diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/Assistant.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/Assistant.java index 415c3aa3325..c9f300b8f94 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/Assistant.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/Assistant.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -10,6 +10,11 @@ * 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. */ + +/* + * IBM OpenAPI SDK Code Generator Version: 99-SNAPSHOT-7cc05500-20201106-154555 + */ + package com.ibm.watson.assistant.v1; import com.google.gson.JsonObject; @@ -20,6 +25,8 @@ import com.ibm.cloud.sdk.core.security.ConfigBasedAuthenticatorFactory; import com.ibm.cloud.sdk.core.service.BaseService; import com.ibm.cloud.sdk.core.util.ResponseConverterUtils; +import com.ibm.watson.assistant.v1.model.BulkClassifyOptions; +import com.ibm.watson.assistant.v1.model.BulkClassifyResponse; import com.ibm.watson.assistant.v1.model.Counterexample; import com.ibm.watson.assistant.v1.model.CounterexampleCollection; import com.ibm.watson.assistant.v1.model.CreateCounterexampleOptions; @@ -85,11 +92,12 @@ import com.ibm.watson.assistant.v1.model.Workspace; import com.ibm.watson.assistant.v1.model.WorkspaceCollection; import com.ibm.watson.common.SdkCommon; +import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; /** - * The IBM Watson™ Assistant service combines machine learning, natural language + * The IBM Watson™ Assistant service combines machine learning, natural language * understanding, and an integrated dialog editor to create conversation flows between your apps and * your users. * @@ -97,70 +105,93 @@ * workspace. * * @version v1 - * @see Assistant + * @see Assistant */ public class Assistant extends BaseService { - private static final String DEFAULT_SERVICE_NAME = "assistant"; + public static final String DEFAULT_SERVICE_NAME = "conversation"; - private static final String DEFAULT_SERVICE_URL = + public static final String DEFAULT_SERVICE_URL = "https://api.us-south.assistant.watson.cloud.ibm.com"; - private String versionDate; + private String version; /** - * Constructs a new `Assistant` client using the DEFAULT_SERVICE_NAME. + * Constructs an instance of the `Assistant` client. The default service name is used to configure + * the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value - * will keep your API calls from failing when the service introduces breaking changes. + * @param version Release date of the API version you want to use. Specify dates in YYYY-MM-DD + * format. The current version is `2020-04-01`. */ - public Assistant(String versionDate) { + public Assistant(String version) { this( - versionDate, + version, DEFAULT_SERVICE_NAME, ConfigBasedAuthenticatorFactory.getAuthenticator(DEFAULT_SERVICE_NAME)); } /** - * Constructs a new `Assistant` client with the DEFAULT_SERVICE_NAME and the specified - * Authenticator. + * Constructs an instance of the `Assistant` client. The default service name and specified + * authenticator are used to configure the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value - * will keep your API calls from failing when the service introduces breaking changes. - * @param authenticator the Authenticator instance to be configured for this service + * @param version Release date of the API version you want to use. Specify dates in YYYY-MM-DD + * format. The current version is `2020-04-01`. + * @param authenticator the {@link Authenticator} instance to be configured for this client */ - public Assistant(String versionDate, Authenticator authenticator) { - this(versionDate, DEFAULT_SERVICE_NAME, authenticator); + public Assistant(String version, Authenticator authenticator) { + this(version, DEFAULT_SERVICE_NAME, authenticator); } /** - * Constructs a new `Assistant` client with the specified serviceName. + * Constructs an instance of the `Assistant` client. The specified service name is used to + * configure the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value - * will keep your API calls from failing when the service introduces breaking changes. - * @param serviceName The name of the service to configure. + * @param version Release date of the API version you want to use. Specify dates in YYYY-MM-DD + * format. The current version is `2020-04-01`. + * @param serviceName the service name to be used when configuring the client instance */ - public Assistant(String versionDate, String serviceName) { - this(versionDate, serviceName, ConfigBasedAuthenticatorFactory.getAuthenticator(serviceName)); + public Assistant(String version, String serviceName) { + this(version, serviceName, ConfigBasedAuthenticatorFactory.getAuthenticator(serviceName)); } /** - * Constructs a new `Assistant` client with the specified Authenticator and serviceName. + * Constructs an instance of the `Assistant` client. The specified service name and authenticator + * are used to configure the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value - * will keep your API calls from failing when the service introduces breaking changes. - * @param serviceName The name of the service to configure. - * @param authenticator the Authenticator instance to be configured for this service + * @param version Release date of the API version you want to use. Specify dates in YYYY-MM-DD + * format. The current version is `2020-04-01`. + * @param serviceName the service name to be used when configuring the client instance + * @param authenticator the {@link Authenticator} instance to be configured for this client */ - public Assistant(String versionDate, String serviceName, Authenticator authenticator) { + public Assistant(String version, String serviceName, Authenticator authenticator) { super(serviceName, authenticator); setServiceUrl(DEFAULT_SERVICE_URL); - com.ibm.cloud.sdk.core.util.Validator.isTrue( - (versionDate != null) && !versionDate.isEmpty(), "version cannot be null."); - this.versionDate = versionDate; + setVersion(version); this.configureService(serviceName); } + /** + * Gets the version. + * + *

Release date of the API version you want to use. Specify dates in YYYY-MM-DD format. The + * current version is `2020-04-01`. + * + * @return the version + */ + public String getVersion() { + return this.version; + } + + /** + * Sets the version. + * + * @param version the new version + */ + public void setVersion(final String version) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(version, "version cannot be empty."); + this.version = version; + } + /** * Get response to user input. * @@ -172,21 +203,22 @@ public Assistant(String versionDate, String serviceName, Authenticator authentic * [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-api-overview). * * @param messageOptions the {@link MessageOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link MessageResponse} + * @return a {@link ServiceCall} with a result of type {@link MessageResponse} */ public ServiceCall message(MessageOptions messageOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull(messageOptions, "messageOptions cannot be null"); - String[] pathSegments = {"v1/workspaces", "message"}; - String[] pathParameters = {messageOptions.workspaceId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", messageOptions.workspaceId()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/workspaces/{workspace_id}/message", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "message"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (messageOptions.nodesVisitedDetails() != null) { builder.query("nodes_visited_details", String.valueOf(messageOptions.nodesVisitedDetails())); } @@ -234,33 +266,36 @@ public ServiceCall message(MessageOptions messageOptions) { * * @param listWorkspacesOptions the {@link ListWorkspacesOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of {@link WorkspaceCollection} + * @return a {@link ServiceCall} with a result of type {@link WorkspaceCollection} */ public ServiceCall listWorkspaces( ListWorkspacesOptions listWorkspacesOptions) { - String[] pathSegments = {"v1/workspaces"}; + if (listWorkspacesOptions == null) { + listWorkspacesOptions = new ListWorkspacesOptions.Builder().build(); + } RequestBuilder builder = - RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); + RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/workspaces")); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "listWorkspaces"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - if (listWorkspacesOptions != null) { - if (listWorkspacesOptions.pageLimit() != null) { - builder.query("page_limit", String.valueOf(listWorkspacesOptions.pageLimit())); - } - if (listWorkspacesOptions.sort() != null) { - builder.query("sort", listWorkspacesOptions.sort()); - } - if (listWorkspacesOptions.cursor() != null) { - builder.query("cursor", listWorkspacesOptions.cursor()); - } - if (listWorkspacesOptions.includeAudit() != null) { - builder.query("include_audit", String.valueOf(listWorkspacesOptions.includeAudit())); - } + builder.query("version", String.valueOf(this.version)); + if (listWorkspacesOptions.pageLimit() != null) { + builder.query("page_limit", String.valueOf(listWorkspacesOptions.pageLimit())); + } + if (listWorkspacesOptions.includeCount() != null) { + builder.query("include_count", String.valueOf(listWorkspacesOptions.includeCount())); + } + if (listWorkspacesOptions.sort() != null) { + builder.query("sort", String.valueOf(listWorkspacesOptions.sort())); + } + if (listWorkspacesOptions.cursor() != null) { + builder.query("cursor", String.valueOf(listWorkspacesOptions.cursor())); + } + if (listWorkspacesOptions.includeAudit() != null) { + builder.query("include_audit", String.valueOf(listWorkspacesOptions.includeAudit())); } ResponseConverter responseConverter = ResponseConverterUtils.getValue( @@ -273,7 +308,7 @@ public ServiceCall listWorkspaces( * *

List the workspaces associated with a Watson Assistant service instance. * - * @return a {@link ServiceCall} with a response type of {@link WorkspaceCollection} + * @return a {@link ServiceCall} with a result of type {@link WorkspaceCollection} */ public ServiceCall listWorkspaces() { return listWorkspaces(null); @@ -287,23 +322,27 @@ public ServiceCall listWorkspaces() { * * @param createWorkspaceOptions the {@link CreateWorkspaceOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of {@link Workspace} + * @return a {@link ServiceCall} with a result of type {@link Workspace} */ public ServiceCall createWorkspace(CreateWorkspaceOptions createWorkspaceOptions) { - String[] pathSegments = {"v1/workspaces"}; + boolean skipBody = false; + if (createWorkspaceOptions == null) { + createWorkspaceOptions = new CreateWorkspaceOptions.Builder().build(); + skipBody = true; + } RequestBuilder builder = - RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); + RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/workspaces")); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "createWorkspace"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - if (createWorkspaceOptions != null) { - if (createWorkspaceOptions.includeAudit() != null) { - builder.query("include_audit", String.valueOf(createWorkspaceOptions.includeAudit())); - } + builder.query("version", String.valueOf(this.version)); + if (createWorkspaceOptions.includeAudit() != null) { + builder.query("include_audit", String.valueOf(createWorkspaceOptions.includeAudit())); + } + if (!skipBody) { final JsonObject contentJson = new JsonObject(); if (createWorkspaceOptions.name() != null) { contentJson.addProperty("name", createWorkspaceOptions.name()); @@ -314,6 +353,18 @@ public ServiceCall createWorkspace(CreateWorkspaceOptions createWorks if (createWorkspaceOptions.language() != null) { contentJson.addProperty("language", createWorkspaceOptions.language()); } + if (createWorkspaceOptions.dialogNodes() != null) { + contentJson.add( + "dialog_nodes", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(createWorkspaceOptions.dialogNodes())); + } + if (createWorkspaceOptions.counterexamples() != null) { + contentJson.add( + "counterexamples", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(createWorkspaceOptions.counterexamples())); + } if (createWorkspaceOptions.metadata() != null) { contentJson.add( "metadata", @@ -329,6 +380,12 @@ public ServiceCall createWorkspace(CreateWorkspaceOptions createWorks com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() .toJsonTree(createWorkspaceOptions.systemSettings())); } + if (createWorkspaceOptions.webhooks() != null) { + contentJson.add( + "webhooks", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(createWorkspaceOptions.webhooks())); + } if (createWorkspaceOptions.intents() != null) { contentJson.add( "intents", @@ -341,24 +398,6 @@ public ServiceCall createWorkspace(CreateWorkspaceOptions createWorks com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() .toJsonTree(createWorkspaceOptions.entities())); } - if (createWorkspaceOptions.dialogNodes() != null) { - contentJson.add( - "dialog_nodes", - com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() - .toJsonTree(createWorkspaceOptions.dialogNodes())); - } - if (createWorkspaceOptions.counterexamples() != null) { - contentJson.add( - "counterexamples", - com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() - .toJsonTree(createWorkspaceOptions.counterexamples())); - } - if (createWorkspaceOptions.webhooks() != null) { - contentJson.add( - "webhooks", - com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() - .toJsonTree(createWorkspaceOptions.webhooks())); - } builder.bodyJson(contentJson); } ResponseConverter responseConverter = @@ -373,7 +412,7 @@ public ServiceCall createWorkspace(CreateWorkspaceOptions createWorks *

Create a workspace based on component objects. You must provide workspace components * defining the content of the new workspace. * - * @return a {@link ServiceCall} with a response type of {@link Workspace} + * @return a {@link ServiceCall} with a result of type {@link Workspace} */ public ServiceCall createWorkspace() { return createWorkspace(null); @@ -385,22 +424,23 @@ public ServiceCall createWorkspace() { *

Get information about a workspace, optionally including all workspace content. * * @param getWorkspaceOptions the {@link GetWorkspaceOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Workspace} + * @return a {@link ServiceCall} with a result of type {@link Workspace} */ public ServiceCall getWorkspace(GetWorkspaceOptions getWorkspaceOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( getWorkspaceOptions, "getWorkspaceOptions cannot be null"); - String[] pathSegments = {"v1/workspaces"}; - String[] pathParameters = {getWorkspaceOptions.workspaceId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", getWorkspaceOptions.workspaceId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/workspaces/{workspace_id}", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "getWorkspace"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (getWorkspaceOptions.export() != null) { builder.query("export", String.valueOf(getWorkspaceOptions.export())); } @@ -408,7 +448,7 @@ public ServiceCall getWorkspace(GetWorkspaceOptions getWorkspaceOptio builder.query("include_audit", String.valueOf(getWorkspaceOptions.includeAudit())); } if (getWorkspaceOptions.sort() != null) { - builder.query("sort", getWorkspaceOptions.sort()); + builder.query("sort", String.valueOf(getWorkspaceOptions.sort())); } ResponseConverter responseConverter = ResponseConverterUtils.getValue( @@ -424,23 +464,24 @@ public ServiceCall getWorkspace(GetWorkspaceOptions getWorkspaceOptio * * @param updateWorkspaceOptions the {@link UpdateWorkspaceOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of {@link Workspace} + * @return a {@link ServiceCall} with a result of type {@link Workspace} */ public ServiceCall updateWorkspace(UpdateWorkspaceOptions updateWorkspaceOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( updateWorkspaceOptions, "updateWorkspaceOptions cannot be null"); - String[] pathSegments = {"v1/workspaces"}; - String[] pathParameters = {updateWorkspaceOptions.workspaceId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", updateWorkspaceOptions.workspaceId()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/workspaces/{workspace_id}", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "updateWorkspace"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (updateWorkspaceOptions.append() != null) { builder.query("append", String.valueOf(updateWorkspaceOptions.append())); } @@ -457,6 +498,18 @@ public ServiceCall updateWorkspace(UpdateWorkspaceOptions updateWorks if (updateWorkspaceOptions.language() != null) { contentJson.addProperty("language", updateWorkspaceOptions.language()); } + if (updateWorkspaceOptions.dialogNodes() != null) { + contentJson.add( + "dialog_nodes", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(updateWorkspaceOptions.dialogNodes())); + } + if (updateWorkspaceOptions.counterexamples() != null) { + contentJson.add( + "counterexamples", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(updateWorkspaceOptions.counterexamples())); + } if (updateWorkspaceOptions.metadata() != null) { contentJson.add( "metadata", @@ -472,6 +525,12 @@ public ServiceCall updateWorkspace(UpdateWorkspaceOptions updateWorks com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() .toJsonTree(updateWorkspaceOptions.systemSettings())); } + if (updateWorkspaceOptions.webhooks() != null) { + contentJson.add( + "webhooks", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(updateWorkspaceOptions.webhooks())); + } if (updateWorkspaceOptions.intents() != null) { contentJson.add( "intents", @@ -484,24 +543,6 @@ public ServiceCall updateWorkspace(UpdateWorkspaceOptions updateWorks com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() .toJsonTree(updateWorkspaceOptions.entities())); } - if (updateWorkspaceOptions.dialogNodes() != null) { - contentJson.add( - "dialog_nodes", - com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() - .toJsonTree(updateWorkspaceOptions.dialogNodes())); - } - if (updateWorkspaceOptions.counterexamples() != null) { - contentJson.add( - "counterexamples", - com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() - .toJsonTree(updateWorkspaceOptions.counterexamples())); - } - if (updateWorkspaceOptions.webhooks() != null) { - contentJson.add( - "webhooks", - com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() - .toJsonTree(updateWorkspaceOptions.webhooks())); - } builder.bodyJson(contentJson); ResponseConverter responseConverter = ResponseConverterUtils.getValue( @@ -516,24 +557,24 @@ public ServiceCall updateWorkspace(UpdateWorkspaceOptions updateWorks * * @param deleteWorkspaceOptions the {@link DeleteWorkspaceOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteWorkspace(DeleteWorkspaceOptions deleteWorkspaceOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( deleteWorkspaceOptions, "deleteWorkspaceOptions cannot be null"); - String[] pathSegments = {"v1/workspaces"}; - String[] pathParameters = {deleteWorkspaceOptions.workspaceId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", deleteWorkspaceOptions.workspaceId()); RequestBuilder builder = RequestBuilder.delete( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/workspaces/{workspace_id}", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "deleteWorkspace"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -544,33 +585,37 @@ public ServiceCall deleteWorkspace(DeleteWorkspaceOptions deleteWorkspaceO *

List the intents for a workspace. * * @param listIntentsOptions the {@link ListIntentsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link IntentCollection} + * @return a {@link ServiceCall} with a result of type {@link IntentCollection} */ public ServiceCall listIntents(ListIntentsOptions listIntentsOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( listIntentsOptions, "listIntentsOptions cannot be null"); - String[] pathSegments = {"v1/workspaces", "intents"}; - String[] pathParameters = {listIntentsOptions.workspaceId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", listIntentsOptions.workspaceId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/workspaces/{workspace_id}/intents", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "listIntents"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (listIntentsOptions.export() != null) { builder.query("export", String.valueOf(listIntentsOptions.export())); } if (listIntentsOptions.pageLimit() != null) { builder.query("page_limit", String.valueOf(listIntentsOptions.pageLimit())); } + if (listIntentsOptions.includeCount() != null) { + builder.query("include_count", String.valueOf(listIntentsOptions.includeCount())); + } if (listIntentsOptions.sort() != null) { - builder.query("sort", listIntentsOptions.sort()); + builder.query("sort", String.valueOf(listIntentsOptions.sort())); } if (listIntentsOptions.cursor() != null) { - builder.query("cursor", listIntentsOptions.cursor()); + builder.query("cursor", String.valueOf(listIntentsOptions.cursor())); } if (listIntentsOptions.includeAudit() != null) { builder.query("include_audit", String.valueOf(listIntentsOptions.includeAudit())); @@ -590,22 +635,23 @@ public ServiceCall listIntents(ListIntentsOptions listIntentsO * workspace](#update-workspace)** method instead. * * @param createIntentOptions the {@link CreateIntentOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Intent} + * @return a {@link ServiceCall} with a result of type {@link Intent} */ public ServiceCall createIntent(CreateIntentOptions createIntentOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( createIntentOptions, "createIntentOptions cannot be null"); - String[] pathSegments = {"v1/workspaces", "intents"}; - String[] pathParameters = {createIntentOptions.workspaceId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", createIntentOptions.workspaceId()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/workspaces/{workspace_id}/intents", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "createIntent"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (createIntentOptions.includeAudit() != null) { builder.query("include_audit", String.valueOf(createIntentOptions.includeAudit())); } @@ -633,22 +679,24 @@ public ServiceCall createIntent(CreateIntentOptions createIntentOptions) *

Get information about an intent, optionally including all intent content. * * @param getIntentOptions the {@link GetIntentOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Intent} + * @return a {@link ServiceCall} with a result of type {@link Intent} */ public ServiceCall getIntent(GetIntentOptions getIntentOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( getIntentOptions, "getIntentOptions cannot be null"); - String[] pathSegments = {"v1/workspaces", "intents"}; - String[] pathParameters = {getIntentOptions.workspaceId(), getIntentOptions.intent()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", getIntentOptions.workspaceId()); + pathParamsMap.put("intent", getIntentOptions.intent()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/workspaces/{workspace_id}/intents/{intent}", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "getIntent"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (getIntentOptions.export() != null) { builder.query("export", String.valueOf(getIntentOptions.export())); } @@ -671,22 +719,24 @@ public ServiceCall getIntent(GetIntentOptions getIntentOptions) { * workspace](#update-workspace)** method instead. * * @param updateIntentOptions the {@link UpdateIntentOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Intent} + * @return a {@link ServiceCall} with a result of type {@link Intent} */ public ServiceCall updateIntent(UpdateIntentOptions updateIntentOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( updateIntentOptions, "updateIntentOptions cannot be null"); - String[] pathSegments = {"v1/workspaces", "intents"}; - String[] pathParameters = {updateIntentOptions.workspaceId(), updateIntentOptions.intent()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", updateIntentOptions.workspaceId()); + pathParamsMap.put("intent", updateIntentOptions.intent()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/workspaces/{workspace_id}/intents/{intent}", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "updateIntent"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (updateIntentOptions.append() != null) { builder.query("append", String.valueOf(updateIntentOptions.append())); } @@ -719,23 +769,24 @@ public ServiceCall updateIntent(UpdateIntentOptions updateIntentOptions) *

Delete an intent from a workspace. * * @param deleteIntentOptions the {@link DeleteIntentOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteIntent(DeleteIntentOptions deleteIntentOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( deleteIntentOptions, "deleteIntentOptions cannot be null"); - String[] pathSegments = {"v1/workspaces", "intents"}; - String[] pathParameters = {deleteIntentOptions.workspaceId(), deleteIntentOptions.intent()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", deleteIntentOptions.workspaceId()); + pathParamsMap.put("intent", deleteIntentOptions.intent()); RequestBuilder builder = RequestBuilder.delete( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/workspaces/{workspace_id}/intents/{intent}", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "deleteIntent"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -746,30 +797,37 @@ public ServiceCall deleteIntent(DeleteIntentOptions deleteIntentOptions) { *

List the user input examples for an intent, optionally including contextual entity mentions. * * @param listExamplesOptions the {@link ListExamplesOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link ExampleCollection} + * @return a {@link ServiceCall} with a result of type {@link ExampleCollection} */ public ServiceCall listExamples(ListExamplesOptions listExamplesOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( listExamplesOptions, "listExamplesOptions cannot be null"); - String[] pathSegments = {"v1/workspaces", "intents", "examples"}; - String[] pathParameters = {listExamplesOptions.workspaceId(), listExamplesOptions.intent()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", listExamplesOptions.workspaceId()); + pathParamsMap.put("intent", listExamplesOptions.intent()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/workspaces/{workspace_id}/intents/{intent}/examples", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "listExamples"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (listExamplesOptions.pageLimit() != null) { builder.query("page_limit", String.valueOf(listExamplesOptions.pageLimit())); } + if (listExamplesOptions.includeCount() != null) { + builder.query("include_count", String.valueOf(listExamplesOptions.includeCount())); + } if (listExamplesOptions.sort() != null) { - builder.query("sort", listExamplesOptions.sort()); + builder.query("sort", String.valueOf(listExamplesOptions.sort())); } if (listExamplesOptions.cursor() != null) { - builder.query("cursor", listExamplesOptions.cursor()); + builder.query("cursor", String.valueOf(listExamplesOptions.cursor())); } if (listExamplesOptions.includeAudit() != null) { builder.query("include_audit", String.valueOf(listExamplesOptions.includeAudit())); @@ -790,22 +848,26 @@ public ServiceCall listExamples(ListExamplesOptions listExamp * * @param createExampleOptions the {@link CreateExampleOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of {@link Example} + * @return a {@link ServiceCall} with a result of type {@link Example} */ public ServiceCall createExample(CreateExampleOptions createExampleOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( createExampleOptions, "createExampleOptions cannot be null"); - String[] pathSegments = {"v1/workspaces", "intents", "examples"}; - String[] pathParameters = {createExampleOptions.workspaceId(), createExampleOptions.intent()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", createExampleOptions.workspaceId()); + pathParamsMap.put("intent", createExampleOptions.intent()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/workspaces/{workspace_id}/intents/{intent}/examples", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "createExample"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (createExampleOptions.includeAudit() != null) { builder.query("include_audit", String.valueOf(createExampleOptions.includeAudit())); } @@ -830,24 +892,27 @@ public ServiceCall createExample(CreateExampleOptions createExampleOpti *

Get information about a user input example. * * @param getExampleOptions the {@link GetExampleOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Example} + * @return a {@link ServiceCall} with a result of type {@link Example} */ public ServiceCall getExample(GetExampleOptions getExampleOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( getExampleOptions, "getExampleOptions cannot be null"); - String[] pathSegments = {"v1/workspaces", "intents", "examples"}; - String[] pathParameters = { - getExampleOptions.workspaceId(), getExampleOptions.intent(), getExampleOptions.text() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", getExampleOptions.workspaceId()); + pathParamsMap.put("intent", getExampleOptions.intent()); + pathParamsMap.put("text", getExampleOptions.text()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/workspaces/{workspace_id}/intents/{intent}/examples/{text}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "getExample"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (getExampleOptions.includeAudit() != null) { builder.query("include_audit", String.valueOf(getExampleOptions.includeAudit())); } @@ -867,24 +932,27 @@ public ServiceCall getExample(GetExampleOptions getExampleOptions) { * * @param updateExampleOptions the {@link UpdateExampleOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of {@link Example} + * @return a {@link ServiceCall} with a result of type {@link Example} */ public ServiceCall updateExample(UpdateExampleOptions updateExampleOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( updateExampleOptions, "updateExampleOptions cannot be null"); - String[] pathSegments = {"v1/workspaces", "intents", "examples"}; - String[] pathParameters = { - updateExampleOptions.workspaceId(), updateExampleOptions.intent(), updateExampleOptions.text() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", updateExampleOptions.workspaceId()); + pathParamsMap.put("intent", updateExampleOptions.intent()); + pathParamsMap.put("text", updateExampleOptions.text()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/workspaces/{workspace_id}/intents/{intent}/examples/{text}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "updateExample"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (updateExampleOptions.includeAudit() != null) { builder.query("include_audit", String.valueOf(updateExampleOptions.includeAudit())); } @@ -912,25 +980,27 @@ public ServiceCall updateExample(UpdateExampleOptions updateExampleOpti * * @param deleteExampleOptions the {@link DeleteExampleOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteExample(DeleteExampleOptions deleteExampleOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( deleteExampleOptions, "deleteExampleOptions cannot be null"); - String[] pathSegments = {"v1/workspaces", "intents", "examples"}; - String[] pathParameters = { - deleteExampleOptions.workspaceId(), deleteExampleOptions.intent(), deleteExampleOptions.text() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", deleteExampleOptions.workspaceId()); + pathParamsMap.put("intent", deleteExampleOptions.intent()); + pathParamsMap.put("text", deleteExampleOptions.text()); RequestBuilder builder = RequestBuilder.delete( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/workspaces/{workspace_id}/intents/{intent}/examples/{text}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "deleteExample"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -943,32 +1013,36 @@ public ServiceCall deleteExample(DeleteExampleOptions deleteExampleOptions * * @param listCounterexamplesOptions the {@link ListCounterexamplesOptions} containing the options * for the call - * @return a {@link ServiceCall} with a response type of {@link CounterexampleCollection} + * @return a {@link ServiceCall} with a result of type {@link CounterexampleCollection} */ public ServiceCall listCounterexamples( ListCounterexamplesOptions listCounterexamplesOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( listCounterexamplesOptions, "listCounterexamplesOptions cannot be null"); - String[] pathSegments = {"v1/workspaces", "counterexamples"}; - String[] pathParameters = {listCounterexamplesOptions.workspaceId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", listCounterexamplesOptions.workspaceId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/workspaces/{workspace_id}/counterexamples", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "listCounterexamples"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (listCounterexamplesOptions.pageLimit() != null) { builder.query("page_limit", String.valueOf(listCounterexamplesOptions.pageLimit())); } + if (listCounterexamplesOptions.includeCount() != null) { + builder.query("include_count", String.valueOf(listCounterexamplesOptions.includeCount())); + } if (listCounterexamplesOptions.sort() != null) { - builder.query("sort", listCounterexamplesOptions.sort()); + builder.query("sort", String.valueOf(listCounterexamplesOptions.sort())); } if (listCounterexamplesOptions.cursor() != null) { - builder.query("cursor", listCounterexamplesOptions.cursor()); + builder.query("cursor", String.valueOf(listCounterexamplesOptions.cursor())); } if (listCounterexamplesOptions.includeAudit() != null) { builder.query("include_audit", String.valueOf(listCounterexamplesOptions.includeAudit())); @@ -990,24 +1064,25 @@ public ServiceCall listCounterexamples( * * @param createCounterexampleOptions the {@link CreateCounterexampleOptions} containing the * options for the call - * @return a {@link ServiceCall} with a response type of {@link Counterexample} + * @return a {@link ServiceCall} with a result of type {@link Counterexample} */ public ServiceCall createCounterexample( CreateCounterexampleOptions createCounterexampleOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( createCounterexampleOptions, "createCounterexampleOptions cannot be null"); - String[] pathSegments = {"v1/workspaces", "counterexamples"}; - String[] pathParameters = {createCounterexampleOptions.workspaceId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", createCounterexampleOptions.workspaceId()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/workspaces/{workspace_id}/counterexamples", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "createCounterexample"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (createCounterexampleOptions.includeAudit() != null) { builder.query("include_audit", String.valueOf(createCounterexampleOptions.includeAudit())); } @@ -1028,26 +1103,28 @@ public ServiceCall createCounterexample( * * @param getCounterexampleOptions the {@link GetCounterexampleOptions} containing the options for * the call - * @return a {@link ServiceCall} with a response type of {@link Counterexample} + * @return a {@link ServiceCall} with a result of type {@link Counterexample} */ public ServiceCall getCounterexample( GetCounterexampleOptions getCounterexampleOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( getCounterexampleOptions, "getCounterexampleOptions cannot be null"); - String[] pathSegments = {"v1/workspaces", "counterexamples"}; - String[] pathParameters = { - getCounterexampleOptions.workspaceId(), getCounterexampleOptions.text() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", getCounterexampleOptions.workspaceId()); + pathParamsMap.put("text", getCounterexampleOptions.text()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/workspaces/{workspace_id}/counterexamples/{text}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "getCounterexample"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (getCounterexampleOptions.includeAudit() != null) { builder.query("include_audit", String.valueOf(getCounterexampleOptions.includeAudit())); } @@ -1065,26 +1142,28 @@ public ServiceCall getCounterexample( * * @param updateCounterexampleOptions the {@link UpdateCounterexampleOptions} containing the * options for the call - * @return a {@link ServiceCall} with a response type of {@link Counterexample} + * @return a {@link ServiceCall} with a result of type {@link Counterexample} */ public ServiceCall updateCounterexample( UpdateCounterexampleOptions updateCounterexampleOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( updateCounterexampleOptions, "updateCounterexampleOptions cannot be null"); - String[] pathSegments = {"v1/workspaces", "counterexamples"}; - String[] pathParameters = { - updateCounterexampleOptions.workspaceId(), updateCounterexampleOptions.text() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", updateCounterexampleOptions.workspaceId()); + pathParamsMap.put("text", updateCounterexampleOptions.text()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/workspaces/{workspace_id}/counterexamples/{text}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "updateCounterexample"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (updateCounterexampleOptions.includeAudit() != null) { builder.query("include_audit", String.valueOf(updateCounterexampleOptions.includeAudit())); } @@ -1107,27 +1186,28 @@ public ServiceCall updateCounterexample( * * @param deleteCounterexampleOptions the {@link DeleteCounterexampleOptions} containing the * options for the call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteCounterexample( DeleteCounterexampleOptions deleteCounterexampleOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( deleteCounterexampleOptions, "deleteCounterexampleOptions cannot be null"); - String[] pathSegments = {"v1/workspaces", "counterexamples"}; - String[] pathParameters = { - deleteCounterexampleOptions.workspaceId(), deleteCounterexampleOptions.text() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", deleteCounterexampleOptions.workspaceId()); + pathParamsMap.put("text", deleteCounterexampleOptions.text()); RequestBuilder builder = RequestBuilder.delete( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/workspaces/{workspace_id}/counterexamples/{text}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "deleteCounterexample"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -1138,33 +1218,37 @@ public ServiceCall deleteCounterexample( *

List the entities for a workspace. * * @param listEntitiesOptions the {@link ListEntitiesOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link EntityCollection} + * @return a {@link ServiceCall} with a result of type {@link EntityCollection} */ public ServiceCall listEntities(ListEntitiesOptions listEntitiesOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( listEntitiesOptions, "listEntitiesOptions cannot be null"); - String[] pathSegments = {"v1/workspaces", "entities"}; - String[] pathParameters = {listEntitiesOptions.workspaceId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", listEntitiesOptions.workspaceId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/workspaces/{workspace_id}/entities", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "listEntities"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (listEntitiesOptions.export() != null) { builder.query("export", String.valueOf(listEntitiesOptions.export())); } if (listEntitiesOptions.pageLimit() != null) { builder.query("page_limit", String.valueOf(listEntitiesOptions.pageLimit())); } + if (listEntitiesOptions.includeCount() != null) { + builder.query("include_count", String.valueOf(listEntitiesOptions.includeCount())); + } if (listEntitiesOptions.sort() != null) { - builder.query("sort", listEntitiesOptions.sort()); + builder.query("sort", String.valueOf(listEntitiesOptions.sort())); } if (listEntitiesOptions.cursor() != null) { - builder.query("cursor", listEntitiesOptions.cursor()); + builder.query("cursor", String.valueOf(listEntitiesOptions.cursor())); } if (listEntitiesOptions.includeAudit() != null) { builder.query("include_audit", String.valueOf(listEntitiesOptions.includeAudit())); @@ -1184,22 +1268,23 @@ public ServiceCall listEntities(ListEntitiesOptions listEntiti * workspace](#update-workspace)** method instead. * * @param createEntityOptions the {@link CreateEntityOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Entity} + * @return a {@link ServiceCall} with a result of type {@link Entity} */ public ServiceCall createEntity(CreateEntityOptions createEntityOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( createEntityOptions, "createEntityOptions cannot be null"); - String[] pathSegments = {"v1/workspaces", "entities"}; - String[] pathParameters = {createEntityOptions.workspaceId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", createEntityOptions.workspaceId()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/workspaces/{workspace_id}/entities", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "createEntity"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (createEntityOptions.includeAudit() != null) { builder.query("include_audit", String.valueOf(createEntityOptions.includeAudit())); } @@ -1236,22 +1321,24 @@ public ServiceCall createEntity(CreateEntityOptions createEntityOptions) *

Get information about an entity, optionally including all entity content. * * @param getEntityOptions the {@link GetEntityOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Entity} + * @return a {@link ServiceCall} with a result of type {@link Entity} */ public ServiceCall getEntity(GetEntityOptions getEntityOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( getEntityOptions, "getEntityOptions cannot be null"); - String[] pathSegments = {"v1/workspaces", "entities"}; - String[] pathParameters = {getEntityOptions.workspaceId(), getEntityOptions.entity()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", getEntityOptions.workspaceId()); + pathParamsMap.put("entity", getEntityOptions.entity()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/workspaces/{workspace_id}/entities/{entity}", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "getEntity"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (getEntityOptions.export() != null) { builder.query("export", String.valueOf(getEntityOptions.export())); } @@ -1274,22 +1361,24 @@ public ServiceCall getEntity(GetEntityOptions getEntityOptions) { * workspace](#update-workspace)** method instead. * * @param updateEntityOptions the {@link UpdateEntityOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Entity} + * @return a {@link ServiceCall} with a result of type {@link Entity} */ public ServiceCall updateEntity(UpdateEntityOptions updateEntityOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( updateEntityOptions, "updateEntityOptions cannot be null"); - String[] pathSegments = {"v1/workspaces", "entities"}; - String[] pathParameters = {updateEntityOptions.workspaceId(), updateEntityOptions.entity()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", updateEntityOptions.workspaceId()); + pathParamsMap.put("entity", updateEntityOptions.entity()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/workspaces/{workspace_id}/entities/{entity}", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "updateEntity"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (updateEntityOptions.append() != null) { builder.query("append", String.valueOf(updateEntityOptions.append())); } @@ -1331,23 +1420,24 @@ public ServiceCall updateEntity(UpdateEntityOptions updateEntityOptions) *

Delete an entity from a workspace, or disable a system entity. * * @param deleteEntityOptions the {@link DeleteEntityOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteEntity(DeleteEntityOptions deleteEntityOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( deleteEntityOptions, "deleteEntityOptions cannot be null"); - String[] pathSegments = {"v1/workspaces", "entities"}; - String[] pathParameters = {deleteEntityOptions.workspaceId(), deleteEntityOptions.entity()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", deleteEntityOptions.workspaceId()); + pathParamsMap.put("entity", deleteEntityOptions.entity()); RequestBuilder builder = RequestBuilder.delete( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/workspaces/{workspace_id}/entities/{entity}", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "deleteEntity"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -1359,23 +1449,27 @@ public ServiceCall deleteEntity(DeleteEntityOptions deleteEntityOptions) { * entity in the context of an intent user input example. * * @param listMentionsOptions the {@link ListMentionsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link EntityMentionCollection} + * @return a {@link ServiceCall} with a result of type {@link EntityMentionCollection} */ public ServiceCall listMentions( ListMentionsOptions listMentionsOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( listMentionsOptions, "listMentionsOptions cannot be null"); - String[] pathSegments = {"v1/workspaces", "entities", "mentions"}; - String[] pathParameters = {listMentionsOptions.workspaceId(), listMentionsOptions.entity()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", listMentionsOptions.workspaceId()); + pathParamsMap.put("entity", listMentionsOptions.entity()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/workspaces/{workspace_id}/entities/{entity}/mentions", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "listMentions"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (listMentionsOptions.export() != null) { builder.query("export", String.valueOf(listMentionsOptions.export())); } @@ -1394,33 +1488,40 @@ public ServiceCall listMentions( *

List the values for an entity. * * @param listValuesOptions the {@link ListValuesOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link ValueCollection} + * @return a {@link ServiceCall} with a result of type {@link ValueCollection} */ public ServiceCall listValues(ListValuesOptions listValuesOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( listValuesOptions, "listValuesOptions cannot be null"); - String[] pathSegments = {"v1/workspaces", "entities", "values"}; - String[] pathParameters = {listValuesOptions.workspaceId(), listValuesOptions.entity()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", listValuesOptions.workspaceId()); + pathParamsMap.put("entity", listValuesOptions.entity()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/workspaces/{workspace_id}/entities/{entity}/values", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "listValues"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (listValuesOptions.export() != null) { builder.query("export", String.valueOf(listValuesOptions.export())); } if (listValuesOptions.pageLimit() != null) { builder.query("page_limit", String.valueOf(listValuesOptions.pageLimit())); } + if (listValuesOptions.includeCount() != null) { + builder.query("include_count", String.valueOf(listValuesOptions.includeCount())); + } if (listValuesOptions.sort() != null) { - builder.query("sort", listValuesOptions.sort()); + builder.query("sort", String.valueOf(listValuesOptions.sort())); } if (listValuesOptions.cursor() != null) { - builder.query("cursor", listValuesOptions.cursor()); + builder.query("cursor", String.valueOf(listValuesOptions.cursor())); } if (listValuesOptions.includeAudit() != null) { builder.query("include_audit", String.valueOf(listValuesOptions.includeAudit())); @@ -1440,22 +1541,26 @@ public ServiceCall listValues(ListValuesOptions listValuesOptio * **[Update entity](#update-entity)** method instead. * * @param createValueOptions the {@link CreateValueOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Value} + * @return a {@link ServiceCall} with a result of type {@link Value} */ public ServiceCall createValue(CreateValueOptions createValueOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( createValueOptions, "createValueOptions cannot be null"); - String[] pathSegments = {"v1/workspaces", "entities", "values"}; - String[] pathParameters = {createValueOptions.workspaceId(), createValueOptions.entity()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", createValueOptions.workspaceId()); + pathParamsMap.put("entity", createValueOptions.entity()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/workspaces/{workspace_id}/entities/{entity}/values", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "createValue"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (createValueOptions.includeAudit() != null) { builder.query("include_audit", String.valueOf(createValueOptions.includeAudit())); } @@ -1495,24 +1600,27 @@ public ServiceCall createValue(CreateValueOptions createValueOptions) { *

Get information about an entity value. * * @param getValueOptions the {@link GetValueOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Value} + * @return a {@link ServiceCall} with a result of type {@link Value} */ public ServiceCall getValue(GetValueOptions getValueOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( getValueOptions, "getValueOptions cannot be null"); - String[] pathSegments = {"v1/workspaces", "entities", "values"}; - String[] pathParameters = { - getValueOptions.workspaceId(), getValueOptions.entity(), getValueOptions.value() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", getValueOptions.workspaceId()); + pathParamsMap.put("entity", getValueOptions.entity()); + pathParamsMap.put("value", getValueOptions.value()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/workspaces/{workspace_id}/entities/{entity}/values/{value}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "getValue"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (getValueOptions.export() != null) { builder.query("export", String.valueOf(getValueOptions.export())); } @@ -1535,24 +1643,27 @@ public ServiceCall getValue(GetValueOptions getValueOptions) { * **[Update entity](#update-entity)** method instead. * * @param updateValueOptions the {@link UpdateValueOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Value} + * @return a {@link ServiceCall} with a result of type {@link Value} */ public ServiceCall updateValue(UpdateValueOptions updateValueOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( updateValueOptions, "updateValueOptions cannot be null"); - String[] pathSegments = {"v1/workspaces", "entities", "values"}; - String[] pathParameters = { - updateValueOptions.workspaceId(), updateValueOptions.entity(), updateValueOptions.value() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", updateValueOptions.workspaceId()); + pathParamsMap.put("entity", updateValueOptions.entity()); + pathParamsMap.put("value", updateValueOptions.value()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/workspaces/{workspace_id}/entities/{entity}/values/{value}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "updateValue"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (updateValueOptions.append() != null) { builder.query("append", String.valueOf(updateValueOptions.append())); } @@ -1597,25 +1708,27 @@ public ServiceCall updateValue(UpdateValueOptions updateValueOptions) { *

Delete a value from an entity. * * @param deleteValueOptions the {@link DeleteValueOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteValue(DeleteValueOptions deleteValueOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( deleteValueOptions, "deleteValueOptions cannot be null"); - String[] pathSegments = {"v1/workspaces", "entities", "values"}; - String[] pathParameters = { - deleteValueOptions.workspaceId(), deleteValueOptions.entity(), deleteValueOptions.value() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", deleteValueOptions.workspaceId()); + pathParamsMap.put("entity", deleteValueOptions.entity()); + pathParamsMap.put("value", deleteValueOptions.value()); RequestBuilder builder = RequestBuilder.delete( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/workspaces/{workspace_id}/entities/{entity}/values/{value}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "deleteValue"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -1626,32 +1739,38 @@ public ServiceCall deleteValue(DeleteValueOptions deleteValueOptions) { *

List the synonyms for an entity value. * * @param listSynonymsOptions the {@link ListSynonymsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link SynonymCollection} + * @return a {@link ServiceCall} with a result of type {@link SynonymCollection} */ public ServiceCall listSynonyms(ListSynonymsOptions listSynonymsOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( listSynonymsOptions, "listSynonymsOptions cannot be null"); - String[] pathSegments = {"v1/workspaces", "entities", "values", "synonyms"}; - String[] pathParameters = { - listSynonymsOptions.workspaceId(), listSynonymsOptions.entity(), listSynonymsOptions.value() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", listSynonymsOptions.workspaceId()); + pathParamsMap.put("entity", listSynonymsOptions.entity()); + pathParamsMap.put("value", listSynonymsOptions.value()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/workspaces/{workspace_id}/entities/{entity}/values/{value}/synonyms", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "listSynonyms"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (listSynonymsOptions.pageLimit() != null) { builder.query("page_limit", String.valueOf(listSynonymsOptions.pageLimit())); } + if (listSynonymsOptions.includeCount() != null) { + builder.query("include_count", String.valueOf(listSynonymsOptions.includeCount())); + } if (listSynonymsOptions.sort() != null) { - builder.query("sort", listSynonymsOptions.sort()); + builder.query("sort", String.valueOf(listSynonymsOptions.sort())); } if (listSynonymsOptions.cursor() != null) { - builder.query("cursor", listSynonymsOptions.cursor()); + builder.query("cursor", String.valueOf(listSynonymsOptions.cursor())); } if (listSynonymsOptions.includeAudit() != null) { builder.query("include_audit", String.valueOf(listSynonymsOptions.includeAudit())); @@ -1672,26 +1791,27 @@ public ServiceCall listSynonyms(ListSynonymsOptions listSynon * * @param createSynonymOptions the {@link CreateSynonymOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of {@link Synonym} + * @return a {@link ServiceCall} with a result of type {@link Synonym} */ public ServiceCall createSynonym(CreateSynonymOptions createSynonymOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( createSynonymOptions, "createSynonymOptions cannot be null"); - String[] pathSegments = {"v1/workspaces", "entities", "values", "synonyms"}; - String[] pathParameters = { - createSynonymOptions.workspaceId(), - createSynonymOptions.entity(), - createSynonymOptions.value() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", createSynonymOptions.workspaceId()); + pathParamsMap.put("entity", createSynonymOptions.entity()); + pathParamsMap.put("value", createSynonymOptions.value()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/workspaces/{workspace_id}/entities/{entity}/values/{value}/synonyms", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "createSynonym"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (createSynonymOptions.includeAudit() != null) { builder.query("include_audit", String.valueOf(createSynonymOptions.includeAudit())); } @@ -1710,27 +1830,28 @@ public ServiceCall createSynonym(CreateSynonymOptions createSynonymOpti *

Get information about a synonym of an entity value. * * @param getSynonymOptions the {@link GetSynonymOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Synonym} + * @return a {@link ServiceCall} with a result of type {@link Synonym} */ public ServiceCall getSynonym(GetSynonymOptions getSynonymOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( getSynonymOptions, "getSynonymOptions cannot be null"); - String[] pathSegments = {"v1/workspaces", "entities", "values", "synonyms"}; - String[] pathParameters = { - getSynonymOptions.workspaceId(), - getSynonymOptions.entity(), - getSynonymOptions.value(), - getSynonymOptions.synonym() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", getSynonymOptions.workspaceId()); + pathParamsMap.put("entity", getSynonymOptions.entity()); + pathParamsMap.put("value", getSynonymOptions.value()); + pathParamsMap.put("synonym", getSynonymOptions.synonym()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/workspaces/{workspace_id}/entities/{entity}/values/{value}/synonyms/{synonym}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "getSynonym"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (getSynonymOptions.includeAudit() != null) { builder.query("include_audit", String.valueOf(getSynonymOptions.includeAudit())); } @@ -1750,27 +1871,28 @@ public ServiceCall getSynonym(GetSynonymOptions getSynonymOptions) { * * @param updateSynonymOptions the {@link UpdateSynonymOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of {@link Synonym} + * @return a {@link ServiceCall} with a result of type {@link Synonym} */ public ServiceCall updateSynonym(UpdateSynonymOptions updateSynonymOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( updateSynonymOptions, "updateSynonymOptions cannot be null"); - String[] pathSegments = {"v1/workspaces", "entities", "values", "synonyms"}; - String[] pathParameters = { - updateSynonymOptions.workspaceId(), - updateSynonymOptions.entity(), - updateSynonymOptions.value(), - updateSynonymOptions.synonym() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", updateSynonymOptions.workspaceId()); + pathParamsMap.put("entity", updateSynonymOptions.entity()); + pathParamsMap.put("value", updateSynonymOptions.value()); + pathParamsMap.put("synonym", updateSynonymOptions.synonym()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/workspaces/{workspace_id}/entities/{entity}/values/{value}/synonyms/{synonym}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "updateSynonym"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (updateSynonymOptions.includeAudit() != null) { builder.query("include_audit", String.valueOf(updateSynonymOptions.includeAudit())); } @@ -1792,28 +1914,28 @@ public ServiceCall updateSynonym(UpdateSynonymOptions updateSynonymOpti * * @param deleteSynonymOptions the {@link DeleteSynonymOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteSynonym(DeleteSynonymOptions deleteSynonymOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( deleteSynonymOptions, "deleteSynonymOptions cannot be null"); - String[] pathSegments = {"v1/workspaces", "entities", "values", "synonyms"}; - String[] pathParameters = { - deleteSynonymOptions.workspaceId(), - deleteSynonymOptions.entity(), - deleteSynonymOptions.value(), - deleteSynonymOptions.synonym() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", deleteSynonymOptions.workspaceId()); + pathParamsMap.put("entity", deleteSynonymOptions.entity()); + pathParamsMap.put("value", deleteSynonymOptions.value()); + pathParamsMap.put("synonym", deleteSynonymOptions.synonym()); RequestBuilder builder = RequestBuilder.delete( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/workspaces/{workspace_id}/entities/{entity}/values/{value}/synonyms/{synonym}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "deleteSynonym"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -1825,32 +1947,36 @@ public ServiceCall deleteSynonym(DeleteSynonymOptions deleteSynonymOptions * * @param listDialogNodesOptions the {@link ListDialogNodesOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of {@link DialogNodeCollection} + * @return a {@link ServiceCall} with a result of type {@link DialogNodeCollection} */ public ServiceCall listDialogNodes( ListDialogNodesOptions listDialogNodesOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( listDialogNodesOptions, "listDialogNodesOptions cannot be null"); - String[] pathSegments = {"v1/workspaces", "dialog_nodes"}; - String[] pathParameters = {listDialogNodesOptions.workspaceId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", listDialogNodesOptions.workspaceId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/workspaces/{workspace_id}/dialog_nodes", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "listDialogNodes"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (listDialogNodesOptions.pageLimit() != null) { builder.query("page_limit", String.valueOf(listDialogNodesOptions.pageLimit())); } + if (listDialogNodesOptions.includeCount() != null) { + builder.query("include_count", String.valueOf(listDialogNodesOptions.includeCount())); + } if (listDialogNodesOptions.sort() != null) { - builder.query("sort", listDialogNodesOptions.sort()); + builder.query("sort", String.valueOf(listDialogNodesOptions.sort())); } if (listDialogNodesOptions.cursor() != null) { - builder.query("cursor", listDialogNodesOptions.cursor()); + builder.query("cursor", String.valueOf(listDialogNodesOptions.cursor())); } if (listDialogNodesOptions.includeAudit() != null) { builder.query("include_audit", String.valueOf(listDialogNodesOptions.includeAudit())); @@ -1871,23 +1997,24 @@ public ServiceCall listDialogNodes( * * @param createDialogNodeOptions the {@link CreateDialogNodeOptions} containing the options for * the call - * @return a {@link ServiceCall} with a response type of {@link DialogNode} + * @return a {@link ServiceCall} with a result of type {@link DialogNode} */ public ServiceCall createDialogNode(CreateDialogNodeOptions createDialogNodeOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( createDialogNodeOptions, "createDialogNodeOptions cannot be null"); - String[] pathSegments = {"v1/workspaces", "dialog_nodes"}; - String[] pathParameters = {createDialogNodeOptions.workspaceId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", createDialogNodeOptions.workspaceId()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/workspaces/{workspace_id}/dialog_nodes", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "createDialogNode"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (createDialogNodeOptions.includeAudit() != null) { builder.query("include_audit", String.valueOf(createDialogNodeOptions.includeAudit())); } @@ -1977,24 +2104,26 @@ public ServiceCall createDialogNode(CreateDialogNodeOptions createDi * * @param getDialogNodeOptions the {@link GetDialogNodeOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of {@link DialogNode} + * @return a {@link ServiceCall} with a result of type {@link DialogNode} */ public ServiceCall getDialogNode(GetDialogNodeOptions getDialogNodeOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( getDialogNodeOptions, "getDialogNodeOptions cannot be null"); - String[] pathSegments = {"v1/workspaces", "dialog_nodes"}; - String[] pathParameters = { - getDialogNodeOptions.workspaceId(), getDialogNodeOptions.dialogNode() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", getDialogNodeOptions.workspaceId()); + pathParamsMap.put("dialog_node", getDialogNodeOptions.dialogNode()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/workspaces/{workspace_id}/dialog_nodes/{dialog_node}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "getDialogNode"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (getDialogNodeOptions.includeAudit() != null) { builder.query("include_audit", String.valueOf(getDialogNodeOptions.includeAudit())); } @@ -2014,25 +2143,27 @@ public ServiceCall getDialogNode(GetDialogNodeOptions getDialogNodeO * * @param updateDialogNodeOptions the {@link UpdateDialogNodeOptions} containing the options for * the call - * @return a {@link ServiceCall} with a response type of {@link DialogNode} + * @return a {@link ServiceCall} with a result of type {@link DialogNode} */ public ServiceCall updateDialogNode(UpdateDialogNodeOptions updateDialogNodeOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( updateDialogNodeOptions, "updateDialogNodeOptions cannot be null"); - String[] pathSegments = {"v1/workspaces", "dialog_nodes"}; - String[] pathParameters = { - updateDialogNodeOptions.workspaceId(), updateDialogNodeOptions.dialogNode() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", updateDialogNodeOptions.workspaceId()); + pathParamsMap.put("dialog_node", updateDialogNodeOptions.dialogNode()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/workspaces/{workspace_id}/dialog_nodes/{dialog_node}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "updateDialogNode"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (updateDialogNodeOptions.includeAudit() != null) { builder.query("include_audit", String.valueOf(updateDialogNodeOptions.includeAudit())); } @@ -2124,26 +2255,27 @@ public ServiceCall updateDialogNode(UpdateDialogNodeOptions updateDi * * @param deleteDialogNodeOptions the {@link DeleteDialogNodeOptions} containing the options for * the call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteDialogNode(DeleteDialogNodeOptions deleteDialogNodeOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( deleteDialogNodeOptions, "deleteDialogNodeOptions cannot be null"); - String[] pathSegments = {"v1/workspaces", "dialog_nodes"}; - String[] pathParameters = { - deleteDialogNodeOptions.workspaceId(), deleteDialogNodeOptions.dialogNode() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", deleteDialogNodeOptions.workspaceId()); + pathParamsMap.put("dialog_node", deleteDialogNodeOptions.dialogNode()); RequestBuilder builder = RequestBuilder.delete( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/workspaces/{workspace_id}/dialog_nodes/{dialog_node}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "deleteDialogNode"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -2154,33 +2286,34 @@ public ServiceCall deleteDialogNode(DeleteDialogNodeOptions deleteDialogNo *

List the events from the log of a specific workspace. * * @param listLogsOptions the {@link ListLogsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link LogCollection} + * @return a {@link ServiceCall} with a result of type {@link LogCollection} */ public ServiceCall listLogs(ListLogsOptions listLogsOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( listLogsOptions, "listLogsOptions cannot be null"); - String[] pathSegments = {"v1/workspaces", "logs"}; - String[] pathParameters = {listLogsOptions.workspaceId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", listLogsOptions.workspaceId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/workspaces/{workspace_id}/logs", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "listLogs"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (listLogsOptions.sort() != null) { - builder.query("sort", listLogsOptions.sort()); + builder.query("sort", String.valueOf(listLogsOptions.sort())); } if (listLogsOptions.filter() != null) { - builder.query("filter", listLogsOptions.filter()); + builder.query("filter", String.valueOf(listLogsOptions.filter())); } if (listLogsOptions.pageLimit() != null) { builder.query("page_limit", String.valueOf(listLogsOptions.pageLimit())); } if (listLogsOptions.cursor() != null) { - builder.query("cursor", listLogsOptions.cursor()); + builder.query("cursor", String.valueOf(listLogsOptions.cursor())); } ResponseConverter responseConverter = ResponseConverterUtils.getValue( @@ -2194,29 +2327,28 @@ public ServiceCall listLogs(ListLogsOptions listLogsOptions) { *

List the events from the logs of all workspaces in the service instance. * * @param listAllLogsOptions the {@link ListAllLogsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link LogCollection} + * @return a {@link ServiceCall} with a result of type {@link LogCollection} */ public ServiceCall listAllLogs(ListAllLogsOptions listAllLogsOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( listAllLogsOptions, "listAllLogsOptions cannot be null"); - String[] pathSegments = {"v1/logs"}; RequestBuilder builder = - RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); + RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/logs")); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "listAllLogs"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - builder.query("filter", listAllLogsOptions.filter()); + builder.query("version", String.valueOf(this.version)); + builder.query("filter", String.valueOf(listAllLogsOptions.filter())); if (listAllLogsOptions.sort() != null) { - builder.query("sort", listAllLogsOptions.sort()); + builder.query("sort", String.valueOf(listAllLogsOptions.sort())); } if (listAllLogsOptions.pageLimit() != null) { builder.query("page_limit", String.valueOf(listAllLogsOptions.pageLimit())); } if (listAllLogsOptions.cursor() != null) { - builder.query("cursor", listAllLogsOptions.cursor()); + builder.query("cursor", String.valueOf(listAllLogsOptions.cursor())); } ResponseConverter responseConverter = ResponseConverterUtils.getValue( @@ -2237,23 +2369,63 @@ public ServiceCall listAllLogs(ListAllLogsOptions listAllLogsOpti * * @param deleteUserDataOptions the {@link DeleteUserDataOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteUserData(DeleteUserDataOptions deleteUserDataOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( deleteUserDataOptions, "deleteUserDataOptions cannot be null"); - String[] pathSegments = {"v1/user_data"}; RequestBuilder builder = - RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); + RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/user_data")); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "deleteUserData"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - builder.query("customer_id", deleteUserDataOptions.customerId()); + builder.query("version", String.valueOf(this.version)); + builder.query("customer_id", String.valueOf(deleteUserDataOptions.customerId())); ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } + + /** + * Identify intents and entities in multiple user utterances. + * + *

Send multiple user inputs to a workspace in a single request and receive information about + * the intents and entities recognized in each input. This method is useful for testing and + * comparing the performance of different workspaces. + * + *

This method is available only with Premium plans. + * + * @param bulkClassifyOptions the {@link BulkClassifyOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link BulkClassifyResponse} + */ + public ServiceCall bulkClassify(BulkClassifyOptions bulkClassifyOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + bulkClassifyOptions, "bulkClassifyOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("workspace_id", bulkClassifyOptions.workspaceId()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/workspaces/{workspace_id}/bulk_classify", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v1", "bulkClassify"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + final JsonObject contentJson = new JsonObject(); + if (bulkClassifyOptions.input() != null) { + contentJson.add( + "input", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(bulkClassifyOptions.input())); + } + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } } diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/BulkClassifyOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/BulkClassifyOptions.java new file mode 100644 index 00000000000..03dcbebfd2b --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/BulkClassifyOptions.java @@ -0,0 +1,131 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.ArrayList; +import java.util.List; + +/** The bulkClassify options. */ +public class BulkClassifyOptions extends GenericModel { + + protected String workspaceId; + protected List input; + + /** Builder. */ + public static class Builder { + private String workspaceId; + private List input; + + private Builder(BulkClassifyOptions bulkClassifyOptions) { + this.workspaceId = bulkClassifyOptions.workspaceId; + this.input = bulkClassifyOptions.input; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param workspaceId the workspaceId + */ + public Builder(String workspaceId) { + this.workspaceId = workspaceId; + } + + /** + * Builds a BulkClassifyOptions. + * + * @return the new BulkClassifyOptions instance + */ + public BulkClassifyOptions build() { + return new BulkClassifyOptions(this); + } + + /** + * Adds an input to input. + * + * @param input the new input + * @return the BulkClassifyOptions builder + */ + public Builder addInput(BulkClassifyUtterance input) { + com.ibm.cloud.sdk.core.util.Validator.notNull(input, "input cannot be null"); + if (this.input == null) { + this.input = new ArrayList(); + } + this.input.add(input); + return this; + } + + /** + * Set the workspaceId. + * + * @param workspaceId the workspaceId + * @return the BulkClassifyOptions builder + */ + public Builder workspaceId(String workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + /** + * Set the input. Existing input will be replaced. + * + * @param input the input + * @return the BulkClassifyOptions builder + */ + public Builder input(List input) { + this.input = input; + return this; + } + } + + protected BulkClassifyOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.workspaceId, "workspaceId cannot be empty"); + workspaceId = builder.workspaceId; + input = builder.input; + } + + /** + * New builder. + * + * @return a BulkClassifyOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the workspaceId. + * + *

Unique identifier of the workspace. + * + * @return the workspaceId + */ + public String workspaceId() { + return workspaceId; + } + + /** + * Gets the input. + * + *

An array of input utterances to classify. + * + * @return the input + */ + public List input() { + return input; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/BulkClassifyOutput.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/BulkClassifyOutput.java new file mode 100644 index 00000000000..0a581efde99 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/BulkClassifyOutput.java @@ -0,0 +1,57 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** BulkClassifyOutput. */ +public class BulkClassifyOutput extends GenericModel { + + protected BulkClassifyUtterance input; + protected List entities; + protected List intents; + + /** + * Gets the input. + * + *

The user input utterance to classify. + * + * @return the input + */ + public BulkClassifyUtterance getInput() { + return input; + } + + /** + * Gets the entities. + * + *

An array of entities identified in the utterance. + * + * @return the entities + */ + public List getEntities() { + return entities; + } + + /** + * Gets the intents. + * + *

An array of intents recognized in the utterance. + * + * @return the intents + */ + public List getIntents() { + return intents; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/SystemResponse.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/BulkClassifyResponse.java similarity index 55% rename from assistant/src/main/java/com/ibm/watson/assistant/v1/model/SystemResponse.java rename to assistant/src/main/java/com/ibm/watson/assistant/v1/model/BulkClassifyResponse.java index cebffe9dd30..2ab28e463e7 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/SystemResponse.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/BulkClassifyResponse.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -12,13 +12,23 @@ */ package com.ibm.watson.assistant.v1.model; -import com.google.gson.reflect.TypeToken; -import com.ibm.cloud.sdk.core.service.model.DynamicModel; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; -/** For internal use only. */ -public class SystemResponse extends DynamicModel { +/** BulkClassifyResponse. */ +public class BulkClassifyResponse extends GenericModel { - public SystemResponse() { - super(new TypeToken() {}); + protected List output; + + /** + * Gets the output. + * + *

An array of objects that contain classification information for the submitted input + * utterances. + * + * @return the output + */ + public List getOutput() { + return output; } } diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/BulkClassifyUtterance.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/BulkClassifyUtterance.java new file mode 100644 index 00000000000..d7180e09c7c --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/BulkClassifyUtterance.java @@ -0,0 +1,87 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The user input utterance to classify. */ +public class BulkClassifyUtterance extends GenericModel { + + protected String text; + + /** Builder. */ + public static class Builder { + private String text; + + private Builder(BulkClassifyUtterance bulkClassifyUtterance) { + this.text = bulkClassifyUtterance.text; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param text the text + */ + public Builder(String text) { + this.text = text; + } + + /** + * Builds a BulkClassifyUtterance. + * + * @return the new BulkClassifyUtterance instance + */ + public BulkClassifyUtterance build() { + return new BulkClassifyUtterance(this); + } + + /** + * Set the text. + * + * @param text the text + * @return the BulkClassifyUtterance builder + */ + public Builder text(String text) { + this.text = text; + return this; + } + } + + protected BulkClassifyUtterance(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.text, "text cannot be null"); + text = builder.text; + } + + /** + * New builder. + * + * @return a BulkClassifyUtterance builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the text. + * + *

The text of the input utterance. + * + * @return the text + */ + public String text() { + return text; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CaptureGroup.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CaptureGroup.java index 0dc407dd7e5..05833f49dde 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CaptureGroup.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CaptureGroup.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -47,7 +47,7 @@ public Builder(String group) { /** * Builds a CaptureGroup. * - * @return the captureGroup + * @return the new CaptureGroup instance */ public CaptureGroup build() { return new CaptureGroup(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Context.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Context.java index a551e971482..dcd7cbb5204 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Context.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Context.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -15,6 +15,8 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.reflect.TypeToken; import com.ibm.cloud.sdk.core.service.model.DynamicModel; +import java.util.HashMap; +import java.util.Map; /** * State information for the conversation. To maintain state, include the context from the previous @@ -26,7 +28,7 @@ public class Context extends DynamicModel { protected String conversationId; @SerializedName("system") - protected SystemResponse system; + protected Map system; @SerializedName("metadata") protected MessageContextMetadata metadata; @@ -35,6 +37,99 @@ public Context() { super(new TypeToken() {}); } + /** Builder. */ + public static class Builder { + private String conversationId; + private Map system; + private MessageContextMetadata metadata; + private Map dynamicProperties; + + private Builder(Context context) { + this.conversationId = context.conversationId; + this.system = context.system; + this.metadata = context.metadata; + this.dynamicProperties = context.getProperties(); + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a Context. + * + * @return the new Context instance + */ + public Context build() { + return new Context(this); + } + + /** + * Set the conversationId. + * + * @param conversationId the conversationId + * @return the Context builder + */ + public Builder conversationId(String conversationId) { + this.conversationId = conversationId; + return this; + } + + /** + * Set the system. + * + * @param system the system + * @return the Context builder + */ + public Builder system(Map system) { + this.system = system; + return this; + } + + /** + * Set the metadata. + * + * @param metadata the metadata + * @return the Context builder + */ + public Builder metadata(MessageContextMetadata metadata) { + this.metadata = metadata; + return this; + } + + /** + * Add an arbitrary property. + * + * @param name the name of the property to add + * @param value the value of the property to add + * @return the Context builder + */ + public Builder add(String name, Object value) { + com.ibm.cloud.sdk.core.util.Validator.notNull(name, "name cannot be null"); + if (this.dynamicProperties == null) { + this.dynamicProperties = new HashMap(); + } + this.dynamicProperties.put(name, value); + return this; + } + } + + protected Context(Builder builder) { + super(new TypeToken() {}); + conversationId = builder.conversationId; + system = builder.system; + metadata = builder.metadata; + this.setProperties(builder.dynamicProperties); + } + + /** + * New builder. + * + * @return a Context builder + */ + public Builder newBuilder() { + return new Builder(this); + } + /** * Gets the conversationId. * @@ -62,7 +157,7 @@ public void setConversationId(final String conversationId) { * * @return the system */ - public SystemResponse getSystem() { + public Map getSystem() { return this.system; } @@ -71,7 +166,7 @@ public SystemResponse getSystem() { * * @param system the new system */ - public void setSystem(final SystemResponse system) { + public void setSystem(final Map system) { this.system = system; } diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Counterexample.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Counterexample.java index a17983c74b9..45e05f67998 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Counterexample.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Counterexample.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -25,13 +25,9 @@ public class Counterexample extends GenericModel { /** Builder. */ public static class Builder { private String text; - private Date created; - private Date updated; private Builder(Counterexample counterexample) { this.text = counterexample.text; - this.created = counterexample.created; - this.updated = counterexample.updated; } /** Instantiates a new builder. */ @@ -49,7 +45,7 @@ public Builder(String text) { /** * Builds a Counterexample. * - * @return the counterexample + * @return the new Counterexample instance */ public Counterexample build() { return new Counterexample(this); @@ -65,35 +61,11 @@ public Builder text(String text) { this.text = text; return this; } - - /** - * Set the created. - * - * @param created the created - * @return the Counterexample builder - */ - public Builder created(Date created) { - this.created = created; - return this; - } - - /** - * Set the updated. - * - * @param updated the updated - * @return the Counterexample builder - */ - public Builder updated(Date updated) { - this.updated = updated; - return this; - } } protected Counterexample(Builder builder) { com.ibm.cloud.sdk.core.util.Validator.notNull(builder.text, "text cannot be null"); text = builder.text; - created = builder.created; - updated = builder.updated; } /** diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CounterexampleCollection.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CounterexampleCollection.java index fb392216208..db0f6b1134d 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CounterexampleCollection.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CounterexampleCollection.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateCounterexampleOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateCounterexampleOptions.java index 1fc5016b44c..308eb48e368 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateCounterexampleOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateCounterexampleOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -50,7 +50,7 @@ public Builder(String workspaceId, String text) { /** * Builds a CreateCounterexampleOptions. * - * @return the createCounterexampleOptions + * @return the new CreateCounterexampleOptions instance */ public CreateCounterexampleOptions build() { return new CreateCounterexampleOptions(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateDialogNodeOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateDialogNodeOptions.java index c15c96b61ef..df4854bf56f 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateDialogNodeOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateDialogNodeOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -95,7 +95,7 @@ public interface DigressOutSlots { protected String parent; protected String previousSibling; protected DialogNodeOutput output; - protected Map context; + protected DialogNodeContext context; protected Map metadata; protected DialogNodeNextStep nextStep; protected String title; @@ -119,7 +119,7 @@ public static class Builder { private String parent; private String previousSibling; private DialogNodeOutput output; - private Map context; + private DialogNodeContext context; private Map metadata; private DialogNodeNextStep nextStep; private String title; @@ -175,7 +175,7 @@ public Builder(String workspaceId, String dialogNode) { /** * Builds a CreateDialogNodeOptions. * - * @return the createDialogNodeOptions + * @return the new CreateDialogNodeOptions instance */ public CreateDialogNodeOptions build() { return new CreateDialogNodeOptions(this); @@ -279,7 +279,7 @@ public Builder output(DialogNodeOutput output) { * @param context the context * @return the CreateDialogNodeOptions builder */ - public Builder context(Map context) { + public Builder context(DialogNodeContext context) { this.context = context; return this; } @@ -583,7 +583,7 @@ public DialogNodeOutput output() { * * @return the context */ - public Map context() { + public DialogNodeContext context() { return context; } diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateEntity.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateEntity.java index 67ee1ce481c..2abf8c90eb3 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateEntity.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateEntity.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -39,8 +39,6 @@ public static class Builder { private String description; private Map metadata; private Boolean fuzzyMatch; - private Date created; - private Date updated; private List values; private Builder(CreateEntity createEntity) { @@ -48,8 +46,6 @@ private Builder(CreateEntity createEntity) { this.description = createEntity.description; this.metadata = createEntity.metadata; this.fuzzyMatch = createEntity.fuzzyMatch; - this.created = createEntity.created; - this.updated = createEntity.updated; this.values = createEntity.values; } @@ -68,7 +64,7 @@ public Builder(String entity) { /** * Builds a CreateEntity. * - * @return the createEntity + * @return the new CreateEntity instance */ public CreateEntity build() { return new CreateEntity(this); @@ -133,28 +129,6 @@ public Builder fuzzyMatch(Boolean fuzzyMatch) { return this; } - /** - * Set the created. - * - * @param created the created - * @return the CreateEntity builder - */ - public Builder created(Date created) { - this.created = created; - return this; - } - - /** - * Set the updated. - * - * @param updated the updated - * @return the CreateEntity builder - */ - public Builder updated(Date updated) { - this.updated = updated; - return this; - } - /** * Set the values. Existing values will be replaced. * @@ -173,8 +147,6 @@ protected CreateEntity(Builder builder) { description = builder.description; metadata = builder.metadata; fuzzyMatch = builder.fuzzyMatch; - created = builder.created; - updated = builder.updated; values = builder.values; } diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateEntityOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateEntityOptions.java index 1cbffa00701..b51a5434cfe 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateEntityOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateEntityOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -65,7 +65,7 @@ public Builder(String workspaceId, String entity) { /** * Builds a CreateEntityOptions. * - * @return the createEntityOptions + * @return the new CreateEntityOptions instance */ public CreateEntityOptions build() { return new CreateEntityOptions(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateExampleOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateExampleOptions.java index c047424c0ac..f844c6c89c6 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateExampleOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateExampleOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -60,7 +60,7 @@ public Builder(String workspaceId, String intent, String text) { /** * Builds a CreateExampleOptions. * - * @return the createExampleOptions + * @return the new CreateExampleOptions instance */ public CreateExampleOptions build() { return new CreateExampleOptions(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateIntent.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateIntent.java index 85081fb59c8..25cc9634edd 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateIntent.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateIntent.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -30,15 +30,11 @@ public class CreateIntent extends GenericModel { public static class Builder { private String intent; private String description; - private Date created; - private Date updated; private List examples; private Builder(CreateIntent createIntent) { this.intent = createIntent.intent; this.description = createIntent.description; - this.created = createIntent.created; - this.updated = createIntent.updated; this.examples = createIntent.examples; } @@ -57,7 +53,7 @@ public Builder(String intent) { /** * Builds a CreateIntent. * - * @return the createIntent + * @return the new CreateIntent instance */ public CreateIntent build() { return new CreateIntent(this); @@ -100,28 +96,6 @@ public Builder description(String description) { return this; } - /** - * Set the created. - * - * @param created the created - * @return the CreateIntent builder - */ - public Builder created(Date created) { - this.created = created; - return this; - } - - /** - * Set the updated. - * - * @param updated the updated - * @return the CreateIntent builder - */ - public Builder updated(Date updated) { - this.updated = updated; - return this; - } - /** * Set the examples. Existing examples will be replaced. * @@ -138,8 +112,6 @@ protected CreateIntent(Builder builder) { com.ibm.cloud.sdk.core.util.Validator.notNull(builder.intent, "intent cannot be null"); intent = builder.intent; description = builder.description; - created = builder.created; - updated = builder.updated; examples = builder.examples; } diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateIntentOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateIntentOptions.java index dfa3b21ee44..6e1ba6a7ce3 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateIntentOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateIntentOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -58,7 +58,7 @@ public Builder(String workspaceId, String intent) { /** * Builds a CreateIntentOptions. * - * @return the createIntentOptions + * @return the new CreateIntentOptions instance */ public CreateIntentOptions build() { return new CreateIntentOptions(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateSynonymOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateSynonymOptions.java index b54d24b6adc..4afb35b8cab 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateSynonymOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateSynonymOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -60,7 +60,7 @@ public Builder(String workspaceId, String entity, String value, String synonym) /** * Builds a CreateSynonymOptions. * - * @return the createSynonymOptions + * @return the new CreateSynonymOptions instance */ public CreateSynonymOptions build() { return new CreateSynonymOptions(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateValue.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateValue.java index c1e41e39953..817759c228e 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateValue.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateValue.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -44,8 +44,6 @@ public static class Builder { private String type; private List synonyms; private List patterns; - private Date created; - private Date updated; private Builder(CreateValue createValue) { this.value = createValue.value; @@ -53,8 +51,6 @@ private Builder(CreateValue createValue) { this.type = createValue.type; this.synonyms = createValue.synonyms; this.patterns = createValue.patterns; - this.created = createValue.created; - this.updated = createValue.updated; } /** Instantiates a new builder. */ @@ -72,7 +68,7 @@ public Builder(String value) { /** * Builds a CreateValue. * - * @return the createValue + * @return the new CreateValue instance */ public CreateValue build() { return new CreateValue(this); @@ -162,28 +158,6 @@ public Builder patterns(List patterns) { this.patterns = patterns; return this; } - - /** - * Set the created. - * - * @param created the created - * @return the CreateValue builder - */ - public Builder created(Date created) { - this.created = created; - return this; - } - - /** - * Set the updated. - * - * @param updated the updated - * @return the CreateValue builder - */ - public Builder updated(Date updated) { - this.updated = updated; - return this; - } } protected CreateValue(Builder builder) { @@ -193,8 +167,6 @@ protected CreateValue(Builder builder) { type = builder.type; synonyms = builder.synonyms; patterns = builder.patterns; - created = builder.created; - updated = builder.updated; } /** diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateValueOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateValueOptions.java index c6ae6ece55d..8071abe0abf 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateValueOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateValueOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -78,7 +78,7 @@ public Builder(String workspaceId, String entity, String value) { /** * Builds a CreateValueOptions. * - * @return the createValueOptions + * @return the new CreateValueOptions instance */ public CreateValueOptions build() { return new CreateValueOptions(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateWorkspaceOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateWorkspaceOptions.java index 57724df5a02..08c1b208268 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateWorkspaceOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateWorkspaceOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -23,14 +23,14 @@ public class CreateWorkspaceOptions extends GenericModel { protected String name; protected String description; protected String language; + protected List dialogNodes; + protected List counterexamples; protected Map metadata; protected Boolean learningOptOut; protected WorkspaceSystemSettings systemSettings; + protected List webhooks; protected List intents; protected List entities; - protected List dialogNodes; - protected List counterexamples; - protected List webhooks; protected Boolean includeAudit; /** Builder. */ @@ -38,28 +38,28 @@ public static class Builder { private String name; private String description; private String language; + private List dialogNodes; + private List counterexamples; private Map metadata; private Boolean learningOptOut; private WorkspaceSystemSettings systemSettings; + private List webhooks; private List intents; private List entities; - private List dialogNodes; - private List counterexamples; - private List webhooks; private Boolean includeAudit; private Builder(CreateWorkspaceOptions createWorkspaceOptions) { this.name = createWorkspaceOptions.name; this.description = createWorkspaceOptions.description; this.language = createWorkspaceOptions.language; + this.dialogNodes = createWorkspaceOptions.dialogNodes; + this.counterexamples = createWorkspaceOptions.counterexamples; this.metadata = createWorkspaceOptions.metadata; this.learningOptOut = createWorkspaceOptions.learningOptOut; this.systemSettings = createWorkspaceOptions.systemSettings; + this.webhooks = createWorkspaceOptions.webhooks; this.intents = createWorkspaceOptions.intents; this.entities = createWorkspaceOptions.entities; - this.dialogNodes = createWorkspaceOptions.dialogNodes; - this.counterexamples = createWorkspaceOptions.counterexamples; - this.webhooks = createWorkspaceOptions.webhooks; this.includeAudit = createWorkspaceOptions.includeAudit; } @@ -69,42 +69,12 @@ public Builder() {} /** * Builds a CreateWorkspaceOptions. * - * @return the createWorkspaceOptions + * @return the new CreateWorkspaceOptions instance */ public CreateWorkspaceOptions build() { return new CreateWorkspaceOptions(this); } - /** - * Adds an intent to intents. - * - * @param intent the new intent - * @return the CreateWorkspaceOptions builder - */ - public Builder addIntent(CreateIntent intent) { - com.ibm.cloud.sdk.core.util.Validator.notNull(intent, "intent cannot be null"); - if (this.intents == null) { - this.intents = new ArrayList(); - } - this.intents.add(intent); - return this; - } - - /** - * Adds an entity to entities. - * - * @param entity the new entity - * @return the CreateWorkspaceOptions builder - */ - public Builder addEntity(CreateEntity entity) { - com.ibm.cloud.sdk.core.util.Validator.notNull(entity, "entity cannot be null"); - if (this.entities == null) { - this.entities = new ArrayList(); - } - this.entities.add(entity); - return this; - } - /** * Adds an dialogNode to dialogNodes. * @@ -151,6 +121,36 @@ public Builder addWebhooks(Webhook webhooks) { return this; } + /** + * Adds an intent to intents. + * + * @param intent the new intent + * @return the CreateWorkspaceOptions builder + */ + public Builder addIntent(CreateIntent intent) { + com.ibm.cloud.sdk.core.util.Validator.notNull(intent, "intent cannot be null"); + if (this.intents == null) { + this.intents = new ArrayList(); + } + this.intents.add(intent); + return this; + } + + /** + * Adds an entity to entities. + * + * @param entity the new entity + * @return the CreateWorkspaceOptions builder + */ + public Builder addEntity(CreateEntity entity) { + com.ibm.cloud.sdk.core.util.Validator.notNull(entity, "entity cannot be null"); + if (this.entities == null) { + this.entities = new ArrayList(); + } + this.entities.add(entity); + return this; + } + /** * Set the name. * @@ -185,90 +185,90 @@ public Builder language(String language) { } /** - * Set the metadata. + * Set the dialogNodes. Existing dialogNodes will be replaced. * - * @param metadata the metadata + * @param dialogNodes the dialogNodes * @return the CreateWorkspaceOptions builder */ - public Builder metadata(Map metadata) { - this.metadata = metadata; + public Builder dialogNodes(List dialogNodes) { + this.dialogNodes = dialogNodes; return this; } /** - * Set the learningOptOut. + * Set the counterexamples. Existing counterexamples will be replaced. * - * @param learningOptOut the learningOptOut + * @param counterexamples the counterexamples * @return the CreateWorkspaceOptions builder */ - public Builder learningOptOut(Boolean learningOptOut) { - this.learningOptOut = learningOptOut; + public Builder counterexamples(List counterexamples) { + this.counterexamples = counterexamples; return this; } /** - * Set the systemSettings. + * Set the metadata. * - * @param systemSettings the systemSettings + * @param metadata the metadata * @return the CreateWorkspaceOptions builder */ - public Builder systemSettings(WorkspaceSystemSettings systemSettings) { - this.systemSettings = systemSettings; + public Builder metadata(Map metadata) { + this.metadata = metadata; return this; } /** - * Set the intents. Existing intents will be replaced. + * Set the learningOptOut. * - * @param intents the intents + * @param learningOptOut the learningOptOut * @return the CreateWorkspaceOptions builder */ - public Builder intents(List intents) { - this.intents = intents; + public Builder learningOptOut(Boolean learningOptOut) { + this.learningOptOut = learningOptOut; return this; } /** - * Set the entities. Existing entities will be replaced. + * Set the systemSettings. * - * @param entities the entities + * @param systemSettings the systemSettings * @return the CreateWorkspaceOptions builder */ - public Builder entities(List entities) { - this.entities = entities; + public Builder systemSettings(WorkspaceSystemSettings systemSettings) { + this.systemSettings = systemSettings; return this; } /** - * Set the dialogNodes. Existing dialogNodes will be replaced. + * Set the webhooks. Existing webhooks will be replaced. * - * @param dialogNodes the dialogNodes + * @param webhooks the webhooks * @return the CreateWorkspaceOptions builder */ - public Builder dialogNodes(List dialogNodes) { - this.dialogNodes = dialogNodes; + public Builder webhooks(List webhooks) { + this.webhooks = webhooks; return this; } /** - * Set the counterexamples. Existing counterexamples will be replaced. + * Set the intents. Existing intents will be replaced. * - * @param counterexamples the counterexamples + * @param intents the intents * @return the CreateWorkspaceOptions builder */ - public Builder counterexamples(List counterexamples) { - this.counterexamples = counterexamples; + public Builder intents(List intents) { + this.intents = intents; return this; } /** - * Set the webhooks. Existing webhooks will be replaced. + * Set the entities. Existing entities will be replaced. * - * @param webhooks the webhooks + * @param entities the entities * @return the CreateWorkspaceOptions builder */ - public Builder webhooks(List webhooks) { - this.webhooks = webhooks; + public Builder entities(List entities) { + this.entities = entities; return this; } @@ -288,14 +288,14 @@ protected CreateWorkspaceOptions(Builder builder) { name = builder.name; description = builder.description; language = builder.language; + dialogNodes = builder.dialogNodes; + counterexamples = builder.counterexamples; metadata = builder.metadata; learningOptOut = builder.learningOptOut; systemSettings = builder.systemSettings; + webhooks = builder.webhooks; intents = builder.intents; entities = builder.entities; - dialogNodes = builder.dialogNodes; - counterexamples = builder.counterexamples; - webhooks = builder.webhooks; includeAudit = builder.includeAudit; } @@ -343,6 +343,28 @@ public String language() { return language; } + /** + * Gets the dialogNodes. + * + *

An array of objects describing the dialog nodes in the workspace. + * + * @return the dialogNodes + */ + public List dialogNodes() { + return dialogNodes; + } + + /** + * Gets the counterexamples. + * + *

An array of objects defining input examples that have been marked as irrelevant input. + * + * @return the counterexamples + */ + public List counterexamples() { + return counterexamples; + } + /** * Gets the metadata. * @@ -378,6 +400,15 @@ public WorkspaceSystemSettings systemSettings() { return systemSettings; } + /** + * Gets the webhooks. + * + * @return the webhooks + */ + public List webhooks() { + return webhooks; + } + /** * Gets the intents. * @@ -400,37 +431,6 @@ public List entities() { return entities; } - /** - * Gets the dialogNodes. - * - *

An array of objects describing the dialog nodes in the workspace. - * - * @return the dialogNodes - */ - public List dialogNodes() { - return dialogNodes; - } - - /** - * Gets the counterexamples. - * - *

An array of objects defining input examples that have been marked as irrelevant input. - * - * @return the counterexamples - */ - public List counterexamples() { - return counterexamples; - } - - /** - * Gets the webhooks. - * - * @return the webhooks - */ - public List webhooks() { - return webhooks; - } - /** * Gets the includeAudit. * diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteCounterexampleOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteCounterexampleOptions.java index 79db402031a..5d2b3cdb084 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteCounterexampleOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteCounterexampleOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -47,7 +47,7 @@ public Builder(String workspaceId, String text) { /** * Builds a DeleteCounterexampleOptions. * - * @return the deleteCounterexampleOptions + * @return the new DeleteCounterexampleOptions instance */ public DeleteCounterexampleOptions build() { return new DeleteCounterexampleOptions(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteDialogNodeOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteDialogNodeOptions.java index cc57a0a9a81..56c89aa42b4 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteDialogNodeOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteDialogNodeOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -47,7 +47,7 @@ public Builder(String workspaceId, String dialogNode) { /** * Builds a DeleteDialogNodeOptions. * - * @return the deleteDialogNodeOptions + * @return the new DeleteDialogNodeOptions instance */ public DeleteDialogNodeOptions build() { return new DeleteDialogNodeOptions(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteEntityOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteEntityOptions.java index 7574ad3d761..96996ca2055 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteEntityOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteEntityOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -47,7 +47,7 @@ public Builder(String workspaceId, String entity) { /** * Builds a DeleteEntityOptions. * - * @return the deleteEntityOptions + * @return the new DeleteEntityOptions instance */ public DeleteEntityOptions build() { return new DeleteEntityOptions(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteExampleOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteExampleOptions.java index 8a411395f72..f8dfe6fcb63 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteExampleOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteExampleOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -52,7 +52,7 @@ public Builder(String workspaceId, String intent, String text) { /** * Builds a DeleteExampleOptions. * - * @return the deleteExampleOptions + * @return the new DeleteExampleOptions instance */ public DeleteExampleOptions build() { return new DeleteExampleOptions(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteIntentOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteIntentOptions.java index 5a1593ed408..940e13a51ab 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteIntentOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteIntentOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -47,7 +47,7 @@ public Builder(String workspaceId, String intent) { /** * Builds a DeleteIntentOptions. * - * @return the deleteIntentOptions + * @return the new DeleteIntentOptions instance */ public DeleteIntentOptions build() { return new DeleteIntentOptions(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteSynonymOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteSynonymOptions.java index f6f3bda5fc9..0b4c6d2ccbb 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteSynonymOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteSynonymOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -57,7 +57,7 @@ public Builder(String workspaceId, String entity, String value, String synonym) /** * Builds a DeleteSynonymOptions. * - * @return the deleteSynonymOptions + * @return the new DeleteSynonymOptions instance */ public DeleteSynonymOptions build() { return new DeleteSynonymOptions(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteUserDataOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteUserDataOptions.java index ceebc25ba19..a4b4a492dec 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteUserDataOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteUserDataOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -42,7 +42,7 @@ public Builder(String customerId) { /** * Builds a DeleteUserDataOptions. * - * @return the deleteUserDataOptions + * @return the new DeleteUserDataOptions instance */ public DeleteUserDataOptions build() { return new DeleteUserDataOptions(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteValueOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteValueOptions.java index aeeca3b07c9..3b64a933c01 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteValueOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteValueOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -52,7 +52,7 @@ public Builder(String workspaceId, String entity, String value) { /** * Builds a DeleteValueOptions. * - * @return the deleteValueOptions + * @return the new DeleteValueOptions instance */ public DeleteValueOptions build() { return new DeleteValueOptions(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteWorkspaceOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteWorkspaceOptions.java index 054d796a42e..b952efbe46e 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteWorkspaceOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteWorkspaceOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -42,7 +42,7 @@ public Builder(String workspaceId) { /** * Builds a DeleteWorkspaceOptions. * - * @return the deleteWorkspaceOptions + * @return the new DeleteWorkspaceOptions instance */ public DeleteWorkspaceOptions build() { return new DeleteWorkspaceOptions(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNode.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNode.java index 7f0d86c5bb1..45c8505b39d 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNode.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNode.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -101,7 +101,7 @@ public interface DigressOutSlots { protected String previousSibling; protected DialogNodeOutput output; - protected Map context; + protected DialogNodeContext context; protected Map metadata; @SerializedName("next_step") @@ -143,7 +143,7 @@ public static class Builder { private String parent; private String previousSibling; private DialogNodeOutput output; - private Map context; + private DialogNodeContext context; private Map metadata; private DialogNodeNextStep nextStep; private String title; @@ -156,9 +156,6 @@ public static class Builder { private String digressOutSlots; private String userLabel; private Boolean disambiguationOptOut; - private Boolean disabled; - private Date created; - private Date updated; private Builder(DialogNode dialogNode) { this.dialogNode = dialogNode.dialogNode; @@ -180,9 +177,6 @@ private Builder(DialogNode dialogNode) { this.digressOutSlots = dialogNode.digressOutSlots; this.userLabel = dialogNode.userLabel; this.disambiguationOptOut = dialogNode.disambiguationOptOut; - this.disabled = dialogNode.disabled; - this.created = dialogNode.created; - this.updated = dialogNode.updated; } /** Instantiates a new builder. */ @@ -200,7 +194,7 @@ public Builder(String dialogNode) { /** * Builds a DialogNode. * - * @return the dialogNode + * @return the new DialogNode instance */ public DialogNode build() { return new DialogNode(this); @@ -293,7 +287,7 @@ public Builder output(DialogNodeOutput output) { * @param context the context * @return the DialogNode builder */ - public Builder context(Map context) { + public Builder context(DialogNodeContext context) { this.context = context; return this; } @@ -429,39 +423,6 @@ public Builder disambiguationOptOut(Boolean disambiguationOptOut) { this.disambiguationOptOut = disambiguationOptOut; return this; } - - /** - * Set the disabled. - * - * @param disabled the disabled - * @return the DialogNode builder - */ - public Builder disabled(Boolean disabled) { - this.disabled = disabled; - return this; - } - - /** - * Set the created. - * - * @param created the created - * @return the DialogNode builder - */ - public Builder created(Date created) { - this.created = created; - return this; - } - - /** - * Set the updated. - * - * @param updated the updated - * @return the DialogNode builder - */ - public Builder updated(Date updated) { - this.updated = updated; - return this; - } } protected DialogNode(Builder builder) { @@ -485,9 +446,6 @@ protected DialogNode(Builder builder) { digressOutSlots = builder.digressOutSlots; userLabel = builder.userLabel; disambiguationOptOut = builder.disambiguationOptOut; - disabled = builder.disabled; - created = builder.created; - updated = builder.updated; } /** @@ -578,7 +536,7 @@ public DialogNodeOutput output() { * * @return the context */ - public Map context() { + public DialogNodeContext context() { return context; } diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeAction.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeAction.java index 5b55a47f859..9dec9205168 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeAction.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeAction.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -75,7 +75,7 @@ public Builder(String name, String resultVariable) { /** * Builds a DialogNodeAction. * - * @return the dialogNodeAction + * @return the new DialogNodeAction instance */ public DialogNodeAction build() { return new DialogNodeAction(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeCollection.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeCollection.java index e63e13ffcca..89cdf6cd31b 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeCollection.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeCollection.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeContext.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeContext.java new file mode 100644 index 00000000000..8085178d0dd --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeContext.java @@ -0,0 +1,115 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.ibm.cloud.sdk.core.service.model.DynamicModel; +import java.util.HashMap; +import java.util.Map; + +/** The context for the dialog node. */ +public class DialogNodeContext extends DynamicModel { + + @SerializedName("integrations") + protected Map> integrations; + + public DialogNodeContext() { + super(new TypeToken() {}); + } + + /** Builder. */ + public static class Builder { + private Map> integrations; + private Map dynamicProperties; + + private Builder(DialogNodeContext dialogNodeContext) { + this.integrations = dialogNodeContext.integrations; + this.dynamicProperties = dialogNodeContext.getProperties(); + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a DialogNodeContext. + * + * @return the new DialogNodeContext instance + */ + public DialogNodeContext build() { + return new DialogNodeContext(this); + } + + /** + * Set the integrations. + * + * @param integrations the integrations + * @return the DialogNodeContext builder + */ + public Builder integrations(Map> integrations) { + this.integrations = integrations; + return this; + } + + /** + * Add an arbitrary property. + * + * @param name the name of the property to add + * @param value the value of the property to add + * @return the DialogNodeContext builder + */ + public Builder add(String name, Object value) { + com.ibm.cloud.sdk.core.util.Validator.notNull(name, "name cannot be null"); + if (this.dynamicProperties == null) { + this.dynamicProperties = new HashMap(); + } + this.dynamicProperties.put(name, value); + return this; + } + } + + protected DialogNodeContext(Builder builder) { + super(new TypeToken() {}); + integrations = builder.integrations; + this.setProperties(builder.dynamicProperties); + } + + /** + * New builder. + * + * @return a DialogNodeContext builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the integrations. + * + *

Context data intended for specific integrations. + * + * @return the integrations + */ + public Map> getIntegrations() { + return this.integrations; + } + + /** + * Sets the integrations. + * + * @param integrations the new integrations + */ + public void setIntegrations(final Map> integrations) { + this.integrations = integrations; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeNextStep.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeNextStep.java index d780d2263fa..3d68c6b1082 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeNextStep.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeNextStep.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -90,7 +90,7 @@ public Builder(String behavior) { /** * Builds a DialogNodeNextStep. * - * @return the dialogNodeNextStep + * @return the new DialogNodeNextStep instance */ public DialogNodeNextStep build() { return new DialogNodeNextStep(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutput.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutput.java index c30c8d77101..b15bdfb7126 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutput.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutput.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -15,7 +15,10 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.reflect.TypeToken; import com.ibm.cloud.sdk.core.service.model.DynamicModel; +import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * The output of the dialog node. For more information about how to specify dialog node output, see @@ -27,6 +30,9 @@ public class DialogNodeOutput extends DynamicModel { @SerializedName("generic") protected List generic; + @SerializedName("integrations") + protected Map> integrations; + @SerializedName("modifiers") protected DialogNodeOutputModifiers modifiers; @@ -34,6 +40,114 @@ public DialogNodeOutput() { super(new TypeToken() {}); } + /** Builder. */ + public static class Builder { + private List generic; + private Map> integrations; + private DialogNodeOutputModifiers modifiers; + private Map dynamicProperties; + + private Builder(DialogNodeOutput dialogNodeOutput) { + this.generic = dialogNodeOutput.generic; + this.integrations = dialogNodeOutput.integrations; + this.modifiers = dialogNodeOutput.modifiers; + this.dynamicProperties = dialogNodeOutput.getProperties(); + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a DialogNodeOutput. + * + * @return the new DialogNodeOutput instance + */ + public DialogNodeOutput build() { + return new DialogNodeOutput(this); + } + + /** + * Adds an generic to generic. + * + * @param generic the new generic + * @return the DialogNodeOutput builder + */ + public Builder addGeneric(DialogNodeOutputGeneric generic) { + com.ibm.cloud.sdk.core.util.Validator.notNull(generic, "generic cannot be null"); + if (this.generic == null) { + this.generic = new ArrayList(); + } + this.generic.add(generic); + return this; + } + + /** + * Set the generic. Existing generic will be replaced. + * + * @param generic the generic + * @return the DialogNodeOutput builder + */ + public Builder generic(List generic) { + this.generic = generic; + return this; + } + + /** + * Set the integrations. + * + * @param integrations the integrations + * @return the DialogNodeOutput builder + */ + public Builder integrations(Map> integrations) { + this.integrations = integrations; + return this; + } + + /** + * Set the modifiers. + * + * @param modifiers the modifiers + * @return the DialogNodeOutput builder + */ + public Builder modifiers(DialogNodeOutputModifiers modifiers) { + this.modifiers = modifiers; + return this; + } + + /** + * Add an arbitrary property. + * + * @param name the name of the property to add + * @param value the value of the property to add + * @return the DialogNodeOutput builder + */ + public Builder add(String name, Object value) { + com.ibm.cloud.sdk.core.util.Validator.notNull(name, "name cannot be null"); + if (this.dynamicProperties == null) { + this.dynamicProperties = new HashMap(); + } + this.dynamicProperties.put(name, value); + return this; + } + } + + protected DialogNodeOutput(Builder builder) { + super(new TypeToken() {}); + generic = builder.generic; + integrations = builder.integrations; + modifiers = builder.modifiers; + this.setProperties(builder.dynamicProperties); + } + + /** + * New builder. + * + * @return a DialogNodeOutput builder + */ + public Builder newBuilder() { + return new Builder(this); + } + /** * Gets the generic. * @@ -54,6 +168,27 @@ public void setGeneric(final List generic) { this.generic = generic; } + /** + * Gets the integrations. + * + *

Output intended for specific integrations. For more information, see the + * [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-dialog-responses-json). + * + * @return the integrations + */ + public Map> getIntegrations() { + return this.integrations; + } + + /** + * Sets the integrations. + * + * @param integrations the new integrations + */ + public void setIntegrations(final Map> integrations) { + this.integrations = integrations; + } + /** * Gets the modifiers. * diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputConnectToAgentTransferInfo.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputConnectToAgentTransferInfo.java new file mode 100644 index 00000000000..296c231f6a0 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputConnectToAgentTransferInfo.java @@ -0,0 +1,77 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.Map; + +/** Routing or other contextual information to be used by target service desk systems. */ +public class DialogNodeOutputConnectToAgentTransferInfo extends GenericModel { + + protected Map> target; + + /** Builder. */ + public static class Builder { + private Map> target; + + private Builder( + DialogNodeOutputConnectToAgentTransferInfo dialogNodeOutputConnectToAgentTransferInfo) { + this.target = dialogNodeOutputConnectToAgentTransferInfo.target; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a DialogNodeOutputConnectToAgentTransferInfo. + * + * @return the new DialogNodeOutputConnectToAgentTransferInfo instance + */ + public DialogNodeOutputConnectToAgentTransferInfo build() { + return new DialogNodeOutputConnectToAgentTransferInfo(this); + } + + /** + * Set the target. + * + * @param target the target + * @return the DialogNodeOutputConnectToAgentTransferInfo builder + */ + public Builder target(Map> target) { + this.target = target; + return this; + } + } + + protected DialogNodeOutputConnectToAgentTransferInfo(Builder builder) { + target = builder.target; + } + + /** + * New builder. + * + * @return a DialogNodeOutputConnectToAgentTransferInfo builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the target. + * + * @return the target + */ + public Map> target() { + return target; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGeneric.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGeneric.java index 4d96e89f987..aa36d306d20 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGeneric.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGeneric.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -14,37 +14,50 @@ import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; -import java.util.ArrayList; import java.util.List; -/** DialogNodeOutputGeneric. */ +/** + * DialogNodeOutputGeneric. + * + *

Classes which extend this class: - DialogNodeOutputGenericDialogNodeOutputResponseTypeText - + * DialogNodeOutputGenericDialogNodeOutputResponseTypePause - + * DialogNodeOutputGenericDialogNodeOutputResponseTypeImage - + * DialogNodeOutputGenericDialogNodeOutputResponseTypeOption - + * DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent - + * DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill + */ public class DialogNodeOutputGeneric extends GenericModel { + @SuppressWarnings("unused") + protected static String discriminatorPropertyName = "response_type"; + + protected static java.util.Map> discriminatorMapping; + + static { + discriminatorMapping = new java.util.HashMap<>(); + discriminatorMapping.put( + "connect_to_agent", + DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent.class); + discriminatorMapping.put( + "image", DialogNodeOutputGenericDialogNodeOutputResponseTypeImage.class); + discriminatorMapping.put( + "option", DialogNodeOutputGenericDialogNodeOutputResponseTypeOption.class); + discriminatorMapping.put( + "pause", DialogNodeOutputGenericDialogNodeOutputResponseTypePause.class); + discriminatorMapping.put( + "search_skill", DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill.class); + discriminatorMapping.put("text", DialogNodeOutputGenericDialogNodeOutputResponseTypeText.class); + } /** * The type of response returned by the dialog node. The specified response type must be supported * by the client application or channel. - * - *

**Note:** The **search_skill** response type is used only by the v2 runtime API. */ public interface ResponseType { /** text. */ String TEXT = "text"; - /** pause. */ - String PAUSE = "pause"; - /** image. */ - String IMAGE = "image"; - /** option. */ - String OPTION = "option"; - /** connect_to_agent. */ - String CONNECT_TO_AGENT = "connect_to_agent"; - /** search_skill. */ - String SEARCH_SKILL = "search_skill"; } - /** - * How a response is selected from the list, if more than one response is specified. Valid only - * when **response_type**=`text`. - */ + /** How a response is selected from the list, if more than one response is specified. */ public interface SelectionPolicy { /** sequential. */ String SEQUENTIAL = "sequential"; @@ -54,10 +67,7 @@ public interface SelectionPolicy { String MULTILINE = "multiline"; } - /** - * The preferred type of control to display, if supported by the channel. Valid only when - * **response_type**=`option`. - */ + /** The preferred type of control to display, if supported by the channel. */ public interface Preference { /** dropdown. */ String DROPDOWN = "dropdown"; @@ -65,7 +75,7 @@ public interface Preference { String BUTTON = "button"; } - /** The type of the search query. Required when **response_type**=`search_skill`. */ + /** The type of the search query. */ public interface QueryType { /** natural_language. */ String NATURAL_LANGUAGE = "natural_language"; @@ -93,6 +103,15 @@ public interface QueryType { @SerializedName("message_to_human_agent") protected String messageToHumanAgent; + @SerializedName("agent_available") + protected String agentAvailable; + + @SerializedName("agent_unavailable") + protected String agentUnavailable; + + @SerializedName("transfer_info") + protected DialogNodeOutputConnectToAgentTransferInfo transferInfo; + protected String query; @SerializedName("query_type") @@ -103,301 +122,7 @@ public interface QueryType { @SerializedName("discovery_version") protected String discoveryVersion; - /** Builder. */ - public static class Builder { - private String responseType; - private List values; - private String selectionPolicy; - private String delimiter; - private Long time; - private Boolean typing; - private String source; - private String title; - private String description; - private String preference; - private List options; - private String messageToHumanAgent; - private String query; - private String queryType; - private String filter; - private String discoveryVersion; - - private Builder(DialogNodeOutputGeneric dialogNodeOutputGeneric) { - this.responseType = dialogNodeOutputGeneric.responseType; - this.values = dialogNodeOutputGeneric.values; - this.selectionPolicy = dialogNodeOutputGeneric.selectionPolicy; - this.delimiter = dialogNodeOutputGeneric.delimiter; - this.time = dialogNodeOutputGeneric.time; - this.typing = dialogNodeOutputGeneric.typing; - this.source = dialogNodeOutputGeneric.source; - this.title = dialogNodeOutputGeneric.title; - this.description = dialogNodeOutputGeneric.description; - this.preference = dialogNodeOutputGeneric.preference; - this.options = dialogNodeOutputGeneric.options; - this.messageToHumanAgent = dialogNodeOutputGeneric.messageToHumanAgent; - this.query = dialogNodeOutputGeneric.query; - this.queryType = dialogNodeOutputGeneric.queryType; - this.filter = dialogNodeOutputGeneric.filter; - this.discoveryVersion = dialogNodeOutputGeneric.discoveryVersion; - } - - /** Instantiates a new builder. */ - public Builder() {} - - /** - * Instantiates a new builder with required properties. - * - * @param responseType the responseType - */ - public Builder(String responseType) { - this.responseType = responseType; - } - - /** - * Builds a DialogNodeOutputGeneric. - * - * @return the dialogNodeOutputGeneric - */ - public DialogNodeOutputGeneric build() { - return new DialogNodeOutputGeneric(this); - } - - /** - * Adds an values to values. - * - * @param values the new values - * @return the DialogNodeOutputGeneric builder - */ - public Builder addValues(DialogNodeOutputTextValuesElement values) { - com.ibm.cloud.sdk.core.util.Validator.notNull(values, "values cannot be null"); - if (this.values == null) { - this.values = new ArrayList(); - } - this.values.add(values); - return this; - } - - /** - * Adds an options to options. - * - * @param options the new options - * @return the DialogNodeOutputGeneric builder - */ - public Builder addOptions(DialogNodeOutputOptionsElement options) { - com.ibm.cloud.sdk.core.util.Validator.notNull(options, "options cannot be null"); - if (this.options == null) { - this.options = new ArrayList(); - } - this.options.add(options); - return this; - } - - /** - * Set the responseType. - * - * @param responseType the responseType - * @return the DialogNodeOutputGeneric builder - */ - public Builder responseType(String responseType) { - this.responseType = responseType; - return this; - } - - /** - * Set the values. Existing values will be replaced. - * - * @param values the values - * @return the DialogNodeOutputGeneric builder - */ - public Builder values(List values) { - this.values = values; - return this; - } - - /** - * Set the selectionPolicy. - * - * @param selectionPolicy the selectionPolicy - * @return the DialogNodeOutputGeneric builder - */ - public Builder selectionPolicy(String selectionPolicy) { - this.selectionPolicy = selectionPolicy; - return this; - } - - /** - * Set the delimiter. - * - * @param delimiter the delimiter - * @return the DialogNodeOutputGeneric builder - */ - public Builder delimiter(String delimiter) { - this.delimiter = delimiter; - return this; - } - - /** - * Set the time. - * - * @param time the time - * @return the DialogNodeOutputGeneric builder - */ - public Builder time(long time) { - this.time = time; - return this; - } - - /** - * Set the typing. - * - * @param typing the typing - * @return the DialogNodeOutputGeneric builder - */ - public Builder typing(Boolean typing) { - this.typing = typing; - return this; - } - - /** - * Set the source. - * - * @param source the source - * @return the DialogNodeOutputGeneric builder - */ - public Builder source(String source) { - this.source = source; - return this; - } - - /** - * Set the title. - * - * @param title the title - * @return the DialogNodeOutputGeneric builder - */ - public Builder title(String title) { - this.title = title; - return this; - } - - /** - * Set the description. - * - * @param description the description - * @return the DialogNodeOutputGeneric builder - */ - public Builder description(String description) { - this.description = description; - return this; - } - - /** - * Set the preference. - * - * @param preference the preference - * @return the DialogNodeOutputGeneric builder - */ - public Builder preference(String preference) { - this.preference = preference; - return this; - } - - /** - * Set the options. Existing options will be replaced. - * - * @param options the options - * @return the DialogNodeOutputGeneric builder - */ - public Builder options(List options) { - this.options = options; - return this; - } - - /** - * Set the messageToHumanAgent. - * - * @param messageToHumanAgent the messageToHumanAgent - * @return the DialogNodeOutputGeneric builder - */ - public Builder messageToHumanAgent(String messageToHumanAgent) { - this.messageToHumanAgent = messageToHumanAgent; - return this; - } - - /** - * Set the query. - * - * @param query the query - * @return the DialogNodeOutputGeneric builder - */ - public Builder query(String query) { - this.query = query; - return this; - } - - /** - * Set the queryType. - * - * @param queryType the queryType - * @return the DialogNodeOutputGeneric builder - */ - public Builder queryType(String queryType) { - this.queryType = queryType; - return this; - } - - /** - * Set the filter. - * - * @param filter the filter - * @return the DialogNodeOutputGeneric builder - */ - public Builder filter(String filter) { - this.filter = filter; - return this; - } - - /** - * Set the discoveryVersion. - * - * @param discoveryVersion the discoveryVersion - * @return the DialogNodeOutputGeneric builder - */ - public Builder discoveryVersion(String discoveryVersion) { - this.discoveryVersion = discoveryVersion; - return this; - } - } - - protected DialogNodeOutputGeneric(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull( - builder.responseType, "responseType cannot be null"); - responseType = builder.responseType; - values = builder.values; - selectionPolicy = builder.selectionPolicy; - delimiter = builder.delimiter; - time = builder.time; - typing = builder.typing; - source = builder.source; - title = builder.title; - description = builder.description; - preference = builder.preference; - options = builder.options; - messageToHumanAgent = builder.messageToHumanAgent; - query = builder.query; - queryType = builder.queryType; - filter = builder.filter; - discoveryVersion = builder.discoveryVersion; - } - - /** - * New builder. - * - * @return a DialogNodeOutputGeneric builder - */ - public Builder newBuilder() { - return new Builder(this); - } + protected DialogNodeOutputGeneric() {} /** * Gets the responseType. @@ -405,8 +130,6 @@ public Builder newBuilder() { *

The type of response returned by the dialog node. The specified response type must be * supported by the client application or channel. * - *

**Note:** The **search_skill** response type is used only by the v2 runtime API. - * * @return the responseType */ public String responseType() { @@ -416,8 +139,7 @@ public String responseType() { /** * Gets the values. * - *

A list of one or more objects defining text responses. Required when - * **response_type**=`text`. + *

A list of one or more objects defining text responses. * * @return the values */ @@ -428,8 +150,7 @@ public List values() { /** * Gets the selectionPolicy. * - *

How a response is selected from the list, if more than one response is specified. Valid only - * when **response_type**=`text`. + *

How a response is selected from the list, if more than one response is specified. * * @return the selectionPolicy */ @@ -451,8 +172,7 @@ public String delimiter() { /** * Gets the time. * - *

How long to pause, in milliseconds. The valid values are from 0 to 10000. Valid only when - * **response_type**=`pause`. + *

How long to pause, in milliseconds. The valid values are from 0 to 10000. * * @return the time */ @@ -464,7 +184,7 @@ public Long time() { * Gets the typing. * *

Whether to send a "user is typing" event during the pause. Ignored if the channel does not - * support this event. Valid only when **response_type**=`pause`. + * support this event. * * @return the typing */ @@ -475,7 +195,7 @@ public Boolean typing() { /** * Gets the source. * - *

The URL of the image. Required when **response_type**=`image`. + *

The URL of the image. * * @return the source */ @@ -486,8 +206,7 @@ public String source() { /** * Gets the title. * - *

An optional title to show before the response. Valid only when **response_type**=`image` or - * `option`. + *

An optional title to show before the response. * * @return the title */ @@ -498,8 +217,7 @@ public String title() { /** * Gets the description. * - *

An optional description to show with the response. Valid only when **response_type**=`image` - * or `option`. + *

An optional description to show with the response. * * @return the description */ @@ -510,8 +228,7 @@ public String description() { /** * Gets the preference. * - *

The preferred type of control to display, if supported by the channel. Valid only when - * **response_type**=`option`. + *

The preferred type of control to display, if supported by the channel. * * @return the preference */ @@ -523,7 +240,7 @@ public String preference() { * Gets the options. * *

An array of objects describing the options from which the user can choose. You can include - * up to 20 options. Required when **response_type**=`option`. + * up to 20 options. * * @return the options */ @@ -535,7 +252,6 @@ public List options() { * Gets the messageToHumanAgent. * *

An optional message to be sent to the human agent who will be taking over the conversation. - * Valid only when **reponse_type**=`connect_to_agent`. * * @return the messageToHumanAgent */ @@ -543,6 +259,41 @@ public String messageToHumanAgent() { return messageToHumanAgent; } + /** + * Gets the agentAvailable. + * + *

An optional message to be displayed to the user to indicate that the conversation will be + * transferred to the next available agent. + * + * @return the agentAvailable + */ + public String agentAvailable() { + return agentAvailable; + } + + /** + * Gets the agentUnavailable. + * + *

An optional message to be displayed to the user to indicate that no online agent is + * available to take over the conversation. + * + * @return the agentUnavailable + */ + public String agentUnavailable() { + return agentUnavailable; + } + + /** + * Gets the transferInfo. + * + *

Routing or other contextual information to be used by target service desk systems. + * + * @return the transferInfo + */ + public DialogNodeOutputConnectToAgentTransferInfo transferInfo() { + return transferInfo; + } + /** * Gets the query. * @@ -550,7 +301,6 @@ public String messageToHumanAgent() { * uses the Discovery query language syntax, depending on the value of the **query_type** * property. For more information, see the [Discovery service * documentation](https://cloud.ibm.com/docs/discovery?topic=discovery-query-operators#query-operators). - * Required when **response_type**=`search_skill`. * * @return the query */ @@ -561,7 +311,7 @@ public String query() { /** * Gets the queryType. * - *

The type of the search query. Required when **response_type**=`search_skill`. + *

The type of the search query. * * @return the queryType */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent.java new file mode 100644 index 00000000000..1d4c3ff1f97 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent.java @@ -0,0 +1,145 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +/** An object that describes a response with response type `connect_to_agent`. */ +public class DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent + extends DialogNodeOutputGeneric { + + /** + * The type of response returned by the dialog node. The specified response type must be supported + * by the client application or channel. + */ + public interface ResponseType { + /** connect_to_agent. */ + String CONNECT_TO_AGENT = "connect_to_agent"; + } + + /** Builder. */ + public static class Builder { + private String responseType; + private String messageToHumanAgent; + private String agentAvailable; + private String agentUnavailable; + private DialogNodeOutputConnectToAgentTransferInfo transferInfo; + + public Builder( + DialogNodeOutputGeneric dialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent) { + this.responseType = + dialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent.responseType; + this.messageToHumanAgent = + dialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent.messageToHumanAgent; + this.agentAvailable = + dialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent.agentAvailable; + this.agentUnavailable = + dialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent.agentUnavailable; + this.transferInfo = + dialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent.transferInfo; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param responseType the responseType + */ + public Builder(String responseType) { + this.responseType = responseType; + } + + /** + * Builds a DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent. + * + * @return the new DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent instance + */ + public DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent build() { + return new DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent(this); + } + + /** + * Set the responseType. + * + * @param responseType the responseType + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent builder + */ + public Builder responseType(String responseType) { + this.responseType = responseType; + return this; + } + + /** + * Set the messageToHumanAgent. + * + * @param messageToHumanAgent the messageToHumanAgent + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent builder + */ + public Builder messageToHumanAgent(String messageToHumanAgent) { + this.messageToHumanAgent = messageToHumanAgent; + return this; + } + + /** + * Set the agentAvailable. + * + * @param agentAvailable the agentAvailable + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent builder + */ + public Builder agentAvailable(String agentAvailable) { + this.agentAvailable = agentAvailable; + return this; + } + + /** + * Set the agentUnavailable. + * + * @param agentUnavailable the agentUnavailable + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent builder + */ + public Builder agentUnavailable(String agentUnavailable) { + this.agentUnavailable = agentUnavailable; + return this; + } + + /** + * Set the transferInfo. + * + * @param transferInfo the transferInfo + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent builder + */ + public Builder transferInfo(DialogNodeOutputConnectToAgentTransferInfo transferInfo) { + this.transferInfo = transferInfo; + return this; + } + } + + protected DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.responseType, "responseType cannot be null"); + responseType = builder.responseType; + messageToHumanAgent = builder.messageToHumanAgent; + agentAvailable = builder.agentAvailable; + agentUnavailable = builder.agentUnavailable; + transferInfo = builder.transferInfo; + } + + /** + * New builder. + * + * @return a DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent builder + */ + public Builder newBuilder() { + return new Builder(this); + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeImage.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeImage.java new file mode 100644 index 00000000000..284ee3a000b --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeImage.java @@ -0,0 +1,129 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +/** An object that describes a response with response type `image`. */ +public class DialogNodeOutputGenericDialogNodeOutputResponseTypeImage + extends DialogNodeOutputGeneric { + + /** + * The type of response returned by the dialog node. The specified response type must be supported + * by the client application or channel. + */ + public interface ResponseType { + /** image. */ + String IMAGE = "image"; + } + + /** Builder. */ + public static class Builder { + private String responseType; + private String source; + private String title; + private String description; + + public Builder( + DialogNodeOutputGeneric dialogNodeOutputGenericDialogNodeOutputResponseTypeImage) { + this.responseType = dialogNodeOutputGenericDialogNodeOutputResponseTypeImage.responseType; + this.source = dialogNodeOutputGenericDialogNodeOutputResponseTypeImage.source; + this.title = dialogNodeOutputGenericDialogNodeOutputResponseTypeImage.title; + this.description = dialogNodeOutputGenericDialogNodeOutputResponseTypeImage.description; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param responseType the responseType + * @param source the source + */ + public Builder(String responseType, String source) { + this.responseType = responseType; + this.source = source; + } + + /** + * Builds a DialogNodeOutputGenericDialogNodeOutputResponseTypeImage. + * + * @return the new DialogNodeOutputGenericDialogNodeOutputResponseTypeImage instance + */ + public DialogNodeOutputGenericDialogNodeOutputResponseTypeImage build() { + return new DialogNodeOutputGenericDialogNodeOutputResponseTypeImage(this); + } + + /** + * Set the responseType. + * + * @param responseType the responseType + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeImage builder + */ + public Builder responseType(String responseType) { + this.responseType = responseType; + return this; + } + + /** + * Set the source. + * + * @param source the source + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeImage builder + */ + public Builder source(String source) { + this.source = source; + return this; + } + + /** + * Set the title. + * + * @param title the title + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeImage builder + */ + public Builder title(String title) { + this.title = title; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeImage builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + } + + protected DialogNodeOutputGenericDialogNodeOutputResponseTypeImage(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.responseType, "responseType cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.source, "source cannot be null"); + responseType = builder.responseType; + source = builder.source; + title = builder.title; + description = builder.description; + } + + /** + * New builder. + * + * @return a DialogNodeOutputGenericDialogNodeOutputResponseTypeImage builder + */ + public Builder newBuilder() { + return new Builder(this); + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeOption.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeOption.java new file mode 100644 index 00000000000..b23daf773db --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeOption.java @@ -0,0 +1,173 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import java.util.ArrayList; +import java.util.List; + +/** An object that describes a response with response type `option`. */ +public class DialogNodeOutputGenericDialogNodeOutputResponseTypeOption + extends DialogNodeOutputGeneric { + + /** + * The type of response returned by the dialog node. The specified response type must be supported + * by the client application or channel. + */ + public interface ResponseType { + /** option. */ + String OPTION = "option"; + } + + /** The preferred type of control to display, if supported by the channel. */ + public interface Preference { + /** dropdown. */ + String DROPDOWN = "dropdown"; + /** button. */ + String BUTTON = "button"; + } + + /** Builder. */ + public static class Builder { + private String responseType; + private String title; + private String description; + private String preference; + private List options; + + public Builder( + DialogNodeOutputGeneric dialogNodeOutputGenericDialogNodeOutputResponseTypeOption) { + this.responseType = dialogNodeOutputGenericDialogNodeOutputResponseTypeOption.responseType; + this.title = dialogNodeOutputGenericDialogNodeOutputResponseTypeOption.title; + this.description = dialogNodeOutputGenericDialogNodeOutputResponseTypeOption.description; + this.preference = dialogNodeOutputGenericDialogNodeOutputResponseTypeOption.preference; + this.options = dialogNodeOutputGenericDialogNodeOutputResponseTypeOption.options; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param responseType the responseType + * @param title the title + * @param options the options + */ + public Builder( + String responseType, String title, List options) { + this.responseType = responseType; + this.title = title; + this.options = options; + } + + /** + * Builds a DialogNodeOutputGenericDialogNodeOutputResponseTypeOption. + * + * @return the new DialogNodeOutputGenericDialogNodeOutputResponseTypeOption instance + */ + public DialogNodeOutputGenericDialogNodeOutputResponseTypeOption build() { + return new DialogNodeOutputGenericDialogNodeOutputResponseTypeOption(this); + } + + /** + * Adds an options to options. + * + * @param options the new options + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeOption builder + */ + public Builder addOptions(DialogNodeOutputOptionsElement options) { + com.ibm.cloud.sdk.core.util.Validator.notNull(options, "options cannot be null"); + if (this.options == null) { + this.options = new ArrayList(); + } + this.options.add(options); + return this; + } + + /** + * Set the responseType. + * + * @param responseType the responseType + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeOption builder + */ + public Builder responseType(String responseType) { + this.responseType = responseType; + return this; + } + + /** + * Set the title. + * + * @param title the title + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeOption builder + */ + public Builder title(String title) { + this.title = title; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeOption builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the preference. + * + * @param preference the preference + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeOption builder + */ + public Builder preference(String preference) { + this.preference = preference; + return this; + } + + /** + * Set the options. Existing options will be replaced. + * + * @param options the options + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeOption builder + */ + public Builder options(List options) { + this.options = options; + return this; + } + } + + protected DialogNodeOutputGenericDialogNodeOutputResponseTypeOption(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.responseType, "responseType cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.title, "title cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.options, "options cannot be null"); + responseType = builder.responseType; + title = builder.title; + description = builder.description; + preference = builder.preference; + options = builder.options; + } + + /** + * New builder. + * + * @return a DialogNodeOutputGenericDialogNodeOutputResponseTypeOption builder + */ + public Builder newBuilder() { + return new Builder(this); + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypePause.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypePause.java new file mode 100644 index 00000000000..43f68f031ec --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypePause.java @@ -0,0 +1,115 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +/** An object that describes a response with response type `pause`. */ +public class DialogNodeOutputGenericDialogNodeOutputResponseTypePause + extends DialogNodeOutputGeneric { + + /** + * The type of response returned by the dialog node. The specified response type must be supported + * by the client application or channel. + */ + public interface ResponseType { + /** pause. */ + String PAUSE = "pause"; + } + + /** Builder. */ + public static class Builder { + private String responseType; + private Long time; + private Boolean typing; + + public Builder( + DialogNodeOutputGeneric dialogNodeOutputGenericDialogNodeOutputResponseTypePause) { + this.responseType = dialogNodeOutputGenericDialogNodeOutputResponseTypePause.responseType; + this.time = dialogNodeOutputGenericDialogNodeOutputResponseTypePause.time; + this.typing = dialogNodeOutputGenericDialogNodeOutputResponseTypePause.typing; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param responseType the responseType + * @param time the time + */ + public Builder(String responseType, Long time) { + this.responseType = responseType; + this.time = time; + } + + /** + * Builds a DialogNodeOutputGenericDialogNodeOutputResponseTypePause. + * + * @return the new DialogNodeOutputGenericDialogNodeOutputResponseTypePause instance + */ + public DialogNodeOutputGenericDialogNodeOutputResponseTypePause build() { + return new DialogNodeOutputGenericDialogNodeOutputResponseTypePause(this); + } + + /** + * Set the responseType. + * + * @param responseType the responseType + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypePause builder + */ + public Builder responseType(String responseType) { + this.responseType = responseType; + return this; + } + + /** + * Set the time. + * + * @param time the time + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypePause builder + */ + public Builder time(long time) { + this.time = time; + return this; + } + + /** + * Set the typing. + * + * @param typing the typing + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypePause builder + */ + public Builder typing(Boolean typing) { + this.typing = typing; + return this; + } + } + + protected DialogNodeOutputGenericDialogNodeOutputResponseTypePause(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.responseType, "responseType cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.time, "time cannot be null"); + responseType = builder.responseType; + time = builder.time; + typing = builder.typing; + } + + /** + * New builder. + * + * @return a DialogNodeOutputGenericDialogNodeOutputResponseTypePause builder + */ + public Builder newBuilder() { + return new Builder(this); + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill.java new file mode 100644 index 00000000000..fa4ba54594c --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill.java @@ -0,0 +1,158 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +/** An object that describes a response with response type `search_skill`. */ +public class DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill + extends DialogNodeOutputGeneric { + + /** + * The type of response returned by the dialog node. The specified response type must be supported + * by the client application or channel. + * + *

**Note:** The **search_skill** response type is used only by the v2 runtime API. + */ + public interface ResponseType { + /** search_skill. */ + String SEARCH_SKILL = "search_skill"; + } + + /** The type of the search query. */ + public interface QueryType { + /** natural_language. */ + String NATURAL_LANGUAGE = "natural_language"; + /** discovery_query_language. */ + String DISCOVERY_QUERY_LANGUAGE = "discovery_query_language"; + } + + /** Builder. */ + public static class Builder { + private String responseType; + private String query; + private String queryType; + private String filter; + private String discoveryVersion; + + public Builder( + DialogNodeOutputGeneric dialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill) { + this.responseType = + dialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill.responseType; + this.query = dialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill.query; + this.queryType = dialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill.queryType; + this.filter = dialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill.filter; + this.discoveryVersion = + dialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill.discoveryVersion; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param responseType the responseType + * @param query the query + * @param queryType the queryType + */ + public Builder(String responseType, String query, String queryType) { + this.responseType = responseType; + this.query = query; + this.queryType = queryType; + } + + /** + * Builds a DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill. + * + * @return the new DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill instance + */ + public DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill build() { + return new DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill(this); + } + + /** + * Set the responseType. + * + * @param responseType the responseType + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill builder + */ + public Builder responseType(String responseType) { + this.responseType = responseType; + return this; + } + + /** + * Set the query. + * + * @param query the query + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill builder + */ + public Builder query(String query) { + this.query = query; + return this; + } + + /** + * Set the queryType. + * + * @param queryType the queryType + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill builder + */ + public Builder queryType(String queryType) { + this.queryType = queryType; + return this; + } + + /** + * Set the filter. + * + * @param filter the filter + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill builder + */ + public Builder filter(String filter) { + this.filter = filter; + return this; + } + + /** + * Set the discoveryVersion. + * + * @param discoveryVersion the discoveryVersion + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill builder + */ + public Builder discoveryVersion(String discoveryVersion) { + this.discoveryVersion = discoveryVersion; + return this; + } + } + + protected DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.responseType, "responseType cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.query, "query cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.queryType, "queryType cannot be null"); + responseType = builder.responseType; + query = builder.query; + queryType = builder.queryType; + filter = builder.filter; + discoveryVersion = builder.discoveryVersion; + } + + /** + * New builder. + * + * @return a DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill builder + */ + public Builder newBuilder() { + return new Builder(this); + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeText.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeText.java new file mode 100644 index 00000000000..e08ffb34ac4 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeText.java @@ -0,0 +1,158 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import java.util.ArrayList; +import java.util.List; + +/** An object that describes a response with response type `text`. */ +public class DialogNodeOutputGenericDialogNodeOutputResponseTypeText + extends DialogNodeOutputGeneric { + + /** + * The type of response returned by the dialog node. The specified response type must be supported + * by the client application or channel. + */ + public interface ResponseType { + /** text. */ + String TEXT = "text"; + } + + /** How a response is selected from the list, if more than one response is specified. */ + public interface SelectionPolicy { + /** sequential. */ + String SEQUENTIAL = "sequential"; + /** random. */ + String RANDOM = "random"; + /** multiline. */ + String MULTILINE = "multiline"; + } + + /** Builder. */ + public static class Builder { + private String responseType; + private List values; + private String selectionPolicy; + private String delimiter; + + public Builder( + DialogNodeOutputGeneric dialogNodeOutputGenericDialogNodeOutputResponseTypeText) { + this.responseType = dialogNodeOutputGenericDialogNodeOutputResponseTypeText.responseType; + this.values = dialogNodeOutputGenericDialogNodeOutputResponseTypeText.values; + this.selectionPolicy = + dialogNodeOutputGenericDialogNodeOutputResponseTypeText.selectionPolicy; + this.delimiter = dialogNodeOutputGenericDialogNodeOutputResponseTypeText.delimiter; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param responseType the responseType + * @param values the values + */ + public Builder(String responseType, List values) { + this.responseType = responseType; + this.values = values; + } + + /** + * Builds a DialogNodeOutputGenericDialogNodeOutputResponseTypeText. + * + * @return the new DialogNodeOutputGenericDialogNodeOutputResponseTypeText instance + */ + public DialogNodeOutputGenericDialogNodeOutputResponseTypeText build() { + return new DialogNodeOutputGenericDialogNodeOutputResponseTypeText(this); + } + + /** + * Adds an values to values. + * + * @param values the new values + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeText builder + */ + public Builder addValues(DialogNodeOutputTextValuesElement values) { + com.ibm.cloud.sdk.core.util.Validator.notNull(values, "values cannot be null"); + if (this.values == null) { + this.values = new ArrayList(); + } + this.values.add(values); + return this; + } + + /** + * Set the responseType. + * + * @param responseType the responseType + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeText builder + */ + public Builder responseType(String responseType) { + this.responseType = responseType; + return this; + } + + /** + * Set the values. Existing values will be replaced. + * + * @param values the values + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeText builder + */ + public Builder values(List values) { + this.values = values; + return this; + } + + /** + * Set the selectionPolicy. + * + * @param selectionPolicy the selectionPolicy + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeText builder + */ + public Builder selectionPolicy(String selectionPolicy) { + this.selectionPolicy = selectionPolicy; + return this; + } + + /** + * Set the delimiter. + * + * @param delimiter the delimiter + * @return the DialogNodeOutputGenericDialogNodeOutputResponseTypeText builder + */ + public Builder delimiter(String delimiter) { + this.delimiter = delimiter; + return this; + } + } + + protected DialogNodeOutputGenericDialogNodeOutputResponseTypeText(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.responseType, "responseType cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.values, "values cannot be null"); + responseType = builder.responseType; + values = builder.values; + selectionPolicy = builder.selectionPolicy; + delimiter = builder.delimiter; + } + + /** + * New builder. + * + * @return a DialogNodeOutputGenericDialogNodeOutputResponseTypeText builder + */ + public Builder newBuilder() { + return new Builder(this); + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputModifiers.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputModifiers.java index b42e0ef9d51..7fcf9cccd19 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputModifiers.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputModifiers.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -33,7 +33,7 @@ public Builder() {} /** * Builds a DialogNodeOutputModifiers. * - * @return the dialogNodeOutputModifiers + * @return the new DialogNodeOutputModifiers instance */ public DialogNodeOutputModifiers build() { return new DialogNodeOutputModifiers(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputOptionsElement.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputOptionsElement.java index da5aa2ec587..d8bf5d240b6 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputOptionsElement.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputOptionsElement.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -47,7 +47,7 @@ public Builder(String label, DialogNodeOutputOptionsElementValue value) { /** * Builds a DialogNodeOutputOptionsElement. * - * @return the dialogNodeOutputOptionsElement + * @return the new DialogNodeOutputOptionsElement instance */ public DialogNodeOutputOptionsElement build() { return new DialogNodeOutputOptionsElement(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputOptionsElementValue.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputOptionsElementValue.java index 724ebcd16d1..019bbd8d373 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputOptionsElementValue.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputOptionsElementValue.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -44,7 +44,7 @@ public Builder() {} /** * Builds a DialogNodeOutputOptionsElementValue. * - * @return the dialogNodeOutputOptionsElementValue + * @return the new DialogNodeOutputOptionsElementValue instance */ public DialogNodeOutputOptionsElementValue build() { return new DialogNodeOutputOptionsElementValue(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputTextValuesElement.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputTextValuesElement.java index 0b4613d3185..bebe5e0db63 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputTextValuesElement.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputTextValuesElement.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -33,7 +33,7 @@ public Builder() {} /** * Builds a DialogNodeOutputTextValuesElement. * - * @return the dialogNodeOutputTextValuesElement + * @return the new DialogNodeOutputTextValuesElement instance */ public DialogNodeOutputTextValuesElement build() { return new DialogNodeOutputTextValuesElement(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeVisitedDetails.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeVisitedDetails.java index 06805f26ad1..0aaa9380241 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeVisitedDetails.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeVisitedDetails.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -42,7 +42,7 @@ public Builder() {} /** * Builds a DialogNodeVisitedDetails. * - * @return the dialogNodeVisitedDetails + * @return the new DialogNodeVisitedDetails instance */ public DialogNodeVisitedDetails build() { return new DialogNodeVisitedDetails(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogSuggestion.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogSuggestion.java index 823cb9000d9..8cc02810e15 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogSuggestion.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogSuggestion.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -14,13 +14,14 @@ import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.Map; /** DialogSuggestion. */ public class DialogSuggestion extends GenericModel { protected String label; protected DialogSuggestionValue value; - protected DialogSuggestionOutput output; + protected Map output; @SerializedName("dialog_node") protected String dialogNode; @@ -29,7 +30,7 @@ public class DialogSuggestion extends GenericModel { public static class Builder { private String label; private DialogSuggestionValue value; - private DialogSuggestionOutput output; + private Map output; private String dialogNode; private Builder(DialogSuggestion dialogSuggestion) { @@ -56,7 +57,7 @@ public Builder(String label, DialogSuggestionValue value) { /** * Builds a DialogSuggestion. * - * @return the dialogSuggestion + * @return the new DialogSuggestion instance */ public DialogSuggestion build() { return new DialogSuggestion(this); @@ -90,7 +91,7 @@ public Builder value(DialogSuggestionValue value) { * @param output the output * @return the DialogSuggestion builder */ - public Builder output(DialogSuggestionOutput output) { + public Builder output(Map output) { this.output = output; return this; } @@ -158,7 +159,7 @@ public DialogSuggestionValue value() { * * @return the output */ - public DialogSuggestionOutput output() { + public Map output() { return output; } diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogSuggestionOutput.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogSuggestionOutput.java deleted file mode 100644 index e1739ac87c7..00000000000 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogSuggestionOutput.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.watson.assistant.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.google.gson.reflect.TypeToken; -import com.ibm.cloud.sdk.core.service.model.DynamicModel; -import java.util.List; - -/** - * The dialog output that will be returned from the Watson Assistant service if the user selects the - * corresponding option. - */ -public class DialogSuggestionOutput extends DynamicModel { - - @SerializedName("nodes_visited") - protected List nodesVisited; - - @SerializedName("nodes_visited_details") - protected List nodesVisitedDetails; - - @SerializedName("text") - protected List text; - - @SerializedName("generic") - protected List generic; - - public DialogSuggestionOutput() { - super(new TypeToken() {}); - } - - /** - * Gets the nodesVisited. - * - *

An array of the nodes that were triggered to create the response, in the order in which they - * were visited. This information is useful for debugging and for tracing the path taken through - * the node tree. - * - * @return the nodesVisited - */ - public List getNodesVisited() { - return this.nodesVisited; - } - - /** - * Sets the nodesVisited. - * - * @param nodesVisited the new nodesVisited - */ - public void setNodesVisited(final List nodesVisited) { - this.nodesVisited = nodesVisited; - } - - /** - * Gets the nodesVisitedDetails. - * - *

An array of objects containing detailed diagnostic information about the nodes that were - * triggered during processing of the input message. Included only if **nodes_visited_details** is - * set to `true` in the message request. - * - * @return the nodesVisitedDetails - */ - public List getNodesVisitedDetails() { - return this.nodesVisitedDetails; - } - - /** - * Sets the nodesVisitedDetails. - * - * @param nodesVisitedDetails the new nodesVisitedDetails - */ - public void setNodesVisitedDetails(final List nodesVisitedDetails) { - this.nodesVisitedDetails = nodesVisitedDetails; - } - - /** - * Gets the text. - * - *

An array of responses to the user. - * - * @return the text - */ - public List getText() { - return this.text; - } - - /** - * Sets the text. - * - * @param text the new text - */ - public void setText(final List text) { - this.text = text; - } - - /** - * Gets the generic. - * - *

Output intended for any channel. It is the responsibility of the client application to - * implement the supported response types. - * - * @return the generic - */ - public List getGeneric() { - return this.generic; - } - - /** - * Sets the generic. - * - * @param generic the new generic - */ - public void setGeneric(final List generic) { - this.generic = generic; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogSuggestionResponseGeneric.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogSuggestionResponseGeneric.java deleted file mode 100644 index f8c740e1c53..00000000000 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogSuggestionResponseGeneric.java +++ /dev/null @@ -1,433 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.watson.assistant.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.cloud.sdk.core.service.model.GenericModel; -import java.util.ArrayList; -import java.util.List; - -/** DialogSuggestionResponseGeneric. */ -public class DialogSuggestionResponseGeneric extends GenericModel { - - /** - * The type of response returned by the dialog node. The specified response type must be supported - * by the client application or channel. - * - *

**Note:** The **search_skill** response type is is used only by the v2 runtime API. - */ - public interface ResponseType { - /** text. */ - String TEXT = "text"; - /** pause. */ - String PAUSE = "pause"; - /** image. */ - String IMAGE = "image"; - /** option. */ - String OPTION = "option"; - /** connect_to_agent. */ - String CONNECT_TO_AGENT = "connect_to_agent"; - /** search_skill. */ - String SEARCH_SKILL = "search_skill"; - } - - /** The preferred type of control to display. */ - public interface Preference { - /** dropdown. */ - String DROPDOWN = "dropdown"; - /** button. */ - String BUTTON = "button"; - } - - @SerializedName("response_type") - protected String responseType; - - protected String text; - protected Long time; - protected Boolean typing; - protected String source; - protected String title; - protected String description; - protected String preference; - protected List options; - - @SerializedName("message_to_human_agent") - protected String messageToHumanAgent; - - protected String topic; - - @SerializedName("dialog_node") - protected String dialogNode; - - /** Builder. */ - public static class Builder { - private String responseType; - private String text; - private Long time; - private Boolean typing; - private String source; - private String title; - private String description; - private String preference; - private List options; - private String messageToHumanAgent; - private String topic; - private String dialogNode; - - private Builder(DialogSuggestionResponseGeneric dialogSuggestionResponseGeneric) { - this.responseType = dialogSuggestionResponseGeneric.responseType; - this.text = dialogSuggestionResponseGeneric.text; - this.time = dialogSuggestionResponseGeneric.time; - this.typing = dialogSuggestionResponseGeneric.typing; - this.source = dialogSuggestionResponseGeneric.source; - this.title = dialogSuggestionResponseGeneric.title; - this.description = dialogSuggestionResponseGeneric.description; - this.preference = dialogSuggestionResponseGeneric.preference; - this.options = dialogSuggestionResponseGeneric.options; - this.messageToHumanAgent = dialogSuggestionResponseGeneric.messageToHumanAgent; - this.topic = dialogSuggestionResponseGeneric.topic; - this.dialogNode = dialogSuggestionResponseGeneric.dialogNode; - } - - /** Instantiates a new builder. */ - public Builder() {} - - /** - * Instantiates a new builder with required properties. - * - * @param responseType the responseType - */ - public Builder(String responseType) { - this.responseType = responseType; - } - - /** - * Builds a DialogSuggestionResponseGeneric. - * - * @return the dialogSuggestionResponseGeneric - */ - public DialogSuggestionResponseGeneric build() { - return new DialogSuggestionResponseGeneric(this); - } - - /** - * Adds an options to options. - * - * @param options the new options - * @return the DialogSuggestionResponseGeneric builder - */ - public Builder addOptions(DialogNodeOutputOptionsElement options) { - com.ibm.cloud.sdk.core.util.Validator.notNull(options, "options cannot be null"); - if (this.options == null) { - this.options = new ArrayList(); - } - this.options.add(options); - return this; - } - - /** - * Set the responseType. - * - * @param responseType the responseType - * @return the DialogSuggestionResponseGeneric builder - */ - public Builder responseType(String responseType) { - this.responseType = responseType; - return this; - } - - /** - * Set the text. - * - * @param text the text - * @return the DialogSuggestionResponseGeneric builder - */ - public Builder text(String text) { - this.text = text; - return this; - } - - /** - * Set the time. - * - * @param time the time - * @return the DialogSuggestionResponseGeneric builder - */ - public Builder time(long time) { - this.time = time; - return this; - } - - /** - * Set the typing. - * - * @param typing the typing - * @return the DialogSuggestionResponseGeneric builder - */ - public Builder typing(Boolean typing) { - this.typing = typing; - return this; - } - - /** - * Set the source. - * - * @param source the source - * @return the DialogSuggestionResponseGeneric builder - */ - public Builder source(String source) { - this.source = source; - return this; - } - - /** - * Set the title. - * - * @param title the title - * @return the DialogSuggestionResponseGeneric builder - */ - public Builder title(String title) { - this.title = title; - return this; - } - - /** - * Set the description. - * - * @param description the description - * @return the DialogSuggestionResponseGeneric builder - */ - public Builder description(String description) { - this.description = description; - return this; - } - - /** - * Set the preference. - * - * @param preference the preference - * @return the DialogSuggestionResponseGeneric builder - */ - public Builder preference(String preference) { - this.preference = preference; - return this; - } - - /** - * Set the options. Existing options will be replaced. - * - * @param options the options - * @return the DialogSuggestionResponseGeneric builder - */ - public Builder options(List options) { - this.options = options; - return this; - } - - /** - * Set the messageToHumanAgent. - * - * @param messageToHumanAgent the messageToHumanAgent - * @return the DialogSuggestionResponseGeneric builder - */ - public Builder messageToHumanAgent(String messageToHumanAgent) { - this.messageToHumanAgent = messageToHumanAgent; - return this; - } - - /** - * Set the topic. - * - * @param topic the topic - * @return the DialogSuggestionResponseGeneric builder - */ - public Builder topic(String topic) { - this.topic = topic; - return this; - } - - /** - * Set the dialogNode. - * - * @param dialogNode the dialogNode - * @return the DialogSuggestionResponseGeneric builder - */ - public Builder dialogNode(String dialogNode) { - this.dialogNode = dialogNode; - return this; - } - } - - protected DialogSuggestionResponseGeneric(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull( - builder.responseType, "responseType cannot be null"); - responseType = builder.responseType; - text = builder.text; - time = builder.time; - typing = builder.typing; - source = builder.source; - title = builder.title; - description = builder.description; - preference = builder.preference; - options = builder.options; - messageToHumanAgent = builder.messageToHumanAgent; - topic = builder.topic; - dialogNode = builder.dialogNode; - } - - /** - * New builder. - * - * @return a DialogSuggestionResponseGeneric builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the responseType. - * - *

The type of response returned by the dialog node. The specified response type must be - * supported by the client application or channel. - * - *

**Note:** The **search_skill** response type is is used only by the v2 runtime API. - * - * @return the responseType - */ - public String responseType() { - return responseType; - } - - /** - * Gets the text. - * - *

The text of the response. - * - * @return the text - */ - public String text() { - return text; - } - - /** - * Gets the time. - * - *

How long to pause, in milliseconds. - * - * @return the time - */ - public Long time() { - return time; - } - - /** - * Gets the typing. - * - *

Whether to send a "user is typing" event during the pause. - * - * @return the typing - */ - public Boolean typing() { - return typing; - } - - /** - * Gets the source. - * - *

The URL of the image. - * - * @return the source - */ - public String source() { - return source; - } - - /** - * Gets the title. - * - *

The title or introductory text to show before the response. - * - * @return the title - */ - public String title() { - return title; - } - - /** - * Gets the description. - * - *

The description to show with the the response. - * - * @return the description - */ - public String description() { - return description; - } - - /** - * Gets the preference. - * - *

The preferred type of control to display. - * - * @return the preference - */ - public String preference() { - return preference; - } - - /** - * Gets the options. - * - *

An array of objects describing the options from which the user can choose. - * - * @return the options - */ - public List options() { - return options; - } - - /** - * Gets the messageToHumanAgent. - * - *

A message to be sent to the human agent who will be taking over the conversation. - * - * @return the messageToHumanAgent - */ - public String messageToHumanAgent() { - return messageToHumanAgent; - } - - /** - * Gets the topic. - * - *

A label identifying the topic of the conversation, derived from the **title** property of - * the relevant node. - * - * @return the topic - */ - public String topic() { - return topic; - } - - /** - * Gets the dialogNode. - * - *

The ID of the dialog node that the **topic** property is taken from. The **topic** property - * is populated using the value of the dialog node's **title** property. - * - * @return the dialogNode - */ - public String dialogNode() { - return dialogNode; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogSuggestionValue.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogSuggestionValue.java index f74e5eb181b..5573c7f4d77 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogSuggestionValue.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogSuggestionValue.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -44,7 +44,7 @@ public Builder() {} /** * Builds a DialogSuggestionValue. * - * @return the dialogSuggestionValue + * @return the new DialogSuggestionValue instance */ public DialogSuggestionValue build() { return new DialogSuggestionValue(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Entity.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Entity.java index 147d67408e7..6f636d76bcb 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Entity.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Entity.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2016, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/EntityCollection.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/EntityCollection.java index 12eba0588c5..bc7a6d628dc 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/EntityCollection.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/EntityCollection.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/EntityMention.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/EntityMention.java index aa987f51189..175420577a6 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/EntityMention.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/EntityMention.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/EntityMentionCollection.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/EntityMentionCollection.java index 549aa9a7bf5..bb98d4c70e1 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/EntityMentionCollection.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/EntityMentionCollection.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Example.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Example.java index 8fad39ea3ad..193457eb59e 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Example.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Example.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -29,14 +29,10 @@ public class Example extends GenericModel { public static class Builder { private String text; private List mentions; - private Date created; - private Date updated; private Builder(Example example) { this.text = example.text; this.mentions = example.mentions; - this.created = example.created; - this.updated = example.updated; } /** Instantiates a new builder. */ @@ -54,7 +50,7 @@ public Builder(String text) { /** * Builds a Example. * - * @return the example + * @return the new Example instance */ public Example build() { return new Example(this); @@ -96,36 +92,12 @@ public Builder mentions(List mentions) { this.mentions = mentions; return this; } - - /** - * Set the created. - * - * @param created the created - * @return the Example builder - */ - public Builder created(Date created) { - this.created = created; - return this; - } - - /** - * Set the updated. - * - * @param updated the updated - * @return the Example builder - */ - public Builder updated(Date updated) { - this.updated = updated; - return this; - } } protected Example(Builder builder) { com.ibm.cloud.sdk.core.util.Validator.notNull(builder.text, "text cannot be null"); text = builder.text; mentions = builder.mentions; - created = builder.created; - updated = builder.updated; } /** diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ExampleCollection.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ExampleCollection.java index 77641981302..c79a5070b7e 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ExampleCollection.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ExampleCollection.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetCounterexampleOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetCounterexampleOptions.java index d0e437b922a..21bdf9b1ede 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetCounterexampleOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetCounterexampleOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -50,7 +50,7 @@ public Builder(String workspaceId, String text) { /** * Builds a GetCounterexampleOptions. * - * @return the getCounterexampleOptions + * @return the new GetCounterexampleOptions instance */ public GetCounterexampleOptions build() { return new GetCounterexampleOptions(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetDialogNodeOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetDialogNodeOptions.java index 27cbd82d5e2..fc79b0ac5eb 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetDialogNodeOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetDialogNodeOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -50,7 +50,7 @@ public Builder(String workspaceId, String dialogNode) { /** * Builds a GetDialogNodeOptions. * - * @return the getDialogNodeOptions + * @return the new GetDialogNodeOptions instance */ public GetDialogNodeOptions build() { return new GetDialogNodeOptions(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetEntityOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetEntityOptions.java index 841b562440c..a5259f6eafd 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetEntityOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetEntityOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -53,7 +53,7 @@ public Builder(String workspaceId, String entity) { /** * Builds a GetEntityOptions. * - * @return the getEntityOptions + * @return the new GetEntityOptions instance */ public GetEntityOptions build() { return new GetEntityOptions(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetExampleOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetExampleOptions.java index 6353dbc2507..7af6169194c 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetExampleOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetExampleOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -55,7 +55,7 @@ public Builder(String workspaceId, String intent, String text) { /** * Builds a GetExampleOptions. * - * @return the getExampleOptions + * @return the new GetExampleOptions instance */ public GetExampleOptions build() { return new GetExampleOptions(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetIntentOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetIntentOptions.java index 2dd40817d9a..9853f07ed30 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetIntentOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetIntentOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -53,7 +53,7 @@ public Builder(String workspaceId, String intent) { /** * Builds a GetIntentOptions. * - * @return the getIntentOptions + * @return the new GetIntentOptions instance */ public GetIntentOptions build() { return new GetIntentOptions(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetSynonymOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetSynonymOptions.java index a1a3115d6ab..9216a960270 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetSynonymOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetSynonymOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -60,7 +60,7 @@ public Builder(String workspaceId, String entity, String value, String synonym) /** * Builds a GetSynonymOptions. * - * @return the getSynonymOptions + * @return the new GetSynonymOptions instance */ public GetSynonymOptions build() { return new GetSynonymOptions(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetValueOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetValueOptions.java index b7726c6ae06..24a2d99b348 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetValueOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetValueOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -58,7 +58,7 @@ public Builder(String workspaceId, String entity, String value) { /** * Builds a GetValueOptions. * - * @return the getValueOptions + * @return the new GetValueOptions instance */ public GetValueOptions build() { return new GetValueOptions(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetWorkspaceOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetWorkspaceOptions.java index 9228686b09d..bcc2f8398de 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetWorkspaceOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetWorkspaceOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -61,7 +61,7 @@ public Builder(String workspaceId) { /** * Builds a GetWorkspaceOptions. * - * @return the getWorkspaceOptions + * @return the new GetWorkspaceOptions instance */ public GetWorkspaceOptions build() { return new GetWorkspaceOptions(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Intent.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Intent.java index db08af834c1..b868d259c75 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Intent.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Intent.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2016, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/IntentCollection.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/IntentCollection.java index 5db65a43622..64be723fec8 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/IntentCollection.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/IntentCollection.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListAllLogsOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListAllLogsOptions.java index 61e80a65593..1bd7f5eddd3 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListAllLogsOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListAllLogsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -51,7 +51,7 @@ public Builder(String filter) { /** * Builds a ListAllLogsOptions. * - * @return the listAllLogsOptions + * @return the new ListAllLogsOptions instance */ public ListAllLogsOptions build() { return new ListAllLogsOptions(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListCounterexamplesOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListCounterexamplesOptions.java index bf5fcaded6c..764f5435c77 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListCounterexamplesOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListCounterexamplesOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -30,6 +30,7 @@ public interface Sort { protected String workspaceId; protected Long pageLimit; + protected Boolean includeCount; protected String sort; protected String cursor; protected Boolean includeAudit; @@ -38,6 +39,7 @@ public interface Sort { public static class Builder { private String workspaceId; private Long pageLimit; + private Boolean includeCount; private String sort; private String cursor; private Boolean includeAudit; @@ -45,6 +47,7 @@ public static class Builder { private Builder(ListCounterexamplesOptions listCounterexamplesOptions) { this.workspaceId = listCounterexamplesOptions.workspaceId; this.pageLimit = listCounterexamplesOptions.pageLimit; + this.includeCount = listCounterexamplesOptions.includeCount; this.sort = listCounterexamplesOptions.sort; this.cursor = listCounterexamplesOptions.cursor; this.includeAudit = listCounterexamplesOptions.includeAudit; @@ -65,7 +68,7 @@ public Builder(String workspaceId) { /** * Builds a ListCounterexamplesOptions. * - * @return the listCounterexamplesOptions + * @return the new ListCounterexamplesOptions instance */ public ListCounterexamplesOptions build() { return new ListCounterexamplesOptions(this); @@ -93,6 +96,17 @@ public Builder pageLimit(long pageLimit) { return this; } + /** + * Set the includeCount. + * + * @param includeCount the includeCount + * @return the ListCounterexamplesOptions builder + */ + public Builder includeCount(Boolean includeCount) { + this.includeCount = includeCount; + return this; + } + /** * Set the sort. * @@ -132,6 +146,7 @@ protected ListCounterexamplesOptions(Builder builder) { builder.workspaceId, "workspaceId cannot be empty"); workspaceId = builder.workspaceId; pageLimit = builder.pageLimit; + includeCount = builder.includeCount; sort = builder.sort; cursor = builder.cursor; includeAudit = builder.includeAudit; @@ -168,6 +183,19 @@ public Long pageLimit() { return pageLimit; } + /** + * Gets the includeCount. + * + *

Whether to include information about the number of records that satisfy the request, + * regardless of the page limit. If this parameter is `true`, the `pagination` object in the + * response includes the `total` property. + * + * @return the includeCount + */ + public Boolean includeCount() { + return includeCount; + } + /** * Gets the sort. * diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListDialogNodesOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListDialogNodesOptions.java index a260c306e38..39cb855ae94 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListDialogNodesOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListDialogNodesOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -30,6 +30,7 @@ public interface Sort { protected String workspaceId; protected Long pageLimit; + protected Boolean includeCount; protected String sort; protected String cursor; protected Boolean includeAudit; @@ -38,6 +39,7 @@ public interface Sort { public static class Builder { private String workspaceId; private Long pageLimit; + private Boolean includeCount; private String sort; private String cursor; private Boolean includeAudit; @@ -45,6 +47,7 @@ public static class Builder { private Builder(ListDialogNodesOptions listDialogNodesOptions) { this.workspaceId = listDialogNodesOptions.workspaceId; this.pageLimit = listDialogNodesOptions.pageLimit; + this.includeCount = listDialogNodesOptions.includeCount; this.sort = listDialogNodesOptions.sort; this.cursor = listDialogNodesOptions.cursor; this.includeAudit = listDialogNodesOptions.includeAudit; @@ -65,7 +68,7 @@ public Builder(String workspaceId) { /** * Builds a ListDialogNodesOptions. * - * @return the listDialogNodesOptions + * @return the new ListDialogNodesOptions instance */ public ListDialogNodesOptions build() { return new ListDialogNodesOptions(this); @@ -93,6 +96,17 @@ public Builder pageLimit(long pageLimit) { return this; } + /** + * Set the includeCount. + * + * @param includeCount the includeCount + * @return the ListDialogNodesOptions builder + */ + public Builder includeCount(Boolean includeCount) { + this.includeCount = includeCount; + return this; + } + /** * Set the sort. * @@ -132,6 +146,7 @@ protected ListDialogNodesOptions(Builder builder) { builder.workspaceId, "workspaceId cannot be empty"); workspaceId = builder.workspaceId; pageLimit = builder.pageLimit; + includeCount = builder.includeCount; sort = builder.sort; cursor = builder.cursor; includeAudit = builder.includeAudit; @@ -168,6 +183,19 @@ public Long pageLimit() { return pageLimit; } + /** + * Gets the includeCount. + * + *

Whether to include information about the number of records that satisfy the request, + * regardless of the page limit. If this parameter is `true`, the `pagination` object in the + * response includes the `total` property. + * + * @return the includeCount + */ + public Boolean includeCount() { + return includeCount; + } + /** * Gets the sort. * diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListEntitiesOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListEntitiesOptions.java index 2eb98009cb5..f9646817f65 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListEntitiesOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListEntitiesOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -31,6 +31,7 @@ public interface Sort { protected String workspaceId; protected Boolean export; protected Long pageLimit; + protected Boolean includeCount; protected String sort; protected String cursor; protected Boolean includeAudit; @@ -40,6 +41,7 @@ public static class Builder { private String workspaceId; private Boolean export; private Long pageLimit; + private Boolean includeCount; private String sort; private String cursor; private Boolean includeAudit; @@ -48,6 +50,7 @@ private Builder(ListEntitiesOptions listEntitiesOptions) { this.workspaceId = listEntitiesOptions.workspaceId; this.export = listEntitiesOptions.export; this.pageLimit = listEntitiesOptions.pageLimit; + this.includeCount = listEntitiesOptions.includeCount; this.sort = listEntitiesOptions.sort; this.cursor = listEntitiesOptions.cursor; this.includeAudit = listEntitiesOptions.includeAudit; @@ -68,7 +71,7 @@ public Builder(String workspaceId) { /** * Builds a ListEntitiesOptions. * - * @return the listEntitiesOptions + * @return the new ListEntitiesOptions instance */ public ListEntitiesOptions build() { return new ListEntitiesOptions(this); @@ -107,6 +110,17 @@ public Builder pageLimit(long pageLimit) { return this; } + /** + * Set the includeCount. + * + * @param includeCount the includeCount + * @return the ListEntitiesOptions builder + */ + public Builder includeCount(Boolean includeCount) { + this.includeCount = includeCount; + return this; + } + /** * Set the sort. * @@ -147,6 +161,7 @@ protected ListEntitiesOptions(Builder builder) { workspaceId = builder.workspaceId; export = builder.export; pageLimit = builder.pageLimit; + includeCount = builder.includeCount; sort = builder.sort; cursor = builder.cursor; includeAudit = builder.includeAudit; @@ -196,6 +211,19 @@ public Long pageLimit() { return pageLimit; } + /** + * Gets the includeCount. + * + *

Whether to include information about the number of records that satisfy the request, + * regardless of the page limit. If this parameter is `true`, the `pagination` object in the + * response includes the `total` property. + * + * @return the includeCount + */ + public Boolean includeCount() { + return includeCount; + } + /** * Gets the sort. * diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListExamplesOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListExamplesOptions.java index 0b2251c09b0..cd95352a06e 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListExamplesOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListExamplesOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -31,6 +31,7 @@ public interface Sort { protected String workspaceId; protected String intent; protected Long pageLimit; + protected Boolean includeCount; protected String sort; protected String cursor; protected Boolean includeAudit; @@ -40,6 +41,7 @@ public static class Builder { private String workspaceId; private String intent; private Long pageLimit; + private Boolean includeCount; private String sort; private String cursor; private Boolean includeAudit; @@ -48,6 +50,7 @@ private Builder(ListExamplesOptions listExamplesOptions) { this.workspaceId = listExamplesOptions.workspaceId; this.intent = listExamplesOptions.intent; this.pageLimit = listExamplesOptions.pageLimit; + this.includeCount = listExamplesOptions.includeCount; this.sort = listExamplesOptions.sort; this.cursor = listExamplesOptions.cursor; this.includeAudit = listExamplesOptions.includeAudit; @@ -70,7 +73,7 @@ public Builder(String workspaceId, String intent) { /** * Builds a ListExamplesOptions. * - * @return the listExamplesOptions + * @return the new ListExamplesOptions instance */ public ListExamplesOptions build() { return new ListExamplesOptions(this); @@ -109,6 +112,17 @@ public Builder pageLimit(long pageLimit) { return this; } + /** + * Set the includeCount. + * + * @param includeCount the includeCount + * @return the ListExamplesOptions builder + */ + public Builder includeCount(Boolean includeCount) { + this.includeCount = includeCount; + return this; + } + /** * Set the sort. * @@ -150,6 +164,7 @@ protected ListExamplesOptions(Builder builder) { workspaceId = builder.workspaceId; intent = builder.intent; pageLimit = builder.pageLimit; + includeCount = builder.includeCount; sort = builder.sort; cursor = builder.cursor; includeAudit = builder.includeAudit; @@ -197,6 +212,19 @@ public Long pageLimit() { return pageLimit; } + /** + * Gets the includeCount. + * + *

Whether to include information about the number of records that satisfy the request, + * regardless of the page limit. If this parameter is `true`, the `pagination` object in the + * response includes the `total` property. + * + * @return the includeCount + */ + public Boolean includeCount() { + return includeCount; + } + /** * Gets the sort. * diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListIntentsOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListIntentsOptions.java index a4873c27059..252ec6c5ad3 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListIntentsOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListIntentsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -31,6 +31,7 @@ public interface Sort { protected String workspaceId; protected Boolean export; protected Long pageLimit; + protected Boolean includeCount; protected String sort; protected String cursor; protected Boolean includeAudit; @@ -40,6 +41,7 @@ public static class Builder { private String workspaceId; private Boolean export; private Long pageLimit; + private Boolean includeCount; private String sort; private String cursor; private Boolean includeAudit; @@ -48,6 +50,7 @@ private Builder(ListIntentsOptions listIntentsOptions) { this.workspaceId = listIntentsOptions.workspaceId; this.export = listIntentsOptions.export; this.pageLimit = listIntentsOptions.pageLimit; + this.includeCount = listIntentsOptions.includeCount; this.sort = listIntentsOptions.sort; this.cursor = listIntentsOptions.cursor; this.includeAudit = listIntentsOptions.includeAudit; @@ -68,7 +71,7 @@ public Builder(String workspaceId) { /** * Builds a ListIntentsOptions. * - * @return the listIntentsOptions + * @return the new ListIntentsOptions instance */ public ListIntentsOptions build() { return new ListIntentsOptions(this); @@ -107,6 +110,17 @@ public Builder pageLimit(long pageLimit) { return this; } + /** + * Set the includeCount. + * + * @param includeCount the includeCount + * @return the ListIntentsOptions builder + */ + public Builder includeCount(Boolean includeCount) { + this.includeCount = includeCount; + return this; + } + /** * Set the sort. * @@ -147,6 +161,7 @@ protected ListIntentsOptions(Builder builder) { workspaceId = builder.workspaceId; export = builder.export; pageLimit = builder.pageLimit; + includeCount = builder.includeCount; sort = builder.sort; cursor = builder.cursor; includeAudit = builder.includeAudit; @@ -196,6 +211,19 @@ public Long pageLimit() { return pageLimit; } + /** + * Gets the includeCount. + * + *

Whether to include information about the number of records that satisfy the request, + * regardless of the page limit. If this parameter is `true`, the `pagination` object in the + * response includes the `total` property. + * + * @return the includeCount + */ + public Boolean includeCount() { + return includeCount; + } + /** * Gets the sort. * diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListLogsOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListLogsOptions.java index 79b6f355a58..b0a93449aed 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListLogsOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListLogsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -54,7 +54,7 @@ public Builder(String workspaceId) { /** * Builds a ListLogsOptions. * - * @return the listLogsOptions + * @return the new ListLogsOptions instance */ public ListLogsOptions build() { return new ListLogsOptions(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListMentionsOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListMentionsOptions.java index 4cebc3db888..809d81b1a86 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListMentionsOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListMentionsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -53,7 +53,7 @@ public Builder(String workspaceId, String entity) { /** * Builds a ListMentionsOptions. * - * @return the listMentionsOptions + * @return the new ListMentionsOptions instance */ public ListMentionsOptions build() { return new ListMentionsOptions(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListSynonymsOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListSynonymsOptions.java index 65d7e1dfc05..842bc957296 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListSynonymsOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListSynonymsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -32,6 +32,7 @@ public interface Sort { protected String entity; protected String value; protected Long pageLimit; + protected Boolean includeCount; protected String sort; protected String cursor; protected Boolean includeAudit; @@ -42,6 +43,7 @@ public static class Builder { private String entity; private String value; private Long pageLimit; + private Boolean includeCount; private String sort; private String cursor; private Boolean includeAudit; @@ -51,6 +53,7 @@ private Builder(ListSynonymsOptions listSynonymsOptions) { this.entity = listSynonymsOptions.entity; this.value = listSynonymsOptions.value; this.pageLimit = listSynonymsOptions.pageLimit; + this.includeCount = listSynonymsOptions.includeCount; this.sort = listSynonymsOptions.sort; this.cursor = listSynonymsOptions.cursor; this.includeAudit = listSynonymsOptions.includeAudit; @@ -75,7 +78,7 @@ public Builder(String workspaceId, String entity, String value) { /** * Builds a ListSynonymsOptions. * - * @return the listSynonymsOptions + * @return the new ListSynonymsOptions instance */ public ListSynonymsOptions build() { return new ListSynonymsOptions(this); @@ -125,6 +128,17 @@ public Builder pageLimit(long pageLimit) { return this; } + /** + * Set the includeCount. + * + * @param includeCount the includeCount + * @return the ListSynonymsOptions builder + */ + public Builder includeCount(Boolean includeCount) { + this.includeCount = includeCount; + return this; + } + /** * Set the sort. * @@ -168,6 +182,7 @@ protected ListSynonymsOptions(Builder builder) { entity = builder.entity; value = builder.value; pageLimit = builder.pageLimit; + includeCount = builder.includeCount; sort = builder.sort; cursor = builder.cursor; includeAudit = builder.includeAudit; @@ -226,6 +241,19 @@ public Long pageLimit() { return pageLimit; } + /** + * Gets the includeCount. + * + *

Whether to include information about the number of records that satisfy the request, + * regardless of the page limit. If this parameter is `true`, the `pagination` object in the + * response includes the `total` property. + * + * @return the includeCount + */ + public Boolean includeCount() { + return includeCount; + } + /** * Gets the sort. * diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListValuesOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListValuesOptions.java index fe592b2ec84..edc5e436b66 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListValuesOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListValuesOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -32,6 +32,7 @@ public interface Sort { protected String entity; protected Boolean export; protected Long pageLimit; + protected Boolean includeCount; protected String sort; protected String cursor; protected Boolean includeAudit; @@ -42,6 +43,7 @@ public static class Builder { private String entity; private Boolean export; private Long pageLimit; + private Boolean includeCount; private String sort; private String cursor; private Boolean includeAudit; @@ -51,6 +53,7 @@ private Builder(ListValuesOptions listValuesOptions) { this.entity = listValuesOptions.entity; this.export = listValuesOptions.export; this.pageLimit = listValuesOptions.pageLimit; + this.includeCount = listValuesOptions.includeCount; this.sort = listValuesOptions.sort; this.cursor = listValuesOptions.cursor; this.includeAudit = listValuesOptions.includeAudit; @@ -73,7 +76,7 @@ public Builder(String workspaceId, String entity) { /** * Builds a ListValuesOptions. * - * @return the listValuesOptions + * @return the new ListValuesOptions instance */ public ListValuesOptions build() { return new ListValuesOptions(this); @@ -123,6 +126,17 @@ public Builder pageLimit(long pageLimit) { return this; } + /** + * Set the includeCount. + * + * @param includeCount the includeCount + * @return the ListValuesOptions builder + */ + public Builder includeCount(Boolean includeCount) { + this.includeCount = includeCount; + return this; + } + /** * Set the sort. * @@ -165,6 +179,7 @@ protected ListValuesOptions(Builder builder) { entity = builder.entity; export = builder.export; pageLimit = builder.pageLimit; + includeCount = builder.includeCount; sort = builder.sort; cursor = builder.cursor; includeAudit = builder.includeAudit; @@ -225,6 +240,19 @@ public Long pageLimit() { return pageLimit; } + /** + * Gets the includeCount. + * + *

Whether to include information about the number of records that satisfy the request, + * regardless of the page limit. If this parameter is `true`, the `pagination` object in the + * response includes the `total` property. + * + * @return the includeCount + */ + public Boolean includeCount() { + return includeCount; + } + /** * Gets the sort. * diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListWorkspacesOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListWorkspacesOptions.java index bc99d681d77..6c025cbf7fb 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListWorkspacesOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListWorkspacesOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -29,6 +29,7 @@ public interface Sort { } protected Long pageLimit; + protected Boolean includeCount; protected String sort; protected String cursor; protected Boolean includeAudit; @@ -36,12 +37,14 @@ public interface Sort { /** Builder. */ public static class Builder { private Long pageLimit; + private Boolean includeCount; private String sort; private String cursor; private Boolean includeAudit; private Builder(ListWorkspacesOptions listWorkspacesOptions) { this.pageLimit = listWorkspacesOptions.pageLimit; + this.includeCount = listWorkspacesOptions.includeCount; this.sort = listWorkspacesOptions.sort; this.cursor = listWorkspacesOptions.cursor; this.includeAudit = listWorkspacesOptions.includeAudit; @@ -53,7 +56,7 @@ public Builder() {} /** * Builds a ListWorkspacesOptions. * - * @return the listWorkspacesOptions + * @return the new ListWorkspacesOptions instance */ public ListWorkspacesOptions build() { return new ListWorkspacesOptions(this); @@ -70,6 +73,17 @@ public Builder pageLimit(long pageLimit) { return this; } + /** + * Set the includeCount. + * + * @param includeCount the includeCount + * @return the ListWorkspacesOptions builder + */ + public Builder includeCount(Boolean includeCount) { + this.includeCount = includeCount; + return this; + } + /** * Set the sort. * @@ -106,6 +120,7 @@ public Builder includeAudit(Boolean includeAudit) { protected ListWorkspacesOptions(Builder builder) { pageLimit = builder.pageLimit; + includeCount = builder.includeCount; sort = builder.sort; cursor = builder.cursor; includeAudit = builder.includeAudit; @@ -131,6 +146,19 @@ public Long pageLimit() { return pageLimit; } + /** + * Gets the includeCount. + * + *

Whether to include information about the number of records that satisfy the request, + * regardless of the page limit. If this parameter is `true`, the `pagination` object in the + * response includes the `total` property. + * + * @return the includeCount + */ + public Boolean includeCount() { + return includeCount; + } + /** * Gets the sort. * diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Log.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Log.java index d889a35be98..ad0aab718fe 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Log.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Log.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/LogCollection.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/LogCollection.java index 6bcc1164b3f..21dce5447f3 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/LogCollection.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/LogCollection.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/LogMessage.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/LogMessage.java index 02a1b130495..2ba04606db5 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/LogMessage.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/LogMessage.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -57,7 +57,7 @@ public Builder(String level, String msg) { /** * Builds a LogMessage. * - * @return the logMessage + * @return the new LogMessage instance */ public LogMessage build() { return new LogMessage(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/LogPagination.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/LogPagination.java index c4e0897dde1..24a9ccf1a93 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/LogPagination.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/LogPagination.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Mention.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Mention.java index 4d40f21e0f1..bdae45e66a1 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Mention.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Mention.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -49,7 +49,7 @@ public Builder(String entity, List location) { /** * Builds a Mention. * - * @return the mention + * @return the new Mention instance */ public Mention build() { return new Mention(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/MessageContextMetadata.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/MessageContextMetadata.java index cfa949eeb92..40a218e731d 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/MessageContextMetadata.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/MessageContextMetadata.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -39,7 +39,7 @@ public Builder() {} /** * Builds a MessageContextMetadata. * - * @return the messageContextMetadata + * @return the new MessageContextMetadata instance */ public MessageContextMetadata build() { return new MessageContextMetadata(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/MessageInput.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/MessageInput.java index 7a50b3586cf..02f3e967e58 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/MessageInput.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/MessageInput.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -15,6 +15,8 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.reflect.TypeToken; import com.ibm.cloud.sdk.core.service.model.DynamicModel; +import java.util.HashMap; +import java.util.Map; /** An input object that includes the input text. */ public class MessageInput extends DynamicModel { @@ -38,6 +40,99 @@ public MessageInput() { super(new TypeToken() {}); } + /** Builder. */ + public static class Builder { + private String text; + private Boolean spellingSuggestions; + private Boolean spellingAutoCorrect; + private Map dynamicProperties; + + private Builder(MessageInput messageInput) { + this.text = messageInput.text; + this.spellingSuggestions = messageInput.spellingSuggestions; + this.spellingAutoCorrect = messageInput.spellingAutoCorrect; + this.dynamicProperties = messageInput.getProperties(); + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a MessageInput. + * + * @return the new MessageInput instance + */ + public MessageInput build() { + return new MessageInput(this); + } + + /** + * Set the text. + * + * @param text the text + * @return the MessageInput builder + */ + public Builder text(String text) { + this.text = text; + return this; + } + + /** + * Set the spellingSuggestions. + * + * @param spellingSuggestions the spellingSuggestions + * @return the MessageInput builder + */ + public Builder spellingSuggestions(Boolean spellingSuggestions) { + this.spellingSuggestions = spellingSuggestions; + return this; + } + + /** + * Set the spellingAutoCorrect. + * + * @param spellingAutoCorrect the spellingAutoCorrect + * @return the MessageInput builder + */ + public Builder spellingAutoCorrect(Boolean spellingAutoCorrect) { + this.spellingAutoCorrect = spellingAutoCorrect; + return this; + } + + /** + * Add an arbitrary property. + * + * @param name the name of the property to add + * @param value the value of the property to add + * @return the MessageInput builder + */ + public Builder add(String name, Object value) { + com.ibm.cloud.sdk.core.util.Validator.notNull(name, "name cannot be null"); + if (this.dynamicProperties == null) { + this.dynamicProperties = new HashMap(); + } + this.dynamicProperties.put(name, value); + return this; + } + } + + protected MessageInput(Builder builder) { + super(new TypeToken() {}); + text = builder.text; + spellingSuggestions = builder.spellingSuggestions; + spellingAutoCorrect = builder.spellingAutoCorrect; + this.setProperties(builder.dynamicProperties); + } + + /** + * New builder. + * + * @return a MessageInput builder + */ + public Builder newBuilder() { + return new Builder(this); + } + /** * Gets the text. * @@ -117,15 +212,6 @@ public String getSuggestedText() { return this.suggestedText; } - /** - * Sets the suggestedText. - * - * @param suggestedText the new suggestedText - */ - public void setSuggestedText(final String suggestedText) { - this.suggestedText = suggestedText; - } - /** * Gets the originalText. * @@ -137,13 +223,4 @@ public void setSuggestedText(final String suggestedText) { public String getOriginalText() { return this.originalText; } - - /** - * Sets the originalText. - * - * @param originalText the new originalText - */ - public void setOriginalText(final String originalText) { - this.originalText = originalText; - } } diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/MessageOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/MessageOptions.java index 58302880755..b742b96ea60 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/MessageOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/MessageOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -65,7 +65,7 @@ public Builder(String workspaceId) { /** * Builds a MessageOptions. * - * @return the messageOptions + * @return the new MessageOptions instance */ public MessageOptions build() { return new MessageOptions(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/MessageRequest.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/MessageRequest.java index 4253b4f6267..57e1f74048e 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/MessageRequest.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/MessageRequest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2016, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -39,7 +39,6 @@ public static class Builder { private Boolean alternateIntents; private Context context; private OutputData output; - private List actions; private Builder(MessageRequest messageRequest) { this.input = messageRequest.input; @@ -48,7 +47,6 @@ private Builder(MessageRequest messageRequest) { this.alternateIntents = messageRequest.alternateIntents; this.context = messageRequest.context; this.output = messageRequest.output; - this.actions = messageRequest.actions; } /** Instantiates a new builder. */ @@ -57,7 +55,7 @@ public Builder() {} /** * Builds a MessageRequest. * - * @return the messageRequest + * @return the new MessageRequest instance */ public MessageRequest build() { return new MessageRequest(this); @@ -93,21 +91,6 @@ public Builder addEntity(RuntimeEntity entity) { return this; } - /** - * Adds an actions to actions. - * - * @param actions the new actions - * @return the MessageRequest builder - */ - public Builder addActions(DialogNodeAction actions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(actions, "actions cannot be null"); - if (this.actions == null) { - this.actions = new ArrayList(); - } - this.actions.add(actions); - return this; - } - /** * Set the input. * @@ -173,17 +156,6 @@ public Builder output(OutputData output) { this.output = output; return this; } - - /** - * Set the actions. Existing actions will be replaced. - * - * @param actions the actions - * @return the MessageRequest builder - */ - public Builder actions(List actions) { - this.actions = actions; - return this; - } } protected MessageRequest(Builder builder) { @@ -193,7 +165,6 @@ protected MessageRequest(Builder builder) { alternateIntents = builder.alternateIntents; context = builder.context; output = builder.output; - actions = builder.actions; } /** diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/MessageResponse.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/MessageResponse.java index 804d18ccad2..f3c9d8e4c24 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/MessageResponse.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/MessageResponse.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2016, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/OutputData.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/OutputData.java index 5ea591d51b9..4fb943c15ea 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/OutputData.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/OutputData.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -15,7 +15,10 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.reflect.TypeToken; import com.ibm.cloud.sdk.core.service.model.DynamicModel; +import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * An output object that includes the response to the user, the dialog nodes that were triggered, @@ -42,6 +45,217 @@ public OutputData() { super(new TypeToken() {}); } + /** Builder. */ + public static class Builder { + private List nodesVisited; + private List nodesVisitedDetails; + private List logMessages; + private List text; + private List generic; + private Map dynamicProperties; + + private Builder(OutputData outputData) { + this.nodesVisited = outputData.nodesVisited; + this.nodesVisitedDetails = outputData.nodesVisitedDetails; + this.logMessages = outputData.logMessages; + this.text = outputData.text; + this.generic = outputData.generic; + this.dynamicProperties = outputData.getProperties(); + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param logMessages the logMessages + * @param text the text + */ + public Builder(List logMessages, List text) { + this.logMessages = logMessages; + this.text = text; + } + + /** + * Builds a OutputData. + * + * @return the new OutputData instance + */ + public OutputData build() { + return new OutputData(this); + } + + /** + * Adds an nodesVisited to nodesVisited. + * + * @param nodesVisited the new nodesVisited + * @return the OutputData builder + */ + public Builder addNodesVisited(String nodesVisited) { + com.ibm.cloud.sdk.core.util.Validator.notNull(nodesVisited, "nodesVisited cannot be null"); + if (this.nodesVisited == null) { + this.nodesVisited = new ArrayList(); + } + this.nodesVisited.add(nodesVisited); + return this; + } + + /** + * Adds an nodesVisitedDetails to nodesVisitedDetails. + * + * @param nodesVisitedDetails the new nodesVisitedDetails + * @return the OutputData builder + */ + public Builder addNodesVisitedDetails(DialogNodeVisitedDetails nodesVisitedDetails) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + nodesVisitedDetails, "nodesVisitedDetails cannot be null"); + if (this.nodesVisitedDetails == null) { + this.nodesVisitedDetails = new ArrayList(); + } + this.nodesVisitedDetails.add(nodesVisitedDetails); + return this; + } + + /** + * Adds an logMessages to logMessages. + * + * @param logMessages the new logMessages + * @return the OutputData builder + */ + public Builder addLogMessages(LogMessage logMessages) { + com.ibm.cloud.sdk.core.util.Validator.notNull(logMessages, "logMessages cannot be null"); + if (this.logMessages == null) { + this.logMessages = new ArrayList(); + } + this.logMessages.add(logMessages); + return this; + } + + /** + * Adds an text to text. + * + * @param text the new text + * @return the OutputData builder + */ + public Builder addText(String text) { + com.ibm.cloud.sdk.core.util.Validator.notNull(text, "text cannot be null"); + if (this.text == null) { + this.text = new ArrayList(); + } + this.text.add(text); + return this; + } + + /** + * Adds an generic to generic. + * + * @param generic the new generic + * @return the OutputData builder + */ + public Builder addGeneric(RuntimeResponseGeneric generic) { + com.ibm.cloud.sdk.core.util.Validator.notNull(generic, "generic cannot be null"); + if (this.generic == null) { + this.generic = new ArrayList(); + } + this.generic.add(generic); + return this; + } + + /** + * Set the nodesVisited. Existing nodesVisited will be replaced. + * + * @param nodesVisited the nodesVisited + * @return the OutputData builder + */ + public Builder nodesVisited(List nodesVisited) { + this.nodesVisited = nodesVisited; + return this; + } + + /** + * Set the nodesVisitedDetails. Existing nodesVisitedDetails will be replaced. + * + * @param nodesVisitedDetails the nodesVisitedDetails + * @return the OutputData builder + */ + public Builder nodesVisitedDetails(List nodesVisitedDetails) { + this.nodesVisitedDetails = nodesVisitedDetails; + return this; + } + + /** + * Set the logMessages. Existing logMessages will be replaced. + * + * @param logMessages the logMessages + * @return the OutputData builder + */ + public Builder logMessages(List logMessages) { + this.logMessages = logMessages; + return this; + } + + /** + * Set the text. Existing text will be replaced. + * + * @param text the text + * @return the OutputData builder + */ + public Builder text(List text) { + this.text = text; + return this; + } + + /** + * Set the generic. Existing generic will be replaced. + * + * @param generic the generic + * @return the OutputData builder + */ + public Builder generic(List generic) { + this.generic = generic; + return this; + } + + /** + * Add an arbitrary property. + * + * @param name the name of the property to add + * @param value the value of the property to add + * @return the OutputData builder + */ + public Builder add(String name, Object value) { + com.ibm.cloud.sdk.core.util.Validator.notNull(name, "name cannot be null"); + if (this.dynamicProperties == null) { + this.dynamicProperties = new HashMap(); + } + this.dynamicProperties.put(name, value); + return this; + } + } + + protected OutputData(Builder builder) { + super(new TypeToken() {}); + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.logMessages, "logMessages cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.text, "text cannot be null"); + nodesVisited = builder.nodesVisited; + nodesVisitedDetails = builder.nodesVisitedDetails; + logMessages = builder.logMessages; + text = builder.text; + generic = builder.generic; + this.setProperties(builder.dynamicProperties); + } + + /** + * New builder. + * + * @return a OutputData builder + */ + public Builder newBuilder() { + return new Builder(this); + } + /** * Gets the nodesVisited. * diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Pagination.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Pagination.java index 6581a9af481..690d8a4cc5d 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Pagination.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Pagination.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -58,7 +58,8 @@ public String getNextUrl() { /** * Gets the total. * - *

Reserved for future use. + *

The total number of objects that satisfy the request. This total includes all results, not + * just those included in the current page. * * @return the total */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeEntity.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeEntity.java index a5e79f22a74..a38cd5df82d 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeEntity.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeEntity.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -73,7 +73,7 @@ public Builder(String entity, List location, String value) { /** * Builds a RuntimeEntity. * - * @return the runtimeEntity + * @return the new RuntimeEntity instance */ public RuntimeEntity build() { return new RuntimeEntity(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeEntityAlternative.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeEntityAlternative.java index 0df8a932c90..2cec2cc18ab 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeEntityAlternative.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeEntityAlternative.java @@ -36,7 +36,7 @@ public Builder() {} /** * Builds a RuntimeEntityAlternative. * - * @return the runtimeEntityAlternative + * @return the new RuntimeEntityAlternative instance */ public RuntimeEntityAlternative build() { return new RuntimeEntityAlternative(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeEntityInterpretation.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeEntityInterpretation.java index 5e0ea581719..7e580674124 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeEntityInterpretation.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeEntityInterpretation.java @@ -184,7 +184,7 @@ public Builder() {} /** * Builds a RuntimeEntityInterpretation. * - * @return the runtimeEntityInterpretation + * @return the new RuntimeEntityInterpretation instance */ public RuntimeEntityInterpretation build() { return new RuntimeEntityInterpretation(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeEntityRole.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeEntityRole.java index ae6d27c5c16..7c46a7de543 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeEntityRole.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeEntityRole.java @@ -53,7 +53,7 @@ public Builder() {} /** * Builds a RuntimeEntityRole. * - * @return the runtimeEntityRole + * @return the new RuntimeEntityRole instance */ public RuntimeEntityRole build() { return new RuntimeEntityRole(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeIntent.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeIntent.java index 9247cd7649c..bdd80b66404 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeIntent.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeIntent.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -47,7 +47,7 @@ public Builder(String intent, Double confidence) { /** * Builds a RuntimeIntent. * - * @return the runtimeIntent + * @return the new RuntimeIntent instance */ public RuntimeIntent build() { return new RuntimeIntent(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGeneric.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGeneric.java index ab59c40fb0a..262e06b1919 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGeneric.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGeneric.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -14,11 +14,34 @@ import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; -import java.util.ArrayList; import java.util.List; -/** RuntimeResponseGeneric. */ +/** + * RuntimeResponseGeneric. + * + *

Classes which extend this class: - RuntimeResponseGenericRuntimeResponseTypeText - + * RuntimeResponseGenericRuntimeResponseTypePause - RuntimeResponseGenericRuntimeResponseTypeImage - + * RuntimeResponseGenericRuntimeResponseTypeOption - + * RuntimeResponseGenericRuntimeResponseTypeConnectToAgent - + * RuntimeResponseGenericRuntimeResponseTypeSuggestion + */ public class RuntimeResponseGeneric extends GenericModel { + @SuppressWarnings("unused") + protected static String discriminatorPropertyName = "response_type"; + + protected static java.util.Map> discriminatorMapping; + + static { + discriminatorMapping = new java.util.HashMap<>(); + discriminatorMapping.put( + "connect_to_agent", RuntimeResponseGenericRuntimeResponseTypeConnectToAgent.class); + discriminatorMapping.put("image", RuntimeResponseGenericRuntimeResponseTypeImage.class); + discriminatorMapping.put("option", RuntimeResponseGenericRuntimeResponseTypeOption.class); + discriminatorMapping.put( + "suggestion", RuntimeResponseGenericRuntimeResponseTypeSuggestion.class); + discriminatorMapping.put("pause", RuntimeResponseGenericRuntimeResponseTypePause.class); + discriminatorMapping.put("text", RuntimeResponseGenericRuntimeResponseTypeText.class); + } /** * The type of response returned by the dialog node. The specified response type must be supported @@ -27,16 +50,6 @@ public class RuntimeResponseGeneric extends GenericModel { public interface ResponseType { /** text. */ String TEXT = "text"; - /** pause. */ - String PAUSE = "pause"; - /** image. */ - String IMAGE = "image"; - /** option. */ - String OPTION = "option"; - /** connect_to_agent. */ - String CONNECT_TO_AGENT = "connect_to_agent"; - /** suggestion. */ - String SUGGESTION = "suggestion"; } /** The preferred type of control to display. */ @@ -62,6 +75,15 @@ public interface Preference { @SerializedName("message_to_human_agent") protected String messageToHumanAgent; + @SerializedName("agent_available") + protected String agentAvailable; + + @SerializedName("agent_unavailable") + protected String agentUnavailable; + + @SerializedName("transfer_info") + protected DialogNodeOutputConnectToAgentTransferInfo transferInfo; + protected String topic; @SerializedName("dialog_node") @@ -69,259 +91,7 @@ public interface Preference { protected List suggestions; - /** Builder. */ - public static class Builder { - private String responseType; - private String text; - private Long time; - private Boolean typing; - private String source; - private String title; - private String description; - private String preference; - private List options; - private String messageToHumanAgent; - private String topic; - private String dialogNode; - private List suggestions; - - private Builder(RuntimeResponseGeneric runtimeResponseGeneric) { - this.responseType = runtimeResponseGeneric.responseType; - this.text = runtimeResponseGeneric.text; - this.time = runtimeResponseGeneric.time; - this.typing = runtimeResponseGeneric.typing; - this.source = runtimeResponseGeneric.source; - this.title = runtimeResponseGeneric.title; - this.description = runtimeResponseGeneric.description; - this.preference = runtimeResponseGeneric.preference; - this.options = runtimeResponseGeneric.options; - this.messageToHumanAgent = runtimeResponseGeneric.messageToHumanAgent; - this.topic = runtimeResponseGeneric.topic; - this.dialogNode = runtimeResponseGeneric.dialogNode; - this.suggestions = runtimeResponseGeneric.suggestions; - } - - /** Instantiates a new builder. */ - public Builder() {} - - /** - * Instantiates a new builder with required properties. - * - * @param responseType the responseType - */ - public Builder(String responseType) { - this.responseType = responseType; - } - - /** - * Builds a RuntimeResponseGeneric. - * - * @return the runtimeResponseGeneric - */ - public RuntimeResponseGeneric build() { - return new RuntimeResponseGeneric(this); - } - - /** - * Adds an options to options. - * - * @param options the new options - * @return the RuntimeResponseGeneric builder - */ - public Builder addOptions(DialogNodeOutputOptionsElement options) { - com.ibm.cloud.sdk.core.util.Validator.notNull(options, "options cannot be null"); - if (this.options == null) { - this.options = new ArrayList(); - } - this.options.add(options); - return this; - } - - /** - * Adds an suggestions to suggestions. - * - * @param suggestions the new suggestions - * @return the RuntimeResponseGeneric builder - */ - public Builder addSuggestions(DialogSuggestion suggestions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(suggestions, "suggestions cannot be null"); - if (this.suggestions == null) { - this.suggestions = new ArrayList(); - } - this.suggestions.add(suggestions); - return this; - } - - /** - * Set the responseType. - * - * @param responseType the responseType - * @return the RuntimeResponseGeneric builder - */ - public Builder responseType(String responseType) { - this.responseType = responseType; - return this; - } - - /** - * Set the text. - * - * @param text the text - * @return the RuntimeResponseGeneric builder - */ - public Builder text(String text) { - this.text = text; - return this; - } - - /** - * Set the time. - * - * @param time the time - * @return the RuntimeResponseGeneric builder - */ - public Builder time(long time) { - this.time = time; - return this; - } - - /** - * Set the typing. - * - * @param typing the typing - * @return the RuntimeResponseGeneric builder - */ - public Builder typing(Boolean typing) { - this.typing = typing; - return this; - } - - /** - * Set the source. - * - * @param source the source - * @return the RuntimeResponseGeneric builder - */ - public Builder source(String source) { - this.source = source; - return this; - } - - /** - * Set the title. - * - * @param title the title - * @return the RuntimeResponseGeneric builder - */ - public Builder title(String title) { - this.title = title; - return this; - } - - /** - * Set the description. - * - * @param description the description - * @return the RuntimeResponseGeneric builder - */ - public Builder description(String description) { - this.description = description; - return this; - } - - /** - * Set the preference. - * - * @param preference the preference - * @return the RuntimeResponseGeneric builder - */ - public Builder preference(String preference) { - this.preference = preference; - return this; - } - - /** - * Set the options. Existing options will be replaced. - * - * @param options the options - * @return the RuntimeResponseGeneric builder - */ - public Builder options(List options) { - this.options = options; - return this; - } - - /** - * Set the messageToHumanAgent. - * - * @param messageToHumanAgent the messageToHumanAgent - * @return the RuntimeResponseGeneric builder - */ - public Builder messageToHumanAgent(String messageToHumanAgent) { - this.messageToHumanAgent = messageToHumanAgent; - return this; - } - - /** - * Set the topic. - * - * @param topic the topic - * @return the RuntimeResponseGeneric builder - */ - public Builder topic(String topic) { - this.topic = topic; - return this; - } - - /** - * Set the dialogNode. - * - * @param dialogNode the dialogNode - * @return the RuntimeResponseGeneric builder - */ - public Builder dialogNode(String dialogNode) { - this.dialogNode = dialogNode; - return this; - } - - /** - * Set the suggestions. Existing suggestions will be replaced. - * - * @param suggestions the suggestions - * @return the RuntimeResponseGeneric builder - */ - public Builder suggestions(List suggestions) { - this.suggestions = suggestions; - return this; - } - } - - protected RuntimeResponseGeneric(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull( - builder.responseType, "responseType cannot be null"); - responseType = builder.responseType; - text = builder.text; - time = builder.time; - typing = builder.typing; - source = builder.source; - title = builder.title; - description = builder.description; - preference = builder.preference; - options = builder.options; - messageToHumanAgent = builder.messageToHumanAgent; - topic = builder.topic; - dialogNode = builder.dialogNode; - suggestions = builder.suggestions; - } - - /** - * New builder. - * - * @return a RuntimeResponseGeneric builder - */ - public Builder newBuilder() { - return new Builder(this); - } + protected RuntimeResponseGeneric() {} /** * Gets the responseType. @@ -434,11 +204,46 @@ public String messageToHumanAgent() { return messageToHumanAgent; } + /** + * Gets the agentAvailable. + * + *

An optional message to be displayed to the user to indicate that the conversation will be + * transferred to the next available agent. + * + * @return the agentAvailable + */ + public String agentAvailable() { + return agentAvailable; + } + + /** + * Gets the agentUnavailable. + * + *

An optional message to be displayed to the user to indicate that no online agent is + * available to take over the conversation. + * + * @return the agentUnavailable + */ + public String agentUnavailable() { + return agentUnavailable; + } + + /** + * Gets the transferInfo. + * + *

Routing or other contextual information to be used by target service desk systems. + * + * @return the transferInfo + */ + public DialogNodeOutputConnectToAgentTransferInfo transferInfo() { + return transferInfo; + } + /** * Gets the topic. * *

A label identifying the topic of the conversation, derived from the **title** property of - * the relevant node. + * the relevant node or the **topic** property of the dialog node response. * * @return the topic */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeConnectToAgent.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeConnectToAgent.java new file mode 100644 index 00000000000..cb8f275f07d --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeConnectToAgent.java @@ -0,0 +1,169 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +/** An object that describes a response with response type `connect_to_agent`. */ +public class RuntimeResponseGenericRuntimeResponseTypeConnectToAgent + extends RuntimeResponseGeneric { + + /** + * The type of response returned by the dialog node. The specified response type must be supported + * by the client application or channel. + */ + public interface ResponseType { + /** connect_to_agent. */ + String CONNECT_TO_AGENT = "connect_to_agent"; + } + + /** Builder. */ + public static class Builder { + private String responseType; + private String messageToHumanAgent; + private String agentAvailable; + private String agentUnavailable; + private DialogNodeOutputConnectToAgentTransferInfo transferInfo; + private String topic; + private String dialogNode; + + public Builder(RuntimeResponseGeneric runtimeResponseGenericRuntimeResponseTypeConnectToAgent) { + this.responseType = runtimeResponseGenericRuntimeResponseTypeConnectToAgent.responseType; + this.messageToHumanAgent = + runtimeResponseGenericRuntimeResponseTypeConnectToAgent.messageToHumanAgent; + this.agentAvailable = runtimeResponseGenericRuntimeResponseTypeConnectToAgent.agentAvailable; + this.agentUnavailable = + runtimeResponseGenericRuntimeResponseTypeConnectToAgent.agentUnavailable; + this.transferInfo = runtimeResponseGenericRuntimeResponseTypeConnectToAgent.transferInfo; + this.topic = runtimeResponseGenericRuntimeResponseTypeConnectToAgent.topic; + this.dialogNode = runtimeResponseGenericRuntimeResponseTypeConnectToAgent.dialogNode; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param responseType the responseType + */ + public Builder(String responseType) { + this.responseType = responseType; + } + + /** + * Builds a RuntimeResponseGenericRuntimeResponseTypeConnectToAgent. + * + * @return the new RuntimeResponseGenericRuntimeResponseTypeConnectToAgent instance + */ + public RuntimeResponseGenericRuntimeResponseTypeConnectToAgent build() { + return new RuntimeResponseGenericRuntimeResponseTypeConnectToAgent(this); + } + + /** + * Set the responseType. + * + * @param responseType the responseType + * @return the RuntimeResponseGenericRuntimeResponseTypeConnectToAgent builder + */ + public Builder responseType(String responseType) { + this.responseType = responseType; + return this; + } + + /** + * Set the messageToHumanAgent. + * + * @param messageToHumanAgent the messageToHumanAgent + * @return the RuntimeResponseGenericRuntimeResponseTypeConnectToAgent builder + */ + public Builder messageToHumanAgent(String messageToHumanAgent) { + this.messageToHumanAgent = messageToHumanAgent; + return this; + } + + /** + * Set the agentAvailable. + * + * @param agentAvailable the agentAvailable + * @return the RuntimeResponseGenericRuntimeResponseTypeConnectToAgent builder + */ + public Builder agentAvailable(String agentAvailable) { + this.agentAvailable = agentAvailable; + return this; + } + + /** + * Set the agentUnavailable. + * + * @param agentUnavailable the agentUnavailable + * @return the RuntimeResponseGenericRuntimeResponseTypeConnectToAgent builder + */ + public Builder agentUnavailable(String agentUnavailable) { + this.agentUnavailable = agentUnavailable; + return this; + } + + /** + * Set the transferInfo. + * + * @param transferInfo the transferInfo + * @return the RuntimeResponseGenericRuntimeResponseTypeConnectToAgent builder + */ + public Builder transferInfo(DialogNodeOutputConnectToAgentTransferInfo transferInfo) { + this.transferInfo = transferInfo; + return this; + } + + /** + * Set the topic. + * + * @param topic the topic + * @return the RuntimeResponseGenericRuntimeResponseTypeConnectToAgent builder + */ + public Builder topic(String topic) { + this.topic = topic; + return this; + } + + /** + * Set the dialogNode. + * + * @param dialogNode the dialogNode + * @return the RuntimeResponseGenericRuntimeResponseTypeConnectToAgent builder + */ + public Builder dialogNode(String dialogNode) { + this.dialogNode = dialogNode; + return this; + } + } + + protected RuntimeResponseGenericRuntimeResponseTypeConnectToAgent(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.responseType, "responseType cannot be null"); + responseType = builder.responseType; + messageToHumanAgent = builder.messageToHumanAgent; + agentAvailable = builder.agentAvailable; + agentUnavailable = builder.agentUnavailable; + transferInfo = builder.transferInfo; + topic = builder.topic; + dialogNode = builder.dialogNode; + } + + /** + * New builder. + * + * @return a RuntimeResponseGenericRuntimeResponseTypeConnectToAgent builder + */ + public Builder newBuilder() { + return new Builder(this); + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeImage.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeImage.java new file mode 100644 index 00000000000..1ee84cadd86 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeImage.java @@ -0,0 +1,127 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +/** An object that describes a response with response type `image`. */ +public class RuntimeResponseGenericRuntimeResponseTypeImage extends RuntimeResponseGeneric { + + /** + * The type of response returned by the dialog node. The specified response type must be supported + * by the client application or channel. + */ + public interface ResponseType { + /** image. */ + String IMAGE = "image"; + } + + /** Builder. */ + public static class Builder { + private String responseType; + private String source; + private String title; + private String description; + + public Builder(RuntimeResponseGeneric runtimeResponseGenericRuntimeResponseTypeImage) { + this.responseType = runtimeResponseGenericRuntimeResponseTypeImage.responseType; + this.source = runtimeResponseGenericRuntimeResponseTypeImage.source; + this.title = runtimeResponseGenericRuntimeResponseTypeImage.title; + this.description = runtimeResponseGenericRuntimeResponseTypeImage.description; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param responseType the responseType + * @param source the source + */ + public Builder(String responseType, String source) { + this.responseType = responseType; + this.source = source; + } + + /** + * Builds a RuntimeResponseGenericRuntimeResponseTypeImage. + * + * @return the new RuntimeResponseGenericRuntimeResponseTypeImage instance + */ + public RuntimeResponseGenericRuntimeResponseTypeImage build() { + return new RuntimeResponseGenericRuntimeResponseTypeImage(this); + } + + /** + * Set the responseType. + * + * @param responseType the responseType + * @return the RuntimeResponseGenericRuntimeResponseTypeImage builder + */ + public Builder responseType(String responseType) { + this.responseType = responseType; + return this; + } + + /** + * Set the source. + * + * @param source the source + * @return the RuntimeResponseGenericRuntimeResponseTypeImage builder + */ + public Builder source(String source) { + this.source = source; + return this; + } + + /** + * Set the title. + * + * @param title the title + * @return the RuntimeResponseGenericRuntimeResponseTypeImage builder + */ + public Builder title(String title) { + this.title = title; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the RuntimeResponseGenericRuntimeResponseTypeImage builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + } + + protected RuntimeResponseGenericRuntimeResponseTypeImage(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.responseType, "responseType cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.source, "source cannot be null"); + responseType = builder.responseType; + source = builder.source; + title = builder.title; + description = builder.description; + } + + /** + * New builder. + * + * @return a RuntimeResponseGenericRuntimeResponseTypeImage builder + */ + public Builder newBuilder() { + return new Builder(this); + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeOption.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeOption.java new file mode 100644 index 00000000000..1ba5179c185 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeOption.java @@ -0,0 +1,171 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import java.util.ArrayList; +import java.util.List; + +/** An object that describes a response with response type `option`. */ +public class RuntimeResponseGenericRuntimeResponseTypeOption extends RuntimeResponseGeneric { + + /** + * The type of response returned by the dialog node. The specified response type must be supported + * by the client application or channel. + */ + public interface ResponseType { + /** option. */ + String OPTION = "option"; + } + + /** The preferred type of control to display. */ + public interface Preference { + /** dropdown. */ + String DROPDOWN = "dropdown"; + /** button. */ + String BUTTON = "button"; + } + + /** Builder. */ + public static class Builder { + private String responseType; + private String title; + private String description; + private String preference; + private List options; + + public Builder(RuntimeResponseGeneric runtimeResponseGenericRuntimeResponseTypeOption) { + this.responseType = runtimeResponseGenericRuntimeResponseTypeOption.responseType; + this.title = runtimeResponseGenericRuntimeResponseTypeOption.title; + this.description = runtimeResponseGenericRuntimeResponseTypeOption.description; + this.preference = runtimeResponseGenericRuntimeResponseTypeOption.preference; + this.options = runtimeResponseGenericRuntimeResponseTypeOption.options; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param responseType the responseType + * @param title the title + * @param options the options + */ + public Builder( + String responseType, String title, List options) { + this.responseType = responseType; + this.title = title; + this.options = options; + } + + /** + * Builds a RuntimeResponseGenericRuntimeResponseTypeOption. + * + * @return the new RuntimeResponseGenericRuntimeResponseTypeOption instance + */ + public RuntimeResponseGenericRuntimeResponseTypeOption build() { + return new RuntimeResponseGenericRuntimeResponseTypeOption(this); + } + + /** + * Adds an options to options. + * + * @param options the new options + * @return the RuntimeResponseGenericRuntimeResponseTypeOption builder + */ + public Builder addOptions(DialogNodeOutputOptionsElement options) { + com.ibm.cloud.sdk.core.util.Validator.notNull(options, "options cannot be null"); + if (this.options == null) { + this.options = new ArrayList(); + } + this.options.add(options); + return this; + } + + /** + * Set the responseType. + * + * @param responseType the responseType + * @return the RuntimeResponseGenericRuntimeResponseTypeOption builder + */ + public Builder responseType(String responseType) { + this.responseType = responseType; + return this; + } + + /** + * Set the title. + * + * @param title the title + * @return the RuntimeResponseGenericRuntimeResponseTypeOption builder + */ + public Builder title(String title) { + this.title = title; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the RuntimeResponseGenericRuntimeResponseTypeOption builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the preference. + * + * @param preference the preference + * @return the RuntimeResponseGenericRuntimeResponseTypeOption builder + */ + public Builder preference(String preference) { + this.preference = preference; + return this; + } + + /** + * Set the options. Existing options will be replaced. + * + * @param options the options + * @return the RuntimeResponseGenericRuntimeResponseTypeOption builder + */ + public Builder options(List options) { + this.options = options; + return this; + } + } + + protected RuntimeResponseGenericRuntimeResponseTypeOption(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.responseType, "responseType cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.title, "title cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.options, "options cannot be null"); + responseType = builder.responseType; + title = builder.title; + description = builder.description; + preference = builder.preference; + options = builder.options; + } + + /** + * New builder. + * + * @return a RuntimeResponseGenericRuntimeResponseTypeOption builder + */ + public Builder newBuilder() { + return new Builder(this); + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypePause.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypePause.java new file mode 100644 index 00000000000..891239ed407 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypePause.java @@ -0,0 +1,113 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +/** An object that describes a response with response type `pause`. */ +public class RuntimeResponseGenericRuntimeResponseTypePause extends RuntimeResponseGeneric { + + /** + * The type of response returned by the dialog node. The specified response type must be supported + * by the client application or channel. + */ + public interface ResponseType { + /** pause. */ + String PAUSE = "pause"; + } + + /** Builder. */ + public static class Builder { + private String responseType; + private Long time; + private Boolean typing; + + public Builder(RuntimeResponseGeneric runtimeResponseGenericRuntimeResponseTypePause) { + this.responseType = runtimeResponseGenericRuntimeResponseTypePause.responseType; + this.time = runtimeResponseGenericRuntimeResponseTypePause.time; + this.typing = runtimeResponseGenericRuntimeResponseTypePause.typing; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param responseType the responseType + * @param time the time + */ + public Builder(String responseType, Long time) { + this.responseType = responseType; + this.time = time; + } + + /** + * Builds a RuntimeResponseGenericRuntimeResponseTypePause. + * + * @return the new RuntimeResponseGenericRuntimeResponseTypePause instance + */ + public RuntimeResponseGenericRuntimeResponseTypePause build() { + return new RuntimeResponseGenericRuntimeResponseTypePause(this); + } + + /** + * Set the responseType. + * + * @param responseType the responseType + * @return the RuntimeResponseGenericRuntimeResponseTypePause builder + */ + public Builder responseType(String responseType) { + this.responseType = responseType; + return this; + } + + /** + * Set the time. + * + * @param time the time + * @return the RuntimeResponseGenericRuntimeResponseTypePause builder + */ + public Builder time(long time) { + this.time = time; + return this; + } + + /** + * Set the typing. + * + * @param typing the typing + * @return the RuntimeResponseGenericRuntimeResponseTypePause builder + */ + public Builder typing(Boolean typing) { + this.typing = typing; + return this; + } + } + + protected RuntimeResponseGenericRuntimeResponseTypePause(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.responseType, "responseType cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.time, "time cannot be null"); + responseType = builder.responseType; + time = builder.time; + typing = builder.typing; + } + + /** + * New builder. + * + * @return a RuntimeResponseGenericRuntimeResponseTypePause builder + */ + public Builder newBuilder() { + return new Builder(this); + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeSuggestion.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeSuggestion.java new file mode 100644 index 00000000000..e2c48c2d3f5 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeSuggestion.java @@ -0,0 +1,135 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import java.util.ArrayList; +import java.util.List; + +/** An object that describes a response with response type `suggestion`. */ +public class RuntimeResponseGenericRuntimeResponseTypeSuggestion extends RuntimeResponseGeneric { + + /** + * The type of response returned by the dialog node. The specified response type must be supported + * by the client application or channel. + */ + public interface ResponseType { + /** suggestion. */ + String SUGGESTION = "suggestion"; + } + + /** Builder. */ + public static class Builder { + private String responseType; + private String title; + private List suggestions; + + public Builder(RuntimeResponseGeneric runtimeResponseGenericRuntimeResponseTypeSuggestion) { + this.responseType = runtimeResponseGenericRuntimeResponseTypeSuggestion.responseType; + this.title = runtimeResponseGenericRuntimeResponseTypeSuggestion.title; + this.suggestions = runtimeResponseGenericRuntimeResponseTypeSuggestion.suggestions; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param responseType the responseType + * @param title the title + * @param suggestions the suggestions + */ + public Builder(String responseType, String title, List suggestions) { + this.responseType = responseType; + this.title = title; + this.suggestions = suggestions; + } + + /** + * Builds a RuntimeResponseGenericRuntimeResponseTypeSuggestion. + * + * @return the new RuntimeResponseGenericRuntimeResponseTypeSuggestion instance + */ + public RuntimeResponseGenericRuntimeResponseTypeSuggestion build() { + return new RuntimeResponseGenericRuntimeResponseTypeSuggestion(this); + } + + /** + * Adds an suggestions to suggestions. + * + * @param suggestions the new suggestions + * @return the RuntimeResponseGenericRuntimeResponseTypeSuggestion builder + */ + public Builder addSuggestions(DialogSuggestion suggestions) { + com.ibm.cloud.sdk.core.util.Validator.notNull(suggestions, "suggestions cannot be null"); + if (this.suggestions == null) { + this.suggestions = new ArrayList(); + } + this.suggestions.add(suggestions); + return this; + } + + /** + * Set the responseType. + * + * @param responseType the responseType + * @return the RuntimeResponseGenericRuntimeResponseTypeSuggestion builder + */ + public Builder responseType(String responseType) { + this.responseType = responseType; + return this; + } + + /** + * Set the title. + * + * @param title the title + * @return the RuntimeResponseGenericRuntimeResponseTypeSuggestion builder + */ + public Builder title(String title) { + this.title = title; + return this; + } + + /** + * Set the suggestions. Existing suggestions will be replaced. + * + * @param suggestions the suggestions + * @return the RuntimeResponseGenericRuntimeResponseTypeSuggestion builder + */ + public Builder suggestions(List suggestions) { + this.suggestions = suggestions; + return this; + } + } + + protected RuntimeResponseGenericRuntimeResponseTypeSuggestion(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.responseType, "responseType cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.title, "title cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.suggestions, "suggestions cannot be null"); + responseType = builder.responseType; + title = builder.title; + suggestions = builder.suggestions; + } + + /** + * New builder. + * + * @return a RuntimeResponseGenericRuntimeResponseTypeSuggestion builder + */ + public Builder newBuilder() { + return new Builder(this); + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeText.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeText.java new file mode 100644 index 00000000000..9a4a7dbff41 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeText.java @@ -0,0 +1,99 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +/** An object that describes a response with response type `text`. */ +public class RuntimeResponseGenericRuntimeResponseTypeText extends RuntimeResponseGeneric { + + /** + * The type of response returned by the dialog node. The specified response type must be supported + * by the client application or channel. + */ + public interface ResponseType { + /** text. */ + String TEXT = "text"; + } + + /** Builder. */ + public static class Builder { + private String responseType; + private String text; + + public Builder(RuntimeResponseGeneric runtimeResponseGenericRuntimeResponseTypeText) { + this.responseType = runtimeResponseGenericRuntimeResponseTypeText.responseType; + this.text = runtimeResponseGenericRuntimeResponseTypeText.text; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param responseType the responseType + * @param text the text + */ + public Builder(String responseType, String text) { + this.responseType = responseType; + this.text = text; + } + + /** + * Builds a RuntimeResponseGenericRuntimeResponseTypeText. + * + * @return the new RuntimeResponseGenericRuntimeResponseTypeText instance + */ + public RuntimeResponseGenericRuntimeResponseTypeText build() { + return new RuntimeResponseGenericRuntimeResponseTypeText(this); + } + + /** + * Set the responseType. + * + * @param responseType the responseType + * @return the RuntimeResponseGenericRuntimeResponseTypeText builder + */ + public Builder responseType(String responseType) { + this.responseType = responseType; + return this; + } + + /** + * Set the text. + * + * @param text the text + * @return the RuntimeResponseGenericRuntimeResponseTypeText builder + */ + public Builder text(String text) { + this.text = text; + return this; + } + } + + protected RuntimeResponseGenericRuntimeResponseTypeText(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.responseType, "responseType cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.text, "text cannot be null"); + responseType = builder.responseType; + text = builder.text; + } + + /** + * New builder. + * + * @return a RuntimeResponseGenericRuntimeResponseTypeText builder + */ + public Builder newBuilder() { + return new Builder(this); + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Synonym.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Synonym.java index ff284f311f1..68dd0a97785 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Synonym.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Synonym.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -25,13 +25,9 @@ public class Synonym extends GenericModel { /** Builder. */ public static class Builder { private String synonym; - private Date created; - private Date updated; private Builder(Synonym synonym) { this.synonym = synonym.synonym; - this.created = synonym.created; - this.updated = synonym.updated; } /** Instantiates a new builder. */ @@ -49,7 +45,7 @@ public Builder(String synonym) { /** * Builds a Synonym. * - * @return the synonym + * @return the new Synonym instance */ public Synonym build() { return new Synonym(this); @@ -65,35 +61,11 @@ public Builder synonym(String synonym) { this.synonym = synonym; return this; } - - /** - * Set the created. - * - * @param created the created - * @return the Synonym builder - */ - public Builder created(Date created) { - this.created = created; - return this; - } - - /** - * Set the updated. - * - * @param updated the updated - * @return the Synonym builder - */ - public Builder updated(Date updated) { - this.updated = updated; - return this; - } } protected Synonym(Builder builder) { com.ibm.cloud.sdk.core.util.Validator.notNull(builder.synonym, "synonym cannot be null"); synonym = builder.synonym; - created = builder.created; - updated = builder.updated; } /** diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/SynonymCollection.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/SynonymCollection.java index 7139eac49a0..f81149579f3 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/SynonymCollection.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/SynonymCollection.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateCounterexampleOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateCounterexampleOptions.java index d59c6bac43c..a8710e31a6f 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateCounterexampleOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateCounterexampleOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -53,7 +53,7 @@ public Builder(String workspaceId, String text) { /** * Builds a UpdateCounterexampleOptions. * - * @return the updateCounterexampleOptions + * @return the new UpdateCounterexampleOptions instance */ public UpdateCounterexampleOptions build() { return new UpdateCounterexampleOptions(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateDialogNodeOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateDialogNodeOptions.java index 7bd98f86a2c..8aa104601dc 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateDialogNodeOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateDialogNodeOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -96,7 +96,7 @@ public interface NewDigressOutSlots { protected String newParent; protected String newPreviousSibling; protected DialogNodeOutput newOutput; - protected Map newContext; + protected DialogNodeContext newContext; protected Map newMetadata; protected DialogNodeNextStep newNextStep; protected String newTitle; @@ -121,7 +121,7 @@ public static class Builder { private String newParent; private String newPreviousSibling; private DialogNodeOutput newOutput; - private Map newContext; + private DialogNodeContext newContext; private Map newMetadata; private DialogNodeNextStep newNextStep; private String newTitle; @@ -178,7 +178,7 @@ public Builder(String workspaceId, String dialogNode) { /** * Builds a UpdateDialogNodeOptions. * - * @return the updateDialogNodeOptions + * @return the new UpdateDialogNodeOptions instance */ public UpdateDialogNodeOptions build() { return new UpdateDialogNodeOptions(this); @@ -293,7 +293,7 @@ public Builder newOutput(DialogNodeOutput newOutput) { * @param newContext the newContext * @return the UpdateDialogNodeOptions builder */ - public Builder newContext(Map newContext) { + public Builder newContext(DialogNodeContext newContext) { this.newContext = newContext; return this; } @@ -581,7 +581,7 @@ public DialogNodeOutput newOutput() { * * @return the newContext */ - public Map newContext() { + public DialogNodeContext newContext() { return newContext; } diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateEntityOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateEntityOptions.java index 5ca3aba2156..1ca61362881 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateEntityOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateEntityOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -71,7 +71,7 @@ public Builder(String workspaceId, String entity) { /** * Builds a UpdateEntityOptions. * - * @return the updateEntityOptions + * @return the new UpdateEntityOptions instance */ public UpdateEntityOptions build() { return new UpdateEntityOptions(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateExampleOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateExampleOptions.java index 698e86b2269..0f90921910a 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateExampleOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateExampleOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -63,7 +63,7 @@ public Builder(String workspaceId, String intent, String text) { /** * Builds a UpdateExampleOptions. * - * @return the updateExampleOptions + * @return the new UpdateExampleOptions instance */ public UpdateExampleOptions build() { return new UpdateExampleOptions(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateIntentOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateIntentOptions.java index 3020a113132..ecc1f49b367 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateIntentOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateIntentOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -64,7 +64,7 @@ public Builder(String workspaceId, String intent) { /** * Builds a UpdateIntentOptions. * - * @return the updateIntentOptions + * @return the new UpdateIntentOptions instance */ public UpdateIntentOptions build() { return new UpdateIntentOptions(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateSynonymOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateSynonymOptions.java index 8c751c89e14..a28b7cccc51 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateSynonymOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateSynonymOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -63,7 +63,7 @@ public Builder(String workspaceId, String entity, String value, String synonym) /** * Builds a UpdateSynonymOptions. * - * @return the updateSynonymOptions + * @return the new UpdateSynonymOptions instance */ public UpdateSynonymOptions build() { return new UpdateSynonymOptions(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateValueOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateValueOptions.java index fffd3caad72..818cca9c07e 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateValueOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateValueOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -84,7 +84,7 @@ public Builder(String workspaceId, String entity, String value) { /** * Builds a UpdateValueOptions. * - * @return the updateValueOptions + * @return the new UpdateValueOptions instance */ public UpdateValueOptions build() { return new UpdateValueOptions(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateWorkspaceOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateWorkspaceOptions.java index 2c23989df83..38c6e202fcc 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateWorkspaceOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateWorkspaceOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -24,14 +24,14 @@ public class UpdateWorkspaceOptions extends GenericModel { protected String name; protected String description; protected String language; + protected List dialogNodes; + protected List counterexamples; protected Map metadata; protected Boolean learningOptOut; protected WorkspaceSystemSettings systemSettings; + protected List webhooks; protected List intents; protected List entities; - protected List dialogNodes; - protected List counterexamples; - protected List webhooks; protected Boolean append; protected Boolean includeAudit; @@ -41,14 +41,14 @@ public static class Builder { private String name; private String description; private String language; + private List dialogNodes; + private List counterexamples; private Map metadata; private Boolean learningOptOut; private WorkspaceSystemSettings systemSettings; + private List webhooks; private List intents; private List entities; - private List dialogNodes; - private List counterexamples; - private List webhooks; private Boolean append; private Boolean includeAudit; @@ -57,14 +57,14 @@ private Builder(UpdateWorkspaceOptions updateWorkspaceOptions) { this.name = updateWorkspaceOptions.name; this.description = updateWorkspaceOptions.description; this.language = updateWorkspaceOptions.language; + this.dialogNodes = updateWorkspaceOptions.dialogNodes; + this.counterexamples = updateWorkspaceOptions.counterexamples; this.metadata = updateWorkspaceOptions.metadata; this.learningOptOut = updateWorkspaceOptions.learningOptOut; this.systemSettings = updateWorkspaceOptions.systemSettings; + this.webhooks = updateWorkspaceOptions.webhooks; this.intents = updateWorkspaceOptions.intents; this.entities = updateWorkspaceOptions.entities; - this.dialogNodes = updateWorkspaceOptions.dialogNodes; - this.counterexamples = updateWorkspaceOptions.counterexamples; - this.webhooks = updateWorkspaceOptions.webhooks; this.append = updateWorkspaceOptions.append; this.includeAudit = updateWorkspaceOptions.includeAudit; } @@ -84,42 +84,12 @@ public Builder(String workspaceId) { /** * Builds a UpdateWorkspaceOptions. * - * @return the updateWorkspaceOptions + * @return the new UpdateWorkspaceOptions instance */ public UpdateWorkspaceOptions build() { return new UpdateWorkspaceOptions(this); } - /** - * Adds an intent to intents. - * - * @param intent the new intent - * @return the UpdateWorkspaceOptions builder - */ - public Builder addIntent(CreateIntent intent) { - com.ibm.cloud.sdk.core.util.Validator.notNull(intent, "intent cannot be null"); - if (this.intents == null) { - this.intents = new ArrayList(); - } - this.intents.add(intent); - return this; - } - - /** - * Adds an entity to entities. - * - * @param entity the new entity - * @return the UpdateWorkspaceOptions builder - */ - public Builder addEntity(CreateEntity entity) { - com.ibm.cloud.sdk.core.util.Validator.notNull(entity, "entity cannot be null"); - if (this.entities == null) { - this.entities = new ArrayList(); - } - this.entities.add(entity); - return this; - } - /** * Adds an dialogNode to dialogNodes. * @@ -166,6 +136,36 @@ public Builder addWebhooks(Webhook webhooks) { return this; } + /** + * Adds an intent to intents. + * + * @param intent the new intent + * @return the UpdateWorkspaceOptions builder + */ + public Builder addIntent(CreateIntent intent) { + com.ibm.cloud.sdk.core.util.Validator.notNull(intent, "intent cannot be null"); + if (this.intents == null) { + this.intents = new ArrayList(); + } + this.intents.add(intent); + return this; + } + + /** + * Adds an entity to entities. + * + * @param entity the new entity + * @return the UpdateWorkspaceOptions builder + */ + public Builder addEntity(CreateEntity entity) { + com.ibm.cloud.sdk.core.util.Validator.notNull(entity, "entity cannot be null"); + if (this.entities == null) { + this.entities = new ArrayList(); + } + this.entities.add(entity); + return this; + } + /** * Set the workspaceId. * @@ -211,90 +211,90 @@ public Builder language(String language) { } /** - * Set the metadata. + * Set the dialogNodes. Existing dialogNodes will be replaced. * - * @param metadata the metadata + * @param dialogNodes the dialogNodes * @return the UpdateWorkspaceOptions builder */ - public Builder metadata(Map metadata) { - this.metadata = metadata; + public Builder dialogNodes(List dialogNodes) { + this.dialogNodes = dialogNodes; return this; } /** - * Set the learningOptOut. + * Set the counterexamples. Existing counterexamples will be replaced. * - * @param learningOptOut the learningOptOut + * @param counterexamples the counterexamples * @return the UpdateWorkspaceOptions builder */ - public Builder learningOptOut(Boolean learningOptOut) { - this.learningOptOut = learningOptOut; + public Builder counterexamples(List counterexamples) { + this.counterexamples = counterexamples; return this; } /** - * Set the systemSettings. + * Set the metadata. * - * @param systemSettings the systemSettings + * @param metadata the metadata * @return the UpdateWorkspaceOptions builder */ - public Builder systemSettings(WorkspaceSystemSettings systemSettings) { - this.systemSettings = systemSettings; + public Builder metadata(Map metadata) { + this.metadata = metadata; return this; } /** - * Set the intents. Existing intents will be replaced. + * Set the learningOptOut. * - * @param intents the intents + * @param learningOptOut the learningOptOut * @return the UpdateWorkspaceOptions builder */ - public Builder intents(List intents) { - this.intents = intents; + public Builder learningOptOut(Boolean learningOptOut) { + this.learningOptOut = learningOptOut; return this; } /** - * Set the entities. Existing entities will be replaced. + * Set the systemSettings. * - * @param entities the entities + * @param systemSettings the systemSettings * @return the UpdateWorkspaceOptions builder */ - public Builder entities(List entities) { - this.entities = entities; + public Builder systemSettings(WorkspaceSystemSettings systemSettings) { + this.systemSettings = systemSettings; return this; } /** - * Set the dialogNodes. Existing dialogNodes will be replaced. + * Set the webhooks. Existing webhooks will be replaced. * - * @param dialogNodes the dialogNodes + * @param webhooks the webhooks * @return the UpdateWorkspaceOptions builder */ - public Builder dialogNodes(List dialogNodes) { - this.dialogNodes = dialogNodes; + public Builder webhooks(List webhooks) { + this.webhooks = webhooks; return this; } /** - * Set the counterexamples. Existing counterexamples will be replaced. + * Set the intents. Existing intents will be replaced. * - * @param counterexamples the counterexamples + * @param intents the intents * @return the UpdateWorkspaceOptions builder */ - public Builder counterexamples(List counterexamples) { - this.counterexamples = counterexamples; + public Builder intents(List intents) { + this.intents = intents; return this; } /** - * Set the webhooks. Existing webhooks will be replaced. + * Set the entities. Existing entities will be replaced. * - * @param webhooks the webhooks + * @param entities the entities * @return the UpdateWorkspaceOptions builder */ - public Builder webhooks(List webhooks) { - this.webhooks = webhooks; + public Builder entities(List entities) { + this.entities = entities; return this; } @@ -328,14 +328,14 @@ protected UpdateWorkspaceOptions(Builder builder) { name = builder.name; description = builder.description; language = builder.language; + dialogNodes = builder.dialogNodes; + counterexamples = builder.counterexamples; metadata = builder.metadata; learningOptOut = builder.learningOptOut; systemSettings = builder.systemSettings; + webhooks = builder.webhooks; intents = builder.intents; entities = builder.entities; - dialogNodes = builder.dialogNodes; - counterexamples = builder.counterexamples; - webhooks = builder.webhooks; append = builder.append; includeAudit = builder.includeAudit; } @@ -395,6 +395,28 @@ public String language() { return language; } + /** + * Gets the dialogNodes. + * + *

An array of objects describing the dialog nodes in the workspace. + * + * @return the dialogNodes + */ + public List dialogNodes() { + return dialogNodes; + } + + /** + * Gets the counterexamples. + * + *

An array of objects defining input examples that have been marked as irrelevant input. + * + * @return the counterexamples + */ + public List counterexamples() { + return counterexamples; + } + /** * Gets the metadata. * @@ -430,6 +452,15 @@ public WorkspaceSystemSettings systemSettings() { return systemSettings; } + /** + * Gets the webhooks. + * + * @return the webhooks + */ + public List webhooks() { + return webhooks; + } + /** * Gets the intents. * @@ -452,37 +483,6 @@ public List entities() { return entities; } - /** - * Gets the dialogNodes. - * - *

An array of objects describing the dialog nodes in the workspace. - * - * @return the dialogNodes - */ - public List dialogNodes() { - return dialogNodes; - } - - /** - * Gets the counterexamples. - * - *

An array of objects defining input examples that have been marked as irrelevant input. - * - * @return the counterexamples - */ - public List counterexamples() { - return counterexamples; - } - - /** - * Gets the webhooks. - * - * @return the webhooks - */ - public List webhooks() { - return webhooks; - } - /** * Gets the append. * diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Value.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Value.java index 542ecb9c3fa..5527c442a4e 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Value.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Value.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -44,8 +44,6 @@ public static class Builder { private String type; private List synonyms; private List patterns; - private Date created; - private Date updated; private Builder(Value value) { this.value = value.value; @@ -53,8 +51,6 @@ private Builder(Value value) { this.type = value.type; this.synonyms = value.synonyms; this.patterns = value.patterns; - this.created = value.created; - this.updated = value.updated; } /** Instantiates a new builder. */ @@ -74,7 +70,7 @@ public Builder(String value, String type) { /** * Builds a Value. * - * @return the value + * @return the new Value instance */ public Value build() { return new Value(this); @@ -164,28 +160,6 @@ public Builder patterns(List patterns) { this.patterns = patterns; return this; } - - /** - * Set the created. - * - * @param created the created - * @return the Value builder - */ - public Builder created(Date created) { - this.created = created; - return this; - } - - /** - * Set the updated. - * - * @param updated the updated - * @return the Value builder - */ - public Builder updated(Date updated) { - this.updated = updated; - return this; - } } protected Value(Builder builder) { @@ -196,8 +170,6 @@ protected Value(Builder builder) { type = builder.type; synonyms = builder.synonyms; patterns = builder.patterns; - created = builder.created; - updated = builder.updated; } /** diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ValueCollection.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ValueCollection.java index f1b391c3c6e..c0c9c30aea7 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ValueCollection.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ValueCollection.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Webhook.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Webhook.java index a9ab4cb637a..f70cb0317d9 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Webhook.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Webhook.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -56,7 +56,7 @@ public Builder(String url, String name) { /** * Builds a Webhook. * - * @return the webhook + * @return the new Webhook instance */ public Webhook build() { return new Webhook(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WebhookHeader.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WebhookHeader.java index 92d36a19f8d..a1239bc9112 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WebhookHeader.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WebhookHeader.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -47,7 +47,7 @@ public Builder(String name, String value) { /** * Builds a WebhookHeader. * - * @return the webhookHeader + * @return the new WebhookHeader instance */ public WebhookHeader build() { return new WebhookHeader(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Workspace.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Workspace.java index b96a7176a69..14d4a31260f 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Workspace.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Workspace.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -38,6 +38,16 @@ public interface Status { protected String name; protected String description; protected String language; + + @SerializedName("workspace_id") + protected String workspaceId; + + @SerializedName("dialog_nodes") + protected List dialogNodes; + + protected List counterexamples; + protected Date created; + protected Date updated; protected Map metadata; @SerializedName("learning_opt_out") @@ -46,21 +56,11 @@ public interface Status { @SerializedName("system_settings") protected WorkspaceSystemSettings systemSettings; - @SerializedName("workspace_id") - protected String workspaceId; - protected String status; - protected Date created; - protected Date updated; + protected List webhooks; protected List intents; protected List entities; - @SerializedName("dialog_nodes") - protected List dialogNodes; - - protected List counterexamples; - protected List webhooks; - /** * Gets the name. * @@ -97,60 +97,36 @@ public String getLanguage() { } /** - * Gets the metadata. - * - *

Any metadata related to the workspace. - * - * @return the metadata - */ - public Map getMetadata() { - return metadata; - } - - /** - * Gets the learningOptOut. - * - *

Whether training data from the workspace (including artifacts such as intents and entities) - * can be used by IBM for general service improvements. `true` indicates that workspace training - * data is not to be used. - * - * @return the learningOptOut - */ - public Boolean isLearningOptOut() { - return learningOptOut; - } - - /** - * Gets the systemSettings. + * Gets the workspaceId. * - *

Global settings for the workspace. + *

The workspace ID of the workspace. * - * @return the systemSettings + * @return the workspaceId */ - public WorkspaceSystemSettings getSystemSettings() { - return systemSettings; + public String getWorkspaceId() { + return workspaceId; } /** - * Gets the workspaceId. + * Gets the dialogNodes. * - *

The workspace ID of the workspace. + *

An array of objects describing the dialog nodes in the workspace. * - * @return the workspaceId + * @return the dialogNodes */ - public String getWorkspaceId() { - return workspaceId; + public List getDialogNodes() { + return dialogNodes; } /** - * Gets the status. + * Gets the counterexamples. * - *

The current status of the workspace. + *

An array of objects defining input examples that have been marked as irrelevant input. * - * @return the status + * @return the counterexamples */ - public String getStatus() { - return status; + public List getCounterexamples() { + return counterexamples; } /** @@ -176,47 +152,49 @@ public Date getUpdated() { } /** - * Gets the intents. + * Gets the metadata. * - *

An array of intents. + *

Any metadata related to the workspace. * - * @return the intents + * @return the metadata */ - public List getIntents() { - return intents; + public Map getMetadata() { + return metadata; } /** - * Gets the entities. + * Gets the learningOptOut. * - *

An array of objects describing the entities for the workspace. + *

Whether training data from the workspace (including artifacts such as intents and entities) + * can be used by IBM for general service improvements. `true` indicates that workspace training + * data is not to be used. * - * @return the entities + * @return the learningOptOut */ - public List getEntities() { - return entities; + public Boolean isLearningOptOut() { + return learningOptOut; } /** - * Gets the dialogNodes. + * Gets the systemSettings. * - *

An array of objects describing the dialog nodes in the workspace. + *

Global settings for the workspace. * - * @return the dialogNodes + * @return the systemSettings */ - public List getDialogNodes() { - return dialogNodes; + public WorkspaceSystemSettings getSystemSettings() { + return systemSettings; } /** - * Gets the counterexamples. + * Gets the status. * - *

An array of counterexamples. + *

The current status of the workspace. * - * @return the counterexamples + * @return the status */ - public List getCounterexamples() { - return counterexamples; + public String getStatus() { + return status; } /** @@ -227,4 +205,26 @@ public List getCounterexamples() { public List getWebhooks() { return webhooks; } + + /** + * Gets the intents. + * + *

An array of intents. + * + * @return the intents + */ + public List getIntents() { + return intents; + } + + /** + * Gets the entities. + * + *

An array of objects describing the entities for the workspace. + * + * @return the entities + */ + public List getEntities() { + return entities; + } } diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceCollection.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceCollection.java index 90d18a60681..fd1e8e99c93 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceCollection.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceCollection.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettings.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettings.java index 07c9aefa30b..00f619261c4 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettings.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettings.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -63,7 +63,7 @@ public Builder() {} /** * Builds a WorkspaceSystemSettings. * - * @return the workspaceSystemSettings + * @return the new WorkspaceSystemSettings instance */ public WorkspaceSystemSettings build() { return new WorkspaceSystemSettings(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsDisambiguation.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsDisambiguation.java index 1a5c52f3b6d..2c7cda5b592 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsDisambiguation.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsDisambiguation.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -71,7 +71,7 @@ public Builder() {} /** * Builds a WorkspaceSystemSettingsDisambiguation. * - * @return the workspaceSystemSettingsDisambiguation + * @return the new WorkspaceSystemSettingsDisambiguation instance */ public WorkspaceSystemSettingsDisambiguation build() { return new WorkspaceSystemSettingsDisambiguation(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsOffTopic.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsOffTopic.java index e7da020c231..c68d08ef3cf 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsOffTopic.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsOffTopic.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -33,7 +33,7 @@ public Builder() {} /** * Builds a WorkspaceSystemSettingsOffTopic. * - * @return the workspaceSystemSettingsOffTopic + * @return the new WorkspaceSystemSettingsOffTopic instance */ public WorkspaceSystemSettingsOffTopic build() { return new WorkspaceSystemSettingsOffTopic(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsSystemEntities.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsSystemEntities.java index 99a45cf68ae..f4c27424079 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsSystemEntities.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsSystemEntities.java @@ -33,7 +33,7 @@ public Builder() {} /** * Builds a WorkspaceSystemSettingsSystemEntities. * - * @return the workspaceSystemSettingsSystemEntities + * @return the new WorkspaceSystemSettingsSystemEntities instance */ public WorkspaceSystemSettingsSystemEntities build() { return new WorkspaceSystemSettingsSystemEntities(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsTooling.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsTooling.java index 43777c0db34..90759c0e728 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsTooling.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsTooling.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -35,7 +35,7 @@ public Builder() {} /** * Builds a WorkspaceSystemSettingsTooling. * - * @return the workspaceSystemSettingsTooling + * @return the new WorkspaceSystemSettingsTooling instance */ public WorkspaceSystemSettingsTooling build() { return new WorkspaceSystemSettingsTooling(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v1/package-info.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/package-info.java index 1fef121beba..a42ae2bcc8d 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v1/package-info.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/package-info.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/Assistant.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/Assistant.java index e4e817609e5..f9ec6cf9939 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/Assistant.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/Assistant.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -10,6 +10,11 @@ * 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. */ + +/* + * IBM OpenAPI SDK Code Generator Version: 99-SNAPSHOT-7cc05500-20201106-154555 + */ + package com.ibm.watson.assistant.v2; import com.google.gson.JsonObject; @@ -20,6 +25,8 @@ import com.ibm.cloud.sdk.core.security.ConfigBasedAuthenticatorFactory; import com.ibm.cloud.sdk.core.service.BaseService; import com.ibm.cloud.sdk.core.util.ResponseConverterUtils; +import com.ibm.watson.assistant.v2.model.BulkClassifyOptions; +import com.ibm.watson.assistant.v2.model.BulkClassifyResponse; import com.ibm.watson.assistant.v2.model.CreateSessionOptions; import com.ibm.watson.assistant.v2.model.DeleteSessionOptions; import com.ibm.watson.assistant.v2.model.DeleteUserDataOptions; @@ -31,11 +38,12 @@ import com.ibm.watson.assistant.v2.model.MessageStatelessOptions; import com.ibm.watson.assistant.v2.model.SessionResponse; import com.ibm.watson.common.SdkCommon; +import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; /** - * The IBM Watson™ Assistant service combines machine learning, natural language + * The IBM Watson&trade; Assistant service combines machine learning, natural language * understanding, and an integrated dialog editor to create conversation flows between your apps and * your users. * @@ -43,70 +51,93 @@ * input to an assistant and receive a response. * * @version v2 - * @see Assistant + * @see Assistant */ public class Assistant extends BaseService { - private static final String DEFAULT_SERVICE_NAME = "assistant"; + public static final String DEFAULT_SERVICE_NAME = "conversation"; - private static final String DEFAULT_SERVICE_URL = + public static final String DEFAULT_SERVICE_URL = "https://api.us-south.assistant.watson.cloud.ibm.com"; - private String versionDate; + private String version; /** - * Constructs a new `Assistant` client using the DEFAULT_SERVICE_NAME. + * Constructs an instance of the `Assistant` client. The default service name is used to configure + * the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value - * will keep your API calls from failing when the service introduces breaking changes. + * @param version Release date of the API version you want to use. Specify dates in YYYY-MM-DD + * format. The current version is `2020-04-01`. */ - public Assistant(String versionDate) { + public Assistant(String version) { this( - versionDate, + version, DEFAULT_SERVICE_NAME, ConfigBasedAuthenticatorFactory.getAuthenticator(DEFAULT_SERVICE_NAME)); } /** - * Constructs a new `Assistant` client with the DEFAULT_SERVICE_NAME and the specified - * Authenticator. + * Constructs an instance of the `Assistant` client. The default service name and specified + * authenticator are used to configure the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value - * will keep your API calls from failing when the service introduces breaking changes. - * @param authenticator the Authenticator instance to be configured for this service + * @param version Release date of the API version you want to use. Specify dates in YYYY-MM-DD + * format. The current version is `2020-04-01`. + * @param authenticator the {@link Authenticator} instance to be configured for this client */ - public Assistant(String versionDate, Authenticator authenticator) { - this(versionDate, DEFAULT_SERVICE_NAME, authenticator); + public Assistant(String version, Authenticator authenticator) { + this(version, DEFAULT_SERVICE_NAME, authenticator); } /** - * Constructs a new `Assistant` client with the specified serviceName. + * Constructs an instance of the `Assistant` client. The specified service name is used to + * configure the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value - * will keep your API calls from failing when the service introduces breaking changes. - * @param serviceName The name of the service to configure. + * @param version Release date of the API version you want to use. Specify dates in YYYY-MM-DD + * format. The current version is `2020-04-01`. + * @param serviceName the service name to be used when configuring the client instance */ - public Assistant(String versionDate, String serviceName) { - this(versionDate, serviceName, ConfigBasedAuthenticatorFactory.getAuthenticator(serviceName)); + public Assistant(String version, String serviceName) { + this(version, serviceName, ConfigBasedAuthenticatorFactory.getAuthenticator(serviceName)); } /** - * Constructs a new `Assistant` client with the specified Authenticator and serviceName. + * Constructs an instance of the `Assistant` client. The specified service name and authenticator + * are used to configure the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value - * will keep your API calls from failing when the service introduces breaking changes. - * @param serviceName The name of the service to configure. - * @param authenticator the Authenticator instance to be configured for this service + * @param version Release date of the API version you want to use. Specify dates in YYYY-MM-DD + * format. The current version is `2020-04-01`. + * @param serviceName the service name to be used when configuring the client instance + * @param authenticator the {@link Authenticator} instance to be configured for this client */ - public Assistant(String versionDate, String serviceName, Authenticator authenticator) { + public Assistant(String version, String serviceName, Authenticator authenticator) { super(serviceName, authenticator); setServiceUrl(DEFAULT_SERVICE_URL); - com.ibm.cloud.sdk.core.util.Validator.isTrue( - (versionDate != null) && !versionDate.isEmpty(), "version cannot be null."); - this.versionDate = versionDate; + setVersion(version); this.configureService(serviceName); } + /** + * Gets the version. + * + *

Release date of the API version you want to use. Specify dates in YYYY-MM-DD format. The + * current version is `2020-04-01`. + * + * @return the version + */ + public String getVersion() { + return this.version; + } + + /** + * Sets the version. + * + * @param version the new version + */ + public void setVersion(final String version) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(version, "version cannot be empty."); + this.version = version; + } + /** * Create a session. * @@ -117,23 +148,23 @@ public Assistant(String versionDate, String serviceName, Authenticator authentic * * @param createSessionOptions the {@link CreateSessionOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of {@link SessionResponse} + * @return a {@link ServiceCall} with a result of type {@link SessionResponse} */ public ServiceCall createSession(CreateSessionOptions createSessionOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( createSessionOptions, "createSessionOptions cannot be null"); - String[] pathSegments = {"v2/assistants", "sessions"}; - String[] pathParameters = {createSessionOptions.assistantId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("assistant_id", createSessionOptions.assistantId()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v2/assistants/{assistant_id}/sessions", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v2", "createSession"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken() {}.getType()); @@ -149,25 +180,26 @@ public ServiceCall createSession(CreateSessionOptions createSes * * @param deleteSessionOptions the {@link DeleteSessionOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteSession(DeleteSessionOptions deleteSessionOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( deleteSessionOptions, "deleteSessionOptions cannot be null"); - String[] pathSegments = {"v2/assistants", "sessions"}; - String[] pathParameters = { - deleteSessionOptions.assistantId(), deleteSessionOptions.sessionId() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("assistant_id", deleteSessionOptions.assistantId()); + pathParamsMap.put("session_id", deleteSessionOptions.sessionId()); RequestBuilder builder = RequestBuilder.delete( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/assistants/{assistant_id}/sessions/{session_id}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v2", "deleteSession"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -179,21 +211,25 @@ public ServiceCall deleteSession(DeleteSessionOptions deleteSessionOptions * context data) stored by Watson Assistant for the duration of the session. * * @param messageOptions the {@link MessageOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link MessageResponse} + * @return a {@link ServiceCall} with a result of type {@link MessageResponse} */ public ServiceCall message(MessageOptions messageOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull(messageOptions, "messageOptions cannot be null"); - String[] pathSegments = {"v2/assistants", "sessions", "message"}; - String[] pathParameters = {messageOptions.assistantId(), messageOptions.sessionId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("assistant_id", messageOptions.assistantId()); + pathParamsMap.put("session_id", messageOptions.sessionId()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/assistants/{assistant_id}/sessions/{session_id}/message", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v2", "message"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); final JsonObject contentJson = new JsonObject(); if (messageOptions.input() != null) { contentJson.add( @@ -220,24 +256,25 @@ public ServiceCall message(MessageOptions messageOptions) { * * @param messageStatelessOptions the {@link MessageStatelessOptions} containing the options for * the call - * @return a {@link ServiceCall} with a response type of {@link MessageResponseStateless} + * @return a {@link ServiceCall} with a result of type {@link MessageResponseStateless} */ public ServiceCall messageStateless( MessageStatelessOptions messageStatelessOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( messageStatelessOptions, "messageStatelessOptions cannot be null"); - String[] pathSegments = {"v2/assistants", "message"}; - String[] pathParameters = {messageStatelessOptions.assistantId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("assistant_id", messageStatelessOptions.assistantId()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v2/assistants/{assistant_id}/message", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v2", "messageStateless"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); final JsonObject contentJson = new JsonObject(); if (messageStatelessOptions.input() != null) { contentJson.add( @@ -266,33 +303,34 @@ public ServiceCall messageStateless( *

This method is available only with Premium plans. * * @param listLogsOptions the {@link ListLogsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link LogCollection} + * @return a {@link ServiceCall} with a result of type {@link LogCollection} */ public ServiceCall listLogs(ListLogsOptions listLogsOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( listLogsOptions, "listLogsOptions cannot be null"); - String[] pathSegments = {"v2/assistants", "logs"}; - String[] pathParameters = {listLogsOptions.assistantId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("assistant_id", listLogsOptions.assistantId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v2/assistants/{assistant_id}/logs", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v2", "listLogs"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (listLogsOptions.sort() != null) { - builder.query("sort", listLogsOptions.sort()); + builder.query("sort", String.valueOf(listLogsOptions.sort())); } if (listLogsOptions.filter() != null) { - builder.query("filter", listLogsOptions.filter()); + builder.query("filter", String.valueOf(listLogsOptions.filter())); } if (listLogsOptions.pageLimit() != null) { builder.query("page_limit", String.valueOf(listLogsOptions.pageLimit())); } if (listLogsOptions.cursor() != null) { - builder.query("cursor", listLogsOptions.cursor()); + builder.query("cursor", String.valueOf(listLogsOptions.cursor())); } ResponseConverter responseConverter = ResponseConverterUtils.getValue( @@ -316,23 +354,63 @@ public ServiceCall listLogs(ListLogsOptions listLogsOptions) { * * @param deleteUserDataOptions the {@link DeleteUserDataOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteUserData(DeleteUserDataOptions deleteUserDataOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( deleteUserDataOptions, "deleteUserDataOptions cannot be null"); - String[] pathSegments = {"v2/user_data"}; RequestBuilder builder = - RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); + RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v2/user_data")); Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v2", "deleteUserData"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - builder.query("customer_id", deleteUserDataOptions.customerId()); + builder.query("version", String.valueOf(this.version)); + builder.query("customer_id", String.valueOf(deleteUserDataOptions.customerId())); ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } + + /** + * Identify intents and entities in multiple user utterances. + * + *

Send multiple user inputs to a dialog skill in a single request and receive information + * about the intents and entities recognized in each input. This method is useful for testing and + * comparing the performance of different skills or skill versions. + * + *

This method is available only with Premium plans. + * + * @param bulkClassifyOptions the {@link BulkClassifyOptions} containing the options for the call + * @return a {@link ServiceCall} with a result of type {@link BulkClassifyResponse} + */ + public ServiceCall bulkClassify(BulkClassifyOptions bulkClassifyOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + bulkClassifyOptions, "bulkClassifyOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("skill_id", bulkClassifyOptions.skillId()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v2/skills/{skill_id}/workspace/bulk_classify", pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v2", "bulkClassify"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + final JsonObject contentJson = new JsonObject(); + if (bulkClassifyOptions.input() != null) { + contentJson.add( + "input", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(bulkClassifyOptions.input())); + } + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } } diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/BulkClassifyOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/BulkClassifyOptions.java new file mode 100644 index 00000000000..1184ea27bab --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/BulkClassifyOptions.java @@ -0,0 +1,131 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.ArrayList; +import java.util.List; + +/** The bulkClassify options. */ +public class BulkClassifyOptions extends GenericModel { + + protected String skillId; + protected List input; + + /** Builder. */ + public static class Builder { + private String skillId; + private List input; + + private Builder(BulkClassifyOptions bulkClassifyOptions) { + this.skillId = bulkClassifyOptions.skillId; + this.input = bulkClassifyOptions.input; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param skillId the skillId + */ + public Builder(String skillId) { + this.skillId = skillId; + } + + /** + * Builds a BulkClassifyOptions. + * + * @return the new BulkClassifyOptions instance + */ + public BulkClassifyOptions build() { + return new BulkClassifyOptions(this); + } + + /** + * Adds an input to input. + * + * @param input the new input + * @return the BulkClassifyOptions builder + */ + public Builder addInput(BulkClassifyUtterance input) { + com.ibm.cloud.sdk.core.util.Validator.notNull(input, "input cannot be null"); + if (this.input == null) { + this.input = new ArrayList(); + } + this.input.add(input); + return this; + } + + /** + * Set the skillId. + * + * @param skillId the skillId + * @return the BulkClassifyOptions builder + */ + public Builder skillId(String skillId) { + this.skillId = skillId; + return this; + } + + /** + * Set the input. Existing input will be replaced. + * + * @param input the input + * @return the BulkClassifyOptions builder + */ + public Builder input(List input) { + this.input = input; + return this; + } + } + + protected BulkClassifyOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.skillId, "skillId cannot be empty"); + skillId = builder.skillId; + input = builder.input; + } + + /** + * New builder. + * + * @return a BulkClassifyOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the skillId. + * + *

Unique identifier of the skill. To find the skill ID in the Watson Assistant user interface, + * open the skill settings and click **API Details**. + * + * @return the skillId + */ + public String skillId() { + return skillId; + } + + /** + * Gets the input. + * + *

An array of input utterances to classify. + * + * @return the input + */ + public List input() { + return input; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/BulkClassifyOutput.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/BulkClassifyOutput.java new file mode 100644 index 00000000000..ea1cce98902 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/BulkClassifyOutput.java @@ -0,0 +1,57 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** BulkClassifyOutput. */ +public class BulkClassifyOutput extends GenericModel { + + protected BulkClassifyUtterance input; + protected List entities; + protected List intents; + + /** + * Gets the input. + * + *

The user input utterance to classify. + * + * @return the input + */ + public BulkClassifyUtterance getInput() { + return input; + } + + /** + * Gets the entities. + * + *

An array of entities identified in the utterance. + * + * @return the entities + */ + public List getEntities() { + return entities; + } + + /** + * Gets the intents. + * + *

An array of intents recognized in the utterance. + * + * @return the intents + */ + public List getIntents() { + return intents; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextSkills.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/BulkClassifyResponse.java similarity index 53% rename from assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextSkills.java rename to assistant/src/main/java/com/ibm/watson/assistant/v2/model/BulkClassifyResponse.java index c85ead99cc2..3decf640901 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextSkills.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/BulkClassifyResponse.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -12,18 +12,23 @@ */ package com.ibm.watson.assistant.v2.model; -import com.google.gson.reflect.TypeToken; -import com.ibm.cloud.sdk.core.service.model.DynamicModel; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; -/** - * Information specific to particular skills used by the assistant. - * - *

**Note:** Currently, only a single child property is supported, containing variables that - * apply to the dialog skill used by the assistant. - */ -public class MessageContextSkills extends DynamicModel { +/** BulkClassifyResponse. */ +public class BulkClassifyResponse extends GenericModel { + + protected List output; - public MessageContextSkills() { - super(new TypeToken() {}); + /** + * Gets the output. + * + *

An array of objects that contain classification information for the submitted input + * utterances. + * + * @return the output + */ + public List getOutput() { + return output; } } diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/BulkClassifyUtterance.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/BulkClassifyUtterance.java new file mode 100644 index 00000000000..6600972a50a --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/BulkClassifyUtterance.java @@ -0,0 +1,87 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The user input utterance to classify. */ +public class BulkClassifyUtterance extends GenericModel { + + protected String text; + + /** Builder. */ + public static class Builder { + private String text; + + private Builder(BulkClassifyUtterance bulkClassifyUtterance) { + this.text = bulkClassifyUtterance.text; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param text the text + */ + public Builder(String text) { + this.text = text; + } + + /** + * Builds a BulkClassifyUtterance. + * + * @return the new BulkClassifyUtterance instance + */ + public BulkClassifyUtterance build() { + return new BulkClassifyUtterance(this); + } + + /** + * Set the text. + * + * @param text the text + * @return the BulkClassifyUtterance builder + */ + public Builder text(String text) { + this.text = text; + return this; + } + } + + protected BulkClassifyUtterance(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.text, "text cannot be null"); + text = builder.text; + } + + /** + * New builder. + * + * @return a BulkClassifyUtterance builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the text. + * + *

The text of the input utterance. + * + * @return the text + */ + public String text() { + return text; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/CaptureGroup.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/CaptureGroup.java index 6cb493c10c5..6ad031ad22a 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/CaptureGroup.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/CaptureGroup.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -47,7 +47,7 @@ public Builder(String group) { /** * Builds a CaptureGroup. * - * @return the captureGroup + * @return the new CaptureGroup instance */ public CaptureGroup build() { return new CaptureGroup(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/CreateSessionOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/CreateSessionOptions.java index 2361cf0040c..5b244e337d6 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/CreateSessionOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/CreateSessionOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -42,7 +42,7 @@ public Builder(String assistantId) { /** * Builds a CreateSessionOptions. * - * @return the createSessionOptions + * @return the new CreateSessionOptions instance */ public CreateSessionOptions build() { return new CreateSessionOptions(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DeleteSessionOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DeleteSessionOptions.java index 6d256083852..5267e601f7f 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DeleteSessionOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DeleteSessionOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -47,7 +47,7 @@ public Builder(String assistantId, String sessionId) { /** * Builds a DeleteSessionOptions. * - * @return the deleteSessionOptions + * @return the new DeleteSessionOptions instance */ public DeleteSessionOptions build() { return new DeleteSessionOptions(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DeleteUserDataOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DeleteUserDataOptions.java index 919a761bb75..36cb37b5bd2 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DeleteUserDataOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DeleteUserDataOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -42,7 +42,7 @@ public Builder(String customerId) { /** * Builds a DeleteUserDataOptions. * - * @return the deleteUserDataOptions + * @return the new DeleteUserDataOptions instance */ public DeleteUserDataOptions build() { return new DeleteUserDataOptions(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogLogMessage.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogLogMessage.java index 1989584c22a..9b1dbbe99a8 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogLogMessage.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogLogMessage.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogNodeAction.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogNodeAction.java index d4e115d7206..581b5a76695 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogNodeAction.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogNodeAction.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogNodeOutputConnectToAgentTransferInfo.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogNodeOutputConnectToAgentTransferInfo.java new file mode 100644 index 00000000000..26dcb6e4f2e --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogNodeOutputConnectToAgentTransferInfo.java @@ -0,0 +1,31 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.Map; + +/** Routing or other contextual information to be used by target service desk systems. */ +public class DialogNodeOutputConnectToAgentTransferInfo extends GenericModel { + + protected Map> target; + + /** + * Gets the target. + * + * @return the target + */ + public Map> getTarget() { + return target; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogNodeOutputOptionsElement.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogNodeOutputOptionsElement.java index 41ace3fecca..46b962c6ba4 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogNodeOutputOptionsElement.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogNodeOutputOptionsElement.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogNodeOutputOptionsElementValue.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogNodeOutputOptionsElementValue.java index 2dc3e0e7c46..882dbefe1ba 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogNodeOutputOptionsElementValue.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogNodeOutputOptionsElementValue.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogNodesVisited.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogNodesVisited.java index 5d98b40c014..4052842cc00 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogNodesVisited.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogNodesVisited.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogSuggestion.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogSuggestion.java index e175fde2b79..c80276afd74 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogSuggestion.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogSuggestion.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogSuggestionValue.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogSuggestionValue.java index 7525c1355fd..ac57a2a56e5 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogSuggestionValue.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogSuggestionValue.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ListLogsOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ListLogsOptions.java index 60bff4e4849..3d499c3a600 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ListLogsOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/ListLogsOptions.java @@ -54,7 +54,7 @@ public Builder(String assistantId) { /** * Builds a ListLogsOptions. * - * @return the listLogsOptions + * @return the new ListLogsOptions instance */ public ListLogsOptions build() { return new ListLogsOptions(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContext.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContext.java index 83f46f4a3b1..8c042336da9 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContext.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContext.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -13,17 +13,18 @@ package com.ibm.watson.assistant.v2.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.Map; /** MessageContext. */ public class MessageContext extends GenericModel { protected MessageContextGlobal global; - protected MessageContextSkills skills; + protected Map skills; /** Builder. */ public static class Builder { private MessageContextGlobal global; - private MessageContextSkills skills; + private Map skills; private Builder(MessageContext messageContext) { this.global = messageContext.global; @@ -36,7 +37,7 @@ public Builder() {} /** * Builds a MessageContext. * - * @return the messageContext + * @return the new MessageContext instance */ public MessageContext build() { return new MessageContext(this); @@ -59,7 +60,7 @@ public Builder global(MessageContextGlobal global) { * @param skills the skills * @return the MessageContext builder */ - public Builder skills(MessageContextSkills skills) { + public Builder skills(Map skills) { this.skills = skills; return this; } @@ -100,7 +101,7 @@ public MessageContextGlobal global() { * * @return the skills */ - public MessageContextSkills skills() { + public Map skills() { return skills; } } diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextGlobal.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextGlobal.java index 332e3f2d314..9f135745094 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextGlobal.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextGlobal.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -26,11 +26,9 @@ public class MessageContextGlobal extends GenericModel { /** Builder. */ public static class Builder { private MessageContextGlobalSystem system; - private String sessionId; private Builder(MessageContextGlobal messageContextGlobal) { this.system = messageContextGlobal.system; - this.sessionId = messageContextGlobal.sessionId; } /** Instantiates a new builder. */ @@ -39,7 +37,7 @@ public Builder() {} /** * Builds a MessageContextGlobal. * - * @return the messageContextGlobal + * @return the new MessageContextGlobal instance */ public MessageContextGlobal build() { return new MessageContextGlobal(this); @@ -55,22 +53,10 @@ public Builder system(MessageContextGlobalSystem system) { this.system = system; return this; } - - /** - * Set the sessionId. - * - * @param sessionId the sessionId - * @return the MessageContextGlobal builder - */ - public Builder sessionId(String sessionId) { - this.sessionId = sessionId; - return this; - } } protected MessageContextGlobal(Builder builder) { system = builder.system; - sessionId = builder.sessionId; } /** diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextGlobalStateless.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextGlobalStateless.java index 0b89b70e0ca..17b705c7aa1 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextGlobalStateless.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextGlobalStateless.java @@ -39,7 +39,7 @@ public Builder() {} /** * Builds a MessageContextGlobalStateless. * - * @return the messageContextGlobalStateless + * @return the new MessageContextGlobalStateless instance */ public MessageContextGlobalStateless build() { return new MessageContextGlobalStateless(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextGlobalSystem.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextGlobalSystem.java index 61a7e8b5a87..fbc14c4b2b8 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextGlobalSystem.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextGlobalSystem.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -94,7 +94,7 @@ public Builder() {} /** * Builds a MessageContextGlobalSystem. * - * @return the messageContextGlobalSystem + * @return the new MessageContextGlobalSystem instance */ public MessageContextGlobalSystem build() { return new MessageContextGlobalSystem(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextSkill.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextSkill.java index bd0a7741b6b..a59817dcc4e 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextSkill.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextSkill.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -25,12 +25,12 @@ public class MessageContextSkill extends GenericModel { @SerializedName("user_defined") protected Map userDefined; - protected Map system; + protected MessageContextSkillSystem system; /** Builder. */ public static class Builder { private Map userDefined; - private Map system; + private MessageContextSkillSystem system; private Builder(MessageContextSkill messageContextSkill) { this.userDefined = messageContextSkill.userDefined; @@ -43,7 +43,7 @@ public Builder() {} /** * Builds a MessageContextSkill. * - * @return the messageContextSkill + * @return the new MessageContextSkill instance */ public MessageContextSkill build() { return new MessageContextSkill(this); @@ -66,7 +66,7 @@ public Builder userDefined(Map userDefined) { * @param system the system * @return the MessageContextSkill builder */ - public Builder system(Map system) { + public Builder system(MessageContextSkillSystem system) { this.system = system; return this; } @@ -104,7 +104,7 @@ public Map userDefined() { * * @return the system */ - public Map system() { + public MessageContextSkillSystem system() { return system; } } diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextSkillSystem.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextSkillSystem.java index 6235bdd7b3e..de1651228ec 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextSkillSystem.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextSkillSystem.java @@ -15,6 +15,8 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.reflect.TypeToken; import com.ibm.cloud.sdk.core.service.model.DynamicModel; +import java.util.HashMap; +import java.util.Map; /** System context data used by the skill. */ public class MessageContextSkillSystem extends DynamicModel { @@ -26,14 +28,78 @@ public MessageContextSkillSystem() { super(new TypeToken() {}); } + /** Builder. */ + public static class Builder { + private String state; + private Map dynamicProperties; + + private Builder(MessageContextSkillSystem messageContextSkillSystem) { + this.state = messageContextSkillSystem.state; + this.dynamicProperties = messageContextSkillSystem.getProperties(); + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a MessageContextSkillSystem. + * + * @return the new MessageContextSkillSystem instance + */ + public MessageContextSkillSystem build() { + return new MessageContextSkillSystem(this); + } + + /** + * Set the state. + * + * @param state the state + * @return the MessageContextSkillSystem builder + */ + public Builder state(String state) { + this.state = state; + return this; + } + + /** + * Add an arbitrary property. + * + * @param name the name of the property to add + * @param value the value of the property to add + * @return the MessageContextSkillSystem builder + */ + public Builder add(String name, Object value) { + com.ibm.cloud.sdk.core.util.Validator.notNull(name, "name cannot be null"); + if (this.dynamicProperties == null) { + this.dynamicProperties = new HashMap(); + } + this.dynamicProperties.put(name, value); + return this; + } + } + + protected MessageContextSkillSystem(Builder builder) { + super(new TypeToken() {}); + state = builder.state; + this.setProperties(builder.dynamicProperties); + } + + /** + * New builder. + * + * @return a MessageContextSkillSystem builder + */ + public Builder newBuilder() { + return new Builder(this); + } + /** * Gets the state. * - *

An encoded string representing the current conversation state. By saving this value and then - * sending it in the context of a subsequent message request, you can restore the conversation to - * the same state. This can be useful if you need to return to an earlier point in the - * conversation. If you are using stateful sessions, you can also use a stored state value to - * restore a paused conversation whose session has expired. + *

An encoded string that represents the current conversation state. By saving this value and + * then sending it in the context of a subsequent message request, you can return to an earlier + * point in the conversation. If you are using stateful sessions, you can also use a stored state + * value to restore a paused conversation whose session is expired. * * @return the state */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextStateless.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextStateless.java index c92c04068ba..44cdd2b4de2 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextStateless.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextStateless.java @@ -13,17 +13,18 @@ package com.ibm.watson.assistant.v2.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.Map; /** MessageContextStateless. */ public class MessageContextStateless extends GenericModel { protected MessageContextGlobalStateless global; - protected MessageContextSkills skills; + protected Map skills; /** Builder. */ public static class Builder { private MessageContextGlobalStateless global; - private MessageContextSkills skills; + private Map skills; private Builder(MessageContextStateless messageContextStateless) { this.global = messageContextStateless.global; @@ -36,7 +37,7 @@ public Builder() {} /** * Builds a MessageContextStateless. * - * @return the messageContextStateless + * @return the new MessageContextStateless instance */ public MessageContextStateless build() { return new MessageContextStateless(this); @@ -59,7 +60,7 @@ public Builder global(MessageContextGlobalStateless global) { * @param skills the skills * @return the MessageContextStateless builder */ - public Builder skills(MessageContextSkills skills) { + public Builder skills(Map skills) { this.skills = skills; return this; } @@ -100,7 +101,7 @@ public MessageContextGlobalStateless global() { * * @return the skills */ - public MessageContextSkills skills() { + public Map skills() { return skills; } } diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageInput.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageInput.java index 09954dcc5a5..96053efc77f 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageInput.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageInput.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -62,7 +62,7 @@ public Builder() {} /** * Builds a MessageInput. * - * @return the messageInput + * @return the new MessageInput instance */ public MessageInput build() { return new MessageInput(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageInputOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageInputOptions.java index c6f2fb205cb..84fd7931896 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageInputOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageInputOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -55,7 +55,7 @@ public Builder() {} /** * Builds a MessageInputOptions. * - * @return the messageInputOptions + * @return the new MessageInputOptions instance */ public MessageInputOptions build() { return new MessageInputOptions(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageInputOptionsSpelling.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageInputOptionsSpelling.java index a23a48e1602..22abb2cfadb 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageInputOptionsSpelling.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageInputOptionsSpelling.java @@ -42,7 +42,7 @@ public Builder() {} /** * Builds a MessageInputOptionsSpelling. * - * @return the messageInputOptionsSpelling + * @return the new MessageInputOptionsSpelling instance */ public MessageInputOptionsSpelling build() { return new MessageInputOptionsSpelling(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageInputOptionsStateless.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageInputOptionsStateless.java index 12da6319e78..e5d794f5731 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageInputOptionsStateless.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageInputOptionsStateless.java @@ -46,7 +46,7 @@ public Builder() {} /** * Builds a MessageInputOptionsStateless. * - * @return the messageInputOptionsStateless + * @return the new MessageInputOptionsStateless instance */ public MessageInputOptionsStateless build() { return new MessageInputOptionsStateless(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageInputStateless.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageInputStateless.java index 6f142ff1b8b..5789a7629d2 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageInputStateless.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageInputStateless.java @@ -62,7 +62,7 @@ public Builder() {} /** * Builds a MessageInputStateless. * - * @return the messageInputStateless + * @return the new MessageInputStateless instance */ public MessageInputStateless build() { return new MessageInputStateless(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOptions.java index 4f8e117633d..cfc9a0f6230 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -53,7 +53,7 @@ public Builder(String assistantId, String sessionId) { /** * Builds a MessageOptions. * - * @return the messageOptions + * @return the new MessageOptions instance */ public MessageOptions build() { return new MessageOptions(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutput.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutput.java index a1c7e17842d..1432696cdcf 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutput.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutput.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebug.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebug.java index d0ea2ec06fe..d96350c294d 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebug.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebug.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageRequest.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageRequest.java index 889e5f618e1..29ad164c633 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageRequest.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageRequest.java @@ -36,7 +36,7 @@ public Builder() {} /** * Builds a MessageRequest. * - * @return the messageRequest + * @return the new MessageRequest instance */ public MessageRequest build() { return new MessageRequest(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageResponse.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageResponse.java index 68e1776f161..fbcbfe3f5b7 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageResponse.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageResponse.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageStatelessOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageStatelessOptions.java index 4c67e41eab9..16050684735 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageStatelessOptions.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageStatelessOptions.java @@ -48,7 +48,7 @@ public Builder(String assistantId) { /** * Builds a MessageStatelessOptions. * - * @return the messageStatelessOptions + * @return the new MessageStatelessOptions instance */ public MessageStatelessOptions build() { return new MessageStatelessOptions(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeEntity.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeEntity.java index 9eedd930b9e..5b54331ed12 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeEntity.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeEntity.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -73,7 +73,7 @@ public Builder(String entity, List location, String value) { /** * Builds a RuntimeEntity. * - * @return the runtimeEntity + * @return the new RuntimeEntity instance */ public RuntimeEntity build() { return new RuntimeEntity(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeEntityAlternative.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeEntityAlternative.java index 88f1f6f575a..7ac042b8083 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeEntityAlternative.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeEntityAlternative.java @@ -36,7 +36,7 @@ public Builder() {} /** * Builds a RuntimeEntityAlternative. * - * @return the runtimeEntityAlternative + * @return the new RuntimeEntityAlternative instance */ public RuntimeEntityAlternative build() { return new RuntimeEntityAlternative(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeEntityInterpretation.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeEntityInterpretation.java index f3975d9fa04..430a7a8bbda 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeEntityInterpretation.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeEntityInterpretation.java @@ -184,7 +184,7 @@ public Builder() {} /** * Builds a RuntimeEntityInterpretation. * - * @return the runtimeEntityInterpretation + * @return the new RuntimeEntityInterpretation instance */ public RuntimeEntityInterpretation build() { return new RuntimeEntityInterpretation(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeEntityRole.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeEntityRole.java index c25aafbcb7e..330c57f4115 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeEntityRole.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeEntityRole.java @@ -53,7 +53,7 @@ public Builder() {} /** * Builds a RuntimeEntityRole. * - * @return the runtimeEntityRole + * @return the new RuntimeEntityRole instance */ public RuntimeEntityRole build() { return new RuntimeEntityRole(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeIntent.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeIntent.java index 74251a2f59d..d8534788c6a 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeIntent.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeIntent.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -47,7 +47,7 @@ public Builder(String intent, Double confidence) { /** * Builds a RuntimeIntent. * - * @return the runtimeIntent + * @return the new RuntimeIntent instance */ public RuntimeIntent build() { return new RuntimeIntent(this); diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGeneric.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGeneric.java index 936aae978ef..3dc9c635708 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGeneric.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGeneric.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -14,11 +14,36 @@ import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; -import java.util.ArrayList; import java.util.List; -/** RuntimeResponseGeneric. */ +/** + * RuntimeResponseGeneric. + * + *

Classes which extend this class: - RuntimeResponseGenericRuntimeResponseTypeText - + * RuntimeResponseGenericRuntimeResponseTypePause - RuntimeResponseGenericRuntimeResponseTypeImage - + * RuntimeResponseGenericRuntimeResponseTypeOption - + * RuntimeResponseGenericRuntimeResponseTypeConnectToAgent - + * RuntimeResponseGenericRuntimeResponseTypeSuggestion - + * RuntimeResponseGenericRuntimeResponseTypeSearch + */ public class RuntimeResponseGeneric extends GenericModel { + @SuppressWarnings("unused") + protected static String discriminatorPropertyName = "response_type"; + + protected static java.util.Map> discriminatorMapping; + + static { + discriminatorMapping = new java.util.HashMap<>(); + discriminatorMapping.put( + "connect_to_agent", RuntimeResponseGenericRuntimeResponseTypeConnectToAgent.class); + discriminatorMapping.put("image", RuntimeResponseGenericRuntimeResponseTypeImage.class); + discriminatorMapping.put("option", RuntimeResponseGenericRuntimeResponseTypeOption.class); + discriminatorMapping.put( + "suggestion", RuntimeResponseGenericRuntimeResponseTypeSuggestion.class); + discriminatorMapping.put("pause", RuntimeResponseGenericRuntimeResponseTypePause.class); + discriminatorMapping.put("search", RuntimeResponseGenericRuntimeResponseTypeSearch.class); + discriminatorMapping.put("text", RuntimeResponseGenericRuntimeResponseTypeText.class); + } /** * The type of response returned by the dialog node. The specified response type must be supported @@ -27,18 +52,6 @@ public class RuntimeResponseGeneric extends GenericModel { public interface ResponseType { /** text. */ String TEXT = "text"; - /** pause. */ - String PAUSE = "pause"; - /** image. */ - String IMAGE = "image"; - /** option. */ - String OPTION = "option"; - /** connect_to_agent. */ - String CONNECT_TO_AGENT = "connect_to_agent"; - /** suggestion. */ - String SUGGESTION = "suggestion"; - /** search. */ - String SEARCH = "search"; } /** The preferred type of control to display. */ @@ -64,293 +77,26 @@ public interface Preference { @SerializedName("message_to_human_agent") protected String messageToHumanAgent; + @SerializedName("agent_available") + protected String agentAvailable; + + @SerializedName("agent_unavailable") + protected String agentUnavailable; + + @SerializedName("transfer_info") + protected DialogNodeOutputConnectToAgentTransferInfo transferInfo; + protected String topic; protected List suggestions; protected String header; - protected List results; - - /** Builder. */ - public static class Builder { - private String responseType; - private String text; - private Long time; - private Boolean typing; - private String source; - private String title; - private String description; - private String preference; - private List options; - private String messageToHumanAgent; - private String topic; - private List suggestions; - private String header; - private List results; - - private Builder(RuntimeResponseGeneric runtimeResponseGeneric) { - this.responseType = runtimeResponseGeneric.responseType; - this.text = runtimeResponseGeneric.text; - this.time = runtimeResponseGeneric.time; - this.typing = runtimeResponseGeneric.typing; - this.source = runtimeResponseGeneric.source; - this.title = runtimeResponseGeneric.title; - this.description = runtimeResponseGeneric.description; - this.preference = runtimeResponseGeneric.preference; - this.options = runtimeResponseGeneric.options; - this.messageToHumanAgent = runtimeResponseGeneric.messageToHumanAgent; - this.topic = runtimeResponseGeneric.topic; - this.suggestions = runtimeResponseGeneric.suggestions; - this.header = runtimeResponseGeneric.header; - this.results = runtimeResponseGeneric.results; - } - - /** Instantiates a new builder. */ - public Builder() {} - - /** - * Instantiates a new builder with required properties. - * - * @param responseType the responseType - */ - public Builder(String responseType) { - this.responseType = responseType; - } - - /** - * Builds a RuntimeResponseGeneric. - * - * @return the runtimeResponseGeneric - */ - public RuntimeResponseGeneric build() { - return new RuntimeResponseGeneric(this); - } - - /** - * Adds an options to options. - * - * @param options the new options - * @return the RuntimeResponseGeneric builder - */ - public Builder addOptions(DialogNodeOutputOptionsElement options) { - com.ibm.cloud.sdk.core.util.Validator.notNull(options, "options cannot be null"); - if (this.options == null) { - this.options = new ArrayList(); - } - this.options.add(options); - return this; - } - - /** - * Adds an suggestions to suggestions. - * - * @param suggestions the new suggestions - * @return the RuntimeResponseGeneric builder - */ - public Builder addSuggestions(DialogSuggestion suggestions) { - com.ibm.cloud.sdk.core.util.Validator.notNull(suggestions, "suggestions cannot be null"); - if (this.suggestions == null) { - this.suggestions = new ArrayList(); - } - this.suggestions.add(suggestions); - return this; - } - - /** - * Adds an results to results. - * - * @param results the new results - * @return the RuntimeResponseGeneric builder - */ - public Builder addResults(SearchResult results) { - com.ibm.cloud.sdk.core.util.Validator.notNull(results, "results cannot be null"); - if (this.results == null) { - this.results = new ArrayList(); - } - this.results.add(results); - return this; - } - - /** - * Set the responseType. - * - * @param responseType the responseType - * @return the RuntimeResponseGeneric builder - */ - public Builder responseType(String responseType) { - this.responseType = responseType; - return this; - } - - /** - * Set the text. - * - * @param text the text - * @return the RuntimeResponseGeneric builder - */ - public Builder text(String text) { - this.text = text; - return this; - } - - /** - * Set the time. - * - * @param time the time - * @return the RuntimeResponseGeneric builder - */ - public Builder time(long time) { - this.time = time; - return this; - } - - /** - * Set the typing. - * - * @param typing the typing - * @return the RuntimeResponseGeneric builder - */ - public Builder typing(Boolean typing) { - this.typing = typing; - return this; - } - - /** - * Set the source. - * - * @param source the source - * @return the RuntimeResponseGeneric builder - */ - public Builder source(String source) { - this.source = source; - return this; - } - - /** - * Set the title. - * - * @param title the title - * @return the RuntimeResponseGeneric builder - */ - public Builder title(String title) { - this.title = title; - return this; - } - - /** - * Set the description. - * - * @param description the description - * @return the RuntimeResponseGeneric builder - */ - public Builder description(String description) { - this.description = description; - return this; - } - - /** - * Set the preference. - * - * @param preference the preference - * @return the RuntimeResponseGeneric builder - */ - public Builder preference(String preference) { - this.preference = preference; - return this; - } - - /** - * Set the options. Existing options will be replaced. - * - * @param options the options - * @return the RuntimeResponseGeneric builder - */ - public Builder options(List options) { - this.options = options; - return this; - } - - /** - * Set the messageToHumanAgent. - * - * @param messageToHumanAgent the messageToHumanAgent - * @return the RuntimeResponseGeneric builder - */ - public Builder messageToHumanAgent(String messageToHumanAgent) { - this.messageToHumanAgent = messageToHumanAgent; - return this; - } - - /** - * Set the topic. - * - * @param topic the topic - * @return the RuntimeResponseGeneric builder - */ - public Builder topic(String topic) { - this.topic = topic; - return this; - } - - /** - * Set the suggestions. Existing suggestions will be replaced. - * - * @param suggestions the suggestions - * @return the RuntimeResponseGeneric builder - */ - public Builder suggestions(List suggestions) { - this.suggestions = suggestions; - return this; - } - - /** - * Set the header. - * - * @param header the header - * @return the RuntimeResponseGeneric builder - */ - public Builder header(String header) { - this.header = header; - return this; - } - - /** - * Set the results. Existing results will be replaced. - * - * @param results the results - * @return the RuntimeResponseGeneric builder - */ - public Builder results(List results) { - this.results = results; - return this; - } - } - protected RuntimeResponseGeneric(Builder builder) { - com.ibm.cloud.sdk.core.util.Validator.notNull( - builder.responseType, "responseType cannot be null"); - responseType = builder.responseType; - text = builder.text; - time = builder.time; - typing = builder.typing; - source = builder.source; - title = builder.title; - description = builder.description; - preference = builder.preference; - options = builder.options; - messageToHumanAgent = builder.messageToHumanAgent; - topic = builder.topic; - suggestions = builder.suggestions; - header = builder.header; - results = builder.results; - } + @SerializedName("primary_results") + protected List primaryResults; - /** - * New builder. - * - * @return a RuntimeResponseGeneric builder - */ - public Builder newBuilder() { - return new Builder(this); - } + @SerializedName("additional_results") + protected List additionalResults; + + protected RuntimeResponseGeneric() {} /** * Gets the responseType. @@ -411,7 +157,7 @@ public String source() { /** * Gets the title. * - *

The title or introductory text to show before the response. + *

The title to show before the response. * * @return the title */ @@ -463,11 +209,46 @@ public String messageToHumanAgent() { return messageToHumanAgent; } + /** + * Gets the agentAvailable. + * + *

An optional message to be displayed to the user to indicate that the conversation will be + * transferred to the next available agent. + * + * @return the agentAvailable + */ + public String agentAvailable() { + return agentAvailable; + } + + /** + * Gets the agentUnavailable. + * + *

An optional message to be displayed to the user to indicate that no online agent is + * available to take over the conversation. + * + * @return the agentUnavailable + */ + public String agentUnavailable() { + return agentUnavailable; + } + + /** + * Gets the transferInfo. + * + *

Routing or other contextual information to be used by target service desk systems. + * + * @return the transferInfo + */ + public DialogNodeOutputConnectToAgentTransferInfo transferInfo() { + return transferInfo; + } + /** * Gets the topic. * - *

A label identifying the topic of the conversation, derived from the **user_label** property - * of the relevant node. + *

A label identifying the topic of the conversation, derived from the **title** property of + * the relevant node or the **topic** property of the dialog node response. * * @return the topic */ @@ -500,13 +281,26 @@ public String header() { } /** - * Gets the results. + * Gets the primaryResults. + * + *

An array of objects that contains the search results to be displayed in the initial response + * to the user. + * + * @return the primaryResults + */ + public List primaryResults() { + return primaryResults; + } + + /** + * Gets the additionalResults. * - *

An array of objects containing search results. + *

An array of objects that contains additional search results that can be displayed to the + * user upon request. * - * @return the results + * @return the additionalResults */ - public List results() { - return results; + public List additionalResults() { + return additionalResults; } } diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeConnectToAgent.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeConnectToAgent.java new file mode 100644 index 00000000000..e5d672795ac --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeConnectToAgent.java @@ -0,0 +1,27 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +/** An object that describes a response with response type `connect_to_agent`. */ +public class RuntimeResponseGenericRuntimeResponseTypeConnectToAgent + extends RuntimeResponseGeneric { + + /** + * The type of response returned by the dialog node. The specified response type must be supported + * by the client application or channel. + */ + public interface ResponseType { + /** connect_to_agent. */ + String CONNECT_TO_AGENT = "connect_to_agent"; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeImage.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeImage.java new file mode 100644 index 00000000000..67f56369513 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeImage.java @@ -0,0 +1,26 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +/** An object that describes a response with response type `image`. */ +public class RuntimeResponseGenericRuntimeResponseTypeImage extends RuntimeResponseGeneric { + + /** + * The type of response returned by the dialog node. The specified response type must be supported + * by the client application or channel. + */ + public interface ResponseType { + /** image. */ + String IMAGE = "image"; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeOption.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeOption.java new file mode 100644 index 00000000000..691be80f076 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeOption.java @@ -0,0 +1,34 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +/** An object that describes a response with response type `option`. */ +public class RuntimeResponseGenericRuntimeResponseTypeOption extends RuntimeResponseGeneric { + + /** + * The type of response returned by the dialog node. The specified response type must be supported + * by the client application or channel. + */ + public interface ResponseType { + /** option. */ + String OPTION = "option"; + } + + /** The preferred type of control to display. */ + public interface Preference { + /** dropdown. */ + String DROPDOWN = "dropdown"; + /** button. */ + String BUTTON = "button"; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypePause.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypePause.java new file mode 100644 index 00000000000..27fa6b06ef6 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypePause.java @@ -0,0 +1,26 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +/** An object that describes a response with response type `pause`. */ +public class RuntimeResponseGenericRuntimeResponseTypePause extends RuntimeResponseGeneric { + + /** + * The type of response returned by the dialog node. The specified response type must be supported + * by the client application or channel. + */ + public interface ResponseType { + /** pause. */ + String PAUSE = "pause"; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeSearch.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeSearch.java new file mode 100644 index 00000000000..c60a6b7d822 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeSearch.java @@ -0,0 +1,26 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +/** An object that describes a response with response type `search`. */ +public class RuntimeResponseGenericRuntimeResponseTypeSearch extends RuntimeResponseGeneric { + + /** + * The type of response returned by the dialog node. The specified response type must be supported + * by the client application or channel. + */ + public interface ResponseType { + /** search. */ + String SEARCH = "search"; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeSuggestion.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeSuggestion.java new file mode 100644 index 00000000000..14b12cbcaa6 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeSuggestion.java @@ -0,0 +1,26 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +/** An object that describes a response with response type `suggestion`. */ +public class RuntimeResponseGenericRuntimeResponseTypeSuggestion extends RuntimeResponseGeneric { + + /** + * The type of response returned by the dialog node. The specified response type must be supported + * by the client application or channel. + */ + public interface ResponseType { + /** suggestion. */ + String SUGGESTION = "suggestion"; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeText.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeText.java new file mode 100644 index 00000000000..2d60a30e94d --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeText.java @@ -0,0 +1,26 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +/** An object that describes a response with response type `text`. */ +public class RuntimeResponseGenericRuntimeResponseTypeText extends RuntimeResponseGeneric { + + /** + * The type of response returned by the dialog node. The specified response type must be supported + * by the client application or channel. + */ + public interface ResponseType { + /** text. */ + String TEXT = "text"; + } +} diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchResult.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchResult.java index 4e4e1403400..c5137fa6d90 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchResult.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -92,7 +92,7 @@ public String getUrl() { * Gets the highlight. * *

An object containing segments of text from search results with query-matching text - * highlighted using HTML `` tags. + * highlighted using HTML `<em>` tags. * * @return the highlight */ diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchResultHighlight.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchResultHighlight.java index 3d4531f2ec6..f0d9ea63dc5 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchResultHighlight.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchResultHighlight.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -19,7 +19,7 @@ /** * An object containing segments of text from search results with query-matching text highlighted - * using HTML `` tags. + * using HTML `<em>` tags. */ public class SearchResultHighlight extends DynamicModel> { diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchResultMetadata.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchResultMetadata.java index c719ac93e67..1681083ae88 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchResultMetadata.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchResultMetadata.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SessionResponse.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SessionResponse.java index 07e07f2686c..38aaca02f40 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SessionResponse.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SessionResponse.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/package-info.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/package-info.java index 49e30314a3f..05bec07c6e2 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/package-info.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/package-info.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/AssistantTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/AssistantTest.java index 68378067ca9..b1bab499e67 100644 --- a/assistant/src/test/java/com/ibm/watson/assistant/v1/AssistantTest.java +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/AssistantTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -12,1184 +12,3825 @@ */ package com.ibm.watson.assistant.v1; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.testng.Assert.*; +import com.ibm.cloud.sdk.core.http.Response; +import com.ibm.cloud.sdk.core.security.Authenticator; import com.ibm.cloud.sdk.core.security.NoAuthAuthenticator; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.model.BulkClassifyOptions; +import com.ibm.watson.assistant.v1.model.BulkClassifyResponse; +import com.ibm.watson.assistant.v1.model.BulkClassifyUtterance; +import com.ibm.watson.assistant.v1.model.CaptureGroup; import com.ibm.watson.assistant.v1.model.Context; import com.ibm.watson.assistant.v1.model.Counterexample; +import com.ibm.watson.assistant.v1.model.CounterexampleCollection; +import com.ibm.watson.assistant.v1.model.CreateCounterexampleOptions; import com.ibm.watson.assistant.v1.model.CreateDialogNodeOptions; import com.ibm.watson.assistant.v1.model.CreateEntity; import com.ibm.watson.assistant.v1.model.CreateEntityOptions; import com.ibm.watson.assistant.v1.model.CreateExampleOptions; import com.ibm.watson.assistant.v1.model.CreateIntent; import com.ibm.watson.assistant.v1.model.CreateIntentOptions; +import com.ibm.watson.assistant.v1.model.CreateSynonymOptions; import com.ibm.watson.assistant.v1.model.CreateValue; import com.ibm.watson.assistant.v1.model.CreateValueOptions; import com.ibm.watson.assistant.v1.model.CreateWorkspaceOptions; +import com.ibm.watson.assistant.v1.model.DeleteCounterexampleOptions; +import com.ibm.watson.assistant.v1.model.DeleteDialogNodeOptions; +import com.ibm.watson.assistant.v1.model.DeleteEntityOptions; +import com.ibm.watson.assistant.v1.model.DeleteExampleOptions; +import com.ibm.watson.assistant.v1.model.DeleteIntentOptions; +import com.ibm.watson.assistant.v1.model.DeleteSynonymOptions; import com.ibm.watson.assistant.v1.model.DeleteUserDataOptions; +import com.ibm.watson.assistant.v1.model.DeleteValueOptions; +import com.ibm.watson.assistant.v1.model.DeleteWorkspaceOptions; import com.ibm.watson.assistant.v1.model.DialogNode; import com.ibm.watson.assistant.v1.model.DialogNodeAction; +import com.ibm.watson.assistant.v1.model.DialogNodeCollection; +import com.ibm.watson.assistant.v1.model.DialogNodeContext; +import com.ibm.watson.assistant.v1.model.DialogNodeNextStep; +import com.ibm.watson.assistant.v1.model.DialogNodeOutput; +import com.ibm.watson.assistant.v1.model.DialogNodeOutputGeneric; +import com.ibm.watson.assistant.v1.model.DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill; +import com.ibm.watson.assistant.v1.model.DialogNodeOutputModifiers; +import com.ibm.watson.assistant.v1.model.DialogNodeOutputOptionsElement; +import com.ibm.watson.assistant.v1.model.DialogNodeOutputOptionsElementValue; +import com.ibm.watson.assistant.v1.model.DialogNodeVisitedDetails; +import com.ibm.watson.assistant.v1.model.Entity; +import com.ibm.watson.assistant.v1.model.EntityCollection; +import com.ibm.watson.assistant.v1.model.EntityMentionCollection; import com.ibm.watson.assistant.v1.model.Example; +import com.ibm.watson.assistant.v1.model.ExampleCollection; +import com.ibm.watson.assistant.v1.model.GetCounterexampleOptions; +import com.ibm.watson.assistant.v1.model.GetDialogNodeOptions; +import com.ibm.watson.assistant.v1.model.GetEntityOptions; +import com.ibm.watson.assistant.v1.model.GetExampleOptions; +import com.ibm.watson.assistant.v1.model.GetIntentOptions; +import com.ibm.watson.assistant.v1.model.GetSynonymOptions; +import com.ibm.watson.assistant.v1.model.GetValueOptions; import com.ibm.watson.assistant.v1.model.GetWorkspaceOptions; +import com.ibm.watson.assistant.v1.model.Intent; +import com.ibm.watson.assistant.v1.model.IntentCollection; import com.ibm.watson.assistant.v1.model.ListAllLogsOptions; +import com.ibm.watson.assistant.v1.model.ListCounterexamplesOptions; +import com.ibm.watson.assistant.v1.model.ListDialogNodesOptions; +import com.ibm.watson.assistant.v1.model.ListEntitiesOptions; +import com.ibm.watson.assistant.v1.model.ListExamplesOptions; +import com.ibm.watson.assistant.v1.model.ListIntentsOptions; +import com.ibm.watson.assistant.v1.model.ListLogsOptions; import com.ibm.watson.assistant.v1.model.ListMentionsOptions; +import com.ibm.watson.assistant.v1.model.ListSynonymsOptions; +import com.ibm.watson.assistant.v1.model.ListValuesOptions; +import com.ibm.watson.assistant.v1.model.ListWorkspacesOptions; +import com.ibm.watson.assistant.v1.model.LogCollection; +import com.ibm.watson.assistant.v1.model.LogMessage; import com.ibm.watson.assistant.v1.model.Mention; import com.ibm.watson.assistant.v1.model.MessageContextMetadata; import com.ibm.watson.assistant.v1.model.MessageInput; import com.ibm.watson.assistant.v1.model.MessageOptions; -import com.ibm.watson.assistant.v1.model.MessageRequest; import com.ibm.watson.assistant.v1.model.MessageResponse; import com.ibm.watson.assistant.v1.model.OutputData; import com.ibm.watson.assistant.v1.model.RuntimeEntity; +import com.ibm.watson.assistant.v1.model.RuntimeEntityAlternative; +import com.ibm.watson.assistant.v1.model.RuntimeEntityInterpretation; +import com.ibm.watson.assistant.v1.model.RuntimeEntityRole; import com.ibm.watson.assistant.v1.model.RuntimeIntent; +import com.ibm.watson.assistant.v1.model.RuntimeResponseGeneric; +import com.ibm.watson.assistant.v1.model.RuntimeResponseGenericRuntimeResponseTypeOption; +import com.ibm.watson.assistant.v1.model.Synonym; +import com.ibm.watson.assistant.v1.model.SynonymCollection; +import com.ibm.watson.assistant.v1.model.UpdateCounterexampleOptions; import com.ibm.watson.assistant.v1.model.UpdateDialogNodeOptions; import com.ibm.watson.assistant.v1.model.UpdateEntityOptions; import com.ibm.watson.assistant.v1.model.UpdateExampleOptions; import com.ibm.watson.assistant.v1.model.UpdateIntentOptions; +import com.ibm.watson.assistant.v1.model.UpdateSynonymOptions; import com.ibm.watson.assistant.v1.model.UpdateValueOptions; import com.ibm.watson.assistant.v1.model.UpdateWorkspaceOptions; +import com.ibm.watson.assistant.v1.model.Value; +import com.ibm.watson.assistant.v1.model.ValueCollection; import com.ibm.watson.assistant.v1.model.Webhook; import com.ibm.watson.assistant.v1.model.WebhookHeader; +import com.ibm.watson.assistant.v1.model.Workspace; +import com.ibm.watson.assistant.v1.model.WorkspaceCollection; import com.ibm.watson.assistant.v1.model.WorkspaceSystemSettings; import com.ibm.watson.assistant.v1.model.WorkspaceSystemSettingsDisambiguation; import com.ibm.watson.assistant.v1.model.WorkspaceSystemSettingsOffTopic; +import com.ibm.watson.assistant.v1.model.WorkspaceSystemSettingsSystemEntities; import com.ibm.watson.assistant.v1.model.WorkspaceSystemSettingsTooling; -import com.ibm.watson.common.WatsonServiceUnitTest; -import java.io.FileNotFoundException; +import com.ibm.watson.assistant.v1.utils.TestUtilities; import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Date; +import java.io.InputStream; import java.util.HashMap; import java.util.List; import java.util.Map; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; import okhttp3.mockwebserver.RecordedRequest; -import org.apache.commons.lang3.StringUtils; -import org.junit.Before; -import org.junit.Test; - -/** Unit tests for the {@link Assistant}. */ -public class AssistantTest extends WatsonServiceUnitTest { - private static final String VERSION_DATE = "2019-02-28"; - private static final String INTENT = "turn_on"; - private static final Double CONFIDENCE = 0.0; - private static final String ENTITY = "genre"; - private static final String VALUE = "jazz"; - private static final String NONE_OF_THE_ABOVE_PROMPT = "none of the above"; - private static final String PROMPT = "prompt"; - private static final List LOCATION = Arrays.asList(1L, 2L); - private static final String TEXT = "text"; - private static final String NAME = "name"; - private static final String CREDENTIALS = "credentials"; - private static final String RESULT_VARIABLE = "result_variable"; - private static final String WEBHOOK_HEADER_NAME = "Webhook-Header"; - private static final String WEBHOOK_HEADER_VALUE = "webhook_value"; - private static final String WEBHOOK_NAME = "webhook_name"; - private static final String WEBHOOK_URL = "webhook_url"; - private static final Long MAX_SUGGESTIONS = 100L; - private static final String SUGGESTION_TEXT_POLICY = "suggestion_text_policy"; - - private Assistant service; - private static final String FIXTURE = "src/test/resources/assistant/assistant.json"; - private static final String WORKSPACE_ID = "123"; - private static final String PATH_MESSAGE = "/v1/workspaces/" + WORKSPACE_ID + "/message"; - private static final String VERSION = "version"; - - /** - * Sets up the tests. - * - * @throws Exception the exception - */ - /* - * (non-Javadoc) - * @see com.ibm.watson.common.WatsonServiceTest#setUp() - */ - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - service = new Assistant(VERSION_DATE, new NoAuthAuthenticator()); - service.setServiceUrl(getMockWebServerUrl()); - } - - /** Negative - Test constructor with null version date. */ - @Test(expected = IllegalArgumentException.class) - public void testConstructorWithNullVersionDate() { - new Assistant(null, new NoAuthAuthenticator()); - } - - /** Negative - Test constructor with empty version date. */ - @Test(expected = IllegalArgumentException.class) - public void testConstructorWithEmptyVersionDate() { - new Assistant("", new NoAuthAuthenticator()); - } - - /** Negative - Test assistant with null options. */ - @Test(expected = IllegalArgumentException.class) - public void testAssistantWithNullOptions() { - service.message(null).execute().getResult(); - } - - /** Negative - Test assistant with null workspaceId. */ - @Test(expected = IllegalArgumentException.class) - public void testAssistantWithNullWorkspaceId() { - MessageOptions options = new MessageOptions.Builder().build(); - service.message(options).execute().getResult(); - } - - /** Negative - Test assistant with empty workspaceId. */ - @Test(expected = IllegalArgumentException.class) - public void testAssistantWithEmptyWorkspaceId() { - MessageOptions options = new MessageOptions.Builder("").build(); - service.message(options).execute().getResult(); - } - - /** - * Test send message. - * - * @throws IOException Signals that an I/O exception has occurred. - * @throws InterruptedException the interrupted exception - */ +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +/** Unit test class for the Assistant service. */ +public class AssistantTest { + + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + protected MockWebServer server; + protected Assistant assistantService; + + public void constructClientService() throws Throwable { + final String serviceName = "testService"; + // set mock values for global params + String version = "testString"; + + final Authenticator authenticator = new NoAuthAuthenticator(); + + assistantService = new Assistant(version, serviceName, authenticator); + String url = server.url("/").toString(); + assistantService.setServiceUrl(url); + } + + /** Negative Test - construct the service with a null authenticator. */ + @Test(expectedExceptions = IllegalArgumentException.class) + public void testConstructorWithNullAuthenticator() throws Throwable { + final String serviceName = "testService"; + // set mock values for global params + String version = "testString"; + + new Assistant(version, serviceName, null); + } + @Test - public void testSendMessage() throws IOException, InterruptedException { - String text = "I would love to hear some jazz music."; - - MessageResponse mockResponse = loadFixture(FIXTURE, MessageResponse.class); - server.enqueue(jsonResponse(mockResponse)); - - MessageInput input = new MessageInput(); - input.setText(text); - RuntimeIntent intent = - new RuntimeIntent.Builder().intent(INTENT).confidence(CONFIDENCE).build(); - RuntimeEntity entity = - new RuntimeEntity.Builder().entity(ENTITY).value(VALUE).location(LOCATION).build(); - MessageOptions options = - new MessageOptions.Builder(WORKSPACE_ID) - .input(input) - .addIntent(intent) - .addEntity(entity) - .alternateIntents(true) + public void testGetVersion() throws Throwable { + constructClientService(); + assertEquals(assistantService.getVersion(), "testString"); + } + + @Test + public void testMessageWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"input\": {\"text\": \"text\", \"spelling_suggestions\": false, \"spelling_auto_correct\": false, \"suggested_text\": \"suggestedText\", \"original_text\": \"originalText\"}, \"intents\": [{\"intent\": \"intent\", \"confidence\": 10}], \"entities\": [{\"entity\": \"entity\", \"location\": [8], \"value\": \"value\", \"confidence\": 10, \"metadata\": {\"mapKey\": \"anyValue\"}, \"groups\": [{\"group\": \"group\", \"location\": [8]}], \"interpretation\": {\"calendar_type\": \"calendarType\", \"datetime_link\": \"datetimeLink\", \"festival\": \"festival\", \"granularity\": \"day\", \"range_link\": \"rangeLink\", \"range_modifier\": \"rangeModifier\", \"relative_day\": 11, \"relative_month\": 13, \"relative_week\": 12, \"relative_weekend\": 15, \"relative_year\": 12, \"specific_day\": 11, \"specific_day_of_week\": \"specificDayOfWeek\", \"specific_month\": 13, \"specific_quarter\": 15, \"specific_year\": 12, \"numeric_value\": 12, \"subtype\": \"subtype\", \"part_of_day\": \"partOfDay\", \"relative_hour\": 12, \"relative_minute\": 14, \"relative_second\": 14, \"specific_hour\": 12, \"specific_minute\": 14, \"specific_second\": 14, \"timezone\": \"timezone\"}, \"alternatives\": [{\"value\": \"value\", \"confidence\": 10}], \"role\": {\"type\": \"date_from\"}}], \"alternate_intents\": true, \"context\": {\"conversation_id\": \"conversationId\", \"system\": {\"mapKey\": \"anyValue\"}, \"metadata\": {\"deployment\": \"deployment\", \"user_id\": \"userId\"}}, \"output\": {\"nodes_visited\": [\"nodesVisited\"], \"nodes_visited_details\": [{\"dialog_node\": \"dialogNode\", \"title\": \"title\", \"conditions\": \"conditions\"}], \"log_messages\": [{\"level\": \"info\", \"msg\": \"msg\"}], \"text\": [\"text\"], \"generic\": [{\"response_type\": \"option\", \"title\": \"title\", \"description\": \"description\", \"preference\": \"dropdown\", \"options\": [{\"label\": \"label\", \"value\": {\"input\": {\"text\": \"text\", \"spelling_suggestions\": false, \"spelling_auto_correct\": false, \"suggested_text\": \"suggestedText\", \"original_text\": \"originalText\"}, \"intents\": [{\"intent\": \"intent\", \"confidence\": 10}], \"entities\": [{\"entity\": \"entity\", \"location\": [8], \"value\": \"value\", \"confidence\": 10, \"metadata\": {\"mapKey\": \"anyValue\"}, \"groups\": [{\"group\": \"group\", \"location\": [8]}], \"interpretation\": {\"calendar_type\": \"calendarType\", \"datetime_link\": \"datetimeLink\", \"festival\": \"festival\", \"granularity\": \"day\", \"range_link\": \"rangeLink\", \"range_modifier\": \"rangeModifier\", \"relative_day\": 11, \"relative_month\": 13, \"relative_week\": 12, \"relative_weekend\": 15, \"relative_year\": 12, \"specific_day\": 11, \"specific_day_of_week\": \"specificDayOfWeek\", \"specific_month\": 13, \"specific_quarter\": 15, \"specific_year\": 12, \"numeric_value\": 12, \"subtype\": \"subtype\", \"part_of_day\": \"partOfDay\", \"relative_hour\": 12, \"relative_minute\": 14, \"relative_second\": 14, \"specific_hour\": 12, \"specific_minute\": 14, \"specific_second\": 14, \"timezone\": \"timezone\"}, \"alternatives\": [{\"value\": \"value\", \"confidence\": 10}], \"role\": {\"type\": \"date_from\"}}]}}]}]}, \"actions\": [{\"name\": \"name\", \"type\": \"client\", \"parameters\": {\"mapKey\": \"anyValue\"}, \"result_variable\": \"resultVariable\", \"credentials\": \"credentials\"}]}"; + String messagePath = "/v1/workspaces/testString/message"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the MessageInput model + MessageInput messageInputModel = + new MessageInput.Builder() + .text("testString") + .spellingSuggestions(true) + .spellingAutoCorrect(true) + .add("foo", "testString") .build(); - // execute first request - MessageResponse serviceResponse = service.message(options).execute().getResult(); + // Construct an instance of the RuntimeIntent model + RuntimeIntent runtimeIntentModel = + new RuntimeIntent.Builder().intent("testString").confidence(Double.valueOf("72.5")).build(); - // first request - RecordedRequest request = server.takeRequest(); + // Construct an instance of the CaptureGroup model + CaptureGroup captureGroupModel = + new CaptureGroup.Builder() + .group("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) + .build(); - String path = StringUtils.join(PATH_MESSAGE, "?", VERSION, "=", VERSION_DATE); - assertEquals(path, request.getPath()); - assertArrayEquals( - new String[] {"Great choice! Playing some jazz for you."}, - serviceResponse.getOutput().getText().toArray(new String[0])); - assertEquals(request.getMethod(), "POST"); - assertNotNull(serviceResponse.getActions()); - assertNotNull(serviceResponse.getActions().get(0).name()); - assertNotNull(serviceResponse.getActions().get(0).credentials()); - assertNotNull(serviceResponse.getActions().get(0).type()); - assertNotNull(serviceResponse.getActions().get(0).parameters()); - assertNotNull(serviceResponse.getActions().get(0).resultVariable()); - assertNotNull(serviceResponse.getOutput().getLogMessages()); - assertNotNull(serviceResponse.getOutput().getNodesVisited()); - assertNotNull(serviceResponse.getOutput().getNodesVisitedDetails()); - assertNotNull(serviceResponse.getOutput().getNodesVisitedDetails().get(0).dialogNode()); - assertNotNull(serviceResponse.getOutput().getNodesVisitedDetails().get(0).title()); - assertNotNull(serviceResponse.getOutput().getNodesVisitedDetails().get(0).conditions()); - assertNotNull(serviceResponse.getOutput().getNodesVisitedDetails().get(0).conditions()); - } - - /** - * Test send message. use some different MessageOptions options like context and other public - * methods - * - * @throws IOException Signals that an I/O exception has occurred. - * @throws InterruptedException the interrupted exception - */ - @Test - public void testSendMessageWithAlternateIntents() throws IOException, InterruptedException { - MessageResponse mockResponse = loadFixture(FIXTURE, MessageResponse.class); - server.enqueue(jsonResponse(mockResponse)); + // Construct an instance of the RuntimeEntityInterpretation model + RuntimeEntityInterpretation runtimeEntityInterpretationModel = + new RuntimeEntityInterpretation.Builder() + .calendarType("testString") + .datetimeLink("testString") + .festival("testString") + .granularity("day") + .rangeLink("testString") + .rangeModifier("testString") + .relativeDay(Double.valueOf("72.5")) + .relativeMonth(Double.valueOf("72.5")) + .relativeWeek(Double.valueOf("72.5")) + .relativeWeekend(Double.valueOf("72.5")) + .relativeYear(Double.valueOf("72.5")) + .specificDay(Double.valueOf("72.5")) + .specificDayOfWeek("testString") + .specificMonth(Double.valueOf("72.5")) + .specificQuarter(Double.valueOf("72.5")) + .specificYear(Double.valueOf("72.5")) + .numericValue(Double.valueOf("72.5")) + .subtype("testString") + .partOfDay("testString") + .relativeHour(Double.valueOf("72.5")) + .relativeMinute(Double.valueOf("72.5")) + .relativeSecond(Double.valueOf("72.5")) + .specificHour(Double.valueOf("72.5")) + .specificMinute(Double.valueOf("72.5")) + .specificSecond(Double.valueOf("72.5")) + .timezone("testString") + .build(); - MessageContextMetadata metadata = new MessageContextMetadata.Builder().build(); - Context contextTemp = new Context(); - contextTemp.put("name", "Myname"); - contextTemp.setMetadata(metadata); - MessageInput inputTemp = new MessageInput(); - inputTemp.setText("My text"); + // Construct an instance of the RuntimeEntityAlternative model + RuntimeEntityAlternative runtimeEntityAlternativeModel = + new RuntimeEntityAlternative.Builder() + .value("testString") + .confidence(Double.valueOf("72.5")) + .build(); - assertEquals("Myname", contextTemp.get("name")); - assertEquals(metadata, contextTemp.getMetadata()); + // Construct an instance of the RuntimeEntityRole model + RuntimeEntityRole runtimeEntityRoleModel = + new RuntimeEntityRole.Builder().type("date_from").build(); + + // Construct an instance of the RuntimeEntity model + RuntimeEntity runtimeEntityModel = + new RuntimeEntity.Builder() + .entity("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) + .value("testString") + .confidence(Double.valueOf("72.5")) + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .groups( + new java.util.ArrayList(java.util.Arrays.asList(captureGroupModel))) + .interpretation(runtimeEntityInterpretationModel) + .alternatives( + new java.util.ArrayList( + java.util.Arrays.asList(runtimeEntityAlternativeModel))) + .role(runtimeEntityRoleModel) + .build(); - MessageOptions options = - new MessageOptions.Builder(WORKSPACE_ID) - .input(inputTemp) - .alternateIntents(false) - .context(contextTemp) - .entities(null) - .intents(null) + // Construct an instance of the MessageContextMetadata model + MessageContextMetadata messageContextMetadataModel = + new MessageContextMetadata.Builder().deployment("testString").userId("testString").build(); + + // Construct an instance of the Context model + Context contextModel = + new Context.Builder() + .conversationId("testString") + .system( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .metadata(messageContextMetadataModel) + .add("foo", "testString") .build(); - // execute first request - MessageResponse serviceResponse = service.message(options).execute().getResult(); + // Construct an instance of the DialogNodeVisitedDetails model + DialogNodeVisitedDetails dialogNodeVisitedDetailsModel = + new DialogNodeVisitedDetails.Builder() + .dialogNode("testString") + .title("testString") + .conditions("testString") + .build(); - // first request - RecordedRequest request = server.takeRequest(); + // Construct an instance of the LogMessage model + LogMessage logMessageModel = new LogMessage.Builder().level("info").msg("testString").build(); + + // Construct an instance of the DialogNodeOutputOptionsElementValue model + DialogNodeOutputOptionsElementValue dialogNodeOutputOptionsElementValueModel = + new DialogNodeOutputOptionsElementValue.Builder() + .input(messageInputModel) + .intents( + new java.util.ArrayList(java.util.Arrays.asList(runtimeIntentModel))) + .entities( + new java.util.ArrayList(java.util.Arrays.asList(runtimeEntityModel))) + .build(); - String path = StringUtils.join(PATH_MESSAGE, "?", VERSION, "=", VERSION_DATE); - assertEquals(path, request.getPath()); - assertArrayEquals( - new String[] {"Great choice! Playing some jazz for you."}, - serviceResponse.getOutput().getText().toArray(new String[0])); - assertEquals(request.getMethod(), "POST"); - } + // Construct an instance of the DialogNodeOutputOptionsElement model + DialogNodeOutputOptionsElement dialogNodeOutputOptionsElementModel = + new DialogNodeOutputOptionsElement.Builder() + .label("testString") + .value(dialogNodeOutputOptionsElementValueModel) + .build(); - /** - * Test send message with message request. - * - * @throws FileNotFoundException the file not found exception - * @throws InterruptedException the interrupted exception - */ - @Test - public void testSendMessageWithMessageRequest() - throws FileNotFoundException, InterruptedException { - String text = "I would love to hear some jazz music."; - - MessageResponse mockResponse = loadFixture(FIXTURE, MessageResponse.class); - server.enqueue(jsonResponse(mockResponse)); - - MessageInput input = new MessageInput(); - input.setText(text); - RuntimeIntent intent = - new RuntimeIntent.Builder().intent(INTENT).confidence(CONFIDENCE).build(); - RuntimeEntity entity = - new RuntimeEntity.Builder().entity(ENTITY).value(VALUE).location(LOCATION).build(); - Context context = new Context(); - OutputData outputData = new OutputData(); - - MessageRequest messageRequest = - new MessageRequest.Builder() - .input(input) - .intents(Collections.singletonList(intent)) - .entities(Collections.singletonList(entity)) - .alternateIntents(true) - .context(context) - .output(outputData) + // Construct an instance of the RuntimeResponseGenericRuntimeResponseTypeOption model + RuntimeResponseGenericRuntimeResponseTypeOption runtimeResponseGenericModel = + new RuntimeResponseGenericRuntimeResponseTypeOption.Builder() + .responseType("option") + .title("testString") + .description("testString") + .preference("dropdown") + .options( + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeOutputOptionsElementModel))) .build(); - assertEquals(input, messageRequest.input()); - assertEquals(intent, messageRequest.intents().get(0)); - assertEquals(entity, messageRequest.entities().get(0)); - assertEquals(context, messageRequest.context()); - assertEquals(outputData, messageRequest.output()); + // Construct an instance of the OutputData model + OutputData outputDataModel = + new OutputData.Builder() + .nodesVisited(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .nodesVisitedDetails( + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeVisitedDetailsModel))) + .logMessages( + new java.util.ArrayList(java.util.Arrays.asList(logMessageModel))) + .text(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .generic( + new java.util.ArrayList( + java.util.Arrays.asList(runtimeResponseGenericModel))) + .add("foo", "testString") + .build(); - MessageOptions options = + // Construct an instance of the MessageOptions model + MessageOptions messageOptionsModel = new MessageOptions.Builder() - .workspaceId(WORKSPACE_ID) - .messageRequest(messageRequest) + .workspaceId("testString") + .input(messageInputModel) + .intents( + new java.util.ArrayList(java.util.Arrays.asList(runtimeIntentModel))) + .entities( + new java.util.ArrayList(java.util.Arrays.asList(runtimeEntityModel))) + .alternateIntents(true) + .context(contextModel) + .output(outputDataModel) + .nodesVisitedDetails(true) .build(); - // execute first request - MessageResponse serviceResponse = service.message(options).execute().getResult(); + // Invoke operation with valid options model (positive test) + Response response = assistantService.message(messageOptionsModel).execute(); + assertNotNull(response); + MessageResponse responseObj = response.getResult(); + assertNotNull(responseObj); - // first request + // Verify the contents of the request RecordedRequest request = server.takeRequest(); - - String path = StringUtils.join(PATH_MESSAGE, "?", VERSION, "=", VERSION_DATE); - assertEquals(path, request.getPath()); - assertArrayEquals( - new String[] {"Great choice! Playing some jazz for you."}, - serviceResponse.getOutput().getText().toArray(new String[0])); + assertNotNull(request); assertEquals(request.getMethod(), "POST"); - assertNotNull(serviceResponse.getActions()); - assertNotNull(serviceResponse.getActions().get(0).name()); - assertNotNull(serviceResponse.getActions().get(0).credentials()); - assertNotNull(serviceResponse.getActions().get(0).type()); - assertNotNull(serviceResponse.getActions().get(0).parameters()); - assertNotNull(serviceResponse.getActions().get(0).resultVariable()); - assertNotNull(serviceResponse.getOutput().getLogMessages()); - assertNotNull(serviceResponse.getOutput().getNodesVisited()); - assertNotNull(serviceResponse.getOutput().getNodesVisitedDetails()); - assertNotNull(serviceResponse.getOutput().getNodesVisitedDetails().get(0).dialogNode()); - assertNotNull(serviceResponse.getOutput().getNodesVisitedDetails().get(0).title()); - assertNotNull(serviceResponse.getOutput().getNodesVisitedDetails().get(0).conditions()); - assertNotNull(serviceResponse.getOutput().getNodesVisitedDetails().get(0).conditions()); - } - - /** - * Negative - Test message with null workspace id. - * - * @throws InterruptedException the interrupted exception - */ - @Test(expected = IllegalArgumentException.class) - public void testSendMessageWithNullWorkspaceId() throws InterruptedException { - String text = "I'd like to get insurance to for my home"; - - MessageInput input = new MessageInput(); - input.setText(text); - MessageOptions options = - new MessageOptions.Builder().input(input).alternateIntents(true).build(); - - service.message(options).execute().getResult(); - } - - /** Test CreateWorkspace builder. */ + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("nodes_visited_details")), Boolean.valueOf(true)); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, messagePath); + } + + // Test the message operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testMessageNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + assistantService.message(null).execute(); + } + + @Test + public void testListWorkspacesWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"workspaces\": [{\"name\": \"name\", \"description\": \"description\", \"language\": \"language\", \"workspace_id\": \"workspaceId\", \"dialog_nodes\": [{\"dialog_node\": \"dialogNode\", \"description\": \"description\", \"conditions\": \"conditions\", \"parent\": \"parent\", \"previous_sibling\": \"previousSibling\", \"output\": {\"generic\": [{\"response_type\": \"search_skill\", \"query\": \"query\", \"query_type\": \"natural_language\", \"filter\": \"filter\", \"discovery_version\": \"discoveryVersion\"}], \"integrations\": {\"mapKey\": {\"mapKey\": \"anyValue\"}}, \"modifiers\": {\"overwrite\": false}}, \"context\": {\"integrations\": {\"mapKey\": {\"mapKey\": \"anyValue\"}}}, \"metadata\": {\"mapKey\": \"anyValue\"}, \"next_step\": {\"behavior\": \"get_user_input\", \"dialog_node\": \"dialogNode\", \"selector\": \"condition\"}, \"title\": \"title\", \"type\": \"standard\", \"event_name\": \"focus\", \"variable\": \"variable\", \"actions\": [{\"name\": \"name\", \"type\": \"client\", \"parameters\": {\"mapKey\": \"anyValue\"}, \"result_variable\": \"resultVariable\", \"credentials\": \"credentials\"}], \"digress_in\": \"not_available\", \"digress_out\": \"allow_returning\", \"digress_out_slots\": \"not_allowed\", \"user_label\": \"userLabel\", \"disambiguation_opt_out\": true, \"disabled\": true, \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}], \"counterexamples\": [{\"text\": \"text\", \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}], \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\", \"metadata\": {\"mapKey\": \"anyValue\"}, \"learning_opt_out\": true, \"system_settings\": {\"tooling\": {\"store_generic_responses\": false}, \"disambiguation\": {\"prompt\": \"prompt\", \"none_of_the_above_prompt\": \"noneOfTheAbovePrompt\", \"enabled\": false, \"sensitivity\": \"auto\", \"randomize\": false, \"max_suggestions\": 1, \"suggestion_text_policy\": \"suggestionTextPolicy\"}, \"human_agent_assist\": {\"mapKey\": \"anyValue\"}, \"spelling_suggestions\": false, \"spelling_auto_correct\": false, \"system_entities\": {\"enabled\": false}, \"off_topic\": {\"enabled\": false}}, \"status\": \"Non Existent\", \"webhooks\": [{\"url\": \"url\", \"name\": \"name\", \"headers\": [{\"name\": \"name\", \"value\": \"value\"}]}], \"intents\": [{\"intent\": \"intent\", \"description\": \"description\", \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\", \"examples\": [{\"text\": \"text\", \"mentions\": [{\"entity\": \"entity\", \"location\": [8]}], \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}]}], \"entities\": [{\"entity\": \"entity\", \"description\": \"description\", \"metadata\": {\"mapKey\": \"anyValue\"}, \"fuzzy_match\": true, \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\", \"values\": [{\"value\": \"value\", \"metadata\": {\"mapKey\": \"anyValue\"}, \"type\": \"synonyms\", \"synonyms\": [\"synonym\"], \"patterns\": [\"pattern\"], \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}]}]}], \"pagination\": {\"refresh_url\": \"refreshUrl\", \"next_url\": \"nextUrl\", \"total\": 5, \"matched\": 7, \"refresh_cursor\": \"refreshCursor\", \"next_cursor\": \"nextCursor\"}}"; + String listWorkspacesPath = "/v1/workspaces"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the ListWorkspacesOptions model + ListWorkspacesOptions listWorkspacesOptionsModel = + new ListWorkspacesOptions.Builder() + .pageLimit(Long.valueOf("26")) + .includeCount(true) + .sort("name") + .cursor("testString") + .includeAudit(true) + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + assistantService.listWorkspaces(listWorkspacesOptionsModel).execute(); + assertNotNull(response); + WorkspaceCollection responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(Long.valueOf(query.get("page_limit")), Long.valueOf("26")); + assertEquals(Boolean.valueOf(query.get("include_count")), Boolean.valueOf(true)); + assertEquals(query.get("sort"), "name"); + assertEquals(query.get("cursor"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(true)); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listWorkspacesPath); + } + @Test - public void testCreateWorkspaceBuilder() { + public void testCreateWorkspaceWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"name\": \"name\", \"description\": \"description\", \"language\": \"language\", \"workspace_id\": \"workspaceId\", \"dialog_nodes\": [{\"dialog_node\": \"dialogNode\", \"description\": \"description\", \"conditions\": \"conditions\", \"parent\": \"parent\", \"previous_sibling\": \"previousSibling\", \"output\": {\"generic\": [{\"response_type\": \"search_skill\", \"query\": \"query\", \"query_type\": \"natural_language\", \"filter\": \"filter\", \"discovery_version\": \"discoveryVersion\"}], \"integrations\": {\"mapKey\": {\"mapKey\": \"anyValue\"}}, \"modifiers\": {\"overwrite\": false}}, \"context\": {\"integrations\": {\"mapKey\": {\"mapKey\": \"anyValue\"}}}, \"metadata\": {\"mapKey\": \"anyValue\"}, \"next_step\": {\"behavior\": \"get_user_input\", \"dialog_node\": \"dialogNode\", \"selector\": \"condition\"}, \"title\": \"title\", \"type\": \"standard\", \"event_name\": \"focus\", \"variable\": \"variable\", \"actions\": [{\"name\": \"name\", \"type\": \"client\", \"parameters\": {\"mapKey\": \"anyValue\"}, \"result_variable\": \"resultVariable\", \"credentials\": \"credentials\"}], \"digress_in\": \"not_available\", \"digress_out\": \"allow_returning\", \"digress_out_slots\": \"not_allowed\", \"user_label\": \"userLabel\", \"disambiguation_opt_out\": true, \"disabled\": true, \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}], \"counterexamples\": [{\"text\": \"text\", \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}], \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\", \"metadata\": {\"mapKey\": \"anyValue\"}, \"learning_opt_out\": true, \"system_settings\": {\"tooling\": {\"store_generic_responses\": false}, \"disambiguation\": {\"prompt\": \"prompt\", \"none_of_the_above_prompt\": \"noneOfTheAbovePrompt\", \"enabled\": false, \"sensitivity\": \"auto\", \"randomize\": false, \"max_suggestions\": 1, \"suggestion_text_policy\": \"suggestionTextPolicy\"}, \"human_agent_assist\": {\"mapKey\": \"anyValue\"}, \"spelling_suggestions\": false, \"spelling_auto_correct\": false, \"system_entities\": {\"enabled\": false}, \"off_topic\": {\"enabled\": false}}, \"status\": \"Non Existent\", \"webhooks\": [{\"url\": \"url\", \"name\": \"name\", \"headers\": [{\"name\": \"name\", \"value\": \"value\"}]}], \"intents\": [{\"intent\": \"intent\", \"description\": \"description\", \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\", \"examples\": [{\"text\": \"text\", \"mentions\": [{\"entity\": \"entity\", \"location\": [8]}], \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}]}], \"entities\": [{\"entity\": \"entity\", \"description\": \"description\", \"metadata\": {\"mapKey\": \"anyValue\"}, \"fuzzy_match\": true, \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\", \"values\": [{\"value\": \"value\", \"metadata\": {\"mapKey\": \"anyValue\"}, \"type\": \"synonyms\", \"synonyms\": [\"synonym\"], \"patterns\": [\"pattern\"], \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}]}]}"; + String createWorkspacePath = "/v1/workspaces"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(201) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill + // model + DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill dialogNodeOutputGenericModel = + new DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill.Builder() + .responseType("search_skill") + .query("testString") + .queryType("natural_language") + .filter("testString") + .discoveryVersion("testString") + .build(); + + // Construct an instance of the DialogNodeOutputModifiers model + DialogNodeOutputModifiers dialogNodeOutputModifiersModel = + new DialogNodeOutputModifiers.Builder().overwrite(true).build(); + + // Construct an instance of the DialogNodeOutput model + DialogNodeOutput dialogNodeOutputModel = + new DialogNodeOutput.Builder() + .generic( + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeOutputGenericModel))) + .integrations( + new java.util.HashMap>() { + { + put( + "foo", + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + } + }) + .modifiers(dialogNodeOutputModifiersModel) + .add("foo", "testString") + .build(); - String workspaceName = "Builder Test"; - String workspaceDescription = "Description of " + workspaceName; - String workspaceLanguage = "en"; - String userLabel = "user_label"; + // Construct an instance of the DialogNodeContext model + DialogNodeContext dialogNodeContextModel = + new DialogNodeContext.Builder() + .integrations( + new java.util.HashMap>() { + { + put( + "foo", + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + } + }) + .add("foo", "testString") + .build(); - // intents - CreateIntent testIntent0 = new CreateIntent.Builder("testIntent0").build(); - CreateIntent testIntent1 = new CreateIntent.Builder("testIntent1").build(); + // Construct an instance of the DialogNodeNextStep model + DialogNodeNextStep dialogNodeNextStepModel = + new DialogNodeNextStep.Builder() + .behavior("get_user_input") + .dialogNode("testString") + .selector("condition") + .build(); - // entities - CreateEntity testEntity0 = new CreateEntity.Builder("testEntity0").build(); - CreateEntity testEntity1 = new CreateEntity.Builder("testEntity1").build(); + // Construct an instance of the DialogNodeAction model + DialogNodeAction dialogNodeActionModel = + new DialogNodeAction.Builder() + .name("testString") + .type("client") + .parameters( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .resultVariable("testString") + .credentials("testString") + .build(); - // counterexamples - Counterexample testCounterexample0 = new Counterexample.Builder("testCounterexample0").build(); - Counterexample testCounterexample1 = new Counterexample.Builder("testCounterexample1").build(); + // Construct an instance of the DialogNode model + DialogNode dialogNodeModel = + new DialogNode.Builder() + .dialogNode("testString") + .description("testString") + .conditions("testString") + .parent("testString") + .previousSibling("testString") + .output(dialogNodeOutputModel) + .context(dialogNodeContextModel) + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .nextStep(dialogNodeNextStepModel) + .title("testString") + .type("standard") + .eventName("focus") + .variable("testString") + .actions( + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeActionModel))) + .digressIn("not_available") + .digressOut("allow_returning") + .digressOutSlots("not_allowed") + .userLabel("testString") + .disambiguationOptOut(true) + .build(); - // dialognodes - DialogNode testDialogNode0 = new DialogNode.Builder("dialogNode0").userLabel(userLabel).build(); - DialogNode testDialogNode1 = new DialogNode.Builder("dialogNode1").build(); + // Construct an instance of the Counterexample model + Counterexample counterexampleModel = new Counterexample.Builder().text("testString").build(); - // metadata - Map workspaceMetadata = new HashMap(); - String metadataValue = "value for " + workspaceName; - workspaceMetadata.put("key", metadataValue); + // Construct an instance of the WorkspaceSystemSettingsTooling model + WorkspaceSystemSettingsTooling workspaceSystemSettingsToolingModel = + new WorkspaceSystemSettingsTooling.Builder().storeGenericResponses(true).build(); - // systemSettings - WorkspaceSystemSettingsDisambiguation disambiguation = + // Construct an instance of the WorkspaceSystemSettingsDisambiguation model + WorkspaceSystemSettingsDisambiguation workspaceSystemSettingsDisambiguationModel = new WorkspaceSystemSettingsDisambiguation.Builder() + .prompt("testString") + .noneOfTheAbovePrompt("testString") .enabled(true) - .noneOfTheAbovePrompt(NONE_OF_THE_ABOVE_PROMPT) - .prompt(PROMPT) - .sensitivity(WorkspaceSystemSettingsDisambiguation.Sensitivity.HIGH) + .sensitivity("auto") .randomize(true) - .maxSuggestions(MAX_SUGGESTIONS) - .suggestionTextPolicy(SUGGESTION_TEXT_POLICY) + .maxSuggestions(Long.valueOf("1")) + .suggestionTextPolicy("testString") .build(); - WorkspaceSystemSettingsTooling tooling = - new WorkspaceSystemSettingsTooling.Builder().storeGenericResponses(true).build(); - Map humanAgentAssist = new HashMap<>(); - humanAgentAssist.put("help", "ok"); - WorkspaceSystemSettingsOffTopic offTopic = + + // Construct an instance of the WorkspaceSystemSettingsSystemEntities model + WorkspaceSystemSettingsSystemEntities workspaceSystemSettingsSystemEntitiesModel = + new WorkspaceSystemSettingsSystemEntities.Builder().enabled(true).build(); + + // Construct an instance of the WorkspaceSystemSettingsOffTopic model + WorkspaceSystemSettingsOffTopic workspaceSystemSettingsOffTopicModel = new WorkspaceSystemSettingsOffTopic.Builder().enabled(true).build(); - WorkspaceSystemSettings systemSettings = + + // Construct an instance of the WorkspaceSystemSettings model + WorkspaceSystemSettings workspaceSystemSettingsModel = new WorkspaceSystemSettings.Builder() - .disambiguation(disambiguation) - .tooling(tooling) - .humanAgentAssist(humanAgentAssist) - .offTopic(offTopic) + .tooling(workspaceSystemSettingsToolingModel) + .disambiguation(workspaceSystemSettingsDisambiguationModel) + .humanAgentAssist( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .spellingSuggestions(true) + .spellingAutoCorrect(true) + .systemEntities(workspaceSystemSettingsSystemEntitiesModel) + .offTopic(workspaceSystemSettingsOffTopicModel) .build(); - WebhookHeader webhookHeader = - new WebhookHeader.Builder().name(WEBHOOK_HEADER_NAME).value(WEBHOOK_HEADER_VALUE).build(); - List webhookHeaderList = new ArrayList<>(); - webhookHeaderList.add(webhookHeader); - Webhook webhook = + // Construct an instance of the WebhookHeader model + WebhookHeader webhookHeaderModel = + new WebhookHeader.Builder().name("testString").value("testString").build(); + + // Construct an instance of the Webhook model + Webhook webhookModel = new Webhook.Builder() - .name(WEBHOOK_NAME) - .url(WEBHOOK_URL) - .headers(webhookHeaderList) - .addHeaders(webhookHeader) + .url("testString") + .name("testString") + .headers( + new java.util.ArrayList(java.util.Arrays.asList(webhookHeaderModel))) + .build(); + + // Construct an instance of the Mention model + Mention mentionModel = + new Mention.Builder() + .entity("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) + .build(); + + // Construct an instance of the Example model + Example exampleModel = + new Example.Builder() + .text("testString") + .mentions(new java.util.ArrayList(java.util.Arrays.asList(mentionModel))) + .build(); + + // Construct an instance of the CreateIntent model + CreateIntent createIntentModel = + new CreateIntent.Builder() + .intent("testString") + .description("testString") + .examples(new java.util.ArrayList(java.util.Arrays.asList(exampleModel))) + .build(); + + // Construct an instance of the CreateValue model + CreateValue createValueModel = + new CreateValue.Builder() + .value("testString") + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .type("synonyms") + .synonyms(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .patterns(new java.util.ArrayList(java.util.Arrays.asList("testString"))) .build(); - List webhookList = new ArrayList<>(); - webhookList.add(webhook); - CreateWorkspaceOptions createOptions = + // Construct an instance of the CreateEntity model + CreateEntity createEntityModel = + new CreateEntity.Builder() + .entity("testString") + .description("testString") + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .fuzzyMatch(true) + .values(new java.util.ArrayList(java.util.Arrays.asList(createValueModel))) + .build(); + + // Construct an instance of the CreateWorkspaceOptions model + CreateWorkspaceOptions createWorkspaceOptionsModel = new CreateWorkspaceOptions.Builder() - .name(workspaceName) - .description(workspaceDescription) - .language(workspaceLanguage) - .addIntent(testIntent0) - .addIntent(testIntent1) - .addEntity(testEntity0) - .addEntity(testEntity1) - .addCounterexample(testCounterexample0) - .addCounterexample(testCounterexample1) - .addDialogNode(testDialogNode0) - .addDialogNode(testDialogNode1) - .metadata(workspaceMetadata) - .systemSettings(systemSettings) - .webhooks(webhookList) - .addWebhooks(webhook) - .build(); - - assertEquals(createOptions.name(), workspaceName); - assertEquals(createOptions.description(), workspaceDescription); - assertEquals(createOptions.language(), workspaceLanguage); - assertNotNull(createOptions.intents()); - assertEquals(createOptions.intents().size(), 2); - assertEquals(createOptions.intents().get(0), testIntent0); - assertEquals(createOptions.intents().get(1), testIntent1); - assertNotNull(createOptions.entities()); - assertEquals(createOptions.entities().size(), 2); - assertEquals(createOptions.entities().get(0), testEntity0); - assertEquals(createOptions.entities().get(1), testEntity1); - assertNotNull(createOptions.counterexamples()); - assertEquals(createOptions.counterexamples().size(), 2); - assertEquals(createOptions.counterexamples().get(0), testCounterexample0); - assertEquals(createOptions.counterexamples().get(1), testCounterexample1); - assertNotNull(createOptions.dialogNodes()); - assertEquals(createOptions.dialogNodes().size(), 2); - assertEquals(createOptions.dialogNodes().get(0), testDialogNode0); - assertEquals(createOptions.dialogNodes().get(0).userLabel(), userLabel); - assertEquals(createOptions.dialogNodes().get(1), testDialogNode1); - assertNotNull(createOptions.systemSettings()); - assertEquals( - createOptions.systemSettings().disambiguation().noneOfTheAbovePrompt(), - disambiguation.noneOfTheAbovePrompt()); - assertEquals(createOptions.systemSettings().disambiguation().prompt(), disambiguation.prompt()); - assertEquals( - createOptions.systemSettings().disambiguation().sensitivity(), - disambiguation.sensitivity()); - assertEquals( - createOptions.systemSettings().disambiguation().enabled(), disambiguation.enabled()); - assertTrue(createOptions.systemSettings().disambiguation().randomize()); - assertEquals(MAX_SUGGESTIONS, createOptions.systemSettings().disambiguation().maxSuggestions()); - assertEquals( - SUGGESTION_TEXT_POLICY, - createOptions.systemSettings().disambiguation().suggestionTextPolicy()); - assertEquals( - createOptions.systemSettings().tooling().storeGenericResponses(), - tooling.storeGenericResponses()); - assertEquals(createOptions.systemSettings().humanAgentAssist(), humanAgentAssist); - assertTrue(createOptions.systemSettings().offTopic().enabled()); - - assertEquals(2, createOptions.webhooks().size()); - assertEquals(webhook, createOptions.webhooks().get(0)); - assertEquals(WEBHOOK_NAME, createOptions.webhooks().get(0).name()); - assertEquals(WEBHOOK_URL, createOptions.webhooks().get(0).url()); - assertEquals(2, createOptions.webhooks().get(0).headers().size()); - assertEquals(webhookHeader, createOptions.webhooks().get(0).headers().get(0)); - assertEquals(WEBHOOK_HEADER_NAME, createOptions.webhooks().get(0).headers().get(0).name()); - assertEquals(WEBHOOK_HEADER_VALUE, createOptions.webhooks().get(0).headers().get(0).value()); - - CreateWorkspaceOptions.Builder builder = createOptions.newBuilder(); - - CreateIntent testIntent2 = new CreateIntent.Builder("testIntent2").build(); - CreateEntity testEntity2 = new CreateEntity.Builder("testEntity2").build(); - Counterexample testCounterexample2 = new Counterexample.Builder("testCounterexample2").build(); - DialogNode testDialogNode2 = new DialogNode.Builder("dialogNode2").build(); - - builder.intents(Collections.singletonList(testIntent2)); - builder.entities(Collections.singletonList(testEntity2)); - builder.counterexamples(Collections.singletonList(testCounterexample2)); - builder.dialogNodes(Collections.singletonList(testDialogNode2)); - - CreateWorkspaceOptions options2 = builder.build(); - - assertNotNull(options2.intents()); - assertEquals(options2.intents().size(), 1); - assertEquals(options2.intents().get(0), testIntent2); - assertNotNull(options2.entities()); - assertEquals(options2.entities().size(), 1); - assertEquals(options2.entities().get(0), testEntity2); - assertNotNull(options2.counterexamples()); - assertEquals(options2.counterexamples().size(), 1); - assertEquals(options2.counterexamples().get(0), testCounterexample2); - assertNotNull(options2.dialogNodes()); - assertEquals(options2.dialogNodes().size(), 1); - assertEquals(options2.dialogNodes().get(0), testDialogNode2); - } - - /** Test UpdateWorkspaceOptions builder. */ + .name("testString") + .description("testString") + .language("testString") + .dialogNodes( + new java.util.ArrayList(java.util.Arrays.asList(dialogNodeModel))) + .counterexamples( + new java.util.ArrayList( + java.util.Arrays.asList(counterexampleModel))) + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .learningOptOut(true) + .systemSettings(workspaceSystemSettingsModel) + .webhooks(new java.util.ArrayList(java.util.Arrays.asList(webhookModel))) + .intents( + new java.util.ArrayList(java.util.Arrays.asList(createIntentModel))) + .entities( + new java.util.ArrayList(java.util.Arrays.asList(createEntityModel))) + .includeAudit(true) + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + assistantService.createWorkspace(createWorkspaceOptionsModel).execute(); + assertNotNull(response); + Workspace responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(true)); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createWorkspacePath); + } + + @Test + public void testGetWorkspaceWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"name\": \"name\", \"description\": \"description\", \"language\": \"language\", \"workspace_id\": \"workspaceId\", \"dialog_nodes\": [{\"dialog_node\": \"dialogNode\", \"description\": \"description\", \"conditions\": \"conditions\", \"parent\": \"parent\", \"previous_sibling\": \"previousSibling\", \"output\": {\"generic\": [{\"response_type\": \"search_skill\", \"query\": \"query\", \"query_type\": \"natural_language\", \"filter\": \"filter\", \"discovery_version\": \"discoveryVersion\"}], \"integrations\": {\"mapKey\": {\"mapKey\": \"anyValue\"}}, \"modifiers\": {\"overwrite\": false}}, \"context\": {\"integrations\": {\"mapKey\": {\"mapKey\": \"anyValue\"}}}, \"metadata\": {\"mapKey\": \"anyValue\"}, \"next_step\": {\"behavior\": \"get_user_input\", \"dialog_node\": \"dialogNode\", \"selector\": \"condition\"}, \"title\": \"title\", \"type\": \"standard\", \"event_name\": \"focus\", \"variable\": \"variable\", \"actions\": [{\"name\": \"name\", \"type\": \"client\", \"parameters\": {\"mapKey\": \"anyValue\"}, \"result_variable\": \"resultVariable\", \"credentials\": \"credentials\"}], \"digress_in\": \"not_available\", \"digress_out\": \"allow_returning\", \"digress_out_slots\": \"not_allowed\", \"user_label\": \"userLabel\", \"disambiguation_opt_out\": true, \"disabled\": true, \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}], \"counterexamples\": [{\"text\": \"text\", \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}], \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\", \"metadata\": {\"mapKey\": \"anyValue\"}, \"learning_opt_out\": true, \"system_settings\": {\"tooling\": {\"store_generic_responses\": false}, \"disambiguation\": {\"prompt\": \"prompt\", \"none_of_the_above_prompt\": \"noneOfTheAbovePrompt\", \"enabled\": false, \"sensitivity\": \"auto\", \"randomize\": false, \"max_suggestions\": 1, \"suggestion_text_policy\": \"suggestionTextPolicy\"}, \"human_agent_assist\": {\"mapKey\": \"anyValue\"}, \"spelling_suggestions\": false, \"spelling_auto_correct\": false, \"system_entities\": {\"enabled\": false}, \"off_topic\": {\"enabled\": false}}, \"status\": \"Non Existent\", \"webhooks\": [{\"url\": \"url\", \"name\": \"name\", \"headers\": [{\"name\": \"name\", \"value\": \"value\"}]}], \"intents\": [{\"intent\": \"intent\", \"description\": \"description\", \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\", \"examples\": [{\"text\": \"text\", \"mentions\": [{\"entity\": \"entity\", \"location\": [8]}], \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}]}], \"entities\": [{\"entity\": \"entity\", \"description\": \"description\", \"metadata\": {\"mapKey\": \"anyValue\"}, \"fuzzy_match\": true, \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\", \"values\": [{\"value\": \"value\", \"metadata\": {\"mapKey\": \"anyValue\"}, \"type\": \"synonyms\", \"synonyms\": [\"synonym\"], \"patterns\": [\"pattern\"], \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}]}]}"; + String getWorkspacePath = "/v1/workspaces/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the GetWorkspaceOptions model + GetWorkspaceOptions getWorkspaceOptionsModel = + new GetWorkspaceOptions.Builder() + .workspaceId("testString") + .export(true) + .includeAudit(true) + .sort("stable") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + assistantService.getWorkspace(getWorkspaceOptionsModel).execute(); + assertNotNull(response); + Workspace responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("export")), Boolean.valueOf(true)); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(true)); + assertEquals(query.get("sort"), "stable"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getWorkspacePath); + } + + // Test the getWorkspace operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetWorkspaceNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + assistantService.getWorkspace(null).execute(); + } + @Test - public void testUpdateWorkspaceOptionsBuilder() { + public void testUpdateWorkspaceWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"name\": \"name\", \"description\": \"description\", \"language\": \"language\", \"workspace_id\": \"workspaceId\", \"dialog_nodes\": [{\"dialog_node\": \"dialogNode\", \"description\": \"description\", \"conditions\": \"conditions\", \"parent\": \"parent\", \"previous_sibling\": \"previousSibling\", \"output\": {\"generic\": [{\"response_type\": \"search_skill\", \"query\": \"query\", \"query_type\": \"natural_language\", \"filter\": \"filter\", \"discovery_version\": \"discoveryVersion\"}], \"integrations\": {\"mapKey\": {\"mapKey\": \"anyValue\"}}, \"modifiers\": {\"overwrite\": false}}, \"context\": {\"integrations\": {\"mapKey\": {\"mapKey\": \"anyValue\"}}}, \"metadata\": {\"mapKey\": \"anyValue\"}, \"next_step\": {\"behavior\": \"get_user_input\", \"dialog_node\": \"dialogNode\", \"selector\": \"condition\"}, \"title\": \"title\", \"type\": \"standard\", \"event_name\": \"focus\", \"variable\": \"variable\", \"actions\": [{\"name\": \"name\", \"type\": \"client\", \"parameters\": {\"mapKey\": \"anyValue\"}, \"result_variable\": \"resultVariable\", \"credentials\": \"credentials\"}], \"digress_in\": \"not_available\", \"digress_out\": \"allow_returning\", \"digress_out_slots\": \"not_allowed\", \"user_label\": \"userLabel\", \"disambiguation_opt_out\": true, \"disabled\": true, \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}], \"counterexamples\": [{\"text\": \"text\", \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}], \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\", \"metadata\": {\"mapKey\": \"anyValue\"}, \"learning_opt_out\": true, \"system_settings\": {\"tooling\": {\"store_generic_responses\": false}, \"disambiguation\": {\"prompt\": \"prompt\", \"none_of_the_above_prompt\": \"noneOfTheAbovePrompt\", \"enabled\": false, \"sensitivity\": \"auto\", \"randomize\": false, \"max_suggestions\": 1, \"suggestion_text_policy\": \"suggestionTextPolicy\"}, \"human_agent_assist\": {\"mapKey\": \"anyValue\"}, \"spelling_suggestions\": false, \"spelling_auto_correct\": false, \"system_entities\": {\"enabled\": false}, \"off_topic\": {\"enabled\": false}}, \"status\": \"Non Existent\", \"webhooks\": [{\"url\": \"url\", \"name\": \"name\", \"headers\": [{\"name\": \"name\", \"value\": \"value\"}]}], \"intents\": [{\"intent\": \"intent\", \"description\": \"description\", \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\", \"examples\": [{\"text\": \"text\", \"mentions\": [{\"entity\": \"entity\", \"location\": [8]}], \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}]}], \"entities\": [{\"entity\": \"entity\", \"description\": \"description\", \"metadata\": {\"mapKey\": \"anyValue\"}, \"fuzzy_match\": true, \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\", \"values\": [{\"value\": \"value\", \"metadata\": {\"mapKey\": \"anyValue\"}, \"type\": \"synonyms\", \"synonyms\": [\"synonym\"], \"patterns\": [\"pattern\"], \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}]}]}"; + String updateWorkspacePath = "/v1/workspaces/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill + // model + DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill dialogNodeOutputGenericModel = + new DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill.Builder() + .responseType("search_skill") + .query("testString") + .queryType("natural_language") + .filter("testString") + .discoveryVersion("testString") + .build(); - String workspaceName = "Builder Test"; - String workspaceDescription = "Description of " + workspaceName; - String workspaceLanguage = "en"; + // Construct an instance of the DialogNodeOutputModifiers model + DialogNodeOutputModifiers dialogNodeOutputModifiersModel = + new DialogNodeOutputModifiers.Builder().overwrite(true).build(); + + // Construct an instance of the DialogNodeOutput model + DialogNodeOutput dialogNodeOutputModel = + new DialogNodeOutput.Builder() + .generic( + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeOutputGenericModel))) + .integrations( + new java.util.HashMap>() { + { + put( + "foo", + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + } + }) + .modifiers(dialogNodeOutputModifiersModel) + .add("foo", "testString") + .build(); + + // Construct an instance of the DialogNodeContext model + DialogNodeContext dialogNodeContextModel = + new DialogNodeContext.Builder() + .integrations( + new java.util.HashMap>() { + { + put( + "foo", + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + } + }) + .add("foo", "testString") + .build(); - // intents - CreateIntent testIntent = new CreateIntent.Builder("testIntent").build(); + // Construct an instance of the DialogNodeNextStep model + DialogNodeNextStep dialogNodeNextStepModel = + new DialogNodeNextStep.Builder() + .behavior("get_user_input") + .dialogNode("testString") + .selector("condition") + .build(); - // entities - CreateEntity testEntity = new CreateEntity.Builder("testEntity").build(); + // Construct an instance of the DialogNodeAction model + DialogNodeAction dialogNodeActionModel = + new DialogNodeAction.Builder() + .name("testString") + .type("client") + .parameters( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .resultVariable("testString") + .credentials("testString") + .build(); - // counterexamples - Counterexample testCounterexample = new Counterexample.Builder("testCounterexample").build(); + // Construct an instance of the DialogNode model + DialogNode dialogNodeModel = + new DialogNode.Builder() + .dialogNode("testString") + .description("testString") + .conditions("testString") + .parent("testString") + .previousSibling("testString") + .output(dialogNodeOutputModel) + .context(dialogNodeContextModel) + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .nextStep(dialogNodeNextStepModel) + .title("testString") + .type("standard") + .eventName("focus") + .variable("testString") + .actions( + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeActionModel))) + .digressIn("not_available") + .digressOut("allow_returning") + .digressOutSlots("not_allowed") + .userLabel("testString") + .disambiguationOptOut(true) + .build(); - // dialognodes - DialogNode testDialogNode = new DialogNode.Builder("dialogNode").build(); + // Construct an instance of the Counterexample model + Counterexample counterexampleModel = new Counterexample.Builder().text("testString").build(); - // metadata - Map workspaceMetadata = new HashMap(); - String metadataValue = "value for " + workspaceName; - workspaceMetadata.put("key", metadataValue); + // Construct an instance of the WorkspaceSystemSettingsTooling model + WorkspaceSystemSettingsTooling workspaceSystemSettingsToolingModel = + new WorkspaceSystemSettingsTooling.Builder().storeGenericResponses(true).build(); - // systemSettings - WorkspaceSystemSettingsDisambiguation disambiguation = + // Construct an instance of the WorkspaceSystemSettingsDisambiguation model + WorkspaceSystemSettingsDisambiguation workspaceSystemSettingsDisambiguationModel = new WorkspaceSystemSettingsDisambiguation.Builder() + .prompt("testString") + .noneOfTheAbovePrompt("testString") .enabled(true) - .noneOfTheAbovePrompt(NONE_OF_THE_ABOVE_PROMPT) - .prompt(PROMPT) - .sensitivity(WorkspaceSystemSettingsDisambiguation.Sensitivity.HIGH) + .sensitivity("auto") .randomize(true) - .maxSuggestions(MAX_SUGGESTIONS) + .maxSuggestions(Long.valueOf("1")) + .suggestionTextPolicy("testString") .build(); - WorkspaceSystemSettingsTooling tooling = - new WorkspaceSystemSettingsTooling.Builder().storeGenericResponses(true).build(); - Map humanAgentAssist = new HashMap<>(); - humanAgentAssist.put("help", "ok"); - WorkspaceSystemSettings systemSettings = + + // Construct an instance of the WorkspaceSystemSettingsSystemEntities model + WorkspaceSystemSettingsSystemEntities workspaceSystemSettingsSystemEntitiesModel = + new WorkspaceSystemSettingsSystemEntities.Builder().enabled(true).build(); + + // Construct an instance of the WorkspaceSystemSettingsOffTopic model + WorkspaceSystemSettingsOffTopic workspaceSystemSettingsOffTopicModel = + new WorkspaceSystemSettingsOffTopic.Builder().enabled(true).build(); + + // Construct an instance of the WorkspaceSystemSettings model + WorkspaceSystemSettings workspaceSystemSettingsModel = new WorkspaceSystemSettings.Builder() - .disambiguation(disambiguation) - .tooling(tooling) - .humanAgentAssist(humanAgentAssist) + .tooling(workspaceSystemSettingsToolingModel) + .disambiguation(workspaceSystemSettingsDisambiguationModel) + .humanAgentAssist( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .spellingSuggestions(true) + .spellingAutoCorrect(true) + .systemEntities(workspaceSystemSettingsSystemEntitiesModel) + .offTopic(workspaceSystemSettingsOffTopicModel) .build(); - WebhookHeader webhookHeader = - new WebhookHeader.Builder().name(WEBHOOK_HEADER_NAME).value(WEBHOOK_HEADER_VALUE).build(); - List webhookHeaderList = new ArrayList<>(); - webhookHeaderList.add(webhookHeader); - Webhook webhook = + // Construct an instance of the WebhookHeader model + WebhookHeader webhookHeaderModel = + new WebhookHeader.Builder().name("testString").value("testString").build(); + + // Construct an instance of the Webhook model + Webhook webhookModel = new Webhook.Builder() - .name(WEBHOOK_NAME) - .url(WEBHOOK_URL) - .headers(webhookHeaderList) - .addHeaders(webhookHeader) - .build(); - List webhookList = new ArrayList<>(); - webhookList.add(webhook); - - UpdateWorkspaceOptions.Builder builder = new UpdateWorkspaceOptions.Builder(WORKSPACE_ID); - builder.name(workspaceName); - builder.description(workspaceDescription); - builder.language(workspaceLanguage); - builder.addIntent(testIntent); - builder.addEntity(testEntity); - builder.addCounterexample(testCounterexample); - builder.addDialogNode(testDialogNode); - builder.metadata(workspaceMetadata); - builder.systemSettings(systemSettings); - builder.webhooks(webhookList); - builder.addWebhooks(webhook); - - UpdateWorkspaceOptions options = builder.build(); - - assertEquals(options.name(), workspaceName); - assertEquals(options.description(), workspaceDescription); - assertEquals(options.language(), workspaceLanguage); - assertNotNull(options.intents()); - assertEquals(options.intents().size(), 1); - assertEquals(options.intents().get(0), testIntent); - assertNotNull(options.entities()); - assertEquals(options.entities().size(), 1); - assertEquals(options.entities().get(0), testEntity); - assertNotNull(options.counterexamples()); - assertEquals(options.counterexamples().size(), 1); - assertEquals(options.counterexamples().get(0), testCounterexample); - assertNotNull(options.dialogNodes()); - assertEquals(options.dialogNodes().size(), 1); - assertEquals(options.dialogNodes().get(0), testDialogNode); - assertNotNull(options.metadata()); - assertEquals(options.metadata(), workspaceMetadata); - assertNotNull(options.systemSettings()); - assertEquals( - options.systemSettings().disambiguation().noneOfTheAbovePrompt(), - disambiguation.noneOfTheAbovePrompt()); - assertEquals( - options.systemSettings().disambiguation().sensitivity(), disambiguation.sensitivity()); - assertEquals(options.systemSettings().disambiguation().prompt(), disambiguation.prompt()); - assertEquals(options.systemSettings().disambiguation().enabled(), disambiguation.enabled()); - assertTrue(options.systemSettings().disambiguation().randomize()); - assertEquals(MAX_SUGGESTIONS, options.systemSettings().disambiguation().maxSuggestions()); - assertEquals( - options.systemSettings().tooling().storeGenericResponses(), - tooling.storeGenericResponses()); - assertEquals(options.systemSettings().humanAgentAssist(), humanAgentAssist); - assertEquals(2, options.webhooks().size()); - assertEquals(webhook, options.webhooks().get(0)); - assertEquals(WEBHOOK_NAME, options.webhooks().get(0).name()); - assertEquals(WEBHOOK_URL, options.webhooks().get(0).url()); - assertEquals(2, options.webhooks().get(0).headers().size()); - assertEquals(webhookHeader, options.webhooks().get(0).headers().get(0)); - assertEquals(WEBHOOK_HEADER_NAME, options.webhooks().get(0).headers().get(0).name()); - assertEquals(WEBHOOK_HEADER_VALUE, options.webhooks().get(0).headers().get(0).value()); - - UpdateWorkspaceOptions.Builder builder2 = options.newBuilder(); - - CreateIntent testIntent2 = new CreateIntent.Builder("testIntent2").build(); - CreateEntity testEntity2 = new CreateEntity.Builder("testEntity2").build(); - Counterexample testCounterexample2 = new Counterexample.Builder("testCounterexample2").build(); - DialogNode testDialogNode2 = new DialogNode.Builder("dialogNode2").build(); - - builder2.intents(new ArrayList()); - builder2.addIntent(testIntent2); - builder2.entities(new ArrayList()); - builder2.addEntity(testEntity2); - builder2.counterexamples(new ArrayList()); - builder2.addCounterexample(testCounterexample2); - builder2.dialogNodes(new ArrayList()); - builder2.addDialogNode(testDialogNode2); - - UpdateWorkspaceOptions options2 = builder2.build(); - - assertNotNull(options2.intents()); - assertEquals(options2.intents().size(), 1); - assertEquals(options2.intents().get(0), testIntent2); - assertNotNull(options2.entities()); - assertEquals(options2.entities().size(), 1); - assertEquals(options2.entities().get(0), testEntity2); - assertNotNull(options2.counterexamples()); - assertEquals(options2.counterexamples().size(), 1); - assertEquals(options2.counterexamples().get(0), testCounterexample2); - assertNotNull(options2.dialogNodes()); - assertEquals(options2.dialogNodes().size(), 1); - assertEquals(options2.dialogNodes().get(0), testDialogNode2); - } - - /** Test get workspace options builder. */ - @Test - public void testGetWorkspaceOptionsBuilder() { - String workspaceId = "workspace_id"; - String sort = GetWorkspaceOptions.Sort.STABLE; + .url("testString") + .name("testString") + .headers( + new java.util.ArrayList(java.util.Arrays.asList(webhookHeaderModel))) + .build(); - GetWorkspaceOptions getWorkspaceOptions = - new GetWorkspaceOptions.Builder() - .workspaceId(workspaceId) - .export(true) + // Construct an instance of the Mention model + Mention mentionModel = + new Mention.Builder() + .entity("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) + .build(); + + // Construct an instance of the Example model + Example exampleModel = + new Example.Builder() + .text("testString") + .mentions(new java.util.ArrayList(java.util.Arrays.asList(mentionModel))) + .build(); + + // Construct an instance of the CreateIntent model + CreateIntent createIntentModel = + new CreateIntent.Builder() + .intent("testString") + .description("testString") + .examples(new java.util.ArrayList(java.util.Arrays.asList(exampleModel))) + .build(); + + // Construct an instance of the CreateValue model + CreateValue createValueModel = + new CreateValue.Builder() + .value("testString") + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .type("synonyms") + .synonyms(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .patterns(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + + // Construct an instance of the CreateEntity model + CreateEntity createEntityModel = + new CreateEntity.Builder() + .entity("testString") + .description("testString") + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .fuzzyMatch(true) + .values(new java.util.ArrayList(java.util.Arrays.asList(createValueModel))) + .build(); + + // Construct an instance of the UpdateWorkspaceOptions model + UpdateWorkspaceOptions updateWorkspaceOptionsModel = + new UpdateWorkspaceOptions.Builder() + .workspaceId("testString") + .name("testString") + .description("testString") + .language("testString") + .dialogNodes( + new java.util.ArrayList(java.util.Arrays.asList(dialogNodeModel))) + .counterexamples( + new java.util.ArrayList( + java.util.Arrays.asList(counterexampleModel))) + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .learningOptOut(true) + .systemSettings(workspaceSystemSettingsModel) + .webhooks(new java.util.ArrayList(java.util.Arrays.asList(webhookModel))) + .intents( + new java.util.ArrayList(java.util.Arrays.asList(createIntentModel))) + .entities( + new java.util.ArrayList(java.util.Arrays.asList(createEntityModel))) + .append(true) .includeAudit(true) - .sort(sort) .build(); - getWorkspaceOptions = getWorkspaceOptions.newBuilder().build(); - assertEquals(workspaceId, getWorkspaceOptions.workspaceId()); - assertTrue(getWorkspaceOptions.export()); - assertTrue(getWorkspaceOptions.includeAudit()); - assertEquals(sort, getWorkspaceOptions.sort()); + // Invoke operation with valid options model (positive test) + Response response = + assistantService.updateWorkspace(updateWorkspaceOptionsModel).execute(); + assertNotNull(response); + Workspace responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("append")), Boolean.valueOf(true)); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(true)); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateWorkspacePath); + } + + // Test the updateWorkspace operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateWorkspaceNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + assistantService.updateWorkspace(null).execute(); } - /** Test create example options builder. */ @Test - public void testCreateExampleOptionsBuilder() { - Mention mentions1 = new Mention.Builder().entity(ENTITY).location(LOCATION).build(); - List mentionsList = new ArrayList<>(); - mentionsList.add(mentions1); - Mention mentions2 = new Mention.Builder().entity(ENTITY).location(LOCATION).build(); + public void testDeleteWorkspaceWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String deleteWorkspacePath = "/v1/workspaces/testString"; - CreateExampleOptions createExampleOptions = - new CreateExampleOptions.Builder() - .workspaceId(WORKSPACE_ID) - .mentions(mentionsList) - .addMentions(mentions2) - .text(TEXT) - .intent(INTENT) - .build(); + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the DeleteWorkspaceOptions model + DeleteWorkspaceOptions deleteWorkspaceOptionsModel = + new DeleteWorkspaceOptions.Builder().workspaceId("testString").build(); - mentionsList.add(mentions2); + // Invoke operation with valid options model (positive test) + Response response = + assistantService.deleteWorkspace(deleteWorkspaceOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); - assertEquals(createExampleOptions.workspaceId(), WORKSPACE_ID); - assertEquals(createExampleOptions.mentions(), mentionsList); - assertEquals(createExampleOptions.text(), TEXT); - assertEquals(createExampleOptions.intent(), INTENT); + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteWorkspacePath); } - /** Test update example options builder. */ - @Test - public void testUpdateExampleOptionsBuilder() { - Mention mentions1 = new Mention.Builder().entity(ENTITY).location(LOCATION).build(); - List mentionsList = new ArrayList<>(); - mentionsList.add(mentions1); - Mention mentions2 = new Mention.Builder().entity(ENTITY).location(LOCATION).build(); + // Test the deleteWorkspace operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteWorkspaceNoOptions() throws Throwable { + // construct the service + constructClientService(); - UpdateExampleOptions updateExampleOptions = - new UpdateExampleOptions.Builder() - .workspaceId(WORKSPACE_ID) - .intent(INTENT) - .text(TEXT) - .newMentions(mentionsList) - .newText(TEXT) + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + assistantService.deleteWorkspace(null).execute(); + } + + @Test + public void testListIntentsWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"intents\": [{\"intent\": \"intent\", \"description\": \"description\", \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\", \"examples\": [{\"text\": \"text\", \"mentions\": [{\"entity\": \"entity\", \"location\": [8]}], \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}]}], \"pagination\": {\"refresh_url\": \"refreshUrl\", \"next_url\": \"nextUrl\", \"total\": 5, \"matched\": 7, \"refresh_cursor\": \"refreshCursor\", \"next_cursor\": \"nextCursor\"}}"; + String listIntentsPath = "/v1/workspaces/testString/intents"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the ListIntentsOptions model + ListIntentsOptions listIntentsOptionsModel = + new ListIntentsOptions.Builder() + .workspaceId("testString") + .export(true) + .pageLimit(Long.valueOf("26")) + .includeCount(true) + .sort("intent") + .cursor("testString") + .includeAudit(true) .build(); - mentionsList.add(mentions2); + // Invoke operation with valid options model (positive test) + Response response = + assistantService.listIntents(listIntentsOptionsModel).execute(); + assertNotNull(response); + IntentCollection responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("export")), Boolean.valueOf(true)); + assertEquals(Long.valueOf(query.get("page_limit")), Long.valueOf("26")); + assertEquals(Boolean.valueOf(query.get("include_count")), Boolean.valueOf(true)); + assertEquals(query.get("sort"), "intent"); + assertEquals(query.get("cursor"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(true)); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listIntentsPath); + } + + // Test the listIntents operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListIntentsNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); - assertEquals(updateExampleOptions.workspaceId(), WORKSPACE_ID); - assertEquals(updateExampleOptions.newMentions(), mentionsList); - assertEquals(updateExampleOptions.newText(), TEXT); - assertEquals(updateExampleOptions.intent(), INTENT); - assertEquals(updateExampleOptions.text(), TEXT); + // Invoke operation with null options model (negative test) + assistantService.listIntents(null).execute(); } - /** Test CreateIntentOptions builder. */ @Test - public void testCreateIntentOptionsBuilder() { - String intent = "anIntent"; - Example intentExample0 = new Example.Builder().text("intentExample0").build(); - Example intentExample1 = new Example.Builder().text("intentExample1").build(); + public void testCreateIntentWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"intent\": \"intent\", \"description\": \"description\", \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\", \"examples\": [{\"text\": \"text\", \"mentions\": [{\"entity\": \"entity\", \"location\": [8]}], \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}]}"; + String createIntentPath = "/v1/workspaces/testString/intents"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(201) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the Mention model + Mention mentionModel = + new Mention.Builder() + .entity("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) + .build(); + + // Construct an instance of the Example model + Example exampleModel = + new Example.Builder() + .text("testString") + .mentions(new java.util.ArrayList(java.util.Arrays.asList(mentionModel))) + .build(); - CreateIntentOptions createOptions = + // Construct an instance of the CreateIntentOptions model + CreateIntentOptions createIntentOptionsModel = new CreateIntentOptions.Builder() - .workspaceId(WORKSPACE_ID) - .intent(intent) - .addExample(intentExample0) - .addExample(intentExample1) + .workspaceId("testString") + .intent("testString") + .description("testString") + .examples(new java.util.ArrayList(java.util.Arrays.asList(exampleModel))) + .includeAudit(true) .build(); - assertEquals(createOptions.workspaceId(), WORKSPACE_ID); - assertEquals(createOptions.intent(), intent); - assertEquals(createOptions.examples().size(), 2); - assertEquals(createOptions.examples().get(0), intentExample0); - assertEquals(createOptions.examples().get(1), intentExample1); + // Invoke operation with valid options model (positive test) + Response response = assistantService.createIntent(createIntentOptionsModel).execute(); + assertNotNull(response); + Intent responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); - CreateIntentOptions.Builder builder = createOptions.newBuilder(); + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(true)); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createIntentPath); + } - Example intentExample2 = new Example.Builder().text("intentExample2").build(); - builder.examples(Collections.singletonList(intentExample2)); + // Test the createIntent operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateIntentNoOptions() throws Throwable { + // construct the service + constructClientService(); - CreateIntentOptions options2 = builder.build(); + server.enqueue(new MockResponse()); - assertEquals(options2.workspaceId(), WORKSPACE_ID); - assertEquals(options2.intent(), intent); - assertEquals(options2.examples().size(), 1); - assertEquals(options2.examples().get(0), intentExample2); + // Invoke operation with null options model (negative test) + assistantService.createIntent(null).execute(); } - /** Test UpdateIntentOptions builder. */ @Test - public void testUpdateIntentOptionsBuilder() { - String intent = "anIntent"; - String newIntent = "renamedIntent"; - Example intentExample0 = new Example.Builder().text("intentExample0").build(); - Example intentExample1 = new Example.Builder().text("intentExample1").build(); - - UpdateIntentOptions updateOptions = - new UpdateIntentOptions.Builder() - .workspaceId(WORKSPACE_ID) - .intent(intent) - .newIntent(newIntent) - .addExample(intentExample0) - .addExample(intentExample1) + public void testGetIntentWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"intent\": \"intent\", \"description\": \"description\", \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\", \"examples\": [{\"text\": \"text\", \"mentions\": [{\"entity\": \"entity\", \"location\": [8]}], \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}]}"; + String getIntentPath = "/v1/workspaces/testString/intents/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the GetIntentOptions model + GetIntentOptions getIntentOptionsModel = + new GetIntentOptions.Builder() + .workspaceId("testString") + .intent("testString") + .export(true) + .includeAudit(true) .build(); - assertEquals(updateOptions.workspaceId(), WORKSPACE_ID); - assertEquals(updateOptions.intent(), intent); - assertEquals(updateOptions.newIntent(), newIntent); - assertEquals(updateOptions.newExamples().size(), 2); - assertEquals(updateOptions.newExamples().get(0), intentExample0); - assertEquals(updateOptions.newExamples().get(1), intentExample1); + // Invoke operation with valid options model (positive test) + Response response = assistantService.getIntent(getIntentOptionsModel).execute(); + assertNotNull(response); + Intent responseObj = response.getResult(); + assertNotNull(responseObj); - UpdateIntentOptions.Builder builder = updateOptions.newBuilder(); + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("export")), Boolean.valueOf(true)); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(true)); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getIntentPath); + } - Example intentExample2 = new Example.Builder().text("intentExample2").build(); - builder.newExamples(Collections.singletonList(intentExample2)); + // Test the getIntent operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetIntentNoOptions() throws Throwable { + // construct the service + constructClientService(); - UpdateIntentOptions options2 = builder.build(); + server.enqueue(new MockResponse()); - assertEquals(options2.workspaceId(), WORKSPACE_ID); - assertEquals(options2.intent(), intent); - assertEquals(options2.newIntent(), newIntent); - assertEquals(options2.newExamples().size(), 1); - assertEquals(options2.newExamples().get(0), intentExample2); + // Invoke operation with null options model (negative test) + assistantService.getIntent(null).execute(); } - /** Test CreateEntityOptions builder. */ @Test - public void testCreateEntityOptionsBuilder() { - String entity = "anEntity"; - CreateValue entityValue0 = - new CreateValue.Builder().value("entityValue0").addPattern("pattern0").build(); - CreateValue entityValue1 = - new CreateValue.Builder().value("entityValue1").addPattern("pattern1").build(); - - CreateEntityOptions createOptions = - new CreateEntityOptions.Builder() - .workspaceId(WORKSPACE_ID) - .entity(entity) - .addValues(entityValue0) - .addValues(entityValue1) + public void testUpdateIntentWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"intent\": \"intent\", \"description\": \"description\", \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\", \"examples\": [{\"text\": \"text\", \"mentions\": [{\"entity\": \"entity\", \"location\": [8]}], \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}]}"; + String updateIntentPath = "/v1/workspaces/testString/intents/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the Mention model + Mention mentionModel = + new Mention.Builder() + .entity("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) + .build(); + + // Construct an instance of the Example model + Example exampleModel = + new Example.Builder() + .text("testString") + .mentions(new java.util.ArrayList(java.util.Arrays.asList(mentionModel))) + .build(); + + // Construct an instance of the UpdateIntentOptions model + UpdateIntentOptions updateIntentOptionsModel = + new UpdateIntentOptions.Builder() + .workspaceId("testString") + .intent("testString") + .newIntent("testString") + .newDescription("testString") + .newExamples(new java.util.ArrayList(java.util.Arrays.asList(exampleModel))) + .append(true) + .includeAudit(true) .build(); - assertEquals(createOptions.workspaceId(), WORKSPACE_ID); - assertEquals(createOptions.entity(), entity); - assertEquals(createOptions.values().size(), 2); - assertEquals(createOptions.values().get(0), entityValue0); - assertEquals(createOptions.values().get(1), entityValue1); + // Invoke operation with valid options model (positive test) + Response response = assistantService.updateIntent(updateIntentOptionsModel).execute(); + assertNotNull(response); + Intent responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); - CreateEntityOptions.Builder builder = createOptions.newBuilder(); + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("append")), Boolean.valueOf(true)); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(true)); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateIntentPath); + } - CreateValue entityValue2 = - new CreateValue.Builder().value("entityValue2").addPattern("pattern2").build(); - builder.values(Collections.singletonList(entityValue2)); + // Test the updateIntent operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateIntentNoOptions() throws Throwable { + // construct the service + constructClientService(); - CreateEntityOptions options2 = builder.build(); + server.enqueue(new MockResponse()); - assertEquals(options2.workspaceId(), WORKSPACE_ID); - assertEquals(options2.entity(), entity); - assertEquals(options2.values().size(), 1); - assertEquals(options2.values().get(0), entityValue2); + // Invoke operation with null options model (negative test) + assistantService.updateIntent(null).execute(); } - /** Test UpdateEntityOptions builder. */ @Test - public void testUpdateEntityOptionsBuilder() { - String entity = "anEntity"; - String newEntity = "renamedEntity"; - CreateValue entityValue0 = - new CreateValue.Builder().value("entityValue0").addPattern("pattern0").build(); - CreateValue entityValue1 = - new CreateValue.Builder().value("entityValue1").addPattern("pattern1").build(); - - UpdateEntityOptions updateOptions = - new UpdateEntityOptions.Builder() - .workspaceId(WORKSPACE_ID) - .entity(entity) - .newEntity(newEntity) - .addValue(entityValue0) - .addValue(entityValue1) - .build(); + public void testDeleteIntentWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String deleteIntentPath = "/v1/workspaces/testString/intents/testString"; - assertEquals(updateOptions.workspaceId(), WORKSPACE_ID); - assertEquals(updateOptions.entity(), entity); - assertEquals(updateOptions.newEntity(), newEntity); - assertEquals(updateOptions.newValues().size(), 2); - assertEquals(updateOptions.newValues().get(0), entityValue0); - assertEquals(updateOptions.newValues().get(1), entityValue1); + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); - UpdateEntityOptions.Builder builder = updateOptions.newBuilder(); + constructClientService(); - CreateValue entityValue2 = - new CreateValue.Builder().value("entityValue2").addPattern("pattern2").build(); - builder.newValues(Collections.singletonList(entityValue2)); + // Construct an instance of the DeleteIntentOptions model + DeleteIntentOptions deleteIntentOptionsModel = + new DeleteIntentOptions.Builder().workspaceId("testString").intent("testString").build(); - UpdateEntityOptions options2 = builder.build(); + // Invoke operation with valid options model (positive test) + Response response = assistantService.deleteIntent(deleteIntentOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); - assertEquals(options2.workspaceId(), WORKSPACE_ID); - assertEquals(options2.entity(), entity); - assertEquals(options2.newEntity(), newEntity); - assertEquals(options2.newValues().size(), 1); - assertEquals(options2.newValues().get(0), entityValue2); + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteIntentPath); + } + + // Test the deleteIntent operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteIntentNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + assistantService.deleteIntent(null).execute(); } - /** Test CreateValueOptions builder. */ - @Test - public void testCreateValueOptionsBuilder() { - String entity = "anEntity"; - String value = "aValue"; - String valueSynonym0 = "valueSynonym0"; - String valueSynonym1 = "valueSynonym1"; - String valuePattern0 = "valuePattern0"; - String valuePattern1 = "valuePattern1"; - String valueType = "patterns"; - - CreateValueOptions createOptions = - new CreateValueOptions.Builder() - .workspaceId(WORKSPACE_ID) - .entity(entity) - .value(value) - .addSynonym(valueSynonym0) - .addSynonym(valueSynonym1) - .addPattern(valuePattern0) - .addPattern(valuePattern1) - .type(valueType) - .build(); - - assertEquals(createOptions.workspaceId(), WORKSPACE_ID); - assertEquals(createOptions.entity(), entity); - assertEquals(createOptions.value(), value); - assertEquals(createOptions.synonyms().size(), 2); - assertEquals(createOptions.synonyms().get(0), valueSynonym0); - assertEquals(createOptions.synonyms().get(1), valueSynonym1); - assertEquals(createOptions.patterns().size(), 2); - assertEquals(createOptions.patterns().get(0), valuePattern0); - assertEquals(createOptions.patterns().get(1), valuePattern1); - assertEquals(createOptions.type(), valueType); - - CreateValueOptions.Builder builder = createOptions.newBuilder(); - - String valueSynonym2 = "valueSynonym2"; - String valuePattern2 = "valuePattern2"; - builder.synonyms(Collections.singletonList(valueSynonym2)); - builder.patterns(Collections.singletonList(valuePattern2)); - - CreateValueOptions options2 = builder.build(); - - assertEquals(options2.workspaceId(), WORKSPACE_ID); - assertEquals(options2.entity(), entity); - assertEquals(options2.value(), value); - assertEquals(options2.synonyms().size(), 1); - assertEquals(options2.synonyms().get(0), valueSynonym2); - assertEquals(options2.patterns().size(), 1); - assertEquals(options2.patterns().get(0), valuePattern2); - } - - /** Test UpdateValueOptions builder. */ @Test - public void testUpdateValueOptionsBuilder() { - String entity = "anEntity"; - String value = "aValue"; - String newValue = "renamedValue"; - String valueSynonym0 = "valueSynonym0"; - String valueSynonym1 = "valueSynonym1"; - - UpdateValueOptions updateOptions = - new UpdateValueOptions.Builder() - .workspaceId(WORKSPACE_ID) - .entity(entity) - .value(value) - .newValue(newValue) - .addSynonym(valueSynonym0) - .addSynonym(valueSynonym1) + public void testListExamplesWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"examples\": [{\"text\": \"text\", \"mentions\": [{\"entity\": \"entity\", \"location\": [8]}], \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}], \"pagination\": {\"refresh_url\": \"refreshUrl\", \"next_url\": \"nextUrl\", \"total\": 5, \"matched\": 7, \"refresh_cursor\": \"refreshCursor\", \"next_cursor\": \"nextCursor\"}}"; + String listExamplesPath = "/v1/workspaces/testString/intents/testString/examples"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the ListExamplesOptions model + ListExamplesOptions listExamplesOptionsModel = + new ListExamplesOptions.Builder() + .workspaceId("testString") + .intent("testString") + .pageLimit(Long.valueOf("26")) + .includeCount(true) + .sort("text") + .cursor("testString") + .includeAudit(true) .build(); - assertEquals(updateOptions.workspaceId(), WORKSPACE_ID); - assertEquals(updateOptions.entity(), entity); - assertEquals(updateOptions.newValue(), newValue); - assertEquals(updateOptions.newSynonyms().size(), 2); - assertEquals(updateOptions.newSynonyms().get(0), valueSynonym0); - assertEquals(updateOptions.newSynonyms().get(1), valueSynonym1); + // Invoke operation with valid options model (positive test) + Response response = + assistantService.listExamples(listExamplesOptionsModel).execute(); + assertNotNull(response); + ExampleCollection responseObj = response.getResult(); + assertNotNull(responseObj); - UpdateValueOptions.Builder builder = updateOptions.newBuilder(); + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(Long.valueOf(query.get("page_limit")), Long.valueOf("26")); + assertEquals(Boolean.valueOf(query.get("include_count")), Boolean.valueOf(true)); + assertEquals(query.get("sort"), "text"); + assertEquals(query.get("cursor"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(true)); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listExamplesPath); + } - String valueSynonym2 = "valueSynonym2"; - builder.newSynonyms(Collections.singletonList(valueSynonym2)); + // Test the listExamples operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListExamplesNoOptions() throws Throwable { + // construct the service + constructClientService(); - UpdateValueOptions options2 = builder.build(); + server.enqueue(new MockResponse()); - assertEquals(options2.workspaceId(), WORKSPACE_ID); - assertEquals(options2.entity(), entity); - assertEquals(options2.newValue(), newValue); - assertEquals(options2.newSynonyms().size(), 1); - assertEquals(options2.newSynonyms().get(0), valueSynonym2); + // Invoke operation with null options model (negative test) + assistantService.listExamples(null).execute(); } - /** Test CreateDialogNodeOptions builder. */ @Test - public void testCreateDialogNodeOptionsBuilder() { - String dialogNodeName = "aDialogNode"; - DialogNodeAction action0 = - new DialogNodeAction.Builder() - .name(NAME) - .credentials(CREDENTIALS) - .resultVariable(RESULT_VARIABLE) - .build(); - DialogNodeAction action1 = - new DialogNodeAction.Builder() - .name(NAME) - .credentials(CREDENTIALS) - .resultVariable(RESULT_VARIABLE) + public void testCreateExampleWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"text\": \"text\", \"mentions\": [{\"entity\": \"entity\", \"location\": [8]}], \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}"; + String createExamplePath = "/v1/workspaces/testString/intents/testString/examples"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(201) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the Mention model + Mention mentionModel = + new Mention.Builder() + .entity("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) .build(); - String userLabel = "user_label"; - CreateDialogNodeOptions createOptions = - new CreateDialogNodeOptions.Builder() - .workspaceId(WORKSPACE_ID) - .dialogNode(dialogNodeName) - .addActions(action0) - .addActions(action1) - .digressIn(CreateDialogNodeOptions.DigressIn.RETURNS) - .digressOut(CreateDialogNodeOptions.DigressOut.ALLOW_ALL) - .digressOutSlots(CreateDialogNodeOptions.DigressOutSlots.ALLOW_ALL) - .userLabel(userLabel) - .disambiguationOptOut(true) + // Construct an instance of the CreateExampleOptions model + CreateExampleOptions createExampleOptionsModel = + new CreateExampleOptions.Builder() + .workspaceId("testString") + .intent("testString") + .text("testString") + .mentions(new java.util.ArrayList(java.util.Arrays.asList(mentionModel))) + .includeAudit(true) .build(); - assertEquals(createOptions.workspaceId(), WORKSPACE_ID); - assertEquals(createOptions.dialogNode(), dialogNodeName); - assertEquals(createOptions.actions().size(), 2); - assertEquals(createOptions.actions().get(0), action0); - assertEquals(createOptions.actions().get(0).credentials(), CREDENTIALS); - assertEquals(createOptions.actions().get(1), action1); - assertEquals(createOptions.actions().get(1).credentials(), CREDENTIALS); - assertEquals(createOptions.digressIn(), CreateDialogNodeOptions.DigressIn.RETURNS); - assertEquals(createOptions.digressOut(), CreateDialogNodeOptions.DigressOut.ALLOW_ALL); - assertEquals( - createOptions.digressOutSlots(), CreateDialogNodeOptions.DigressOutSlots.ALLOW_ALL); - assertEquals(createOptions.userLabel(), userLabel); - assertTrue(createOptions.disambiguationOptOut()); + // Invoke operation with valid options model (positive test) + Response response = + assistantService.createExample(createExampleOptionsModel).execute(); + assertNotNull(response); + Example responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(true)); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createExamplePath); + } + + // Test the createExample operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateExampleNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + assistantService.createExample(null).execute(); } - /** Test UpdateDialogNodeOptions builder. */ @Test - public void testUpdateDialogNodeOptionsBuilder() { - String dialogNodeName = "aDialogNode"; - String newDialogNodeName = "renamedDialogNode"; - DialogNodeAction action0 = - new DialogNodeAction.Builder() - .name(NAME) - .credentials(CREDENTIALS) - .resultVariable(RESULT_VARIABLE) + public void testGetExampleWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"text\": \"text\", \"mentions\": [{\"entity\": \"entity\", \"location\": [8]}], \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}"; + String getExamplePath = "/v1/workspaces/testString/intents/testString/examples/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the GetExampleOptions model + GetExampleOptions getExampleOptionsModel = + new GetExampleOptions.Builder() + .workspaceId("testString") + .intent("testString") + .text("testString") + .includeAudit(true) .build(); - DialogNodeAction action1 = - new DialogNodeAction.Builder() - .name(NAME) - .credentials(CREDENTIALS) - .resultVariable(RESULT_VARIABLE) + + // Invoke operation with valid options model (positive test) + Response response = assistantService.getExample(getExampleOptionsModel).execute(); + assertNotNull(response); + Example responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(true)); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getExamplePath); + } + + // Test the getExample operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetExampleNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + assistantService.getExample(null).execute(); + } + + @Test + public void testUpdateExampleWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"text\": \"text\", \"mentions\": [{\"entity\": \"entity\", \"location\": [8]}], \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}"; + String updateExamplePath = "/v1/workspaces/testString/intents/testString/examples/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the Mention model + Mention mentionModel = + new Mention.Builder() + .entity("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) .build(); - String userLabel = "user_label"; - UpdateDialogNodeOptions updateOptions = - new UpdateDialogNodeOptions.Builder() - .workspaceId(WORKSPACE_ID) - .dialogNode(dialogNodeName) - .newDialogNode(newDialogNodeName) - .addNewActions(action0) - .addNewActions(action1) - .newDigressIn(UpdateDialogNodeOptions.NewDigressIn.RETURNS) - .newDigressOut(UpdateDialogNodeOptions.NewDigressOut.ALLOW_ALL) - .newDigressOutSlots(UpdateDialogNodeOptions.NewDigressOutSlots.ALLOW_ALL) - .newUserLabel(userLabel) - .newDisambiguationOptOut(true) + // Construct an instance of the UpdateExampleOptions model + UpdateExampleOptions updateExampleOptionsModel = + new UpdateExampleOptions.Builder() + .workspaceId("testString") + .intent("testString") + .text("testString") + .newText("testString") + .newMentions(new java.util.ArrayList(java.util.Arrays.asList(mentionModel))) + .includeAudit(true) .build(); - assertEquals(updateOptions.workspaceId(), WORKSPACE_ID); - assertEquals(updateOptions.dialogNode(), dialogNodeName); - assertEquals(updateOptions.newActions().size(), 2); - assertEquals(updateOptions.newActions().get(0), action0); - assertEquals(updateOptions.newActions().get(0).credentials(), CREDENTIALS); - assertEquals(updateOptions.newActions().get(1), action1); - assertEquals(updateOptions.newActions().get(1).credentials(), CREDENTIALS); - assertEquals(updateOptions.newDigressIn(), UpdateDialogNodeOptions.NewDigressIn.RETURNS); - assertEquals(updateOptions.newDigressOut(), UpdateDialogNodeOptions.NewDigressOut.ALLOW_ALL); - assertEquals( - updateOptions.newDigressOutSlots(), UpdateDialogNodeOptions.NewDigressOutSlots.ALLOW_ALL); - assertEquals(updateOptions.newUserLabel(), userLabel); - assertTrue(updateOptions.newDisambiguationOptOut()); + // Invoke operation with valid options model (positive test) + Response response = + assistantService.updateExample(updateExampleOptionsModel).execute(); + assertNotNull(response); + Example responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(true)); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateExamplePath); + } + + // Test the updateExample operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateExampleNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + assistantService.updateExample(null).execute(); } - /** Test ListAllLogsOptions builder. */ @Test - public void testListAllLogsOptionsBuilder() { - String sort = "sort"; - String filter = "filter"; - Long pageLimit = 5L; - String cursor = "cursor"; + public void testDeleteExampleWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String deleteExamplePath = "/v1/workspaces/testString/intents/testString/examples/testString"; - ListAllLogsOptions listOptions = - new ListAllLogsOptions.Builder() - .sort(sort) - .filter(filter) - .pageLimit(pageLimit) - .cursor(cursor) + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the DeleteExampleOptions model + DeleteExampleOptions deleteExampleOptionsModel = + new DeleteExampleOptions.Builder() + .workspaceId("testString") + .intent("testString") + .text("testString") .build(); - assertEquals(listOptions.sort(), sort); - assertEquals(listOptions.filter(), filter); - assertEquals(listOptions.pageLimit(), pageLimit); - assertEquals(listOptions.cursor(), cursor); + // Invoke operation with valid options model (positive test) + Response response = assistantService.deleteExample(deleteExampleOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteExamplePath); } - /** Test DeleteUserDataOptions builder. */ - @Test - public void testDeleteUserDataOptionsBuilder() { - String customerId = "customer_id"; + // Test the deleteExample operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteExampleNoOptions() throws Throwable { + // construct the service + constructClientService(); - DeleteUserDataOptions deleteOptions = - new DeleteUserDataOptions.Builder().customerId(customerId).build(); + server.enqueue(new MockResponse()); - assertEquals(deleteOptions.customerId(), customerId); + // Invoke operation with null options model (negative test) + assistantService.deleteExample(null).execute(); } - /** Test list mentions builder. */ @Test - public void testListMentionsBuilder() { - String entity = "entity"; - - ListMentionsOptions listMentionsOptions = - new ListMentionsOptions.Builder() - .workspaceId(WORKSPACE_ID) - .entity(entity) - .export(true) + public void testListCounterexamplesWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"counterexamples\": [{\"text\": \"text\", \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}], \"pagination\": {\"refresh_url\": \"refreshUrl\", \"next_url\": \"nextUrl\", \"total\": 5, \"matched\": 7, \"refresh_cursor\": \"refreshCursor\", \"next_cursor\": \"nextCursor\"}}"; + String listCounterexamplesPath = "/v1/workspaces/testString/counterexamples"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the ListCounterexamplesOptions model + ListCounterexamplesOptions listCounterexamplesOptionsModel = + new ListCounterexamplesOptions.Builder() + .workspaceId("testString") + .pageLimit(Long.valueOf("26")) + .includeCount(true) + .sort("text") + .cursor("testString") .includeAudit(true) .build(); - assertEquals(listMentionsOptions.workspaceId(), WORKSPACE_ID); - assertEquals(listMentionsOptions.entity(), entity); - assertEquals(listMentionsOptions.export(), true); - assertEquals(listMentionsOptions.includeAudit(), true); + // Invoke operation with valid options model (positive test) + Response response = + assistantService.listCounterexamples(listCounterexamplesOptionsModel).execute(); + assertNotNull(response); + CounterexampleCollection responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(Long.valueOf(query.get("page_limit")), Long.valueOf("26")); + assertEquals(Boolean.valueOf(query.get("include_count")), Boolean.valueOf(true)); + assertEquals(query.get("sort"), "text"); + assertEquals(query.get("cursor"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(true)); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listCounterexamplesPath); } - /** Test message context metadata. */ - @Test - public void testMessageContextMetadata() { - String deployment = "deployment"; - String userId = "user_id"; + // Test the listCounterexamples operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListCounterexamplesNoOptions() throws Throwable { + // construct the service + constructClientService(); - MessageContextMetadata messageContextMetadata = - new MessageContextMetadata.Builder().deployment(deployment).userId(userId).build(); + server.enqueue(new MockResponse()); - assertEquals(deployment, messageContextMetadata.deployment()); - assertEquals(userId, messageContextMetadata.userId()); + // Invoke operation with null options model (negative test) + assistantService.listCounterexamples(null).execute(); } - /** Test create entity builder. */ @Test - public void testCreateEntityBuilder() { - String entity = "entity"; - String description = "Entity description"; - Map metadata = new HashMap<>(); - String metadataKey = "metadata_key"; - String metadataValue = "metadata_value"; - metadata.put(metadataKey, metadataValue); - Date testDate = new Date(); - String value = "value"; - CreateValue createValue = new CreateValue.Builder(value).build(); - CreateValue secondValue = new CreateValue.Builder().value(value).build(); - List values = new ArrayList<>(); - values.add(createValue); - - CreateEntity createEntity = - new CreateEntity.Builder() - .entity(entity) - .description(description) - .metadata(metadata) - .values(values) - .addValues(secondValue) - .fuzzyMatch(true) - .created(testDate) - .updated(testDate) + public void testCreateCounterexampleWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"text\": \"text\", \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}"; + String createCounterexamplePath = "/v1/workspaces/testString/counterexamples"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(201) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the CreateCounterexampleOptions model + CreateCounterexampleOptions createCounterexampleOptionsModel = + new CreateCounterexampleOptions.Builder() + .workspaceId("testString") + .text("testString") + .includeAudit(true) .build(); - createEntity = createEntity.newBuilder().build(); - assertEquals(entity, createEntity.entity()); - assertEquals(description, createEntity.description()); - assertTrue(createEntity.metadata().containsKey(metadataKey)); - assertEquals(metadataValue, createEntity.metadata().get(metadataKey)); - assertNotNull(createEntity.values()); - assertEquals(2, createEntity.values().size()); - assertTrue(createEntity.fuzzyMatch()); - assertEquals(testDate, createEntity.created()); - assertEquals(testDate, createEntity.updated()); + // Invoke operation with valid options model (positive test) + Response response = + assistantService.createCounterexample(createCounterexampleOptionsModel).execute(); + assertNotNull(response); + Counterexample responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(true)); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createCounterexamplePath); } - /** Test create intent builder. */ - @Test - public void testCreateIntentBuilder() { - String intent = "intent"; - String description = "Intent description"; - Date testDate = new Date(); - String text = "text"; - Example example = new Example.Builder(text).build(); - Example secondExample = new Example.Builder().text(text).build(); - List examples = new ArrayList<>(); - examples.add(example); - - CreateIntent createIntent = - new CreateIntent.Builder() - .intent(intent) - .description(description) - .examples(examples) - .addExample(secondExample) - .created(testDate) - .updated(testDate) - .build(); - createIntent = createIntent.newBuilder().build(); - - assertEquals(intent, createIntent.intent()); - assertEquals(description, createIntent.description()); - assertNotNull(createIntent.examples()); - assertEquals(2, createIntent.examples().size()); - assertEquals(testDate, createIntent.created()); - assertEquals(testDate, createIntent.updated()); + // Test the createCounterexample operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateCounterexampleNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + assistantService.createCounterexample(null).execute(); + } + + @Test + public void testGetCounterexampleWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"text\": \"text\", \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}"; + String getCounterexamplePath = "/v1/workspaces/testString/counterexamples/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the GetCounterexampleOptions model + GetCounterexampleOptions getCounterexampleOptionsModel = + new GetCounterexampleOptions.Builder() + .workspaceId("testString") + .text("testString") + .includeAudit(true) + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + assistantService.getCounterexample(getCounterexampleOptionsModel).execute(); + assertNotNull(response); + Counterexample responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(true)); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getCounterexamplePath); + } + + // Test the getCounterexample operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetCounterexampleNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + assistantService.getCounterexample(null).execute(); + } + + @Test + public void testUpdateCounterexampleWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"text\": \"text\", \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}"; + String updateCounterexamplePath = "/v1/workspaces/testString/counterexamples/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the UpdateCounterexampleOptions model + UpdateCounterexampleOptions updateCounterexampleOptionsModel = + new UpdateCounterexampleOptions.Builder() + .workspaceId("testString") + .text("testString") + .newText("testString") + .includeAudit(true) + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + assistantService.updateCounterexample(updateCounterexampleOptionsModel).execute(); + assertNotNull(response); + Counterexample responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(true)); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateCounterexamplePath); + } + + // Test the updateCounterexample operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateCounterexampleNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + assistantService.updateCounterexample(null).execute(); + } + + @Test + public void testDeleteCounterexampleWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String deleteCounterexamplePath = "/v1/workspaces/testString/counterexamples/testString"; + + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the DeleteCounterexampleOptions model + DeleteCounterexampleOptions deleteCounterexampleOptionsModel = + new DeleteCounterexampleOptions.Builder() + .workspaceId("testString") + .text("testString") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + assistantService.deleteCounterexample(deleteCounterexampleOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteCounterexamplePath); + } + + // Test the deleteCounterexample operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteCounterexampleNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + assistantService.deleteCounterexample(null).execute(); + } + + @Test + public void testListEntitiesWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"entities\": [{\"entity\": \"entity\", \"description\": \"description\", \"metadata\": {\"mapKey\": \"anyValue\"}, \"fuzzy_match\": true, \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\", \"values\": [{\"value\": \"value\", \"metadata\": {\"mapKey\": \"anyValue\"}, \"type\": \"synonyms\", \"synonyms\": [\"synonym\"], \"patterns\": [\"pattern\"], \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}]}], \"pagination\": {\"refresh_url\": \"refreshUrl\", \"next_url\": \"nextUrl\", \"total\": 5, \"matched\": 7, \"refresh_cursor\": \"refreshCursor\", \"next_cursor\": \"nextCursor\"}}"; + String listEntitiesPath = "/v1/workspaces/testString/entities"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the ListEntitiesOptions model + ListEntitiesOptions listEntitiesOptionsModel = + new ListEntitiesOptions.Builder() + .workspaceId("testString") + .export(true) + .pageLimit(Long.valueOf("26")) + .includeCount(true) + .sort("entity") + .cursor("testString") + .includeAudit(true) + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + assistantService.listEntities(listEntitiesOptionsModel).execute(); + assertNotNull(response); + EntityCollection responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("export")), Boolean.valueOf(true)); + assertEquals(Long.valueOf(query.get("page_limit")), Long.valueOf("26")); + assertEquals(Boolean.valueOf(query.get("include_count")), Boolean.valueOf(true)); + assertEquals(query.get("sort"), "entity"); + assertEquals(query.get("cursor"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(true)); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listEntitiesPath); + } + + // Test the listEntities operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListEntitiesNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + assistantService.listEntities(null).execute(); + } + + @Test + public void testCreateEntityWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"entity\": \"entity\", \"description\": \"description\", \"metadata\": {\"mapKey\": \"anyValue\"}, \"fuzzy_match\": true, \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\", \"values\": [{\"value\": \"value\", \"metadata\": {\"mapKey\": \"anyValue\"}, \"type\": \"synonyms\", \"synonyms\": [\"synonym\"], \"patterns\": [\"pattern\"], \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}]}"; + String createEntityPath = "/v1/workspaces/testString/entities"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(201) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the CreateValue model + CreateValue createValueModel = + new CreateValue.Builder() + .value("testString") + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .type("synonyms") + .synonyms(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .patterns(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + + // Construct an instance of the CreateEntityOptions model + CreateEntityOptions createEntityOptionsModel = + new CreateEntityOptions.Builder() + .workspaceId("testString") + .entity("testString") + .description("testString") + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .fuzzyMatch(true) + .values(new java.util.ArrayList(java.util.Arrays.asList(createValueModel))) + .includeAudit(true) + .build(); + + // Invoke operation with valid options model (positive test) + Response response = assistantService.createEntity(createEntityOptionsModel).execute(); + assertNotNull(response); + Entity responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(true)); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createEntityPath); + } + + // Test the createEntity operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateEntityNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + assistantService.createEntity(null).execute(); + } + + @Test + public void testGetEntityWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"entity\": \"entity\", \"description\": \"description\", \"metadata\": {\"mapKey\": \"anyValue\"}, \"fuzzy_match\": true, \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\", \"values\": [{\"value\": \"value\", \"metadata\": {\"mapKey\": \"anyValue\"}, \"type\": \"synonyms\", \"synonyms\": [\"synonym\"], \"patterns\": [\"pattern\"], \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}]}"; + String getEntityPath = "/v1/workspaces/testString/entities/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the GetEntityOptions model + GetEntityOptions getEntityOptionsModel = + new GetEntityOptions.Builder() + .workspaceId("testString") + .entity("testString") + .export(true) + .includeAudit(true) + .build(); + + // Invoke operation with valid options model (positive test) + Response response = assistantService.getEntity(getEntityOptionsModel).execute(); + assertNotNull(response); + Entity responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("export")), Boolean.valueOf(true)); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(true)); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getEntityPath); + } + + // Test the getEntity operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetEntityNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + assistantService.getEntity(null).execute(); + } + + @Test + public void testUpdateEntityWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"entity\": \"entity\", \"description\": \"description\", \"metadata\": {\"mapKey\": \"anyValue\"}, \"fuzzy_match\": true, \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\", \"values\": [{\"value\": \"value\", \"metadata\": {\"mapKey\": \"anyValue\"}, \"type\": \"synonyms\", \"synonyms\": [\"synonym\"], \"patterns\": [\"pattern\"], \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}]}"; + String updateEntityPath = "/v1/workspaces/testString/entities/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the CreateValue model + CreateValue createValueModel = + new CreateValue.Builder() + .value("testString") + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .type("synonyms") + .synonyms(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .patterns(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + + // Construct an instance of the UpdateEntityOptions model + UpdateEntityOptions updateEntityOptionsModel = + new UpdateEntityOptions.Builder() + .workspaceId("testString") + .entity("testString") + .newEntity("testString") + .newDescription("testString") + .newMetadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .newFuzzyMatch(true) + .newValues( + new java.util.ArrayList(java.util.Arrays.asList(createValueModel))) + .append(true) + .includeAudit(true) + .build(); + + // Invoke operation with valid options model (positive test) + Response response = assistantService.updateEntity(updateEntityOptionsModel).execute(); + assertNotNull(response); + Entity responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("append")), Boolean.valueOf(true)); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(true)); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateEntityPath); + } + + // Test the updateEntity operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateEntityNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + assistantService.updateEntity(null).execute(); + } + + @Test + public void testDeleteEntityWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String deleteEntityPath = "/v1/workspaces/testString/entities/testString"; + + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the DeleteEntityOptions model + DeleteEntityOptions deleteEntityOptionsModel = + new DeleteEntityOptions.Builder().workspaceId("testString").entity("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = assistantService.deleteEntity(deleteEntityOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteEntityPath); + } + + // Test the deleteEntity operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteEntityNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + assistantService.deleteEntity(null).execute(); + } + + @Test + public void testListMentionsWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"examples\": [{\"text\": \"text\", \"intent\": \"intent\", \"location\": [8]}], \"pagination\": {\"refresh_url\": \"refreshUrl\", \"next_url\": \"nextUrl\", \"total\": 5, \"matched\": 7, \"refresh_cursor\": \"refreshCursor\", \"next_cursor\": \"nextCursor\"}}"; + String listMentionsPath = "/v1/workspaces/testString/entities/testString/mentions"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the ListMentionsOptions model + ListMentionsOptions listMentionsOptionsModel = + new ListMentionsOptions.Builder() + .workspaceId("testString") + .entity("testString") + .export(true) + .includeAudit(true) + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + assistantService.listMentions(listMentionsOptionsModel).execute(); + assertNotNull(response); + EntityMentionCollection responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("export")), Boolean.valueOf(true)); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(true)); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listMentionsPath); + } + + // Test the listMentions operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListMentionsNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + assistantService.listMentions(null).execute(); + } + + @Test + public void testListValuesWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"values\": [{\"value\": \"value\", \"metadata\": {\"mapKey\": \"anyValue\"}, \"type\": \"synonyms\", \"synonyms\": [\"synonym\"], \"patterns\": [\"pattern\"], \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}], \"pagination\": {\"refresh_url\": \"refreshUrl\", \"next_url\": \"nextUrl\", \"total\": 5, \"matched\": 7, \"refresh_cursor\": \"refreshCursor\", \"next_cursor\": \"nextCursor\"}}"; + String listValuesPath = "/v1/workspaces/testString/entities/testString/values"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the ListValuesOptions model + ListValuesOptions listValuesOptionsModel = + new ListValuesOptions.Builder() + .workspaceId("testString") + .entity("testString") + .export(true) + .pageLimit(Long.valueOf("26")) + .includeCount(true) + .sort("value") + .cursor("testString") + .includeAudit(true) + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + assistantService.listValues(listValuesOptionsModel).execute(); + assertNotNull(response); + ValueCollection responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("export")), Boolean.valueOf(true)); + assertEquals(Long.valueOf(query.get("page_limit")), Long.valueOf("26")); + assertEquals(Boolean.valueOf(query.get("include_count")), Boolean.valueOf(true)); + assertEquals(query.get("sort"), "value"); + assertEquals(query.get("cursor"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(true)); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listValuesPath); + } + + // Test the listValues operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListValuesNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + assistantService.listValues(null).execute(); + } + + @Test + public void testCreateValueWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"value\": \"value\", \"metadata\": {\"mapKey\": \"anyValue\"}, \"type\": \"synonyms\", \"synonyms\": [\"synonym\"], \"patterns\": [\"pattern\"], \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}"; + String createValuePath = "/v1/workspaces/testString/entities/testString/values"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(201) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the CreateValueOptions model + CreateValueOptions createValueOptionsModel = + new CreateValueOptions.Builder() + .workspaceId("testString") + .entity("testString") + .value("testString") + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .type("synonyms") + .synonyms(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .patterns(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .includeAudit(true) + .build(); + + // Invoke operation with valid options model (positive test) + Response response = assistantService.createValue(createValueOptionsModel).execute(); + assertNotNull(response); + Value responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(true)); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createValuePath); + } + + // Test the createValue operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateValueNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + assistantService.createValue(null).execute(); + } + + @Test + public void testGetValueWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"value\": \"value\", \"metadata\": {\"mapKey\": \"anyValue\"}, \"type\": \"synonyms\", \"synonyms\": [\"synonym\"], \"patterns\": [\"pattern\"], \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}"; + String getValuePath = "/v1/workspaces/testString/entities/testString/values/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the GetValueOptions model + GetValueOptions getValueOptionsModel = + new GetValueOptions.Builder() + .workspaceId("testString") + .entity("testString") + .value("testString") + .export(true) + .includeAudit(true) + .build(); + + // Invoke operation with valid options model (positive test) + Response response = assistantService.getValue(getValueOptionsModel).execute(); + assertNotNull(response); + Value responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("export")), Boolean.valueOf(true)); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(true)); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getValuePath); + } + + // Test the getValue operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetValueNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + assistantService.getValue(null).execute(); + } + + @Test + public void testUpdateValueWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"value\": \"value\", \"metadata\": {\"mapKey\": \"anyValue\"}, \"type\": \"synonyms\", \"synonyms\": [\"synonym\"], \"patterns\": [\"pattern\"], \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}"; + String updateValuePath = "/v1/workspaces/testString/entities/testString/values/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the UpdateValueOptions model + UpdateValueOptions updateValueOptionsModel = + new UpdateValueOptions.Builder() + .workspaceId("testString") + .entity("testString") + .value("testString") + .newValue("testString") + .newMetadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .newType("synonyms") + .newSynonyms(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .newPatterns(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .append(true) + .includeAudit(true) + .build(); + + // Invoke operation with valid options model (positive test) + Response response = assistantService.updateValue(updateValueOptionsModel).execute(); + assertNotNull(response); + Value responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("append")), Boolean.valueOf(true)); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(true)); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateValuePath); + } + + // Test the updateValue operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateValueNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + assistantService.updateValue(null).execute(); + } + + @Test + public void testDeleteValueWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String deleteValuePath = "/v1/workspaces/testString/entities/testString/values/testString"; + + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the DeleteValueOptions model + DeleteValueOptions deleteValueOptionsModel = + new DeleteValueOptions.Builder() + .workspaceId("testString") + .entity("testString") + .value("testString") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = assistantService.deleteValue(deleteValueOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteValuePath); + } + + // Test the deleteValue operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteValueNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + assistantService.deleteValue(null).execute(); + } + + @Test + public void testListSynonymsWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"synonyms\": [{\"synonym\": \"synonym\", \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}], \"pagination\": {\"refresh_url\": \"refreshUrl\", \"next_url\": \"nextUrl\", \"total\": 5, \"matched\": 7, \"refresh_cursor\": \"refreshCursor\", \"next_cursor\": \"nextCursor\"}}"; + String listSynonymsPath = + "/v1/workspaces/testString/entities/testString/values/testString/synonyms"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the ListSynonymsOptions model + ListSynonymsOptions listSynonymsOptionsModel = + new ListSynonymsOptions.Builder() + .workspaceId("testString") + .entity("testString") + .value("testString") + .pageLimit(Long.valueOf("26")) + .includeCount(true) + .sort("synonym") + .cursor("testString") + .includeAudit(true) + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + assistantService.listSynonyms(listSynonymsOptionsModel).execute(); + assertNotNull(response); + SynonymCollection responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(Long.valueOf(query.get("page_limit")), Long.valueOf("26")); + assertEquals(Boolean.valueOf(query.get("include_count")), Boolean.valueOf(true)); + assertEquals(query.get("sort"), "synonym"); + assertEquals(query.get("cursor"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(true)); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listSynonymsPath); + } + + // Test the listSynonyms operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListSynonymsNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + assistantService.listSynonyms(null).execute(); + } + + @Test + public void testCreateSynonymWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"synonym\": \"synonym\", \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}"; + String createSynonymPath = + "/v1/workspaces/testString/entities/testString/values/testString/synonyms"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(201) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the CreateSynonymOptions model + CreateSynonymOptions createSynonymOptionsModel = + new CreateSynonymOptions.Builder() + .workspaceId("testString") + .entity("testString") + .value("testString") + .synonym("testString") + .includeAudit(true) + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + assistantService.createSynonym(createSynonymOptionsModel).execute(); + assertNotNull(response); + Synonym responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(true)); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createSynonymPath); + } + + // Test the createSynonym operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateSynonymNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + assistantService.createSynonym(null).execute(); + } + + @Test + public void testGetSynonymWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"synonym\": \"synonym\", \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}"; + String getSynonymPath = + "/v1/workspaces/testString/entities/testString/values/testString/synonyms/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the GetSynonymOptions model + GetSynonymOptions getSynonymOptionsModel = + new GetSynonymOptions.Builder() + .workspaceId("testString") + .entity("testString") + .value("testString") + .synonym("testString") + .includeAudit(true) + .build(); + + // Invoke operation with valid options model (positive test) + Response response = assistantService.getSynonym(getSynonymOptionsModel).execute(); + assertNotNull(response); + Synonym responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(true)); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getSynonymPath); + } + + // Test the getSynonym operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetSynonymNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + assistantService.getSynonym(null).execute(); + } + + @Test + public void testUpdateSynonymWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"synonym\": \"synonym\", \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}"; + String updateSynonymPath = + "/v1/workspaces/testString/entities/testString/values/testString/synonyms/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the UpdateSynonymOptions model + UpdateSynonymOptions updateSynonymOptionsModel = + new UpdateSynonymOptions.Builder() + .workspaceId("testString") + .entity("testString") + .value("testString") + .synonym("testString") + .newSynonym("testString") + .includeAudit(true) + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + assistantService.updateSynonym(updateSynonymOptionsModel).execute(); + assertNotNull(response); + Synonym responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(true)); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateSynonymPath); + } + + // Test the updateSynonym operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateSynonymNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + assistantService.updateSynonym(null).execute(); + } + + @Test + public void testDeleteSynonymWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String deleteSynonymPath = + "/v1/workspaces/testString/entities/testString/values/testString/synonyms/testString"; + + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the DeleteSynonymOptions model + DeleteSynonymOptions deleteSynonymOptionsModel = + new DeleteSynonymOptions.Builder() + .workspaceId("testString") + .entity("testString") + .value("testString") + .synonym("testString") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = assistantService.deleteSynonym(deleteSynonymOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteSynonymPath); + } + + // Test the deleteSynonym operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteSynonymNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + assistantService.deleteSynonym(null).execute(); + } + + @Test + public void testListDialogNodesWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"dialog_nodes\": [{\"dialog_node\": \"dialogNode\", \"description\": \"description\", \"conditions\": \"conditions\", \"parent\": \"parent\", \"previous_sibling\": \"previousSibling\", \"output\": {\"generic\": [{\"response_type\": \"search_skill\", \"query\": \"query\", \"query_type\": \"natural_language\", \"filter\": \"filter\", \"discovery_version\": \"discoveryVersion\"}], \"integrations\": {\"mapKey\": {\"mapKey\": \"anyValue\"}}, \"modifiers\": {\"overwrite\": false}}, \"context\": {\"integrations\": {\"mapKey\": {\"mapKey\": \"anyValue\"}}}, \"metadata\": {\"mapKey\": \"anyValue\"}, \"next_step\": {\"behavior\": \"get_user_input\", \"dialog_node\": \"dialogNode\", \"selector\": \"condition\"}, \"title\": \"title\", \"type\": \"standard\", \"event_name\": \"focus\", \"variable\": \"variable\", \"actions\": [{\"name\": \"name\", \"type\": \"client\", \"parameters\": {\"mapKey\": \"anyValue\"}, \"result_variable\": \"resultVariable\", \"credentials\": \"credentials\"}], \"digress_in\": \"not_available\", \"digress_out\": \"allow_returning\", \"digress_out_slots\": \"not_allowed\", \"user_label\": \"userLabel\", \"disambiguation_opt_out\": true, \"disabled\": true, \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}], \"pagination\": {\"refresh_url\": \"refreshUrl\", \"next_url\": \"nextUrl\", \"total\": 5, \"matched\": 7, \"refresh_cursor\": \"refreshCursor\", \"next_cursor\": \"nextCursor\"}}"; + String listDialogNodesPath = "/v1/workspaces/testString/dialog_nodes"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the ListDialogNodesOptions model + ListDialogNodesOptions listDialogNodesOptionsModel = + new ListDialogNodesOptions.Builder() + .workspaceId("testString") + .pageLimit(Long.valueOf("26")) + .includeCount(true) + .sort("dialog_node") + .cursor("testString") + .includeAudit(true) + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + assistantService.listDialogNodes(listDialogNodesOptionsModel).execute(); + assertNotNull(response); + DialogNodeCollection responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(Long.valueOf(query.get("page_limit")), Long.valueOf("26")); + assertEquals(Boolean.valueOf(query.get("include_count")), Boolean.valueOf(true)); + assertEquals(query.get("sort"), "dialog_node"); + assertEquals(query.get("cursor"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(true)); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listDialogNodesPath); + } + + // Test the listDialogNodes operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListDialogNodesNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + assistantService.listDialogNodes(null).execute(); + } + + @Test + public void testCreateDialogNodeWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"dialog_node\": \"dialogNode\", \"description\": \"description\", \"conditions\": \"conditions\", \"parent\": \"parent\", \"previous_sibling\": \"previousSibling\", \"output\": {\"generic\": [{\"response_type\": \"search_skill\", \"query\": \"query\", \"query_type\": \"natural_language\", \"filter\": \"filter\", \"discovery_version\": \"discoveryVersion\"}], \"integrations\": {\"mapKey\": {\"mapKey\": \"anyValue\"}}, \"modifiers\": {\"overwrite\": false}}, \"context\": {\"integrations\": {\"mapKey\": {\"mapKey\": \"anyValue\"}}}, \"metadata\": {\"mapKey\": \"anyValue\"}, \"next_step\": {\"behavior\": \"get_user_input\", \"dialog_node\": \"dialogNode\", \"selector\": \"condition\"}, \"title\": \"title\", \"type\": \"standard\", \"event_name\": \"focus\", \"variable\": \"variable\", \"actions\": [{\"name\": \"name\", \"type\": \"client\", \"parameters\": {\"mapKey\": \"anyValue\"}, \"result_variable\": \"resultVariable\", \"credentials\": \"credentials\"}], \"digress_in\": \"not_available\", \"digress_out\": \"allow_returning\", \"digress_out_slots\": \"not_allowed\", \"user_label\": \"userLabel\", \"disambiguation_opt_out\": true, \"disabled\": true, \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}"; + String createDialogNodePath = "/v1/workspaces/testString/dialog_nodes"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(201) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill + // model + DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill dialogNodeOutputGenericModel = + new DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill.Builder() + .responseType("search_skill") + .query("testString") + .queryType("natural_language") + .filter("testString") + .discoveryVersion("testString") + .build(); + + // Construct an instance of the DialogNodeOutputModifiers model + DialogNodeOutputModifiers dialogNodeOutputModifiersModel = + new DialogNodeOutputModifiers.Builder().overwrite(true).build(); + + // Construct an instance of the DialogNodeOutput model + DialogNodeOutput dialogNodeOutputModel = + new DialogNodeOutput.Builder() + .generic( + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeOutputGenericModel))) + .integrations( + new java.util.HashMap>() { + { + put( + "foo", + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + } + }) + .modifiers(dialogNodeOutputModifiersModel) + .add("foo", "testString") + .build(); + + // Construct an instance of the DialogNodeContext model + DialogNodeContext dialogNodeContextModel = + new DialogNodeContext.Builder() + .integrations( + new java.util.HashMap>() { + { + put( + "foo", + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + } + }) + .add("foo", "testString") + .build(); + + // Construct an instance of the DialogNodeNextStep model + DialogNodeNextStep dialogNodeNextStepModel = + new DialogNodeNextStep.Builder() + .behavior("get_user_input") + .dialogNode("testString") + .selector("condition") + .build(); + + // Construct an instance of the DialogNodeAction model + DialogNodeAction dialogNodeActionModel = + new DialogNodeAction.Builder() + .name("testString") + .type("client") + .parameters( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .resultVariable("testString") + .credentials("testString") + .build(); + + // Construct an instance of the CreateDialogNodeOptions model + CreateDialogNodeOptions createDialogNodeOptionsModel = + new CreateDialogNodeOptions.Builder() + .workspaceId("testString") + .dialogNode("testString") + .description("testString") + .conditions("testString") + .parent("testString") + .previousSibling("testString") + .output(dialogNodeOutputModel) + .context(dialogNodeContextModel) + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .nextStep(dialogNodeNextStepModel) + .title("testString") + .type("standard") + .eventName("focus") + .variable("testString") + .actions( + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeActionModel))) + .digressIn("not_available") + .digressOut("allow_returning") + .digressOutSlots("not_allowed") + .userLabel("testString") + .disambiguationOptOut(true) + .includeAudit(true) + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + assistantService.createDialogNode(createDialogNodeOptionsModel).execute(); + assertNotNull(response); + DialogNode responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(true)); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createDialogNodePath); + } + + // Test the createDialogNode operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateDialogNodeNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + assistantService.createDialogNode(null).execute(); + } + + @Test + public void testGetDialogNodeWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"dialog_node\": \"dialogNode\", \"description\": \"description\", \"conditions\": \"conditions\", \"parent\": \"parent\", \"previous_sibling\": \"previousSibling\", \"output\": {\"generic\": [{\"response_type\": \"search_skill\", \"query\": \"query\", \"query_type\": \"natural_language\", \"filter\": \"filter\", \"discovery_version\": \"discoveryVersion\"}], \"integrations\": {\"mapKey\": {\"mapKey\": \"anyValue\"}}, \"modifiers\": {\"overwrite\": false}}, \"context\": {\"integrations\": {\"mapKey\": {\"mapKey\": \"anyValue\"}}}, \"metadata\": {\"mapKey\": \"anyValue\"}, \"next_step\": {\"behavior\": \"get_user_input\", \"dialog_node\": \"dialogNode\", \"selector\": \"condition\"}, \"title\": \"title\", \"type\": \"standard\", \"event_name\": \"focus\", \"variable\": \"variable\", \"actions\": [{\"name\": \"name\", \"type\": \"client\", \"parameters\": {\"mapKey\": \"anyValue\"}, \"result_variable\": \"resultVariable\", \"credentials\": \"credentials\"}], \"digress_in\": \"not_available\", \"digress_out\": \"allow_returning\", \"digress_out_slots\": \"not_allowed\", \"user_label\": \"userLabel\", \"disambiguation_opt_out\": true, \"disabled\": true, \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}"; + String getDialogNodePath = "/v1/workspaces/testString/dialog_nodes/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the GetDialogNodeOptions model + GetDialogNodeOptions getDialogNodeOptionsModel = + new GetDialogNodeOptions.Builder() + .workspaceId("testString") + .dialogNode("testString") + .includeAudit(true) + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + assistantService.getDialogNode(getDialogNodeOptionsModel).execute(); + assertNotNull(response); + DialogNode responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(true)); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getDialogNodePath); + } + + // Test the getDialogNode operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetDialogNodeNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + assistantService.getDialogNode(null).execute(); + } + + @Test + public void testUpdateDialogNodeWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"dialog_node\": \"dialogNode\", \"description\": \"description\", \"conditions\": \"conditions\", \"parent\": \"parent\", \"previous_sibling\": \"previousSibling\", \"output\": {\"generic\": [{\"response_type\": \"search_skill\", \"query\": \"query\", \"query_type\": \"natural_language\", \"filter\": \"filter\", \"discovery_version\": \"discoveryVersion\"}], \"integrations\": {\"mapKey\": {\"mapKey\": \"anyValue\"}}, \"modifiers\": {\"overwrite\": false}}, \"context\": {\"integrations\": {\"mapKey\": {\"mapKey\": \"anyValue\"}}}, \"metadata\": {\"mapKey\": \"anyValue\"}, \"next_step\": {\"behavior\": \"get_user_input\", \"dialog_node\": \"dialogNode\", \"selector\": \"condition\"}, \"title\": \"title\", \"type\": \"standard\", \"event_name\": \"focus\", \"variable\": \"variable\", \"actions\": [{\"name\": \"name\", \"type\": \"client\", \"parameters\": {\"mapKey\": \"anyValue\"}, \"result_variable\": \"resultVariable\", \"credentials\": \"credentials\"}], \"digress_in\": \"not_available\", \"digress_out\": \"allow_returning\", \"digress_out_slots\": \"not_allowed\", \"user_label\": \"userLabel\", \"disambiguation_opt_out\": true, \"disabled\": true, \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}"; + String updateDialogNodePath = "/v1/workspaces/testString/dialog_nodes/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill + // model + DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill dialogNodeOutputGenericModel = + new DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill.Builder() + .responseType("search_skill") + .query("testString") + .queryType("natural_language") + .filter("testString") + .discoveryVersion("testString") + .build(); + + // Construct an instance of the DialogNodeOutputModifiers model + DialogNodeOutputModifiers dialogNodeOutputModifiersModel = + new DialogNodeOutputModifiers.Builder().overwrite(true).build(); + + // Construct an instance of the DialogNodeOutput model + DialogNodeOutput dialogNodeOutputModel = + new DialogNodeOutput.Builder() + .generic( + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeOutputGenericModel))) + .integrations( + new java.util.HashMap>() { + { + put( + "foo", + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + } + }) + .modifiers(dialogNodeOutputModifiersModel) + .add("foo", "testString") + .build(); + + // Construct an instance of the DialogNodeContext model + DialogNodeContext dialogNodeContextModel = + new DialogNodeContext.Builder() + .integrations( + new java.util.HashMap>() { + { + put( + "foo", + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + } + }) + .add("foo", "testString") + .build(); + + // Construct an instance of the DialogNodeNextStep model + DialogNodeNextStep dialogNodeNextStepModel = + new DialogNodeNextStep.Builder() + .behavior("get_user_input") + .dialogNode("testString") + .selector("condition") + .build(); + + // Construct an instance of the DialogNodeAction model + DialogNodeAction dialogNodeActionModel = + new DialogNodeAction.Builder() + .name("testString") + .type("client") + .parameters( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .resultVariable("testString") + .credentials("testString") + .build(); + + // Construct an instance of the UpdateDialogNodeOptions model + UpdateDialogNodeOptions updateDialogNodeOptionsModel = + new UpdateDialogNodeOptions.Builder() + .workspaceId("testString") + .dialogNode("testString") + .newDialogNode("testString") + .newDescription("testString") + .newConditions("testString") + .newParent("testString") + .newPreviousSibling("testString") + .newOutput(dialogNodeOutputModel) + .newContext(dialogNodeContextModel) + .newMetadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .newNextStep(dialogNodeNextStepModel) + .newTitle("testString") + .newType("standard") + .newEventName("focus") + .newVariable("testString") + .newActions( + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeActionModel))) + .newDigressIn("not_available") + .newDigressOut("allow_returning") + .newDigressOutSlots("not_allowed") + .newUserLabel("testString") + .newDisambiguationOptOut(true) + .includeAudit(true) + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + assistantService.updateDialogNode(updateDialogNodeOptionsModel).execute(); + assertNotNull(response); + DialogNode responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_audit")), Boolean.valueOf(true)); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateDialogNodePath); + } + + // Test the updateDialogNode operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateDialogNodeNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + assistantService.updateDialogNode(null).execute(); + } + + @Test + public void testDeleteDialogNodeWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String deleteDialogNodePath = "/v1/workspaces/testString/dialog_nodes/testString"; + + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the DeleteDialogNodeOptions model + DeleteDialogNodeOptions deleteDialogNodeOptionsModel = + new DeleteDialogNodeOptions.Builder() + .workspaceId("testString") + .dialogNode("testString") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + assistantService.deleteDialogNode(deleteDialogNodeOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteDialogNodePath); + } + + // Test the deleteDialogNode operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteDialogNodeNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + assistantService.deleteDialogNode(null).execute(); + } + + @Test + public void testListLogsWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"logs\": [{\"request\": {\"input\": {\"text\": \"text\", \"spelling_suggestions\": false, \"spelling_auto_correct\": false, \"suggested_text\": \"suggestedText\", \"original_text\": \"originalText\"}, \"intents\": [{\"intent\": \"intent\", \"confidence\": 10}], \"entities\": [{\"entity\": \"entity\", \"location\": [8], \"value\": \"value\", \"confidence\": 10, \"metadata\": {\"mapKey\": \"anyValue\"}, \"groups\": [{\"group\": \"group\", \"location\": [8]}], \"interpretation\": {\"calendar_type\": \"calendarType\", \"datetime_link\": \"datetimeLink\", \"festival\": \"festival\", \"granularity\": \"day\", \"range_link\": \"rangeLink\", \"range_modifier\": \"rangeModifier\", \"relative_day\": 11, \"relative_month\": 13, \"relative_week\": 12, \"relative_weekend\": 15, \"relative_year\": 12, \"specific_day\": 11, \"specific_day_of_week\": \"specificDayOfWeek\", \"specific_month\": 13, \"specific_quarter\": 15, \"specific_year\": 12, \"numeric_value\": 12, \"subtype\": \"subtype\", \"part_of_day\": \"partOfDay\", \"relative_hour\": 12, \"relative_minute\": 14, \"relative_second\": 14, \"specific_hour\": 12, \"specific_minute\": 14, \"specific_second\": 14, \"timezone\": \"timezone\"}, \"alternatives\": [{\"value\": \"value\", \"confidence\": 10}], \"role\": {\"type\": \"date_from\"}}], \"alternate_intents\": true, \"context\": {\"conversation_id\": \"conversationId\", \"system\": {\"mapKey\": \"anyValue\"}, \"metadata\": {\"deployment\": \"deployment\", \"user_id\": \"userId\"}}, \"output\": {\"nodes_visited\": [\"nodesVisited\"], \"nodes_visited_details\": [{\"dialog_node\": \"dialogNode\", \"title\": \"title\", \"conditions\": \"conditions\"}], \"log_messages\": [{\"level\": \"info\", \"msg\": \"msg\"}], \"text\": [\"text\"], \"generic\": [{\"response_type\": \"option\", \"title\": \"title\", \"description\": \"description\", \"preference\": \"dropdown\", \"options\": [{\"label\": \"label\", \"value\": {\"input\": {\"text\": \"text\", \"spelling_suggestions\": false, \"spelling_auto_correct\": false, \"suggested_text\": \"suggestedText\", \"original_text\": \"originalText\"}, \"intents\": [{\"intent\": \"intent\", \"confidence\": 10}], \"entities\": [{\"entity\": \"entity\", \"location\": [8], \"value\": \"value\", \"confidence\": 10, \"metadata\": {\"mapKey\": \"anyValue\"}, \"groups\": [{\"group\": \"group\", \"location\": [8]}], \"interpretation\": {\"calendar_type\": \"calendarType\", \"datetime_link\": \"datetimeLink\", \"festival\": \"festival\", \"granularity\": \"day\", \"range_link\": \"rangeLink\", \"range_modifier\": \"rangeModifier\", \"relative_day\": 11, \"relative_month\": 13, \"relative_week\": 12, \"relative_weekend\": 15, \"relative_year\": 12, \"specific_day\": 11, \"specific_day_of_week\": \"specificDayOfWeek\", \"specific_month\": 13, \"specific_quarter\": 15, \"specific_year\": 12, \"numeric_value\": 12, \"subtype\": \"subtype\", \"part_of_day\": \"partOfDay\", \"relative_hour\": 12, \"relative_minute\": 14, \"relative_second\": 14, \"specific_hour\": 12, \"specific_minute\": 14, \"specific_second\": 14, \"timezone\": \"timezone\"}, \"alternatives\": [{\"value\": \"value\", \"confidence\": 10}], \"role\": {\"type\": \"date_from\"}}]}}]}]}, \"actions\": [{\"name\": \"name\", \"type\": \"client\", \"parameters\": {\"mapKey\": \"anyValue\"}, \"result_variable\": \"resultVariable\", \"credentials\": \"credentials\"}]}, \"response\": {\"input\": {\"text\": \"text\", \"spelling_suggestions\": false, \"spelling_auto_correct\": false, \"suggested_text\": \"suggestedText\", \"original_text\": \"originalText\"}, \"intents\": [{\"intent\": \"intent\", \"confidence\": 10}], \"entities\": [{\"entity\": \"entity\", \"location\": [8], \"value\": \"value\", \"confidence\": 10, \"metadata\": {\"mapKey\": \"anyValue\"}, \"groups\": [{\"group\": \"group\", \"location\": [8]}], \"interpretation\": {\"calendar_type\": \"calendarType\", \"datetime_link\": \"datetimeLink\", \"festival\": \"festival\", \"granularity\": \"day\", \"range_link\": \"rangeLink\", \"range_modifier\": \"rangeModifier\", \"relative_day\": 11, \"relative_month\": 13, \"relative_week\": 12, \"relative_weekend\": 15, \"relative_year\": 12, \"specific_day\": 11, \"specific_day_of_week\": \"specificDayOfWeek\", \"specific_month\": 13, \"specific_quarter\": 15, \"specific_year\": 12, \"numeric_value\": 12, \"subtype\": \"subtype\", \"part_of_day\": \"partOfDay\", \"relative_hour\": 12, \"relative_minute\": 14, \"relative_second\": 14, \"specific_hour\": 12, \"specific_minute\": 14, \"specific_second\": 14, \"timezone\": \"timezone\"}, \"alternatives\": [{\"value\": \"value\", \"confidence\": 10}], \"role\": {\"type\": \"date_from\"}}], \"alternate_intents\": true, \"context\": {\"conversation_id\": \"conversationId\", \"system\": {\"mapKey\": \"anyValue\"}, \"metadata\": {\"deployment\": \"deployment\", \"user_id\": \"userId\"}}, \"output\": {\"nodes_visited\": [\"nodesVisited\"], \"nodes_visited_details\": [{\"dialog_node\": \"dialogNode\", \"title\": \"title\", \"conditions\": \"conditions\"}], \"log_messages\": [{\"level\": \"info\", \"msg\": \"msg\"}], \"text\": [\"text\"], \"generic\": [{\"response_type\": \"option\", \"title\": \"title\", \"description\": \"description\", \"preference\": \"dropdown\", \"options\": [{\"label\": \"label\", \"value\": {\"input\": {\"text\": \"text\", \"spelling_suggestions\": false, \"spelling_auto_correct\": false, \"suggested_text\": \"suggestedText\", \"original_text\": \"originalText\"}, \"intents\": [{\"intent\": \"intent\", \"confidence\": 10}], \"entities\": [{\"entity\": \"entity\", \"location\": [8], \"value\": \"value\", \"confidence\": 10, \"metadata\": {\"mapKey\": \"anyValue\"}, \"groups\": [{\"group\": \"group\", \"location\": [8]}], \"interpretation\": {\"calendar_type\": \"calendarType\", \"datetime_link\": \"datetimeLink\", \"festival\": \"festival\", \"granularity\": \"day\", \"range_link\": \"rangeLink\", \"range_modifier\": \"rangeModifier\", \"relative_day\": 11, \"relative_month\": 13, \"relative_week\": 12, \"relative_weekend\": 15, \"relative_year\": 12, \"specific_day\": 11, \"specific_day_of_week\": \"specificDayOfWeek\", \"specific_month\": 13, \"specific_quarter\": 15, \"specific_year\": 12, \"numeric_value\": 12, \"subtype\": \"subtype\", \"part_of_day\": \"partOfDay\", \"relative_hour\": 12, \"relative_minute\": 14, \"relative_second\": 14, \"specific_hour\": 12, \"specific_minute\": 14, \"specific_second\": 14, \"timezone\": \"timezone\"}, \"alternatives\": [{\"value\": \"value\", \"confidence\": 10}], \"role\": {\"type\": \"date_from\"}}]}}]}]}, \"actions\": [{\"name\": \"name\", \"type\": \"client\", \"parameters\": {\"mapKey\": \"anyValue\"}, \"result_variable\": \"resultVariable\", \"credentials\": \"credentials\"}]}, \"log_id\": \"logId\", \"request_timestamp\": \"requestTimestamp\", \"response_timestamp\": \"responseTimestamp\", \"workspace_id\": \"workspaceId\", \"language\": \"language\"}], \"pagination\": {\"next_url\": \"nextUrl\", \"matched\": 7, \"next_cursor\": \"nextCursor\"}}"; + String listLogsPath = "/v1/workspaces/testString/logs"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the ListLogsOptions model + ListLogsOptions listLogsOptionsModel = + new ListLogsOptions.Builder() + .workspaceId("testString") + .sort("testString") + .filter("testString") + .pageLimit(Long.valueOf("26")) + .cursor("testString") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = assistantService.listLogs(listLogsOptionsModel).execute(); + assertNotNull(response); + LogCollection responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(query.get("sort"), "testString"); + assertEquals(query.get("filter"), "testString"); + assertEquals(Long.valueOf(query.get("page_limit")), Long.valueOf("26")); + assertEquals(query.get("cursor"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listLogsPath); + } + + // Test the listLogs operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListLogsNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + assistantService.listLogs(null).execute(); + } + + @Test + public void testListAllLogsWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"logs\": [{\"request\": {\"input\": {\"text\": \"text\", \"spelling_suggestions\": false, \"spelling_auto_correct\": false, \"suggested_text\": \"suggestedText\", \"original_text\": \"originalText\"}, \"intents\": [{\"intent\": \"intent\", \"confidence\": 10}], \"entities\": [{\"entity\": \"entity\", \"location\": [8], \"value\": \"value\", \"confidence\": 10, \"metadata\": {\"mapKey\": \"anyValue\"}, \"groups\": [{\"group\": \"group\", \"location\": [8]}], \"interpretation\": {\"calendar_type\": \"calendarType\", \"datetime_link\": \"datetimeLink\", \"festival\": \"festival\", \"granularity\": \"day\", \"range_link\": \"rangeLink\", \"range_modifier\": \"rangeModifier\", \"relative_day\": 11, \"relative_month\": 13, \"relative_week\": 12, \"relative_weekend\": 15, \"relative_year\": 12, \"specific_day\": 11, \"specific_day_of_week\": \"specificDayOfWeek\", \"specific_month\": 13, \"specific_quarter\": 15, \"specific_year\": 12, \"numeric_value\": 12, \"subtype\": \"subtype\", \"part_of_day\": \"partOfDay\", \"relative_hour\": 12, \"relative_minute\": 14, \"relative_second\": 14, \"specific_hour\": 12, \"specific_minute\": 14, \"specific_second\": 14, \"timezone\": \"timezone\"}, \"alternatives\": [{\"value\": \"value\", \"confidence\": 10}], \"role\": {\"type\": \"date_from\"}}], \"alternate_intents\": true, \"context\": {\"conversation_id\": \"conversationId\", \"system\": {\"mapKey\": \"anyValue\"}, \"metadata\": {\"deployment\": \"deployment\", \"user_id\": \"userId\"}}, \"output\": {\"nodes_visited\": [\"nodesVisited\"], \"nodes_visited_details\": [{\"dialog_node\": \"dialogNode\", \"title\": \"title\", \"conditions\": \"conditions\"}], \"log_messages\": [{\"level\": \"info\", \"msg\": \"msg\"}], \"text\": [\"text\"], \"generic\": [{\"response_type\": \"option\", \"title\": \"title\", \"description\": \"description\", \"preference\": \"dropdown\", \"options\": [{\"label\": \"label\", \"value\": {\"input\": {\"text\": \"text\", \"spelling_suggestions\": false, \"spelling_auto_correct\": false, \"suggested_text\": \"suggestedText\", \"original_text\": \"originalText\"}, \"intents\": [{\"intent\": \"intent\", \"confidence\": 10}], \"entities\": [{\"entity\": \"entity\", \"location\": [8], \"value\": \"value\", \"confidence\": 10, \"metadata\": {\"mapKey\": \"anyValue\"}, \"groups\": [{\"group\": \"group\", \"location\": [8]}], \"interpretation\": {\"calendar_type\": \"calendarType\", \"datetime_link\": \"datetimeLink\", \"festival\": \"festival\", \"granularity\": \"day\", \"range_link\": \"rangeLink\", \"range_modifier\": \"rangeModifier\", \"relative_day\": 11, \"relative_month\": 13, \"relative_week\": 12, \"relative_weekend\": 15, \"relative_year\": 12, \"specific_day\": 11, \"specific_day_of_week\": \"specificDayOfWeek\", \"specific_month\": 13, \"specific_quarter\": 15, \"specific_year\": 12, \"numeric_value\": 12, \"subtype\": \"subtype\", \"part_of_day\": \"partOfDay\", \"relative_hour\": 12, \"relative_minute\": 14, \"relative_second\": 14, \"specific_hour\": 12, \"specific_minute\": 14, \"specific_second\": 14, \"timezone\": \"timezone\"}, \"alternatives\": [{\"value\": \"value\", \"confidence\": 10}], \"role\": {\"type\": \"date_from\"}}]}}]}]}, \"actions\": [{\"name\": \"name\", \"type\": \"client\", \"parameters\": {\"mapKey\": \"anyValue\"}, \"result_variable\": \"resultVariable\", \"credentials\": \"credentials\"}]}, \"response\": {\"input\": {\"text\": \"text\", \"spelling_suggestions\": false, \"spelling_auto_correct\": false, \"suggested_text\": \"suggestedText\", \"original_text\": \"originalText\"}, \"intents\": [{\"intent\": \"intent\", \"confidence\": 10}], \"entities\": [{\"entity\": \"entity\", \"location\": [8], \"value\": \"value\", \"confidence\": 10, \"metadata\": {\"mapKey\": \"anyValue\"}, \"groups\": [{\"group\": \"group\", \"location\": [8]}], \"interpretation\": {\"calendar_type\": \"calendarType\", \"datetime_link\": \"datetimeLink\", \"festival\": \"festival\", \"granularity\": \"day\", \"range_link\": \"rangeLink\", \"range_modifier\": \"rangeModifier\", \"relative_day\": 11, \"relative_month\": 13, \"relative_week\": 12, \"relative_weekend\": 15, \"relative_year\": 12, \"specific_day\": 11, \"specific_day_of_week\": \"specificDayOfWeek\", \"specific_month\": 13, \"specific_quarter\": 15, \"specific_year\": 12, \"numeric_value\": 12, \"subtype\": \"subtype\", \"part_of_day\": \"partOfDay\", \"relative_hour\": 12, \"relative_minute\": 14, \"relative_second\": 14, \"specific_hour\": 12, \"specific_minute\": 14, \"specific_second\": 14, \"timezone\": \"timezone\"}, \"alternatives\": [{\"value\": \"value\", \"confidence\": 10}], \"role\": {\"type\": \"date_from\"}}], \"alternate_intents\": true, \"context\": {\"conversation_id\": \"conversationId\", \"system\": {\"mapKey\": \"anyValue\"}, \"metadata\": {\"deployment\": \"deployment\", \"user_id\": \"userId\"}}, \"output\": {\"nodes_visited\": [\"nodesVisited\"], \"nodes_visited_details\": [{\"dialog_node\": \"dialogNode\", \"title\": \"title\", \"conditions\": \"conditions\"}], \"log_messages\": [{\"level\": \"info\", \"msg\": \"msg\"}], \"text\": [\"text\"], \"generic\": [{\"response_type\": \"option\", \"title\": \"title\", \"description\": \"description\", \"preference\": \"dropdown\", \"options\": [{\"label\": \"label\", \"value\": {\"input\": {\"text\": \"text\", \"spelling_suggestions\": false, \"spelling_auto_correct\": false, \"suggested_text\": \"suggestedText\", \"original_text\": \"originalText\"}, \"intents\": [{\"intent\": \"intent\", \"confidence\": 10}], \"entities\": [{\"entity\": \"entity\", \"location\": [8], \"value\": \"value\", \"confidence\": 10, \"metadata\": {\"mapKey\": \"anyValue\"}, \"groups\": [{\"group\": \"group\", \"location\": [8]}], \"interpretation\": {\"calendar_type\": \"calendarType\", \"datetime_link\": \"datetimeLink\", \"festival\": \"festival\", \"granularity\": \"day\", \"range_link\": \"rangeLink\", \"range_modifier\": \"rangeModifier\", \"relative_day\": 11, \"relative_month\": 13, \"relative_week\": 12, \"relative_weekend\": 15, \"relative_year\": 12, \"specific_day\": 11, \"specific_day_of_week\": \"specificDayOfWeek\", \"specific_month\": 13, \"specific_quarter\": 15, \"specific_year\": 12, \"numeric_value\": 12, \"subtype\": \"subtype\", \"part_of_day\": \"partOfDay\", \"relative_hour\": 12, \"relative_minute\": 14, \"relative_second\": 14, \"specific_hour\": 12, \"specific_minute\": 14, \"specific_second\": 14, \"timezone\": \"timezone\"}, \"alternatives\": [{\"value\": \"value\", \"confidence\": 10}], \"role\": {\"type\": \"date_from\"}}]}}]}]}, \"actions\": [{\"name\": \"name\", \"type\": \"client\", \"parameters\": {\"mapKey\": \"anyValue\"}, \"result_variable\": \"resultVariable\", \"credentials\": \"credentials\"}]}, \"log_id\": \"logId\", \"request_timestamp\": \"requestTimestamp\", \"response_timestamp\": \"responseTimestamp\", \"workspace_id\": \"workspaceId\", \"language\": \"language\"}], \"pagination\": {\"next_url\": \"nextUrl\", \"matched\": 7, \"next_cursor\": \"nextCursor\"}}"; + String listAllLogsPath = "/v1/logs"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the ListAllLogsOptions model + ListAllLogsOptions listAllLogsOptionsModel = + new ListAllLogsOptions.Builder() + .filter("testString") + .sort("testString") + .pageLimit(Long.valueOf("26")) + .cursor("testString") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + assistantService.listAllLogs(listAllLogsOptionsModel).execute(); + assertNotNull(response); + LogCollection responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(query.get("filter"), "testString"); + assertEquals(query.get("sort"), "testString"); + assertEquals(Long.valueOf(query.get("page_limit")), Long.valueOf("26")); + assertEquals(query.get("cursor"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listAllLogsPath); + } + + // Test the listAllLogs operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListAllLogsNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + assistantService.listAllLogs(null).execute(); + } + + @Test + public void testDeleteUserDataWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String deleteUserDataPath = "/v1/user_data"; + + server.enqueue(new MockResponse().setResponseCode(202).setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the DeleteUserDataOptions model + DeleteUserDataOptions deleteUserDataOptionsModel = + new DeleteUserDataOptions.Builder().customerId("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = assistantService.deleteUserData(deleteUserDataOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(query.get("customer_id"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteUserDataPath); + } + + // Test the deleteUserData operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteUserDataNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + assistantService.deleteUserData(null).execute(); + } + + @Test + public void testBulkClassifyWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"output\": [{\"input\": {\"text\": \"text\"}, \"entities\": [{\"entity\": \"entity\", \"location\": [8], \"value\": \"value\", \"confidence\": 10, \"metadata\": {\"mapKey\": \"anyValue\"}, \"groups\": [{\"group\": \"group\", \"location\": [8]}], \"interpretation\": {\"calendar_type\": \"calendarType\", \"datetime_link\": \"datetimeLink\", \"festival\": \"festival\", \"granularity\": \"day\", \"range_link\": \"rangeLink\", \"range_modifier\": \"rangeModifier\", \"relative_day\": 11, \"relative_month\": 13, \"relative_week\": 12, \"relative_weekend\": 15, \"relative_year\": 12, \"specific_day\": 11, \"specific_day_of_week\": \"specificDayOfWeek\", \"specific_month\": 13, \"specific_quarter\": 15, \"specific_year\": 12, \"numeric_value\": 12, \"subtype\": \"subtype\", \"part_of_day\": \"partOfDay\", \"relative_hour\": 12, \"relative_minute\": 14, \"relative_second\": 14, \"specific_hour\": 12, \"specific_minute\": 14, \"specific_second\": 14, \"timezone\": \"timezone\"}, \"alternatives\": [{\"value\": \"value\", \"confidence\": 10}], \"role\": {\"type\": \"date_from\"}}], \"intents\": [{\"intent\": \"intent\", \"confidence\": 10}]}]}"; + String bulkClassifyPath = "/v1/workspaces/testString/bulk_classify"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the BulkClassifyUtterance model + BulkClassifyUtterance bulkClassifyUtteranceModel = + new BulkClassifyUtterance.Builder().text("testString").build(); + + // Construct an instance of the BulkClassifyOptions model + BulkClassifyOptions bulkClassifyOptionsModel = + new BulkClassifyOptions.Builder() + .workspaceId("testString") + .input( + new java.util.ArrayList( + java.util.Arrays.asList(bulkClassifyUtteranceModel))) + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + assistantService.bulkClassify(bulkClassifyOptionsModel).execute(); + assertNotNull(response); + BulkClassifyResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, bulkClassifyPath); + } + + // Test the bulkClassify operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testBulkClassifyNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + assistantService.bulkClassify(null).execute(); + } + + /** Initialize the server */ + @BeforeMethod + public void setUpMockServer() { + try { + server = new MockWebServer(); + // register handler + server.start(); + } catch (IOException err) { + fail("Failed to instantiate mock web server"); + } + } + + @AfterMethod + public void tearDownMockServer() throws IOException { + server.shutdown(); + assistantService = null; } } diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/BulkClassifyOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/BulkClassifyOptionsTest.java new file mode 100644 index 00000000000..0a9a95dac01 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/BulkClassifyOptionsTest.java @@ -0,0 +1,55 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the BulkClassifyOptions model. */ +public class BulkClassifyOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testBulkClassifyOptions() throws Throwable { + BulkClassifyUtterance bulkClassifyUtteranceModel = + new BulkClassifyUtterance.Builder().text("testString").build(); + assertEquals(bulkClassifyUtteranceModel.text(), "testString"); + + BulkClassifyOptions bulkClassifyOptionsModel = + new BulkClassifyOptions.Builder() + .workspaceId("testString") + .input( + new java.util.ArrayList( + java.util.Arrays.asList(bulkClassifyUtteranceModel))) + .build(); + assertEquals(bulkClassifyOptionsModel.workspaceId(), "testString"); + assertEquals( + bulkClassifyOptionsModel.input(), + new java.util.ArrayList( + java.util.Arrays.asList(bulkClassifyUtteranceModel))); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testBulkClassifyOptionsError() throws Throwable { + new BulkClassifyOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/BulkClassifyOutputTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/BulkClassifyOutputTest.java new file mode 100644 index 00000000000..dc8b601d3dd --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/BulkClassifyOutputTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the BulkClassifyOutput model. */ +public class BulkClassifyOutputTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testBulkClassifyOutput() throws Throwable { + BulkClassifyOutput bulkClassifyOutputModel = new BulkClassifyOutput(); + assertNull(bulkClassifyOutputModel.getInput()); + assertNull(bulkClassifyOutputModel.getEntities()); + assertNull(bulkClassifyOutputModel.getIntents()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/BulkClassifyResponseTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/BulkClassifyResponseTest.java new file mode 100644 index 00000000000..d4cc84c09a4 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/BulkClassifyResponseTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the BulkClassifyResponse model. */ +public class BulkClassifyResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testBulkClassifyResponse() throws Throwable { + BulkClassifyResponse bulkClassifyResponseModel = new BulkClassifyResponse(); + assertNull(bulkClassifyResponseModel.getOutput()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/BulkClassifyUtteranceTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/BulkClassifyUtteranceTest.java new file mode 100644 index 00000000000..814a0f698c5 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/BulkClassifyUtteranceTest.java @@ -0,0 +1,49 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the BulkClassifyUtterance model. */ +public class BulkClassifyUtteranceTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testBulkClassifyUtterance() throws Throwable { + BulkClassifyUtterance bulkClassifyUtteranceModel = + new BulkClassifyUtterance.Builder().text("testString").build(); + assertEquals(bulkClassifyUtteranceModel.text(), "testString"); + + String json = TestUtilities.serialize(bulkClassifyUtteranceModel); + + BulkClassifyUtterance bulkClassifyUtteranceModelNew = + TestUtilities.deserialize(json, BulkClassifyUtterance.class); + assertTrue(bulkClassifyUtteranceModelNew instanceof BulkClassifyUtterance); + assertEquals(bulkClassifyUtteranceModelNew.text(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testBulkClassifyUtteranceError() throws Throwable { + new BulkClassifyUtterance.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CaptureGroupTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CaptureGroupTest.java new file mode 100644 index 00000000000..c098a595e28 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CaptureGroupTest.java @@ -0,0 +1,54 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CaptureGroup model. */ +public class CaptureGroupTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCaptureGroup() throws Throwable { + CaptureGroup captureGroupModel = + new CaptureGroup.Builder() + .group("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) + .build(); + assertEquals(captureGroupModel.group(), "testString"); + assertEquals( + captureGroupModel.location(), + new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))); + + String json = TestUtilities.serialize(captureGroupModel); + + CaptureGroup captureGroupModelNew = TestUtilities.deserialize(json, CaptureGroup.class); + assertTrue(captureGroupModelNew instanceof CaptureGroup); + assertEquals(captureGroupModelNew.group(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCaptureGroupError() throws Throwable { + new CaptureGroup.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ContextTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ContextTest.java new file mode 100644 index 00000000000..3bf740ff0bf --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ContextTest.java @@ -0,0 +1,69 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Context model. */ +public class ContextTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testContext() throws Throwable { + MessageContextMetadata messageContextMetadataModel = + new MessageContextMetadata.Builder().deployment("testString").userId("testString").build(); + assertEquals(messageContextMetadataModel.deployment(), "testString"); + assertEquals(messageContextMetadataModel.userId(), "testString"); + + Context contextModel = + new Context.Builder() + .conversationId("testString") + .system( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .metadata(messageContextMetadataModel) + .add("foo", "testString") + .build(); + assertEquals(contextModel.getConversationId(), "testString"); + assertEquals( + contextModel.getSystem(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals(contextModel.getMetadata(), messageContextMetadataModel); + assertEquals(contextModel.get("foo"), "testString"); + + String json = TestUtilities.serialize(contextModel); + + Context contextModelNew = TestUtilities.deserialize(json, Context.class); + assertTrue(contextModelNew instanceof Context); + assertEquals(contextModelNew.getConversationId(), "testString"); + assertEquals(contextModelNew.getMetadata().toString(), messageContextMetadataModel.toString()); + assertEquals(contextModelNew.get("foo"), "testString"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CounterexampleCollectionTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CounterexampleCollectionTest.java new file mode 100644 index 00000000000..400b8a58445 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CounterexampleCollectionTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CounterexampleCollection model. */ +public class CounterexampleCollectionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCounterexampleCollection() throws Throwable { + CounterexampleCollection counterexampleCollectionModel = new CounterexampleCollection(); + assertNull(counterexampleCollectionModel.getCounterexamples()); + assertNull(counterexampleCollectionModel.getPagination()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CounterexampleTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CounterexampleTest.java new file mode 100644 index 00000000000..4e8a74fdaae --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CounterexampleTest.java @@ -0,0 +1,47 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Counterexample model. */ +public class CounterexampleTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCounterexample() throws Throwable { + Counterexample counterexampleModel = new Counterexample.Builder().text("testString").build(); + assertEquals(counterexampleModel.text(), "testString"); + + String json = TestUtilities.serialize(counterexampleModel); + + Counterexample counterexampleModelNew = TestUtilities.deserialize(json, Counterexample.class); + assertTrue(counterexampleModelNew instanceof Counterexample); + assertEquals(counterexampleModelNew.text(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCounterexampleError() throws Throwable { + new Counterexample.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateCounterexampleOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateCounterexampleOptionsTest.java new file mode 100644 index 00000000000..fdd5812fa2c --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateCounterexampleOptionsTest.java @@ -0,0 +1,48 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateCounterexampleOptions model. */ +public class CreateCounterexampleOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateCounterexampleOptions() throws Throwable { + CreateCounterexampleOptions createCounterexampleOptionsModel = + new CreateCounterexampleOptions.Builder() + .workspaceId("testString") + .text("testString") + .includeAudit(true) + .build(); + assertEquals(createCounterexampleOptionsModel.workspaceId(), "testString"); + assertEquals(createCounterexampleOptionsModel.text(), "testString"); + assertEquals(createCounterexampleOptionsModel.includeAudit(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateCounterexampleOptionsError() throws Throwable { + new CreateCounterexampleOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateDialogNodeOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateDialogNodeOptionsTest.java new file mode 100644 index 00000000000..df07b093a06 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateDialogNodeOptionsTest.java @@ -0,0 +1,224 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.testng.annotations.Test; + +/** Unit test class for the CreateDialogNodeOptions model. */ +public class CreateDialogNodeOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateDialogNodeOptions() throws Throwable { + DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill dialogNodeOutputGenericModel = + new DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill.Builder() + .responseType("search_skill") + .query("testString") + .queryType("natural_language") + .filter("testString") + .discoveryVersion("testString") + .build(); + assertEquals(dialogNodeOutputGenericModel.responseType(), "search_skill"); + assertEquals(dialogNodeOutputGenericModel.query(), "testString"); + assertEquals(dialogNodeOutputGenericModel.queryType(), "natural_language"); + assertEquals(dialogNodeOutputGenericModel.filter(), "testString"); + assertEquals(dialogNodeOutputGenericModel.discoveryVersion(), "testString"); + + DialogNodeOutputModifiers dialogNodeOutputModifiersModel = + new DialogNodeOutputModifiers.Builder().overwrite(true).build(); + assertEquals(dialogNodeOutputModifiersModel.overwrite(), Boolean.valueOf(true)); + + DialogNodeOutput dialogNodeOutputModel = + new DialogNodeOutput.Builder() + .generic( + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeOutputGenericModel))) + .integrations( + new java.util.HashMap>() { + { + put( + "foo", + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + } + }) + .modifiers(dialogNodeOutputModifiersModel) + .add("foo", "testString") + .build(); + assertEquals( + dialogNodeOutputModel.getGeneric(), + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeOutputGenericModel))); + assertEquals( + dialogNodeOutputModel.getIntegrations(), + new java.util.HashMap>() { + { + put( + "foo", + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + } + }); + assertEquals(dialogNodeOutputModel.getModifiers(), dialogNodeOutputModifiersModel); + assertEquals(dialogNodeOutputModel.get("foo"), "testString"); + + DialogNodeContext dialogNodeContextModel = + new DialogNodeContext.Builder() + .integrations( + new java.util.HashMap>() { + { + put( + "foo", + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + } + }) + .add("foo", "testString") + .build(); + assertEquals( + dialogNodeContextModel.getIntegrations(), + new java.util.HashMap>() { + { + put( + "foo", + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + } + }); + assertEquals(dialogNodeContextModel.get("foo"), "testString"); + + DialogNodeNextStep dialogNodeNextStepModel = + new DialogNodeNextStep.Builder() + .behavior("get_user_input") + .dialogNode("testString") + .selector("condition") + .build(); + assertEquals(dialogNodeNextStepModel.behavior(), "get_user_input"); + assertEquals(dialogNodeNextStepModel.dialogNode(), "testString"); + assertEquals(dialogNodeNextStepModel.selector(), "condition"); + + DialogNodeAction dialogNodeActionModel = + new DialogNodeAction.Builder() + .name("testString") + .type("client") + .parameters( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .resultVariable("testString") + .credentials("testString") + .build(); + assertEquals(dialogNodeActionModel.name(), "testString"); + assertEquals(dialogNodeActionModel.type(), "client"); + assertEquals( + dialogNodeActionModel.parameters(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals(dialogNodeActionModel.resultVariable(), "testString"); + assertEquals(dialogNodeActionModel.credentials(), "testString"); + + CreateDialogNodeOptions createDialogNodeOptionsModel = + new CreateDialogNodeOptions.Builder() + .workspaceId("testString") + .dialogNode("testString") + .description("testString") + .conditions("testString") + .parent("testString") + .previousSibling("testString") + .output(dialogNodeOutputModel) + .context(dialogNodeContextModel) + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .nextStep(dialogNodeNextStepModel) + .title("testString") + .type("standard") + .eventName("focus") + .variable("testString") + .actions( + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeActionModel))) + .digressIn("not_available") + .digressOut("allow_returning") + .digressOutSlots("not_allowed") + .userLabel("testString") + .disambiguationOptOut(true) + .includeAudit(true) + .build(); + assertEquals(createDialogNodeOptionsModel.workspaceId(), "testString"); + assertEquals(createDialogNodeOptionsModel.dialogNode(), "testString"); + assertEquals(createDialogNodeOptionsModel.description(), "testString"); + assertEquals(createDialogNodeOptionsModel.conditions(), "testString"); + assertEquals(createDialogNodeOptionsModel.parent(), "testString"); + assertEquals(createDialogNodeOptionsModel.previousSibling(), "testString"); + assertEquals(createDialogNodeOptionsModel.output(), dialogNodeOutputModel); + assertEquals(createDialogNodeOptionsModel.context(), dialogNodeContextModel); + assertEquals( + createDialogNodeOptionsModel.metadata(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals(createDialogNodeOptionsModel.nextStep(), dialogNodeNextStepModel); + assertEquals(createDialogNodeOptionsModel.title(), "testString"); + assertEquals(createDialogNodeOptionsModel.type(), "standard"); + assertEquals(createDialogNodeOptionsModel.eventName(), "focus"); + assertEquals(createDialogNodeOptionsModel.variable(), "testString"); + assertEquals( + createDialogNodeOptionsModel.actions(), + new java.util.ArrayList(java.util.Arrays.asList(dialogNodeActionModel))); + assertEquals(createDialogNodeOptionsModel.digressIn(), "not_available"); + assertEquals(createDialogNodeOptionsModel.digressOut(), "allow_returning"); + assertEquals(createDialogNodeOptionsModel.digressOutSlots(), "not_allowed"); + assertEquals(createDialogNodeOptionsModel.userLabel(), "testString"); + assertEquals(createDialogNodeOptionsModel.disambiguationOptOut(), Boolean.valueOf(true)); + assertEquals(createDialogNodeOptionsModel.includeAudit(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateDialogNodeOptionsError() throws Throwable { + new CreateDialogNodeOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateEntityOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateEntityOptionsTest.java new file mode 100644 index 00000000000..bdfba7d8545 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateEntityOptionsTest.java @@ -0,0 +1,98 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateEntityOptions model. */ +public class CreateEntityOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateEntityOptions() throws Throwable { + CreateValue createValueModel = + new CreateValue.Builder() + .value("testString") + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .type("synonyms") + .synonyms(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .patterns(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals(createValueModel.value(), "testString"); + assertEquals( + createValueModel.metadata(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals(createValueModel.type(), "synonyms"); + assertEquals( + createValueModel.synonyms(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals( + createValueModel.patterns(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + CreateEntityOptions createEntityOptionsModel = + new CreateEntityOptions.Builder() + .workspaceId("testString") + .entity("testString") + .description("testString") + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .fuzzyMatch(true) + .values(new java.util.ArrayList(java.util.Arrays.asList(createValueModel))) + .includeAudit(true) + .build(); + assertEquals(createEntityOptionsModel.workspaceId(), "testString"); + assertEquals(createEntityOptionsModel.entity(), "testString"); + assertEquals(createEntityOptionsModel.description(), "testString"); + assertEquals( + createEntityOptionsModel.metadata(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals(createEntityOptionsModel.fuzzyMatch(), Boolean.valueOf(true)); + assertEquals( + createEntityOptionsModel.values(), + new java.util.ArrayList(java.util.Arrays.asList(createValueModel))); + assertEquals(createEntityOptionsModel.includeAudit(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateEntityOptionsError() throws Throwable { + new CreateEntityOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateEntityTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateEntityTest.java new file mode 100644 index 00000000000..5323f811f4d --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateEntityTest.java @@ -0,0 +1,102 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateEntity model. */ +public class CreateEntityTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateEntity() throws Throwable { + CreateValue createValueModel = + new CreateValue.Builder() + .value("testString") + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .type("synonyms") + .synonyms(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .patterns(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals(createValueModel.value(), "testString"); + assertEquals( + createValueModel.metadata(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals(createValueModel.type(), "synonyms"); + assertEquals( + createValueModel.synonyms(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals( + createValueModel.patterns(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + CreateEntity createEntityModel = + new CreateEntity.Builder() + .entity("testString") + .description("testString") + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .fuzzyMatch(true) + .values(new java.util.ArrayList(java.util.Arrays.asList(createValueModel))) + .build(); + assertEquals(createEntityModel.entity(), "testString"); + assertEquals(createEntityModel.description(), "testString"); + assertEquals( + createEntityModel.metadata(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals(createEntityModel.fuzzyMatch(), Boolean.valueOf(true)); + assertEquals( + createEntityModel.values(), + new java.util.ArrayList(java.util.Arrays.asList(createValueModel))); + + String json = TestUtilities.serialize(createEntityModel); + + CreateEntity createEntityModelNew = TestUtilities.deserialize(json, CreateEntity.class); + assertTrue(createEntityModelNew instanceof CreateEntity); + assertEquals(createEntityModelNew.entity(), "testString"); + assertEquals(createEntityModelNew.description(), "testString"); + assertEquals(createEntityModelNew.fuzzyMatch(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateEntityError() throws Throwable { + new CreateEntity.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateExampleOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateExampleOptionsTest.java new file mode 100644 index 00000000000..22e9b32e624 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateExampleOptionsTest.java @@ -0,0 +1,64 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateExampleOptions model. */ +public class CreateExampleOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateExampleOptions() throws Throwable { + Mention mentionModel = + new Mention.Builder() + .entity("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) + .build(); + assertEquals(mentionModel.entity(), "testString"); + assertEquals( + mentionModel.location(), + new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))); + + CreateExampleOptions createExampleOptionsModel = + new CreateExampleOptions.Builder() + .workspaceId("testString") + .intent("testString") + .text("testString") + .mentions(new java.util.ArrayList(java.util.Arrays.asList(mentionModel))) + .includeAudit(true) + .build(); + assertEquals(createExampleOptionsModel.workspaceId(), "testString"); + assertEquals(createExampleOptionsModel.intent(), "testString"); + assertEquals(createExampleOptionsModel.text(), "testString"); + assertEquals( + createExampleOptionsModel.mentions(), + new java.util.ArrayList(java.util.Arrays.asList(mentionModel))); + assertEquals(createExampleOptionsModel.includeAudit(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateExampleOptionsError() throws Throwable { + new CreateExampleOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateIntentOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateIntentOptionsTest.java new file mode 100644 index 00000000000..aab0a588a86 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateIntentOptionsTest.java @@ -0,0 +1,74 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateIntentOptions model. */ +public class CreateIntentOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateIntentOptions() throws Throwable { + Mention mentionModel = + new Mention.Builder() + .entity("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) + .build(); + assertEquals(mentionModel.entity(), "testString"); + assertEquals( + mentionModel.location(), + new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))); + + Example exampleModel = + new Example.Builder() + .text("testString") + .mentions(new java.util.ArrayList(java.util.Arrays.asList(mentionModel))) + .build(); + assertEquals(exampleModel.text(), "testString"); + assertEquals( + exampleModel.mentions(), + new java.util.ArrayList(java.util.Arrays.asList(mentionModel))); + + CreateIntentOptions createIntentOptionsModel = + new CreateIntentOptions.Builder() + .workspaceId("testString") + .intent("testString") + .description("testString") + .examples(new java.util.ArrayList(java.util.Arrays.asList(exampleModel))) + .includeAudit(true) + .build(); + assertEquals(createIntentOptionsModel.workspaceId(), "testString"); + assertEquals(createIntentOptionsModel.intent(), "testString"); + assertEquals(createIntentOptionsModel.description(), "testString"); + assertEquals( + createIntentOptionsModel.examples(), + new java.util.ArrayList(java.util.Arrays.asList(exampleModel))); + assertEquals(createIntentOptionsModel.includeAudit(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateIntentOptionsError() throws Throwable { + new CreateIntentOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateIntentTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateIntentTest.java new file mode 100644 index 00000000000..cf80d44d7a2 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateIntentTest.java @@ -0,0 +1,77 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateIntent model. */ +public class CreateIntentTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateIntent() throws Throwable { + Mention mentionModel = + new Mention.Builder() + .entity("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) + .build(); + assertEquals(mentionModel.entity(), "testString"); + assertEquals( + mentionModel.location(), + new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))); + + Example exampleModel = + new Example.Builder() + .text("testString") + .mentions(new java.util.ArrayList(java.util.Arrays.asList(mentionModel))) + .build(); + assertEquals(exampleModel.text(), "testString"); + assertEquals( + exampleModel.mentions(), + new java.util.ArrayList(java.util.Arrays.asList(mentionModel))); + + CreateIntent createIntentModel = + new CreateIntent.Builder() + .intent("testString") + .description("testString") + .examples(new java.util.ArrayList(java.util.Arrays.asList(exampleModel))) + .build(); + assertEquals(createIntentModel.intent(), "testString"); + assertEquals(createIntentModel.description(), "testString"); + assertEquals( + createIntentModel.examples(), + new java.util.ArrayList(java.util.Arrays.asList(exampleModel))); + + String json = TestUtilities.serialize(createIntentModel); + + CreateIntent createIntentModelNew = TestUtilities.deserialize(json, CreateIntent.class); + assertTrue(createIntentModelNew instanceof CreateIntent); + assertEquals(createIntentModelNew.intent(), "testString"); + assertEquals(createIntentModelNew.description(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateIntentError() throws Throwable { + new CreateIntent.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateSynonymOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateSynonymOptionsTest.java new file mode 100644 index 00000000000..191fa90b08a --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateSynonymOptionsTest.java @@ -0,0 +1,52 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateSynonymOptions model. */ +public class CreateSynonymOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateSynonymOptions() throws Throwable { + CreateSynonymOptions createSynonymOptionsModel = + new CreateSynonymOptions.Builder() + .workspaceId("testString") + .entity("testString") + .value("testString") + .synonym("testString") + .includeAudit(true) + .build(); + assertEquals(createSynonymOptionsModel.workspaceId(), "testString"); + assertEquals(createSynonymOptionsModel.entity(), "testString"); + assertEquals(createSynonymOptionsModel.value(), "testString"); + assertEquals(createSynonymOptionsModel.synonym(), "testString"); + assertEquals(createSynonymOptionsModel.includeAudit(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateSynonymOptionsError() throws Throwable { + new CreateSynonymOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateValueOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateValueOptionsTest.java new file mode 100644 index 00000000000..fb3d24d9138 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateValueOptionsTest.java @@ -0,0 +1,73 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateValueOptions model. */ +public class CreateValueOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateValueOptions() throws Throwable { + CreateValueOptions createValueOptionsModel = + new CreateValueOptions.Builder() + .workspaceId("testString") + .entity("testString") + .value("testString") + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .type("synonyms") + .synonyms(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .patterns(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .includeAudit(true) + .build(); + assertEquals(createValueOptionsModel.workspaceId(), "testString"); + assertEquals(createValueOptionsModel.entity(), "testString"); + assertEquals(createValueOptionsModel.value(), "testString"); + assertEquals( + createValueOptionsModel.metadata(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals(createValueOptionsModel.type(), "synonyms"); + assertEquals( + createValueOptionsModel.synonyms(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals( + createValueOptionsModel.patterns(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals(createValueOptionsModel.includeAudit(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateValueOptionsError() throws Throwable { + new CreateValueOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateValueTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateValueTest.java new file mode 100644 index 00000000000..0725270d8de --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateValueTest.java @@ -0,0 +1,74 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateValue model. */ +public class CreateValueTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateValue() throws Throwable { + CreateValue createValueModel = + new CreateValue.Builder() + .value("testString") + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .type("synonyms") + .synonyms(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .patterns(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals(createValueModel.value(), "testString"); + assertEquals( + createValueModel.metadata(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals(createValueModel.type(), "synonyms"); + assertEquals( + createValueModel.synonyms(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals( + createValueModel.patterns(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + String json = TestUtilities.serialize(createValueModel); + + CreateValue createValueModelNew = TestUtilities.deserialize(json, CreateValue.class); + assertTrue(createValueModelNew instanceof CreateValue); + assertEquals(createValueModelNew.value(), "testString"); + assertEquals(createValueModelNew.type(), "synonyms"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateValueError() throws Throwable { + new CreateValue.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateWorkspaceOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateWorkspaceOptionsTest.java new file mode 100644 index 00000000000..6948f544dae --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/CreateWorkspaceOptionsTest.java @@ -0,0 +1,440 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.testng.annotations.Test; + +/** Unit test class for the CreateWorkspaceOptions model. */ +public class CreateWorkspaceOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateWorkspaceOptions() throws Throwable { + DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill dialogNodeOutputGenericModel = + new DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill.Builder() + .responseType("search_skill") + .query("testString") + .queryType("natural_language") + .filter("testString") + .discoveryVersion("testString") + .build(); + assertEquals(dialogNodeOutputGenericModel.responseType(), "search_skill"); + assertEquals(dialogNodeOutputGenericModel.query(), "testString"); + assertEquals(dialogNodeOutputGenericModel.queryType(), "natural_language"); + assertEquals(dialogNodeOutputGenericModel.filter(), "testString"); + assertEquals(dialogNodeOutputGenericModel.discoveryVersion(), "testString"); + + DialogNodeOutputModifiers dialogNodeOutputModifiersModel = + new DialogNodeOutputModifiers.Builder().overwrite(true).build(); + assertEquals(dialogNodeOutputModifiersModel.overwrite(), Boolean.valueOf(true)); + + DialogNodeOutput dialogNodeOutputModel = + new DialogNodeOutput.Builder() + .generic( + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeOutputGenericModel))) + .integrations( + new java.util.HashMap>() { + { + put( + "foo", + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + } + }) + .modifiers(dialogNodeOutputModifiersModel) + .add("foo", "testString") + .build(); + assertEquals( + dialogNodeOutputModel.getGeneric(), + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeOutputGenericModel))); + assertEquals( + dialogNodeOutputModel.getIntegrations(), + new java.util.HashMap>() { + { + put( + "foo", + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + } + }); + assertEquals(dialogNodeOutputModel.getModifiers(), dialogNodeOutputModifiersModel); + assertEquals(dialogNodeOutputModel.get("foo"), "testString"); + + DialogNodeContext dialogNodeContextModel = + new DialogNodeContext.Builder() + .integrations( + new java.util.HashMap>() { + { + put( + "foo", + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + } + }) + .add("foo", "testString") + .build(); + assertEquals( + dialogNodeContextModel.getIntegrations(), + new java.util.HashMap>() { + { + put( + "foo", + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + } + }); + assertEquals(dialogNodeContextModel.get("foo"), "testString"); + + DialogNodeNextStep dialogNodeNextStepModel = + new DialogNodeNextStep.Builder() + .behavior("get_user_input") + .dialogNode("testString") + .selector("condition") + .build(); + assertEquals(dialogNodeNextStepModel.behavior(), "get_user_input"); + assertEquals(dialogNodeNextStepModel.dialogNode(), "testString"); + assertEquals(dialogNodeNextStepModel.selector(), "condition"); + + DialogNodeAction dialogNodeActionModel = + new DialogNodeAction.Builder() + .name("testString") + .type("client") + .parameters( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .resultVariable("testString") + .credentials("testString") + .build(); + assertEquals(dialogNodeActionModel.name(), "testString"); + assertEquals(dialogNodeActionModel.type(), "client"); + assertEquals( + dialogNodeActionModel.parameters(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals(dialogNodeActionModel.resultVariable(), "testString"); + assertEquals(dialogNodeActionModel.credentials(), "testString"); + + DialogNode dialogNodeModel = + new DialogNode.Builder() + .dialogNode("testString") + .description("testString") + .conditions("testString") + .parent("testString") + .previousSibling("testString") + .output(dialogNodeOutputModel) + .context(dialogNodeContextModel) + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .nextStep(dialogNodeNextStepModel) + .title("testString") + .type("standard") + .eventName("focus") + .variable("testString") + .actions( + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeActionModel))) + .digressIn("not_available") + .digressOut("allow_returning") + .digressOutSlots("not_allowed") + .userLabel("testString") + .disambiguationOptOut(true) + .build(); + assertEquals(dialogNodeModel.dialogNode(), "testString"); + assertEquals(dialogNodeModel.description(), "testString"); + assertEquals(dialogNodeModel.conditions(), "testString"); + assertEquals(dialogNodeModel.parent(), "testString"); + assertEquals(dialogNodeModel.previousSibling(), "testString"); + assertEquals(dialogNodeModel.output(), dialogNodeOutputModel); + assertEquals(dialogNodeModel.context(), dialogNodeContextModel); + assertEquals( + dialogNodeModel.metadata(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals(dialogNodeModel.nextStep(), dialogNodeNextStepModel); + assertEquals(dialogNodeModel.title(), "testString"); + assertEquals(dialogNodeModel.type(), "standard"); + assertEquals(dialogNodeModel.eventName(), "focus"); + assertEquals(dialogNodeModel.variable(), "testString"); + assertEquals( + dialogNodeModel.actions(), + new java.util.ArrayList(java.util.Arrays.asList(dialogNodeActionModel))); + assertEquals(dialogNodeModel.digressIn(), "not_available"); + assertEquals(dialogNodeModel.digressOut(), "allow_returning"); + assertEquals(dialogNodeModel.digressOutSlots(), "not_allowed"); + assertEquals(dialogNodeModel.userLabel(), "testString"); + assertEquals(dialogNodeModel.disambiguationOptOut(), Boolean.valueOf(true)); + + Counterexample counterexampleModel = new Counterexample.Builder().text("testString").build(); + assertEquals(counterexampleModel.text(), "testString"); + + WorkspaceSystemSettingsTooling workspaceSystemSettingsToolingModel = + new WorkspaceSystemSettingsTooling.Builder().storeGenericResponses(true).build(); + assertEquals( + workspaceSystemSettingsToolingModel.storeGenericResponses(), Boolean.valueOf(true)); + + WorkspaceSystemSettingsDisambiguation workspaceSystemSettingsDisambiguationModel = + new WorkspaceSystemSettingsDisambiguation.Builder() + .prompt("testString") + .noneOfTheAbovePrompt("testString") + .enabled(true) + .sensitivity("auto") + .randomize(true) + .maxSuggestions(Long.valueOf("1")) + .suggestionTextPolicy("testString") + .build(); + assertEquals(workspaceSystemSettingsDisambiguationModel.prompt(), "testString"); + assertEquals(workspaceSystemSettingsDisambiguationModel.noneOfTheAbovePrompt(), "testString"); + assertEquals(workspaceSystemSettingsDisambiguationModel.enabled(), Boolean.valueOf(true)); + assertEquals(workspaceSystemSettingsDisambiguationModel.sensitivity(), "auto"); + assertEquals(workspaceSystemSettingsDisambiguationModel.randomize(), Boolean.valueOf(true)); + assertEquals(workspaceSystemSettingsDisambiguationModel.maxSuggestions(), Long.valueOf("1")); + assertEquals(workspaceSystemSettingsDisambiguationModel.suggestionTextPolicy(), "testString"); + + WorkspaceSystemSettingsSystemEntities workspaceSystemSettingsSystemEntitiesModel = + new WorkspaceSystemSettingsSystemEntities.Builder().enabled(true).build(); + assertEquals(workspaceSystemSettingsSystemEntitiesModel.enabled(), Boolean.valueOf(true)); + + WorkspaceSystemSettingsOffTopic workspaceSystemSettingsOffTopicModel = + new WorkspaceSystemSettingsOffTopic.Builder().enabled(true).build(); + assertEquals(workspaceSystemSettingsOffTopicModel.enabled(), Boolean.valueOf(true)); + + WorkspaceSystemSettings workspaceSystemSettingsModel = + new WorkspaceSystemSettings.Builder() + .tooling(workspaceSystemSettingsToolingModel) + .disambiguation(workspaceSystemSettingsDisambiguationModel) + .humanAgentAssist( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .spellingSuggestions(true) + .spellingAutoCorrect(true) + .systemEntities(workspaceSystemSettingsSystemEntitiesModel) + .offTopic(workspaceSystemSettingsOffTopicModel) + .build(); + assertEquals(workspaceSystemSettingsModel.tooling(), workspaceSystemSettingsToolingModel); + assertEquals( + workspaceSystemSettingsModel.disambiguation(), workspaceSystemSettingsDisambiguationModel); + assertEquals( + workspaceSystemSettingsModel.humanAgentAssist(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals(workspaceSystemSettingsModel.spellingSuggestions(), Boolean.valueOf(true)); + assertEquals(workspaceSystemSettingsModel.spellingAutoCorrect(), Boolean.valueOf(true)); + assertEquals( + workspaceSystemSettingsModel.systemEntities(), workspaceSystemSettingsSystemEntitiesModel); + assertEquals(workspaceSystemSettingsModel.offTopic(), workspaceSystemSettingsOffTopicModel); + + WebhookHeader webhookHeaderModel = + new WebhookHeader.Builder().name("testString").value("testString").build(); + assertEquals(webhookHeaderModel.name(), "testString"); + assertEquals(webhookHeaderModel.value(), "testString"); + + Webhook webhookModel = + new Webhook.Builder() + .url("testString") + .name("testString") + .headers( + new java.util.ArrayList(java.util.Arrays.asList(webhookHeaderModel))) + .build(); + assertEquals(webhookModel.url(), "testString"); + assertEquals(webhookModel.name(), "testString"); + assertEquals( + webhookModel.headers(), + new java.util.ArrayList(java.util.Arrays.asList(webhookHeaderModel))); + + Mention mentionModel = + new Mention.Builder() + .entity("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) + .build(); + assertEquals(mentionModel.entity(), "testString"); + assertEquals( + mentionModel.location(), + new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))); + + Example exampleModel = + new Example.Builder() + .text("testString") + .mentions(new java.util.ArrayList(java.util.Arrays.asList(mentionModel))) + .build(); + assertEquals(exampleModel.text(), "testString"); + assertEquals( + exampleModel.mentions(), + new java.util.ArrayList(java.util.Arrays.asList(mentionModel))); + + CreateIntent createIntentModel = + new CreateIntent.Builder() + .intent("testString") + .description("testString") + .examples(new java.util.ArrayList(java.util.Arrays.asList(exampleModel))) + .build(); + assertEquals(createIntentModel.intent(), "testString"); + assertEquals(createIntentModel.description(), "testString"); + assertEquals( + createIntentModel.examples(), + new java.util.ArrayList(java.util.Arrays.asList(exampleModel))); + + CreateValue createValueModel = + new CreateValue.Builder() + .value("testString") + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .type("synonyms") + .synonyms(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .patterns(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals(createValueModel.value(), "testString"); + assertEquals( + createValueModel.metadata(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals(createValueModel.type(), "synonyms"); + assertEquals( + createValueModel.synonyms(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals( + createValueModel.patterns(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + CreateEntity createEntityModel = + new CreateEntity.Builder() + .entity("testString") + .description("testString") + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .fuzzyMatch(true) + .values(new java.util.ArrayList(java.util.Arrays.asList(createValueModel))) + .build(); + assertEquals(createEntityModel.entity(), "testString"); + assertEquals(createEntityModel.description(), "testString"); + assertEquals( + createEntityModel.metadata(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals(createEntityModel.fuzzyMatch(), Boolean.valueOf(true)); + assertEquals( + createEntityModel.values(), + new java.util.ArrayList(java.util.Arrays.asList(createValueModel))); + + CreateWorkspaceOptions createWorkspaceOptionsModel = + new CreateWorkspaceOptions.Builder() + .name("testString") + .description("testString") + .language("testString") + .dialogNodes( + new java.util.ArrayList(java.util.Arrays.asList(dialogNodeModel))) + .counterexamples( + new java.util.ArrayList( + java.util.Arrays.asList(counterexampleModel))) + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .learningOptOut(true) + .systemSettings(workspaceSystemSettingsModel) + .webhooks(new java.util.ArrayList(java.util.Arrays.asList(webhookModel))) + .intents( + new java.util.ArrayList(java.util.Arrays.asList(createIntentModel))) + .entities( + new java.util.ArrayList(java.util.Arrays.asList(createEntityModel))) + .includeAudit(true) + .build(); + assertEquals(createWorkspaceOptionsModel.name(), "testString"); + assertEquals(createWorkspaceOptionsModel.description(), "testString"); + assertEquals(createWorkspaceOptionsModel.language(), "testString"); + assertEquals( + createWorkspaceOptionsModel.dialogNodes(), + new java.util.ArrayList(java.util.Arrays.asList(dialogNodeModel))); + assertEquals( + createWorkspaceOptionsModel.counterexamples(), + new java.util.ArrayList(java.util.Arrays.asList(counterexampleModel))); + assertEquals( + createWorkspaceOptionsModel.metadata(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals(createWorkspaceOptionsModel.learningOptOut(), Boolean.valueOf(true)); + assertEquals(createWorkspaceOptionsModel.systemSettings(), workspaceSystemSettingsModel); + assertEquals( + createWorkspaceOptionsModel.webhooks(), + new java.util.ArrayList(java.util.Arrays.asList(webhookModel))); + assertEquals( + createWorkspaceOptionsModel.intents(), + new java.util.ArrayList(java.util.Arrays.asList(createIntentModel))); + assertEquals( + createWorkspaceOptionsModel.entities(), + new java.util.ArrayList(java.util.Arrays.asList(createEntityModel))); + assertEquals(createWorkspaceOptionsModel.includeAudit(), Boolean.valueOf(true)); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DeleteCounterexampleOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DeleteCounterexampleOptionsTest.java new file mode 100644 index 00000000000..51c586a9269 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DeleteCounterexampleOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteCounterexampleOptions model. */ +public class DeleteCounterexampleOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteCounterexampleOptions() throws Throwable { + DeleteCounterexampleOptions deleteCounterexampleOptionsModel = + new DeleteCounterexampleOptions.Builder() + .workspaceId("testString") + .text("testString") + .build(); + assertEquals(deleteCounterexampleOptionsModel.workspaceId(), "testString"); + assertEquals(deleteCounterexampleOptionsModel.text(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteCounterexampleOptionsError() throws Throwable { + new DeleteCounterexampleOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DeleteDialogNodeOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DeleteDialogNodeOptionsTest.java new file mode 100644 index 00000000000..ef84d6961d7 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DeleteDialogNodeOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteDialogNodeOptions model. */ +public class DeleteDialogNodeOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteDialogNodeOptions() throws Throwable { + DeleteDialogNodeOptions deleteDialogNodeOptionsModel = + new DeleteDialogNodeOptions.Builder() + .workspaceId("testString") + .dialogNode("testString") + .build(); + assertEquals(deleteDialogNodeOptionsModel.workspaceId(), "testString"); + assertEquals(deleteDialogNodeOptionsModel.dialogNode(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteDialogNodeOptionsError() throws Throwable { + new DeleteDialogNodeOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DeleteEntityOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DeleteEntityOptionsTest.java new file mode 100644 index 00000000000..dfb0feb2cb6 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DeleteEntityOptionsTest.java @@ -0,0 +1,43 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteEntityOptions model. */ +public class DeleteEntityOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteEntityOptions() throws Throwable { + DeleteEntityOptions deleteEntityOptionsModel = + new DeleteEntityOptions.Builder().workspaceId("testString").entity("testString").build(); + assertEquals(deleteEntityOptionsModel.workspaceId(), "testString"); + assertEquals(deleteEntityOptionsModel.entity(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteEntityOptionsError() throws Throwable { + new DeleteEntityOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DeleteExampleOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DeleteExampleOptionsTest.java new file mode 100644 index 00000000000..105fe378e5d --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DeleteExampleOptionsTest.java @@ -0,0 +1,48 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteExampleOptions model. */ +public class DeleteExampleOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteExampleOptions() throws Throwable { + DeleteExampleOptions deleteExampleOptionsModel = + new DeleteExampleOptions.Builder() + .workspaceId("testString") + .intent("testString") + .text("testString") + .build(); + assertEquals(deleteExampleOptionsModel.workspaceId(), "testString"); + assertEquals(deleteExampleOptionsModel.intent(), "testString"); + assertEquals(deleteExampleOptionsModel.text(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteExampleOptionsError() throws Throwable { + new DeleteExampleOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DeleteIntentOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DeleteIntentOptionsTest.java new file mode 100644 index 00000000000..3ab37d0c679 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DeleteIntentOptionsTest.java @@ -0,0 +1,43 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteIntentOptions model. */ +public class DeleteIntentOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteIntentOptions() throws Throwable { + DeleteIntentOptions deleteIntentOptionsModel = + new DeleteIntentOptions.Builder().workspaceId("testString").intent("testString").build(); + assertEquals(deleteIntentOptionsModel.workspaceId(), "testString"); + assertEquals(deleteIntentOptionsModel.intent(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteIntentOptionsError() throws Throwable { + new DeleteIntentOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DeleteSynonymOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DeleteSynonymOptionsTest.java new file mode 100644 index 00000000000..9677f0b3325 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DeleteSynonymOptionsTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteSynonymOptions model. */ +public class DeleteSynonymOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteSynonymOptions() throws Throwable { + DeleteSynonymOptions deleteSynonymOptionsModel = + new DeleteSynonymOptions.Builder() + .workspaceId("testString") + .entity("testString") + .value("testString") + .synonym("testString") + .build(); + assertEquals(deleteSynonymOptionsModel.workspaceId(), "testString"); + assertEquals(deleteSynonymOptionsModel.entity(), "testString"); + assertEquals(deleteSynonymOptionsModel.value(), "testString"); + assertEquals(deleteSynonymOptionsModel.synonym(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteSynonymOptionsError() throws Throwable { + new DeleteSynonymOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DeleteUserDataOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DeleteUserDataOptionsTest.java new file mode 100644 index 00000000000..3c4cae4ea21 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DeleteUserDataOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteUserDataOptions model. */ +public class DeleteUserDataOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteUserDataOptions() throws Throwable { + DeleteUserDataOptions deleteUserDataOptionsModel = + new DeleteUserDataOptions.Builder().customerId("testString").build(); + assertEquals(deleteUserDataOptionsModel.customerId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteUserDataOptionsError() throws Throwable { + new DeleteUserDataOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DeleteValueOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DeleteValueOptionsTest.java new file mode 100644 index 00000000000..cadaf27fb21 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DeleteValueOptionsTest.java @@ -0,0 +1,48 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteValueOptions model. */ +public class DeleteValueOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteValueOptions() throws Throwable { + DeleteValueOptions deleteValueOptionsModel = + new DeleteValueOptions.Builder() + .workspaceId("testString") + .entity("testString") + .value("testString") + .build(); + assertEquals(deleteValueOptionsModel.workspaceId(), "testString"); + assertEquals(deleteValueOptionsModel.entity(), "testString"); + assertEquals(deleteValueOptionsModel.value(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteValueOptionsError() throws Throwable { + new DeleteValueOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DeleteWorkspaceOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DeleteWorkspaceOptionsTest.java new file mode 100644 index 00000000000..d1cb9765310 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DeleteWorkspaceOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteWorkspaceOptions model. */ +public class DeleteWorkspaceOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteWorkspaceOptions() throws Throwable { + DeleteWorkspaceOptions deleteWorkspaceOptionsModel = + new DeleteWorkspaceOptions.Builder().workspaceId("testString").build(); + assertEquals(deleteWorkspaceOptionsModel.workspaceId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteWorkspaceOptionsError() throws Throwable { + new DeleteWorkspaceOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeActionTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeActionTest.java new file mode 100644 index 00000000000..19ad697209a --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeActionTest.java @@ -0,0 +1,73 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DialogNodeAction model. */ +public class DialogNodeActionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogNodeAction() throws Throwable { + DialogNodeAction dialogNodeActionModel = + new DialogNodeAction.Builder() + .name("testString") + .type("client") + .parameters( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .resultVariable("testString") + .credentials("testString") + .build(); + assertEquals(dialogNodeActionModel.name(), "testString"); + assertEquals(dialogNodeActionModel.type(), "client"); + assertEquals( + dialogNodeActionModel.parameters(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals(dialogNodeActionModel.resultVariable(), "testString"); + assertEquals(dialogNodeActionModel.credentials(), "testString"); + + String json = TestUtilities.serialize(dialogNodeActionModel); + + DialogNodeAction dialogNodeActionModelNew = + TestUtilities.deserialize(json, DialogNodeAction.class); + assertTrue(dialogNodeActionModelNew instanceof DialogNodeAction); + assertEquals(dialogNodeActionModelNew.name(), "testString"); + assertEquals(dialogNodeActionModelNew.type(), "client"); + assertEquals(dialogNodeActionModelNew.resultVariable(), "testString"); + assertEquals(dialogNodeActionModelNew.credentials(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDialogNodeActionError() throws Throwable { + new DialogNodeAction.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeCollectionTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeCollectionTest.java new file mode 100644 index 00000000000..815397fff98 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeCollectionTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DialogNodeCollection model. */ +public class DialogNodeCollectionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogNodeCollection() throws Throwable { + DialogNodeCollection dialogNodeCollectionModel = new DialogNodeCollection(); + assertNull(dialogNodeCollectionModel.getDialogNodes()); + assertNull(dialogNodeCollectionModel.getPagination()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeContextTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeContextTest.java new file mode 100644 index 00000000000..927cea40cbd --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeContextTest.java @@ -0,0 +1,72 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.testng.annotations.Test; + +/** Unit test class for the DialogNodeContext model. */ +public class DialogNodeContextTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogNodeContext() throws Throwable { + DialogNodeContext dialogNodeContextModel = + new DialogNodeContext.Builder() + .integrations( + new java.util.HashMap>() { + { + put( + "foo", + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + } + }) + .add("foo", "testString") + .build(); + assertEquals( + dialogNodeContextModel.getIntegrations(), + new java.util.HashMap>() { + { + put( + "foo", + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + } + }); + assertEquals(dialogNodeContextModel.get("foo"), "testString"); + + String json = TestUtilities.serialize(dialogNodeContextModel); + + DialogNodeContext dialogNodeContextModelNew = + TestUtilities.deserialize(json, DialogNodeContext.class); + assertTrue(dialogNodeContextModelNew instanceof DialogNodeContext); + assertEquals(dialogNodeContextModelNew.get("foo"), "testString"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeNextStepTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeNextStepTest.java new file mode 100644 index 00000000000..f8869a129f2 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeNextStepTest.java @@ -0,0 +1,57 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DialogNodeNextStep model. */ +public class DialogNodeNextStepTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogNodeNextStep() throws Throwable { + DialogNodeNextStep dialogNodeNextStepModel = + new DialogNodeNextStep.Builder() + .behavior("get_user_input") + .dialogNode("testString") + .selector("condition") + .build(); + assertEquals(dialogNodeNextStepModel.behavior(), "get_user_input"); + assertEquals(dialogNodeNextStepModel.dialogNode(), "testString"); + assertEquals(dialogNodeNextStepModel.selector(), "condition"); + + String json = TestUtilities.serialize(dialogNodeNextStepModel); + + DialogNodeNextStep dialogNodeNextStepModelNew = + TestUtilities.deserialize(json, DialogNodeNextStep.class); + assertTrue(dialogNodeNextStepModelNew instanceof DialogNodeNextStep); + assertEquals(dialogNodeNextStepModelNew.behavior(), "get_user_input"); + assertEquals(dialogNodeNextStepModelNew.dialogNode(), "testString"); + assertEquals(dialogNodeNextStepModelNew.selector(), "condition"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDialogNodeNextStepError() throws Throwable { + new DialogNodeNextStep.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputConnectToAgentTransferInfoTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputConnectToAgentTransferInfoTest.java new file mode 100644 index 00000000000..a7ee65db2fe --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputConnectToAgentTransferInfoTest.java @@ -0,0 +1,71 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.testng.annotations.Test; + +/** Unit test class for the DialogNodeOutputConnectToAgentTransferInfo model. */ +public class DialogNodeOutputConnectToAgentTransferInfoTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogNodeOutputConnectToAgentTransferInfo() throws Throwable { + DialogNodeOutputConnectToAgentTransferInfo dialogNodeOutputConnectToAgentTransferInfoModel = + new DialogNodeOutputConnectToAgentTransferInfo.Builder() + .target( + new java.util.HashMap>() { + { + put( + "foo", + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + } + }) + .build(); + assertEquals( + dialogNodeOutputConnectToAgentTransferInfoModel.target(), + new java.util.HashMap>() { + { + put( + "foo", + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + } + }); + + String json = TestUtilities.serialize(dialogNodeOutputConnectToAgentTransferInfoModel); + + DialogNodeOutputConnectToAgentTransferInfo dialogNodeOutputConnectToAgentTransferInfoModelNew = + TestUtilities.deserialize(json, DialogNodeOutputConnectToAgentTransferInfo.class); + assertTrue( + dialogNodeOutputConnectToAgentTransferInfoModelNew + instanceof DialogNodeOutputConnectToAgentTransferInfo); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgentTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgentTest.java new file mode 100644 index 00000000000..64d96df8237 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgentTest.java @@ -0,0 +1,129 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.testng.annotations.Test; + +/** + * Unit test class for the DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent model. + */ +public class DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgentTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent() + throws Throwable { + DialogNodeOutputConnectToAgentTransferInfo dialogNodeOutputConnectToAgentTransferInfoModel = + new DialogNodeOutputConnectToAgentTransferInfo.Builder() + .target( + new java.util.HashMap>() { + { + put( + "foo", + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + } + }) + .build(); + assertEquals( + dialogNodeOutputConnectToAgentTransferInfoModel.target(), + new java.util.HashMap>() { + { + put( + "foo", + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + } + }); + + DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent + dialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgentModel = + new DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent.Builder() + .responseType("connect_to_agent") + .messageToHumanAgent("testString") + .agentAvailable("testString") + .agentUnavailable("testString") + .transferInfo(dialogNodeOutputConnectToAgentTransferInfoModel) + .build(); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgentModel.responseType(), + "connect_to_agent"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgentModel + .messageToHumanAgent(), + "testString"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgentModel.agentAvailable(), + "testString"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgentModel.agentUnavailable(), + "testString"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgentModel.transferInfo(), + dialogNodeOutputConnectToAgentTransferInfoModel); + + String json = + TestUtilities.serialize( + dialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgentModel); + + DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent + dialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgentModelNew = + TestUtilities.deserialize( + json, DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent.class); + assertTrue( + dialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgentModelNew + instanceof DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgentModelNew.responseType(), + "connect_to_agent"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgentModelNew + .messageToHumanAgent(), + "testString"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgentModelNew.agentAvailable(), + "testString"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgentModelNew + .agentUnavailable(), + "testString"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgentModelNew + .transferInfo() + .toString(), + dialogNodeOutputConnectToAgentTransferInfoModel.toString()); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgentError() + throws Throwable { + new DialogNodeOutputGenericDialogNodeOutputResponseTypeConnectToAgent.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeImageTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeImageTest.java new file mode 100644 index 00000000000..e0663835a26 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeImageTest.java @@ -0,0 +1,75 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DialogNodeOutputGenericDialogNodeOutputResponseTypeImage model. */ +public class DialogNodeOutputGenericDialogNodeOutputResponseTypeImageTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogNodeOutputGenericDialogNodeOutputResponseTypeImage() throws Throwable { + DialogNodeOutputGenericDialogNodeOutputResponseTypeImage + dialogNodeOutputGenericDialogNodeOutputResponseTypeImageModel = + new DialogNodeOutputGenericDialogNodeOutputResponseTypeImage.Builder() + .responseType("image") + .source("testString") + .title("testString") + .description("testString") + .build(); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeImageModel.responseType(), "image"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeImageModel.source(), "testString"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeImageModel.title(), "testString"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeImageModel.description(), "testString"); + + String json = + TestUtilities.serialize(dialogNodeOutputGenericDialogNodeOutputResponseTypeImageModel); + + DialogNodeOutputGenericDialogNodeOutputResponseTypeImage + dialogNodeOutputGenericDialogNodeOutputResponseTypeImageModelNew = + TestUtilities.deserialize( + json, DialogNodeOutputGenericDialogNodeOutputResponseTypeImage.class); + assertTrue( + dialogNodeOutputGenericDialogNodeOutputResponseTypeImageModelNew + instanceof DialogNodeOutputGenericDialogNodeOutputResponseTypeImage); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeImageModelNew.responseType(), "image"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeImageModelNew.source(), "testString"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeImageModelNew.title(), "testString"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeImageModelNew.description(), + "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDialogNodeOutputGenericDialogNodeOutputResponseTypeImageError() throws Throwable { + new DialogNodeOutputGenericDialogNodeOutputResponseTypeImage.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeOptionTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeOptionTest.java new file mode 100644 index 00000000000..251fd76d5e3 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeOptionTest.java @@ -0,0 +1,246 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DialogNodeOutputGenericDialogNodeOutputResponseTypeOption model. */ +public class DialogNodeOutputGenericDialogNodeOutputResponseTypeOptionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogNodeOutputGenericDialogNodeOutputResponseTypeOption() throws Throwable { + MessageInput messageInputModel = + new MessageInput.Builder() + .text("testString") + .spellingSuggestions(true) + .spellingAutoCorrect(true) + .add("foo", "testString") + .build(); + assertEquals(messageInputModel.getText(), "testString"); + assertEquals(messageInputModel.isSpellingSuggestions(), Boolean.valueOf(true)); + assertEquals(messageInputModel.isSpellingAutoCorrect(), Boolean.valueOf(true)); + assertEquals(messageInputModel.get("foo"), "testString"); + + RuntimeIntent runtimeIntentModel = + new RuntimeIntent.Builder().intent("testString").confidence(Double.valueOf("72.5")).build(); + assertEquals(runtimeIntentModel.intent(), "testString"); + assertEquals(runtimeIntentModel.confidence(), Double.valueOf("72.5")); + + CaptureGroup captureGroupModel = + new CaptureGroup.Builder() + .group("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) + .build(); + assertEquals(captureGroupModel.group(), "testString"); + assertEquals( + captureGroupModel.location(), + new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))); + + RuntimeEntityInterpretation runtimeEntityInterpretationModel = + new RuntimeEntityInterpretation.Builder() + .calendarType("testString") + .datetimeLink("testString") + .festival("testString") + .granularity("day") + .rangeLink("testString") + .rangeModifier("testString") + .relativeDay(Double.valueOf("72.5")) + .relativeMonth(Double.valueOf("72.5")) + .relativeWeek(Double.valueOf("72.5")) + .relativeWeekend(Double.valueOf("72.5")) + .relativeYear(Double.valueOf("72.5")) + .specificDay(Double.valueOf("72.5")) + .specificDayOfWeek("testString") + .specificMonth(Double.valueOf("72.5")) + .specificQuarter(Double.valueOf("72.5")) + .specificYear(Double.valueOf("72.5")) + .numericValue(Double.valueOf("72.5")) + .subtype("testString") + .partOfDay("testString") + .relativeHour(Double.valueOf("72.5")) + .relativeMinute(Double.valueOf("72.5")) + .relativeSecond(Double.valueOf("72.5")) + .specificHour(Double.valueOf("72.5")) + .specificMinute(Double.valueOf("72.5")) + .specificSecond(Double.valueOf("72.5")) + .timezone("testString") + .build(); + assertEquals(runtimeEntityInterpretationModel.calendarType(), "testString"); + assertEquals(runtimeEntityInterpretationModel.datetimeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.festival(), "testString"); + assertEquals(runtimeEntityInterpretationModel.granularity(), "day"); + assertEquals(runtimeEntityInterpretationModel.rangeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.rangeModifier(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeek(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeekend(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDayOfWeek(), "testString"); + assertEquals(runtimeEntityInterpretationModel.specificMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificQuarter(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.numericValue(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.subtype(), "testString"); + assertEquals(runtimeEntityInterpretationModel.partOfDay(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.timezone(), "testString"); + + RuntimeEntityAlternative runtimeEntityAlternativeModel = + new RuntimeEntityAlternative.Builder() + .value("testString") + .confidence(Double.valueOf("72.5")) + .build(); + assertEquals(runtimeEntityAlternativeModel.value(), "testString"); + assertEquals(runtimeEntityAlternativeModel.confidence(), Double.valueOf("72.5")); + + RuntimeEntityRole runtimeEntityRoleModel = + new RuntimeEntityRole.Builder().type("date_from").build(); + assertEquals(runtimeEntityRoleModel.type(), "date_from"); + + RuntimeEntity runtimeEntityModel = + new RuntimeEntity.Builder() + .entity("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) + .value("testString") + .confidence(Double.valueOf("72.5")) + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .groups( + new java.util.ArrayList(java.util.Arrays.asList(captureGroupModel))) + .interpretation(runtimeEntityInterpretationModel) + .alternatives( + new java.util.ArrayList( + java.util.Arrays.asList(runtimeEntityAlternativeModel))) + .role(runtimeEntityRoleModel) + .build(); + assertEquals(runtimeEntityModel.entity(), "testString"); + assertEquals( + runtimeEntityModel.location(), + new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))); + assertEquals(runtimeEntityModel.value(), "testString"); + assertEquals(runtimeEntityModel.confidence(), Double.valueOf("72.5")); + assertEquals( + runtimeEntityModel.metadata(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals( + runtimeEntityModel.groups(), + new java.util.ArrayList(java.util.Arrays.asList(captureGroupModel))); + assertEquals(runtimeEntityModel.interpretation(), runtimeEntityInterpretationModel); + assertEquals( + runtimeEntityModel.alternatives(), + new java.util.ArrayList( + java.util.Arrays.asList(runtimeEntityAlternativeModel))); + assertEquals(runtimeEntityModel.role(), runtimeEntityRoleModel); + + DialogNodeOutputOptionsElementValue dialogNodeOutputOptionsElementValueModel = + new DialogNodeOutputOptionsElementValue.Builder() + .input(messageInputModel) + .intents( + new java.util.ArrayList(java.util.Arrays.asList(runtimeIntentModel))) + .entities( + new java.util.ArrayList(java.util.Arrays.asList(runtimeEntityModel))) + .build(); + assertEquals(dialogNodeOutputOptionsElementValueModel.input(), messageInputModel); + assertEquals( + dialogNodeOutputOptionsElementValueModel.intents(), + new java.util.ArrayList(java.util.Arrays.asList(runtimeIntentModel))); + assertEquals( + dialogNodeOutputOptionsElementValueModel.entities(), + new java.util.ArrayList(java.util.Arrays.asList(runtimeEntityModel))); + + DialogNodeOutputOptionsElement dialogNodeOutputOptionsElementModel = + new DialogNodeOutputOptionsElement.Builder() + .label("testString") + .value(dialogNodeOutputOptionsElementValueModel) + .build(); + assertEquals(dialogNodeOutputOptionsElementModel.label(), "testString"); + assertEquals( + dialogNodeOutputOptionsElementModel.value(), dialogNodeOutputOptionsElementValueModel); + + DialogNodeOutputGenericDialogNodeOutputResponseTypeOption + dialogNodeOutputGenericDialogNodeOutputResponseTypeOptionModel = + new DialogNodeOutputGenericDialogNodeOutputResponseTypeOption.Builder() + .responseType("option") + .title("testString") + .description("testString") + .preference("dropdown") + .options( + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeOutputOptionsElementModel))) + .build(); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeOptionModel.responseType(), "option"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeOptionModel.title(), "testString"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeOptionModel.description(), "testString"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeOptionModel.preference(), "dropdown"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeOptionModel.options(), + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeOutputOptionsElementModel))); + + String json = + TestUtilities.serialize(dialogNodeOutputGenericDialogNodeOutputResponseTypeOptionModel); + + DialogNodeOutputGenericDialogNodeOutputResponseTypeOption + dialogNodeOutputGenericDialogNodeOutputResponseTypeOptionModelNew = + TestUtilities.deserialize( + json, DialogNodeOutputGenericDialogNodeOutputResponseTypeOption.class); + assertTrue( + dialogNodeOutputGenericDialogNodeOutputResponseTypeOptionModelNew + instanceof DialogNodeOutputGenericDialogNodeOutputResponseTypeOption); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeOptionModelNew.responseType(), "option"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeOptionModelNew.title(), "testString"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeOptionModelNew.description(), + "testString"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeOptionModelNew.preference(), "dropdown"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDialogNodeOutputGenericDialogNodeOutputResponseTypeOptionError() + throws Throwable { + new DialogNodeOutputGenericDialogNodeOutputResponseTypeOption.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypePauseTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypePauseTest.java new file mode 100644 index 00000000000..c811ec9d17b --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypePauseTest.java @@ -0,0 +1,72 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DialogNodeOutputGenericDialogNodeOutputResponseTypePause model. */ +public class DialogNodeOutputGenericDialogNodeOutputResponseTypePauseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogNodeOutputGenericDialogNodeOutputResponseTypePause() throws Throwable { + DialogNodeOutputGenericDialogNodeOutputResponseTypePause + dialogNodeOutputGenericDialogNodeOutputResponseTypePauseModel = + new DialogNodeOutputGenericDialogNodeOutputResponseTypePause.Builder() + .responseType("pause") + .time(Long.valueOf("26")) + .typing(true) + .build(); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypePauseModel.responseType(), "pause"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypePauseModel.time(), Long.valueOf("26")); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypePauseModel.typing(), + Boolean.valueOf(true)); + + String json = + TestUtilities.serialize(dialogNodeOutputGenericDialogNodeOutputResponseTypePauseModel); + + DialogNodeOutputGenericDialogNodeOutputResponseTypePause + dialogNodeOutputGenericDialogNodeOutputResponseTypePauseModelNew = + TestUtilities.deserialize( + json, DialogNodeOutputGenericDialogNodeOutputResponseTypePause.class); + assertTrue( + dialogNodeOutputGenericDialogNodeOutputResponseTypePauseModelNew + instanceof DialogNodeOutputGenericDialogNodeOutputResponseTypePause); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypePauseModelNew.responseType(), "pause"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypePauseModelNew.time(), + Long.valueOf("26")); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypePauseModelNew.typing(), + Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDialogNodeOutputGenericDialogNodeOutputResponseTypePauseError() throws Throwable { + new DialogNodeOutputGenericDialogNodeOutputResponseTypePause.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkillTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkillTest.java new file mode 100644 index 00000000000..1307acd35c1 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkillTest.java @@ -0,0 +1,90 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill model. */ +public class DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkillTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill() + throws Throwable { + DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill + dialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkillModel = + new DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill.Builder() + .responseType("search_skill") + .query("testString") + .queryType("natural_language") + .filter("testString") + .discoveryVersion("testString") + .build(); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkillModel.responseType(), + "search_skill"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkillModel.query(), "testString"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkillModel.queryType(), + "natural_language"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkillModel.filter(), "testString"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkillModel.discoveryVersion(), + "testString"); + + String json = + TestUtilities.serialize( + dialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkillModel); + + DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill + dialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkillModelNew = + TestUtilities.deserialize( + json, DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill.class); + assertTrue( + dialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkillModelNew + instanceof DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkillModelNew.responseType(), + "search_skill"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkillModelNew.query(), + "testString"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkillModelNew.queryType(), + "natural_language"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkillModelNew.filter(), + "testString"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkillModelNew.discoveryVersion(), + "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkillError() + throws Throwable { + new DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeTextTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeTextTest.java new file mode 100644 index 00000000000..1a6f27a670c --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericDialogNodeOutputResponseTypeTextTest.java @@ -0,0 +1,82 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DialogNodeOutputGenericDialogNodeOutputResponseTypeText model. */ +public class DialogNodeOutputGenericDialogNodeOutputResponseTypeTextTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogNodeOutputGenericDialogNodeOutputResponseTypeText() throws Throwable { + DialogNodeOutputTextValuesElement dialogNodeOutputTextValuesElementModel = + new DialogNodeOutputTextValuesElement.Builder().text("testString").build(); + assertEquals(dialogNodeOutputTextValuesElementModel.text(), "testString"); + + DialogNodeOutputGenericDialogNodeOutputResponseTypeText + dialogNodeOutputGenericDialogNodeOutputResponseTypeTextModel = + new DialogNodeOutputGenericDialogNodeOutputResponseTypeText.Builder() + .responseType("text") + .values( + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeOutputTextValuesElementModel))) + .selectionPolicy("sequential") + .delimiter("testString") + .build(); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeTextModel.responseType(), "text"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeTextModel.values(), + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeOutputTextValuesElementModel))); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeTextModel.selectionPolicy(), + "sequential"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeTextModel.delimiter(), "testString"); + + String json = + TestUtilities.serialize(dialogNodeOutputGenericDialogNodeOutputResponseTypeTextModel); + + DialogNodeOutputGenericDialogNodeOutputResponseTypeText + dialogNodeOutputGenericDialogNodeOutputResponseTypeTextModelNew = + TestUtilities.deserialize( + json, DialogNodeOutputGenericDialogNodeOutputResponseTypeText.class); + assertTrue( + dialogNodeOutputGenericDialogNodeOutputResponseTypeTextModelNew + instanceof DialogNodeOutputGenericDialogNodeOutputResponseTypeText); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeTextModelNew.responseType(), "text"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeTextModelNew.selectionPolicy(), + "sequential"); + assertEquals( + dialogNodeOutputGenericDialogNodeOutputResponseTypeTextModelNew.delimiter(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDialogNodeOutputGenericDialogNodeOutputResponseTypeTextError() throws Throwable { + new DialogNodeOutputGenericDialogNodeOutputResponseTypeText.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericTest.java new file mode 100644 index 00000000000..eef69f5cfe0 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGenericTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DialogNodeOutputGeneric model. */ +public class DialogNodeOutputGenericTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + // TODO: Add tests for models that are abstract + @Test + public void testDialogNodeOutputGeneric() throws Throwable { + DialogNodeOutputGeneric dialogNodeOutputGenericModel = new DialogNodeOutputGeneric(); + assertNotNull(dialogNodeOutputGenericModel); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputModifiersTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputModifiersTest.java new file mode 100644 index 00000000000..c2d7a76c608 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputModifiersTest.java @@ -0,0 +1,44 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DialogNodeOutputModifiers model. */ +public class DialogNodeOutputModifiersTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogNodeOutputModifiers() throws Throwable { + DialogNodeOutputModifiers dialogNodeOutputModifiersModel = + new DialogNodeOutputModifiers.Builder().overwrite(true).build(); + assertEquals(dialogNodeOutputModifiersModel.overwrite(), Boolean.valueOf(true)); + + String json = TestUtilities.serialize(dialogNodeOutputModifiersModel); + + DialogNodeOutputModifiers dialogNodeOutputModifiersModelNew = + TestUtilities.deserialize(json, DialogNodeOutputModifiers.class); + assertTrue(dialogNodeOutputModifiersModelNew instanceof DialogNodeOutputModifiers); + assertEquals(dialogNodeOutputModifiersModelNew.overwrite(), Boolean.valueOf(true)); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputOptionsElementTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputOptionsElementTest.java new file mode 100644 index 00000000000..c3e398d0121 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputOptionsElementTest.java @@ -0,0 +1,211 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DialogNodeOutputOptionsElement model. */ +public class DialogNodeOutputOptionsElementTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogNodeOutputOptionsElement() throws Throwable { + MessageInput messageInputModel = + new MessageInput.Builder() + .text("testString") + .spellingSuggestions(true) + .spellingAutoCorrect(true) + .add("foo", "testString") + .build(); + assertEquals(messageInputModel.getText(), "testString"); + assertEquals(messageInputModel.isSpellingSuggestions(), Boolean.valueOf(true)); + assertEquals(messageInputModel.isSpellingAutoCorrect(), Boolean.valueOf(true)); + assertEquals(messageInputModel.get("foo"), "testString"); + + RuntimeIntent runtimeIntentModel = + new RuntimeIntent.Builder().intent("testString").confidence(Double.valueOf("72.5")).build(); + assertEquals(runtimeIntentModel.intent(), "testString"); + assertEquals(runtimeIntentModel.confidence(), Double.valueOf("72.5")); + + CaptureGroup captureGroupModel = + new CaptureGroup.Builder() + .group("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) + .build(); + assertEquals(captureGroupModel.group(), "testString"); + assertEquals( + captureGroupModel.location(), + new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))); + + RuntimeEntityInterpretation runtimeEntityInterpretationModel = + new RuntimeEntityInterpretation.Builder() + .calendarType("testString") + .datetimeLink("testString") + .festival("testString") + .granularity("day") + .rangeLink("testString") + .rangeModifier("testString") + .relativeDay(Double.valueOf("72.5")) + .relativeMonth(Double.valueOf("72.5")) + .relativeWeek(Double.valueOf("72.5")) + .relativeWeekend(Double.valueOf("72.5")) + .relativeYear(Double.valueOf("72.5")) + .specificDay(Double.valueOf("72.5")) + .specificDayOfWeek("testString") + .specificMonth(Double.valueOf("72.5")) + .specificQuarter(Double.valueOf("72.5")) + .specificYear(Double.valueOf("72.5")) + .numericValue(Double.valueOf("72.5")) + .subtype("testString") + .partOfDay("testString") + .relativeHour(Double.valueOf("72.5")) + .relativeMinute(Double.valueOf("72.5")) + .relativeSecond(Double.valueOf("72.5")) + .specificHour(Double.valueOf("72.5")) + .specificMinute(Double.valueOf("72.5")) + .specificSecond(Double.valueOf("72.5")) + .timezone("testString") + .build(); + assertEquals(runtimeEntityInterpretationModel.calendarType(), "testString"); + assertEquals(runtimeEntityInterpretationModel.datetimeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.festival(), "testString"); + assertEquals(runtimeEntityInterpretationModel.granularity(), "day"); + assertEquals(runtimeEntityInterpretationModel.rangeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.rangeModifier(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeek(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeekend(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDayOfWeek(), "testString"); + assertEquals(runtimeEntityInterpretationModel.specificMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificQuarter(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.numericValue(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.subtype(), "testString"); + assertEquals(runtimeEntityInterpretationModel.partOfDay(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.timezone(), "testString"); + + RuntimeEntityAlternative runtimeEntityAlternativeModel = + new RuntimeEntityAlternative.Builder() + .value("testString") + .confidence(Double.valueOf("72.5")) + .build(); + assertEquals(runtimeEntityAlternativeModel.value(), "testString"); + assertEquals(runtimeEntityAlternativeModel.confidence(), Double.valueOf("72.5")); + + RuntimeEntityRole runtimeEntityRoleModel = + new RuntimeEntityRole.Builder().type("date_from").build(); + assertEquals(runtimeEntityRoleModel.type(), "date_from"); + + RuntimeEntity runtimeEntityModel = + new RuntimeEntity.Builder() + .entity("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) + .value("testString") + .confidence(Double.valueOf("72.5")) + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .groups( + new java.util.ArrayList(java.util.Arrays.asList(captureGroupModel))) + .interpretation(runtimeEntityInterpretationModel) + .alternatives( + new java.util.ArrayList( + java.util.Arrays.asList(runtimeEntityAlternativeModel))) + .role(runtimeEntityRoleModel) + .build(); + assertEquals(runtimeEntityModel.entity(), "testString"); + assertEquals( + runtimeEntityModel.location(), + new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))); + assertEquals(runtimeEntityModel.value(), "testString"); + assertEquals(runtimeEntityModel.confidence(), Double.valueOf("72.5")); + assertEquals( + runtimeEntityModel.metadata(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals( + runtimeEntityModel.groups(), + new java.util.ArrayList(java.util.Arrays.asList(captureGroupModel))); + assertEquals(runtimeEntityModel.interpretation(), runtimeEntityInterpretationModel); + assertEquals( + runtimeEntityModel.alternatives(), + new java.util.ArrayList( + java.util.Arrays.asList(runtimeEntityAlternativeModel))); + assertEquals(runtimeEntityModel.role(), runtimeEntityRoleModel); + + DialogNodeOutputOptionsElementValue dialogNodeOutputOptionsElementValueModel = + new DialogNodeOutputOptionsElementValue.Builder() + .input(messageInputModel) + .intents( + new java.util.ArrayList(java.util.Arrays.asList(runtimeIntentModel))) + .entities( + new java.util.ArrayList(java.util.Arrays.asList(runtimeEntityModel))) + .build(); + assertEquals(dialogNodeOutputOptionsElementValueModel.input(), messageInputModel); + assertEquals( + dialogNodeOutputOptionsElementValueModel.intents(), + new java.util.ArrayList(java.util.Arrays.asList(runtimeIntentModel))); + assertEquals( + dialogNodeOutputOptionsElementValueModel.entities(), + new java.util.ArrayList(java.util.Arrays.asList(runtimeEntityModel))); + + DialogNodeOutputOptionsElement dialogNodeOutputOptionsElementModel = + new DialogNodeOutputOptionsElement.Builder() + .label("testString") + .value(dialogNodeOutputOptionsElementValueModel) + .build(); + assertEquals(dialogNodeOutputOptionsElementModel.label(), "testString"); + assertEquals( + dialogNodeOutputOptionsElementModel.value(), dialogNodeOutputOptionsElementValueModel); + + String json = TestUtilities.serialize(dialogNodeOutputOptionsElementModel); + + DialogNodeOutputOptionsElement dialogNodeOutputOptionsElementModelNew = + TestUtilities.deserialize(json, DialogNodeOutputOptionsElement.class); + assertTrue(dialogNodeOutputOptionsElementModelNew instanceof DialogNodeOutputOptionsElement); + assertEquals(dialogNodeOutputOptionsElementModelNew.label(), "testString"); + assertEquals( + dialogNodeOutputOptionsElementModelNew.value().toString(), + dialogNodeOutputOptionsElementValueModel.toString()); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDialogNodeOutputOptionsElementError() throws Throwable { + new DialogNodeOutputOptionsElement.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputOptionsElementValueTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputOptionsElementValueTest.java new file mode 100644 index 00000000000..47db48be21d --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputOptionsElementValueTest.java @@ -0,0 +1,197 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DialogNodeOutputOptionsElementValue model. */ +public class DialogNodeOutputOptionsElementValueTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogNodeOutputOptionsElementValue() throws Throwable { + MessageInput messageInputModel = + new MessageInput.Builder() + .text("testString") + .spellingSuggestions(true) + .spellingAutoCorrect(true) + .add("foo", "testString") + .build(); + assertEquals(messageInputModel.getText(), "testString"); + assertEquals(messageInputModel.isSpellingSuggestions(), Boolean.valueOf(true)); + assertEquals(messageInputModel.isSpellingAutoCorrect(), Boolean.valueOf(true)); + assertEquals(messageInputModel.get("foo"), "testString"); + + RuntimeIntent runtimeIntentModel = + new RuntimeIntent.Builder().intent("testString").confidence(Double.valueOf("72.5")).build(); + assertEquals(runtimeIntentModel.intent(), "testString"); + assertEquals(runtimeIntentModel.confidence(), Double.valueOf("72.5")); + + CaptureGroup captureGroupModel = + new CaptureGroup.Builder() + .group("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) + .build(); + assertEquals(captureGroupModel.group(), "testString"); + assertEquals( + captureGroupModel.location(), + new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))); + + RuntimeEntityInterpretation runtimeEntityInterpretationModel = + new RuntimeEntityInterpretation.Builder() + .calendarType("testString") + .datetimeLink("testString") + .festival("testString") + .granularity("day") + .rangeLink("testString") + .rangeModifier("testString") + .relativeDay(Double.valueOf("72.5")) + .relativeMonth(Double.valueOf("72.5")) + .relativeWeek(Double.valueOf("72.5")) + .relativeWeekend(Double.valueOf("72.5")) + .relativeYear(Double.valueOf("72.5")) + .specificDay(Double.valueOf("72.5")) + .specificDayOfWeek("testString") + .specificMonth(Double.valueOf("72.5")) + .specificQuarter(Double.valueOf("72.5")) + .specificYear(Double.valueOf("72.5")) + .numericValue(Double.valueOf("72.5")) + .subtype("testString") + .partOfDay("testString") + .relativeHour(Double.valueOf("72.5")) + .relativeMinute(Double.valueOf("72.5")) + .relativeSecond(Double.valueOf("72.5")) + .specificHour(Double.valueOf("72.5")) + .specificMinute(Double.valueOf("72.5")) + .specificSecond(Double.valueOf("72.5")) + .timezone("testString") + .build(); + assertEquals(runtimeEntityInterpretationModel.calendarType(), "testString"); + assertEquals(runtimeEntityInterpretationModel.datetimeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.festival(), "testString"); + assertEquals(runtimeEntityInterpretationModel.granularity(), "day"); + assertEquals(runtimeEntityInterpretationModel.rangeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.rangeModifier(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeek(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeekend(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDayOfWeek(), "testString"); + assertEquals(runtimeEntityInterpretationModel.specificMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificQuarter(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.numericValue(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.subtype(), "testString"); + assertEquals(runtimeEntityInterpretationModel.partOfDay(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.timezone(), "testString"); + + RuntimeEntityAlternative runtimeEntityAlternativeModel = + new RuntimeEntityAlternative.Builder() + .value("testString") + .confidence(Double.valueOf("72.5")) + .build(); + assertEquals(runtimeEntityAlternativeModel.value(), "testString"); + assertEquals(runtimeEntityAlternativeModel.confidence(), Double.valueOf("72.5")); + + RuntimeEntityRole runtimeEntityRoleModel = + new RuntimeEntityRole.Builder().type("date_from").build(); + assertEquals(runtimeEntityRoleModel.type(), "date_from"); + + RuntimeEntity runtimeEntityModel = + new RuntimeEntity.Builder() + .entity("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) + .value("testString") + .confidence(Double.valueOf("72.5")) + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .groups( + new java.util.ArrayList(java.util.Arrays.asList(captureGroupModel))) + .interpretation(runtimeEntityInterpretationModel) + .alternatives( + new java.util.ArrayList( + java.util.Arrays.asList(runtimeEntityAlternativeModel))) + .role(runtimeEntityRoleModel) + .build(); + assertEquals(runtimeEntityModel.entity(), "testString"); + assertEquals( + runtimeEntityModel.location(), + new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))); + assertEquals(runtimeEntityModel.value(), "testString"); + assertEquals(runtimeEntityModel.confidence(), Double.valueOf("72.5")); + assertEquals( + runtimeEntityModel.metadata(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals( + runtimeEntityModel.groups(), + new java.util.ArrayList(java.util.Arrays.asList(captureGroupModel))); + assertEquals(runtimeEntityModel.interpretation(), runtimeEntityInterpretationModel); + assertEquals( + runtimeEntityModel.alternatives(), + new java.util.ArrayList( + java.util.Arrays.asList(runtimeEntityAlternativeModel))); + assertEquals(runtimeEntityModel.role(), runtimeEntityRoleModel); + + DialogNodeOutputOptionsElementValue dialogNodeOutputOptionsElementValueModel = + new DialogNodeOutputOptionsElementValue.Builder() + .input(messageInputModel) + .intents( + new java.util.ArrayList(java.util.Arrays.asList(runtimeIntentModel))) + .entities( + new java.util.ArrayList(java.util.Arrays.asList(runtimeEntityModel))) + .build(); + assertEquals(dialogNodeOutputOptionsElementValueModel.input(), messageInputModel); + assertEquals( + dialogNodeOutputOptionsElementValueModel.intents(), + new java.util.ArrayList(java.util.Arrays.asList(runtimeIntentModel))); + assertEquals( + dialogNodeOutputOptionsElementValueModel.entities(), + new java.util.ArrayList(java.util.Arrays.asList(runtimeEntityModel))); + + String json = TestUtilities.serialize(dialogNodeOutputOptionsElementValueModel); + + DialogNodeOutputOptionsElementValue dialogNodeOutputOptionsElementValueModelNew = + TestUtilities.deserialize(json, DialogNodeOutputOptionsElementValue.class); + assertTrue( + dialogNodeOutputOptionsElementValueModelNew instanceof DialogNodeOutputOptionsElementValue); + assertEquals( + dialogNodeOutputOptionsElementValueModelNew.input().toString(), + messageInputModel.toString()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputTest.java new file mode 100644 index 00000000000..b97d2c90ec2 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputTest.java @@ -0,0 +1,102 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.testng.annotations.Test; + +/** Unit test class for the DialogNodeOutput model. */ +public class DialogNodeOutputTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogNodeOutput() throws Throwable { + DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill dialogNodeOutputGenericModel = + new DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill.Builder() + .responseType("search_skill") + .query("testString") + .queryType("natural_language") + .filter("testString") + .discoveryVersion("testString") + .build(); + assertEquals(dialogNodeOutputGenericModel.responseType(), "search_skill"); + assertEquals(dialogNodeOutputGenericModel.query(), "testString"); + assertEquals(dialogNodeOutputGenericModel.queryType(), "natural_language"); + assertEquals(dialogNodeOutputGenericModel.filter(), "testString"); + assertEquals(dialogNodeOutputGenericModel.discoveryVersion(), "testString"); + + DialogNodeOutputModifiers dialogNodeOutputModifiersModel = + new DialogNodeOutputModifiers.Builder().overwrite(true).build(); + assertEquals(dialogNodeOutputModifiersModel.overwrite(), Boolean.valueOf(true)); + + DialogNodeOutput dialogNodeOutputModel = + new DialogNodeOutput.Builder() + .generic( + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeOutputGenericModel))) + .integrations( + new java.util.HashMap>() { + { + put( + "foo", + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + } + }) + .modifiers(dialogNodeOutputModifiersModel) + .add("foo", "testString") + .build(); + assertEquals( + dialogNodeOutputModel.getGeneric(), + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeOutputGenericModel))); + assertEquals( + dialogNodeOutputModel.getIntegrations(), + new java.util.HashMap>() { + { + put( + "foo", + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + } + }); + assertEquals(dialogNodeOutputModel.getModifiers(), dialogNodeOutputModifiersModel); + assertEquals(dialogNodeOutputModel.get("foo"), "testString"); + + String json = TestUtilities.serialize(dialogNodeOutputModel); + + DialogNodeOutput dialogNodeOutputModelNew = + TestUtilities.deserialize(json, DialogNodeOutput.class); + assertTrue(dialogNodeOutputModelNew instanceof DialogNodeOutput); + assertEquals( + dialogNodeOutputModelNew.getModifiers().toString(), + dialogNodeOutputModifiersModel.toString()); + assertEquals(dialogNodeOutputModelNew.get("foo"), "testString"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputTextValuesElementTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputTextValuesElementTest.java new file mode 100644 index 00000000000..6e76ba0d3b6 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputTextValuesElementTest.java @@ -0,0 +1,45 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DialogNodeOutputTextValuesElement model. */ +public class DialogNodeOutputTextValuesElementTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogNodeOutputTextValuesElement() throws Throwable { + DialogNodeOutputTextValuesElement dialogNodeOutputTextValuesElementModel = + new DialogNodeOutputTextValuesElement.Builder().text("testString").build(); + assertEquals(dialogNodeOutputTextValuesElementModel.text(), "testString"); + + String json = TestUtilities.serialize(dialogNodeOutputTextValuesElementModel); + + DialogNodeOutputTextValuesElement dialogNodeOutputTextValuesElementModelNew = + TestUtilities.deserialize(json, DialogNodeOutputTextValuesElement.class); + assertTrue( + dialogNodeOutputTextValuesElementModelNew instanceof DialogNodeOutputTextValuesElement); + assertEquals(dialogNodeOutputTextValuesElementModelNew.text(), "testString"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeTest.java new file mode 100644 index 00000000000..fed00d1e58d --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeTest.java @@ -0,0 +1,242 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.testng.annotations.Test; + +/** Unit test class for the DialogNode model. */ +public class DialogNodeTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogNode() throws Throwable { + DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill dialogNodeOutputGenericModel = + new DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill.Builder() + .responseType("search_skill") + .query("testString") + .queryType("natural_language") + .filter("testString") + .discoveryVersion("testString") + .build(); + assertEquals(dialogNodeOutputGenericModel.responseType(), "search_skill"); + assertEquals(dialogNodeOutputGenericModel.query(), "testString"); + assertEquals(dialogNodeOutputGenericModel.queryType(), "natural_language"); + assertEquals(dialogNodeOutputGenericModel.filter(), "testString"); + assertEquals(dialogNodeOutputGenericModel.discoveryVersion(), "testString"); + + DialogNodeOutputModifiers dialogNodeOutputModifiersModel = + new DialogNodeOutputModifiers.Builder().overwrite(true).build(); + assertEquals(dialogNodeOutputModifiersModel.overwrite(), Boolean.valueOf(true)); + + DialogNodeOutput dialogNodeOutputModel = + new DialogNodeOutput.Builder() + .generic( + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeOutputGenericModel))) + .integrations( + new java.util.HashMap>() { + { + put( + "foo", + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + } + }) + .modifiers(dialogNodeOutputModifiersModel) + .add("foo", "testString") + .build(); + assertEquals( + dialogNodeOutputModel.getGeneric(), + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeOutputGenericModel))); + assertEquals( + dialogNodeOutputModel.getIntegrations(), + new java.util.HashMap>() { + { + put( + "foo", + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + } + }); + assertEquals(dialogNodeOutputModel.getModifiers(), dialogNodeOutputModifiersModel); + assertEquals(dialogNodeOutputModel.get("foo"), "testString"); + + DialogNodeContext dialogNodeContextModel = + new DialogNodeContext.Builder() + .integrations( + new java.util.HashMap>() { + { + put( + "foo", + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + } + }) + .add("foo", "testString") + .build(); + assertEquals( + dialogNodeContextModel.getIntegrations(), + new java.util.HashMap>() { + { + put( + "foo", + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + } + }); + assertEquals(dialogNodeContextModel.get("foo"), "testString"); + + DialogNodeNextStep dialogNodeNextStepModel = + new DialogNodeNextStep.Builder() + .behavior("get_user_input") + .dialogNode("testString") + .selector("condition") + .build(); + assertEquals(dialogNodeNextStepModel.behavior(), "get_user_input"); + assertEquals(dialogNodeNextStepModel.dialogNode(), "testString"); + assertEquals(dialogNodeNextStepModel.selector(), "condition"); + + DialogNodeAction dialogNodeActionModel = + new DialogNodeAction.Builder() + .name("testString") + .type("client") + .parameters( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .resultVariable("testString") + .credentials("testString") + .build(); + assertEquals(dialogNodeActionModel.name(), "testString"); + assertEquals(dialogNodeActionModel.type(), "client"); + assertEquals( + dialogNodeActionModel.parameters(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals(dialogNodeActionModel.resultVariable(), "testString"); + assertEquals(dialogNodeActionModel.credentials(), "testString"); + + DialogNode dialogNodeModel = + new DialogNode.Builder() + .dialogNode("testString") + .description("testString") + .conditions("testString") + .parent("testString") + .previousSibling("testString") + .output(dialogNodeOutputModel) + .context(dialogNodeContextModel) + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .nextStep(dialogNodeNextStepModel) + .title("testString") + .type("standard") + .eventName("focus") + .variable("testString") + .actions( + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeActionModel))) + .digressIn("not_available") + .digressOut("allow_returning") + .digressOutSlots("not_allowed") + .userLabel("testString") + .disambiguationOptOut(true) + .build(); + assertEquals(dialogNodeModel.dialogNode(), "testString"); + assertEquals(dialogNodeModel.description(), "testString"); + assertEquals(dialogNodeModel.conditions(), "testString"); + assertEquals(dialogNodeModel.parent(), "testString"); + assertEquals(dialogNodeModel.previousSibling(), "testString"); + assertEquals(dialogNodeModel.output(), dialogNodeOutputModel); + assertEquals(dialogNodeModel.context(), dialogNodeContextModel); + assertEquals( + dialogNodeModel.metadata(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals(dialogNodeModel.nextStep(), dialogNodeNextStepModel); + assertEquals(dialogNodeModel.title(), "testString"); + assertEquals(dialogNodeModel.type(), "standard"); + assertEquals(dialogNodeModel.eventName(), "focus"); + assertEquals(dialogNodeModel.variable(), "testString"); + assertEquals( + dialogNodeModel.actions(), + new java.util.ArrayList(java.util.Arrays.asList(dialogNodeActionModel))); + assertEquals(dialogNodeModel.digressIn(), "not_available"); + assertEquals(dialogNodeModel.digressOut(), "allow_returning"); + assertEquals(dialogNodeModel.digressOutSlots(), "not_allowed"); + assertEquals(dialogNodeModel.userLabel(), "testString"); + assertEquals(dialogNodeModel.disambiguationOptOut(), Boolean.valueOf(true)); + + String json = TestUtilities.serialize(dialogNodeModel); + + DialogNode dialogNodeModelNew = TestUtilities.deserialize(json, DialogNode.class); + assertTrue(dialogNodeModelNew instanceof DialogNode); + assertEquals(dialogNodeModelNew.dialogNode(), "testString"); + assertEquals(dialogNodeModelNew.description(), "testString"); + assertEquals(dialogNodeModelNew.conditions(), "testString"); + assertEquals(dialogNodeModelNew.parent(), "testString"); + assertEquals(dialogNodeModelNew.previousSibling(), "testString"); + assertEquals(dialogNodeModelNew.output().toString(), dialogNodeOutputModel.toString()); + assertEquals(dialogNodeModelNew.context().toString(), dialogNodeContextModel.toString()); + assertEquals(dialogNodeModelNew.nextStep().toString(), dialogNodeNextStepModel.toString()); + assertEquals(dialogNodeModelNew.title(), "testString"); + assertEquals(dialogNodeModelNew.type(), "standard"); + assertEquals(dialogNodeModelNew.eventName(), "focus"); + assertEquals(dialogNodeModelNew.variable(), "testString"); + assertEquals(dialogNodeModelNew.digressIn(), "not_available"); + assertEquals(dialogNodeModelNew.digressOut(), "allow_returning"); + assertEquals(dialogNodeModelNew.digressOutSlots(), "not_allowed"); + assertEquals(dialogNodeModelNew.userLabel(), "testString"); + assertEquals(dialogNodeModelNew.disambiguationOptOut(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDialogNodeError() throws Throwable { + new DialogNode.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeVisitedDetailsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeVisitedDetailsTest.java new file mode 100644 index 00000000000..0bd486d3d2a --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogNodeVisitedDetailsTest.java @@ -0,0 +1,52 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DialogNodeVisitedDetails model. */ +public class DialogNodeVisitedDetailsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogNodeVisitedDetails() throws Throwable { + DialogNodeVisitedDetails dialogNodeVisitedDetailsModel = + new DialogNodeVisitedDetails.Builder() + .dialogNode("testString") + .title("testString") + .conditions("testString") + .build(); + assertEquals(dialogNodeVisitedDetailsModel.dialogNode(), "testString"); + assertEquals(dialogNodeVisitedDetailsModel.title(), "testString"); + assertEquals(dialogNodeVisitedDetailsModel.conditions(), "testString"); + + String json = TestUtilities.serialize(dialogNodeVisitedDetailsModel); + + DialogNodeVisitedDetails dialogNodeVisitedDetailsModelNew = + TestUtilities.deserialize(json, DialogNodeVisitedDetails.class); + assertTrue(dialogNodeVisitedDetailsModelNew instanceof DialogNodeVisitedDetails); + assertEquals(dialogNodeVisitedDetailsModelNew.dialogNode(), "testString"); + assertEquals(dialogNodeVisitedDetailsModelNew.title(), "testString"); + assertEquals(dialogNodeVisitedDetailsModelNew.conditions(), "testString"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogSuggestionTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogSuggestionTest.java new file mode 100644 index 00000000000..421fa3c48aa --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogSuggestionTest.java @@ -0,0 +1,225 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DialogSuggestion model. */ +public class DialogSuggestionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogSuggestion() throws Throwable { + MessageInput messageInputModel = + new MessageInput.Builder() + .text("testString") + .spellingSuggestions(true) + .spellingAutoCorrect(true) + .add("foo", "testString") + .build(); + assertEquals(messageInputModel.getText(), "testString"); + assertEquals(messageInputModel.isSpellingSuggestions(), Boolean.valueOf(true)); + assertEquals(messageInputModel.isSpellingAutoCorrect(), Boolean.valueOf(true)); + assertEquals(messageInputModel.get("foo"), "testString"); + + RuntimeIntent runtimeIntentModel = + new RuntimeIntent.Builder().intent("testString").confidence(Double.valueOf("72.5")).build(); + assertEquals(runtimeIntentModel.intent(), "testString"); + assertEquals(runtimeIntentModel.confidence(), Double.valueOf("72.5")); + + CaptureGroup captureGroupModel = + new CaptureGroup.Builder() + .group("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) + .build(); + assertEquals(captureGroupModel.group(), "testString"); + assertEquals( + captureGroupModel.location(), + new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))); + + RuntimeEntityInterpretation runtimeEntityInterpretationModel = + new RuntimeEntityInterpretation.Builder() + .calendarType("testString") + .datetimeLink("testString") + .festival("testString") + .granularity("day") + .rangeLink("testString") + .rangeModifier("testString") + .relativeDay(Double.valueOf("72.5")) + .relativeMonth(Double.valueOf("72.5")) + .relativeWeek(Double.valueOf("72.5")) + .relativeWeekend(Double.valueOf("72.5")) + .relativeYear(Double.valueOf("72.5")) + .specificDay(Double.valueOf("72.5")) + .specificDayOfWeek("testString") + .specificMonth(Double.valueOf("72.5")) + .specificQuarter(Double.valueOf("72.5")) + .specificYear(Double.valueOf("72.5")) + .numericValue(Double.valueOf("72.5")) + .subtype("testString") + .partOfDay("testString") + .relativeHour(Double.valueOf("72.5")) + .relativeMinute(Double.valueOf("72.5")) + .relativeSecond(Double.valueOf("72.5")) + .specificHour(Double.valueOf("72.5")) + .specificMinute(Double.valueOf("72.5")) + .specificSecond(Double.valueOf("72.5")) + .timezone("testString") + .build(); + assertEquals(runtimeEntityInterpretationModel.calendarType(), "testString"); + assertEquals(runtimeEntityInterpretationModel.datetimeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.festival(), "testString"); + assertEquals(runtimeEntityInterpretationModel.granularity(), "day"); + assertEquals(runtimeEntityInterpretationModel.rangeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.rangeModifier(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeek(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeekend(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDayOfWeek(), "testString"); + assertEquals(runtimeEntityInterpretationModel.specificMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificQuarter(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.numericValue(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.subtype(), "testString"); + assertEquals(runtimeEntityInterpretationModel.partOfDay(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.timezone(), "testString"); + + RuntimeEntityAlternative runtimeEntityAlternativeModel = + new RuntimeEntityAlternative.Builder() + .value("testString") + .confidence(Double.valueOf("72.5")) + .build(); + assertEquals(runtimeEntityAlternativeModel.value(), "testString"); + assertEquals(runtimeEntityAlternativeModel.confidence(), Double.valueOf("72.5")); + + RuntimeEntityRole runtimeEntityRoleModel = + new RuntimeEntityRole.Builder().type("date_from").build(); + assertEquals(runtimeEntityRoleModel.type(), "date_from"); + + RuntimeEntity runtimeEntityModel = + new RuntimeEntity.Builder() + .entity("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) + .value("testString") + .confidence(Double.valueOf("72.5")) + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .groups( + new java.util.ArrayList(java.util.Arrays.asList(captureGroupModel))) + .interpretation(runtimeEntityInterpretationModel) + .alternatives( + new java.util.ArrayList( + java.util.Arrays.asList(runtimeEntityAlternativeModel))) + .role(runtimeEntityRoleModel) + .build(); + assertEquals(runtimeEntityModel.entity(), "testString"); + assertEquals( + runtimeEntityModel.location(), + new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))); + assertEquals(runtimeEntityModel.value(), "testString"); + assertEquals(runtimeEntityModel.confidence(), Double.valueOf("72.5")); + assertEquals( + runtimeEntityModel.metadata(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals( + runtimeEntityModel.groups(), + new java.util.ArrayList(java.util.Arrays.asList(captureGroupModel))); + assertEquals(runtimeEntityModel.interpretation(), runtimeEntityInterpretationModel); + assertEquals( + runtimeEntityModel.alternatives(), + new java.util.ArrayList( + java.util.Arrays.asList(runtimeEntityAlternativeModel))); + assertEquals(runtimeEntityModel.role(), runtimeEntityRoleModel); + + DialogSuggestionValue dialogSuggestionValueModel = + new DialogSuggestionValue.Builder() + .input(messageInputModel) + .intents( + new java.util.ArrayList(java.util.Arrays.asList(runtimeIntentModel))) + .entities( + new java.util.ArrayList(java.util.Arrays.asList(runtimeEntityModel))) + .build(); + assertEquals(dialogSuggestionValueModel.input(), messageInputModel); + assertEquals( + dialogSuggestionValueModel.intents(), + new java.util.ArrayList(java.util.Arrays.asList(runtimeIntentModel))); + assertEquals( + dialogSuggestionValueModel.entities(), + new java.util.ArrayList(java.util.Arrays.asList(runtimeEntityModel))); + + DialogSuggestion dialogSuggestionModel = + new DialogSuggestion.Builder() + .label("testString") + .value(dialogSuggestionValueModel) + .output( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .dialogNode("testString") + .build(); + assertEquals(dialogSuggestionModel.label(), "testString"); + assertEquals(dialogSuggestionModel.value(), dialogSuggestionValueModel); + assertEquals( + dialogSuggestionModel.output(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals(dialogSuggestionModel.dialogNode(), "testString"); + + String json = TestUtilities.serialize(dialogSuggestionModel); + + DialogSuggestion dialogSuggestionModelNew = + TestUtilities.deserialize(json, DialogSuggestion.class); + assertTrue(dialogSuggestionModelNew instanceof DialogSuggestion); + assertEquals(dialogSuggestionModelNew.label(), "testString"); + assertEquals( + dialogSuggestionModelNew.value().toString(), dialogSuggestionValueModel.toString()); + assertEquals(dialogSuggestionModelNew.dialogNode(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDialogSuggestionError() throws Throwable { + new DialogSuggestion.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogSuggestionValueTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogSuggestionValueTest.java new file mode 100644 index 00000000000..88745ab6b29 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/DialogSuggestionValueTest.java @@ -0,0 +1,194 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DialogSuggestionValue model. */ +public class DialogSuggestionValueTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogSuggestionValue() throws Throwable { + MessageInput messageInputModel = + new MessageInput.Builder() + .text("testString") + .spellingSuggestions(true) + .spellingAutoCorrect(true) + .add("foo", "testString") + .build(); + assertEquals(messageInputModel.getText(), "testString"); + assertEquals(messageInputModel.isSpellingSuggestions(), Boolean.valueOf(true)); + assertEquals(messageInputModel.isSpellingAutoCorrect(), Boolean.valueOf(true)); + assertEquals(messageInputModel.get("foo"), "testString"); + + RuntimeIntent runtimeIntentModel = + new RuntimeIntent.Builder().intent("testString").confidence(Double.valueOf("72.5")).build(); + assertEquals(runtimeIntentModel.intent(), "testString"); + assertEquals(runtimeIntentModel.confidence(), Double.valueOf("72.5")); + + CaptureGroup captureGroupModel = + new CaptureGroup.Builder() + .group("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) + .build(); + assertEquals(captureGroupModel.group(), "testString"); + assertEquals( + captureGroupModel.location(), + new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))); + + RuntimeEntityInterpretation runtimeEntityInterpretationModel = + new RuntimeEntityInterpretation.Builder() + .calendarType("testString") + .datetimeLink("testString") + .festival("testString") + .granularity("day") + .rangeLink("testString") + .rangeModifier("testString") + .relativeDay(Double.valueOf("72.5")) + .relativeMonth(Double.valueOf("72.5")) + .relativeWeek(Double.valueOf("72.5")) + .relativeWeekend(Double.valueOf("72.5")) + .relativeYear(Double.valueOf("72.5")) + .specificDay(Double.valueOf("72.5")) + .specificDayOfWeek("testString") + .specificMonth(Double.valueOf("72.5")) + .specificQuarter(Double.valueOf("72.5")) + .specificYear(Double.valueOf("72.5")) + .numericValue(Double.valueOf("72.5")) + .subtype("testString") + .partOfDay("testString") + .relativeHour(Double.valueOf("72.5")) + .relativeMinute(Double.valueOf("72.5")) + .relativeSecond(Double.valueOf("72.5")) + .specificHour(Double.valueOf("72.5")) + .specificMinute(Double.valueOf("72.5")) + .specificSecond(Double.valueOf("72.5")) + .timezone("testString") + .build(); + assertEquals(runtimeEntityInterpretationModel.calendarType(), "testString"); + assertEquals(runtimeEntityInterpretationModel.datetimeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.festival(), "testString"); + assertEquals(runtimeEntityInterpretationModel.granularity(), "day"); + assertEquals(runtimeEntityInterpretationModel.rangeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.rangeModifier(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeek(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeekend(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDayOfWeek(), "testString"); + assertEquals(runtimeEntityInterpretationModel.specificMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificQuarter(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.numericValue(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.subtype(), "testString"); + assertEquals(runtimeEntityInterpretationModel.partOfDay(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.timezone(), "testString"); + + RuntimeEntityAlternative runtimeEntityAlternativeModel = + new RuntimeEntityAlternative.Builder() + .value("testString") + .confidence(Double.valueOf("72.5")) + .build(); + assertEquals(runtimeEntityAlternativeModel.value(), "testString"); + assertEquals(runtimeEntityAlternativeModel.confidence(), Double.valueOf("72.5")); + + RuntimeEntityRole runtimeEntityRoleModel = + new RuntimeEntityRole.Builder().type("date_from").build(); + assertEquals(runtimeEntityRoleModel.type(), "date_from"); + + RuntimeEntity runtimeEntityModel = + new RuntimeEntity.Builder() + .entity("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) + .value("testString") + .confidence(Double.valueOf("72.5")) + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .groups( + new java.util.ArrayList(java.util.Arrays.asList(captureGroupModel))) + .interpretation(runtimeEntityInterpretationModel) + .alternatives( + new java.util.ArrayList( + java.util.Arrays.asList(runtimeEntityAlternativeModel))) + .role(runtimeEntityRoleModel) + .build(); + assertEquals(runtimeEntityModel.entity(), "testString"); + assertEquals( + runtimeEntityModel.location(), + new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))); + assertEquals(runtimeEntityModel.value(), "testString"); + assertEquals(runtimeEntityModel.confidence(), Double.valueOf("72.5")); + assertEquals( + runtimeEntityModel.metadata(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals( + runtimeEntityModel.groups(), + new java.util.ArrayList(java.util.Arrays.asList(captureGroupModel))); + assertEquals(runtimeEntityModel.interpretation(), runtimeEntityInterpretationModel); + assertEquals( + runtimeEntityModel.alternatives(), + new java.util.ArrayList( + java.util.Arrays.asList(runtimeEntityAlternativeModel))); + assertEquals(runtimeEntityModel.role(), runtimeEntityRoleModel); + + DialogSuggestionValue dialogSuggestionValueModel = + new DialogSuggestionValue.Builder() + .input(messageInputModel) + .intents( + new java.util.ArrayList(java.util.Arrays.asList(runtimeIntentModel))) + .entities( + new java.util.ArrayList(java.util.Arrays.asList(runtimeEntityModel))) + .build(); + assertEquals(dialogSuggestionValueModel.input(), messageInputModel); + assertEquals( + dialogSuggestionValueModel.intents(), + new java.util.ArrayList(java.util.Arrays.asList(runtimeIntentModel))); + assertEquals( + dialogSuggestionValueModel.entities(), + new java.util.ArrayList(java.util.Arrays.asList(runtimeEntityModel))); + + String json = TestUtilities.serialize(dialogSuggestionValueModel); + + DialogSuggestionValue dialogSuggestionValueModelNew = + TestUtilities.deserialize(json, DialogSuggestionValue.class); + assertTrue(dialogSuggestionValueModelNew instanceof DialogSuggestionValue); + assertEquals(dialogSuggestionValueModelNew.input().toString(), messageInputModel.toString()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/EntityCollectionTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/EntityCollectionTest.java new file mode 100644 index 00000000000..51329a0b15a --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/EntityCollectionTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the EntityCollection model. */ +public class EntityCollectionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testEntityCollection() throws Throwable { + EntityCollection entityCollectionModel = new EntityCollection(); + assertNull(entityCollectionModel.getEntities()); + assertNull(entityCollectionModel.getPagination()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/EntityMentionCollectionTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/EntityMentionCollectionTest.java new file mode 100644 index 00000000000..520cf6a1455 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/EntityMentionCollectionTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the EntityMentionCollection model. */ +public class EntityMentionCollectionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testEntityMentionCollection() throws Throwable { + EntityMentionCollection entityMentionCollectionModel = new EntityMentionCollection(); + assertNull(entityMentionCollectionModel.getExamples()); + assertNull(entityMentionCollectionModel.getPagination()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/EntityMentionTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/EntityMentionTest.java new file mode 100644 index 00000000000..ca0f0ff7da3 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/EntityMentionTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the EntityMention model. */ +public class EntityMentionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testEntityMention() throws Throwable { + EntityMention entityMentionModel = new EntityMention(); + assertNull(entityMentionModel.getText()); + assertNull(entityMentionModel.getIntent()); + assertNull(entityMentionModel.getLocation()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/EntityTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/EntityTest.java new file mode 100644 index 00000000000..c707585f9f9 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/EntityTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Entity model. */ +public class EntityTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testEntity() throws Throwable { + Entity entityModel = new Entity(); + assertNull(entityModel.getEntity()); + assertNull(entityModel.getDescription()); + assertNull(entityModel.getMetadata()); + assertNull(entityModel.isFuzzyMatch()); + assertNull(entityModel.getValues()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ExampleCollectionTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ExampleCollectionTest.java new file mode 100644 index 00000000000..a95f93ca2e2 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ExampleCollectionTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ExampleCollection model. */ +public class ExampleCollectionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testExampleCollection() throws Throwable { + ExampleCollection exampleCollectionModel = new ExampleCollection(); + assertNull(exampleCollectionModel.getExamples()); + assertNull(exampleCollectionModel.getPagination()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ExampleTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ExampleTest.java new file mode 100644 index 00000000000..d2205d3fe83 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ExampleTest.java @@ -0,0 +1,64 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Example model. */ +public class ExampleTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testExample() throws Throwable { + Mention mentionModel = + new Mention.Builder() + .entity("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) + .build(); + assertEquals(mentionModel.entity(), "testString"); + assertEquals( + mentionModel.location(), + new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))); + + Example exampleModel = + new Example.Builder() + .text("testString") + .mentions(new java.util.ArrayList(java.util.Arrays.asList(mentionModel))) + .build(); + assertEquals(exampleModel.text(), "testString"); + assertEquals( + exampleModel.mentions(), + new java.util.ArrayList(java.util.Arrays.asList(mentionModel))); + + String json = TestUtilities.serialize(exampleModel); + + Example exampleModelNew = TestUtilities.deserialize(json, Example.class); + assertTrue(exampleModelNew instanceof Example); + assertEquals(exampleModelNew.text(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testExampleError() throws Throwable { + new Example.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/GetCounterexampleOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/GetCounterexampleOptionsTest.java new file mode 100644 index 00000000000..873e9614cb9 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/GetCounterexampleOptionsTest.java @@ -0,0 +1,48 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetCounterexampleOptions model. */ +public class GetCounterexampleOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetCounterexampleOptions() throws Throwable { + GetCounterexampleOptions getCounterexampleOptionsModel = + new GetCounterexampleOptions.Builder() + .workspaceId("testString") + .text("testString") + .includeAudit(true) + .build(); + assertEquals(getCounterexampleOptionsModel.workspaceId(), "testString"); + assertEquals(getCounterexampleOptionsModel.text(), "testString"); + assertEquals(getCounterexampleOptionsModel.includeAudit(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetCounterexampleOptionsError() throws Throwable { + new GetCounterexampleOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/GetDialogNodeOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/GetDialogNodeOptionsTest.java new file mode 100644 index 00000000000..6f90046b23b --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/GetDialogNodeOptionsTest.java @@ -0,0 +1,48 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetDialogNodeOptions model. */ +public class GetDialogNodeOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetDialogNodeOptions() throws Throwable { + GetDialogNodeOptions getDialogNodeOptionsModel = + new GetDialogNodeOptions.Builder() + .workspaceId("testString") + .dialogNode("testString") + .includeAudit(true) + .build(); + assertEquals(getDialogNodeOptionsModel.workspaceId(), "testString"); + assertEquals(getDialogNodeOptionsModel.dialogNode(), "testString"); + assertEquals(getDialogNodeOptionsModel.includeAudit(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetDialogNodeOptionsError() throws Throwable { + new GetDialogNodeOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/GetEntityOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/GetEntityOptionsTest.java new file mode 100644 index 00000000000..4751d85ddbe --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/GetEntityOptionsTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetEntityOptions model. */ +public class GetEntityOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetEntityOptions() throws Throwable { + GetEntityOptions getEntityOptionsModel = + new GetEntityOptions.Builder() + .workspaceId("testString") + .entity("testString") + .export(true) + .includeAudit(true) + .build(); + assertEquals(getEntityOptionsModel.workspaceId(), "testString"); + assertEquals(getEntityOptionsModel.entity(), "testString"); + assertEquals(getEntityOptionsModel.export(), Boolean.valueOf(true)); + assertEquals(getEntityOptionsModel.includeAudit(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetEntityOptionsError() throws Throwable { + new GetEntityOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/GetExampleOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/GetExampleOptionsTest.java new file mode 100644 index 00000000000..3fe2d51080b --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/GetExampleOptionsTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetExampleOptions model. */ +public class GetExampleOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetExampleOptions() throws Throwable { + GetExampleOptions getExampleOptionsModel = + new GetExampleOptions.Builder() + .workspaceId("testString") + .intent("testString") + .text("testString") + .includeAudit(true) + .build(); + assertEquals(getExampleOptionsModel.workspaceId(), "testString"); + assertEquals(getExampleOptionsModel.intent(), "testString"); + assertEquals(getExampleOptionsModel.text(), "testString"); + assertEquals(getExampleOptionsModel.includeAudit(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetExampleOptionsError() throws Throwable { + new GetExampleOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/GetIntentOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/GetIntentOptionsTest.java new file mode 100644 index 00000000000..9da52e97460 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/GetIntentOptionsTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetIntentOptions model. */ +public class GetIntentOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetIntentOptions() throws Throwable { + GetIntentOptions getIntentOptionsModel = + new GetIntentOptions.Builder() + .workspaceId("testString") + .intent("testString") + .export(true) + .includeAudit(true) + .build(); + assertEquals(getIntentOptionsModel.workspaceId(), "testString"); + assertEquals(getIntentOptionsModel.intent(), "testString"); + assertEquals(getIntentOptionsModel.export(), Boolean.valueOf(true)); + assertEquals(getIntentOptionsModel.includeAudit(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetIntentOptionsError() throws Throwable { + new GetIntentOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/GetSynonymOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/GetSynonymOptionsTest.java new file mode 100644 index 00000000000..a6c6a7d1fda --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/GetSynonymOptionsTest.java @@ -0,0 +1,52 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetSynonymOptions model. */ +public class GetSynonymOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetSynonymOptions() throws Throwable { + GetSynonymOptions getSynonymOptionsModel = + new GetSynonymOptions.Builder() + .workspaceId("testString") + .entity("testString") + .value("testString") + .synonym("testString") + .includeAudit(true) + .build(); + assertEquals(getSynonymOptionsModel.workspaceId(), "testString"); + assertEquals(getSynonymOptionsModel.entity(), "testString"); + assertEquals(getSynonymOptionsModel.value(), "testString"); + assertEquals(getSynonymOptionsModel.synonym(), "testString"); + assertEquals(getSynonymOptionsModel.includeAudit(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetSynonymOptionsError() throws Throwable { + new GetSynonymOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/GetValueOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/GetValueOptionsTest.java new file mode 100644 index 00000000000..98f29a6c800 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/GetValueOptionsTest.java @@ -0,0 +1,52 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetValueOptions model. */ +public class GetValueOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetValueOptions() throws Throwable { + GetValueOptions getValueOptionsModel = + new GetValueOptions.Builder() + .workspaceId("testString") + .entity("testString") + .value("testString") + .export(true) + .includeAudit(true) + .build(); + assertEquals(getValueOptionsModel.workspaceId(), "testString"); + assertEquals(getValueOptionsModel.entity(), "testString"); + assertEquals(getValueOptionsModel.value(), "testString"); + assertEquals(getValueOptionsModel.export(), Boolean.valueOf(true)); + assertEquals(getValueOptionsModel.includeAudit(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetValueOptionsError() throws Throwable { + new GetValueOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/GetWorkspaceOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/GetWorkspaceOptionsTest.java new file mode 100644 index 00000000000..2a2a19915e0 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/GetWorkspaceOptionsTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetWorkspaceOptions model. */ +public class GetWorkspaceOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetWorkspaceOptions() throws Throwable { + GetWorkspaceOptions getWorkspaceOptionsModel = + new GetWorkspaceOptions.Builder() + .workspaceId("testString") + .export(true) + .includeAudit(true) + .sort("stable") + .build(); + assertEquals(getWorkspaceOptionsModel.workspaceId(), "testString"); + assertEquals(getWorkspaceOptionsModel.export(), Boolean.valueOf(true)); + assertEquals(getWorkspaceOptionsModel.includeAudit(), Boolean.valueOf(true)); + assertEquals(getWorkspaceOptionsModel.sort(), "stable"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetWorkspaceOptionsError() throws Throwable { + new GetWorkspaceOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/IntentCollectionTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/IntentCollectionTest.java new file mode 100644 index 00000000000..7325ad1f0fe --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/IntentCollectionTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the IntentCollection model. */ +public class IntentCollectionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testIntentCollection() throws Throwable { + IntentCollection intentCollectionModel = new IntentCollection(); + assertNull(intentCollectionModel.getIntents()); + assertNull(intentCollectionModel.getPagination()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/IntentTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/IntentTest.java new file mode 100644 index 00000000000..e2969aa0402 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/IntentTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Intent model. */ +public class IntentTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testIntent() throws Throwable { + Intent intentModel = new Intent(); + assertNull(intentModel.getIntent()); + assertNull(intentModel.getDescription()); + assertNull(intentModel.getExamples()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListAllLogsOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListAllLogsOptionsTest.java new file mode 100644 index 00000000000..f09ab161ad2 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListAllLogsOptionsTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListAllLogsOptions model. */ +public class ListAllLogsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListAllLogsOptions() throws Throwable { + ListAllLogsOptions listAllLogsOptionsModel = + new ListAllLogsOptions.Builder() + .filter("testString") + .sort("testString") + .pageLimit(Long.valueOf("26")) + .cursor("testString") + .build(); + assertEquals(listAllLogsOptionsModel.filter(), "testString"); + assertEquals(listAllLogsOptionsModel.sort(), "testString"); + assertEquals(listAllLogsOptionsModel.pageLimit(), Long.valueOf("26")); + assertEquals(listAllLogsOptionsModel.cursor(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListAllLogsOptionsError() throws Throwable { + new ListAllLogsOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListCounterexamplesOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListCounterexamplesOptionsTest.java new file mode 100644 index 00000000000..c87bd4b2ed3 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListCounterexamplesOptionsTest.java @@ -0,0 +1,54 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListCounterexamplesOptions model. */ +public class ListCounterexamplesOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListCounterexamplesOptions() throws Throwable { + ListCounterexamplesOptions listCounterexamplesOptionsModel = + new ListCounterexamplesOptions.Builder() + .workspaceId("testString") + .pageLimit(Long.valueOf("26")) + .includeCount(true) + .sort("text") + .cursor("testString") + .includeAudit(true) + .build(); + assertEquals(listCounterexamplesOptionsModel.workspaceId(), "testString"); + assertEquals(listCounterexamplesOptionsModel.pageLimit(), Long.valueOf("26")); + assertEquals(listCounterexamplesOptionsModel.includeCount(), Boolean.valueOf(true)); + assertEquals(listCounterexamplesOptionsModel.sort(), "text"); + assertEquals(listCounterexamplesOptionsModel.cursor(), "testString"); + assertEquals(listCounterexamplesOptionsModel.includeAudit(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListCounterexamplesOptionsError() throws Throwable { + new ListCounterexamplesOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListDialogNodesOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListDialogNodesOptionsTest.java new file mode 100644 index 00000000000..a39ec2fdb36 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListDialogNodesOptionsTest.java @@ -0,0 +1,54 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListDialogNodesOptions model. */ +public class ListDialogNodesOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListDialogNodesOptions() throws Throwable { + ListDialogNodesOptions listDialogNodesOptionsModel = + new ListDialogNodesOptions.Builder() + .workspaceId("testString") + .pageLimit(Long.valueOf("26")) + .includeCount(true) + .sort("dialog_node") + .cursor("testString") + .includeAudit(true) + .build(); + assertEquals(listDialogNodesOptionsModel.workspaceId(), "testString"); + assertEquals(listDialogNodesOptionsModel.pageLimit(), Long.valueOf("26")); + assertEquals(listDialogNodesOptionsModel.includeCount(), Boolean.valueOf(true)); + assertEquals(listDialogNodesOptionsModel.sort(), "dialog_node"); + assertEquals(listDialogNodesOptionsModel.cursor(), "testString"); + assertEquals(listDialogNodesOptionsModel.includeAudit(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListDialogNodesOptionsError() throws Throwable { + new ListDialogNodesOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListEntitiesOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListEntitiesOptionsTest.java new file mode 100644 index 00000000000..05e2c06a4ea --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListEntitiesOptionsTest.java @@ -0,0 +1,56 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListEntitiesOptions model. */ +public class ListEntitiesOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListEntitiesOptions() throws Throwable { + ListEntitiesOptions listEntitiesOptionsModel = + new ListEntitiesOptions.Builder() + .workspaceId("testString") + .export(true) + .pageLimit(Long.valueOf("26")) + .includeCount(true) + .sort("entity") + .cursor("testString") + .includeAudit(true) + .build(); + assertEquals(listEntitiesOptionsModel.workspaceId(), "testString"); + assertEquals(listEntitiesOptionsModel.export(), Boolean.valueOf(true)); + assertEquals(listEntitiesOptionsModel.pageLimit(), Long.valueOf("26")); + assertEquals(listEntitiesOptionsModel.includeCount(), Boolean.valueOf(true)); + assertEquals(listEntitiesOptionsModel.sort(), "entity"); + assertEquals(listEntitiesOptionsModel.cursor(), "testString"); + assertEquals(listEntitiesOptionsModel.includeAudit(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListEntitiesOptionsError() throws Throwable { + new ListEntitiesOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListExamplesOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListExamplesOptionsTest.java new file mode 100644 index 00000000000..8893843b058 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListExamplesOptionsTest.java @@ -0,0 +1,56 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListExamplesOptions model. */ +public class ListExamplesOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListExamplesOptions() throws Throwable { + ListExamplesOptions listExamplesOptionsModel = + new ListExamplesOptions.Builder() + .workspaceId("testString") + .intent("testString") + .pageLimit(Long.valueOf("26")) + .includeCount(true) + .sort("text") + .cursor("testString") + .includeAudit(true) + .build(); + assertEquals(listExamplesOptionsModel.workspaceId(), "testString"); + assertEquals(listExamplesOptionsModel.intent(), "testString"); + assertEquals(listExamplesOptionsModel.pageLimit(), Long.valueOf("26")); + assertEquals(listExamplesOptionsModel.includeCount(), Boolean.valueOf(true)); + assertEquals(listExamplesOptionsModel.sort(), "text"); + assertEquals(listExamplesOptionsModel.cursor(), "testString"); + assertEquals(listExamplesOptionsModel.includeAudit(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListExamplesOptionsError() throws Throwable { + new ListExamplesOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListIntentsOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListIntentsOptionsTest.java new file mode 100644 index 00000000000..6f1067c4c2c --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListIntentsOptionsTest.java @@ -0,0 +1,56 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListIntentsOptions model. */ +public class ListIntentsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListIntentsOptions() throws Throwable { + ListIntentsOptions listIntentsOptionsModel = + new ListIntentsOptions.Builder() + .workspaceId("testString") + .export(true) + .pageLimit(Long.valueOf("26")) + .includeCount(true) + .sort("intent") + .cursor("testString") + .includeAudit(true) + .build(); + assertEquals(listIntentsOptionsModel.workspaceId(), "testString"); + assertEquals(listIntentsOptionsModel.export(), Boolean.valueOf(true)); + assertEquals(listIntentsOptionsModel.pageLimit(), Long.valueOf("26")); + assertEquals(listIntentsOptionsModel.includeCount(), Boolean.valueOf(true)); + assertEquals(listIntentsOptionsModel.sort(), "intent"); + assertEquals(listIntentsOptionsModel.cursor(), "testString"); + assertEquals(listIntentsOptionsModel.includeAudit(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListIntentsOptionsError() throws Throwable { + new ListIntentsOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListLogsOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListLogsOptionsTest.java new file mode 100644 index 00000000000..45676d2199a --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListLogsOptionsTest.java @@ -0,0 +1,52 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListLogsOptions model. */ +public class ListLogsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListLogsOptions() throws Throwable { + ListLogsOptions listLogsOptionsModel = + new ListLogsOptions.Builder() + .workspaceId("testString") + .sort("testString") + .filter("testString") + .pageLimit(Long.valueOf("26")) + .cursor("testString") + .build(); + assertEquals(listLogsOptionsModel.workspaceId(), "testString"); + assertEquals(listLogsOptionsModel.sort(), "testString"); + assertEquals(listLogsOptionsModel.filter(), "testString"); + assertEquals(listLogsOptionsModel.pageLimit(), Long.valueOf("26")); + assertEquals(listLogsOptionsModel.cursor(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListLogsOptionsError() throws Throwable { + new ListLogsOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListMentionsOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListMentionsOptionsTest.java new file mode 100644 index 00000000000..a07f4575630 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListMentionsOptionsTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListMentionsOptions model. */ +public class ListMentionsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListMentionsOptions() throws Throwable { + ListMentionsOptions listMentionsOptionsModel = + new ListMentionsOptions.Builder() + .workspaceId("testString") + .entity("testString") + .export(true) + .includeAudit(true) + .build(); + assertEquals(listMentionsOptionsModel.workspaceId(), "testString"); + assertEquals(listMentionsOptionsModel.entity(), "testString"); + assertEquals(listMentionsOptionsModel.export(), Boolean.valueOf(true)); + assertEquals(listMentionsOptionsModel.includeAudit(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListMentionsOptionsError() throws Throwable { + new ListMentionsOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListSynonymsOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListSynonymsOptionsTest.java new file mode 100644 index 00000000000..6b65009871b --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListSynonymsOptionsTest.java @@ -0,0 +1,58 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListSynonymsOptions model. */ +public class ListSynonymsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListSynonymsOptions() throws Throwable { + ListSynonymsOptions listSynonymsOptionsModel = + new ListSynonymsOptions.Builder() + .workspaceId("testString") + .entity("testString") + .value("testString") + .pageLimit(Long.valueOf("26")) + .includeCount(true) + .sort("synonym") + .cursor("testString") + .includeAudit(true) + .build(); + assertEquals(listSynonymsOptionsModel.workspaceId(), "testString"); + assertEquals(listSynonymsOptionsModel.entity(), "testString"); + assertEquals(listSynonymsOptionsModel.value(), "testString"); + assertEquals(listSynonymsOptionsModel.pageLimit(), Long.valueOf("26")); + assertEquals(listSynonymsOptionsModel.includeCount(), Boolean.valueOf(true)); + assertEquals(listSynonymsOptionsModel.sort(), "synonym"); + assertEquals(listSynonymsOptionsModel.cursor(), "testString"); + assertEquals(listSynonymsOptionsModel.includeAudit(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListSynonymsOptionsError() throws Throwable { + new ListSynonymsOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListValuesOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListValuesOptionsTest.java new file mode 100644 index 00000000000..59b803a321f --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListValuesOptionsTest.java @@ -0,0 +1,58 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListValuesOptions model. */ +public class ListValuesOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListValuesOptions() throws Throwable { + ListValuesOptions listValuesOptionsModel = + new ListValuesOptions.Builder() + .workspaceId("testString") + .entity("testString") + .export(true) + .pageLimit(Long.valueOf("26")) + .includeCount(true) + .sort("value") + .cursor("testString") + .includeAudit(true) + .build(); + assertEquals(listValuesOptionsModel.workspaceId(), "testString"); + assertEquals(listValuesOptionsModel.entity(), "testString"); + assertEquals(listValuesOptionsModel.export(), Boolean.valueOf(true)); + assertEquals(listValuesOptionsModel.pageLimit(), Long.valueOf("26")); + assertEquals(listValuesOptionsModel.includeCount(), Boolean.valueOf(true)); + assertEquals(listValuesOptionsModel.sort(), "value"); + assertEquals(listValuesOptionsModel.cursor(), "testString"); + assertEquals(listValuesOptionsModel.includeAudit(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListValuesOptionsError() throws Throwable { + new ListValuesOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListWorkspacesOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListWorkspacesOptionsTest.java new file mode 100644 index 00000000000..490352845e5 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ListWorkspacesOptionsTest.java @@ -0,0 +1,47 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListWorkspacesOptions model. */ +public class ListWorkspacesOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListWorkspacesOptions() throws Throwable { + ListWorkspacesOptions listWorkspacesOptionsModel = + new ListWorkspacesOptions.Builder() + .pageLimit(Long.valueOf("26")) + .includeCount(true) + .sort("name") + .cursor("testString") + .includeAudit(true) + .build(); + assertEquals(listWorkspacesOptionsModel.pageLimit(), Long.valueOf("26")); + assertEquals(listWorkspacesOptionsModel.includeCount(), Boolean.valueOf(true)); + assertEquals(listWorkspacesOptionsModel.sort(), "name"); + assertEquals(listWorkspacesOptionsModel.cursor(), "testString"); + assertEquals(listWorkspacesOptionsModel.includeAudit(), Boolean.valueOf(true)); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/LogCollectionTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/LogCollectionTest.java new file mode 100644 index 00000000000..0b07e77e869 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/LogCollectionTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the LogCollection model. */ +public class LogCollectionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testLogCollection() throws Throwable { + LogCollection logCollectionModel = new LogCollection(); + assertNull(logCollectionModel.getLogs()); + assertNull(logCollectionModel.getPagination()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/LogMessageTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/LogMessageTest.java new file mode 100644 index 00000000000..30a67f284fd --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/LogMessageTest.java @@ -0,0 +1,49 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the LogMessage model. */ +public class LogMessageTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testLogMessage() throws Throwable { + LogMessage logMessageModel = new LogMessage.Builder().level("info").msg("testString").build(); + assertEquals(logMessageModel.level(), "info"); + assertEquals(logMessageModel.msg(), "testString"); + + String json = TestUtilities.serialize(logMessageModel); + + LogMessage logMessageModelNew = TestUtilities.deserialize(json, LogMessage.class); + assertTrue(logMessageModelNew instanceof LogMessage); + assertEquals(logMessageModelNew.level(), "info"); + assertEquals(logMessageModelNew.msg(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testLogMessageError() throws Throwable { + new LogMessage.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/LogPaginationTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/LogPaginationTest.java new file mode 100644 index 00000000000..68a794c3e7b --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/LogPaginationTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the LogPagination model. */ +public class LogPaginationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testLogPagination() throws Throwable { + LogPagination logPaginationModel = new LogPagination(); + assertNull(logPaginationModel.getNextUrl()); + assertNull(logPaginationModel.getMatched()); + assertNull(logPaginationModel.getNextCursor()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/LogTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/LogTest.java new file mode 100644 index 00000000000..05e878467f6 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/LogTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Log model. */ +public class LogTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testLog() throws Throwable { + Log logModel = new Log(); + assertNull(logModel.getRequest()); + assertNull(logModel.getResponse()); + assertNull(logModel.getLogId()); + assertNull(logModel.getRequestTimestamp()); + assertNull(logModel.getResponseTimestamp()); + assertNull(logModel.getWorkspaceId()); + assertNull(logModel.getLanguage()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/MentionTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/MentionTest.java new file mode 100644 index 00000000000..00fce41b95c --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/MentionTest.java @@ -0,0 +1,54 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Mention model. */ +public class MentionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMention() throws Throwable { + Mention mentionModel = + new Mention.Builder() + .entity("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) + .build(); + assertEquals(mentionModel.entity(), "testString"); + assertEquals( + mentionModel.location(), + new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))); + + String json = TestUtilities.serialize(mentionModel); + + Mention mentionModelNew = TestUtilities.deserialize(json, Mention.class); + assertTrue(mentionModelNew instanceof Mention); + assertEquals(mentionModelNew.entity(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testMentionError() throws Throwable { + new Mention.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/MessageContextMetadataTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/MessageContextMetadataTest.java new file mode 100644 index 00000000000..452986f59be --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/MessageContextMetadataTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageContextMetadata model. */ +public class MessageContextMetadataTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageContextMetadata() throws Throwable { + MessageContextMetadata messageContextMetadataModel = + new MessageContextMetadata.Builder().deployment("testString").userId("testString").build(); + assertEquals(messageContextMetadataModel.deployment(), "testString"); + assertEquals(messageContextMetadataModel.userId(), "testString"); + + String json = TestUtilities.serialize(messageContextMetadataModel); + + MessageContextMetadata messageContextMetadataModelNew = + TestUtilities.deserialize(json, MessageContextMetadata.class); + assertTrue(messageContextMetadataModelNew instanceof MessageContextMetadata); + assertEquals(messageContextMetadataModelNew.deployment(), "testString"); + assertEquals(messageContextMetadataModelNew.userId(), "testString"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/MessageInputTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/MessageInputTest.java new file mode 100644 index 00000000000..3328955535f --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/MessageInputTest.java @@ -0,0 +1,54 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageInput model. */ +public class MessageInputTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageInput() throws Throwable { + MessageInput messageInputModel = + new MessageInput.Builder() + .text("testString") + .spellingSuggestions(true) + .spellingAutoCorrect(true) + .add("foo", "testString") + .build(); + assertEquals(messageInputModel.getText(), "testString"); + assertEquals(messageInputModel.isSpellingSuggestions(), Boolean.valueOf(true)); + assertEquals(messageInputModel.isSpellingAutoCorrect(), Boolean.valueOf(true)); + assertEquals(messageInputModel.get("foo"), "testString"); + + String json = TestUtilities.serialize(messageInputModel); + + MessageInput messageInputModelNew = TestUtilities.deserialize(json, MessageInput.class); + assertTrue(messageInputModelNew instanceof MessageInput); + assertEquals(messageInputModelNew.getText(), "testString"); + assertEquals(messageInputModelNew.isSpellingSuggestions(), Boolean.valueOf(true)); + assertEquals(messageInputModelNew.isSpellingAutoCorrect(), Boolean.valueOf(true)); + assertEquals(messageInputModelNew.get("foo"), "testString"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/MessageOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/MessageOptionsTest.java new file mode 100644 index 00000000000..d70d1712825 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/MessageOptionsTest.java @@ -0,0 +1,321 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageOptions model. */ +public class MessageOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageOptions() throws Throwable { + MessageInput messageInputModel = + new MessageInput.Builder() + .text("testString") + .spellingSuggestions(true) + .spellingAutoCorrect(true) + .add("foo", "testString") + .build(); + assertEquals(messageInputModel.getText(), "testString"); + assertEquals(messageInputModel.isSpellingSuggestions(), Boolean.valueOf(true)); + assertEquals(messageInputModel.isSpellingAutoCorrect(), Boolean.valueOf(true)); + assertEquals(messageInputModel.get("foo"), "testString"); + + RuntimeIntent runtimeIntentModel = + new RuntimeIntent.Builder().intent("testString").confidence(Double.valueOf("72.5")).build(); + assertEquals(runtimeIntentModel.intent(), "testString"); + assertEquals(runtimeIntentModel.confidence(), Double.valueOf("72.5")); + + CaptureGroup captureGroupModel = + new CaptureGroup.Builder() + .group("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) + .build(); + assertEquals(captureGroupModel.group(), "testString"); + assertEquals( + captureGroupModel.location(), + new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))); + + RuntimeEntityInterpretation runtimeEntityInterpretationModel = + new RuntimeEntityInterpretation.Builder() + .calendarType("testString") + .datetimeLink("testString") + .festival("testString") + .granularity("day") + .rangeLink("testString") + .rangeModifier("testString") + .relativeDay(Double.valueOf("72.5")) + .relativeMonth(Double.valueOf("72.5")) + .relativeWeek(Double.valueOf("72.5")) + .relativeWeekend(Double.valueOf("72.5")) + .relativeYear(Double.valueOf("72.5")) + .specificDay(Double.valueOf("72.5")) + .specificDayOfWeek("testString") + .specificMonth(Double.valueOf("72.5")) + .specificQuarter(Double.valueOf("72.5")) + .specificYear(Double.valueOf("72.5")) + .numericValue(Double.valueOf("72.5")) + .subtype("testString") + .partOfDay("testString") + .relativeHour(Double.valueOf("72.5")) + .relativeMinute(Double.valueOf("72.5")) + .relativeSecond(Double.valueOf("72.5")) + .specificHour(Double.valueOf("72.5")) + .specificMinute(Double.valueOf("72.5")) + .specificSecond(Double.valueOf("72.5")) + .timezone("testString") + .build(); + assertEquals(runtimeEntityInterpretationModel.calendarType(), "testString"); + assertEquals(runtimeEntityInterpretationModel.datetimeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.festival(), "testString"); + assertEquals(runtimeEntityInterpretationModel.granularity(), "day"); + assertEquals(runtimeEntityInterpretationModel.rangeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.rangeModifier(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeek(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeekend(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDayOfWeek(), "testString"); + assertEquals(runtimeEntityInterpretationModel.specificMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificQuarter(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.numericValue(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.subtype(), "testString"); + assertEquals(runtimeEntityInterpretationModel.partOfDay(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.timezone(), "testString"); + + RuntimeEntityAlternative runtimeEntityAlternativeModel = + new RuntimeEntityAlternative.Builder() + .value("testString") + .confidence(Double.valueOf("72.5")) + .build(); + assertEquals(runtimeEntityAlternativeModel.value(), "testString"); + assertEquals(runtimeEntityAlternativeModel.confidence(), Double.valueOf("72.5")); + + RuntimeEntityRole runtimeEntityRoleModel = + new RuntimeEntityRole.Builder().type("date_from").build(); + assertEquals(runtimeEntityRoleModel.type(), "date_from"); + + RuntimeEntity runtimeEntityModel = + new RuntimeEntity.Builder() + .entity("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) + .value("testString") + .confidence(Double.valueOf("72.5")) + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .groups( + new java.util.ArrayList(java.util.Arrays.asList(captureGroupModel))) + .interpretation(runtimeEntityInterpretationModel) + .alternatives( + new java.util.ArrayList( + java.util.Arrays.asList(runtimeEntityAlternativeModel))) + .role(runtimeEntityRoleModel) + .build(); + assertEquals(runtimeEntityModel.entity(), "testString"); + assertEquals( + runtimeEntityModel.location(), + new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))); + assertEquals(runtimeEntityModel.value(), "testString"); + assertEquals(runtimeEntityModel.confidence(), Double.valueOf("72.5")); + assertEquals( + runtimeEntityModel.metadata(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals( + runtimeEntityModel.groups(), + new java.util.ArrayList(java.util.Arrays.asList(captureGroupModel))); + assertEquals(runtimeEntityModel.interpretation(), runtimeEntityInterpretationModel); + assertEquals( + runtimeEntityModel.alternatives(), + new java.util.ArrayList( + java.util.Arrays.asList(runtimeEntityAlternativeModel))); + assertEquals(runtimeEntityModel.role(), runtimeEntityRoleModel); + + MessageContextMetadata messageContextMetadataModel = + new MessageContextMetadata.Builder().deployment("testString").userId("testString").build(); + assertEquals(messageContextMetadataModel.deployment(), "testString"); + assertEquals(messageContextMetadataModel.userId(), "testString"); + + Context contextModel = + new Context.Builder() + .conversationId("testString") + .system( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .metadata(messageContextMetadataModel) + .add("foo", "testString") + .build(); + assertEquals(contextModel.getConversationId(), "testString"); + assertEquals( + contextModel.getSystem(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals(contextModel.getMetadata(), messageContextMetadataModel); + assertEquals(contextModel.get("foo"), "testString"); + + DialogNodeVisitedDetails dialogNodeVisitedDetailsModel = + new DialogNodeVisitedDetails.Builder() + .dialogNode("testString") + .title("testString") + .conditions("testString") + .build(); + assertEquals(dialogNodeVisitedDetailsModel.dialogNode(), "testString"); + assertEquals(dialogNodeVisitedDetailsModel.title(), "testString"); + assertEquals(dialogNodeVisitedDetailsModel.conditions(), "testString"); + + LogMessage logMessageModel = new LogMessage.Builder().level("info").msg("testString").build(); + assertEquals(logMessageModel.level(), "info"); + assertEquals(logMessageModel.msg(), "testString"); + + DialogNodeOutputOptionsElementValue dialogNodeOutputOptionsElementValueModel = + new DialogNodeOutputOptionsElementValue.Builder() + .input(messageInputModel) + .intents( + new java.util.ArrayList(java.util.Arrays.asList(runtimeIntentModel))) + .entities( + new java.util.ArrayList(java.util.Arrays.asList(runtimeEntityModel))) + .build(); + assertEquals(dialogNodeOutputOptionsElementValueModel.input(), messageInputModel); + assertEquals( + dialogNodeOutputOptionsElementValueModel.intents(), + new java.util.ArrayList(java.util.Arrays.asList(runtimeIntentModel))); + assertEquals( + dialogNodeOutputOptionsElementValueModel.entities(), + new java.util.ArrayList(java.util.Arrays.asList(runtimeEntityModel))); + + DialogNodeOutputOptionsElement dialogNodeOutputOptionsElementModel = + new DialogNodeOutputOptionsElement.Builder() + .label("testString") + .value(dialogNodeOutputOptionsElementValueModel) + .build(); + assertEquals(dialogNodeOutputOptionsElementModel.label(), "testString"); + assertEquals( + dialogNodeOutputOptionsElementModel.value(), dialogNodeOutputOptionsElementValueModel); + + RuntimeResponseGenericRuntimeResponseTypeOption runtimeResponseGenericModel = + new RuntimeResponseGenericRuntimeResponseTypeOption.Builder() + .responseType("option") + .title("testString") + .description("testString") + .preference("dropdown") + .options( + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeOutputOptionsElementModel))) + .build(); + assertEquals(runtimeResponseGenericModel.responseType(), "option"); + assertEquals(runtimeResponseGenericModel.title(), "testString"); + assertEquals(runtimeResponseGenericModel.description(), "testString"); + assertEquals(runtimeResponseGenericModel.preference(), "dropdown"); + assertEquals( + runtimeResponseGenericModel.options(), + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeOutputOptionsElementModel))); + + OutputData outputDataModel = + new OutputData.Builder() + .nodesVisited(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .nodesVisitedDetails( + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeVisitedDetailsModel))) + .logMessages( + new java.util.ArrayList(java.util.Arrays.asList(logMessageModel))) + .text(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .generic( + new java.util.ArrayList( + java.util.Arrays.asList(runtimeResponseGenericModel))) + .add("foo", "testString") + .build(); + assertEquals( + outputDataModel.getNodesVisited(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals( + outputDataModel.getNodesVisitedDetails(), + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeVisitedDetailsModel))); + assertEquals( + outputDataModel.getLogMessages(), + new java.util.ArrayList(java.util.Arrays.asList(logMessageModel))); + assertEquals( + outputDataModel.getText(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals( + outputDataModel.getGeneric(), + new java.util.ArrayList( + java.util.Arrays.asList(runtimeResponseGenericModel))); + assertEquals(outputDataModel.get("foo"), "testString"); + + MessageOptions messageOptionsModel = + new MessageOptions.Builder() + .workspaceId("testString") + .input(messageInputModel) + .intents( + new java.util.ArrayList(java.util.Arrays.asList(runtimeIntentModel))) + .entities( + new java.util.ArrayList(java.util.Arrays.asList(runtimeEntityModel))) + .alternateIntents(true) + .context(contextModel) + .output(outputDataModel) + .nodesVisitedDetails(true) + .build(); + assertEquals(messageOptionsModel.workspaceId(), "testString"); + assertEquals(messageOptionsModel.input(), messageInputModel); + assertEquals( + messageOptionsModel.intents(), + new java.util.ArrayList(java.util.Arrays.asList(runtimeIntentModel))); + assertEquals( + messageOptionsModel.entities(), + new java.util.ArrayList(java.util.Arrays.asList(runtimeEntityModel))); + assertEquals(messageOptionsModel.alternateIntents(), Boolean.valueOf(true)); + assertEquals(messageOptionsModel.context(), contextModel); + assertEquals(messageOptionsModel.output(), outputDataModel); + assertEquals(messageOptionsModel.nodesVisitedDetails(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testMessageOptionsError() throws Throwable { + new MessageOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/MessageRequestTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/MessageRequestTest.java new file mode 100644 index 00000000000..05a02b4ac24 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/MessageRequestTest.java @@ -0,0 +1,321 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageRequest model. */ +public class MessageRequestTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageRequest() throws Throwable { + MessageInput messageInputModel = + new MessageInput.Builder() + .text("testString") + .spellingSuggestions(true) + .spellingAutoCorrect(true) + .add("foo", "testString") + .build(); + assertEquals(messageInputModel.getText(), "testString"); + assertEquals(messageInputModel.isSpellingSuggestions(), Boolean.valueOf(true)); + assertEquals(messageInputModel.isSpellingAutoCorrect(), Boolean.valueOf(true)); + assertEquals(messageInputModel.get("foo"), "testString"); + + RuntimeIntent runtimeIntentModel = + new RuntimeIntent.Builder().intent("testString").confidence(Double.valueOf("72.5")).build(); + assertEquals(runtimeIntentModel.intent(), "testString"); + assertEquals(runtimeIntentModel.confidence(), Double.valueOf("72.5")); + + CaptureGroup captureGroupModel = + new CaptureGroup.Builder() + .group("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) + .build(); + assertEquals(captureGroupModel.group(), "testString"); + assertEquals( + captureGroupModel.location(), + new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))); + + RuntimeEntityInterpretation runtimeEntityInterpretationModel = + new RuntimeEntityInterpretation.Builder() + .calendarType("testString") + .datetimeLink("testString") + .festival("testString") + .granularity("day") + .rangeLink("testString") + .rangeModifier("testString") + .relativeDay(Double.valueOf("72.5")) + .relativeMonth(Double.valueOf("72.5")) + .relativeWeek(Double.valueOf("72.5")) + .relativeWeekend(Double.valueOf("72.5")) + .relativeYear(Double.valueOf("72.5")) + .specificDay(Double.valueOf("72.5")) + .specificDayOfWeek("testString") + .specificMonth(Double.valueOf("72.5")) + .specificQuarter(Double.valueOf("72.5")) + .specificYear(Double.valueOf("72.5")) + .numericValue(Double.valueOf("72.5")) + .subtype("testString") + .partOfDay("testString") + .relativeHour(Double.valueOf("72.5")) + .relativeMinute(Double.valueOf("72.5")) + .relativeSecond(Double.valueOf("72.5")) + .specificHour(Double.valueOf("72.5")) + .specificMinute(Double.valueOf("72.5")) + .specificSecond(Double.valueOf("72.5")) + .timezone("testString") + .build(); + assertEquals(runtimeEntityInterpretationModel.calendarType(), "testString"); + assertEquals(runtimeEntityInterpretationModel.datetimeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.festival(), "testString"); + assertEquals(runtimeEntityInterpretationModel.granularity(), "day"); + assertEquals(runtimeEntityInterpretationModel.rangeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.rangeModifier(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeek(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeekend(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDayOfWeek(), "testString"); + assertEquals(runtimeEntityInterpretationModel.specificMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificQuarter(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.numericValue(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.subtype(), "testString"); + assertEquals(runtimeEntityInterpretationModel.partOfDay(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.timezone(), "testString"); + + RuntimeEntityAlternative runtimeEntityAlternativeModel = + new RuntimeEntityAlternative.Builder() + .value("testString") + .confidence(Double.valueOf("72.5")) + .build(); + assertEquals(runtimeEntityAlternativeModel.value(), "testString"); + assertEquals(runtimeEntityAlternativeModel.confidence(), Double.valueOf("72.5")); + + RuntimeEntityRole runtimeEntityRoleModel = + new RuntimeEntityRole.Builder().type("date_from").build(); + assertEquals(runtimeEntityRoleModel.type(), "date_from"); + + RuntimeEntity runtimeEntityModel = + new RuntimeEntity.Builder() + .entity("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) + .value("testString") + .confidence(Double.valueOf("72.5")) + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .groups( + new java.util.ArrayList(java.util.Arrays.asList(captureGroupModel))) + .interpretation(runtimeEntityInterpretationModel) + .alternatives( + new java.util.ArrayList( + java.util.Arrays.asList(runtimeEntityAlternativeModel))) + .role(runtimeEntityRoleModel) + .build(); + assertEquals(runtimeEntityModel.entity(), "testString"); + assertEquals( + runtimeEntityModel.location(), + new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))); + assertEquals(runtimeEntityModel.value(), "testString"); + assertEquals(runtimeEntityModel.confidence(), Double.valueOf("72.5")); + assertEquals( + runtimeEntityModel.metadata(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals( + runtimeEntityModel.groups(), + new java.util.ArrayList(java.util.Arrays.asList(captureGroupModel))); + assertEquals(runtimeEntityModel.interpretation(), runtimeEntityInterpretationModel); + assertEquals( + runtimeEntityModel.alternatives(), + new java.util.ArrayList( + java.util.Arrays.asList(runtimeEntityAlternativeModel))); + assertEquals(runtimeEntityModel.role(), runtimeEntityRoleModel); + + MessageContextMetadata messageContextMetadataModel = + new MessageContextMetadata.Builder().deployment("testString").userId("testString").build(); + assertEquals(messageContextMetadataModel.deployment(), "testString"); + assertEquals(messageContextMetadataModel.userId(), "testString"); + + Context contextModel = + new Context.Builder() + .conversationId("testString") + .system( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .metadata(messageContextMetadataModel) + .add("foo", "testString") + .build(); + assertEquals(contextModel.getConversationId(), "testString"); + assertEquals( + contextModel.getSystem(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals(contextModel.getMetadata(), messageContextMetadataModel); + assertEquals(contextModel.get("foo"), "testString"); + + DialogNodeVisitedDetails dialogNodeVisitedDetailsModel = + new DialogNodeVisitedDetails.Builder() + .dialogNode("testString") + .title("testString") + .conditions("testString") + .build(); + assertEquals(dialogNodeVisitedDetailsModel.dialogNode(), "testString"); + assertEquals(dialogNodeVisitedDetailsModel.title(), "testString"); + assertEquals(dialogNodeVisitedDetailsModel.conditions(), "testString"); + + LogMessage logMessageModel = new LogMessage.Builder().level("info").msg("testString").build(); + assertEquals(logMessageModel.level(), "info"); + assertEquals(logMessageModel.msg(), "testString"); + + DialogNodeOutputOptionsElementValue dialogNodeOutputOptionsElementValueModel = + new DialogNodeOutputOptionsElementValue.Builder() + .input(messageInputModel) + .intents( + new java.util.ArrayList(java.util.Arrays.asList(runtimeIntentModel))) + .entities( + new java.util.ArrayList(java.util.Arrays.asList(runtimeEntityModel))) + .build(); + assertEquals(dialogNodeOutputOptionsElementValueModel.input(), messageInputModel); + assertEquals( + dialogNodeOutputOptionsElementValueModel.intents(), + new java.util.ArrayList(java.util.Arrays.asList(runtimeIntentModel))); + assertEquals( + dialogNodeOutputOptionsElementValueModel.entities(), + new java.util.ArrayList(java.util.Arrays.asList(runtimeEntityModel))); + + DialogNodeOutputOptionsElement dialogNodeOutputOptionsElementModel = + new DialogNodeOutputOptionsElement.Builder() + .label("testString") + .value(dialogNodeOutputOptionsElementValueModel) + .build(); + assertEquals(dialogNodeOutputOptionsElementModel.label(), "testString"); + assertEquals( + dialogNodeOutputOptionsElementModel.value(), dialogNodeOutputOptionsElementValueModel); + + RuntimeResponseGenericRuntimeResponseTypeOption runtimeResponseGenericModel = + new RuntimeResponseGenericRuntimeResponseTypeOption.Builder() + .responseType("option") + .title("testString") + .description("testString") + .preference("dropdown") + .options( + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeOutputOptionsElementModel))) + .build(); + assertEquals(runtimeResponseGenericModel.responseType(), "option"); + assertEquals(runtimeResponseGenericModel.title(), "testString"); + assertEquals(runtimeResponseGenericModel.description(), "testString"); + assertEquals(runtimeResponseGenericModel.preference(), "dropdown"); + assertEquals( + runtimeResponseGenericModel.options(), + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeOutputOptionsElementModel))); + + OutputData outputDataModel = + new OutputData.Builder() + .nodesVisited(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .nodesVisitedDetails( + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeVisitedDetailsModel))) + .logMessages( + new java.util.ArrayList(java.util.Arrays.asList(logMessageModel))) + .text(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .generic( + new java.util.ArrayList( + java.util.Arrays.asList(runtimeResponseGenericModel))) + .add("foo", "testString") + .build(); + assertEquals( + outputDataModel.getNodesVisited(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals( + outputDataModel.getNodesVisitedDetails(), + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeVisitedDetailsModel))); + assertEquals( + outputDataModel.getLogMessages(), + new java.util.ArrayList(java.util.Arrays.asList(logMessageModel))); + assertEquals( + outputDataModel.getText(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals( + outputDataModel.getGeneric(), + new java.util.ArrayList( + java.util.Arrays.asList(runtimeResponseGenericModel))); + assertEquals(outputDataModel.get("foo"), "testString"); + + MessageRequest messageRequestModel = + new MessageRequest.Builder() + .input(messageInputModel) + .intents( + new java.util.ArrayList(java.util.Arrays.asList(runtimeIntentModel))) + .entities( + new java.util.ArrayList(java.util.Arrays.asList(runtimeEntityModel))) + .alternateIntents(true) + .context(contextModel) + .output(outputDataModel) + .build(); + assertEquals(messageRequestModel.input(), messageInputModel); + assertEquals( + messageRequestModel.intents(), + new java.util.ArrayList(java.util.Arrays.asList(runtimeIntentModel))); + assertEquals( + messageRequestModel.entities(), + new java.util.ArrayList(java.util.Arrays.asList(runtimeEntityModel))); + assertEquals(messageRequestModel.alternateIntents(), Boolean.valueOf(true)); + assertEquals(messageRequestModel.context(), contextModel); + assertEquals(messageRequestModel.output(), outputDataModel); + + String json = TestUtilities.serialize(messageRequestModel); + + MessageRequest messageRequestModelNew = TestUtilities.deserialize(json, MessageRequest.class); + assertTrue(messageRequestModelNew instanceof MessageRequest); + assertEquals(messageRequestModelNew.input().toString(), messageInputModel.toString()); + assertEquals(messageRequestModelNew.alternateIntents(), Boolean.valueOf(true)); + assertEquals(messageRequestModelNew.context().toString(), contextModel.toString()); + assertEquals(messageRequestModelNew.output().toString(), outputDataModel.toString()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/MessageResponseTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/MessageResponseTest.java new file mode 100644 index 00000000000..546a99d72b3 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/MessageResponseTest.java @@ -0,0 +1,41 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageResponse model. */ +public class MessageResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageResponse() throws Throwable { + MessageResponse messageResponseModel = new MessageResponse(); + assertNull(messageResponseModel.getInput()); + assertNull(messageResponseModel.getIntents()); + assertNull(messageResponseModel.getEntities()); + assertNull(messageResponseModel.isAlternateIntents()); + assertNull(messageResponseModel.getContext()); + assertNull(messageResponseModel.getOutput()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/OutputDataTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/OutputDataTest.java new file mode 100644 index 00000000000..3633acb55af --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/OutputDataTest.java @@ -0,0 +1,273 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the OutputData model. */ +public class OutputDataTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testOutputData() throws Throwable { + DialogNodeVisitedDetails dialogNodeVisitedDetailsModel = + new DialogNodeVisitedDetails.Builder() + .dialogNode("testString") + .title("testString") + .conditions("testString") + .build(); + assertEquals(dialogNodeVisitedDetailsModel.dialogNode(), "testString"); + assertEquals(dialogNodeVisitedDetailsModel.title(), "testString"); + assertEquals(dialogNodeVisitedDetailsModel.conditions(), "testString"); + + LogMessage logMessageModel = new LogMessage.Builder().level("info").msg("testString").build(); + assertEquals(logMessageModel.level(), "info"); + assertEquals(logMessageModel.msg(), "testString"); + + MessageInput messageInputModel = + new MessageInput.Builder() + .text("testString") + .spellingSuggestions(true) + .spellingAutoCorrect(true) + .add("foo", "testString") + .build(); + assertEquals(messageInputModel.getText(), "testString"); + assertEquals(messageInputModel.isSpellingSuggestions(), Boolean.valueOf(true)); + assertEquals(messageInputModel.isSpellingAutoCorrect(), Boolean.valueOf(true)); + assertEquals(messageInputModel.get("foo"), "testString"); + + RuntimeIntent runtimeIntentModel = + new RuntimeIntent.Builder().intent("testString").confidence(Double.valueOf("72.5")).build(); + assertEquals(runtimeIntentModel.intent(), "testString"); + assertEquals(runtimeIntentModel.confidence(), Double.valueOf("72.5")); + + CaptureGroup captureGroupModel = + new CaptureGroup.Builder() + .group("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) + .build(); + assertEquals(captureGroupModel.group(), "testString"); + assertEquals( + captureGroupModel.location(), + new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))); + + RuntimeEntityInterpretation runtimeEntityInterpretationModel = + new RuntimeEntityInterpretation.Builder() + .calendarType("testString") + .datetimeLink("testString") + .festival("testString") + .granularity("day") + .rangeLink("testString") + .rangeModifier("testString") + .relativeDay(Double.valueOf("72.5")) + .relativeMonth(Double.valueOf("72.5")) + .relativeWeek(Double.valueOf("72.5")) + .relativeWeekend(Double.valueOf("72.5")) + .relativeYear(Double.valueOf("72.5")) + .specificDay(Double.valueOf("72.5")) + .specificDayOfWeek("testString") + .specificMonth(Double.valueOf("72.5")) + .specificQuarter(Double.valueOf("72.5")) + .specificYear(Double.valueOf("72.5")) + .numericValue(Double.valueOf("72.5")) + .subtype("testString") + .partOfDay("testString") + .relativeHour(Double.valueOf("72.5")) + .relativeMinute(Double.valueOf("72.5")) + .relativeSecond(Double.valueOf("72.5")) + .specificHour(Double.valueOf("72.5")) + .specificMinute(Double.valueOf("72.5")) + .specificSecond(Double.valueOf("72.5")) + .timezone("testString") + .build(); + assertEquals(runtimeEntityInterpretationModel.calendarType(), "testString"); + assertEquals(runtimeEntityInterpretationModel.datetimeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.festival(), "testString"); + assertEquals(runtimeEntityInterpretationModel.granularity(), "day"); + assertEquals(runtimeEntityInterpretationModel.rangeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.rangeModifier(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeek(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeekend(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDayOfWeek(), "testString"); + assertEquals(runtimeEntityInterpretationModel.specificMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificQuarter(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.numericValue(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.subtype(), "testString"); + assertEquals(runtimeEntityInterpretationModel.partOfDay(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.timezone(), "testString"); + + RuntimeEntityAlternative runtimeEntityAlternativeModel = + new RuntimeEntityAlternative.Builder() + .value("testString") + .confidence(Double.valueOf("72.5")) + .build(); + assertEquals(runtimeEntityAlternativeModel.value(), "testString"); + assertEquals(runtimeEntityAlternativeModel.confidence(), Double.valueOf("72.5")); + + RuntimeEntityRole runtimeEntityRoleModel = + new RuntimeEntityRole.Builder().type("date_from").build(); + assertEquals(runtimeEntityRoleModel.type(), "date_from"); + + RuntimeEntity runtimeEntityModel = + new RuntimeEntity.Builder() + .entity("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) + .value("testString") + .confidence(Double.valueOf("72.5")) + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .groups( + new java.util.ArrayList(java.util.Arrays.asList(captureGroupModel))) + .interpretation(runtimeEntityInterpretationModel) + .alternatives( + new java.util.ArrayList( + java.util.Arrays.asList(runtimeEntityAlternativeModel))) + .role(runtimeEntityRoleModel) + .build(); + assertEquals(runtimeEntityModel.entity(), "testString"); + assertEquals( + runtimeEntityModel.location(), + new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))); + assertEquals(runtimeEntityModel.value(), "testString"); + assertEquals(runtimeEntityModel.confidence(), Double.valueOf("72.5")); + assertEquals( + runtimeEntityModel.metadata(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals( + runtimeEntityModel.groups(), + new java.util.ArrayList(java.util.Arrays.asList(captureGroupModel))); + assertEquals(runtimeEntityModel.interpretation(), runtimeEntityInterpretationModel); + assertEquals( + runtimeEntityModel.alternatives(), + new java.util.ArrayList( + java.util.Arrays.asList(runtimeEntityAlternativeModel))); + assertEquals(runtimeEntityModel.role(), runtimeEntityRoleModel); + + DialogNodeOutputOptionsElementValue dialogNodeOutputOptionsElementValueModel = + new DialogNodeOutputOptionsElementValue.Builder() + .input(messageInputModel) + .intents( + new java.util.ArrayList(java.util.Arrays.asList(runtimeIntentModel))) + .entities( + new java.util.ArrayList(java.util.Arrays.asList(runtimeEntityModel))) + .build(); + assertEquals(dialogNodeOutputOptionsElementValueModel.input(), messageInputModel); + assertEquals( + dialogNodeOutputOptionsElementValueModel.intents(), + new java.util.ArrayList(java.util.Arrays.asList(runtimeIntentModel))); + assertEquals( + dialogNodeOutputOptionsElementValueModel.entities(), + new java.util.ArrayList(java.util.Arrays.asList(runtimeEntityModel))); + + DialogNodeOutputOptionsElement dialogNodeOutputOptionsElementModel = + new DialogNodeOutputOptionsElement.Builder() + .label("testString") + .value(dialogNodeOutputOptionsElementValueModel) + .build(); + assertEquals(dialogNodeOutputOptionsElementModel.label(), "testString"); + assertEquals( + dialogNodeOutputOptionsElementModel.value(), dialogNodeOutputOptionsElementValueModel); + + RuntimeResponseGenericRuntimeResponseTypeOption runtimeResponseGenericModel = + new RuntimeResponseGenericRuntimeResponseTypeOption.Builder() + .responseType("option") + .title("testString") + .description("testString") + .preference("dropdown") + .options( + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeOutputOptionsElementModel))) + .build(); + assertEquals(runtimeResponseGenericModel.responseType(), "option"); + assertEquals(runtimeResponseGenericModel.title(), "testString"); + assertEquals(runtimeResponseGenericModel.description(), "testString"); + assertEquals(runtimeResponseGenericModel.preference(), "dropdown"); + assertEquals( + runtimeResponseGenericModel.options(), + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeOutputOptionsElementModel))); + + OutputData outputDataModel = + new OutputData.Builder() + .nodesVisited(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .nodesVisitedDetails( + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeVisitedDetailsModel))) + .logMessages( + new java.util.ArrayList(java.util.Arrays.asList(logMessageModel))) + .text(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .generic( + new java.util.ArrayList( + java.util.Arrays.asList(runtimeResponseGenericModel))) + .add("foo", "testString") + .build(); + assertEquals( + outputDataModel.getNodesVisited(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals( + outputDataModel.getNodesVisitedDetails(), + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeVisitedDetailsModel))); + assertEquals( + outputDataModel.getLogMessages(), + new java.util.ArrayList(java.util.Arrays.asList(logMessageModel))); + assertEquals( + outputDataModel.getText(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals( + outputDataModel.getGeneric(), + new java.util.ArrayList( + java.util.Arrays.asList(runtimeResponseGenericModel))); + assertEquals(outputDataModel.get("foo"), "testString"); + + String json = TestUtilities.serialize(outputDataModel); + + OutputData outputDataModelNew = TestUtilities.deserialize(json, OutputData.class); + assertTrue(outputDataModelNew instanceof OutputData); + assertEquals(outputDataModelNew.get("foo"), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testOutputDataError() throws Throwable { + new OutputData.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/PaginationTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/PaginationTest.java new file mode 100644 index 00000000000..a0c812a84b8 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/PaginationTest.java @@ -0,0 +1,41 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Pagination model. */ +public class PaginationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testPagination() throws Throwable { + Pagination paginationModel = new Pagination(); + assertNull(paginationModel.getRefreshUrl()); + assertNull(paginationModel.getNextUrl()); + assertNull(paginationModel.getTotal()); + assertNull(paginationModel.getMatched()); + assertNull(paginationModel.getRefreshCursor()); + assertNull(paginationModel.getNextCursor()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeEntityAlternativeTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeEntityAlternativeTest.java new file mode 100644 index 00000000000..2eb058e5009 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeEntityAlternativeTest.java @@ -0,0 +1,49 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeEntityAlternative model. */ +public class RuntimeEntityAlternativeTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeEntityAlternative() throws Throwable { + RuntimeEntityAlternative runtimeEntityAlternativeModel = + new RuntimeEntityAlternative.Builder() + .value("testString") + .confidence(Double.valueOf("72.5")) + .build(); + assertEquals(runtimeEntityAlternativeModel.value(), "testString"); + assertEquals(runtimeEntityAlternativeModel.confidence(), Double.valueOf("72.5")); + + String json = TestUtilities.serialize(runtimeEntityAlternativeModel); + + RuntimeEntityAlternative runtimeEntityAlternativeModelNew = + TestUtilities.deserialize(json, RuntimeEntityAlternative.class); + assertTrue(runtimeEntityAlternativeModelNew instanceof RuntimeEntityAlternative); + assertEquals(runtimeEntityAlternativeModelNew.value(), "testString"); + assertEquals(runtimeEntityAlternativeModelNew.confidence(), Double.valueOf("72.5")); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeEntityInterpretationTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeEntityInterpretationTest.java new file mode 100644 index 00000000000..e0f9570575f --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeEntityInterpretationTest.java @@ -0,0 +1,121 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeEntityInterpretation model. */ +public class RuntimeEntityInterpretationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeEntityInterpretation() throws Throwable { + RuntimeEntityInterpretation runtimeEntityInterpretationModel = + new RuntimeEntityInterpretation.Builder() + .calendarType("testString") + .datetimeLink("testString") + .festival("testString") + .granularity("day") + .rangeLink("testString") + .rangeModifier("testString") + .relativeDay(Double.valueOf("72.5")) + .relativeMonth(Double.valueOf("72.5")) + .relativeWeek(Double.valueOf("72.5")) + .relativeWeekend(Double.valueOf("72.5")) + .relativeYear(Double.valueOf("72.5")) + .specificDay(Double.valueOf("72.5")) + .specificDayOfWeek("testString") + .specificMonth(Double.valueOf("72.5")) + .specificQuarter(Double.valueOf("72.5")) + .specificYear(Double.valueOf("72.5")) + .numericValue(Double.valueOf("72.5")) + .subtype("testString") + .partOfDay("testString") + .relativeHour(Double.valueOf("72.5")) + .relativeMinute(Double.valueOf("72.5")) + .relativeSecond(Double.valueOf("72.5")) + .specificHour(Double.valueOf("72.5")) + .specificMinute(Double.valueOf("72.5")) + .specificSecond(Double.valueOf("72.5")) + .timezone("testString") + .build(); + assertEquals(runtimeEntityInterpretationModel.calendarType(), "testString"); + assertEquals(runtimeEntityInterpretationModel.datetimeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.festival(), "testString"); + assertEquals(runtimeEntityInterpretationModel.granularity(), "day"); + assertEquals(runtimeEntityInterpretationModel.rangeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.rangeModifier(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeek(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeekend(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDayOfWeek(), "testString"); + assertEquals(runtimeEntityInterpretationModel.specificMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificQuarter(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.numericValue(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.subtype(), "testString"); + assertEquals(runtimeEntityInterpretationModel.partOfDay(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.timezone(), "testString"); + + String json = TestUtilities.serialize(runtimeEntityInterpretationModel); + + RuntimeEntityInterpretation runtimeEntityInterpretationModelNew = + TestUtilities.deserialize(json, RuntimeEntityInterpretation.class); + assertTrue(runtimeEntityInterpretationModelNew instanceof RuntimeEntityInterpretation); + assertEquals(runtimeEntityInterpretationModelNew.calendarType(), "testString"); + assertEquals(runtimeEntityInterpretationModelNew.datetimeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModelNew.festival(), "testString"); + assertEquals(runtimeEntityInterpretationModelNew.granularity(), "day"); + assertEquals(runtimeEntityInterpretationModelNew.rangeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModelNew.rangeModifier(), "testString"); + assertEquals(runtimeEntityInterpretationModelNew.relativeDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.relativeMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.relativeWeek(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.relativeWeekend(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.relativeYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.specificDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.specificDayOfWeek(), "testString"); + assertEquals(runtimeEntityInterpretationModelNew.specificMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.specificQuarter(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.specificYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.numericValue(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.subtype(), "testString"); + assertEquals(runtimeEntityInterpretationModelNew.partOfDay(), "testString"); + assertEquals(runtimeEntityInterpretationModelNew.relativeHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.relativeMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.relativeSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.specificHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.specificMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.specificSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.timezone(), "testString"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeEntityRoleTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeEntityRoleTest.java new file mode 100644 index 00000000000..e63705f19b6 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeEntityRoleTest.java @@ -0,0 +1,44 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeEntityRole model. */ +public class RuntimeEntityRoleTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeEntityRole() throws Throwable { + RuntimeEntityRole runtimeEntityRoleModel = + new RuntimeEntityRole.Builder().type("date_from").build(); + assertEquals(runtimeEntityRoleModel.type(), "date_from"); + + String json = TestUtilities.serialize(runtimeEntityRoleModel); + + RuntimeEntityRole runtimeEntityRoleModelNew = + TestUtilities.deserialize(json, RuntimeEntityRole.class); + assertTrue(runtimeEntityRoleModelNew instanceof RuntimeEntityRole); + assertEquals(runtimeEntityRoleModelNew.type(), "date_from"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeEntityTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeEntityTest.java new file mode 100644 index 00000000000..0ae93182e2c --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeEntityTest.java @@ -0,0 +1,171 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeEntity model. */ +public class RuntimeEntityTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeEntity() throws Throwable { + CaptureGroup captureGroupModel = + new CaptureGroup.Builder() + .group("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) + .build(); + assertEquals(captureGroupModel.group(), "testString"); + assertEquals( + captureGroupModel.location(), + new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))); + + RuntimeEntityInterpretation runtimeEntityInterpretationModel = + new RuntimeEntityInterpretation.Builder() + .calendarType("testString") + .datetimeLink("testString") + .festival("testString") + .granularity("day") + .rangeLink("testString") + .rangeModifier("testString") + .relativeDay(Double.valueOf("72.5")) + .relativeMonth(Double.valueOf("72.5")) + .relativeWeek(Double.valueOf("72.5")) + .relativeWeekend(Double.valueOf("72.5")) + .relativeYear(Double.valueOf("72.5")) + .specificDay(Double.valueOf("72.5")) + .specificDayOfWeek("testString") + .specificMonth(Double.valueOf("72.5")) + .specificQuarter(Double.valueOf("72.5")) + .specificYear(Double.valueOf("72.5")) + .numericValue(Double.valueOf("72.5")) + .subtype("testString") + .partOfDay("testString") + .relativeHour(Double.valueOf("72.5")) + .relativeMinute(Double.valueOf("72.5")) + .relativeSecond(Double.valueOf("72.5")) + .specificHour(Double.valueOf("72.5")) + .specificMinute(Double.valueOf("72.5")) + .specificSecond(Double.valueOf("72.5")) + .timezone("testString") + .build(); + assertEquals(runtimeEntityInterpretationModel.calendarType(), "testString"); + assertEquals(runtimeEntityInterpretationModel.datetimeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.festival(), "testString"); + assertEquals(runtimeEntityInterpretationModel.granularity(), "day"); + assertEquals(runtimeEntityInterpretationModel.rangeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.rangeModifier(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeek(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeekend(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDayOfWeek(), "testString"); + assertEquals(runtimeEntityInterpretationModel.specificMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificQuarter(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.numericValue(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.subtype(), "testString"); + assertEquals(runtimeEntityInterpretationModel.partOfDay(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.timezone(), "testString"); + + RuntimeEntityAlternative runtimeEntityAlternativeModel = + new RuntimeEntityAlternative.Builder() + .value("testString") + .confidence(Double.valueOf("72.5")) + .build(); + assertEquals(runtimeEntityAlternativeModel.value(), "testString"); + assertEquals(runtimeEntityAlternativeModel.confidence(), Double.valueOf("72.5")); + + RuntimeEntityRole runtimeEntityRoleModel = + new RuntimeEntityRole.Builder().type("date_from").build(); + assertEquals(runtimeEntityRoleModel.type(), "date_from"); + + RuntimeEntity runtimeEntityModel = + new RuntimeEntity.Builder() + .entity("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) + .value("testString") + .confidence(Double.valueOf("72.5")) + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .groups( + new java.util.ArrayList(java.util.Arrays.asList(captureGroupModel))) + .interpretation(runtimeEntityInterpretationModel) + .alternatives( + new java.util.ArrayList( + java.util.Arrays.asList(runtimeEntityAlternativeModel))) + .role(runtimeEntityRoleModel) + .build(); + assertEquals(runtimeEntityModel.entity(), "testString"); + assertEquals( + runtimeEntityModel.location(), + new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))); + assertEquals(runtimeEntityModel.value(), "testString"); + assertEquals(runtimeEntityModel.confidence(), Double.valueOf("72.5")); + assertEquals( + runtimeEntityModel.metadata(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals( + runtimeEntityModel.groups(), + new java.util.ArrayList(java.util.Arrays.asList(captureGroupModel))); + assertEquals(runtimeEntityModel.interpretation(), runtimeEntityInterpretationModel); + assertEquals( + runtimeEntityModel.alternatives(), + new java.util.ArrayList( + java.util.Arrays.asList(runtimeEntityAlternativeModel))); + assertEquals(runtimeEntityModel.role(), runtimeEntityRoleModel); + + String json = TestUtilities.serialize(runtimeEntityModel); + + RuntimeEntity runtimeEntityModelNew = TestUtilities.deserialize(json, RuntimeEntity.class); + assertTrue(runtimeEntityModelNew instanceof RuntimeEntity); + assertEquals(runtimeEntityModelNew.entity(), "testString"); + assertEquals(runtimeEntityModelNew.value(), "testString"); + assertEquals(runtimeEntityModelNew.confidence(), Double.valueOf("72.5")); + assertEquals( + runtimeEntityModelNew.interpretation().toString(), + runtimeEntityInterpretationModel.toString()); + assertEquals(runtimeEntityModelNew.role().toString(), runtimeEntityRoleModel.toString()); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testRuntimeEntityError() throws Throwable { + new RuntimeEntity.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeIntentTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeIntentTest.java new file mode 100644 index 00000000000..e7c1fd0acf2 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeIntentTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeIntent model. */ +public class RuntimeIntentTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeIntent() throws Throwable { + RuntimeIntent runtimeIntentModel = + new RuntimeIntent.Builder().intent("testString").confidence(Double.valueOf("72.5")).build(); + assertEquals(runtimeIntentModel.intent(), "testString"); + assertEquals(runtimeIntentModel.confidence(), Double.valueOf("72.5")); + + String json = TestUtilities.serialize(runtimeIntentModel); + + RuntimeIntent runtimeIntentModelNew = TestUtilities.deserialize(json, RuntimeIntent.class); + assertTrue(runtimeIntentModelNew instanceof RuntimeIntent); + assertEquals(runtimeIntentModelNew.intent(), "testString"); + assertEquals(runtimeIntentModelNew.confidence(), Double.valueOf("72.5")); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testRuntimeIntentError() throws Throwable { + new RuntimeIntent.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeConnectToAgentTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeConnectToAgentTest.java new file mode 100644 index 00000000000..740881c2620 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeConnectToAgentTest.java @@ -0,0 +1,129 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeResponseGenericRuntimeResponseTypeConnectToAgent model. */ +public class RuntimeResponseGenericRuntimeResponseTypeConnectToAgentTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeResponseGenericRuntimeResponseTypeConnectToAgent() throws Throwable { + DialogNodeOutputConnectToAgentTransferInfo dialogNodeOutputConnectToAgentTransferInfoModel = + new DialogNodeOutputConnectToAgentTransferInfo.Builder() + .target( + new java.util.HashMap>() { + { + put( + "foo", + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + } + }) + .build(); + assertEquals( + dialogNodeOutputConnectToAgentTransferInfoModel.target(), + new java.util.HashMap>() { + { + put( + "foo", + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + } + }); + + RuntimeResponseGenericRuntimeResponseTypeConnectToAgent + runtimeResponseGenericRuntimeResponseTypeConnectToAgentModel = + new RuntimeResponseGenericRuntimeResponseTypeConnectToAgent.Builder() + .responseType("connect_to_agent") + .messageToHumanAgent("testString") + .agentAvailable("testString") + .agentUnavailable("testString") + .transferInfo(dialogNodeOutputConnectToAgentTransferInfoModel) + .topic("testString") + .dialogNode("testString") + .build(); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeConnectToAgentModel.responseType(), + "connect_to_agent"); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeConnectToAgentModel.messageToHumanAgent(), + "testString"); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeConnectToAgentModel.agentAvailable(), + "testString"); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeConnectToAgentModel.agentUnavailable(), + "testString"); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeConnectToAgentModel.transferInfo(), + dialogNodeOutputConnectToAgentTransferInfoModel); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeConnectToAgentModel.topic(), "testString"); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeConnectToAgentModel.dialogNode(), "testString"); + + String json = + TestUtilities.serialize(runtimeResponseGenericRuntimeResponseTypeConnectToAgentModel); + + RuntimeResponseGenericRuntimeResponseTypeConnectToAgent + runtimeResponseGenericRuntimeResponseTypeConnectToAgentModelNew = + TestUtilities.deserialize( + json, RuntimeResponseGenericRuntimeResponseTypeConnectToAgent.class); + assertTrue( + runtimeResponseGenericRuntimeResponseTypeConnectToAgentModelNew + instanceof RuntimeResponseGenericRuntimeResponseTypeConnectToAgent); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeConnectToAgentModelNew.responseType(), + "connect_to_agent"); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeConnectToAgentModelNew.messageToHumanAgent(), + "testString"); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeConnectToAgentModelNew.agentAvailable(), + "testString"); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeConnectToAgentModelNew.agentUnavailable(), + "testString"); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeConnectToAgentModelNew.transferInfo().toString(), + dialogNodeOutputConnectToAgentTransferInfoModel.toString()); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeConnectToAgentModelNew.topic(), "testString"); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeConnectToAgentModelNew.dialogNode(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testRuntimeResponseGenericRuntimeResponseTypeConnectToAgentError() throws Throwable { + new RuntimeResponseGenericRuntimeResponseTypeConnectToAgent.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeImageTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeImageTest.java new file mode 100644 index 00000000000..ccf5fa67af7 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeImageTest.java @@ -0,0 +1,65 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeResponseGenericRuntimeResponseTypeImage model. */ +public class RuntimeResponseGenericRuntimeResponseTypeImageTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeResponseGenericRuntimeResponseTypeImage() throws Throwable { + RuntimeResponseGenericRuntimeResponseTypeImage + runtimeResponseGenericRuntimeResponseTypeImageModel = + new RuntimeResponseGenericRuntimeResponseTypeImage.Builder() + .responseType("image") + .source("testString") + .title("testString") + .description("testString") + .build(); + assertEquals(runtimeResponseGenericRuntimeResponseTypeImageModel.responseType(), "image"); + assertEquals(runtimeResponseGenericRuntimeResponseTypeImageModel.source(), "testString"); + assertEquals(runtimeResponseGenericRuntimeResponseTypeImageModel.title(), "testString"); + assertEquals(runtimeResponseGenericRuntimeResponseTypeImageModel.description(), "testString"); + + String json = TestUtilities.serialize(runtimeResponseGenericRuntimeResponseTypeImageModel); + + RuntimeResponseGenericRuntimeResponseTypeImage + runtimeResponseGenericRuntimeResponseTypeImageModelNew = + TestUtilities.deserialize(json, RuntimeResponseGenericRuntimeResponseTypeImage.class); + assertTrue( + runtimeResponseGenericRuntimeResponseTypeImageModelNew + instanceof RuntimeResponseGenericRuntimeResponseTypeImage); + assertEquals(runtimeResponseGenericRuntimeResponseTypeImageModelNew.responseType(), "image"); + assertEquals(runtimeResponseGenericRuntimeResponseTypeImageModelNew.source(), "testString"); + assertEquals(runtimeResponseGenericRuntimeResponseTypeImageModelNew.title(), "testString"); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeImageModelNew.description(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testRuntimeResponseGenericRuntimeResponseTypeImageError() throws Throwable { + new RuntimeResponseGenericRuntimeResponseTypeImage.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeOptionTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeOptionTest.java new file mode 100644 index 00000000000..48f48974d1d --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeOptionTest.java @@ -0,0 +1,235 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeResponseGenericRuntimeResponseTypeOption model. */ +public class RuntimeResponseGenericRuntimeResponseTypeOptionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeResponseGenericRuntimeResponseTypeOption() throws Throwable { + MessageInput messageInputModel = + new MessageInput.Builder() + .text("testString") + .spellingSuggestions(true) + .spellingAutoCorrect(true) + .add("foo", "testString") + .build(); + assertEquals(messageInputModel.getText(), "testString"); + assertEquals(messageInputModel.isSpellingSuggestions(), Boolean.valueOf(true)); + assertEquals(messageInputModel.isSpellingAutoCorrect(), Boolean.valueOf(true)); + assertEquals(messageInputModel.get("foo"), "testString"); + + RuntimeIntent runtimeIntentModel = + new RuntimeIntent.Builder().intent("testString").confidence(Double.valueOf("72.5")).build(); + assertEquals(runtimeIntentModel.intent(), "testString"); + assertEquals(runtimeIntentModel.confidence(), Double.valueOf("72.5")); + + CaptureGroup captureGroupModel = + new CaptureGroup.Builder() + .group("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) + .build(); + assertEquals(captureGroupModel.group(), "testString"); + assertEquals( + captureGroupModel.location(), + new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))); + + RuntimeEntityInterpretation runtimeEntityInterpretationModel = + new RuntimeEntityInterpretation.Builder() + .calendarType("testString") + .datetimeLink("testString") + .festival("testString") + .granularity("day") + .rangeLink("testString") + .rangeModifier("testString") + .relativeDay(Double.valueOf("72.5")) + .relativeMonth(Double.valueOf("72.5")) + .relativeWeek(Double.valueOf("72.5")) + .relativeWeekend(Double.valueOf("72.5")) + .relativeYear(Double.valueOf("72.5")) + .specificDay(Double.valueOf("72.5")) + .specificDayOfWeek("testString") + .specificMonth(Double.valueOf("72.5")) + .specificQuarter(Double.valueOf("72.5")) + .specificYear(Double.valueOf("72.5")) + .numericValue(Double.valueOf("72.5")) + .subtype("testString") + .partOfDay("testString") + .relativeHour(Double.valueOf("72.5")) + .relativeMinute(Double.valueOf("72.5")) + .relativeSecond(Double.valueOf("72.5")) + .specificHour(Double.valueOf("72.5")) + .specificMinute(Double.valueOf("72.5")) + .specificSecond(Double.valueOf("72.5")) + .timezone("testString") + .build(); + assertEquals(runtimeEntityInterpretationModel.calendarType(), "testString"); + assertEquals(runtimeEntityInterpretationModel.datetimeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.festival(), "testString"); + assertEquals(runtimeEntityInterpretationModel.granularity(), "day"); + assertEquals(runtimeEntityInterpretationModel.rangeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.rangeModifier(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeek(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeekend(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDayOfWeek(), "testString"); + assertEquals(runtimeEntityInterpretationModel.specificMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificQuarter(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.numericValue(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.subtype(), "testString"); + assertEquals(runtimeEntityInterpretationModel.partOfDay(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.timezone(), "testString"); + + RuntimeEntityAlternative runtimeEntityAlternativeModel = + new RuntimeEntityAlternative.Builder() + .value("testString") + .confidence(Double.valueOf("72.5")) + .build(); + assertEquals(runtimeEntityAlternativeModel.value(), "testString"); + assertEquals(runtimeEntityAlternativeModel.confidence(), Double.valueOf("72.5")); + + RuntimeEntityRole runtimeEntityRoleModel = + new RuntimeEntityRole.Builder().type("date_from").build(); + assertEquals(runtimeEntityRoleModel.type(), "date_from"); + + RuntimeEntity runtimeEntityModel = + new RuntimeEntity.Builder() + .entity("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) + .value("testString") + .confidence(Double.valueOf("72.5")) + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .groups( + new java.util.ArrayList(java.util.Arrays.asList(captureGroupModel))) + .interpretation(runtimeEntityInterpretationModel) + .alternatives( + new java.util.ArrayList( + java.util.Arrays.asList(runtimeEntityAlternativeModel))) + .role(runtimeEntityRoleModel) + .build(); + assertEquals(runtimeEntityModel.entity(), "testString"); + assertEquals( + runtimeEntityModel.location(), + new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))); + assertEquals(runtimeEntityModel.value(), "testString"); + assertEquals(runtimeEntityModel.confidence(), Double.valueOf("72.5")); + assertEquals( + runtimeEntityModel.metadata(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals( + runtimeEntityModel.groups(), + new java.util.ArrayList(java.util.Arrays.asList(captureGroupModel))); + assertEquals(runtimeEntityModel.interpretation(), runtimeEntityInterpretationModel); + assertEquals( + runtimeEntityModel.alternatives(), + new java.util.ArrayList( + java.util.Arrays.asList(runtimeEntityAlternativeModel))); + assertEquals(runtimeEntityModel.role(), runtimeEntityRoleModel); + + DialogNodeOutputOptionsElementValue dialogNodeOutputOptionsElementValueModel = + new DialogNodeOutputOptionsElementValue.Builder() + .input(messageInputModel) + .intents( + new java.util.ArrayList(java.util.Arrays.asList(runtimeIntentModel))) + .entities( + new java.util.ArrayList(java.util.Arrays.asList(runtimeEntityModel))) + .build(); + assertEquals(dialogNodeOutputOptionsElementValueModel.input(), messageInputModel); + assertEquals( + dialogNodeOutputOptionsElementValueModel.intents(), + new java.util.ArrayList(java.util.Arrays.asList(runtimeIntentModel))); + assertEquals( + dialogNodeOutputOptionsElementValueModel.entities(), + new java.util.ArrayList(java.util.Arrays.asList(runtimeEntityModel))); + + DialogNodeOutputOptionsElement dialogNodeOutputOptionsElementModel = + new DialogNodeOutputOptionsElement.Builder() + .label("testString") + .value(dialogNodeOutputOptionsElementValueModel) + .build(); + assertEquals(dialogNodeOutputOptionsElementModel.label(), "testString"); + assertEquals( + dialogNodeOutputOptionsElementModel.value(), dialogNodeOutputOptionsElementValueModel); + + RuntimeResponseGenericRuntimeResponseTypeOption + runtimeResponseGenericRuntimeResponseTypeOptionModel = + new RuntimeResponseGenericRuntimeResponseTypeOption.Builder() + .responseType("option") + .title("testString") + .description("testString") + .preference("dropdown") + .options( + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeOutputOptionsElementModel))) + .build(); + assertEquals(runtimeResponseGenericRuntimeResponseTypeOptionModel.responseType(), "option"); + assertEquals(runtimeResponseGenericRuntimeResponseTypeOptionModel.title(), "testString"); + assertEquals(runtimeResponseGenericRuntimeResponseTypeOptionModel.description(), "testString"); + assertEquals(runtimeResponseGenericRuntimeResponseTypeOptionModel.preference(), "dropdown"); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeOptionModel.options(), + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeOutputOptionsElementModel))); + + String json = TestUtilities.serialize(runtimeResponseGenericRuntimeResponseTypeOptionModel); + + RuntimeResponseGenericRuntimeResponseTypeOption + runtimeResponseGenericRuntimeResponseTypeOptionModelNew = + TestUtilities.deserialize(json, RuntimeResponseGenericRuntimeResponseTypeOption.class); + assertTrue( + runtimeResponseGenericRuntimeResponseTypeOptionModelNew + instanceof RuntimeResponseGenericRuntimeResponseTypeOption); + assertEquals(runtimeResponseGenericRuntimeResponseTypeOptionModelNew.responseType(), "option"); + assertEquals(runtimeResponseGenericRuntimeResponseTypeOptionModelNew.title(), "testString"); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeOptionModelNew.description(), "testString"); + assertEquals(runtimeResponseGenericRuntimeResponseTypeOptionModelNew.preference(), "dropdown"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testRuntimeResponseGenericRuntimeResponseTypeOptionError() throws Throwable { + new RuntimeResponseGenericRuntimeResponseTypeOption.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypePauseTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypePauseTest.java new file mode 100644 index 00000000000..42af4ec3c5e --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypePauseTest.java @@ -0,0 +1,63 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeResponseGenericRuntimeResponseTypePause model. */ +public class RuntimeResponseGenericRuntimeResponseTypePauseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeResponseGenericRuntimeResponseTypePause() throws Throwable { + RuntimeResponseGenericRuntimeResponseTypePause + runtimeResponseGenericRuntimeResponseTypePauseModel = + new RuntimeResponseGenericRuntimeResponseTypePause.Builder() + .responseType("pause") + .time(Long.valueOf("26")) + .typing(true) + .build(); + assertEquals(runtimeResponseGenericRuntimeResponseTypePauseModel.responseType(), "pause"); + assertEquals(runtimeResponseGenericRuntimeResponseTypePauseModel.time(), Long.valueOf("26")); + assertEquals( + runtimeResponseGenericRuntimeResponseTypePauseModel.typing(), Boolean.valueOf(true)); + + String json = TestUtilities.serialize(runtimeResponseGenericRuntimeResponseTypePauseModel); + + RuntimeResponseGenericRuntimeResponseTypePause + runtimeResponseGenericRuntimeResponseTypePauseModelNew = + TestUtilities.deserialize(json, RuntimeResponseGenericRuntimeResponseTypePause.class); + assertTrue( + runtimeResponseGenericRuntimeResponseTypePauseModelNew + instanceof RuntimeResponseGenericRuntimeResponseTypePause); + assertEquals(runtimeResponseGenericRuntimeResponseTypePauseModelNew.responseType(), "pause"); + assertEquals(runtimeResponseGenericRuntimeResponseTypePauseModelNew.time(), Long.valueOf("26")); + assertEquals( + runtimeResponseGenericRuntimeResponseTypePauseModelNew.typing(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testRuntimeResponseGenericRuntimeResponseTypePauseError() throws Throwable { + new RuntimeResponseGenericRuntimeResponseTypePause.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeSuggestionTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeSuggestionTest.java new file mode 100644 index 00000000000..b1b8dc677e4 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeSuggestionTest.java @@ -0,0 +1,244 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeResponseGenericRuntimeResponseTypeSuggestion model. */ +public class RuntimeResponseGenericRuntimeResponseTypeSuggestionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeResponseGenericRuntimeResponseTypeSuggestion() throws Throwable { + MessageInput messageInputModel = + new MessageInput.Builder() + .text("testString") + .spellingSuggestions(true) + .spellingAutoCorrect(true) + .add("foo", "testString") + .build(); + assertEquals(messageInputModel.getText(), "testString"); + assertEquals(messageInputModel.isSpellingSuggestions(), Boolean.valueOf(true)); + assertEquals(messageInputModel.isSpellingAutoCorrect(), Boolean.valueOf(true)); + assertEquals(messageInputModel.get("foo"), "testString"); + + RuntimeIntent runtimeIntentModel = + new RuntimeIntent.Builder().intent("testString").confidence(Double.valueOf("72.5")).build(); + assertEquals(runtimeIntentModel.intent(), "testString"); + assertEquals(runtimeIntentModel.confidence(), Double.valueOf("72.5")); + + CaptureGroup captureGroupModel = + new CaptureGroup.Builder() + .group("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) + .build(); + assertEquals(captureGroupModel.group(), "testString"); + assertEquals( + captureGroupModel.location(), + new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))); + + RuntimeEntityInterpretation runtimeEntityInterpretationModel = + new RuntimeEntityInterpretation.Builder() + .calendarType("testString") + .datetimeLink("testString") + .festival("testString") + .granularity("day") + .rangeLink("testString") + .rangeModifier("testString") + .relativeDay(Double.valueOf("72.5")) + .relativeMonth(Double.valueOf("72.5")) + .relativeWeek(Double.valueOf("72.5")) + .relativeWeekend(Double.valueOf("72.5")) + .relativeYear(Double.valueOf("72.5")) + .specificDay(Double.valueOf("72.5")) + .specificDayOfWeek("testString") + .specificMonth(Double.valueOf("72.5")) + .specificQuarter(Double.valueOf("72.5")) + .specificYear(Double.valueOf("72.5")) + .numericValue(Double.valueOf("72.5")) + .subtype("testString") + .partOfDay("testString") + .relativeHour(Double.valueOf("72.5")) + .relativeMinute(Double.valueOf("72.5")) + .relativeSecond(Double.valueOf("72.5")) + .specificHour(Double.valueOf("72.5")) + .specificMinute(Double.valueOf("72.5")) + .specificSecond(Double.valueOf("72.5")) + .timezone("testString") + .build(); + assertEquals(runtimeEntityInterpretationModel.calendarType(), "testString"); + assertEquals(runtimeEntityInterpretationModel.datetimeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.festival(), "testString"); + assertEquals(runtimeEntityInterpretationModel.granularity(), "day"); + assertEquals(runtimeEntityInterpretationModel.rangeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.rangeModifier(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeek(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeekend(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDayOfWeek(), "testString"); + assertEquals(runtimeEntityInterpretationModel.specificMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificQuarter(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.numericValue(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.subtype(), "testString"); + assertEquals(runtimeEntityInterpretationModel.partOfDay(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.timezone(), "testString"); + + RuntimeEntityAlternative runtimeEntityAlternativeModel = + new RuntimeEntityAlternative.Builder() + .value("testString") + .confidence(Double.valueOf("72.5")) + .build(); + assertEquals(runtimeEntityAlternativeModel.value(), "testString"); + assertEquals(runtimeEntityAlternativeModel.confidence(), Double.valueOf("72.5")); + + RuntimeEntityRole runtimeEntityRoleModel = + new RuntimeEntityRole.Builder().type("date_from").build(); + assertEquals(runtimeEntityRoleModel.type(), "date_from"); + + RuntimeEntity runtimeEntityModel = + new RuntimeEntity.Builder() + .entity("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) + .value("testString") + .confidence(Double.valueOf("72.5")) + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .groups( + new java.util.ArrayList(java.util.Arrays.asList(captureGroupModel))) + .interpretation(runtimeEntityInterpretationModel) + .alternatives( + new java.util.ArrayList( + java.util.Arrays.asList(runtimeEntityAlternativeModel))) + .role(runtimeEntityRoleModel) + .build(); + assertEquals(runtimeEntityModel.entity(), "testString"); + assertEquals( + runtimeEntityModel.location(), + new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))); + assertEquals(runtimeEntityModel.value(), "testString"); + assertEquals(runtimeEntityModel.confidence(), Double.valueOf("72.5")); + assertEquals( + runtimeEntityModel.metadata(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals( + runtimeEntityModel.groups(), + new java.util.ArrayList(java.util.Arrays.asList(captureGroupModel))); + assertEquals(runtimeEntityModel.interpretation(), runtimeEntityInterpretationModel); + assertEquals( + runtimeEntityModel.alternatives(), + new java.util.ArrayList( + java.util.Arrays.asList(runtimeEntityAlternativeModel))); + assertEquals(runtimeEntityModel.role(), runtimeEntityRoleModel); + + DialogSuggestionValue dialogSuggestionValueModel = + new DialogSuggestionValue.Builder() + .input(messageInputModel) + .intents( + new java.util.ArrayList(java.util.Arrays.asList(runtimeIntentModel))) + .entities( + new java.util.ArrayList(java.util.Arrays.asList(runtimeEntityModel))) + .build(); + assertEquals(dialogSuggestionValueModel.input(), messageInputModel); + assertEquals( + dialogSuggestionValueModel.intents(), + new java.util.ArrayList(java.util.Arrays.asList(runtimeIntentModel))); + assertEquals( + dialogSuggestionValueModel.entities(), + new java.util.ArrayList(java.util.Arrays.asList(runtimeEntityModel))); + + DialogSuggestion dialogSuggestionModel = + new DialogSuggestion.Builder() + .label("testString") + .value(dialogSuggestionValueModel) + .output( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .dialogNode("testString") + .build(); + assertEquals(dialogSuggestionModel.label(), "testString"); + assertEquals(dialogSuggestionModel.value(), dialogSuggestionValueModel); + assertEquals( + dialogSuggestionModel.output(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals(dialogSuggestionModel.dialogNode(), "testString"); + + RuntimeResponseGenericRuntimeResponseTypeSuggestion + runtimeResponseGenericRuntimeResponseTypeSuggestionModel = + new RuntimeResponseGenericRuntimeResponseTypeSuggestion.Builder() + .responseType("suggestion") + .title("testString") + .suggestions( + new java.util.ArrayList( + java.util.Arrays.asList(dialogSuggestionModel))) + .build(); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeSuggestionModel.responseType(), "suggestion"); + assertEquals(runtimeResponseGenericRuntimeResponseTypeSuggestionModel.title(), "testString"); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeSuggestionModel.suggestions(), + new java.util.ArrayList(java.util.Arrays.asList(dialogSuggestionModel))); + + String json = TestUtilities.serialize(runtimeResponseGenericRuntimeResponseTypeSuggestionModel); + + RuntimeResponseGenericRuntimeResponseTypeSuggestion + runtimeResponseGenericRuntimeResponseTypeSuggestionModelNew = + TestUtilities.deserialize( + json, RuntimeResponseGenericRuntimeResponseTypeSuggestion.class); + assertTrue( + runtimeResponseGenericRuntimeResponseTypeSuggestionModelNew + instanceof RuntimeResponseGenericRuntimeResponseTypeSuggestion); + assertEquals( + runtimeResponseGenericRuntimeResponseTypeSuggestionModelNew.responseType(), "suggestion"); + assertEquals(runtimeResponseGenericRuntimeResponseTypeSuggestionModelNew.title(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testRuntimeResponseGenericRuntimeResponseTypeSuggestionError() throws Throwable { + new RuntimeResponseGenericRuntimeResponseTypeSuggestion.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeTextTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeTextTest.java new file mode 100644 index 00000000000..20dd5c53419 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericRuntimeResponseTypeTextTest.java @@ -0,0 +1,58 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeResponseGenericRuntimeResponseTypeText model. */ +public class RuntimeResponseGenericRuntimeResponseTypeTextTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeResponseGenericRuntimeResponseTypeText() throws Throwable { + RuntimeResponseGenericRuntimeResponseTypeText + runtimeResponseGenericRuntimeResponseTypeTextModel = + new RuntimeResponseGenericRuntimeResponseTypeText.Builder() + .responseType("text") + .text("testString") + .build(); + assertEquals(runtimeResponseGenericRuntimeResponseTypeTextModel.responseType(), "text"); + assertEquals(runtimeResponseGenericRuntimeResponseTypeTextModel.text(), "testString"); + + String json = TestUtilities.serialize(runtimeResponseGenericRuntimeResponseTypeTextModel); + + RuntimeResponseGenericRuntimeResponseTypeText + runtimeResponseGenericRuntimeResponseTypeTextModelNew = + TestUtilities.deserialize(json, RuntimeResponseGenericRuntimeResponseTypeText.class); + assertTrue( + runtimeResponseGenericRuntimeResponseTypeTextModelNew + instanceof RuntimeResponseGenericRuntimeResponseTypeText); + assertEquals(runtimeResponseGenericRuntimeResponseTypeTextModelNew.responseType(), "text"); + assertEquals(runtimeResponseGenericRuntimeResponseTypeTextModelNew.text(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testRuntimeResponseGenericRuntimeResponseTypeTextError() throws Throwable { + new RuntimeResponseGenericRuntimeResponseTypeText.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericTest.java new file mode 100644 index 00000000000..711db1a5356 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGenericTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeResponseGeneric model. */ +public class RuntimeResponseGenericTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + // TODO: Add tests for models that are abstract + @Test + public void testRuntimeResponseGeneric() throws Throwable { + RuntimeResponseGeneric runtimeResponseGenericModel = new RuntimeResponseGeneric(); + assertNotNull(runtimeResponseGenericModel); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/SynonymCollectionTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/SynonymCollectionTest.java new file mode 100644 index 00000000000..ac4a76d891f --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/SynonymCollectionTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SynonymCollection model. */ +public class SynonymCollectionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSynonymCollection() throws Throwable { + SynonymCollection synonymCollectionModel = new SynonymCollection(); + assertNull(synonymCollectionModel.getSynonyms()); + assertNull(synonymCollectionModel.getPagination()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/SynonymTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/SynonymTest.java new file mode 100644 index 00000000000..eac82e3d965 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/SynonymTest.java @@ -0,0 +1,47 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Synonym model. */ +public class SynonymTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSynonym() throws Throwable { + Synonym synonymModel = new Synonym.Builder().synonym("testString").build(); + assertEquals(synonymModel.synonym(), "testString"); + + String json = TestUtilities.serialize(synonymModel); + + Synonym synonymModelNew = TestUtilities.deserialize(json, Synonym.class); + assertTrue(synonymModelNew instanceof Synonym); + assertEquals(synonymModelNew.synonym(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testSynonymError() throws Throwable { + new Synonym.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateCounterexampleOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateCounterexampleOptionsTest.java new file mode 100644 index 00000000000..61960b28a89 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateCounterexampleOptionsTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the UpdateCounterexampleOptions model. */ +public class UpdateCounterexampleOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateCounterexampleOptions() throws Throwable { + UpdateCounterexampleOptions updateCounterexampleOptionsModel = + new UpdateCounterexampleOptions.Builder() + .workspaceId("testString") + .text("testString") + .newText("testString") + .includeAudit(true) + .build(); + assertEquals(updateCounterexampleOptionsModel.workspaceId(), "testString"); + assertEquals(updateCounterexampleOptionsModel.text(), "testString"); + assertEquals(updateCounterexampleOptionsModel.newText(), "testString"); + assertEquals(updateCounterexampleOptionsModel.includeAudit(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateCounterexampleOptionsError() throws Throwable { + new UpdateCounterexampleOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateDialogNodeOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateDialogNodeOptionsTest.java new file mode 100644 index 00000000000..06a336c38a1 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateDialogNodeOptionsTest.java @@ -0,0 +1,226 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.testng.annotations.Test; + +/** Unit test class for the UpdateDialogNodeOptions model. */ +public class UpdateDialogNodeOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateDialogNodeOptions() throws Throwable { + DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill dialogNodeOutputGenericModel = + new DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill.Builder() + .responseType("search_skill") + .query("testString") + .queryType("natural_language") + .filter("testString") + .discoveryVersion("testString") + .build(); + assertEquals(dialogNodeOutputGenericModel.responseType(), "search_skill"); + assertEquals(dialogNodeOutputGenericModel.query(), "testString"); + assertEquals(dialogNodeOutputGenericModel.queryType(), "natural_language"); + assertEquals(dialogNodeOutputGenericModel.filter(), "testString"); + assertEquals(dialogNodeOutputGenericModel.discoveryVersion(), "testString"); + + DialogNodeOutputModifiers dialogNodeOutputModifiersModel = + new DialogNodeOutputModifiers.Builder().overwrite(true).build(); + assertEquals(dialogNodeOutputModifiersModel.overwrite(), Boolean.valueOf(true)); + + DialogNodeOutput dialogNodeOutputModel = + new DialogNodeOutput.Builder() + .generic( + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeOutputGenericModel))) + .integrations( + new java.util.HashMap>() { + { + put( + "foo", + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + } + }) + .modifiers(dialogNodeOutputModifiersModel) + .add("foo", "testString") + .build(); + assertEquals( + dialogNodeOutputModel.getGeneric(), + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeOutputGenericModel))); + assertEquals( + dialogNodeOutputModel.getIntegrations(), + new java.util.HashMap>() { + { + put( + "foo", + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + } + }); + assertEquals(dialogNodeOutputModel.getModifiers(), dialogNodeOutputModifiersModel); + assertEquals(dialogNodeOutputModel.get("foo"), "testString"); + + DialogNodeContext dialogNodeContextModel = + new DialogNodeContext.Builder() + .integrations( + new java.util.HashMap>() { + { + put( + "foo", + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + } + }) + .add("foo", "testString") + .build(); + assertEquals( + dialogNodeContextModel.getIntegrations(), + new java.util.HashMap>() { + { + put( + "foo", + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + } + }); + assertEquals(dialogNodeContextModel.get("foo"), "testString"); + + DialogNodeNextStep dialogNodeNextStepModel = + new DialogNodeNextStep.Builder() + .behavior("get_user_input") + .dialogNode("testString") + .selector("condition") + .build(); + assertEquals(dialogNodeNextStepModel.behavior(), "get_user_input"); + assertEquals(dialogNodeNextStepModel.dialogNode(), "testString"); + assertEquals(dialogNodeNextStepModel.selector(), "condition"); + + DialogNodeAction dialogNodeActionModel = + new DialogNodeAction.Builder() + .name("testString") + .type("client") + .parameters( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .resultVariable("testString") + .credentials("testString") + .build(); + assertEquals(dialogNodeActionModel.name(), "testString"); + assertEquals(dialogNodeActionModel.type(), "client"); + assertEquals( + dialogNodeActionModel.parameters(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals(dialogNodeActionModel.resultVariable(), "testString"); + assertEquals(dialogNodeActionModel.credentials(), "testString"); + + UpdateDialogNodeOptions updateDialogNodeOptionsModel = + new UpdateDialogNodeOptions.Builder() + .workspaceId("testString") + .dialogNode("testString") + .newDialogNode("testString") + .newDescription("testString") + .newConditions("testString") + .newParent("testString") + .newPreviousSibling("testString") + .newOutput(dialogNodeOutputModel) + .newContext(dialogNodeContextModel) + .newMetadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .newNextStep(dialogNodeNextStepModel) + .newTitle("testString") + .newType("standard") + .newEventName("focus") + .newVariable("testString") + .newActions( + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeActionModel))) + .newDigressIn("not_available") + .newDigressOut("allow_returning") + .newDigressOutSlots("not_allowed") + .newUserLabel("testString") + .newDisambiguationOptOut(true) + .includeAudit(true) + .build(); + assertEquals(updateDialogNodeOptionsModel.workspaceId(), "testString"); + assertEquals(updateDialogNodeOptionsModel.dialogNode(), "testString"); + assertEquals(updateDialogNodeOptionsModel.newDialogNode(), "testString"); + assertEquals(updateDialogNodeOptionsModel.newDescription(), "testString"); + assertEquals(updateDialogNodeOptionsModel.newConditions(), "testString"); + assertEquals(updateDialogNodeOptionsModel.newParent(), "testString"); + assertEquals(updateDialogNodeOptionsModel.newPreviousSibling(), "testString"); + assertEquals(updateDialogNodeOptionsModel.newOutput(), dialogNodeOutputModel); + assertEquals(updateDialogNodeOptionsModel.newContext(), dialogNodeContextModel); + assertEquals( + updateDialogNodeOptionsModel.newMetadata(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals(updateDialogNodeOptionsModel.newNextStep(), dialogNodeNextStepModel); + assertEquals(updateDialogNodeOptionsModel.newTitle(), "testString"); + assertEquals(updateDialogNodeOptionsModel.newType(), "standard"); + assertEquals(updateDialogNodeOptionsModel.newEventName(), "focus"); + assertEquals(updateDialogNodeOptionsModel.newVariable(), "testString"); + assertEquals( + updateDialogNodeOptionsModel.newActions(), + new java.util.ArrayList(java.util.Arrays.asList(dialogNodeActionModel))); + assertEquals(updateDialogNodeOptionsModel.newDigressIn(), "not_available"); + assertEquals(updateDialogNodeOptionsModel.newDigressOut(), "allow_returning"); + assertEquals(updateDialogNodeOptionsModel.newDigressOutSlots(), "not_allowed"); + assertEquals(updateDialogNodeOptionsModel.newUserLabel(), "testString"); + assertEquals(updateDialogNodeOptionsModel.newDisambiguationOptOut(), Boolean.valueOf(true)); + assertEquals(updateDialogNodeOptionsModel.includeAudit(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateDialogNodeOptionsError() throws Throwable { + new UpdateDialogNodeOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateEntityOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateEntityOptionsTest.java new file mode 100644 index 00000000000..4713766e1dc --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateEntityOptionsTest.java @@ -0,0 +1,103 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the UpdateEntityOptions model. */ +public class UpdateEntityOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateEntityOptions() throws Throwable { + CreateValue createValueModel = + new CreateValue.Builder() + .value("testString") + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .type("synonyms") + .synonyms(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .patterns(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals(createValueModel.value(), "testString"); + assertEquals( + createValueModel.metadata(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals(createValueModel.type(), "synonyms"); + assertEquals( + createValueModel.synonyms(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals( + createValueModel.patterns(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + UpdateEntityOptions updateEntityOptionsModel = + new UpdateEntityOptions.Builder() + .workspaceId("testString") + .entity("testString") + .newEntity("testString") + .newDescription("testString") + .newMetadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .newFuzzyMatch(true) + .newValues( + new java.util.ArrayList(java.util.Arrays.asList(createValueModel))) + .append(true) + .includeAudit(true) + .build(); + assertEquals(updateEntityOptionsModel.workspaceId(), "testString"); + assertEquals(updateEntityOptionsModel.entity(), "testString"); + assertEquals(updateEntityOptionsModel.newEntity(), "testString"); + assertEquals(updateEntityOptionsModel.newDescription(), "testString"); + assertEquals( + updateEntityOptionsModel.newMetadata(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals(updateEntityOptionsModel.newFuzzyMatch(), Boolean.valueOf(true)); + assertEquals( + updateEntityOptionsModel.newValues(), + new java.util.ArrayList(java.util.Arrays.asList(createValueModel))); + assertEquals(updateEntityOptionsModel.append(), Boolean.valueOf(true)); + assertEquals(updateEntityOptionsModel.includeAudit(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateEntityOptionsError() throws Throwable { + new UpdateEntityOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateExampleOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateExampleOptionsTest.java new file mode 100644 index 00000000000..25ea95eba39 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateExampleOptionsTest.java @@ -0,0 +1,66 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the UpdateExampleOptions model. */ +public class UpdateExampleOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateExampleOptions() throws Throwable { + Mention mentionModel = + new Mention.Builder() + .entity("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) + .build(); + assertEquals(mentionModel.entity(), "testString"); + assertEquals( + mentionModel.location(), + new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))); + + UpdateExampleOptions updateExampleOptionsModel = + new UpdateExampleOptions.Builder() + .workspaceId("testString") + .intent("testString") + .text("testString") + .newText("testString") + .newMentions(new java.util.ArrayList(java.util.Arrays.asList(mentionModel))) + .includeAudit(true) + .build(); + assertEquals(updateExampleOptionsModel.workspaceId(), "testString"); + assertEquals(updateExampleOptionsModel.intent(), "testString"); + assertEquals(updateExampleOptionsModel.text(), "testString"); + assertEquals(updateExampleOptionsModel.newText(), "testString"); + assertEquals( + updateExampleOptionsModel.newMentions(), + new java.util.ArrayList(java.util.Arrays.asList(mentionModel))); + assertEquals(updateExampleOptionsModel.includeAudit(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateExampleOptionsError() throws Throwable { + new UpdateExampleOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateIntentOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateIntentOptionsTest.java new file mode 100644 index 00000000000..25e9fd56f2c --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateIntentOptionsTest.java @@ -0,0 +1,78 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the UpdateIntentOptions model. */ +public class UpdateIntentOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateIntentOptions() throws Throwable { + Mention mentionModel = + new Mention.Builder() + .entity("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) + .build(); + assertEquals(mentionModel.entity(), "testString"); + assertEquals( + mentionModel.location(), + new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))); + + Example exampleModel = + new Example.Builder() + .text("testString") + .mentions(new java.util.ArrayList(java.util.Arrays.asList(mentionModel))) + .build(); + assertEquals(exampleModel.text(), "testString"); + assertEquals( + exampleModel.mentions(), + new java.util.ArrayList(java.util.Arrays.asList(mentionModel))); + + UpdateIntentOptions updateIntentOptionsModel = + new UpdateIntentOptions.Builder() + .workspaceId("testString") + .intent("testString") + .newIntent("testString") + .newDescription("testString") + .newExamples(new java.util.ArrayList(java.util.Arrays.asList(exampleModel))) + .append(true) + .includeAudit(true) + .build(); + assertEquals(updateIntentOptionsModel.workspaceId(), "testString"); + assertEquals(updateIntentOptionsModel.intent(), "testString"); + assertEquals(updateIntentOptionsModel.newIntent(), "testString"); + assertEquals(updateIntentOptionsModel.newDescription(), "testString"); + assertEquals( + updateIntentOptionsModel.newExamples(), + new java.util.ArrayList(java.util.Arrays.asList(exampleModel))); + assertEquals(updateIntentOptionsModel.append(), Boolean.valueOf(true)); + assertEquals(updateIntentOptionsModel.includeAudit(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateIntentOptionsError() throws Throwable { + new UpdateIntentOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateSynonymOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateSynonymOptionsTest.java new file mode 100644 index 00000000000..597b86bffcb --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateSynonymOptionsTest.java @@ -0,0 +1,54 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the UpdateSynonymOptions model. */ +public class UpdateSynonymOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateSynonymOptions() throws Throwable { + UpdateSynonymOptions updateSynonymOptionsModel = + new UpdateSynonymOptions.Builder() + .workspaceId("testString") + .entity("testString") + .value("testString") + .synonym("testString") + .newSynonym("testString") + .includeAudit(true) + .build(); + assertEquals(updateSynonymOptionsModel.workspaceId(), "testString"); + assertEquals(updateSynonymOptionsModel.entity(), "testString"); + assertEquals(updateSynonymOptionsModel.value(), "testString"); + assertEquals(updateSynonymOptionsModel.synonym(), "testString"); + assertEquals(updateSynonymOptionsModel.newSynonym(), "testString"); + assertEquals(updateSynonymOptionsModel.includeAudit(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateSynonymOptionsError() throws Throwable { + new UpdateSynonymOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateValueOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateValueOptionsTest.java new file mode 100644 index 00000000000..88d94be1709 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateValueOptionsTest.java @@ -0,0 +1,77 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the UpdateValueOptions model. */ +public class UpdateValueOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateValueOptions() throws Throwable { + UpdateValueOptions updateValueOptionsModel = + new UpdateValueOptions.Builder() + .workspaceId("testString") + .entity("testString") + .value("testString") + .newValue("testString") + .newMetadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .newType("synonyms") + .newSynonyms(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .newPatterns(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .append(true) + .includeAudit(true) + .build(); + assertEquals(updateValueOptionsModel.workspaceId(), "testString"); + assertEquals(updateValueOptionsModel.entity(), "testString"); + assertEquals(updateValueOptionsModel.value(), "testString"); + assertEquals(updateValueOptionsModel.newValue(), "testString"); + assertEquals( + updateValueOptionsModel.newMetadata(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals(updateValueOptionsModel.newType(), "synonyms"); + assertEquals( + updateValueOptionsModel.newSynonyms(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals( + updateValueOptionsModel.newPatterns(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals(updateValueOptionsModel.append(), Boolean.valueOf(true)); + assertEquals(updateValueOptionsModel.includeAudit(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateValueOptionsError() throws Throwable { + new UpdateValueOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateWorkspaceOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateWorkspaceOptionsTest.java new file mode 100644 index 00000000000..80faa7f9196 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/UpdateWorkspaceOptionsTest.java @@ -0,0 +1,449 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.testng.annotations.Test; + +/** Unit test class for the UpdateWorkspaceOptions model. */ +public class UpdateWorkspaceOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateWorkspaceOptions() throws Throwable { + DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill dialogNodeOutputGenericModel = + new DialogNodeOutputGenericDialogNodeOutputResponseTypeSearchSkill.Builder() + .responseType("search_skill") + .query("testString") + .queryType("natural_language") + .filter("testString") + .discoveryVersion("testString") + .build(); + assertEquals(dialogNodeOutputGenericModel.responseType(), "search_skill"); + assertEquals(dialogNodeOutputGenericModel.query(), "testString"); + assertEquals(dialogNodeOutputGenericModel.queryType(), "natural_language"); + assertEquals(dialogNodeOutputGenericModel.filter(), "testString"); + assertEquals(dialogNodeOutputGenericModel.discoveryVersion(), "testString"); + + DialogNodeOutputModifiers dialogNodeOutputModifiersModel = + new DialogNodeOutputModifiers.Builder().overwrite(true).build(); + assertEquals(dialogNodeOutputModifiersModel.overwrite(), Boolean.valueOf(true)); + + DialogNodeOutput dialogNodeOutputModel = + new DialogNodeOutput.Builder() + .generic( + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeOutputGenericModel))) + .integrations( + new java.util.HashMap>() { + { + put( + "foo", + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + } + }) + .modifiers(dialogNodeOutputModifiersModel) + .add("foo", "testString") + .build(); + assertEquals( + dialogNodeOutputModel.getGeneric(), + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeOutputGenericModel))); + assertEquals( + dialogNodeOutputModel.getIntegrations(), + new java.util.HashMap>() { + { + put( + "foo", + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + } + }); + assertEquals(dialogNodeOutputModel.getModifiers(), dialogNodeOutputModifiersModel); + assertEquals(dialogNodeOutputModel.get("foo"), "testString"); + + DialogNodeContext dialogNodeContextModel = + new DialogNodeContext.Builder() + .integrations( + new java.util.HashMap>() { + { + put( + "foo", + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + } + }) + .add("foo", "testString") + .build(); + assertEquals( + dialogNodeContextModel.getIntegrations(), + new java.util.HashMap>() { + { + put( + "foo", + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + } + }); + assertEquals(dialogNodeContextModel.get("foo"), "testString"); + + DialogNodeNextStep dialogNodeNextStepModel = + new DialogNodeNextStep.Builder() + .behavior("get_user_input") + .dialogNode("testString") + .selector("condition") + .build(); + assertEquals(dialogNodeNextStepModel.behavior(), "get_user_input"); + assertEquals(dialogNodeNextStepModel.dialogNode(), "testString"); + assertEquals(dialogNodeNextStepModel.selector(), "condition"); + + DialogNodeAction dialogNodeActionModel = + new DialogNodeAction.Builder() + .name("testString") + .type("client") + .parameters( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .resultVariable("testString") + .credentials("testString") + .build(); + assertEquals(dialogNodeActionModel.name(), "testString"); + assertEquals(dialogNodeActionModel.type(), "client"); + assertEquals( + dialogNodeActionModel.parameters(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals(dialogNodeActionModel.resultVariable(), "testString"); + assertEquals(dialogNodeActionModel.credentials(), "testString"); + + DialogNode dialogNodeModel = + new DialogNode.Builder() + .dialogNode("testString") + .description("testString") + .conditions("testString") + .parent("testString") + .previousSibling("testString") + .output(dialogNodeOutputModel) + .context(dialogNodeContextModel) + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .nextStep(dialogNodeNextStepModel) + .title("testString") + .type("standard") + .eventName("focus") + .variable("testString") + .actions( + new java.util.ArrayList( + java.util.Arrays.asList(dialogNodeActionModel))) + .digressIn("not_available") + .digressOut("allow_returning") + .digressOutSlots("not_allowed") + .userLabel("testString") + .disambiguationOptOut(true) + .build(); + assertEquals(dialogNodeModel.dialogNode(), "testString"); + assertEquals(dialogNodeModel.description(), "testString"); + assertEquals(dialogNodeModel.conditions(), "testString"); + assertEquals(dialogNodeModel.parent(), "testString"); + assertEquals(dialogNodeModel.previousSibling(), "testString"); + assertEquals(dialogNodeModel.output(), dialogNodeOutputModel); + assertEquals(dialogNodeModel.context(), dialogNodeContextModel); + assertEquals( + dialogNodeModel.metadata(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals(dialogNodeModel.nextStep(), dialogNodeNextStepModel); + assertEquals(dialogNodeModel.title(), "testString"); + assertEquals(dialogNodeModel.type(), "standard"); + assertEquals(dialogNodeModel.eventName(), "focus"); + assertEquals(dialogNodeModel.variable(), "testString"); + assertEquals( + dialogNodeModel.actions(), + new java.util.ArrayList(java.util.Arrays.asList(dialogNodeActionModel))); + assertEquals(dialogNodeModel.digressIn(), "not_available"); + assertEquals(dialogNodeModel.digressOut(), "allow_returning"); + assertEquals(dialogNodeModel.digressOutSlots(), "not_allowed"); + assertEquals(dialogNodeModel.userLabel(), "testString"); + assertEquals(dialogNodeModel.disambiguationOptOut(), Boolean.valueOf(true)); + + Counterexample counterexampleModel = new Counterexample.Builder().text("testString").build(); + assertEquals(counterexampleModel.text(), "testString"); + + WorkspaceSystemSettingsTooling workspaceSystemSettingsToolingModel = + new WorkspaceSystemSettingsTooling.Builder().storeGenericResponses(true).build(); + assertEquals( + workspaceSystemSettingsToolingModel.storeGenericResponses(), Boolean.valueOf(true)); + + WorkspaceSystemSettingsDisambiguation workspaceSystemSettingsDisambiguationModel = + new WorkspaceSystemSettingsDisambiguation.Builder() + .prompt("testString") + .noneOfTheAbovePrompt("testString") + .enabled(true) + .sensitivity("auto") + .randomize(true) + .maxSuggestions(Long.valueOf("1")) + .suggestionTextPolicy("testString") + .build(); + assertEquals(workspaceSystemSettingsDisambiguationModel.prompt(), "testString"); + assertEquals(workspaceSystemSettingsDisambiguationModel.noneOfTheAbovePrompt(), "testString"); + assertEquals(workspaceSystemSettingsDisambiguationModel.enabled(), Boolean.valueOf(true)); + assertEquals(workspaceSystemSettingsDisambiguationModel.sensitivity(), "auto"); + assertEquals(workspaceSystemSettingsDisambiguationModel.randomize(), Boolean.valueOf(true)); + assertEquals(workspaceSystemSettingsDisambiguationModel.maxSuggestions(), Long.valueOf("1")); + assertEquals(workspaceSystemSettingsDisambiguationModel.suggestionTextPolicy(), "testString"); + + WorkspaceSystemSettingsSystemEntities workspaceSystemSettingsSystemEntitiesModel = + new WorkspaceSystemSettingsSystemEntities.Builder().enabled(true).build(); + assertEquals(workspaceSystemSettingsSystemEntitiesModel.enabled(), Boolean.valueOf(true)); + + WorkspaceSystemSettingsOffTopic workspaceSystemSettingsOffTopicModel = + new WorkspaceSystemSettingsOffTopic.Builder().enabled(true).build(); + assertEquals(workspaceSystemSettingsOffTopicModel.enabled(), Boolean.valueOf(true)); + + WorkspaceSystemSettings workspaceSystemSettingsModel = + new WorkspaceSystemSettings.Builder() + .tooling(workspaceSystemSettingsToolingModel) + .disambiguation(workspaceSystemSettingsDisambiguationModel) + .humanAgentAssist( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .spellingSuggestions(true) + .spellingAutoCorrect(true) + .systemEntities(workspaceSystemSettingsSystemEntitiesModel) + .offTopic(workspaceSystemSettingsOffTopicModel) + .build(); + assertEquals(workspaceSystemSettingsModel.tooling(), workspaceSystemSettingsToolingModel); + assertEquals( + workspaceSystemSettingsModel.disambiguation(), workspaceSystemSettingsDisambiguationModel); + assertEquals( + workspaceSystemSettingsModel.humanAgentAssist(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals(workspaceSystemSettingsModel.spellingSuggestions(), Boolean.valueOf(true)); + assertEquals(workspaceSystemSettingsModel.spellingAutoCorrect(), Boolean.valueOf(true)); + assertEquals( + workspaceSystemSettingsModel.systemEntities(), workspaceSystemSettingsSystemEntitiesModel); + assertEquals(workspaceSystemSettingsModel.offTopic(), workspaceSystemSettingsOffTopicModel); + + WebhookHeader webhookHeaderModel = + new WebhookHeader.Builder().name("testString").value("testString").build(); + assertEquals(webhookHeaderModel.name(), "testString"); + assertEquals(webhookHeaderModel.value(), "testString"); + + Webhook webhookModel = + new Webhook.Builder() + .url("testString") + .name("testString") + .headers( + new java.util.ArrayList(java.util.Arrays.asList(webhookHeaderModel))) + .build(); + assertEquals(webhookModel.url(), "testString"); + assertEquals(webhookModel.name(), "testString"); + assertEquals( + webhookModel.headers(), + new java.util.ArrayList(java.util.Arrays.asList(webhookHeaderModel))); + + Mention mentionModel = + new Mention.Builder() + .entity("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) + .build(); + assertEquals(mentionModel.entity(), "testString"); + assertEquals( + mentionModel.location(), + new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))); + + Example exampleModel = + new Example.Builder() + .text("testString") + .mentions(new java.util.ArrayList(java.util.Arrays.asList(mentionModel))) + .build(); + assertEquals(exampleModel.text(), "testString"); + assertEquals( + exampleModel.mentions(), + new java.util.ArrayList(java.util.Arrays.asList(mentionModel))); + + CreateIntent createIntentModel = + new CreateIntent.Builder() + .intent("testString") + .description("testString") + .examples(new java.util.ArrayList(java.util.Arrays.asList(exampleModel))) + .build(); + assertEquals(createIntentModel.intent(), "testString"); + assertEquals(createIntentModel.description(), "testString"); + assertEquals( + createIntentModel.examples(), + new java.util.ArrayList(java.util.Arrays.asList(exampleModel))); + + CreateValue createValueModel = + new CreateValue.Builder() + .value("testString") + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .type("synonyms") + .synonyms(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .patterns(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals(createValueModel.value(), "testString"); + assertEquals( + createValueModel.metadata(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals(createValueModel.type(), "synonyms"); + assertEquals( + createValueModel.synonyms(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals( + createValueModel.patterns(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + CreateEntity createEntityModel = + new CreateEntity.Builder() + .entity("testString") + .description("testString") + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .fuzzyMatch(true) + .values(new java.util.ArrayList(java.util.Arrays.asList(createValueModel))) + .build(); + assertEquals(createEntityModel.entity(), "testString"); + assertEquals(createEntityModel.description(), "testString"); + assertEquals( + createEntityModel.metadata(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals(createEntityModel.fuzzyMatch(), Boolean.valueOf(true)); + assertEquals( + createEntityModel.values(), + new java.util.ArrayList(java.util.Arrays.asList(createValueModel))); + + UpdateWorkspaceOptions updateWorkspaceOptionsModel = + new UpdateWorkspaceOptions.Builder() + .workspaceId("testString") + .name("testString") + .description("testString") + .language("testString") + .dialogNodes( + new java.util.ArrayList(java.util.Arrays.asList(dialogNodeModel))) + .counterexamples( + new java.util.ArrayList( + java.util.Arrays.asList(counterexampleModel))) + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .learningOptOut(true) + .systemSettings(workspaceSystemSettingsModel) + .webhooks(new java.util.ArrayList(java.util.Arrays.asList(webhookModel))) + .intents( + new java.util.ArrayList(java.util.Arrays.asList(createIntentModel))) + .entities( + new java.util.ArrayList(java.util.Arrays.asList(createEntityModel))) + .append(true) + .includeAudit(true) + .build(); + assertEquals(updateWorkspaceOptionsModel.workspaceId(), "testString"); + assertEquals(updateWorkspaceOptionsModel.name(), "testString"); + assertEquals(updateWorkspaceOptionsModel.description(), "testString"); + assertEquals(updateWorkspaceOptionsModel.language(), "testString"); + assertEquals( + updateWorkspaceOptionsModel.dialogNodes(), + new java.util.ArrayList(java.util.Arrays.asList(dialogNodeModel))); + assertEquals( + updateWorkspaceOptionsModel.counterexamples(), + new java.util.ArrayList(java.util.Arrays.asList(counterexampleModel))); + assertEquals( + updateWorkspaceOptionsModel.metadata(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals(updateWorkspaceOptionsModel.learningOptOut(), Boolean.valueOf(true)); + assertEquals(updateWorkspaceOptionsModel.systemSettings(), workspaceSystemSettingsModel); + assertEquals( + updateWorkspaceOptionsModel.webhooks(), + new java.util.ArrayList(java.util.Arrays.asList(webhookModel))); + assertEquals( + updateWorkspaceOptionsModel.intents(), + new java.util.ArrayList(java.util.Arrays.asList(createIntentModel))); + assertEquals( + updateWorkspaceOptionsModel.entities(), + new java.util.ArrayList(java.util.Arrays.asList(createEntityModel))); + assertEquals(updateWorkspaceOptionsModel.append(), Boolean.valueOf(true)); + assertEquals(updateWorkspaceOptionsModel.includeAudit(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateWorkspaceOptionsError() throws Throwable { + new UpdateWorkspaceOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ValueCollectionTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ValueCollectionTest.java new file mode 100644 index 00000000000..07a20c468b8 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ValueCollectionTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ValueCollection model. */ +public class ValueCollectionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testValueCollection() throws Throwable { + ValueCollection valueCollectionModel = new ValueCollection(); + assertNull(valueCollectionModel.getValues()); + assertNull(valueCollectionModel.getPagination()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ValueTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ValueTest.java new file mode 100644 index 00000000000..3cea67302c8 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/ValueTest.java @@ -0,0 +1,35 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Value model. */ +public class ValueTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testValueError() throws Throwable { + new Value.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WebhookHeaderTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WebhookHeaderTest.java new file mode 100644 index 00000000000..ea77dc56b95 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WebhookHeaderTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the WebhookHeader model. */ +public class WebhookHeaderTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testWebhookHeader() throws Throwable { + WebhookHeader webhookHeaderModel = + new WebhookHeader.Builder().name("testString").value("testString").build(); + assertEquals(webhookHeaderModel.name(), "testString"); + assertEquals(webhookHeaderModel.value(), "testString"); + + String json = TestUtilities.serialize(webhookHeaderModel); + + WebhookHeader webhookHeaderModelNew = TestUtilities.deserialize(json, WebhookHeader.class); + assertTrue(webhookHeaderModelNew instanceof WebhookHeader); + assertEquals(webhookHeaderModelNew.name(), "testString"); + assertEquals(webhookHeaderModelNew.value(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testWebhookHeaderError() throws Throwable { + new WebhookHeader.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WebhookTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WebhookTest.java new file mode 100644 index 00000000000..6463dd723b2 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WebhookTest.java @@ -0,0 +1,63 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Webhook model. */ +public class WebhookTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testWebhook() throws Throwable { + WebhookHeader webhookHeaderModel = + new WebhookHeader.Builder().name("testString").value("testString").build(); + assertEquals(webhookHeaderModel.name(), "testString"); + assertEquals(webhookHeaderModel.value(), "testString"); + + Webhook webhookModel = + new Webhook.Builder() + .url("testString") + .name("testString") + .headers( + new java.util.ArrayList(java.util.Arrays.asList(webhookHeaderModel))) + .build(); + assertEquals(webhookModel.url(), "testString"); + assertEquals(webhookModel.name(), "testString"); + assertEquals( + webhookModel.headers(), + new java.util.ArrayList(java.util.Arrays.asList(webhookHeaderModel))); + + String json = TestUtilities.serialize(webhookModel); + + Webhook webhookModelNew = TestUtilities.deserialize(json, Webhook.class); + assertTrue(webhookModelNew instanceof Webhook); + assertEquals(webhookModelNew.url(), "testString"); + assertEquals(webhookModelNew.name(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testWebhookError() throws Throwable { + new Webhook.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WorkspaceCollectionTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WorkspaceCollectionTest.java new file mode 100644 index 00000000000..50bdcfaa35b --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WorkspaceCollectionTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the WorkspaceCollection model. */ +public class WorkspaceCollectionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testWorkspaceCollection() throws Throwable { + WorkspaceCollection workspaceCollectionModel = new WorkspaceCollection(); + assertNull(workspaceCollectionModel.getWorkspaces()); + assertNull(workspaceCollectionModel.getPagination()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsDisambiguationTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsDisambiguationTest.java new file mode 100644 index 00000000000..f003447eecf --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsDisambiguationTest.java @@ -0,0 +1,68 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the WorkspaceSystemSettingsDisambiguation model. */ +public class WorkspaceSystemSettingsDisambiguationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testWorkspaceSystemSettingsDisambiguation() throws Throwable { + WorkspaceSystemSettingsDisambiguation workspaceSystemSettingsDisambiguationModel = + new WorkspaceSystemSettingsDisambiguation.Builder() + .prompt("testString") + .noneOfTheAbovePrompt("testString") + .enabled(true) + .sensitivity("auto") + .randomize(true) + .maxSuggestions(Long.valueOf("1")) + .suggestionTextPolicy("testString") + .build(); + assertEquals(workspaceSystemSettingsDisambiguationModel.prompt(), "testString"); + assertEquals(workspaceSystemSettingsDisambiguationModel.noneOfTheAbovePrompt(), "testString"); + assertEquals(workspaceSystemSettingsDisambiguationModel.enabled(), Boolean.valueOf(true)); + assertEquals(workspaceSystemSettingsDisambiguationModel.sensitivity(), "auto"); + assertEquals(workspaceSystemSettingsDisambiguationModel.randomize(), Boolean.valueOf(true)); + assertEquals(workspaceSystemSettingsDisambiguationModel.maxSuggestions(), Long.valueOf("1")); + assertEquals(workspaceSystemSettingsDisambiguationModel.suggestionTextPolicy(), "testString"); + + String json = TestUtilities.serialize(workspaceSystemSettingsDisambiguationModel); + + WorkspaceSystemSettingsDisambiguation workspaceSystemSettingsDisambiguationModelNew = + TestUtilities.deserialize(json, WorkspaceSystemSettingsDisambiguation.class); + assertTrue( + workspaceSystemSettingsDisambiguationModelNew + instanceof WorkspaceSystemSettingsDisambiguation); + assertEquals(workspaceSystemSettingsDisambiguationModelNew.prompt(), "testString"); + assertEquals( + workspaceSystemSettingsDisambiguationModelNew.noneOfTheAbovePrompt(), "testString"); + assertEquals(workspaceSystemSettingsDisambiguationModelNew.enabled(), Boolean.valueOf(true)); + assertEquals(workspaceSystemSettingsDisambiguationModelNew.sensitivity(), "auto"); + assertEquals(workspaceSystemSettingsDisambiguationModelNew.randomize(), Boolean.valueOf(true)); + assertEquals(workspaceSystemSettingsDisambiguationModelNew.maxSuggestions(), Long.valueOf("1")); + assertEquals( + workspaceSystemSettingsDisambiguationModelNew.suggestionTextPolicy(), "testString"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsOffTopicTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsOffTopicTest.java new file mode 100644 index 00000000000..23e4fa20c8e --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsOffTopicTest.java @@ -0,0 +1,44 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the WorkspaceSystemSettingsOffTopic model. */ +public class WorkspaceSystemSettingsOffTopicTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testWorkspaceSystemSettingsOffTopic() throws Throwable { + WorkspaceSystemSettingsOffTopic workspaceSystemSettingsOffTopicModel = + new WorkspaceSystemSettingsOffTopic.Builder().enabled(true).build(); + assertEquals(workspaceSystemSettingsOffTopicModel.enabled(), Boolean.valueOf(true)); + + String json = TestUtilities.serialize(workspaceSystemSettingsOffTopicModel); + + WorkspaceSystemSettingsOffTopic workspaceSystemSettingsOffTopicModelNew = + TestUtilities.deserialize(json, WorkspaceSystemSettingsOffTopic.class); + assertTrue(workspaceSystemSettingsOffTopicModelNew instanceof WorkspaceSystemSettingsOffTopic); + assertEquals(workspaceSystemSettingsOffTopicModelNew.enabled(), Boolean.valueOf(true)); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsSystemEntitiesTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsSystemEntitiesTest.java new file mode 100644 index 00000000000..7d5642b6e9e --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsSystemEntitiesTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the WorkspaceSystemSettingsSystemEntities model. */ +public class WorkspaceSystemSettingsSystemEntitiesTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testWorkspaceSystemSettingsSystemEntities() throws Throwable { + WorkspaceSystemSettingsSystemEntities workspaceSystemSettingsSystemEntitiesModel = + new WorkspaceSystemSettingsSystemEntities.Builder().enabled(true).build(); + assertEquals(workspaceSystemSettingsSystemEntitiesModel.enabled(), Boolean.valueOf(true)); + + String json = TestUtilities.serialize(workspaceSystemSettingsSystemEntitiesModel); + + WorkspaceSystemSettingsSystemEntities workspaceSystemSettingsSystemEntitiesModelNew = + TestUtilities.deserialize(json, WorkspaceSystemSettingsSystemEntities.class); + assertTrue( + workspaceSystemSettingsSystemEntitiesModelNew + instanceof WorkspaceSystemSettingsSystemEntities); + assertEquals(workspaceSystemSettingsSystemEntitiesModelNew.enabled(), Boolean.valueOf(true)); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsTest.java new file mode 100644 index 00000000000..6585ff9665d --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsTest.java @@ -0,0 +1,115 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the WorkspaceSystemSettings model. */ +public class WorkspaceSystemSettingsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testWorkspaceSystemSettings() throws Throwable { + WorkspaceSystemSettingsTooling workspaceSystemSettingsToolingModel = + new WorkspaceSystemSettingsTooling.Builder().storeGenericResponses(true).build(); + assertEquals( + workspaceSystemSettingsToolingModel.storeGenericResponses(), Boolean.valueOf(true)); + + WorkspaceSystemSettingsDisambiguation workspaceSystemSettingsDisambiguationModel = + new WorkspaceSystemSettingsDisambiguation.Builder() + .prompt("testString") + .noneOfTheAbovePrompt("testString") + .enabled(true) + .sensitivity("auto") + .randomize(true) + .maxSuggestions(Long.valueOf("1")) + .suggestionTextPolicy("testString") + .build(); + assertEquals(workspaceSystemSettingsDisambiguationModel.prompt(), "testString"); + assertEquals(workspaceSystemSettingsDisambiguationModel.noneOfTheAbovePrompt(), "testString"); + assertEquals(workspaceSystemSettingsDisambiguationModel.enabled(), Boolean.valueOf(true)); + assertEquals(workspaceSystemSettingsDisambiguationModel.sensitivity(), "auto"); + assertEquals(workspaceSystemSettingsDisambiguationModel.randomize(), Boolean.valueOf(true)); + assertEquals(workspaceSystemSettingsDisambiguationModel.maxSuggestions(), Long.valueOf("1")); + assertEquals(workspaceSystemSettingsDisambiguationModel.suggestionTextPolicy(), "testString"); + + WorkspaceSystemSettingsSystemEntities workspaceSystemSettingsSystemEntitiesModel = + new WorkspaceSystemSettingsSystemEntities.Builder().enabled(true).build(); + assertEquals(workspaceSystemSettingsSystemEntitiesModel.enabled(), Boolean.valueOf(true)); + + WorkspaceSystemSettingsOffTopic workspaceSystemSettingsOffTopicModel = + new WorkspaceSystemSettingsOffTopic.Builder().enabled(true).build(); + assertEquals(workspaceSystemSettingsOffTopicModel.enabled(), Boolean.valueOf(true)); + + WorkspaceSystemSettings workspaceSystemSettingsModel = + new WorkspaceSystemSettings.Builder() + .tooling(workspaceSystemSettingsToolingModel) + .disambiguation(workspaceSystemSettingsDisambiguationModel) + .humanAgentAssist( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .spellingSuggestions(true) + .spellingAutoCorrect(true) + .systemEntities(workspaceSystemSettingsSystemEntitiesModel) + .offTopic(workspaceSystemSettingsOffTopicModel) + .build(); + assertEquals(workspaceSystemSettingsModel.tooling(), workspaceSystemSettingsToolingModel); + assertEquals( + workspaceSystemSettingsModel.disambiguation(), workspaceSystemSettingsDisambiguationModel); + assertEquals( + workspaceSystemSettingsModel.humanAgentAssist(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals(workspaceSystemSettingsModel.spellingSuggestions(), Boolean.valueOf(true)); + assertEquals(workspaceSystemSettingsModel.spellingAutoCorrect(), Boolean.valueOf(true)); + assertEquals( + workspaceSystemSettingsModel.systemEntities(), workspaceSystemSettingsSystemEntitiesModel); + assertEquals(workspaceSystemSettingsModel.offTopic(), workspaceSystemSettingsOffTopicModel); + + String json = TestUtilities.serialize(workspaceSystemSettingsModel); + + WorkspaceSystemSettings workspaceSystemSettingsModelNew = + TestUtilities.deserialize(json, WorkspaceSystemSettings.class); + assertTrue(workspaceSystemSettingsModelNew instanceof WorkspaceSystemSettings); + assertEquals( + workspaceSystemSettingsModelNew.tooling().toString(), + workspaceSystemSettingsToolingModel.toString()); + assertEquals( + workspaceSystemSettingsModelNew.disambiguation().toString(), + workspaceSystemSettingsDisambiguationModel.toString()); + assertEquals(workspaceSystemSettingsModelNew.spellingSuggestions(), Boolean.valueOf(true)); + assertEquals(workspaceSystemSettingsModelNew.spellingAutoCorrect(), Boolean.valueOf(true)); + assertEquals( + workspaceSystemSettingsModelNew.systemEntities().toString(), + workspaceSystemSettingsSystemEntitiesModel.toString()); + assertEquals( + workspaceSystemSettingsModelNew.offTopic().toString(), + workspaceSystemSettingsOffTopicModel.toString()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsToolingTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsToolingTest.java new file mode 100644 index 00000000000..eb3851f10a4 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsToolingTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the WorkspaceSystemSettingsTooling model. */ +public class WorkspaceSystemSettingsToolingTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testWorkspaceSystemSettingsTooling() throws Throwable { + WorkspaceSystemSettingsTooling workspaceSystemSettingsToolingModel = + new WorkspaceSystemSettingsTooling.Builder().storeGenericResponses(true).build(); + assertEquals( + workspaceSystemSettingsToolingModel.storeGenericResponses(), Boolean.valueOf(true)); + + String json = TestUtilities.serialize(workspaceSystemSettingsToolingModel); + + WorkspaceSystemSettingsTooling workspaceSystemSettingsToolingModelNew = + TestUtilities.deserialize(json, WorkspaceSystemSettingsTooling.class); + assertTrue(workspaceSystemSettingsToolingModelNew instanceof WorkspaceSystemSettingsTooling); + assertEquals( + workspaceSystemSettingsToolingModelNew.storeGenericResponses(), Boolean.valueOf(true)); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WorkspaceTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WorkspaceTest.java new file mode 100644 index 00000000000..684276c616d --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/model/WorkspaceTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Workspace model. */ +public class WorkspaceTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testWorkspace() throws Throwable { + Workspace workspaceModel = new Workspace(); + assertNull(workspaceModel.getName()); + assertNull(workspaceModel.getDescription()); + assertNull(workspaceModel.getLanguage()); + assertNull(workspaceModel.getDialogNodes()); + assertNull(workspaceModel.getCounterexamples()); + assertNull(workspaceModel.getMetadata()); + assertNull(workspaceModel.isLearningOptOut()); + assertNull(workspaceModel.getSystemSettings()); + assertNull(workspaceModel.getWebhooks()); + assertNull(workspaceModel.getIntents()); + assertNull(workspaceModel.getEntities()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v1/utils/TestUtilities.java b/assistant/src/test/java/com/ibm/watson/assistant/v1/utils/TestUtilities.java new file mode 100644 index 00000000000..2c22a2df327 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/utils/TestUtilities.java @@ -0,0 +1,128 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v1.utils; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.cloud.sdk.core.util.GsonSingleton; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import okhttp3.HttpUrl; +import okhttp3.mockwebserver.RecordedRequest; + +/** A class used by the unit tests containing utility functions. */ +public class TestUtilities { + public static Map createMockMap() { + Map mockMap = new HashMap<>(); + mockMap.put("foo", "bar"); + return mockMap; + } + + public static HashMap createMockStreamMap() { + return new HashMap() { + { + put("key1", createMockStream("This is a mock file.")); + } + }; + } + + public static Map parseQueryString(RecordedRequest req) { + Map queryMap = new HashMap<>(); + + try { + HttpUrl requestUrl = req.getRequestUrl(); + + if (requestUrl != null) { + Set queryParamsNames = requestUrl.queryParameterNames(); + // map the parameter name to its corresponding value + for (String p : queryParamsNames) { + // get the corresponding value for the parameter (p) + List val = requestUrl.queryParameterValues(p); + if (val != null && !val.isEmpty()) { + String joinedQuery = String.join(",", val); + queryMap.put(p, joinedQuery); + } + } + } + if (queryMap.isEmpty()) { + return null; + } + } catch (Exception e) { + return null; + } + + return queryMap; + } + + public static String parseReqPath(RecordedRequest req) { + String parsedPath = null; + + try { + String fullPath = req.getPath(); + if (fullPath != null && !fullPath.isEmpty()) { + // retrieve the path segment before the query parameter + parsedPath = fullPath.split("\\?", 2)[0]; + } + if (parsedPath.isEmpty() || parsedPath == null) { + return null; + } + + } catch (Exception e) { + return null; + } + + return parsedPath; + } + + public static String serialize(Object obj) { + return GsonSingleton.getGson().toJson(obj); + } + + public static T deserialize(String json, Class clazz) { + return GsonSingleton.getGson().fromJson(json, clazz); + } + + public static InputStream createMockStream(String s) { + return new ByteArrayInputStream(s.getBytes()); + } + + public static List creatMockListFileWithMetadata() { + List list = new ArrayList(); + byte[] fileBytes = {(byte) 0xde, (byte) 0xad, (byte) 0xbe, (byte) 0xef}; + InputStream inputStream = new ByteArrayInputStream(fileBytes); + FileWithMetadata.Builder builder = new FileWithMetadata.Builder(); + builder.data(inputStream); + FileWithMetadata fileWithMetadata = builder.build(); + list.add(fileWithMetadata); + + return list; + } + + public static byte[] createMockByteArray(String bytes) { + return bytes.getBytes(); + } + + public static Date createMockDate(String date) throws Exception { + return new SimpleDateFormat("yyyy-MM-dd").parse(date); + } + + public static Date createMockDateTime(String date) throws Exception { + return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").parse(date); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/AssistantServiceIT.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/AssistantServiceIT.java index 16b02f35d0d..f9f3ccb6459 100644 --- a/assistant/src/test/java/com/ibm/watson/assistant/v2/AssistantServiceIT.java +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/AssistantServiceIT.java @@ -53,8 +53,7 @@ public void testSendMessages() { service.createSession(createSessionOptions).execute().getResult(); String sessionId = sessionResponse.getSessionId(); - final List messages = - Arrays.asList("Hello"); + final List messages = Arrays.asList("Hello"); MessageContext context = new MessageContext.Builder().build(); try { @@ -111,8 +110,7 @@ public void testSendMessageStateless() { service.createSession(createSessionOptions).execute().getResult(); String sessionId = sessionResponse.getSessionId(); - final List messages = - Arrays.asList("Hello"); + final List messages = Arrays.asList("Hello"); MessageContextStateless context = new MessageContextStateless.Builder().build(); try { diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/AssistantTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/AssistantTest.java index 481745d40bf..464324727b1 100644 --- a/assistant/src/test/java/com/ibm/watson/assistant/v2/AssistantTest.java +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/AssistantTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -12,383 +12,796 @@ */ package com.ibm.watson.assistant.v2; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.testng.Assert.*; +import com.ibm.cloud.sdk.core.http.Response; +import com.ibm.cloud.sdk.core.security.Authenticator; import com.ibm.cloud.sdk.core.security.NoAuthAuthenticator; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.model.BulkClassifyOptions; +import com.ibm.watson.assistant.v2.model.BulkClassifyResponse; +import com.ibm.watson.assistant.v2.model.BulkClassifyUtterance; import com.ibm.watson.assistant.v2.model.CaptureGroup; import com.ibm.watson.assistant.v2.model.CreateSessionOptions; import com.ibm.watson.assistant.v2.model.DeleteSessionOptions; -import com.ibm.watson.assistant.v2.model.DialogLogMessage; -import com.ibm.watson.assistant.v2.model.DialogNodeAction; +import com.ibm.watson.assistant.v2.model.DeleteUserDataOptions; +import com.ibm.watson.assistant.v2.model.ListLogsOptions; +import com.ibm.watson.assistant.v2.model.LogCollection; import com.ibm.watson.assistant.v2.model.MessageContext; import com.ibm.watson.assistant.v2.model.MessageContextGlobal; +import com.ibm.watson.assistant.v2.model.MessageContextGlobalStateless; import com.ibm.watson.assistant.v2.model.MessageContextGlobalSystem; -import com.ibm.watson.assistant.v2.model.MessageContextSkills; +import com.ibm.watson.assistant.v2.model.MessageContextSkill; +import com.ibm.watson.assistant.v2.model.MessageContextSkillSystem; +import com.ibm.watson.assistant.v2.model.MessageContextStateless; import com.ibm.watson.assistant.v2.model.MessageInput; import com.ibm.watson.assistant.v2.model.MessageInputOptions; +import com.ibm.watson.assistant.v2.model.MessageInputOptionsSpelling; +import com.ibm.watson.assistant.v2.model.MessageInputOptionsStateless; +import com.ibm.watson.assistant.v2.model.MessageInputStateless; import com.ibm.watson.assistant.v2.model.MessageOptions; -import com.ibm.watson.assistant.v2.model.MessageOutputDebug; import com.ibm.watson.assistant.v2.model.MessageResponse; +import com.ibm.watson.assistant.v2.model.MessageResponseStateless; +import com.ibm.watson.assistant.v2.model.MessageStatelessOptions; import com.ibm.watson.assistant.v2.model.RuntimeEntity; +import com.ibm.watson.assistant.v2.model.RuntimeEntityAlternative; +import com.ibm.watson.assistant.v2.model.RuntimeEntityInterpretation; +import com.ibm.watson.assistant.v2.model.RuntimeEntityRole; import com.ibm.watson.assistant.v2.model.RuntimeIntent; -import com.ibm.watson.assistant.v2.model.RuntimeResponseGeneric; import com.ibm.watson.assistant.v2.model.SessionResponse; -import com.ibm.watson.common.WatsonServiceUnitTest; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.IOException; +import java.io.InputStream; import java.util.HashMap; import java.util.List; import java.util.Map; import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; import okhttp3.mockwebserver.RecordedRequest; -import org.junit.Before; -import org.junit.Test; - -/** Unit tests for Assistant v2. */ -public class AssistantTest extends WatsonServiceUnitTest { - private static final String ASSISTANT_ID = "assistant_id"; - private static final String SESSION_ID = "session_id"; - private static final String TIMEZONE = "timezone"; - private static final Long TURN_COUNT = 10L; - private static final String USER_ID = "user_id"; - private static final String GROUP = "group"; - private static final List LOCATION = Arrays.asList(1L, 2L); - private static final Double CONFIDENCE = 0.0; - private static final String ENTITY = "entity"; - private static final Map MAP = new HashMap<>(); - private static final String VALUE = "value"; - private static final String INTENT = "intent"; - private static final String TEXT = "text"; - private static final String SUGGESTION_ID = "suggestion_id"; - private static final String MESSAGE = "message"; - private static final String CONDITIONS = "conditions"; - private static final String TITLE = "title"; - private static final String DIALOG_NODE = "dialog_node"; - private static final String NAME = "name"; - private static final String RESULT_VARIABLE = "result_variable"; - private static final String CREDENTIALS = "credentials"; - private static final String DESCRIPTION = "description"; - private static final Long TIME = 1234L; - private static final String SOURCE = "source"; - private static final String TOPIC = "topic"; - private static final String LABEL = "label"; - - private static final String VERSION = "2018-09-20"; - private static final String RESOURCE = "src/test/resources/assistant/"; - private static final String MESSAGE_PATH = - String.format( - "/v2/assistants/%s/sessions/%s/message?version=%s", ASSISTANT_ID, SESSION_ID, VERSION); - private static final String CREATE_SESSION_PATH = - String.format("/v2/assistants/%s/sessions?version=%s", ASSISTANT_ID, VERSION); - private static final String DELETE_SESSION_PATH = - String.format("/v2/assistants/%s/sessions/%s?version=%s", ASSISTANT_ID, SESSION_ID, VERSION); - - private MessageResponse messageResponse; - private SessionResponse sessionResponse; - - private Assistant service; - - /** - * Sets up the tests. - * - * @throws Exception the exception - */ - /* - * (non-Javadoc) - * @see com.ibm.watson.common.WatsonServiceTest#setUp() - */ - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - - MAP.put("key", "value"); - - messageResponse = loadFixture(RESOURCE + "message_response.json", MessageResponse.class); - sessionResponse = loadFixture(RESOURCE + "session_response.json", SessionResponse.class); - - service = new Assistant(VERSION, new NoAuthAuthenticator()); - service.setServiceUrl(getMockWebServerUrl()); +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +/** Unit test class for the Assistant service. */ +public class AssistantTest { + + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + protected MockWebServer server; + protected Assistant assistantService; + + public void constructClientService() throws Throwable { + final String serviceName = "testService"; + // set mock values for global params + String version = "testString"; + + final Authenticator authenticator = new NoAuthAuthenticator(); + + assistantService = new Assistant(version, serviceName, authenticator); + String url = server.url("/").toString(); + assistantService.setServiceUrl(url); } - /** Test capture group. */ - @Test - public void testCaptureGroup() { - CaptureGroup captureGroup = new CaptureGroup.Builder().group(GROUP).location(LOCATION).build(); + /** Negative Test - construct the service with a null authenticator. */ + @Test(expectedExceptions = IllegalArgumentException.class) + public void testConstructorWithNullAuthenticator() throws Throwable { + final String serviceName = "testService"; + // set mock values for global params + String version = "testString"; - assertEquals(GROUP, captureGroup.group()); - assertEquals(LOCATION, captureGroup.location()); + new Assistant(version, serviceName, null); } - /** Test create session options. */ @Test - public void testCreateSessionOptions() { - CreateSessionOptions createSessionOptions = - new CreateSessionOptions.Builder().assistantId(ASSISTANT_ID).build(); - createSessionOptions = createSessionOptions.newBuilder().build(); - - assertEquals(ASSISTANT_ID, createSessionOptions.assistantId()); + public void testGetVersion() throws Throwable { + constructClientService(); + assertEquals(assistantService.getVersion(), "testString"); } - /** Test delete session options. */ @Test - public void testDeleteSessionOptions() { - DeleteSessionOptions deleteSessionOptions = - new DeleteSessionOptions.Builder().assistantId(ASSISTANT_ID).sessionId(SESSION_ID).build(); - deleteSessionOptions = deleteSessionOptions.newBuilder().build(); + public void testCreateSessionWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = "{\"session_id\": \"sessionId\"}"; + String createSessionPath = "/v2/assistants/testString/sessions"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(201) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the CreateSessionOptions model + CreateSessionOptions createSessionOptionsModel = + new CreateSessionOptions.Builder().assistantId("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = + assistantService.createSession(createSessionOptionsModel).execute(); + assertNotNull(response); + SessionResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createSessionPath); + } + + // Test the createSession operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateSessionNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); - assertEquals(ASSISTANT_ID, deleteSessionOptions.assistantId()); - assertEquals(SESSION_ID, deleteSessionOptions.sessionId()); + // Invoke operation with null options model (negative test) + assistantService.createSession(null).execute(); } - /** Test message context global system. */ @Test - public void testMessageContextGlobalSystem() { - MessageContextGlobalSystem messageContextGlobalSystem = - new MessageContextGlobalSystem.Builder() - .timezone(TIMEZONE) - .turnCount(TURN_COUNT) - .userId(USER_ID) + public void testDeleteSessionWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String deleteSessionPath = "/v2/assistants/testString/sessions/testString"; + + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the DeleteSessionOptions model + DeleteSessionOptions deleteSessionOptionsModel = + new DeleteSessionOptions.Builder() + .assistantId("testString") + .sessionId("testString") .build(); - assertEquals(TIMEZONE, messageContextGlobalSystem.timezone()); - assertEquals(TURN_COUNT, messageContextGlobalSystem.turnCount()); - assertEquals(USER_ID, messageContextGlobalSystem.userId()); + // Invoke operation with valid options model (positive test) + Response response = assistantService.deleteSession(deleteSessionOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteSessionPath); } - /** Test message context global. */ - @Test - public void testMessageContextGlobal() { - MessageContextGlobalSystem messageContextGlobalSystem = - new MessageContextGlobalSystem.Builder().build(); + // Test the deleteSession operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteSessionNoOptions() throws Throwable { + // construct the service + constructClientService(); - MessageContextGlobal messageContextGlobal = - new MessageContextGlobal.Builder().system(messageContextGlobalSystem).build(); + server.enqueue(new MockResponse()); - assertEquals(messageContextGlobalSystem, messageContextGlobal.system()); + // Invoke operation with null options model (negative test) + assistantService.deleteSession(null).execute(); } - /** Test message context. */ @Test - public void testMessageContext() { - MessageContextGlobal messageContextGlobal = new MessageContextGlobal.Builder().build(); - MessageContextSkills messageContextSkills = new MessageContextSkills(); + public void testMessageWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"output\": {\"generic\": [{\"response_type\": \"option\", \"title\": \"title\", \"description\": \"description\", \"preference\": \"dropdown\", \"options\": [{\"label\": \"label\", \"value\": {\"input\": {\"message_type\": \"text\", \"text\": \"text\", \"intents\": [{\"intent\": \"intent\", \"confidence\": 10}], \"entities\": [{\"entity\": \"entity\", \"location\": [8], \"value\": \"value\", \"confidence\": 10, \"metadata\": {\"mapKey\": \"anyValue\"}, \"groups\": [{\"group\": \"group\", \"location\": [8]}], \"interpretation\": {\"calendar_type\": \"calendarType\", \"datetime_link\": \"datetimeLink\", \"festival\": \"festival\", \"granularity\": \"day\", \"range_link\": \"rangeLink\", \"range_modifier\": \"rangeModifier\", \"relative_day\": 11, \"relative_month\": 13, \"relative_week\": 12, \"relative_weekend\": 15, \"relative_year\": 12, \"specific_day\": 11, \"specific_day_of_week\": \"specificDayOfWeek\", \"specific_month\": 13, \"specific_quarter\": 15, \"specific_year\": 12, \"numeric_value\": 12, \"subtype\": \"subtype\", \"part_of_day\": \"partOfDay\", \"relative_hour\": 12, \"relative_minute\": 14, \"relative_second\": 14, \"specific_hour\": 12, \"specific_minute\": 14, \"specific_second\": 14, \"timezone\": \"timezone\"}, \"alternatives\": [{\"value\": \"value\", \"confidence\": 10}], \"role\": {\"type\": \"date_from\"}}], \"suggestion_id\": \"suggestionId\", \"options\": {\"restart\": false, \"alternate_intents\": true, \"spelling\": {\"suggestions\": false, \"auto_correct\": false}, \"debug\": false, \"return_context\": false, \"export\": true}}}}]}], \"intents\": [{\"intent\": \"intent\", \"confidence\": 10}], \"entities\": [{\"entity\": \"entity\", \"location\": [8], \"value\": \"value\", \"confidence\": 10, \"metadata\": {\"mapKey\": \"anyValue\"}, \"groups\": [{\"group\": \"group\", \"location\": [8]}], \"interpretation\": {\"calendar_type\": \"calendarType\", \"datetime_link\": \"datetimeLink\", \"festival\": \"festival\", \"granularity\": \"day\", \"range_link\": \"rangeLink\", \"range_modifier\": \"rangeModifier\", \"relative_day\": 11, \"relative_month\": 13, \"relative_week\": 12, \"relative_weekend\": 15, \"relative_year\": 12, \"specific_day\": 11, \"specific_day_of_week\": \"specificDayOfWeek\", \"specific_month\": 13, \"specific_quarter\": 15, \"specific_year\": 12, \"numeric_value\": 12, \"subtype\": \"subtype\", \"part_of_day\": \"partOfDay\", \"relative_hour\": 12, \"relative_minute\": 14, \"relative_second\": 14, \"specific_hour\": 12, \"specific_minute\": 14, \"specific_second\": 14, \"timezone\": \"timezone\"}, \"alternatives\": [{\"value\": \"value\", \"confidence\": 10}], \"role\": {\"type\": \"date_from\"}}], \"actions\": [{\"name\": \"name\", \"type\": \"client\", \"parameters\": {\"mapKey\": \"anyValue\"}, \"result_variable\": \"resultVariable\", \"credentials\": \"credentials\"}], \"debug\": {\"nodes_visited\": [{\"dialog_node\": \"dialogNode\", \"title\": \"title\", \"conditions\": \"conditions\"}], \"log_messages\": [{\"level\": \"info\", \"message\": \"message\"}], \"branch_exited\": true, \"branch_exited_reason\": \"completed\"}, \"user_defined\": {\"mapKey\": \"anyValue\"}, \"spelling\": {\"text\": \"text\", \"original_text\": \"originalText\", \"suggested_text\": \"suggestedText\"}}, \"context\": {\"global\": {\"system\": {\"timezone\": \"timezone\", \"user_id\": \"userId\", \"turn_count\": 9, \"locale\": \"en-us\", \"reference_time\": \"referenceTime\"}, \"session_id\": \"sessionId\"}, \"skills\": {\"mapKey\": {\"user_defined\": {\"mapKey\": \"anyValue\"}, \"system\": {\"state\": \"state\"}}}}}"; + String messagePath = "/v2/assistants/testString/sessions/testString/message"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the RuntimeIntent model + RuntimeIntent runtimeIntentModel = + new RuntimeIntent.Builder().intent("testString").confidence(Double.valueOf("72.5")).build(); + + // Construct an instance of the CaptureGroup model + CaptureGroup captureGroupModel = + new CaptureGroup.Builder() + .group("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) + .build(); - MessageContext messageContext = - new MessageContext.Builder() - .global(messageContextGlobal) - .skills(messageContextSkills) + // Construct an instance of the RuntimeEntityInterpretation model + RuntimeEntityInterpretation runtimeEntityInterpretationModel = + new RuntimeEntityInterpretation.Builder() + .calendarType("testString") + .datetimeLink("testString") + .festival("testString") + .granularity("day") + .rangeLink("testString") + .rangeModifier("testString") + .relativeDay(Double.valueOf("72.5")) + .relativeMonth(Double.valueOf("72.5")) + .relativeWeek(Double.valueOf("72.5")) + .relativeWeekend(Double.valueOf("72.5")) + .relativeYear(Double.valueOf("72.5")) + .specificDay(Double.valueOf("72.5")) + .specificDayOfWeek("testString") + .specificMonth(Double.valueOf("72.5")) + .specificQuarter(Double.valueOf("72.5")) + .specificYear(Double.valueOf("72.5")) + .numericValue(Double.valueOf("72.5")) + .subtype("testString") + .partOfDay("testString") + .relativeHour(Double.valueOf("72.5")) + .relativeMinute(Double.valueOf("72.5")) + .relativeSecond(Double.valueOf("72.5")) + .specificHour(Double.valueOf("72.5")) + .specificMinute(Double.valueOf("72.5")) + .specificSecond(Double.valueOf("72.5")) + .timezone("testString") .build(); - assertEquals(messageContextGlobal, messageContext.global()); - assertEquals(messageContextSkills, messageContext.skills()); - } + // Construct an instance of the RuntimeEntityAlternative model + RuntimeEntityAlternative runtimeEntityAlternativeModel = + new RuntimeEntityAlternative.Builder() + .value("testString") + .confidence(Double.valueOf("72.5")) + .build(); - /** Test message input. */ - @Test - public void testMessageInput() { - RuntimeEntity entity1 = - new RuntimeEntity.Builder().entity(ENTITY).location(LOCATION).value(VALUE).build(); - RuntimeEntity entity2 = - new RuntimeEntity.Builder().entity(ENTITY).location(LOCATION).value(VALUE).build(); - List entityList = new ArrayList<>(); - entityList.add(entity1); - RuntimeIntent intent1 = - new RuntimeIntent.Builder().confidence(CONFIDENCE).intent(INTENT).build(); - RuntimeIntent intent2 = - new RuntimeIntent.Builder().confidence(CONFIDENCE).intent(INTENT).build(); - List intentList = new ArrayList<>(); - intentList.add(intent1); - MessageInputOptions inputOptions = new MessageInputOptions.Builder().build(); - - MessageInput messageInput = - new MessageInput.Builder() - .messageType(MessageInput.MessageType.TEXT) - .entities(entityList) - .addEntity(entity2) - .intents(intentList) - .addIntent(intent2) - .options(inputOptions) - .suggestionId(SUGGESTION_ID) - .text(TEXT) + // Construct an instance of the RuntimeEntityRole model + RuntimeEntityRole runtimeEntityRoleModel = + new RuntimeEntityRole.Builder().type("date_from").build(); + + // Construct an instance of the RuntimeEntity model + RuntimeEntity runtimeEntityModel = + new RuntimeEntity.Builder() + .entity("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) + .value("testString") + .confidence(Double.valueOf("72.5")) + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .groups( + new java.util.ArrayList(java.util.Arrays.asList(captureGroupModel))) + .interpretation(runtimeEntityInterpretationModel) + .alternatives( + new java.util.ArrayList( + java.util.Arrays.asList(runtimeEntityAlternativeModel))) + .role(runtimeEntityRoleModel) .build(); - messageInput = messageInput.newBuilder().build(); - - entityList.add(entity2); - intentList.add(intent2); - assertEquals(MessageInput.MessageType.TEXT, messageInput.messageType()); - assertEquals(entityList, messageInput.entities()); - assertEquals(intentList, messageInput.intents()); - assertEquals(inputOptions, messageInput.options()); - assertEquals(SUGGESTION_ID, messageInput.suggestionId()); - assertEquals(TEXT, messageInput.text()); - } - /** Test message input options. */ - @Test - public void testMessageInputOptions() { - MessageInputOptions inputOptions = + // Construct an instance of the MessageInputOptionsSpelling model + MessageInputOptionsSpelling messageInputOptionsSpellingModel = + new MessageInputOptionsSpelling.Builder().suggestions(true).autoCorrect(true).build(); + + // Construct an instance of the MessageInputOptions model + MessageInputOptions messageInputOptionsModel = new MessageInputOptions.Builder() + .restart(true) .alternateIntents(true) + .spelling(messageInputOptionsSpellingModel) .debug(true) - .restart(true) .returnContext(true) + .export(true) .build(); - assertTrue(inputOptions.alternateIntents()); - assertTrue(inputOptions.debug()); - assertTrue(inputOptions.restart()); - assertTrue(inputOptions.returnContext()); - } + // Construct an instance of the MessageInput model + MessageInput messageInputModel = + new MessageInput.Builder() + .messageType("text") + .text("testString") + .intents( + new java.util.ArrayList(java.util.Arrays.asList(runtimeIntentModel))) + .entities( + new java.util.ArrayList(java.util.Arrays.asList(runtimeEntityModel))) + .suggestionId("testString") + .options(messageInputOptionsModel) + .build(); - /** Test message options. */ - @Test - public void testMessageOptions() { - MessageContext messageContext = new MessageContext.Builder().build(); - MessageInput messageInput = new MessageInput.Builder().build(); + // Construct an instance of the MessageContextGlobalSystem model + MessageContextGlobalSystem messageContextGlobalSystemModel = + new MessageContextGlobalSystem.Builder() + .timezone("testString") + .userId("testString") + .turnCount(Long.valueOf("26")) + .locale("en-us") + .referenceTime("testString") + .build(); + + // Construct an instance of the MessageContextGlobal model + MessageContextGlobal messageContextGlobalModel = + new MessageContextGlobal.Builder().system(messageContextGlobalSystemModel).build(); + + // Construct an instance of the MessageContextSkillSystem model + MessageContextSkillSystem messageContextSkillSystemModel = + new MessageContextSkillSystem.Builder() + .state("testString") + .add("foo", "testString") + .build(); + + // Construct an instance of the MessageContextSkill model + MessageContextSkill messageContextSkillModel = + new MessageContextSkill.Builder() + .userDefined( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .system(messageContextSkillSystemModel) + .build(); + + // Construct an instance of the MessageContext model + MessageContext messageContextModel = + new MessageContext.Builder() + .global(messageContextGlobalModel) + .skills( + new java.util.HashMap() { + { + put("foo", messageContextSkillModel); + } + }) + .build(); - MessageOptions messageOptions = + // Construct an instance of the MessageOptions model + MessageOptions messageOptionsModel = new MessageOptions.Builder() - .assistantId(ASSISTANT_ID) - .context(messageContext) - .input(messageInput) - .sessionId(SESSION_ID) + .assistantId("testString") + .sessionId("testString") + .input(messageInputModel) + .context(messageContextModel) .build(); - messageOptions = messageOptions.newBuilder().build(); - assertEquals(ASSISTANT_ID, messageOptions.assistantId()); - assertEquals(messageContext, messageOptions.context()); - assertEquals(messageInput, messageOptions.input()); - assertEquals(SESSION_ID, messageOptions.sessionId()); + // Invoke operation with valid options model (positive test) + Response response = assistantService.message(messageOptionsModel).execute(); + assertNotNull(response); + MessageResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, messagePath); + } + + // Test the message operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testMessageNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + assistantService.message(null).execute(); } - /** Test runtime entity. */ @Test - public void testRuntimeEntity() { - CaptureGroup captureGroup = new CaptureGroup.Builder().group(GROUP).build(); - List captureGroupList = Collections.singletonList(captureGroup); + public void testMessageStatelessWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"output\": {\"generic\": [{\"response_type\": \"option\", \"title\": \"title\", \"description\": \"description\", \"preference\": \"dropdown\", \"options\": [{\"label\": \"label\", \"value\": {\"input\": {\"message_type\": \"text\", \"text\": \"text\", \"intents\": [{\"intent\": \"intent\", \"confidence\": 10}], \"entities\": [{\"entity\": \"entity\", \"location\": [8], \"value\": \"value\", \"confidence\": 10, \"metadata\": {\"mapKey\": \"anyValue\"}, \"groups\": [{\"group\": \"group\", \"location\": [8]}], \"interpretation\": {\"calendar_type\": \"calendarType\", \"datetime_link\": \"datetimeLink\", \"festival\": \"festival\", \"granularity\": \"day\", \"range_link\": \"rangeLink\", \"range_modifier\": \"rangeModifier\", \"relative_day\": 11, \"relative_month\": 13, \"relative_week\": 12, \"relative_weekend\": 15, \"relative_year\": 12, \"specific_day\": 11, \"specific_day_of_week\": \"specificDayOfWeek\", \"specific_month\": 13, \"specific_quarter\": 15, \"specific_year\": 12, \"numeric_value\": 12, \"subtype\": \"subtype\", \"part_of_day\": \"partOfDay\", \"relative_hour\": 12, \"relative_minute\": 14, \"relative_second\": 14, \"specific_hour\": 12, \"specific_minute\": 14, \"specific_second\": 14, \"timezone\": \"timezone\"}, \"alternatives\": [{\"value\": \"value\", \"confidence\": 10}], \"role\": {\"type\": \"date_from\"}}], \"suggestion_id\": \"suggestionId\", \"options\": {\"restart\": false, \"alternate_intents\": true, \"spelling\": {\"suggestions\": false, \"auto_correct\": false}, \"debug\": false, \"return_context\": false, \"export\": true}}}}]}], \"intents\": [{\"intent\": \"intent\", \"confidence\": 10}], \"entities\": [{\"entity\": \"entity\", \"location\": [8], \"value\": \"value\", \"confidence\": 10, \"metadata\": {\"mapKey\": \"anyValue\"}, \"groups\": [{\"group\": \"group\", \"location\": [8]}], \"interpretation\": {\"calendar_type\": \"calendarType\", \"datetime_link\": \"datetimeLink\", \"festival\": \"festival\", \"granularity\": \"day\", \"range_link\": \"rangeLink\", \"range_modifier\": \"rangeModifier\", \"relative_day\": 11, \"relative_month\": 13, \"relative_week\": 12, \"relative_weekend\": 15, \"relative_year\": 12, \"specific_day\": 11, \"specific_day_of_week\": \"specificDayOfWeek\", \"specific_month\": 13, \"specific_quarter\": 15, \"specific_year\": 12, \"numeric_value\": 12, \"subtype\": \"subtype\", \"part_of_day\": \"partOfDay\", \"relative_hour\": 12, \"relative_minute\": 14, \"relative_second\": 14, \"specific_hour\": 12, \"specific_minute\": 14, \"specific_second\": 14, \"timezone\": \"timezone\"}, \"alternatives\": [{\"value\": \"value\", \"confidence\": 10}], \"role\": {\"type\": \"date_from\"}}], \"actions\": [{\"name\": \"name\", \"type\": \"client\", \"parameters\": {\"mapKey\": \"anyValue\"}, \"result_variable\": \"resultVariable\", \"credentials\": \"credentials\"}], \"debug\": {\"nodes_visited\": [{\"dialog_node\": \"dialogNode\", \"title\": \"title\", \"conditions\": \"conditions\"}], \"log_messages\": [{\"level\": \"info\", \"message\": \"message\"}], \"branch_exited\": true, \"branch_exited_reason\": \"completed\"}, \"user_defined\": {\"mapKey\": \"anyValue\"}, \"spelling\": {\"text\": \"text\", \"original_text\": \"originalText\", \"suggested_text\": \"suggestedText\"}}, \"context\": {\"global\": {\"system\": {\"timezone\": \"timezone\", \"user_id\": \"userId\", \"turn_count\": 9, \"locale\": \"en-us\", \"reference_time\": \"referenceTime\"}, \"session_id\": \"sessionId\"}, \"skills\": {\"mapKey\": {\"user_defined\": {\"mapKey\": \"anyValue\"}, \"system\": {\"state\": \"state\"}}}}}"; + String messageStatelessPath = "/v2/assistants/testString/message"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the RuntimeIntent model + RuntimeIntent runtimeIntentModel = + new RuntimeIntent.Builder().intent("testString").confidence(Double.valueOf("72.5")).build(); + + // Construct an instance of the CaptureGroup model + CaptureGroup captureGroupModel = + new CaptureGroup.Builder() + .group("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) + .build(); - RuntimeEntity runtimeEntity = + // Construct an instance of the RuntimeEntityInterpretation model + RuntimeEntityInterpretation runtimeEntityInterpretationModel = + new RuntimeEntityInterpretation.Builder() + .calendarType("testString") + .datetimeLink("testString") + .festival("testString") + .granularity("day") + .rangeLink("testString") + .rangeModifier("testString") + .relativeDay(Double.valueOf("72.5")) + .relativeMonth(Double.valueOf("72.5")) + .relativeWeek(Double.valueOf("72.5")) + .relativeWeekend(Double.valueOf("72.5")) + .relativeYear(Double.valueOf("72.5")) + .specificDay(Double.valueOf("72.5")) + .specificDayOfWeek("testString") + .specificMonth(Double.valueOf("72.5")) + .specificQuarter(Double.valueOf("72.5")) + .specificYear(Double.valueOf("72.5")) + .numericValue(Double.valueOf("72.5")) + .subtype("testString") + .partOfDay("testString") + .relativeHour(Double.valueOf("72.5")) + .relativeMinute(Double.valueOf("72.5")) + .relativeSecond(Double.valueOf("72.5")) + .specificHour(Double.valueOf("72.5")) + .specificMinute(Double.valueOf("72.5")) + .specificSecond(Double.valueOf("72.5")) + .timezone("testString") + .build(); + + // Construct an instance of the RuntimeEntityAlternative model + RuntimeEntityAlternative runtimeEntityAlternativeModel = + new RuntimeEntityAlternative.Builder() + .value("testString") + .confidence(Double.valueOf("72.5")) + .build(); + + // Construct an instance of the RuntimeEntityRole model + RuntimeEntityRole runtimeEntityRoleModel = + new RuntimeEntityRole.Builder().type("date_from").build(); + + // Construct an instance of the RuntimeEntity model + RuntimeEntity runtimeEntityModel = new RuntimeEntity.Builder() - .confidence(CONFIDENCE) - .entity(ENTITY) - .groups(captureGroupList) - .location(LOCATION) - .metadata(MAP) - .value(VALUE) + .entity("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) + .value("testString") + .confidence(Double.valueOf("72.5")) + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .groups( + new java.util.ArrayList(java.util.Arrays.asList(captureGroupModel))) + .interpretation(runtimeEntityInterpretationModel) + .alternatives( + new java.util.ArrayList( + java.util.Arrays.asList(runtimeEntityAlternativeModel))) + .role(runtimeEntityRoleModel) + .build(); + + // Construct an instance of the MessageInputOptionsSpelling model + MessageInputOptionsSpelling messageInputOptionsSpellingModel = + new MessageInputOptionsSpelling.Builder().suggestions(true).autoCorrect(true).build(); + + // Construct an instance of the MessageInputOptionsStateless model + MessageInputOptionsStateless messageInputOptionsStatelessModel = + new MessageInputOptionsStateless.Builder() + .restart(true) + .alternateIntents(true) + .spelling(messageInputOptionsSpellingModel) + .debug(true) + .build(); + + // Construct an instance of the MessageInputStateless model + MessageInputStateless messageInputStatelessModel = + new MessageInputStateless.Builder() + .messageType("text") + .text("testString") + .intents( + new java.util.ArrayList(java.util.Arrays.asList(runtimeIntentModel))) + .entities( + new java.util.ArrayList(java.util.Arrays.asList(runtimeEntityModel))) + .suggestionId("testString") + .options(messageInputOptionsStatelessModel) + .build(); + + // Construct an instance of the MessageContextGlobalSystem model + MessageContextGlobalSystem messageContextGlobalSystemModel = + new MessageContextGlobalSystem.Builder() + .timezone("testString") + .userId("testString") + .turnCount(Long.valueOf("26")) + .locale("en-us") + .referenceTime("testString") + .build(); + + // Construct an instance of the MessageContextGlobalStateless model + MessageContextGlobalStateless messageContextGlobalStatelessModel = + new MessageContextGlobalStateless.Builder() + .system(messageContextGlobalSystemModel) + .sessionId("testString") + .build(); + + // Construct an instance of the MessageContextSkillSystem model + MessageContextSkillSystem messageContextSkillSystemModel = + new MessageContextSkillSystem.Builder() + .state("testString") + .add("foo", "testString") + .build(); + + // Construct an instance of the MessageContextSkill model + MessageContextSkill messageContextSkillModel = + new MessageContextSkill.Builder() + .userDefined( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .system(messageContextSkillSystemModel) .build(); - assertEquals(CONFIDENCE, runtimeEntity.confidence()); - assertEquals(ENTITY, runtimeEntity.entity()); - assertEquals(captureGroupList, runtimeEntity.groups()); - assertEquals(LOCATION, runtimeEntity.location()); - assertEquals(MAP, runtimeEntity.metadata()); - assertEquals(VALUE, runtimeEntity.value()); + // Construct an instance of the MessageContextStateless model + MessageContextStateless messageContextStatelessModel = + new MessageContextStateless.Builder() + .global(messageContextGlobalStatelessModel) + .skills( + new java.util.HashMap() { + { + put("foo", messageContextSkillModel); + } + }) + .build(); + + // Construct an instance of the MessageStatelessOptions model + MessageStatelessOptions messageStatelessOptionsModel = + new MessageStatelessOptions.Builder() + .assistantId("testString") + .input(messageInputStatelessModel) + .context(messageContextStatelessModel) + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + assistantService.messageStateless(messageStatelessOptionsModel).execute(); + assertNotNull(response); + MessageResponseStateless responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, messageStatelessPath); } - /** Test runtime intent. */ - @Test - public void testRuntimeIntent() { - RuntimeIntent runtimeIntent = - new RuntimeIntent.Builder().confidence(CONFIDENCE).intent(INTENT).build(); + // Test the messageStateless operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testMessageStatelessNoOptions() throws Throwable { + // construct the service + constructClientService(); - assertEquals(CONFIDENCE, runtimeIntent.confidence()); - assertEquals(INTENT, runtimeIntent.intent()); + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + assistantService.messageStateless(null).execute(); } - /** - * Test message. - * - * @throws InterruptedException the interrupted exception - */ @Test - public void testMessage() throws InterruptedException { - server.enqueue(jsonResponse(messageResponse)); + public void testListLogsWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"logs\": [{\"log_id\": \"logId\", \"request\": {\"input\": {\"message_type\": \"text\", \"text\": \"text\", \"intents\": [{\"intent\": \"intent\", \"confidence\": 10}], \"entities\": [{\"entity\": \"entity\", \"location\": [8], \"value\": \"value\", \"confidence\": 10, \"metadata\": {\"mapKey\": \"anyValue\"}, \"groups\": [{\"group\": \"group\", \"location\": [8]}], \"interpretation\": {\"calendar_type\": \"calendarType\", \"datetime_link\": \"datetimeLink\", \"festival\": \"festival\", \"granularity\": \"day\", \"range_link\": \"rangeLink\", \"range_modifier\": \"rangeModifier\", \"relative_day\": 11, \"relative_month\": 13, \"relative_week\": 12, \"relative_weekend\": 15, \"relative_year\": 12, \"specific_day\": 11, \"specific_day_of_week\": \"specificDayOfWeek\", \"specific_month\": 13, \"specific_quarter\": 15, \"specific_year\": 12, \"numeric_value\": 12, \"subtype\": \"subtype\", \"part_of_day\": \"partOfDay\", \"relative_hour\": 12, \"relative_minute\": 14, \"relative_second\": 14, \"specific_hour\": 12, \"specific_minute\": 14, \"specific_second\": 14, \"timezone\": \"timezone\"}, \"alternatives\": [{\"value\": \"value\", \"confidence\": 10}], \"role\": {\"type\": \"date_from\"}}], \"suggestion_id\": \"suggestionId\", \"options\": {\"restart\": false, \"alternate_intents\": true, \"spelling\": {\"suggestions\": false, \"auto_correct\": false}, \"debug\": false, \"return_context\": false, \"export\": true}}, \"context\": {\"global\": {\"system\": {\"timezone\": \"timezone\", \"user_id\": \"userId\", \"turn_count\": 9, \"locale\": \"en-us\", \"reference_time\": \"referenceTime\"}, \"session_id\": \"sessionId\"}, \"skills\": {\"mapKey\": {\"user_defined\": {\"mapKey\": \"anyValue\"}, \"system\": {\"state\": \"state\"}}}}}, \"response\": {\"output\": {\"generic\": [{\"response_type\": \"option\", \"title\": \"title\", \"description\": \"description\", \"preference\": \"dropdown\", \"options\": [{\"label\": \"label\", \"value\": {\"input\": {\"message_type\": \"text\", \"text\": \"text\", \"intents\": [{\"intent\": \"intent\", \"confidence\": 10}], \"entities\": [{\"entity\": \"entity\", \"location\": [8], \"value\": \"value\", \"confidence\": 10, \"metadata\": {\"mapKey\": \"anyValue\"}, \"groups\": [{\"group\": \"group\", \"location\": [8]}], \"interpretation\": {\"calendar_type\": \"calendarType\", \"datetime_link\": \"datetimeLink\", \"festival\": \"festival\", \"granularity\": \"day\", \"range_link\": \"rangeLink\", \"range_modifier\": \"rangeModifier\", \"relative_day\": 11, \"relative_month\": 13, \"relative_week\": 12, \"relative_weekend\": 15, \"relative_year\": 12, \"specific_day\": 11, \"specific_day_of_week\": \"specificDayOfWeek\", \"specific_month\": 13, \"specific_quarter\": 15, \"specific_year\": 12, \"numeric_value\": 12, \"subtype\": \"subtype\", \"part_of_day\": \"partOfDay\", \"relative_hour\": 12, \"relative_minute\": 14, \"relative_second\": 14, \"specific_hour\": 12, \"specific_minute\": 14, \"specific_second\": 14, \"timezone\": \"timezone\"}, \"alternatives\": [{\"value\": \"value\", \"confidence\": 10}], \"role\": {\"type\": \"date_from\"}}], \"suggestion_id\": \"suggestionId\", \"options\": {\"restart\": false, \"alternate_intents\": true, \"spelling\": {\"suggestions\": false, \"auto_correct\": false}, \"debug\": false, \"return_context\": false, \"export\": true}}}}]}], \"intents\": [{\"intent\": \"intent\", \"confidence\": 10}], \"entities\": [{\"entity\": \"entity\", \"location\": [8], \"value\": \"value\", \"confidence\": 10, \"metadata\": {\"mapKey\": \"anyValue\"}, \"groups\": [{\"group\": \"group\", \"location\": [8]}], \"interpretation\": {\"calendar_type\": \"calendarType\", \"datetime_link\": \"datetimeLink\", \"festival\": \"festival\", \"granularity\": \"day\", \"range_link\": \"rangeLink\", \"range_modifier\": \"rangeModifier\", \"relative_day\": 11, \"relative_month\": 13, \"relative_week\": 12, \"relative_weekend\": 15, \"relative_year\": 12, \"specific_day\": 11, \"specific_day_of_week\": \"specificDayOfWeek\", \"specific_month\": 13, \"specific_quarter\": 15, \"specific_year\": 12, \"numeric_value\": 12, \"subtype\": \"subtype\", \"part_of_day\": \"partOfDay\", \"relative_hour\": 12, \"relative_minute\": 14, \"relative_second\": 14, \"specific_hour\": 12, \"specific_minute\": 14, \"specific_second\": 14, \"timezone\": \"timezone\"}, \"alternatives\": [{\"value\": \"value\", \"confidence\": 10}], \"role\": {\"type\": \"date_from\"}}], \"actions\": [{\"name\": \"name\", \"type\": \"client\", \"parameters\": {\"mapKey\": \"anyValue\"}, \"result_variable\": \"resultVariable\", \"credentials\": \"credentials\"}], \"debug\": {\"nodes_visited\": [{\"dialog_node\": \"dialogNode\", \"title\": \"title\", \"conditions\": \"conditions\"}], \"log_messages\": [{\"level\": \"info\", \"message\": \"message\"}], \"branch_exited\": true, \"branch_exited_reason\": \"completed\"}, \"user_defined\": {\"mapKey\": \"anyValue\"}, \"spelling\": {\"text\": \"text\", \"original_text\": \"originalText\", \"suggested_text\": \"suggestedText\"}}, \"context\": {\"global\": {\"system\": {\"timezone\": \"timezone\", \"user_id\": \"userId\", \"turn_count\": 9, \"locale\": \"en-us\", \"reference_time\": \"referenceTime\"}, \"session_id\": \"sessionId\"}, \"skills\": {\"mapKey\": {\"user_defined\": {\"mapKey\": \"anyValue\"}, \"system\": {\"state\": \"state\"}}}}}, \"assistant_id\": \"assistantId\", \"session_id\": \"sessionId\", \"skill_id\": \"skillId\", \"snapshot\": \"snapshot\", \"request_timestamp\": \"requestTimestamp\", \"response_timestamp\": \"responseTimestamp\", \"language\": \"language\", \"customer_id\": \"customerId\"}], \"pagination\": {\"next_url\": \"nextUrl\", \"matched\": 7, \"next_cursor\": \"nextCursor\"}}"; + String listLogsPath = "/v2/assistants/testString/logs"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the ListLogsOptions model + ListLogsOptions listLogsOptionsModel = + new ListLogsOptions.Builder() + .assistantId("testString") + .sort("testString") + .filter("testString") + .pageLimit(Long.valueOf("26")) + .cursor("testString") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = assistantService.listLogs(listLogsOptionsModel).execute(); + assertNotNull(response); + LogCollection responseObj = response.getResult(); + assertNotNull(responseObj); - MessageOptions messageOptions = - new MessageOptions.Builder().assistantId(ASSISTANT_ID).sessionId(SESSION_ID).build(); - MessageResponse response = service.message(messageOptions).execute().getResult(); + // Verify the contents of the request RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(query.get("sort"), "testString"); + assertEquals(query.get("filter"), "testString"); + assertEquals(Long.valueOf(query.get("page_limit")), Long.valueOf("26")); + assertEquals(query.get("cursor"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listLogsPath); + } - assertEquals(MESSAGE_PATH, request.getPath()); - assertNotNull(response.getContext()); - assertNotNull(response.getOutput()); - - assertEquals(DialogNodeAction.Type.CLIENT, response.getOutput().getActions().get(0).getType()); - assertEquals(NAME, response.getOutput().getActions().get(0).getName()); - assertEquals(MAP, response.getOutput().getActions().get(0).getParameters()); - assertEquals(RESULT_VARIABLE, response.getOutput().getActions().get(0).getResultVariable()); - assertEquals(CREDENTIALS, response.getOutput().getActions().get(0).getCredentials()); - assertEquals( - MessageOutputDebug.BranchExitedReason.COMPLETED, - response.getOutput().getDebug().getBranchExitedReason()); - assertEquals( - DialogLogMessage.Level.INFO, - response.getOutput().getDebug().getLogMessages().get(0).getLevel()); - assertEquals(MESSAGE, response.getOutput().getDebug().getLogMessages().get(0).getMessage()); - assertEquals( - CONDITIONS, response.getOutput().getDebug().getNodesVisited().get(0).getConditions()); - assertEquals(TITLE, response.getOutput().getDebug().getNodesVisited().get(0).getTitle()); - assertEquals( - DIALOG_NODE, response.getOutput().getDebug().getNodesVisited().get(0).getDialogNode()); - assertTrue(response.getOutput().getDebug().isBranchExited()); - assertEquals(DESCRIPTION, response.getOutput().getGeneric().get(0).description()); - assertEquals( - RuntimeResponseGeneric.ResponseType.TEXT, - response.getOutput().getGeneric().get(0).responseType()); - assertEquals( - RuntimeResponseGeneric.Preference.BUTTON, - response.getOutput().getGeneric().get(0).preference()); - assertEquals(TEXT, response.getOutput().getGeneric().get(0).text()); - assertEquals(TIME, response.getOutput().getGeneric().get(0).time()); - assertTrue(response.getOutput().getGeneric().get(0).typing()); - assertEquals(SOURCE, response.getOutput().getGeneric().get(0).source()); - assertEquals(TITLE, response.getOutput().getGeneric().get(0).title()); - assertEquals(MESSAGE, response.getOutput().getGeneric().get(0).messageToHumanAgent()); - assertEquals(TOPIC, response.getOutput().getGeneric().get(0).topic()); - assertEquals(LABEL, response.getOutput().getGeneric().get(0).options().get(0).getLabel()); - assertNotNull(response.getOutput().getGeneric().get(0).options().get(0).getValue().getInput()); - assertEquals(LABEL, response.getOutput().getGeneric().get(0).suggestions().get(0).getLabel()); - assertNotNull(response.getOutput().getGeneric().get(0).suggestions().get(0).getValue()); + // Test the listLogs operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListLogsNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + assistantService.listLogs(null).execute(); } - /** - * Test create session. - * - * @throws InterruptedException the interrupted exception - */ @Test - public void testCreateSession() throws InterruptedException { - server.enqueue(jsonResponse(sessionResponse)); + public void testDeleteUserDataWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String deleteUserDataPath = "/v2/user_data"; - CreateSessionOptions createSessionOptions = - new CreateSessionOptions.Builder().assistantId(ASSISTANT_ID).build(); - SessionResponse response = service.createSession(createSessionOptions).execute().getResult(); - RecordedRequest request = server.takeRequest(); + server.enqueue(new MockResponse().setResponseCode(202).setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the DeleteUserDataOptions model + DeleteUserDataOptions deleteUserDataOptionsModel = + new DeleteUserDataOptions.Builder().customerId("testString").build(); + // Invoke operation with valid options model (positive test) + Response response = assistantService.deleteUserData(deleteUserDataOptionsModel).execute(); assertNotNull(response); - assertEquals(CREATE_SESSION_PATH, request.getPath()); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); - assertEquals(SESSION_ID, response.getSessionId()); + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(query.get("customer_id"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteUserDataPath); } - /** - * Test delete session. - * - * @throws InterruptedException the interrupted exception - */ - @Test - public void testDeleteSession() throws InterruptedException { + // Test the deleteUserData operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteUserDataNoOptions() throws Throwable { + // construct the service + constructClientService(); + server.enqueue(new MockResponse()); - DeleteSessionOptions deleteSessionOptions = - new DeleteSessionOptions.Builder().assistantId(ASSISTANT_ID).sessionId(SESSION_ID).build(); - service.deleteSession(deleteSessionOptions).execute().getResult(); + // Invoke operation with null options model (negative test) + assistantService.deleteUserData(null).execute(); + } + + @Test + public void testBulkClassifyWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"output\": [{\"input\": {\"text\": \"text\"}, \"entities\": [{\"entity\": \"entity\", \"location\": [8], \"value\": \"value\", \"confidence\": 10, \"metadata\": {\"mapKey\": \"anyValue\"}, \"groups\": [{\"group\": \"group\", \"location\": [8]}], \"interpretation\": {\"calendar_type\": \"calendarType\", \"datetime_link\": \"datetimeLink\", \"festival\": \"festival\", \"granularity\": \"day\", \"range_link\": \"rangeLink\", \"range_modifier\": \"rangeModifier\", \"relative_day\": 11, \"relative_month\": 13, \"relative_week\": 12, \"relative_weekend\": 15, \"relative_year\": 12, \"specific_day\": 11, \"specific_day_of_week\": \"specificDayOfWeek\", \"specific_month\": 13, \"specific_quarter\": 15, \"specific_year\": 12, \"numeric_value\": 12, \"subtype\": \"subtype\", \"part_of_day\": \"partOfDay\", \"relative_hour\": 12, \"relative_minute\": 14, \"relative_second\": 14, \"specific_hour\": 12, \"specific_minute\": 14, \"specific_second\": 14, \"timezone\": \"timezone\"}, \"alternatives\": [{\"value\": \"value\", \"confidence\": 10}], \"role\": {\"type\": \"date_from\"}}], \"intents\": [{\"intent\": \"intent\", \"confidence\": 10}]}]}"; + String bulkClassifyPath = "/v2/skills/testString/workspace/bulk_classify"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the BulkClassifyUtterance model + BulkClassifyUtterance bulkClassifyUtteranceModel = + new BulkClassifyUtterance.Builder().text("testString").build(); + + // Construct an instance of the BulkClassifyOptions model + BulkClassifyOptions bulkClassifyOptionsModel = + new BulkClassifyOptions.Builder() + .skillId("testString") + .input( + new java.util.ArrayList( + java.util.Arrays.asList(bulkClassifyUtteranceModel))) + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + assistantService.bulkClassify(bulkClassifyOptionsModel).execute(); + assertNotNull(response); + BulkClassifyResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, bulkClassifyPath); + } + + // Test the bulkClassify operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testBulkClassifyNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + assistantService.bulkClassify(null).execute(); + } + + /** Initialize the server */ + @BeforeMethod + public void setUpMockServer() { + try { + server = new MockWebServer(); + // register handler + server.start(); + } catch (IOException err) { + fail("Failed to instantiate mock web server"); + } + } - assertEquals(DELETE_SESSION_PATH, request.getPath()); + @AfterMethod + public void tearDownMockServer() throws IOException { + server.shutdown(); + assistantService = null; } } diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/BulkClassifyOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/BulkClassifyOptionsTest.java new file mode 100644 index 00000000000..556bcfc38fa --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/BulkClassifyOptionsTest.java @@ -0,0 +1,55 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the BulkClassifyOptions model. */ +public class BulkClassifyOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testBulkClassifyOptions() throws Throwable { + BulkClassifyUtterance bulkClassifyUtteranceModel = + new BulkClassifyUtterance.Builder().text("testString").build(); + assertEquals(bulkClassifyUtteranceModel.text(), "testString"); + + BulkClassifyOptions bulkClassifyOptionsModel = + new BulkClassifyOptions.Builder() + .skillId("testString") + .input( + new java.util.ArrayList( + java.util.Arrays.asList(bulkClassifyUtteranceModel))) + .build(); + assertEquals(bulkClassifyOptionsModel.skillId(), "testString"); + assertEquals( + bulkClassifyOptionsModel.input(), + new java.util.ArrayList( + java.util.Arrays.asList(bulkClassifyUtteranceModel))); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testBulkClassifyOptionsError() throws Throwable { + new BulkClassifyOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/BulkClassifyOutputTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/BulkClassifyOutputTest.java new file mode 100644 index 00000000000..5e605fa42ca --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/BulkClassifyOutputTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the BulkClassifyOutput model. */ +public class BulkClassifyOutputTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testBulkClassifyOutput() throws Throwable { + BulkClassifyOutput bulkClassifyOutputModel = new BulkClassifyOutput(); + assertNull(bulkClassifyOutputModel.getInput()); + assertNull(bulkClassifyOutputModel.getEntities()); + assertNull(bulkClassifyOutputModel.getIntents()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/BulkClassifyResponseTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/BulkClassifyResponseTest.java new file mode 100644 index 00000000000..61f003e3a7f --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/BulkClassifyResponseTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the BulkClassifyResponse model. */ +public class BulkClassifyResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testBulkClassifyResponse() throws Throwable { + BulkClassifyResponse bulkClassifyResponseModel = new BulkClassifyResponse(); + assertNull(bulkClassifyResponseModel.getOutput()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/BulkClassifyUtteranceTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/BulkClassifyUtteranceTest.java new file mode 100644 index 00000000000..ae772dafdd0 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/BulkClassifyUtteranceTest.java @@ -0,0 +1,49 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the BulkClassifyUtterance model. */ +public class BulkClassifyUtteranceTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testBulkClassifyUtterance() throws Throwable { + BulkClassifyUtterance bulkClassifyUtteranceModel = + new BulkClassifyUtterance.Builder().text("testString").build(); + assertEquals(bulkClassifyUtteranceModel.text(), "testString"); + + String json = TestUtilities.serialize(bulkClassifyUtteranceModel); + + BulkClassifyUtterance bulkClassifyUtteranceModelNew = + TestUtilities.deserialize(json, BulkClassifyUtterance.class); + assertTrue(bulkClassifyUtteranceModelNew instanceof BulkClassifyUtterance); + assertEquals(bulkClassifyUtteranceModelNew.text(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testBulkClassifyUtteranceError() throws Throwable { + new BulkClassifyUtterance.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/CaptureGroupTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/CaptureGroupTest.java new file mode 100644 index 00000000000..823ba8566b1 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/CaptureGroupTest.java @@ -0,0 +1,54 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CaptureGroup model. */ +public class CaptureGroupTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCaptureGroup() throws Throwable { + CaptureGroup captureGroupModel = + new CaptureGroup.Builder() + .group("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) + .build(); + assertEquals(captureGroupModel.group(), "testString"); + assertEquals( + captureGroupModel.location(), + new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))); + + String json = TestUtilities.serialize(captureGroupModel); + + CaptureGroup captureGroupModelNew = TestUtilities.deserialize(json, CaptureGroup.class); + assertTrue(captureGroupModelNew instanceof CaptureGroup); + assertEquals(captureGroupModelNew.group(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCaptureGroupError() throws Throwable { + new CaptureGroup.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/CreateSessionOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/CreateSessionOptionsTest.java new file mode 100644 index 00000000000..5d206b5c54a --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/CreateSessionOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateSessionOptions model. */ +public class CreateSessionOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateSessionOptions() throws Throwable { + CreateSessionOptions createSessionOptionsModel = + new CreateSessionOptions.Builder().assistantId("testString").build(); + assertEquals(createSessionOptionsModel.assistantId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateSessionOptionsError() throws Throwable { + new CreateSessionOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DeleteSessionOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DeleteSessionOptionsTest.java new file mode 100644 index 00000000000..9673ca3bf6a --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DeleteSessionOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteSessionOptions model. */ +public class DeleteSessionOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteSessionOptions() throws Throwable { + DeleteSessionOptions deleteSessionOptionsModel = + new DeleteSessionOptions.Builder() + .assistantId("testString") + .sessionId("testString") + .build(); + assertEquals(deleteSessionOptionsModel.assistantId(), "testString"); + assertEquals(deleteSessionOptionsModel.sessionId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteSessionOptionsError() throws Throwable { + new DeleteSessionOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DeleteUserDataOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DeleteUserDataOptionsTest.java new file mode 100644 index 00000000000..69dd32f109a --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DeleteUserDataOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteUserDataOptions model. */ +public class DeleteUserDataOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteUserDataOptions() throws Throwable { + DeleteUserDataOptions deleteUserDataOptionsModel = + new DeleteUserDataOptions.Builder().customerId("testString").build(); + assertEquals(deleteUserDataOptionsModel.customerId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteUserDataOptionsError() throws Throwable { + new DeleteUserDataOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DialogLogMessageTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DialogLogMessageTest.java new file mode 100644 index 00000000000..446684ed333 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DialogLogMessageTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DialogLogMessage model. */ +public class DialogLogMessageTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogLogMessage() throws Throwable { + DialogLogMessage dialogLogMessageModel = new DialogLogMessage(); + assertNull(dialogLogMessageModel.getLevel()); + assertNull(dialogLogMessageModel.getMessage()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DialogNodeActionTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DialogNodeActionTest.java new file mode 100644 index 00000000000..4b996c1f137 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DialogNodeActionTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DialogNodeAction model. */ +public class DialogNodeActionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogNodeAction() throws Throwable { + DialogNodeAction dialogNodeActionModel = new DialogNodeAction(); + assertNull(dialogNodeActionModel.getName()); + assertNull(dialogNodeActionModel.getType()); + assertNull(dialogNodeActionModel.getParameters()); + assertNull(dialogNodeActionModel.getResultVariable()); + assertNull(dialogNodeActionModel.getCredentials()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DialogNodeOutputConnectToAgentTransferInfoTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DialogNodeOutputConnectToAgentTransferInfoTest.java new file mode 100644 index 00000000000..7ee6eeb6dd0 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DialogNodeOutputConnectToAgentTransferInfoTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DialogNodeOutputConnectToAgentTransferInfo model. */ +public class DialogNodeOutputConnectToAgentTransferInfoTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogNodeOutputConnectToAgentTransferInfo() throws Throwable { + DialogNodeOutputConnectToAgentTransferInfo dialogNodeOutputConnectToAgentTransferInfoModel = + new DialogNodeOutputConnectToAgentTransferInfo(); + assertNull(dialogNodeOutputConnectToAgentTransferInfoModel.getTarget()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DialogNodeOutputOptionsElementTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DialogNodeOutputOptionsElementTest.java new file mode 100644 index 00000000000..9e12a1fd1a0 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DialogNodeOutputOptionsElementTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DialogNodeOutputOptionsElement model. */ +public class DialogNodeOutputOptionsElementTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogNodeOutputOptionsElement() throws Throwable { + DialogNodeOutputOptionsElement dialogNodeOutputOptionsElementModel = + new DialogNodeOutputOptionsElement(); + assertNull(dialogNodeOutputOptionsElementModel.getLabel()); + assertNull(dialogNodeOutputOptionsElementModel.getValue()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DialogNodeOutputOptionsElementValueTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DialogNodeOutputOptionsElementValueTest.java new file mode 100644 index 00000000000..e494832edf0 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DialogNodeOutputOptionsElementValueTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DialogNodeOutputOptionsElementValue model. */ +public class DialogNodeOutputOptionsElementValueTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogNodeOutputOptionsElementValue() throws Throwable { + DialogNodeOutputOptionsElementValue dialogNodeOutputOptionsElementValueModel = + new DialogNodeOutputOptionsElementValue(); + assertNull(dialogNodeOutputOptionsElementValueModel.getInput()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DialogNodesVisitedTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DialogNodesVisitedTest.java new file mode 100644 index 00000000000..e2ba07156e9 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DialogNodesVisitedTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DialogNodesVisited model. */ +public class DialogNodesVisitedTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogNodesVisited() throws Throwable { + DialogNodesVisited dialogNodesVisitedModel = new DialogNodesVisited(); + assertNull(dialogNodesVisitedModel.getDialogNode()); + assertNull(dialogNodesVisitedModel.getTitle()); + assertNull(dialogNodesVisitedModel.getConditions()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DialogSuggestionTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DialogSuggestionTest.java new file mode 100644 index 00000000000..cefeb960a49 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DialogSuggestionTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DialogSuggestion model. */ +public class DialogSuggestionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogSuggestion() throws Throwable { + DialogSuggestion dialogSuggestionModel = new DialogSuggestion(); + assertNull(dialogSuggestionModel.getLabel()); + assertNull(dialogSuggestionModel.getValue()); + assertNull(dialogSuggestionModel.getOutput()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DialogSuggestionValueTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DialogSuggestionValueTest.java new file mode 100644 index 00000000000..5b864405be6 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/DialogSuggestionValueTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DialogSuggestionValue model. */ +public class DialogSuggestionValueTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDialogSuggestionValue() throws Throwable { + DialogSuggestionValue dialogSuggestionValueModel = new DialogSuggestionValue(); + assertNull(dialogSuggestionValueModel.getInput()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ListLogsOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ListLogsOptionsTest.java new file mode 100644 index 00000000000..44fe49938f5 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/ListLogsOptionsTest.java @@ -0,0 +1,52 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListLogsOptions model. */ +public class ListLogsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListLogsOptions() throws Throwable { + ListLogsOptions listLogsOptionsModel = + new ListLogsOptions.Builder() + .assistantId("testString") + .sort("testString") + .filter("testString") + .pageLimit(Long.valueOf("26")) + .cursor("testString") + .build(); + assertEquals(listLogsOptionsModel.assistantId(), "testString"); + assertEquals(listLogsOptionsModel.sort(), "testString"); + assertEquals(listLogsOptionsModel.filter(), "testString"); + assertEquals(listLogsOptionsModel.pageLimit(), Long.valueOf("26")); + assertEquals(listLogsOptionsModel.cursor(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListLogsOptionsError() throws Throwable { + new ListLogsOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/LogCollectionTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/LogCollectionTest.java new file mode 100644 index 00000000000..9356c9fb5bd --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/LogCollectionTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the LogCollection model. */ +public class LogCollectionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testLogCollection() throws Throwable { + LogCollection logCollectionModel = new LogCollection(); + assertNull(logCollectionModel.getLogs()); + assertNull(logCollectionModel.getPagination()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/LogPaginationTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/LogPaginationTest.java new file mode 100644 index 00000000000..778ae5b7140 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/LogPaginationTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the LogPagination model. */ +public class LogPaginationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testLogPagination() throws Throwable { + LogPagination logPaginationModel = new LogPagination(); + assertNull(logPaginationModel.getNextUrl()); + assertNull(logPaginationModel.getMatched()); + assertNull(logPaginationModel.getNextCursor()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/LogTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/LogTest.java new file mode 100644 index 00000000000..1ab09f45063 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/LogTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Log model. */ +public class LogTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testLog() throws Throwable { + Log logModel = new Log(); + assertNull(logModel.getLogId()); + assertNull(logModel.getRequest()); + assertNull(logModel.getResponse()); + assertNull(logModel.getAssistantId()); + assertNull(logModel.getSessionId()); + assertNull(logModel.getSkillId()); + assertNull(logModel.getSnapshot()); + assertNull(logModel.getRequestTimestamp()); + assertNull(logModel.getResponseTimestamp()); + assertNull(logModel.getLanguage()); + assertNull(logModel.getCustomerId()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextGlobalStatelessTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextGlobalStatelessTest.java new file mode 100644 index 00000000000..c6d653f6a08 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextGlobalStatelessTest.java @@ -0,0 +1,65 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageContextGlobalStateless model. */ +public class MessageContextGlobalStatelessTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageContextGlobalStateless() throws Throwable { + MessageContextGlobalSystem messageContextGlobalSystemModel = + new MessageContextGlobalSystem.Builder() + .timezone("testString") + .userId("testString") + .turnCount(Long.valueOf("26")) + .locale("en-us") + .referenceTime("testString") + .build(); + assertEquals(messageContextGlobalSystemModel.timezone(), "testString"); + assertEquals(messageContextGlobalSystemModel.userId(), "testString"); + assertEquals(messageContextGlobalSystemModel.turnCount(), Long.valueOf("26")); + assertEquals(messageContextGlobalSystemModel.locale(), "en-us"); + assertEquals(messageContextGlobalSystemModel.referenceTime(), "testString"); + + MessageContextGlobalStateless messageContextGlobalStatelessModel = + new MessageContextGlobalStateless.Builder() + .system(messageContextGlobalSystemModel) + .sessionId("testString") + .build(); + assertEquals(messageContextGlobalStatelessModel.system(), messageContextGlobalSystemModel); + assertEquals(messageContextGlobalStatelessModel.sessionId(), "testString"); + + String json = TestUtilities.serialize(messageContextGlobalStatelessModel); + + MessageContextGlobalStateless messageContextGlobalStatelessModelNew = + TestUtilities.deserialize(json, MessageContextGlobalStateless.class); + assertTrue(messageContextGlobalStatelessModelNew instanceof MessageContextGlobalStateless); + assertEquals( + messageContextGlobalStatelessModelNew.system().toString(), + messageContextGlobalSystemModel.toString()); + assertEquals(messageContextGlobalStatelessModelNew.sessionId(), "testString"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextGlobalSystemTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextGlobalSystemTest.java new file mode 100644 index 00000000000..2594098c732 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextGlobalSystemTest.java @@ -0,0 +1,58 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageContextGlobalSystem model. */ +public class MessageContextGlobalSystemTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageContextGlobalSystem() throws Throwable { + MessageContextGlobalSystem messageContextGlobalSystemModel = + new MessageContextGlobalSystem.Builder() + .timezone("testString") + .userId("testString") + .turnCount(Long.valueOf("26")) + .locale("en-us") + .referenceTime("testString") + .build(); + assertEquals(messageContextGlobalSystemModel.timezone(), "testString"); + assertEquals(messageContextGlobalSystemModel.userId(), "testString"); + assertEquals(messageContextGlobalSystemModel.turnCount(), Long.valueOf("26")); + assertEquals(messageContextGlobalSystemModel.locale(), "en-us"); + assertEquals(messageContextGlobalSystemModel.referenceTime(), "testString"); + + String json = TestUtilities.serialize(messageContextGlobalSystemModel); + + MessageContextGlobalSystem messageContextGlobalSystemModelNew = + TestUtilities.deserialize(json, MessageContextGlobalSystem.class); + assertTrue(messageContextGlobalSystemModelNew instanceof MessageContextGlobalSystem); + assertEquals(messageContextGlobalSystemModelNew.timezone(), "testString"); + assertEquals(messageContextGlobalSystemModelNew.userId(), "testString"); + assertEquals(messageContextGlobalSystemModelNew.turnCount(), Long.valueOf("26")); + assertEquals(messageContextGlobalSystemModelNew.locale(), "en-us"); + assertEquals(messageContextGlobalSystemModelNew.referenceTime(), "testString"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextGlobalTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextGlobalTest.java new file mode 100644 index 00000000000..8636053792b --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextGlobalTest.java @@ -0,0 +1,60 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageContextGlobal model. */ +public class MessageContextGlobalTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageContextGlobal() throws Throwable { + MessageContextGlobalSystem messageContextGlobalSystemModel = + new MessageContextGlobalSystem.Builder() + .timezone("testString") + .userId("testString") + .turnCount(Long.valueOf("26")) + .locale("en-us") + .referenceTime("testString") + .build(); + assertEquals(messageContextGlobalSystemModel.timezone(), "testString"); + assertEquals(messageContextGlobalSystemModel.userId(), "testString"); + assertEquals(messageContextGlobalSystemModel.turnCount(), Long.valueOf("26")); + assertEquals(messageContextGlobalSystemModel.locale(), "en-us"); + assertEquals(messageContextGlobalSystemModel.referenceTime(), "testString"); + + MessageContextGlobal messageContextGlobalModel = + new MessageContextGlobal.Builder().system(messageContextGlobalSystemModel).build(); + assertEquals(messageContextGlobalModel.system(), messageContextGlobalSystemModel); + + String json = TestUtilities.serialize(messageContextGlobalModel); + + MessageContextGlobal messageContextGlobalModelNew = + TestUtilities.deserialize(json, MessageContextGlobal.class); + assertTrue(messageContextGlobalModelNew instanceof MessageContextGlobal); + assertEquals( + messageContextGlobalModelNew.system().toString(), + messageContextGlobalSystemModel.toString()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextSkillSystemTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextSkillSystemTest.java new file mode 100644 index 00000000000..af74ff19450 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextSkillSystemTest.java @@ -0,0 +1,49 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageContextSkillSystem model. */ +public class MessageContextSkillSystemTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageContextSkillSystem() throws Throwable { + MessageContextSkillSystem messageContextSkillSystemModel = + new MessageContextSkillSystem.Builder() + .state("testString") + .add("foo", "testString") + .build(); + assertEquals(messageContextSkillSystemModel.getState(), "testString"); + assertEquals(messageContextSkillSystemModel.get("foo"), "testString"); + + String json = TestUtilities.serialize(messageContextSkillSystemModel); + + MessageContextSkillSystem messageContextSkillSystemModelNew = + TestUtilities.deserialize(json, MessageContextSkillSystem.class); + assertTrue(messageContextSkillSystemModelNew instanceof MessageContextSkillSystem); + assertEquals(messageContextSkillSystemModelNew.getState(), "testString"); + assertEquals(messageContextSkillSystemModelNew.get("foo"), "testString"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextSkillTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextSkillTest.java new file mode 100644 index 00000000000..f857b06fa89 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextSkillTest.java @@ -0,0 +1,68 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageContextSkill model. */ +public class MessageContextSkillTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageContextSkill() throws Throwable { + MessageContextSkillSystem messageContextSkillSystemModel = + new MessageContextSkillSystem.Builder() + .state("testString") + .add("foo", "testString") + .build(); + assertEquals(messageContextSkillSystemModel.getState(), "testString"); + assertEquals(messageContextSkillSystemModel.get("foo"), "testString"); + + MessageContextSkill messageContextSkillModel = + new MessageContextSkill.Builder() + .userDefined( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .system(messageContextSkillSystemModel) + .build(); + assertEquals( + messageContextSkillModel.userDefined(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals(messageContextSkillModel.system(), messageContextSkillSystemModel); + + String json = TestUtilities.serialize(messageContextSkillModel); + + MessageContextSkill messageContextSkillModelNew = + TestUtilities.deserialize(json, MessageContextSkill.class); + assertTrue(messageContextSkillModelNew instanceof MessageContextSkill); + assertEquals( + messageContextSkillModelNew.system().toString(), messageContextSkillSystemModel.toString()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextStatelessTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextStatelessTest.java new file mode 100644 index 00000000000..625d14de78b --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextStatelessTest.java @@ -0,0 +1,110 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageContextStateless model. */ +public class MessageContextStatelessTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageContextStateless() throws Throwable { + MessageContextGlobalSystem messageContextGlobalSystemModel = + new MessageContextGlobalSystem.Builder() + .timezone("testString") + .userId("testString") + .turnCount(Long.valueOf("26")) + .locale("en-us") + .referenceTime("testString") + .build(); + assertEquals(messageContextGlobalSystemModel.timezone(), "testString"); + assertEquals(messageContextGlobalSystemModel.userId(), "testString"); + assertEquals(messageContextGlobalSystemModel.turnCount(), Long.valueOf("26")); + assertEquals(messageContextGlobalSystemModel.locale(), "en-us"); + assertEquals(messageContextGlobalSystemModel.referenceTime(), "testString"); + + MessageContextGlobalStateless messageContextGlobalStatelessModel = + new MessageContextGlobalStateless.Builder() + .system(messageContextGlobalSystemModel) + .sessionId("testString") + .build(); + assertEquals(messageContextGlobalStatelessModel.system(), messageContextGlobalSystemModel); + assertEquals(messageContextGlobalStatelessModel.sessionId(), "testString"); + + MessageContextSkillSystem messageContextSkillSystemModel = + new MessageContextSkillSystem.Builder() + .state("testString") + .add("foo", "testString") + .build(); + assertEquals(messageContextSkillSystemModel.getState(), "testString"); + assertEquals(messageContextSkillSystemModel.get("foo"), "testString"); + + MessageContextSkill messageContextSkillModel = + new MessageContextSkill.Builder() + .userDefined( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .system(messageContextSkillSystemModel) + .build(); + assertEquals( + messageContextSkillModel.userDefined(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals(messageContextSkillModel.system(), messageContextSkillSystemModel); + + MessageContextStateless messageContextStatelessModel = + new MessageContextStateless.Builder() + .global(messageContextGlobalStatelessModel) + .skills( + new java.util.HashMap() { + { + put("foo", messageContextSkillModel); + } + }) + .build(); + assertEquals(messageContextStatelessModel.global(), messageContextGlobalStatelessModel); + assertEquals( + messageContextStatelessModel.skills(), + new java.util.HashMap() { + { + put("foo", messageContextSkillModel); + } + }); + + String json = TestUtilities.serialize(messageContextStatelessModel); + + MessageContextStateless messageContextStatelessModelNew = + TestUtilities.deserialize(json, MessageContextStateless.class); + assertTrue(messageContextStatelessModelNew instanceof MessageContextStateless); + assertEquals( + messageContextStatelessModelNew.global().toString(), + messageContextGlobalStatelessModel.toString()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextTest.java new file mode 100644 index 00000000000..8bce37c31d6 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageContextTest.java @@ -0,0 +1,103 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageContext model. */ +public class MessageContextTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageContext() throws Throwable { + MessageContextGlobalSystem messageContextGlobalSystemModel = + new MessageContextGlobalSystem.Builder() + .timezone("testString") + .userId("testString") + .turnCount(Long.valueOf("26")) + .locale("en-us") + .referenceTime("testString") + .build(); + assertEquals(messageContextGlobalSystemModel.timezone(), "testString"); + assertEquals(messageContextGlobalSystemModel.userId(), "testString"); + assertEquals(messageContextGlobalSystemModel.turnCount(), Long.valueOf("26")); + assertEquals(messageContextGlobalSystemModel.locale(), "en-us"); + assertEquals(messageContextGlobalSystemModel.referenceTime(), "testString"); + + MessageContextGlobal messageContextGlobalModel = + new MessageContextGlobal.Builder().system(messageContextGlobalSystemModel).build(); + assertEquals(messageContextGlobalModel.system(), messageContextGlobalSystemModel); + + MessageContextSkillSystem messageContextSkillSystemModel = + new MessageContextSkillSystem.Builder() + .state("testString") + .add("foo", "testString") + .build(); + assertEquals(messageContextSkillSystemModel.getState(), "testString"); + assertEquals(messageContextSkillSystemModel.get("foo"), "testString"); + + MessageContextSkill messageContextSkillModel = + new MessageContextSkill.Builder() + .userDefined( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .system(messageContextSkillSystemModel) + .build(); + assertEquals( + messageContextSkillModel.userDefined(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals(messageContextSkillModel.system(), messageContextSkillSystemModel); + + MessageContext messageContextModel = + new MessageContext.Builder() + .global(messageContextGlobalModel) + .skills( + new java.util.HashMap() { + { + put("foo", messageContextSkillModel); + } + }) + .build(); + assertEquals(messageContextModel.global(), messageContextGlobalModel); + assertEquals( + messageContextModel.skills(), + new java.util.HashMap() { + { + put("foo", messageContextSkillModel); + } + }); + + String json = TestUtilities.serialize(messageContextModel); + + MessageContext messageContextModelNew = TestUtilities.deserialize(json, MessageContext.class); + assertTrue(messageContextModelNew instanceof MessageContext); + assertEquals(messageContextModelNew.global().toString(), messageContextGlobalModel.toString()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageInputOptionsSpellingTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageInputOptionsSpellingTest.java new file mode 100644 index 00000000000..6f7f345a862 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageInputOptionsSpellingTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageInputOptionsSpelling model. */ +public class MessageInputOptionsSpellingTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageInputOptionsSpelling() throws Throwable { + MessageInputOptionsSpelling messageInputOptionsSpellingModel = + new MessageInputOptionsSpelling.Builder().suggestions(true).autoCorrect(true).build(); + assertEquals(messageInputOptionsSpellingModel.suggestions(), Boolean.valueOf(true)); + assertEquals(messageInputOptionsSpellingModel.autoCorrect(), Boolean.valueOf(true)); + + String json = TestUtilities.serialize(messageInputOptionsSpellingModel); + + MessageInputOptionsSpelling messageInputOptionsSpellingModelNew = + TestUtilities.deserialize(json, MessageInputOptionsSpelling.class); + assertTrue(messageInputOptionsSpellingModelNew instanceof MessageInputOptionsSpelling); + assertEquals(messageInputOptionsSpellingModelNew.suggestions(), Boolean.valueOf(true)); + assertEquals(messageInputOptionsSpellingModelNew.autoCorrect(), Boolean.valueOf(true)); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageInputOptionsStatelessTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageInputOptionsStatelessTest.java new file mode 100644 index 00000000000..323a57b3b7a --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageInputOptionsStatelessTest.java @@ -0,0 +1,62 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageInputOptionsStateless model. */ +public class MessageInputOptionsStatelessTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageInputOptionsStateless() throws Throwable { + MessageInputOptionsSpelling messageInputOptionsSpellingModel = + new MessageInputOptionsSpelling.Builder().suggestions(true).autoCorrect(true).build(); + assertEquals(messageInputOptionsSpellingModel.suggestions(), Boolean.valueOf(true)); + assertEquals(messageInputOptionsSpellingModel.autoCorrect(), Boolean.valueOf(true)); + + MessageInputOptionsStateless messageInputOptionsStatelessModel = + new MessageInputOptionsStateless.Builder() + .restart(true) + .alternateIntents(true) + .spelling(messageInputOptionsSpellingModel) + .debug(true) + .build(); + assertEquals(messageInputOptionsStatelessModel.restart(), Boolean.valueOf(true)); + assertEquals(messageInputOptionsStatelessModel.alternateIntents(), Boolean.valueOf(true)); + assertEquals(messageInputOptionsStatelessModel.spelling(), messageInputOptionsSpellingModel); + assertEquals(messageInputOptionsStatelessModel.debug(), Boolean.valueOf(true)); + + String json = TestUtilities.serialize(messageInputOptionsStatelessModel); + + MessageInputOptionsStateless messageInputOptionsStatelessModelNew = + TestUtilities.deserialize(json, MessageInputOptionsStateless.class); + assertTrue(messageInputOptionsStatelessModelNew instanceof MessageInputOptionsStateless); + assertEquals(messageInputOptionsStatelessModelNew.restart(), Boolean.valueOf(true)); + assertEquals(messageInputOptionsStatelessModelNew.alternateIntents(), Boolean.valueOf(true)); + assertEquals( + messageInputOptionsStatelessModelNew.spelling().toString(), + messageInputOptionsSpellingModel.toString()); + assertEquals(messageInputOptionsStatelessModelNew.debug(), Boolean.valueOf(true)); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageInputOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageInputOptionsTest.java new file mode 100644 index 00000000000..ad4d9967a6c --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageInputOptionsTest.java @@ -0,0 +1,68 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageInputOptions model. */ +public class MessageInputOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageInputOptions() throws Throwable { + MessageInputOptionsSpelling messageInputOptionsSpellingModel = + new MessageInputOptionsSpelling.Builder().suggestions(true).autoCorrect(true).build(); + assertEquals(messageInputOptionsSpellingModel.suggestions(), Boolean.valueOf(true)); + assertEquals(messageInputOptionsSpellingModel.autoCorrect(), Boolean.valueOf(true)); + + MessageInputOptions messageInputOptionsModel = + new MessageInputOptions.Builder() + .restart(true) + .alternateIntents(true) + .spelling(messageInputOptionsSpellingModel) + .debug(true) + .returnContext(true) + .export(true) + .build(); + assertEquals(messageInputOptionsModel.restart(), Boolean.valueOf(true)); + assertEquals(messageInputOptionsModel.alternateIntents(), Boolean.valueOf(true)); + assertEquals(messageInputOptionsModel.spelling(), messageInputOptionsSpellingModel); + assertEquals(messageInputOptionsModel.debug(), Boolean.valueOf(true)); + assertEquals(messageInputOptionsModel.returnContext(), Boolean.valueOf(true)); + assertEquals(messageInputOptionsModel.export(), Boolean.valueOf(true)); + + String json = TestUtilities.serialize(messageInputOptionsModel); + + MessageInputOptions messageInputOptionsModelNew = + TestUtilities.deserialize(json, MessageInputOptions.class); + assertTrue(messageInputOptionsModelNew instanceof MessageInputOptions); + assertEquals(messageInputOptionsModelNew.restart(), Boolean.valueOf(true)); + assertEquals(messageInputOptionsModelNew.alternateIntents(), Boolean.valueOf(true)); + assertEquals( + messageInputOptionsModelNew.spelling().toString(), + messageInputOptionsSpellingModel.toString()); + assertEquals(messageInputOptionsModelNew.debug(), Boolean.valueOf(true)); + assertEquals(messageInputOptionsModelNew.returnContext(), Boolean.valueOf(true)); + assertEquals(messageInputOptionsModelNew.export(), Boolean.valueOf(true)); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageInputStatelessTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageInputStatelessTest.java new file mode 100644 index 00000000000..85ebb693026 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageInputStatelessTest.java @@ -0,0 +1,210 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageInputStateless model. */ +public class MessageInputStatelessTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageInputStateless() throws Throwable { + RuntimeIntent runtimeIntentModel = + new RuntimeIntent.Builder().intent("testString").confidence(Double.valueOf("72.5")).build(); + assertEquals(runtimeIntentModel.intent(), "testString"); + assertEquals(runtimeIntentModel.confidence(), Double.valueOf("72.5")); + + CaptureGroup captureGroupModel = + new CaptureGroup.Builder() + .group("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) + .build(); + assertEquals(captureGroupModel.group(), "testString"); + assertEquals( + captureGroupModel.location(), + new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))); + + RuntimeEntityInterpretation runtimeEntityInterpretationModel = + new RuntimeEntityInterpretation.Builder() + .calendarType("testString") + .datetimeLink("testString") + .festival("testString") + .granularity("day") + .rangeLink("testString") + .rangeModifier("testString") + .relativeDay(Double.valueOf("72.5")) + .relativeMonth(Double.valueOf("72.5")) + .relativeWeek(Double.valueOf("72.5")) + .relativeWeekend(Double.valueOf("72.5")) + .relativeYear(Double.valueOf("72.5")) + .specificDay(Double.valueOf("72.5")) + .specificDayOfWeek("testString") + .specificMonth(Double.valueOf("72.5")) + .specificQuarter(Double.valueOf("72.5")) + .specificYear(Double.valueOf("72.5")) + .numericValue(Double.valueOf("72.5")) + .subtype("testString") + .partOfDay("testString") + .relativeHour(Double.valueOf("72.5")) + .relativeMinute(Double.valueOf("72.5")) + .relativeSecond(Double.valueOf("72.5")) + .specificHour(Double.valueOf("72.5")) + .specificMinute(Double.valueOf("72.5")) + .specificSecond(Double.valueOf("72.5")) + .timezone("testString") + .build(); + assertEquals(runtimeEntityInterpretationModel.calendarType(), "testString"); + assertEquals(runtimeEntityInterpretationModel.datetimeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.festival(), "testString"); + assertEquals(runtimeEntityInterpretationModel.granularity(), "day"); + assertEquals(runtimeEntityInterpretationModel.rangeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.rangeModifier(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeek(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeekend(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDayOfWeek(), "testString"); + assertEquals(runtimeEntityInterpretationModel.specificMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificQuarter(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.numericValue(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.subtype(), "testString"); + assertEquals(runtimeEntityInterpretationModel.partOfDay(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.timezone(), "testString"); + + RuntimeEntityAlternative runtimeEntityAlternativeModel = + new RuntimeEntityAlternative.Builder() + .value("testString") + .confidence(Double.valueOf("72.5")) + .build(); + assertEquals(runtimeEntityAlternativeModel.value(), "testString"); + assertEquals(runtimeEntityAlternativeModel.confidence(), Double.valueOf("72.5")); + + RuntimeEntityRole runtimeEntityRoleModel = + new RuntimeEntityRole.Builder().type("date_from").build(); + assertEquals(runtimeEntityRoleModel.type(), "date_from"); + + RuntimeEntity runtimeEntityModel = + new RuntimeEntity.Builder() + .entity("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) + .value("testString") + .confidence(Double.valueOf("72.5")) + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .groups( + new java.util.ArrayList(java.util.Arrays.asList(captureGroupModel))) + .interpretation(runtimeEntityInterpretationModel) + .alternatives( + new java.util.ArrayList( + java.util.Arrays.asList(runtimeEntityAlternativeModel))) + .role(runtimeEntityRoleModel) + .build(); + assertEquals(runtimeEntityModel.entity(), "testString"); + assertEquals( + runtimeEntityModel.location(), + new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))); + assertEquals(runtimeEntityModel.value(), "testString"); + assertEquals(runtimeEntityModel.confidence(), Double.valueOf("72.5")); + assertEquals( + runtimeEntityModel.metadata(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals( + runtimeEntityModel.groups(), + new java.util.ArrayList(java.util.Arrays.asList(captureGroupModel))); + assertEquals(runtimeEntityModel.interpretation(), runtimeEntityInterpretationModel); + assertEquals( + runtimeEntityModel.alternatives(), + new java.util.ArrayList( + java.util.Arrays.asList(runtimeEntityAlternativeModel))); + assertEquals(runtimeEntityModel.role(), runtimeEntityRoleModel); + + MessageInputOptionsSpelling messageInputOptionsSpellingModel = + new MessageInputOptionsSpelling.Builder().suggestions(true).autoCorrect(true).build(); + assertEquals(messageInputOptionsSpellingModel.suggestions(), Boolean.valueOf(true)); + assertEquals(messageInputOptionsSpellingModel.autoCorrect(), Boolean.valueOf(true)); + + MessageInputOptionsStateless messageInputOptionsStatelessModel = + new MessageInputOptionsStateless.Builder() + .restart(true) + .alternateIntents(true) + .spelling(messageInputOptionsSpellingModel) + .debug(true) + .build(); + assertEquals(messageInputOptionsStatelessModel.restart(), Boolean.valueOf(true)); + assertEquals(messageInputOptionsStatelessModel.alternateIntents(), Boolean.valueOf(true)); + assertEquals(messageInputOptionsStatelessModel.spelling(), messageInputOptionsSpellingModel); + assertEquals(messageInputOptionsStatelessModel.debug(), Boolean.valueOf(true)); + + MessageInputStateless messageInputStatelessModel = + new MessageInputStateless.Builder() + .messageType("text") + .text("testString") + .intents( + new java.util.ArrayList(java.util.Arrays.asList(runtimeIntentModel))) + .entities( + new java.util.ArrayList(java.util.Arrays.asList(runtimeEntityModel))) + .suggestionId("testString") + .options(messageInputOptionsStatelessModel) + .build(); + assertEquals(messageInputStatelessModel.messageType(), "text"); + assertEquals(messageInputStatelessModel.text(), "testString"); + assertEquals( + messageInputStatelessModel.intents(), + new java.util.ArrayList(java.util.Arrays.asList(runtimeIntentModel))); + assertEquals( + messageInputStatelessModel.entities(), + new java.util.ArrayList(java.util.Arrays.asList(runtimeEntityModel))); + assertEquals(messageInputStatelessModel.suggestionId(), "testString"); + assertEquals(messageInputStatelessModel.options(), messageInputOptionsStatelessModel); + + String json = TestUtilities.serialize(messageInputStatelessModel); + + MessageInputStateless messageInputStatelessModelNew = + TestUtilities.deserialize(json, MessageInputStateless.class); + assertTrue(messageInputStatelessModelNew instanceof MessageInputStateless); + assertEquals(messageInputStatelessModelNew.messageType(), "text"); + assertEquals(messageInputStatelessModelNew.text(), "testString"); + assertEquals(messageInputStatelessModelNew.suggestionId(), "testString"); + assertEquals( + messageInputStatelessModelNew.options().toString(), + messageInputOptionsStatelessModel.toString()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageInputTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageInputTest.java new file mode 100644 index 00000000000..06e4d497bc0 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageInputTest.java @@ -0,0 +1,211 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageInput model. */ +public class MessageInputTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageInput() throws Throwable { + RuntimeIntent runtimeIntentModel = + new RuntimeIntent.Builder().intent("testString").confidence(Double.valueOf("72.5")).build(); + assertEquals(runtimeIntentModel.intent(), "testString"); + assertEquals(runtimeIntentModel.confidence(), Double.valueOf("72.5")); + + CaptureGroup captureGroupModel = + new CaptureGroup.Builder() + .group("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) + .build(); + assertEquals(captureGroupModel.group(), "testString"); + assertEquals( + captureGroupModel.location(), + new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))); + + RuntimeEntityInterpretation runtimeEntityInterpretationModel = + new RuntimeEntityInterpretation.Builder() + .calendarType("testString") + .datetimeLink("testString") + .festival("testString") + .granularity("day") + .rangeLink("testString") + .rangeModifier("testString") + .relativeDay(Double.valueOf("72.5")) + .relativeMonth(Double.valueOf("72.5")) + .relativeWeek(Double.valueOf("72.5")) + .relativeWeekend(Double.valueOf("72.5")) + .relativeYear(Double.valueOf("72.5")) + .specificDay(Double.valueOf("72.5")) + .specificDayOfWeek("testString") + .specificMonth(Double.valueOf("72.5")) + .specificQuarter(Double.valueOf("72.5")) + .specificYear(Double.valueOf("72.5")) + .numericValue(Double.valueOf("72.5")) + .subtype("testString") + .partOfDay("testString") + .relativeHour(Double.valueOf("72.5")) + .relativeMinute(Double.valueOf("72.5")) + .relativeSecond(Double.valueOf("72.5")) + .specificHour(Double.valueOf("72.5")) + .specificMinute(Double.valueOf("72.5")) + .specificSecond(Double.valueOf("72.5")) + .timezone("testString") + .build(); + assertEquals(runtimeEntityInterpretationModel.calendarType(), "testString"); + assertEquals(runtimeEntityInterpretationModel.datetimeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.festival(), "testString"); + assertEquals(runtimeEntityInterpretationModel.granularity(), "day"); + assertEquals(runtimeEntityInterpretationModel.rangeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.rangeModifier(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeek(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeekend(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDayOfWeek(), "testString"); + assertEquals(runtimeEntityInterpretationModel.specificMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificQuarter(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.numericValue(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.subtype(), "testString"); + assertEquals(runtimeEntityInterpretationModel.partOfDay(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.timezone(), "testString"); + + RuntimeEntityAlternative runtimeEntityAlternativeModel = + new RuntimeEntityAlternative.Builder() + .value("testString") + .confidence(Double.valueOf("72.5")) + .build(); + assertEquals(runtimeEntityAlternativeModel.value(), "testString"); + assertEquals(runtimeEntityAlternativeModel.confidence(), Double.valueOf("72.5")); + + RuntimeEntityRole runtimeEntityRoleModel = + new RuntimeEntityRole.Builder().type("date_from").build(); + assertEquals(runtimeEntityRoleModel.type(), "date_from"); + + RuntimeEntity runtimeEntityModel = + new RuntimeEntity.Builder() + .entity("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) + .value("testString") + .confidence(Double.valueOf("72.5")) + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .groups( + new java.util.ArrayList(java.util.Arrays.asList(captureGroupModel))) + .interpretation(runtimeEntityInterpretationModel) + .alternatives( + new java.util.ArrayList( + java.util.Arrays.asList(runtimeEntityAlternativeModel))) + .role(runtimeEntityRoleModel) + .build(); + assertEquals(runtimeEntityModel.entity(), "testString"); + assertEquals( + runtimeEntityModel.location(), + new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))); + assertEquals(runtimeEntityModel.value(), "testString"); + assertEquals(runtimeEntityModel.confidence(), Double.valueOf("72.5")); + assertEquals( + runtimeEntityModel.metadata(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals( + runtimeEntityModel.groups(), + new java.util.ArrayList(java.util.Arrays.asList(captureGroupModel))); + assertEquals(runtimeEntityModel.interpretation(), runtimeEntityInterpretationModel); + assertEquals( + runtimeEntityModel.alternatives(), + new java.util.ArrayList( + java.util.Arrays.asList(runtimeEntityAlternativeModel))); + assertEquals(runtimeEntityModel.role(), runtimeEntityRoleModel); + + MessageInputOptionsSpelling messageInputOptionsSpellingModel = + new MessageInputOptionsSpelling.Builder().suggestions(true).autoCorrect(true).build(); + assertEquals(messageInputOptionsSpellingModel.suggestions(), Boolean.valueOf(true)); + assertEquals(messageInputOptionsSpellingModel.autoCorrect(), Boolean.valueOf(true)); + + MessageInputOptions messageInputOptionsModel = + new MessageInputOptions.Builder() + .restart(true) + .alternateIntents(true) + .spelling(messageInputOptionsSpellingModel) + .debug(true) + .returnContext(true) + .export(true) + .build(); + assertEquals(messageInputOptionsModel.restart(), Boolean.valueOf(true)); + assertEquals(messageInputOptionsModel.alternateIntents(), Boolean.valueOf(true)); + assertEquals(messageInputOptionsModel.spelling(), messageInputOptionsSpellingModel); + assertEquals(messageInputOptionsModel.debug(), Boolean.valueOf(true)); + assertEquals(messageInputOptionsModel.returnContext(), Boolean.valueOf(true)); + assertEquals(messageInputOptionsModel.export(), Boolean.valueOf(true)); + + MessageInput messageInputModel = + new MessageInput.Builder() + .messageType("text") + .text("testString") + .intents( + new java.util.ArrayList(java.util.Arrays.asList(runtimeIntentModel))) + .entities( + new java.util.ArrayList(java.util.Arrays.asList(runtimeEntityModel))) + .suggestionId("testString") + .options(messageInputOptionsModel) + .build(); + assertEquals(messageInputModel.messageType(), "text"); + assertEquals(messageInputModel.text(), "testString"); + assertEquals( + messageInputModel.intents(), + new java.util.ArrayList(java.util.Arrays.asList(runtimeIntentModel))); + assertEquals( + messageInputModel.entities(), + new java.util.ArrayList(java.util.Arrays.asList(runtimeEntityModel))); + assertEquals(messageInputModel.suggestionId(), "testString"); + assertEquals(messageInputModel.options(), messageInputOptionsModel); + + String json = TestUtilities.serialize(messageInputModel); + + MessageInput messageInputModelNew = TestUtilities.deserialize(json, MessageInput.class); + assertTrue(messageInputModelNew instanceof MessageInput); + assertEquals(messageInputModelNew.messageType(), "text"); + assertEquals(messageInputModelNew.text(), "testString"); + assertEquals(messageInputModelNew.suggestionId(), "testString"); + assertEquals(messageInputModelNew.options().toString(), messageInputOptionsModel.toString()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOptionsTest.java new file mode 100644 index 00000000000..3039fd0f27b --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOptionsTest.java @@ -0,0 +1,283 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageOptions model. */ +public class MessageOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageOptions() throws Throwable { + RuntimeIntent runtimeIntentModel = + new RuntimeIntent.Builder().intent("testString").confidence(Double.valueOf("72.5")).build(); + assertEquals(runtimeIntentModel.intent(), "testString"); + assertEquals(runtimeIntentModel.confidence(), Double.valueOf("72.5")); + + CaptureGroup captureGroupModel = + new CaptureGroup.Builder() + .group("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) + .build(); + assertEquals(captureGroupModel.group(), "testString"); + assertEquals( + captureGroupModel.location(), + new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))); + + RuntimeEntityInterpretation runtimeEntityInterpretationModel = + new RuntimeEntityInterpretation.Builder() + .calendarType("testString") + .datetimeLink("testString") + .festival("testString") + .granularity("day") + .rangeLink("testString") + .rangeModifier("testString") + .relativeDay(Double.valueOf("72.5")) + .relativeMonth(Double.valueOf("72.5")) + .relativeWeek(Double.valueOf("72.5")) + .relativeWeekend(Double.valueOf("72.5")) + .relativeYear(Double.valueOf("72.5")) + .specificDay(Double.valueOf("72.5")) + .specificDayOfWeek("testString") + .specificMonth(Double.valueOf("72.5")) + .specificQuarter(Double.valueOf("72.5")) + .specificYear(Double.valueOf("72.5")) + .numericValue(Double.valueOf("72.5")) + .subtype("testString") + .partOfDay("testString") + .relativeHour(Double.valueOf("72.5")) + .relativeMinute(Double.valueOf("72.5")) + .relativeSecond(Double.valueOf("72.5")) + .specificHour(Double.valueOf("72.5")) + .specificMinute(Double.valueOf("72.5")) + .specificSecond(Double.valueOf("72.5")) + .timezone("testString") + .build(); + assertEquals(runtimeEntityInterpretationModel.calendarType(), "testString"); + assertEquals(runtimeEntityInterpretationModel.datetimeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.festival(), "testString"); + assertEquals(runtimeEntityInterpretationModel.granularity(), "day"); + assertEquals(runtimeEntityInterpretationModel.rangeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.rangeModifier(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeek(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeekend(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDayOfWeek(), "testString"); + assertEquals(runtimeEntityInterpretationModel.specificMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificQuarter(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.numericValue(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.subtype(), "testString"); + assertEquals(runtimeEntityInterpretationModel.partOfDay(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.timezone(), "testString"); + + RuntimeEntityAlternative runtimeEntityAlternativeModel = + new RuntimeEntityAlternative.Builder() + .value("testString") + .confidence(Double.valueOf("72.5")) + .build(); + assertEquals(runtimeEntityAlternativeModel.value(), "testString"); + assertEquals(runtimeEntityAlternativeModel.confidence(), Double.valueOf("72.5")); + + RuntimeEntityRole runtimeEntityRoleModel = + new RuntimeEntityRole.Builder().type("date_from").build(); + assertEquals(runtimeEntityRoleModel.type(), "date_from"); + + RuntimeEntity runtimeEntityModel = + new RuntimeEntity.Builder() + .entity("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) + .value("testString") + .confidence(Double.valueOf("72.5")) + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .groups( + new java.util.ArrayList(java.util.Arrays.asList(captureGroupModel))) + .interpretation(runtimeEntityInterpretationModel) + .alternatives( + new java.util.ArrayList( + java.util.Arrays.asList(runtimeEntityAlternativeModel))) + .role(runtimeEntityRoleModel) + .build(); + assertEquals(runtimeEntityModel.entity(), "testString"); + assertEquals( + runtimeEntityModel.location(), + new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))); + assertEquals(runtimeEntityModel.value(), "testString"); + assertEquals(runtimeEntityModel.confidence(), Double.valueOf("72.5")); + assertEquals( + runtimeEntityModel.metadata(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals( + runtimeEntityModel.groups(), + new java.util.ArrayList(java.util.Arrays.asList(captureGroupModel))); + assertEquals(runtimeEntityModel.interpretation(), runtimeEntityInterpretationModel); + assertEquals( + runtimeEntityModel.alternatives(), + new java.util.ArrayList( + java.util.Arrays.asList(runtimeEntityAlternativeModel))); + assertEquals(runtimeEntityModel.role(), runtimeEntityRoleModel); + + MessageInputOptionsSpelling messageInputOptionsSpellingModel = + new MessageInputOptionsSpelling.Builder().suggestions(true).autoCorrect(true).build(); + assertEquals(messageInputOptionsSpellingModel.suggestions(), Boolean.valueOf(true)); + assertEquals(messageInputOptionsSpellingModel.autoCorrect(), Boolean.valueOf(true)); + + MessageInputOptions messageInputOptionsModel = + new MessageInputOptions.Builder() + .restart(true) + .alternateIntents(true) + .spelling(messageInputOptionsSpellingModel) + .debug(true) + .returnContext(true) + .export(true) + .build(); + assertEquals(messageInputOptionsModel.restart(), Boolean.valueOf(true)); + assertEquals(messageInputOptionsModel.alternateIntents(), Boolean.valueOf(true)); + assertEquals(messageInputOptionsModel.spelling(), messageInputOptionsSpellingModel); + assertEquals(messageInputOptionsModel.debug(), Boolean.valueOf(true)); + assertEquals(messageInputOptionsModel.returnContext(), Boolean.valueOf(true)); + assertEquals(messageInputOptionsModel.export(), Boolean.valueOf(true)); + + MessageInput messageInputModel = + new MessageInput.Builder() + .messageType("text") + .text("testString") + .intents( + new java.util.ArrayList(java.util.Arrays.asList(runtimeIntentModel))) + .entities( + new java.util.ArrayList(java.util.Arrays.asList(runtimeEntityModel))) + .suggestionId("testString") + .options(messageInputOptionsModel) + .build(); + assertEquals(messageInputModel.messageType(), "text"); + assertEquals(messageInputModel.text(), "testString"); + assertEquals( + messageInputModel.intents(), + new java.util.ArrayList(java.util.Arrays.asList(runtimeIntentModel))); + assertEquals( + messageInputModel.entities(), + new java.util.ArrayList(java.util.Arrays.asList(runtimeEntityModel))); + assertEquals(messageInputModel.suggestionId(), "testString"); + assertEquals(messageInputModel.options(), messageInputOptionsModel); + + MessageContextGlobalSystem messageContextGlobalSystemModel = + new MessageContextGlobalSystem.Builder() + .timezone("testString") + .userId("testString") + .turnCount(Long.valueOf("26")) + .locale("en-us") + .referenceTime("testString") + .build(); + assertEquals(messageContextGlobalSystemModel.timezone(), "testString"); + assertEquals(messageContextGlobalSystemModel.userId(), "testString"); + assertEquals(messageContextGlobalSystemModel.turnCount(), Long.valueOf("26")); + assertEquals(messageContextGlobalSystemModel.locale(), "en-us"); + assertEquals(messageContextGlobalSystemModel.referenceTime(), "testString"); + + MessageContextGlobal messageContextGlobalModel = + new MessageContextGlobal.Builder().system(messageContextGlobalSystemModel).build(); + assertEquals(messageContextGlobalModel.system(), messageContextGlobalSystemModel); + + MessageContextSkillSystem messageContextSkillSystemModel = + new MessageContextSkillSystem.Builder() + .state("testString") + .add("foo", "testString") + .build(); + assertEquals(messageContextSkillSystemModel.getState(), "testString"); + assertEquals(messageContextSkillSystemModel.get("foo"), "testString"); + + MessageContextSkill messageContextSkillModel = + new MessageContextSkill.Builder() + .userDefined( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .system(messageContextSkillSystemModel) + .build(); + assertEquals( + messageContextSkillModel.userDefined(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals(messageContextSkillModel.system(), messageContextSkillSystemModel); + + MessageContext messageContextModel = + new MessageContext.Builder() + .global(messageContextGlobalModel) + .skills( + new java.util.HashMap() { + { + put("foo", messageContextSkillModel); + } + }) + .build(); + assertEquals(messageContextModel.global(), messageContextGlobalModel); + assertEquals( + messageContextModel.skills(), + new java.util.HashMap() { + { + put("foo", messageContextSkillModel); + } + }); + + MessageOptions messageOptionsModel = + new MessageOptions.Builder() + .assistantId("testString") + .sessionId("testString") + .input(messageInputModel) + .context(messageContextModel) + .build(); + assertEquals(messageOptionsModel.assistantId(), "testString"); + assertEquals(messageOptionsModel.sessionId(), "testString"); + assertEquals(messageOptionsModel.input(), messageInputModel); + assertEquals(messageOptionsModel.context(), messageContextModel); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testMessageOptionsError() throws Throwable { + new MessageOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTest.java new file mode 100644 index 00000000000..972e57c5a5b --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputDebugTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageOutputDebug model. */ +public class MessageOutputDebugTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageOutputDebug() throws Throwable { + MessageOutputDebug messageOutputDebugModel = new MessageOutputDebug(); + assertNull(messageOutputDebugModel.getNodesVisited()); + assertNull(messageOutputDebugModel.getLogMessages()); + assertNull(messageOutputDebugModel.isBranchExited()); + assertNull(messageOutputDebugModel.getBranchExitedReason()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputSpellingTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputSpellingTest.java new file mode 100644 index 00000000000..d8eee4cafa7 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputSpellingTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageOutputSpelling model. */ +public class MessageOutputSpellingTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageOutputSpelling() throws Throwable { + MessageOutputSpelling messageOutputSpellingModel = new MessageOutputSpelling(); + assertNull(messageOutputSpellingModel.getText()); + assertNull(messageOutputSpellingModel.getOriginalText()); + assertNull(messageOutputSpellingModel.getSuggestedText()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputTest.java new file mode 100644 index 00000000000..e04ac620884 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageOutputTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageOutput model. */ +public class MessageOutputTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageOutput() throws Throwable { + MessageOutput messageOutputModel = new MessageOutput(); + assertNull(messageOutputModel.getGeneric()); + assertNull(messageOutputModel.getIntents()); + assertNull(messageOutputModel.getEntities()); + assertNull(messageOutputModel.getActions()); + assertNull(messageOutputModel.getDebug()); + assertNull(messageOutputModel.getUserDefined()); + assertNull(messageOutputModel.getSpelling()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageRequestTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageRequestTest.java new file mode 100644 index 00000000000..e2919f1d8a3 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageRequestTest.java @@ -0,0 +1,278 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageRequest model. */ +public class MessageRequestTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageRequest() throws Throwable { + RuntimeIntent runtimeIntentModel = + new RuntimeIntent.Builder().intent("testString").confidence(Double.valueOf("72.5")).build(); + assertEquals(runtimeIntentModel.intent(), "testString"); + assertEquals(runtimeIntentModel.confidence(), Double.valueOf("72.5")); + + CaptureGroup captureGroupModel = + new CaptureGroup.Builder() + .group("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) + .build(); + assertEquals(captureGroupModel.group(), "testString"); + assertEquals( + captureGroupModel.location(), + new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))); + + RuntimeEntityInterpretation runtimeEntityInterpretationModel = + new RuntimeEntityInterpretation.Builder() + .calendarType("testString") + .datetimeLink("testString") + .festival("testString") + .granularity("day") + .rangeLink("testString") + .rangeModifier("testString") + .relativeDay(Double.valueOf("72.5")) + .relativeMonth(Double.valueOf("72.5")) + .relativeWeek(Double.valueOf("72.5")) + .relativeWeekend(Double.valueOf("72.5")) + .relativeYear(Double.valueOf("72.5")) + .specificDay(Double.valueOf("72.5")) + .specificDayOfWeek("testString") + .specificMonth(Double.valueOf("72.5")) + .specificQuarter(Double.valueOf("72.5")) + .specificYear(Double.valueOf("72.5")) + .numericValue(Double.valueOf("72.5")) + .subtype("testString") + .partOfDay("testString") + .relativeHour(Double.valueOf("72.5")) + .relativeMinute(Double.valueOf("72.5")) + .relativeSecond(Double.valueOf("72.5")) + .specificHour(Double.valueOf("72.5")) + .specificMinute(Double.valueOf("72.5")) + .specificSecond(Double.valueOf("72.5")) + .timezone("testString") + .build(); + assertEquals(runtimeEntityInterpretationModel.calendarType(), "testString"); + assertEquals(runtimeEntityInterpretationModel.datetimeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.festival(), "testString"); + assertEquals(runtimeEntityInterpretationModel.granularity(), "day"); + assertEquals(runtimeEntityInterpretationModel.rangeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.rangeModifier(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeek(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeekend(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDayOfWeek(), "testString"); + assertEquals(runtimeEntityInterpretationModel.specificMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificQuarter(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.numericValue(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.subtype(), "testString"); + assertEquals(runtimeEntityInterpretationModel.partOfDay(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.timezone(), "testString"); + + RuntimeEntityAlternative runtimeEntityAlternativeModel = + new RuntimeEntityAlternative.Builder() + .value("testString") + .confidence(Double.valueOf("72.5")) + .build(); + assertEquals(runtimeEntityAlternativeModel.value(), "testString"); + assertEquals(runtimeEntityAlternativeModel.confidence(), Double.valueOf("72.5")); + + RuntimeEntityRole runtimeEntityRoleModel = + new RuntimeEntityRole.Builder().type("date_from").build(); + assertEquals(runtimeEntityRoleModel.type(), "date_from"); + + RuntimeEntity runtimeEntityModel = + new RuntimeEntity.Builder() + .entity("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) + .value("testString") + .confidence(Double.valueOf("72.5")) + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .groups( + new java.util.ArrayList(java.util.Arrays.asList(captureGroupModel))) + .interpretation(runtimeEntityInterpretationModel) + .alternatives( + new java.util.ArrayList( + java.util.Arrays.asList(runtimeEntityAlternativeModel))) + .role(runtimeEntityRoleModel) + .build(); + assertEquals(runtimeEntityModel.entity(), "testString"); + assertEquals( + runtimeEntityModel.location(), + new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))); + assertEquals(runtimeEntityModel.value(), "testString"); + assertEquals(runtimeEntityModel.confidence(), Double.valueOf("72.5")); + assertEquals( + runtimeEntityModel.metadata(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals( + runtimeEntityModel.groups(), + new java.util.ArrayList(java.util.Arrays.asList(captureGroupModel))); + assertEquals(runtimeEntityModel.interpretation(), runtimeEntityInterpretationModel); + assertEquals( + runtimeEntityModel.alternatives(), + new java.util.ArrayList( + java.util.Arrays.asList(runtimeEntityAlternativeModel))); + assertEquals(runtimeEntityModel.role(), runtimeEntityRoleModel); + + MessageInputOptionsSpelling messageInputOptionsSpellingModel = + new MessageInputOptionsSpelling.Builder().suggestions(true).autoCorrect(true).build(); + assertEquals(messageInputOptionsSpellingModel.suggestions(), Boolean.valueOf(true)); + assertEquals(messageInputOptionsSpellingModel.autoCorrect(), Boolean.valueOf(true)); + + MessageInputOptions messageInputOptionsModel = + new MessageInputOptions.Builder() + .restart(true) + .alternateIntents(true) + .spelling(messageInputOptionsSpellingModel) + .debug(true) + .returnContext(true) + .export(true) + .build(); + assertEquals(messageInputOptionsModel.restart(), Boolean.valueOf(true)); + assertEquals(messageInputOptionsModel.alternateIntents(), Boolean.valueOf(true)); + assertEquals(messageInputOptionsModel.spelling(), messageInputOptionsSpellingModel); + assertEquals(messageInputOptionsModel.debug(), Boolean.valueOf(true)); + assertEquals(messageInputOptionsModel.returnContext(), Boolean.valueOf(true)); + assertEquals(messageInputOptionsModel.export(), Boolean.valueOf(true)); + + MessageInput messageInputModel = + new MessageInput.Builder() + .messageType("text") + .text("Hello") + .intents( + new java.util.ArrayList(java.util.Arrays.asList(runtimeIntentModel))) + .entities( + new java.util.ArrayList(java.util.Arrays.asList(runtimeEntityModel))) + .suggestionId("testString") + .options(messageInputOptionsModel) + .build(); + assertEquals(messageInputModel.messageType(), "text"); + assertEquals(messageInputModel.text(), "Hello"); + assertEquals( + messageInputModel.intents(), + new java.util.ArrayList(java.util.Arrays.asList(runtimeIntentModel))); + assertEquals( + messageInputModel.entities(), + new java.util.ArrayList(java.util.Arrays.asList(runtimeEntityModel))); + assertEquals(messageInputModel.suggestionId(), "testString"); + assertEquals(messageInputModel.options(), messageInputOptionsModel); + + MessageContextGlobalSystem messageContextGlobalSystemModel = + new MessageContextGlobalSystem.Builder() + .timezone("testString") + .userId("my_user_id") + .turnCount(Long.valueOf("26")) + .locale("en-us") + .referenceTime("testString") + .build(); + assertEquals(messageContextGlobalSystemModel.timezone(), "testString"); + assertEquals(messageContextGlobalSystemModel.userId(), "my_user_id"); + assertEquals(messageContextGlobalSystemModel.turnCount(), Long.valueOf("26")); + assertEquals(messageContextGlobalSystemModel.locale(), "en-us"); + assertEquals(messageContextGlobalSystemModel.referenceTime(), "testString"); + + MessageContextGlobal messageContextGlobalModel = + new MessageContextGlobal.Builder().system(messageContextGlobalSystemModel).build(); + assertEquals(messageContextGlobalModel.system(), messageContextGlobalSystemModel); + + MessageContextSkillSystem messageContextSkillSystemModel = + new MessageContextSkillSystem.Builder() + .state("testString") + .add("foo", "testString") + .build(); + assertEquals(messageContextSkillSystemModel.getState(), "testString"); + assertEquals(messageContextSkillSystemModel.get("foo"), "testString"); + + MessageContextSkill messageContextSkillModel = + new MessageContextSkill.Builder() + .userDefined( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .system(messageContextSkillSystemModel) + .build(); + assertEquals( + messageContextSkillModel.userDefined(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals(messageContextSkillModel.system(), messageContextSkillSystemModel); + + MessageContext messageContextModel = + new MessageContext.Builder() + .global(messageContextGlobalModel) + .skills( + new java.util.HashMap() { + { + put("foo", messageContextSkillModel); + } + }) + .build(); + assertEquals(messageContextModel.global(), messageContextGlobalModel); + assertEquals( + messageContextModel.skills(), + new java.util.HashMap() { + { + put("foo", messageContextSkillModel); + } + }); + + MessageRequest messageRequestModel = + new MessageRequest.Builder().input(messageInputModel).context(messageContextModel).build(); + assertEquals(messageRequestModel.input(), messageInputModel); + assertEquals(messageRequestModel.context(), messageContextModel); + + String json = TestUtilities.serialize(messageRequestModel); + + MessageRequest messageRequestModelNew = TestUtilities.deserialize(json, MessageRequest.class); + assertTrue(messageRequestModelNew instanceof MessageRequest); + assertEquals(messageRequestModelNew.input().toString(), messageInputModel.toString()); + assertEquals(messageRequestModelNew.context().toString(), messageContextModel.toString()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageResponseStatelessTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageResponseStatelessTest.java new file mode 100644 index 00000000000..7dec022f7aa --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageResponseStatelessTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageResponseStateless model. */ +public class MessageResponseStatelessTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageResponseStateless() throws Throwable { + MessageResponseStateless messageResponseStatelessModel = new MessageResponseStateless(); + assertNull(messageResponseStatelessModel.getOutput()); + assertNull(messageResponseStatelessModel.getContext()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageResponseTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageResponseTest.java new file mode 100644 index 00000000000..f3246624a14 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageResponseTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageResponse model. */ +public class MessageResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageResponse() throws Throwable { + MessageResponse messageResponseModel = new MessageResponse(); + assertNull(messageResponseModel.getOutput()); + assertNull(messageResponseModel.getContext()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageStatelessOptionsTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageStatelessOptionsTest.java new file mode 100644 index 00000000000..7a04624de0d --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/MessageStatelessOptionsTest.java @@ -0,0 +1,281 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MessageStatelessOptions model. */ +public class MessageStatelessOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMessageStatelessOptions() throws Throwable { + RuntimeIntent runtimeIntentModel = + new RuntimeIntent.Builder().intent("testString").confidence(Double.valueOf("72.5")).build(); + assertEquals(runtimeIntentModel.intent(), "testString"); + assertEquals(runtimeIntentModel.confidence(), Double.valueOf("72.5")); + + CaptureGroup captureGroupModel = + new CaptureGroup.Builder() + .group("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) + .build(); + assertEquals(captureGroupModel.group(), "testString"); + assertEquals( + captureGroupModel.location(), + new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))); + + RuntimeEntityInterpretation runtimeEntityInterpretationModel = + new RuntimeEntityInterpretation.Builder() + .calendarType("testString") + .datetimeLink("testString") + .festival("testString") + .granularity("day") + .rangeLink("testString") + .rangeModifier("testString") + .relativeDay(Double.valueOf("72.5")) + .relativeMonth(Double.valueOf("72.5")) + .relativeWeek(Double.valueOf("72.5")) + .relativeWeekend(Double.valueOf("72.5")) + .relativeYear(Double.valueOf("72.5")) + .specificDay(Double.valueOf("72.5")) + .specificDayOfWeek("testString") + .specificMonth(Double.valueOf("72.5")) + .specificQuarter(Double.valueOf("72.5")) + .specificYear(Double.valueOf("72.5")) + .numericValue(Double.valueOf("72.5")) + .subtype("testString") + .partOfDay("testString") + .relativeHour(Double.valueOf("72.5")) + .relativeMinute(Double.valueOf("72.5")) + .relativeSecond(Double.valueOf("72.5")) + .specificHour(Double.valueOf("72.5")) + .specificMinute(Double.valueOf("72.5")) + .specificSecond(Double.valueOf("72.5")) + .timezone("testString") + .build(); + assertEquals(runtimeEntityInterpretationModel.calendarType(), "testString"); + assertEquals(runtimeEntityInterpretationModel.datetimeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.festival(), "testString"); + assertEquals(runtimeEntityInterpretationModel.granularity(), "day"); + assertEquals(runtimeEntityInterpretationModel.rangeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.rangeModifier(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeek(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeekend(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDayOfWeek(), "testString"); + assertEquals(runtimeEntityInterpretationModel.specificMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificQuarter(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.numericValue(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.subtype(), "testString"); + assertEquals(runtimeEntityInterpretationModel.partOfDay(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.timezone(), "testString"); + + RuntimeEntityAlternative runtimeEntityAlternativeModel = + new RuntimeEntityAlternative.Builder() + .value("testString") + .confidence(Double.valueOf("72.5")) + .build(); + assertEquals(runtimeEntityAlternativeModel.value(), "testString"); + assertEquals(runtimeEntityAlternativeModel.confidence(), Double.valueOf("72.5")); + + RuntimeEntityRole runtimeEntityRoleModel = + new RuntimeEntityRole.Builder().type("date_from").build(); + assertEquals(runtimeEntityRoleModel.type(), "date_from"); + + RuntimeEntity runtimeEntityModel = + new RuntimeEntity.Builder() + .entity("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) + .value("testString") + .confidence(Double.valueOf("72.5")) + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .groups( + new java.util.ArrayList(java.util.Arrays.asList(captureGroupModel))) + .interpretation(runtimeEntityInterpretationModel) + .alternatives( + new java.util.ArrayList( + java.util.Arrays.asList(runtimeEntityAlternativeModel))) + .role(runtimeEntityRoleModel) + .build(); + assertEquals(runtimeEntityModel.entity(), "testString"); + assertEquals( + runtimeEntityModel.location(), + new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))); + assertEquals(runtimeEntityModel.value(), "testString"); + assertEquals(runtimeEntityModel.confidence(), Double.valueOf("72.5")); + assertEquals( + runtimeEntityModel.metadata(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals( + runtimeEntityModel.groups(), + new java.util.ArrayList(java.util.Arrays.asList(captureGroupModel))); + assertEquals(runtimeEntityModel.interpretation(), runtimeEntityInterpretationModel); + assertEquals( + runtimeEntityModel.alternatives(), + new java.util.ArrayList( + java.util.Arrays.asList(runtimeEntityAlternativeModel))); + assertEquals(runtimeEntityModel.role(), runtimeEntityRoleModel); + + MessageInputOptionsSpelling messageInputOptionsSpellingModel = + new MessageInputOptionsSpelling.Builder().suggestions(true).autoCorrect(true).build(); + assertEquals(messageInputOptionsSpellingModel.suggestions(), Boolean.valueOf(true)); + assertEquals(messageInputOptionsSpellingModel.autoCorrect(), Boolean.valueOf(true)); + + MessageInputOptionsStateless messageInputOptionsStatelessModel = + new MessageInputOptionsStateless.Builder() + .restart(true) + .alternateIntents(true) + .spelling(messageInputOptionsSpellingModel) + .debug(true) + .build(); + assertEquals(messageInputOptionsStatelessModel.restart(), Boolean.valueOf(true)); + assertEquals(messageInputOptionsStatelessModel.alternateIntents(), Boolean.valueOf(true)); + assertEquals(messageInputOptionsStatelessModel.spelling(), messageInputOptionsSpellingModel); + assertEquals(messageInputOptionsStatelessModel.debug(), Boolean.valueOf(true)); + + MessageInputStateless messageInputStatelessModel = + new MessageInputStateless.Builder() + .messageType("text") + .text("testString") + .intents( + new java.util.ArrayList(java.util.Arrays.asList(runtimeIntentModel))) + .entities( + new java.util.ArrayList(java.util.Arrays.asList(runtimeEntityModel))) + .suggestionId("testString") + .options(messageInputOptionsStatelessModel) + .build(); + assertEquals(messageInputStatelessModel.messageType(), "text"); + assertEquals(messageInputStatelessModel.text(), "testString"); + assertEquals( + messageInputStatelessModel.intents(), + new java.util.ArrayList(java.util.Arrays.asList(runtimeIntentModel))); + assertEquals( + messageInputStatelessModel.entities(), + new java.util.ArrayList(java.util.Arrays.asList(runtimeEntityModel))); + assertEquals(messageInputStatelessModel.suggestionId(), "testString"); + assertEquals(messageInputStatelessModel.options(), messageInputOptionsStatelessModel); + + MessageContextGlobalSystem messageContextGlobalSystemModel = + new MessageContextGlobalSystem.Builder() + .timezone("testString") + .userId("testString") + .turnCount(Long.valueOf("26")) + .locale("en-us") + .referenceTime("testString") + .build(); + assertEquals(messageContextGlobalSystemModel.timezone(), "testString"); + assertEquals(messageContextGlobalSystemModel.userId(), "testString"); + assertEquals(messageContextGlobalSystemModel.turnCount(), Long.valueOf("26")); + assertEquals(messageContextGlobalSystemModel.locale(), "en-us"); + assertEquals(messageContextGlobalSystemModel.referenceTime(), "testString"); + + MessageContextGlobalStateless messageContextGlobalStatelessModel = + new MessageContextGlobalStateless.Builder() + .system(messageContextGlobalSystemModel) + .sessionId("testString") + .build(); + assertEquals(messageContextGlobalStatelessModel.system(), messageContextGlobalSystemModel); + assertEquals(messageContextGlobalStatelessModel.sessionId(), "testString"); + + MessageContextSkillSystem messageContextSkillSystemModel = + new MessageContextSkillSystem.Builder() + .state("testString") + .add("foo", "testString") + .build(); + assertEquals(messageContextSkillSystemModel.getState(), "testString"); + assertEquals(messageContextSkillSystemModel.get("foo"), "testString"); + + MessageContextSkill messageContextSkillModel = + new MessageContextSkill.Builder() + .userDefined( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .system(messageContextSkillSystemModel) + .build(); + assertEquals( + messageContextSkillModel.userDefined(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals(messageContextSkillModel.system(), messageContextSkillSystemModel); + + MessageContextStateless messageContextStatelessModel = + new MessageContextStateless.Builder() + .global(messageContextGlobalStatelessModel) + .skills( + new java.util.HashMap() { + { + put("foo", messageContextSkillModel); + } + }) + .build(); + assertEquals(messageContextStatelessModel.global(), messageContextGlobalStatelessModel); + assertEquals( + messageContextStatelessModel.skills(), + new java.util.HashMap() { + { + put("foo", messageContextSkillModel); + } + }); + + MessageStatelessOptions messageStatelessOptionsModel = + new MessageStatelessOptions.Builder() + .assistantId("testString") + .input(messageInputStatelessModel) + .context(messageContextStatelessModel) + .build(); + assertEquals(messageStatelessOptionsModel.assistantId(), "testString"); + assertEquals(messageStatelessOptionsModel.input(), messageInputStatelessModel); + assertEquals(messageStatelessOptionsModel.context(), messageContextStatelessModel); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testMessageStatelessOptionsError() throws Throwable { + new MessageStatelessOptions.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeEntityAlternativeTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeEntityAlternativeTest.java new file mode 100644 index 00000000000..ac0fad47a3c --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeEntityAlternativeTest.java @@ -0,0 +1,49 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeEntityAlternative model. */ +public class RuntimeEntityAlternativeTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeEntityAlternative() throws Throwable { + RuntimeEntityAlternative runtimeEntityAlternativeModel = + new RuntimeEntityAlternative.Builder() + .value("testString") + .confidence(Double.valueOf("72.5")) + .build(); + assertEquals(runtimeEntityAlternativeModel.value(), "testString"); + assertEquals(runtimeEntityAlternativeModel.confidence(), Double.valueOf("72.5")); + + String json = TestUtilities.serialize(runtimeEntityAlternativeModel); + + RuntimeEntityAlternative runtimeEntityAlternativeModelNew = + TestUtilities.deserialize(json, RuntimeEntityAlternative.class); + assertTrue(runtimeEntityAlternativeModelNew instanceof RuntimeEntityAlternative); + assertEquals(runtimeEntityAlternativeModelNew.value(), "testString"); + assertEquals(runtimeEntityAlternativeModelNew.confidence(), Double.valueOf("72.5")); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeEntityInterpretationTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeEntityInterpretationTest.java new file mode 100644 index 00000000000..e4e7362b086 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeEntityInterpretationTest.java @@ -0,0 +1,121 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeEntityInterpretation model. */ +public class RuntimeEntityInterpretationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeEntityInterpretation() throws Throwable { + RuntimeEntityInterpretation runtimeEntityInterpretationModel = + new RuntimeEntityInterpretation.Builder() + .calendarType("testString") + .datetimeLink("testString") + .festival("testString") + .granularity("day") + .rangeLink("testString") + .rangeModifier("testString") + .relativeDay(Double.valueOf("72.5")) + .relativeMonth(Double.valueOf("72.5")) + .relativeWeek(Double.valueOf("72.5")) + .relativeWeekend(Double.valueOf("72.5")) + .relativeYear(Double.valueOf("72.5")) + .specificDay(Double.valueOf("72.5")) + .specificDayOfWeek("testString") + .specificMonth(Double.valueOf("72.5")) + .specificQuarter(Double.valueOf("72.5")) + .specificYear(Double.valueOf("72.5")) + .numericValue(Double.valueOf("72.5")) + .subtype("testString") + .partOfDay("testString") + .relativeHour(Double.valueOf("72.5")) + .relativeMinute(Double.valueOf("72.5")) + .relativeSecond(Double.valueOf("72.5")) + .specificHour(Double.valueOf("72.5")) + .specificMinute(Double.valueOf("72.5")) + .specificSecond(Double.valueOf("72.5")) + .timezone("testString") + .build(); + assertEquals(runtimeEntityInterpretationModel.calendarType(), "testString"); + assertEquals(runtimeEntityInterpretationModel.datetimeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.festival(), "testString"); + assertEquals(runtimeEntityInterpretationModel.granularity(), "day"); + assertEquals(runtimeEntityInterpretationModel.rangeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.rangeModifier(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeek(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeekend(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDayOfWeek(), "testString"); + assertEquals(runtimeEntityInterpretationModel.specificMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificQuarter(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.numericValue(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.subtype(), "testString"); + assertEquals(runtimeEntityInterpretationModel.partOfDay(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.timezone(), "testString"); + + String json = TestUtilities.serialize(runtimeEntityInterpretationModel); + + RuntimeEntityInterpretation runtimeEntityInterpretationModelNew = + TestUtilities.deserialize(json, RuntimeEntityInterpretation.class); + assertTrue(runtimeEntityInterpretationModelNew instanceof RuntimeEntityInterpretation); + assertEquals(runtimeEntityInterpretationModelNew.calendarType(), "testString"); + assertEquals(runtimeEntityInterpretationModelNew.datetimeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModelNew.festival(), "testString"); + assertEquals(runtimeEntityInterpretationModelNew.granularity(), "day"); + assertEquals(runtimeEntityInterpretationModelNew.rangeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModelNew.rangeModifier(), "testString"); + assertEquals(runtimeEntityInterpretationModelNew.relativeDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.relativeMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.relativeWeek(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.relativeWeekend(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.relativeYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.specificDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.specificDayOfWeek(), "testString"); + assertEquals(runtimeEntityInterpretationModelNew.specificMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.specificQuarter(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.specificYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.numericValue(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.subtype(), "testString"); + assertEquals(runtimeEntityInterpretationModelNew.partOfDay(), "testString"); + assertEquals(runtimeEntityInterpretationModelNew.relativeHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.relativeMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.relativeSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.specificHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.specificMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.specificSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModelNew.timezone(), "testString"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeEntityRoleTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeEntityRoleTest.java new file mode 100644 index 00000000000..960f230804c --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeEntityRoleTest.java @@ -0,0 +1,44 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeEntityRole model. */ +public class RuntimeEntityRoleTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeEntityRole() throws Throwable { + RuntimeEntityRole runtimeEntityRoleModel = + new RuntimeEntityRole.Builder().type("date_from").build(); + assertEquals(runtimeEntityRoleModel.type(), "date_from"); + + String json = TestUtilities.serialize(runtimeEntityRoleModel); + + RuntimeEntityRole runtimeEntityRoleModelNew = + TestUtilities.deserialize(json, RuntimeEntityRole.class); + assertTrue(runtimeEntityRoleModelNew instanceof RuntimeEntityRole); + assertEquals(runtimeEntityRoleModelNew.type(), "date_from"); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeEntityTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeEntityTest.java new file mode 100644 index 00000000000..91b28d46976 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeEntityTest.java @@ -0,0 +1,171 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeEntity model. */ +public class RuntimeEntityTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeEntity() throws Throwable { + CaptureGroup captureGroupModel = + new CaptureGroup.Builder() + .group("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) + .build(); + assertEquals(captureGroupModel.group(), "testString"); + assertEquals( + captureGroupModel.location(), + new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))); + + RuntimeEntityInterpretation runtimeEntityInterpretationModel = + new RuntimeEntityInterpretation.Builder() + .calendarType("testString") + .datetimeLink("testString") + .festival("testString") + .granularity("day") + .rangeLink("testString") + .rangeModifier("testString") + .relativeDay(Double.valueOf("72.5")) + .relativeMonth(Double.valueOf("72.5")) + .relativeWeek(Double.valueOf("72.5")) + .relativeWeekend(Double.valueOf("72.5")) + .relativeYear(Double.valueOf("72.5")) + .specificDay(Double.valueOf("72.5")) + .specificDayOfWeek("testString") + .specificMonth(Double.valueOf("72.5")) + .specificQuarter(Double.valueOf("72.5")) + .specificYear(Double.valueOf("72.5")) + .numericValue(Double.valueOf("72.5")) + .subtype("testString") + .partOfDay("testString") + .relativeHour(Double.valueOf("72.5")) + .relativeMinute(Double.valueOf("72.5")) + .relativeSecond(Double.valueOf("72.5")) + .specificHour(Double.valueOf("72.5")) + .specificMinute(Double.valueOf("72.5")) + .specificSecond(Double.valueOf("72.5")) + .timezone("testString") + .build(); + assertEquals(runtimeEntityInterpretationModel.calendarType(), "testString"); + assertEquals(runtimeEntityInterpretationModel.datetimeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.festival(), "testString"); + assertEquals(runtimeEntityInterpretationModel.granularity(), "day"); + assertEquals(runtimeEntityInterpretationModel.rangeLink(), "testString"); + assertEquals(runtimeEntityInterpretationModel.rangeModifier(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeek(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeWeekend(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDay(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificDayOfWeek(), "testString"); + assertEquals(runtimeEntityInterpretationModel.specificMonth(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificQuarter(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificYear(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.numericValue(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.subtype(), "testString"); + assertEquals(runtimeEntityInterpretationModel.partOfDay(), "testString"); + assertEquals(runtimeEntityInterpretationModel.relativeHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.relativeSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificHour(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificMinute(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.specificSecond(), Double.valueOf("72.5")); + assertEquals(runtimeEntityInterpretationModel.timezone(), "testString"); + + RuntimeEntityAlternative runtimeEntityAlternativeModel = + new RuntimeEntityAlternative.Builder() + .value("testString") + .confidence(Double.valueOf("72.5")) + .build(); + assertEquals(runtimeEntityAlternativeModel.value(), "testString"); + assertEquals(runtimeEntityAlternativeModel.confidence(), Double.valueOf("72.5")); + + RuntimeEntityRole runtimeEntityRoleModel = + new RuntimeEntityRole.Builder().type("date_from").build(); + assertEquals(runtimeEntityRoleModel.type(), "date_from"); + + RuntimeEntity runtimeEntityModel = + new RuntimeEntity.Builder() + .entity("testString") + .location(new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))) + .value("testString") + .confidence(Double.valueOf("72.5")) + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .groups( + new java.util.ArrayList(java.util.Arrays.asList(captureGroupModel))) + .interpretation(runtimeEntityInterpretationModel) + .alternatives( + new java.util.ArrayList( + java.util.Arrays.asList(runtimeEntityAlternativeModel))) + .role(runtimeEntityRoleModel) + .build(); + assertEquals(runtimeEntityModel.entity(), "testString"); + assertEquals( + runtimeEntityModel.location(), + new java.util.ArrayList(java.util.Arrays.asList(Long.valueOf("26")))); + assertEquals(runtimeEntityModel.value(), "testString"); + assertEquals(runtimeEntityModel.confidence(), Double.valueOf("72.5")); + assertEquals( + runtimeEntityModel.metadata(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals( + runtimeEntityModel.groups(), + new java.util.ArrayList(java.util.Arrays.asList(captureGroupModel))); + assertEquals(runtimeEntityModel.interpretation(), runtimeEntityInterpretationModel); + assertEquals( + runtimeEntityModel.alternatives(), + new java.util.ArrayList( + java.util.Arrays.asList(runtimeEntityAlternativeModel))); + assertEquals(runtimeEntityModel.role(), runtimeEntityRoleModel); + + String json = TestUtilities.serialize(runtimeEntityModel); + + RuntimeEntity runtimeEntityModelNew = TestUtilities.deserialize(json, RuntimeEntity.class); + assertTrue(runtimeEntityModelNew instanceof RuntimeEntity); + assertEquals(runtimeEntityModelNew.entity(), "testString"); + assertEquals(runtimeEntityModelNew.value(), "testString"); + assertEquals(runtimeEntityModelNew.confidence(), Double.valueOf("72.5")); + assertEquals( + runtimeEntityModelNew.interpretation().toString(), + runtimeEntityInterpretationModel.toString()); + assertEquals(runtimeEntityModelNew.role().toString(), runtimeEntityRoleModel.toString()); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testRuntimeEntityError() throws Throwable { + new RuntimeEntity.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeIntentTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeIntentTest.java new file mode 100644 index 00000000000..b42b4c1aad6 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeIntentTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeIntent model. */ +public class RuntimeIntentTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeIntent() throws Throwable { + RuntimeIntent runtimeIntentModel = + new RuntimeIntent.Builder().intent("testString").confidence(Double.valueOf("72.5")).build(); + assertEquals(runtimeIntentModel.intent(), "testString"); + assertEquals(runtimeIntentModel.confidence(), Double.valueOf("72.5")); + + String json = TestUtilities.serialize(runtimeIntentModel); + + RuntimeIntent runtimeIntentModelNew = TestUtilities.deserialize(json, RuntimeIntent.class); + assertTrue(runtimeIntentModelNew instanceof RuntimeIntent); + assertEquals(runtimeIntentModelNew.intent(), "testString"); + assertEquals(runtimeIntentModelNew.confidence(), Double.valueOf("72.5")); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testRuntimeIntentError() throws Throwable { + new RuntimeIntent.Builder().build(); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeConnectToAgentTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeConnectToAgentTest.java new file mode 100644 index 00000000000..52368862492 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeConnectToAgentTest.java @@ -0,0 +1,43 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeResponseGenericRuntimeResponseTypeConnectToAgent model. */ +public class RuntimeResponseGenericRuntimeResponseTypeConnectToAgentTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeResponseGenericRuntimeResponseTypeConnectToAgent() throws Throwable { + RuntimeResponseGenericRuntimeResponseTypeConnectToAgent + runtimeResponseGenericRuntimeResponseTypeConnectToAgentModel = + new RuntimeResponseGenericRuntimeResponseTypeConnectToAgent(); + assertNull(runtimeResponseGenericRuntimeResponseTypeConnectToAgentModel.responseType()); + assertNull(runtimeResponseGenericRuntimeResponseTypeConnectToAgentModel.messageToHumanAgent()); + assertNull(runtimeResponseGenericRuntimeResponseTypeConnectToAgentModel.agentAvailable()); + assertNull(runtimeResponseGenericRuntimeResponseTypeConnectToAgentModel.agentUnavailable()); + assertNull(runtimeResponseGenericRuntimeResponseTypeConnectToAgentModel.transferInfo()); + assertNull(runtimeResponseGenericRuntimeResponseTypeConnectToAgentModel.topic()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeImageTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeImageTest.java new file mode 100644 index 00000000000..45177e2ab23 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeImageTest.java @@ -0,0 +1,41 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeResponseGenericRuntimeResponseTypeImage model. */ +public class RuntimeResponseGenericRuntimeResponseTypeImageTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeResponseGenericRuntimeResponseTypeImage() throws Throwable { + RuntimeResponseGenericRuntimeResponseTypeImage + runtimeResponseGenericRuntimeResponseTypeImageModel = + new RuntimeResponseGenericRuntimeResponseTypeImage(); + assertNull(runtimeResponseGenericRuntimeResponseTypeImageModel.responseType()); + assertNull(runtimeResponseGenericRuntimeResponseTypeImageModel.source()); + assertNull(runtimeResponseGenericRuntimeResponseTypeImageModel.title()); + assertNull(runtimeResponseGenericRuntimeResponseTypeImageModel.description()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeOptionTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeOptionTest.java new file mode 100644 index 00000000000..a903ccb89a2 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeOptionTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeResponseGenericRuntimeResponseTypeOption model. */ +public class RuntimeResponseGenericRuntimeResponseTypeOptionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeResponseGenericRuntimeResponseTypeOption() throws Throwable { + RuntimeResponseGenericRuntimeResponseTypeOption + runtimeResponseGenericRuntimeResponseTypeOptionModel = + new RuntimeResponseGenericRuntimeResponseTypeOption(); + assertNull(runtimeResponseGenericRuntimeResponseTypeOptionModel.responseType()); + assertNull(runtimeResponseGenericRuntimeResponseTypeOptionModel.title()); + assertNull(runtimeResponseGenericRuntimeResponseTypeOptionModel.description()); + assertNull(runtimeResponseGenericRuntimeResponseTypeOptionModel.preference()); + assertNull(runtimeResponseGenericRuntimeResponseTypeOptionModel.options()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypePauseTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypePauseTest.java new file mode 100644 index 00000000000..7d41a4b54d0 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypePauseTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeResponseGenericRuntimeResponseTypePause model. */ +public class RuntimeResponseGenericRuntimeResponseTypePauseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeResponseGenericRuntimeResponseTypePause() throws Throwable { + RuntimeResponseGenericRuntimeResponseTypePause + runtimeResponseGenericRuntimeResponseTypePauseModel = + new RuntimeResponseGenericRuntimeResponseTypePause(); + assertNull(runtimeResponseGenericRuntimeResponseTypePauseModel.responseType()); + assertNull(runtimeResponseGenericRuntimeResponseTypePauseModel.time()); + assertNull(runtimeResponseGenericRuntimeResponseTypePauseModel.typing()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeSearchTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeSearchTest.java new file mode 100644 index 00000000000..fc247854873 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeSearchTest.java @@ -0,0 +1,41 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeResponseGenericRuntimeResponseTypeSearch model. */ +public class RuntimeResponseGenericRuntimeResponseTypeSearchTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeResponseGenericRuntimeResponseTypeSearch() throws Throwable { + RuntimeResponseGenericRuntimeResponseTypeSearch + runtimeResponseGenericRuntimeResponseTypeSearchModel = + new RuntimeResponseGenericRuntimeResponseTypeSearch(); + assertNull(runtimeResponseGenericRuntimeResponseTypeSearchModel.responseType()); + assertNull(runtimeResponseGenericRuntimeResponseTypeSearchModel.header()); + assertNull(runtimeResponseGenericRuntimeResponseTypeSearchModel.primaryResults()); + assertNull(runtimeResponseGenericRuntimeResponseTypeSearchModel.additionalResults()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeSuggestionTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeSuggestionTest.java new file mode 100644 index 00000000000..6a1d0a587e5 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeSuggestionTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeResponseGenericRuntimeResponseTypeSuggestion model. */ +public class RuntimeResponseGenericRuntimeResponseTypeSuggestionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeResponseGenericRuntimeResponseTypeSuggestion() throws Throwable { + RuntimeResponseGenericRuntimeResponseTypeSuggestion + runtimeResponseGenericRuntimeResponseTypeSuggestionModel = + new RuntimeResponseGenericRuntimeResponseTypeSuggestion(); + assertNull(runtimeResponseGenericRuntimeResponseTypeSuggestionModel.responseType()); + assertNull(runtimeResponseGenericRuntimeResponseTypeSuggestionModel.title()); + assertNull(runtimeResponseGenericRuntimeResponseTypeSuggestionModel.suggestions()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeTextTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeTextTest.java new file mode 100644 index 00000000000..827a5ea5ce6 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericRuntimeResponseTypeTextTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeResponseGenericRuntimeResponseTypeText model. */ +public class RuntimeResponseGenericRuntimeResponseTypeTextTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRuntimeResponseGenericRuntimeResponseTypeText() throws Throwable { + RuntimeResponseGenericRuntimeResponseTypeText + runtimeResponseGenericRuntimeResponseTypeTextModel = + new RuntimeResponseGenericRuntimeResponseTypeText(); + assertNull(runtimeResponseGenericRuntimeResponseTypeTextModel.responseType()); + assertNull(runtimeResponseGenericRuntimeResponseTypeTextModel.text()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericTest.java new file mode 100644 index 00000000000..2e1711cd7fd --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGenericTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RuntimeResponseGeneric model. */ +public class RuntimeResponseGenericTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + // TODO: Add tests for models that are abstract + @Test + public void testRuntimeResponseGeneric() throws Throwable { + RuntimeResponseGeneric runtimeResponseGenericModel = new RuntimeResponseGeneric(); + assertNotNull(runtimeResponseGenericModel); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchResultHighlightTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchResultHighlightTest.java new file mode 100644 index 00000000000..469b29e381c --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchResultHighlightTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SearchResultHighlight model. */ +public class SearchResultHighlightTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSearchResultHighlight() throws Throwable { + SearchResultHighlight searchResultHighlightModel = new SearchResultHighlight(); + assertNull(searchResultHighlightModel.getBody()); + assertNull(searchResultHighlightModel.getTitle()); + assertNull(searchResultHighlightModel.getUrl()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchResultMetadataTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchResultMetadataTest.java new file mode 100644 index 00000000000..1a5af1a37b9 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchResultMetadataTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SearchResultMetadata model. */ +public class SearchResultMetadataTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSearchResultMetadata() throws Throwable { + SearchResultMetadata searchResultMetadataModel = new SearchResultMetadata(); + assertNull(searchResultMetadataModel.getConfidence()); + assertNull(searchResultMetadataModel.getScore()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchResultTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchResultTest.java new file mode 100644 index 00000000000..d9746d467de --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SearchResultTest.java @@ -0,0 +1,41 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SearchResult model. */ +public class SearchResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSearchResult() throws Throwable { + SearchResult searchResultModel = new SearchResult(); + assertNull(searchResultModel.getId()); + assertNull(searchResultModel.getResultMetadata()); + assertNull(searchResultModel.getBody()); + assertNull(searchResultModel.getTitle()); + assertNull(searchResultModel.getUrl()); + assertNull(searchResultModel.getHighlight()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SessionResponseTest.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SessionResponseTest.java new file mode 100644 index 00000000000..683365579ad --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/SessionResponseTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.assistant.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SessionResponse model. */ +public class SessionResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSessionResponse() throws Throwable { + SessionResponse sessionResponseModel = new SessionResponse(); + assertNull(sessionResponseModel.getSessionId()); + } +} diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/utils/TestUtilities.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/utils/TestUtilities.java new file mode 100644 index 00000000000..3fab8ceb653 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/utils/TestUtilities.java @@ -0,0 +1,128 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.assistant.v2.utils; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.cloud.sdk.core.util.GsonSingleton; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import okhttp3.HttpUrl; +import okhttp3.mockwebserver.RecordedRequest; + +/** A class used by the unit tests containing utility functions. */ +public class TestUtilities { + public static Map createMockMap() { + Map mockMap = new HashMap<>(); + mockMap.put("foo", "bar"); + return mockMap; + } + + public static HashMap createMockStreamMap() { + return new HashMap() { + { + put("key1", createMockStream("This is a mock file.")); + } + }; + } + + public static Map parseQueryString(RecordedRequest req) { + Map queryMap = new HashMap<>(); + + try { + HttpUrl requestUrl = req.getRequestUrl(); + + if (requestUrl != null) { + Set queryParamsNames = requestUrl.queryParameterNames(); + // map the parameter name to its corresponding value + for (String p : queryParamsNames) { + // get the corresponding value for the parameter (p) + List val = requestUrl.queryParameterValues(p); + if (val != null && !val.isEmpty()) { + String joinedQuery = String.join(",", val); + queryMap.put(p, joinedQuery); + } + } + } + if (queryMap.isEmpty()) { + return null; + } + } catch (Exception e) { + return null; + } + + return queryMap; + } + + public static String parseReqPath(RecordedRequest req) { + String parsedPath = null; + + try { + String fullPath = req.getPath(); + if (fullPath != null && !fullPath.isEmpty()) { + // retrieve the path segment before the query parameter + parsedPath = fullPath.split("\\?", 2)[0]; + } + if (parsedPath.isEmpty() || parsedPath == null) { + return null; + } + + } catch (Exception e) { + return null; + } + + return parsedPath; + } + + public static String serialize(Object obj) { + return GsonSingleton.getGson().toJson(obj); + } + + public static T deserialize(String json, Class clazz) { + return GsonSingleton.getGson().fromJson(json, clazz); + } + + public static InputStream createMockStream(String s) { + return new ByteArrayInputStream(s.getBytes()); + } + + public static List creatMockListFileWithMetadata() { + List list = new ArrayList(); + byte[] fileBytes = {(byte) 0xde, (byte) 0xad, (byte) 0xbe, (byte) 0xef}; + InputStream inputStream = new ByteArrayInputStream(fileBytes); + FileWithMetadata.Builder builder = new FileWithMetadata.Builder(); + builder.data(inputStream); + FileWithMetadata fileWithMetadata = builder.build(); + list.add(fileWithMetadata); + + return list; + } + + public static byte[] createMockByteArray(String bytes) { + return bytes.getBytes(); + } + + public static Date createMockDate(String date) throws Exception { + return new SimpleDateFormat("yyyy-MM-dd").parse(date); + } + + public static Date createMockDateTime(String date) throws Exception { + return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").parse(date); + } +} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/CompareComply.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/CompareComply.java index a7e4a09c525..8d82d657e67 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/CompareComply.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/CompareComply.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -10,6 +10,11 @@ * 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. */ + +/* + * IBM OpenAPI SDK Code Generator Version: 99-SNAPSHOT-7cc05500-20201106-154555 + */ + package com.ibm.watson.compare_comply.v1; import com.google.gson.JsonObject; @@ -44,12 +49,13 @@ import com.ibm.watson.compare_comply.v1.model.ListFeedbackOptions; import com.ibm.watson.compare_comply.v1.model.TableReturn; import com.ibm.watson.compare_comply.v1.model.UpdateBatchOptions; +import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; import okhttp3.MultipartBody; /** - * IBM Watson™ Compare and Comply analyzes governing documents to provide details about + * IBM Watson&trade; Compare and Comply analyzes governing documents to provide details about * critical aspects of the documents. * * @version v1 @@ -58,66 +64,89 @@ */ public class CompareComply extends BaseService { - private static final String DEFAULT_SERVICE_NAME = "compare_comply"; + public static final String DEFAULT_SERVICE_NAME = "compare-comply"; - private static final String DEFAULT_SERVICE_URL = - "https://gateway.watsonplatform.net/compare-comply/api"; + public static final String DEFAULT_SERVICE_URL = + "https://api.us-south.compare-comply.watson.cloud.ibm.com"; - private String versionDate; + private String version; /** - * Constructs a new `CompareComply` client using the DEFAULT_SERVICE_NAME. + * Constructs an instance of the `CompareComply` client. The default service name is used to + * configure the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value - * will keep your API calls from failing when the service introduces breaking changes. + * @param version Release date of the version of the API you want to use. Specify dates in + * YYYY-MM-DD format. The current version is `2018-10-15`. */ - public CompareComply(String versionDate) { + public CompareComply(String version) { this( - versionDate, + version, DEFAULT_SERVICE_NAME, ConfigBasedAuthenticatorFactory.getAuthenticator(DEFAULT_SERVICE_NAME)); } /** - * Constructs a new `CompareComply` client with the DEFAULT_SERVICE_NAME and the specified - * Authenticator. + * Constructs an instance of the `CompareComply` client. The default service name and specified + * authenticator are used to configure the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value - * will keep your API calls from failing when the service introduces breaking changes. - * @param authenticator the Authenticator instance to be configured for this service + * @param version Release date of the version of the API you want to use. Specify dates in + * YYYY-MM-DD format. The current version is `2018-10-15`. + * @param authenticator the {@link Authenticator} instance to be configured for this client */ - public CompareComply(String versionDate, Authenticator authenticator) { - this(versionDate, DEFAULT_SERVICE_NAME, authenticator); + public CompareComply(String version, Authenticator authenticator) { + this(version, DEFAULT_SERVICE_NAME, authenticator); } /** - * Constructs a new `CompareComply` client with the specified serviceName. + * Constructs an instance of the `CompareComply` client. The specified service name is used to + * configure the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value - * will keep your API calls from failing when the service introduces breaking changes. - * @param serviceName The name of the service to configure. + * @param version Release date of the version of the API you want to use. Specify dates in + * YYYY-MM-DD format. The current version is `2018-10-15`. + * @param serviceName the service name to be used when configuring the client instance */ - public CompareComply(String versionDate, String serviceName) { - this(versionDate, serviceName, ConfigBasedAuthenticatorFactory.getAuthenticator(serviceName)); + public CompareComply(String version, String serviceName) { + this(version, serviceName, ConfigBasedAuthenticatorFactory.getAuthenticator(serviceName)); } /** - * Constructs a new `CompareComply` client with the specified Authenticator and serviceName. + * Constructs an instance of the `CompareComply` client. The specified service name and + * authenticator are used to configure the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value - * will keep your API calls from failing when the service introduces breaking changes. - * @param serviceName The name of the service to configure. - * @param authenticator the Authenticator instance to be configured for this service + * @param version Release date of the version of the API you want to use. Specify dates in + * YYYY-MM-DD format. The current version is `2018-10-15`. + * @param serviceName the service name to be used when configuring the client instance + * @param authenticator the {@link Authenticator} instance to be configured for this client */ - public CompareComply(String versionDate, String serviceName, Authenticator authenticator) { + public CompareComply(String version, String serviceName, Authenticator authenticator) { super(serviceName, authenticator); setServiceUrl(DEFAULT_SERVICE_URL); - com.ibm.cloud.sdk.core.util.Validator.isTrue( - (versionDate != null) && !versionDate.isEmpty(), "version cannot be null."); - this.versionDate = versionDate; + setVersion(version); this.configureService(serviceName); } + /** + * Gets the version. + * + *

Release date of the version of the API you want to use. Specify dates in YYYY-MM-DD format. + * The current version is `2018-10-15`. + * + * @return the version + */ + public String getVersion() { + return this.version; + } + + /** + * Sets the version. + * + * @param version the new version + */ + public void setVersion(final String version) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(version, "version cannot be empty."); + this.version = version; + } + /** * Convert document to HTML. * @@ -125,23 +154,23 @@ public CompareComply(String versionDate, String serviceName, Authenticator authe * * @param convertToHtmlOptions the {@link ConvertToHtmlOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of {@link HTMLReturn} + * @return a {@link ServiceCall} with a result of type {@link HTMLReturn} */ public ServiceCall convertToHtml(ConvertToHtmlOptions convertToHtmlOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( convertToHtmlOptions, "convertToHtmlOptions cannot be null"); - String[] pathSegments = {"v1/html_conversion"}; RequestBuilder builder = - RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); + RequestBuilder.post( + RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/html_conversion")); Map sdkHeaders = SdkCommon.getSdkHeaders("compare-comply", "v1", "convertToHtml"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (convertToHtmlOptions.model() != null) { - builder.query("model", convertToHtmlOptions.model()); + builder.query("model", String.valueOf(convertToHtmlOptions.model())); } MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); multipartBuilder.setType(MultipartBody.FORM); @@ -163,24 +192,24 @@ public ServiceCall convertToHtml(ConvertToHtmlOptions convertToHtmlO * * @param classifyElementsOptions the {@link ClassifyElementsOptions} containing the options for * the call - * @return a {@link ServiceCall} with a response type of {@link ClassifyReturn} + * @return a {@link ServiceCall} with a result of type {@link ClassifyReturn} */ public ServiceCall classifyElements( ClassifyElementsOptions classifyElementsOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( classifyElementsOptions, "classifyElementsOptions cannot be null"); - String[] pathSegments = {"v1/element_classification"}; RequestBuilder builder = - RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); + RequestBuilder.post( + RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/element_classification")); Map sdkHeaders = SdkCommon.getSdkHeaders("compare-comply", "v1", "classifyElements"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (classifyElementsOptions.model() != null) { - builder.query("model", classifyElementsOptions.model()); + builder.query("model", String.valueOf(classifyElementsOptions.model())); } MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); multipartBuilder.setType(MultipartBody.FORM); @@ -202,23 +231,22 @@ public ServiceCall classifyElements( * * @param extractTablesOptions the {@link ExtractTablesOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of {@link TableReturn} + * @return a {@link ServiceCall} with a result of type {@link TableReturn} */ public ServiceCall extractTables(ExtractTablesOptions extractTablesOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( extractTablesOptions, "extractTablesOptions cannot be null"); - String[] pathSegments = {"v1/tables"}; RequestBuilder builder = - RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); + RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/tables")); Map sdkHeaders = SdkCommon.getSdkHeaders("compare-comply", "v1", "extractTables"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (extractTablesOptions.model() != null) { - builder.query("model", extractTablesOptions.model()); + builder.query("model", String.valueOf(extractTablesOptions.model())); } MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); multipartBuilder.setType(MultipartBody.FORM); @@ -240,30 +268,29 @@ public ServiceCall extractTables(ExtractTablesOptions extractTables * * @param compareDocumentsOptions the {@link CompareDocumentsOptions} containing the options for * the call - * @return a {@link ServiceCall} with a response type of {@link CompareReturn} + * @return a {@link ServiceCall} with a result of type {@link CompareReturn} */ public ServiceCall compareDocuments( CompareDocumentsOptions compareDocumentsOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( compareDocumentsOptions, "compareDocumentsOptions cannot be null"); - String[] pathSegments = {"v1/comparison"}; RequestBuilder builder = - RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); + RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/comparison")); Map sdkHeaders = SdkCommon.getSdkHeaders("compare-comply", "v1", "compareDocuments"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (compareDocumentsOptions.file1Label() != null) { - builder.query("file_1_label", compareDocumentsOptions.file1Label()); + builder.query("file_1_label", String.valueOf(compareDocumentsOptions.file1Label())); } if (compareDocumentsOptions.file2Label() != null) { - builder.query("file_2_label", compareDocumentsOptions.file2Label()); + builder.query("file_2_label", String.valueOf(compareDocumentsOptions.file2Label())); } if (compareDocumentsOptions.model() != null) { - builder.query("model", compareDocumentsOptions.model()); + builder.query("model", String.valueOf(compareDocumentsOptions.model())); } MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); multipartBuilder.setType(MultipartBody.FORM); @@ -291,20 +318,19 @@ public ServiceCall compareDocuments( * suggest future updates to the training model. * * @param addFeedbackOptions the {@link AddFeedbackOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link FeedbackReturn} + * @return a {@link ServiceCall} with a result of type {@link FeedbackReturn} */ public ServiceCall addFeedback(AddFeedbackOptions addFeedbackOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( addFeedbackOptions, "addFeedbackOptions cannot be null"); - String[] pathSegments = {"v1/feedback"}; RequestBuilder builder = - RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); + RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/feedback")); Map sdkHeaders = SdkCommon.getSdkHeaders("compare-comply", "v1", "addFeedback"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); final JsonObject contentJson = new JsonObject(); contentJson.add( "feedback_data", @@ -329,68 +355,63 @@ public ServiceCall addFeedback(AddFeedbackOptions addFeedbackOpt *

Lists the feedback in a document. * * @param listFeedbackOptions the {@link ListFeedbackOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link FeedbackList} + * @return a {@link ServiceCall} with a result of type {@link FeedbackList} */ public ServiceCall listFeedback(ListFeedbackOptions listFeedbackOptions) { - String[] pathSegments = {"v1/feedback"}; + if (listFeedbackOptions == null) { + listFeedbackOptions = new ListFeedbackOptions.Builder().build(); + } RequestBuilder builder = - RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); + RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/feedback")); Map sdkHeaders = SdkCommon.getSdkHeaders("compare-comply", "v1", "listFeedback"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - if (listFeedbackOptions != null) { - if (listFeedbackOptions.feedbackType() != null) { - builder.query("feedback_type", listFeedbackOptions.feedbackType()); - } - if (listFeedbackOptions.before() != null) { - builder.query("before", String.valueOf(listFeedbackOptions.before())); - } - if (listFeedbackOptions.after() != null) { - builder.query("after", String.valueOf(listFeedbackOptions.after())); - } - if (listFeedbackOptions.documentTitle() != null) { - builder.query("document_title", listFeedbackOptions.documentTitle()); - } - if (listFeedbackOptions.modelId() != null) { - builder.query("model_id", listFeedbackOptions.modelId()); - } - if (listFeedbackOptions.modelVersion() != null) { - builder.query("model_version", listFeedbackOptions.modelVersion()); - } - if (listFeedbackOptions.categoryRemoved() != null) { - builder.query("category_removed", listFeedbackOptions.categoryRemoved()); - } - if (listFeedbackOptions.categoryAdded() != null) { - builder.query("category_added", listFeedbackOptions.categoryAdded()); - } - if (listFeedbackOptions.categoryNotChanged() != null) { - builder.query("category_not_changed", listFeedbackOptions.categoryNotChanged()); - } - if (listFeedbackOptions.typeRemoved() != null) { - builder.query("type_removed", listFeedbackOptions.typeRemoved()); - } - if (listFeedbackOptions.typeAdded() != null) { - builder.query("type_added", listFeedbackOptions.typeAdded()); - } - if (listFeedbackOptions.typeNotChanged() != null) { - builder.query("type_not_changed", listFeedbackOptions.typeNotChanged()); - } - if (listFeedbackOptions.pageLimit() != null) { - builder.query("page_limit", String.valueOf(listFeedbackOptions.pageLimit())); - } - if (listFeedbackOptions.cursor() != null) { - builder.query("cursor", listFeedbackOptions.cursor()); - } - if (listFeedbackOptions.sort() != null) { - builder.query("sort", listFeedbackOptions.sort()); - } - if (listFeedbackOptions.includeTotal() != null) { - builder.query("include_total", String.valueOf(listFeedbackOptions.includeTotal())); - } + builder.query("version", String.valueOf(this.version)); + if (listFeedbackOptions.feedbackType() != null) { + builder.query("feedback_type", String.valueOf(listFeedbackOptions.feedbackType())); + } + if (listFeedbackOptions.documentTitle() != null) { + builder.query("document_title", String.valueOf(listFeedbackOptions.documentTitle())); + } + if (listFeedbackOptions.modelId() != null) { + builder.query("model_id", String.valueOf(listFeedbackOptions.modelId())); + } + if (listFeedbackOptions.modelVersion() != null) { + builder.query("model_version", String.valueOf(listFeedbackOptions.modelVersion())); + } + if (listFeedbackOptions.categoryRemoved() != null) { + builder.query("category_removed", String.valueOf(listFeedbackOptions.categoryRemoved())); + } + if (listFeedbackOptions.categoryAdded() != null) { + builder.query("category_added", String.valueOf(listFeedbackOptions.categoryAdded())); + } + if (listFeedbackOptions.categoryNotChanged() != null) { + builder.query( + "category_not_changed", String.valueOf(listFeedbackOptions.categoryNotChanged())); + } + if (listFeedbackOptions.typeRemoved() != null) { + builder.query("type_removed", String.valueOf(listFeedbackOptions.typeRemoved())); + } + if (listFeedbackOptions.typeAdded() != null) { + builder.query("type_added", String.valueOf(listFeedbackOptions.typeAdded())); + } + if (listFeedbackOptions.typeNotChanged() != null) { + builder.query("type_not_changed", String.valueOf(listFeedbackOptions.typeNotChanged())); + } + if (listFeedbackOptions.pageLimit() != null) { + builder.query("page_limit", String.valueOf(listFeedbackOptions.pageLimit())); + } + if (listFeedbackOptions.cursor() != null) { + builder.query("cursor", String.valueOf(listFeedbackOptions.cursor())); + } + if (listFeedbackOptions.sort() != null) { + builder.query("sort", String.valueOf(listFeedbackOptions.sort())); + } + if (listFeedbackOptions.includeTotal() != null) { + builder.query("include_total", String.valueOf(listFeedbackOptions.includeTotal())); } ResponseConverter responseConverter = ResponseConverterUtils.getValue( @@ -403,7 +424,7 @@ public ServiceCall listFeedback(ListFeedbackOptions listFeedbackOp * *

Lists the feedback in a document. * - * @return a {@link ServiceCall} with a response type of {@link FeedbackList} + * @return a {@link ServiceCall} with a result of type {@link FeedbackList} */ public ServiceCall listFeedback() { return listFeedback(null); @@ -415,24 +436,25 @@ public ServiceCall listFeedback() { *

Gets a feedback entry with a specified `feedback_id`. * * @param getFeedbackOptions the {@link GetFeedbackOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link GetFeedback} + * @return a {@link ServiceCall} with a result of type {@link GetFeedback} */ public ServiceCall getFeedback(GetFeedbackOptions getFeedbackOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( getFeedbackOptions, "getFeedbackOptions cannot be null"); - String[] pathSegments = {"v1/feedback"}; - String[] pathParameters = {getFeedbackOptions.feedbackId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("feedback_id", getFeedbackOptions.feedbackId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/feedback/{feedback_id}", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("compare-comply", "v1", "getFeedback"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (getFeedbackOptions.model() != null) { - builder.query("model", getFeedbackOptions.model()); + builder.query("model", String.valueOf(getFeedbackOptions.model())); } ResponseConverter responseConverter = ResponseConverterUtils.getValue( @@ -447,25 +469,26 @@ public ServiceCall getFeedback(GetFeedbackOptions getFeedbackOption * * @param deleteFeedbackOptions the {@link DeleteFeedbackOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of {@link FeedbackDeleted} + * @return a {@link ServiceCall} with a result of type {@link FeedbackDeleted} */ public ServiceCall deleteFeedback(DeleteFeedbackOptions deleteFeedbackOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( deleteFeedbackOptions, "deleteFeedbackOptions cannot be null"); - String[] pathSegments = {"v1/feedback"}; - String[] pathParameters = {deleteFeedbackOptions.feedbackId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("feedback_id", deleteFeedbackOptions.feedbackId()); RequestBuilder builder = RequestBuilder.delete( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/feedback/{feedback_id}", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("compare-comply", "v1", "deleteFeedback"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (deleteFeedbackOptions.model() != null) { - builder.query("model", deleteFeedbackOptions.model()); + builder.query("model", String.valueOf(deleteFeedbackOptions.model())); } ResponseConverter responseConverter = ResponseConverterUtils.getValue( @@ -478,30 +501,28 @@ public ServiceCall deleteFeedback(DeleteFeedbackOptions deleteF * *

Run Compare and Comply methods over a collection of input documents. * - *

**Important:** Batch processing requires the use of the [IBM Cloud Object Storage service] - * (https://cloud.ibm.com/docs/cloud-object-storage? - * topic=cloud-object-storage-about#about-ibm-cloud-object-storage). The use of IBM Cloud Object - * Storage with Compare and Comply is discussed at [Using batch + *

**Important:** Batch processing requires the use of the [IBM Cloud Object Storage + * service](https://cloud.ibm.com/docs/cloud-object-storage?topic=cloud-object-storage-about#about-ibm-cloud-object-storage). + * The use of IBM Cloud Object Storage with Compare and Comply is discussed at [Using batch * processing](https://cloud.ibm.com/docs/compare-comply?topic=compare-comply-batching#before-you-batch). * * @param createBatchOptions the {@link CreateBatchOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link BatchStatus} + * @return a {@link ServiceCall} with a result of type {@link BatchStatus} */ public ServiceCall createBatch(CreateBatchOptions createBatchOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( createBatchOptions, "createBatchOptions cannot be null"); - String[] pathSegments = {"v1/batches"}; RequestBuilder builder = - RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); + RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/batches")); Map sdkHeaders = SdkCommon.getSdkHeaders("compare-comply", "v1", "createBatch"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - builder.query("function", createBatchOptions.function()); + builder.query("version", String.valueOf(this.version)); + builder.query("function", String.valueOf(createBatchOptions.function())); if (createBatchOptions.model() != null) { - builder.query("model", createBatchOptions.model()); + builder.query("model", String.valueOf(createBatchOptions.model())); } MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); multipartBuilder.setType(MultipartBody.FORM); @@ -533,20 +554,17 @@ public ServiceCall createBatch(CreateBatchOptions createBatchOption *

Lists batch-processing jobs submitted by users. * * @param listBatchesOptions the {@link ListBatchesOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Batches} + * @return a {@link ServiceCall} with a result of type {@link Batches} */ public ServiceCall listBatches(ListBatchesOptions listBatchesOptions) { - String[] pathSegments = {"v1/batches"}; RequestBuilder builder = - RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); + RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/batches")); Map sdkHeaders = SdkCommon.getSdkHeaders("compare-comply", "v1", "listBatches"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - if (listBatchesOptions != null) {} - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken() {}.getType()); @@ -558,7 +576,7 @@ public ServiceCall listBatches(ListBatchesOptions listBatchesOptions) { * *

Lists batch-processing jobs submitted by users. * - * @return a {@link ServiceCall} with a response type of {@link Batches} + * @return a {@link ServiceCall} with a result of type {@link Batches} */ public ServiceCall listBatches() { return listBatches(null); @@ -570,23 +588,23 @@ public ServiceCall listBatches() { *

Gets information about a batch-processing job with a specified ID. * * @param getBatchOptions the {@link GetBatchOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link BatchStatus} + * @return a {@link ServiceCall} with a result of type {@link BatchStatus} */ public ServiceCall getBatch(GetBatchOptions getBatchOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( getBatchOptions, "getBatchOptions cannot be null"); - String[] pathSegments = {"v1/batches"}; - String[] pathParameters = {getBatchOptions.batchId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("batch_id", getBatchOptions.batchId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/batches/{batch_id}", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("compare-comply", "v1", "getBatch"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken() {}.getType()); @@ -600,25 +618,26 @@ public ServiceCall getBatch(GetBatchOptions getBatchOptions) { * for new documents or cancel a job. * * @param updateBatchOptions the {@link UpdateBatchOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link BatchStatus} + * @return a {@link ServiceCall} with a result of type {@link BatchStatus} */ public ServiceCall updateBatch(UpdateBatchOptions updateBatchOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( updateBatchOptions, "updateBatchOptions cannot be null"); - String[] pathSegments = {"v1/batches"}; - String[] pathParameters = {updateBatchOptions.batchId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("batch_id", updateBatchOptions.batchId()); RequestBuilder builder = RequestBuilder.put( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/batches/{batch_id}", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("compare-comply", "v1", "updateBatch"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - builder.query("action", updateBatchOptions.action()); + builder.query("version", String.valueOf(this.version)); + builder.query("action", String.valueOf(updateBatchOptions.action())); if (updateBatchOptions.model() != null) { - builder.query("model", updateBatchOptions.model()); + builder.query("model", String.valueOf(updateBatchOptions.model())); } ResponseConverter responseConverter = ResponseConverterUtils.getValue( diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/AddFeedbackOptions.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/AddFeedbackOptions.java index b73a214e9b6..1de908e5e80 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/AddFeedbackOptions.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/AddFeedbackOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -48,7 +48,7 @@ public Builder(FeedbackDataInput feedbackData) { /** * Builds a AddFeedbackOptions. * - * @return the addFeedbackOptions + * @return the new AddFeedbackOptions instance */ public AddFeedbackOptions build() { return new AddFeedbackOptions(this); diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Address.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Address.java index 4d4ddc807ba..753b7859e85 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Address.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Address.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/AlignedElement.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/AlignedElement.java index 9a484674800..838ebb38b05 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/AlignedElement.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/AlignedElement.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Attribute.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Attribute.java index c75f0428d7a..445e1072ef7 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Attribute.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Attribute.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/BatchStatus.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/BatchStatus.java index fc05e8aaf01..6e513829c01 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/BatchStatus.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/BatchStatus.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Batches.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Batches.java index 513859a67f2..2dad8cf6a94 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Batches.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Batches.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/BodyCells.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/BodyCells.java index 0fc7ef0ad51..704a387d861 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/BodyCells.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/BodyCells.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Category.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Category.java index f63adb01118..b04e6c5bfab 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Category.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Category.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -54,9 +54,9 @@ public interface Label { String LIABILITY = "Liability"; /** Order of Precedence. */ String ORDER_OF_PRECEDENCE = "Order of Precedence"; - /** Payment Terms & Billing. */ + /** Payment Terms & Billing. */ String PAYMENT_TERMS_BILLING = "Payment Terms & Billing"; - /** Pricing & Taxes. */ + /** Pricing & Taxes. */ String PRICING_TAXES = "Pricing & Taxes"; /** Privacy. */ String PRIVACY = "Privacy"; @@ -68,25 +68,39 @@ public interface Label { String SCOPE_OF_WORK = "Scope of Work"; /** Subcontracts. */ String SUBCONTRACTS = "Subcontracts"; - /** Term & Termination. */ + /** Term & Termination. */ String TERM_TERMINATION = "Term & Termination"; /** Warranties. */ String WARRANTIES = "Warranties"; } + /** The type of modification of the feedback entry in the updated labels response. */ + public interface Modification { + /** added. */ + String ADDED = "added"; + /** unchanged. */ + String UNCHANGED = "unchanged"; + /** removed. */ + String REMOVED = "removed"; + } + protected String label; @SerializedName("provenance_ids") protected List provenanceIds; + protected String modification; + /** Builder. */ public static class Builder { private String label; private List provenanceIds; + private String modification; private Builder(Category category) { this.label = category.label; this.provenanceIds = category.provenanceIds; + this.modification = category.modification; } /** Instantiates a new builder. */ @@ -95,7 +109,7 @@ public Builder() {} /** * Builds a Category. * - * @return the category + * @return the new Category instance */ public Category build() { return new Category(this); @@ -137,11 +151,23 @@ public Builder provenanceIds(List provenanceIds) { this.provenanceIds = provenanceIds; return this; } + + /** + * Set the modification. + * + * @param modification the modification + * @return the Category builder + */ + public Builder modification(String modification) { + this.modification = modification; + return this; + } } protected Category(Builder builder) { label = builder.label; provenanceIds = builder.provenanceIds; + modification = builder.modification; } /** @@ -174,4 +200,15 @@ public String label() { public List provenanceIds() { return provenanceIds; } + + /** + * Gets the modification. + * + *

The type of modification of the feedback entry in the updated labels response. + * + * @return the modification + */ + public String modification() { + return modification; + } } diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/CategoryComparison.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/CategoryComparison.java index f91c4f60cbd..daa1a25d10d 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/CategoryComparison.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/CategoryComparison.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -51,9 +51,9 @@ public interface Label { String LIABILITY = "Liability"; /** Order of Precedence. */ String ORDER_OF_PRECEDENCE = "Order of Precedence"; - /** Payment Terms & Billing. */ + /** Payment Terms & Billing. */ String PAYMENT_TERMS_BILLING = "Payment Terms & Billing"; - /** Pricing & Taxes. */ + /** Pricing & Taxes. */ String PRICING_TAXES = "Pricing & Taxes"; /** Privacy. */ String PRIVACY = "Privacy"; @@ -65,7 +65,7 @@ public interface Label { String SCOPE_OF_WORK = "Scope of Work"; /** Subcontracts. */ String SUBCONTRACTS = "Subcontracts"; - /** Term & Termination. */ + /** Term & Termination. */ String TERM_TERMINATION = "Term & Termination"; /** Warranties. */ String WARRANTIES = "Warranties"; diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ClassifyElementsOptions.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ClassifyElementsOptions.java index faaa73daf5f..d109bbe159c 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ClassifyElementsOptions.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ClassifyElementsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -65,7 +65,7 @@ public Builder(InputStream file) { /** * Builds a ClassifyElementsOptions. * - * @return the classifyElementsOptions + * @return the new ClassifyElementsOptions instance */ public ClassifyElementsOptions build() { return new ClassifyElementsOptions(this); diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ClassifyReturn.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ClassifyReturn.java index 2a89b5ba274..aae2839867e 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ClassifyReturn.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ClassifyReturn.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ColumnHeaders.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ColumnHeaders.java index 46f174d07f0..bb3a9b6d6d1 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ColumnHeaders.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ColumnHeaders.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/CompareDocumentsOptions.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/CompareDocumentsOptions.java index 1a89eb6c789..3cb5716e676 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/CompareDocumentsOptions.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/CompareDocumentsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -79,7 +79,7 @@ public Builder(InputStream file1, InputStream file2) { /** * Builds a CompareDocumentsOptions. * - * @return the compareDocumentsOptions + * @return the new CompareDocumentsOptions instance */ public CompareDocumentsOptions build() { return new CompareDocumentsOptions(this); diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/CompareReturn.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/CompareReturn.java index 1b14a2ca632..7cd0d6441ed 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/CompareReturn.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/CompareReturn.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Contact.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Contact.java index 56e95d7cfff..617b512ad1b 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Contact.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Contact.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Contexts.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Contexts.java index 370f6966f3c..65318d83d1c 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Contexts.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Contexts.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ContractAmts.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ContractAmts.java index 27eb35233ee..26e3a51e051 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ContractAmts.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ContractAmts.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ContractCurrencies.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ContractCurrencies.java index 4cff195dcf7..9e520b85fdc 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ContractCurrencies.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ContractCurrencies.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ContractTerms.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ContractTerms.java index e73168c56f2..855d75d33bb 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ContractTerms.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ContractTerms.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ContractTypes.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ContractTypes.java index 4e18a3b66c0..38c5b3de129 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ContractTypes.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ContractTypes.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ConvertToHtmlOptions.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ConvertToHtmlOptions.java index 0fb8d1db30c..72100e8ec41 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ConvertToHtmlOptions.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ConvertToHtmlOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -65,7 +65,7 @@ public Builder(InputStream file) { /** * Builds a ConvertToHtmlOptions. * - * @return the convertToHtmlOptions + * @return the new ConvertToHtmlOptions instance */ public ConvertToHtmlOptions build() { return new ConvertToHtmlOptions(this); diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/CreateBatchOptions.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/CreateBatchOptions.java index ed80ad58a2b..7c43742a1a7 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/CreateBatchOptions.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/CreateBatchOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -109,7 +109,7 @@ public Builder( /** * Builds a CreateBatchOptions. * - * @return the createBatchOptions + * @return the new CreateBatchOptions instance */ public CreateBatchOptions build() { return new CreateBatchOptions(this); diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/DeleteFeedbackOptions.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/DeleteFeedbackOptions.java index 93c1b095189..8cff43d4080 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/DeleteFeedbackOptions.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/DeleteFeedbackOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -58,7 +58,7 @@ public Builder(String feedbackId) { /** * Builds a DeleteFeedbackOptions. * - * @return the deleteFeedbackOptions + * @return the new DeleteFeedbackOptions instance */ public DeleteFeedbackOptions build() { return new DeleteFeedbackOptions(this); diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/DocCounts.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/DocCounts.java index a6f4c0374e4..7bbda9f34f4 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/DocCounts.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/DocCounts.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/DocInfo.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/DocInfo.java index f4d4cf09000..ffd2e3c538d 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/DocInfo.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/DocInfo.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/DocStructure.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/DocStructure.java index 027cd818392..6bee4523d34 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/DocStructure.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/DocStructure.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Document.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Document.java index b261f6eab52..edd1ebce938 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Document.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Document.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/EffectiveDates.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/EffectiveDates.java index 3e9c2bd3f89..cbe687c2377 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/EffectiveDates.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/EffectiveDates.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Element.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Element.java index f8f08716fbf..24c1d278a8e 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Element.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Element.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ElementLocations.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ElementLocations.java index 5a58abb5dd3..dc4be77a13d 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ElementLocations.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ElementLocations.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ElementPair.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ElementPair.java index 02b9cd903bc..4f182bb8da0 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ElementPair.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ElementPair.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ExtractTablesOptions.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ExtractTablesOptions.java index b068b277da6..fa5ff9b7146 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ExtractTablesOptions.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ExtractTablesOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -65,7 +65,7 @@ public Builder(InputStream file) { /** * Builds a ExtractTablesOptions. * - * @return the extractTablesOptions + * @return the new ExtractTablesOptions instance */ public ExtractTablesOptions build() { return new ExtractTablesOptions(this); diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/FeedbackDataInput.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/FeedbackDataInput.java index 88ca36c5fe3..852d2a81178 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/FeedbackDataInput.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/FeedbackDataInput.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -88,7 +88,7 @@ public Builder( /** * Builds a FeedbackDataInput. * - * @return the feedbackDataInput + * @return the new FeedbackDataInput instance */ public FeedbackDataInput build() { return new FeedbackDataInput(this); diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/FeedbackDataOutput.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/FeedbackDataOutput.java index c25cbece89b..ba416093519 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/FeedbackDataOutput.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/FeedbackDataOutput.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/FeedbackDeleted.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/FeedbackDeleted.java index 73357540cb6..2a3d257c53a 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/FeedbackDeleted.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/FeedbackDeleted.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/FeedbackList.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/FeedbackList.java index 1199dec1366..af640c3f5d5 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/FeedbackList.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/FeedbackList.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/FeedbackReturn.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/FeedbackReturn.java index 9cc77272878..ff7a81b6995 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/FeedbackReturn.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/FeedbackReturn.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/GetBatchOptions.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/GetBatchOptions.java index c69c3057c4a..170479e3a97 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/GetBatchOptions.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/GetBatchOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -42,7 +42,7 @@ public Builder(String batchId) { /** * Builds a GetBatchOptions. * - * @return the getBatchOptions + * @return the new GetBatchOptions instance */ public GetBatchOptions build() { return new GetBatchOptions(this); diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/GetFeedback.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/GetFeedback.java index c8814444fd6..571a185b4f4 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/GetFeedback.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/GetFeedback.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/GetFeedbackOptions.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/GetFeedbackOptions.java index 93a15e32b7c..141ba26e47c 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/GetFeedbackOptions.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/GetFeedbackOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -58,7 +58,7 @@ public Builder(String feedbackId) { /** * Builds a GetFeedbackOptions. * - * @return the getFeedbackOptions + * @return the new GetFeedbackOptions instance */ public GetFeedbackOptions build() { return new GetFeedbackOptions(this); diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/HTMLReturn.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/HTMLReturn.java index a425967c73d..78cdaa91dec 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/HTMLReturn.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/HTMLReturn.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Interpretation.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Interpretation.java index d5fc5291867..69e1db544b4 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Interpretation.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Interpretation.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Key.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Key.java index 268c70d4e3f..9bff522fa05 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Key.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Key.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/KeyValuePair.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/KeyValuePair.java index b5d8a405aea..feb6e8d7d78 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/KeyValuePair.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/KeyValuePair.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Label.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Label.java index 9ec024ec08c..39ddbb344cf 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Label.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Label.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -50,7 +50,7 @@ public Builder(String nature, String party) { /** * Builds a Label. * - * @return the label + * @return the new Label instance */ public Label build() { return new Label(this); diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/LeadingSentence.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/LeadingSentence.java index d475d5dfd63..de73203cc12 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/LeadingSentence.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/LeadingSentence.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ListBatchesOptions.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ListBatchesOptions.java index 07ce5b7f36c..fb0773f3104 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ListBatchesOptions.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ListBatchesOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -15,33 +15,4 @@ import com.ibm.cloud.sdk.core.service.model.GenericModel; /** The listBatches options. */ -public class ListBatchesOptions extends GenericModel { - - /** Builder. */ - public static class Builder { - - private Builder(ListBatchesOptions listBatchesOptions) {} - - /** Instantiates a new builder. */ - public Builder() {} - - /** - * Builds a ListBatchesOptions. - * - * @return the listBatchesOptions - */ - public ListBatchesOptions build() { - return new ListBatchesOptions(this); - } - } - - private ListBatchesOptions(Builder builder) {} - /** - * New builder. - * - * @return a ListBatchesOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } -} +public class ListBatchesOptions extends GenericModel {} diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ListFeedbackOptions.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ListFeedbackOptions.java index 41ab7c347e5..9af05a9d004 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ListFeedbackOptions.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ListFeedbackOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -13,14 +13,11 @@ package com.ibm.watson.compare_comply.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -import java.util.Date; /** The listFeedback options. */ public class ListFeedbackOptions extends GenericModel { protected String feedbackType; - protected Date before; - protected Date after; protected String documentTitle; protected String modelId; protected String modelVersion; @@ -38,8 +35,6 @@ public class ListFeedbackOptions extends GenericModel { /** Builder. */ public static class Builder { private String feedbackType; - private Date before; - private Date after; private String documentTitle; private String modelId; private String modelVersion; @@ -56,8 +51,6 @@ public static class Builder { private Builder(ListFeedbackOptions listFeedbackOptions) { this.feedbackType = listFeedbackOptions.feedbackType; - this.before = listFeedbackOptions.before; - this.after = listFeedbackOptions.after; this.documentTitle = listFeedbackOptions.documentTitle; this.modelId = listFeedbackOptions.modelId; this.modelVersion = listFeedbackOptions.modelVersion; @@ -79,7 +72,7 @@ public Builder() {} /** * Builds a ListFeedbackOptions. * - * @return the listFeedbackOptions + * @return the new ListFeedbackOptions instance */ public ListFeedbackOptions build() { return new ListFeedbackOptions(this); @@ -96,28 +89,6 @@ public Builder feedbackType(String feedbackType) { return this; } - /** - * Set the before. - * - * @param before the before - * @return the ListFeedbackOptions builder - */ - public Builder before(Date before) { - this.before = before; - return this; - } - - /** - * Set the after. - * - * @param after the after - * @return the ListFeedbackOptions builder - */ - public Builder after(Date after) { - this.after = after; - return this; - } - /** * Set the documentTitle. * @@ -264,8 +235,6 @@ public Builder includeTotal(Boolean includeTotal) { protected ListFeedbackOptions(Builder builder) { feedbackType = builder.feedbackType; - before = builder.before; - after = builder.after; documentTitle = builder.documentTitle; modelId = builder.modelId; modelVersion = builder.modelVersion; @@ -302,30 +271,6 @@ public String feedbackType() { return feedbackType; } - /** - * Gets the before. - * - *

An optional string in the format `YYYY-MM-DD` that filters the output to include only - * feedback that was added before the specified date. - * - * @return the before - */ - public Date before() { - return before; - } - - /** - * Gets the after. - * - *

An optional string in the format `YYYY-MM-DD` that filters the output to include only - * feedback that was added after the specified date. - * - * @return the after - */ - public Date after() { - return after; - } - /** * Gets the documentTitle. * diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Location.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Location.java index bcb3798c33b..5bde76fd40d 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Location.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Location.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -50,7 +50,7 @@ public Builder(Long begin, Long end) { /** * Builds a Location. * - * @return the location + * @return the new Location instance */ public Location build() { return new Location(this); diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Mention.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Mention.java index 684e0c97a85..807fa60ab00 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Mention.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Mention.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/OriginalLabelsIn.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/OriginalLabelsIn.java index 4ed4e08664b..75cead05b49 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/OriginalLabelsIn.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/OriginalLabelsIn.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -49,7 +49,7 @@ public Builder(List types, List categories) { /** * Builds a OriginalLabelsIn. * - * @return the originalLabelsIn + * @return the new OriginalLabelsIn instance */ public OriginalLabelsIn build() { return new OriginalLabelsIn(this); diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/OriginalLabelsOut.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/OriginalLabelsOut.java index 3b7faab92df..f65df694fe3 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/OriginalLabelsOut.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/OriginalLabelsOut.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -18,22 +18,8 @@ /** The original labeling from the input document, without the submitted feedback. */ public class OriginalLabelsOut extends GenericModel { - /** - * A string identifying the type of modification the feedback entry in the `updated_labels` array. - * Possible values are `added`, `not_changed`, and `removed`. - */ - public interface Modification { - /** added. */ - String ADDED = "added"; - /** not_changed. */ - String NOT_CHANGED = "not_changed"; - /** removed. */ - String REMOVED = "removed"; - } - protected List types; protected List categories; - protected String modification; /** * Gets the types. @@ -57,16 +43,4 @@ public List getTypes() { public List getCategories() { return categories; } - - /** - * Gets the modification. - * - *

A string identifying the type of modification the feedback entry in the `updated_labels` - * array. Possible values are `added`, `not_changed`, and `removed`. - * - * @return the modification - */ - public String getModification() { - return modification; - } } diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Pagination.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Pagination.java index 490a5aeb3db..43727cff425 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Pagination.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Pagination.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Paragraphs.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Paragraphs.java index a7aad9c45f6..eef36dcc58e 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Paragraphs.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Paragraphs.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Parties.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Parties.java index 26693b354ad..9a1307ef194 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Parties.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Parties.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/PaymentTerms.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/PaymentTerms.java index 3cec66f9265..bf09b43d980 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/PaymentTerms.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/PaymentTerms.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/RowHeaders.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/RowHeaders.java index 1a3db3e2bc2..c02ce55fd60 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/RowHeaders.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/RowHeaders.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/SectionTitle.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/SectionTitle.java index b0a5f9211eb..3e972f1cebd 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/SectionTitle.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/SectionTitle.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/SectionTitles.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/SectionTitles.java index d72a6a0b2a6..b2742382b5d 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/SectionTitles.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/SectionTitles.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ShortDoc.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ShortDoc.java index fa8d66a726e..22f831f7abe 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ShortDoc.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ShortDoc.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -36,7 +36,7 @@ public Builder() {} /** * Builds a ShortDoc. * - * @return the shortDoc + * @return the new ShortDoc instance */ public ShortDoc build() { return new ShortDoc(this); diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/TableHeaders.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/TableHeaders.java index 07bee6f213f..0d8c32d1d73 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/TableHeaders.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/TableHeaders.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/TableReturn.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/TableReturn.java index d73283839e8..255dcdd8c47 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/TableReturn.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/TableReturn.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/TableTitle.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/TableTitle.java index 0a1775d7bbf..d1830a91589 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/TableTitle.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/TableTitle.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Tables.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Tables.java index 47482031a1f..d7d9e840966 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Tables.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Tables.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/TerminationDates.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/TerminationDates.java index 559ee05bf16..42844cfd8e6 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/TerminationDates.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/TerminationDates.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/TypeLabel.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/TypeLabel.java index 15e9fd53f6c..91789eab079 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/TypeLabel.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/TypeLabel.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -20,19 +20,33 @@ /** Identification of a specific type. */ public class TypeLabel extends GenericModel { + /** The type of modification of the feedback entry in the updated labels response. */ + public interface Modification { + /** added. */ + String ADDED = "added"; + /** unchanged. */ + String UNCHANGED = "unchanged"; + /** removed. */ + String REMOVED = "removed"; + } + protected Label label; @SerializedName("provenance_ids") protected List provenanceIds; + protected String modification; + /** Builder. */ public static class Builder { private Label label; private List provenanceIds; + private String modification; private Builder(TypeLabel typeLabel) { this.label = typeLabel.label; this.provenanceIds = typeLabel.provenanceIds; + this.modification = typeLabel.modification; } /** Instantiates a new builder. */ @@ -41,7 +55,7 @@ public Builder() {} /** * Builds a TypeLabel. * - * @return the typeLabel + * @return the new TypeLabel instance */ public TypeLabel build() { return new TypeLabel(this); @@ -83,11 +97,23 @@ public Builder provenanceIds(List provenanceIds) { this.provenanceIds = provenanceIds; return this; } + + /** + * Set the modification. + * + * @param modification the modification + * @return the TypeLabel builder + */ + public Builder modification(String modification) { + this.modification = modification; + return this; + } } protected TypeLabel(Builder builder) { label = builder.label; provenanceIds = builder.provenanceIds; + modification = builder.modification; } /** @@ -121,4 +147,15 @@ public Label label() { public List provenanceIds() { return provenanceIds; } + + /** + * Gets the modification. + * + *

The type of modification of the feedback entry in the updated labels response. + * + * @return the modification + */ + public String modification() { + return modification; + } } diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/TypeLabelComparison.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/TypeLabelComparison.java index 76bceb11c14..6780e461370 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/TypeLabelComparison.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/TypeLabelComparison.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/UnalignedElement.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/UnalignedElement.java index 27344755c26..ec898c6b3fb 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/UnalignedElement.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/UnalignedElement.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/UpdateBatchOptions.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/UpdateBatchOptions.java index 37fab408bb3..2ae3c64d88c 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/UpdateBatchOptions.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/UpdateBatchOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -71,7 +71,7 @@ public Builder(String batchId, String action) { /** * Builds a UpdateBatchOptions. * - * @return the updateBatchOptions + * @return the new UpdateBatchOptions instance */ public UpdateBatchOptions build() { return new UpdateBatchOptions(this); diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/UpdatedLabelsIn.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/UpdatedLabelsIn.java index ab1780ae8f7..c13abac243f 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/UpdatedLabelsIn.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/UpdatedLabelsIn.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -49,7 +49,7 @@ public Builder(List types, List categories) { /** * Builds a UpdatedLabelsIn. * - * @return the updatedLabelsIn + * @return the new UpdatedLabelsIn instance */ public UpdatedLabelsIn build() { return new UpdatedLabelsIn(this); diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/UpdatedLabelsOut.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/UpdatedLabelsOut.java index 7303b467b23..3e3a525158e 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/UpdatedLabelsOut.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/UpdatedLabelsOut.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -18,22 +18,8 @@ /** The updated labeling from the input document, accounting for the submitted feedback. */ public class UpdatedLabelsOut extends GenericModel { - /** - * The type of modification the feedback entry in the `updated_labels` array. Possible values are - * `added`, `not_changed`, and `removed`. - */ - public interface Modification { - /** added. */ - String ADDED = "added"; - /** not_changed. */ - String NOT_CHANGED = "not_changed"; - /** removed. */ - String REMOVED = "removed"; - } - protected List types; protected List categories; - protected String modification; /** * Gets the types. @@ -57,16 +43,4 @@ public List getTypes() { public List getCategories() { return categories; } - - /** - * Gets the modification. - * - *

The type of modification the feedback entry in the `updated_labels` array. Possible values - * are `added`, `not_changed`, and `removed`. - * - * @return the modification - */ - public String getModification() { - return modification; - } } diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Value.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Value.java index b14e521807c..5e04c71b3b0 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Value.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/Value.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/package-info.java b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/package-info.java index 0d635624b4a..78264661d3f 100644 --- a/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/package-info.java +++ b/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/package-info.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/CompareComplyTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/CompareComplyTest.java index 4b967b976a1..0f4e77d104b 100644 --- a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/CompareComplyTest.java +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/CompareComplyTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -12,12 +12,12 @@ */ package com.ibm.watson.compare_comply.v1; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.testng.Assert.*; -import com.ibm.cloud.sdk.core.http.HttpMediaType; +import com.ibm.cloud.sdk.core.http.Response; +import com.ibm.cloud.sdk.core.security.Authenticator; import com.ibm.cloud.sdk.core.security.NoAuthAuthenticator; -import com.ibm.watson.common.WatsonServiceUnitTest; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; import com.ibm.watson.compare_comply.v1.model.AddFeedbackOptions; import com.ibm.watson.compare_comply.v1.model.BatchStatus; import com.ibm.watson.compare_comply.v1.model.Batches; @@ -26,16 +26,12 @@ import com.ibm.watson.compare_comply.v1.model.ClassifyReturn; import com.ibm.watson.compare_comply.v1.model.CompareDocumentsOptions; import com.ibm.watson.compare_comply.v1.model.CompareReturn; -import com.ibm.watson.compare_comply.v1.model.ContractAmts; -import com.ibm.watson.compare_comply.v1.model.ContractCurrencies; -import com.ibm.watson.compare_comply.v1.model.ContractTerms; -import com.ibm.watson.compare_comply.v1.model.ContractTypes; import com.ibm.watson.compare_comply.v1.model.ConvertToHtmlOptions; import com.ibm.watson.compare_comply.v1.model.CreateBatchOptions; import com.ibm.watson.compare_comply.v1.model.DeleteFeedbackOptions; -import com.ibm.watson.compare_comply.v1.model.EffectiveDates; import com.ibm.watson.compare_comply.v1.model.ExtractTablesOptions; import com.ibm.watson.compare_comply.v1.model.FeedbackDataInput; +import com.ibm.watson.compare_comply.v1.model.FeedbackDeleted; import com.ibm.watson.compare_comply.v1.model.FeedbackList; import com.ibm.watson.compare_comply.v1.model.FeedbackReturn; import com.ibm.watson.compare_comply.v1.model.GetBatchOptions; @@ -47,1525 +43,817 @@ import com.ibm.watson.compare_comply.v1.model.ListFeedbackOptions; import com.ibm.watson.compare_comply.v1.model.Location; import com.ibm.watson.compare_comply.v1.model.OriginalLabelsIn; -import com.ibm.watson.compare_comply.v1.model.OriginalLabelsOut; -import com.ibm.watson.compare_comply.v1.model.Parties; -import com.ibm.watson.compare_comply.v1.model.PaymentTerms; import com.ibm.watson.compare_comply.v1.model.ShortDoc; import com.ibm.watson.compare_comply.v1.model.TableReturn; -import com.ibm.watson.compare_comply.v1.model.TerminationDates; import com.ibm.watson.compare_comply.v1.model.TypeLabel; import com.ibm.watson.compare_comply.v1.model.UpdateBatchOptions; import com.ibm.watson.compare_comply.v1.model.UpdatedLabelsIn; -import com.ibm.watson.compare_comply.v1.model.UpdatedLabelsOut; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.IOException; import java.io.InputStream; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Collections; -import java.util.Date; -import java.util.Locale; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; import okhttp3.mockwebserver.RecordedRequest; -import org.junit.Before; -import org.junit.Test; - -public class CompareComplyTest extends WatsonServiceUnitTest { - private static final String VERSION = "2018-10-15"; - private static final String RESOURCE = "src/test/resources/compare_comply/"; - - private static final String COMMENT = "comment"; - private static final String USER_ID = "user_id"; - private static final String PROVENANCE_ID = "provenance_id"; - private static final File SAMPLE_PDF = new File(RESOURCE + "test-pdf.pdf"); - private static final String FILENAME = "filename"; - private static final String CONTENT_TYPE_PDF = "application/pdf"; - private static final String LABEL = "label"; - private static final String BUCKET_LOCATION = "bucket_location"; - private static final String BUCKET_NAME = "bucket_name"; - private static final File CREDENTIALS_FILE = new File(RESOURCE + "credentials.json"); - private static final String FEEDBACK_ID = "feedback_id"; - private static final String FEEDBACK_TYPE = "feedback_type"; - private static final String MODEL_ID = "model_id"; - private static final String MODEL_VERSION = "model_version"; - private static final String TEXT = "text"; - private static final String BATCH_ID = "batch_id"; - private static final String NATURE = "nature"; - private static final String PARTY = "party"; - private static final Date DATE = new Date(); - private static final String CATEGORY_ADDED = "category_added"; - private static final String CATEGORY_REMOVED = "category_removed"; - private static final String CATEGORY_NOT_CHANGED = "category_not_changed"; - private static final String DOCUMENT_TITLE = "document_title"; - private static final String SORT = "sort"; - private static final String TYPE_ADDED = "type_added"; - private static final String TYPE_REMOVED = "type_removed"; - private static final String TYPE_NOT_CHANGED = "type_not_changed"; - private static final Long BEGIN = 0L; - private static final Long END = 1L; - private static final Double BEGIN_DOUBLE = 0.0; - private static final Double END_DOUBLE = 1.0; - private static final String HASH = "hash"; - private static final String TITLE = "title"; - private static final String NUM_PAGES = "20"; - private static final String AUTHOR = "author"; - private static final String PUBLICATION_DATE = "06-12-1995"; - private static final String HTML = "html"; - private static final String DOCUMENT_LABEL = "document_label"; - private static final String TYPE = "type"; - private static final String REFRESH_CURSOR = "refresh_cursor"; - private static final String NEXT_CURSOR = "next_cursor"; - private static final String REFRESH_URL = "refresh_url"; - private static final String NEXT_URL = "next_url"; - private static final Long TOTAL = 1000L; - private static final Long PENDING = 300L; - private static final Long SUCCESSFUL = 400L; - private static final Long FAILED = 500L; - private static final String STATUS = "status"; - private static final String CELL_ID = "cell_id"; - private static final Long ROW_INDEX_BEGIN = 2000L; - private static final Long ROW_INDEX_END = 3000L; - private static final Long COLUMN_INDEX_BEGIN = 4000L; - private static final Long COLUMN_INDEX_END = 5000L; - private static final String ID = "id"; - private static final String TEXT_NORMALIZED = "text_normalized"; - private static final Long LEVEL = 12L; - private static final String ROLE = "role"; - private static final String NAME = "name"; - private static final Long PAGE_LIMIT = 7L; - private static final String CURSOR = "cursor"; - private static final String VALUE = "value"; - private static final String UNIT = "unit"; - private static final Double NUMERIC_VALUE = 21.0; - - private static final String CONVERT_TO_HTML_PATH = - String.format("/v1/html_conversion?version=%s", VERSION); - private static final String CLASSIFY_ELEMENTS_PATH = - String.format("/v1/element_classification?version=%s", VERSION); - private static final String EXTRACT_TABLES_PATH = String.format("/v1/tables?version=%s", VERSION); - private static final String COMPARE_DOCUMENTS_PATH = - String.format("/v1/comparison?version=%s", VERSION); - private static final String FEEDBACK_PATH = String.format("/v1/feedback?version=%s", VERSION); - private static final String SPECIFIC_FEEDBACK_PATH = - String.format("/v1/feedback/%s?version=%s", FEEDBACK_ID, VERSION); - private static final String CREATE_BATCH_PATH = - String.format( - "/v1/batches?version=%s&function=%s", - VERSION, CreateBatchOptions.Function.ELEMENT_CLASSIFICATION); - private static final String GET_BATCH_PATH = - String.format("/v1/batches/%s?version=%s", BATCH_ID, VERSION); - private static final String LIST_BATCHES_PATH = String.format("/v1/batches?version=%s", VERSION); - private static final String UPDATE_BATCH_PATH = - String.format( - "/v1/batches/%s?version=%s&action=%s", - BATCH_ID, VERSION, UpdateBatchOptions.Action.CANCEL); - - private CompareComply service; - private Date testDateValue; - private DateFormat dateFormat; - private HTMLReturn convertToHtmlResponse; - private ClassifyReturn classifyElementsResponse; - private TableReturn extractTablesResponse; - private CompareReturn compareDocumentsResponse; - private FeedbackReturn addFeedbackResponse; - private GetFeedback getFeedbackResponse; - private FeedbackList listFeedbackResponse; - private BatchStatus batchStatusResponse; - private Batches batchesResponse; - - /* - * (non-Javadoc) - * @see com.ibm.watson.common.WatsonServiceTest#setUp() - */ - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - - String dateString = "1995-06-12T01:11:11.111+0000"; - dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ", Locale.ENGLISH); - testDateValue = dateFormat.parse(dateString); - - convertToHtmlResponse = loadFixture(RESOURCE + "html-return.json", HTMLReturn.class); - classifyElementsResponse = loadFixture(RESOURCE + "classify-return.json", ClassifyReturn.class); - extractTablesResponse = loadFixture(RESOURCE + "table-return.json", TableReturn.class); - compareDocumentsResponse = loadFixture(RESOURCE + "compare-return.json", CompareReturn.class); - addFeedbackResponse = loadFixture(RESOURCE + "feedback-return.json", FeedbackReturn.class); - getFeedbackResponse = loadFixture(RESOURCE + "get-feedback.json", GetFeedback.class); - listFeedbackResponse = loadFixture(RESOURCE + "feedback-list.json", FeedbackList.class); - batchStatusResponse = loadFixture(RESOURCE + "batch-status.json", BatchStatus.class); - batchesResponse = loadFixture(RESOURCE + "batches.json", Batches.class); - - service = new CompareComply(VERSION, new NoAuthAuthenticator()); - service.setServiceUrl(getMockWebServerUrl()); - } +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; - // --- MODELS --- +/** Unit test class for the CompareComply service. */ +public class CompareComplyTest { - @Test - public void testAddFeedbackOptions() { - Location location = new Location.Builder().begin(BEGIN).end(END).build(); - Category category = new Category.Builder().build(); - TypeLabel typeLabel = new TypeLabel.Builder().build(); - OriginalLabelsIn originalLabelsIn = - new OriginalLabelsIn.Builder() - .categories(Collections.singletonList(category)) - .types(Collections.singletonList(typeLabel)) - .build(); - UpdatedLabelsIn updatedLabelsIn = - new UpdatedLabelsIn.Builder() - .categories(Collections.singletonList(category)) - .types(Collections.singletonList(typeLabel)) - .build(); - FeedbackDataInput feedbackDataInput = - new FeedbackDataInput.Builder() - .feedbackType(FEEDBACK_TYPE) - .location(location) - .originalLabels(originalLabelsIn) - .text(TEXT) - .updatedLabels(updatedLabelsIn) - .build(); + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); - AddFeedbackOptions addFeedbackOptions = - new AddFeedbackOptions.Builder() - .comment(COMMENT) - .feedbackData(feedbackDataInput) - .userId(USER_ID) - .build(); - addFeedbackOptions = addFeedbackOptions.newBuilder().build(); + protected MockWebServer server; + protected CompareComply compareComplyService; + + public void constructClientService() throws Throwable { + final String serviceName = "testService"; + // set mock values for global params + String version = "testString"; + + final Authenticator authenticator = new NoAuthAuthenticator(); - assertEquals(COMMENT, addFeedbackOptions.comment()); - assertEquals(feedbackDataInput, addFeedbackOptions.feedbackData()); - assertEquals(USER_ID, addFeedbackOptions.userId()); + compareComplyService = new CompareComply(version, serviceName, authenticator); + String url = server.url("/").toString(); + compareComplyService.setServiceUrl(url); } - @Test - public void testClassifyElementsOptions() throws FileNotFoundException { - InputStream fileInputStream = new FileInputStream(SAMPLE_PDF); - ClassifyElementsOptions classifyElementsOptions = - new ClassifyElementsOptions.Builder() - .file(fileInputStream) - .fileContentType(HttpMediaType.APPLICATION_PDF) - .model(ClassifyElementsOptions.Model.CONTRACTS) - .build(); - classifyElementsOptions = classifyElementsOptions.newBuilder().build(); + /** Negative Test - construct the service with a null authenticator. */ + @Test(expectedExceptions = IllegalArgumentException.class) + public void testConstructorWithNullAuthenticator() throws Throwable { + final String serviceName = "testService"; + // set mock values for global params + String version = "testString"; - assertEquals(fileInputStream, classifyElementsOptions.file()); - assertEquals(HttpMediaType.APPLICATION_PDF, classifyElementsOptions.fileContentType()); - assertEquals(ClassifyElementsOptions.Model.CONTRACTS, classifyElementsOptions.model()); + new CompareComply(version, serviceName, null); } @Test - public void testCompareDocumentsOptions() throws FileNotFoundException { - InputStream fileInputStream = new FileInputStream(SAMPLE_PDF); - CompareDocumentsOptions compareDocumentsOptions = - new CompareDocumentsOptions.Builder() - .file1(fileInputStream) - .file1ContentType(CONTENT_TYPE_PDF) - .file1Label(LABEL) - .file2(fileInputStream) - .file2ContentType(CONTENT_TYPE_PDF) - .file2Label(LABEL) - .model(CompareDocumentsOptions.Model.CONTRACTS) - .build(); - compareDocumentsOptions = compareDocumentsOptions.newBuilder().build(); - - assertEquals(fileInputStream, compareDocumentsOptions.file1()); - assertEquals(CONTENT_TYPE_PDF, compareDocumentsOptions.file1ContentType()); - assertEquals(LABEL, compareDocumentsOptions.file1Label()); - assertEquals(fileInputStream, compareDocumentsOptions.file2()); - assertEquals(CONTENT_TYPE_PDF, compareDocumentsOptions.file2ContentType()); - assertEquals(LABEL, compareDocumentsOptions.file2Label()); - assertEquals(CompareDocumentsOptions.Model.CONTRACTS, compareDocumentsOptions.model()); + public void testGetVersion() throws Throwable { + constructClientService(); + assertEquals(compareComplyService.getVersion(), "testString"); } @Test - public void testConvertToHtmlOptions() throws FileNotFoundException { - InputStream fileInputStream = new FileInputStream(SAMPLE_PDF); - ConvertToHtmlOptions convertToHtmlOptions = + public void testConvertToHtmlWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"num_pages\": \"numPages\", \"author\": \"author\", \"publication_date\": \"publicationDate\", \"title\": \"title\", \"html\": \"html\"}"; + String convertToHtmlPath = "/v1/html_conversion"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the ConvertToHtmlOptions model + ConvertToHtmlOptions convertToHtmlOptionsModel = new ConvertToHtmlOptions.Builder() - .file(fileInputStream) - .fileContentType(CONTENT_TYPE_PDF) - .model(ConvertToHtmlOptions.Model.CONTRACTS) + .file(TestUtilities.createMockStream("This is a mock file.")) + .fileContentType("application/pdf") + .model("contracts") .build(); - convertToHtmlOptions = convertToHtmlOptions.newBuilder().build(); - assertEquals(fileInputStream, convertToHtmlOptions.file()); - assertEquals(CONTENT_TYPE_PDF, convertToHtmlOptions.fileContentType()); - assertEquals(ConvertToHtmlOptions.Model.CONTRACTS, convertToHtmlOptions.model()); - } + // Invoke operation with valid options model (positive test) + Response response = + compareComplyService.convertToHtml(convertToHtmlOptionsModel).execute(); + assertNotNull(response); + HTMLReturn responseObj = response.getResult(); + assertNotNull(responseObj); - @Test - public void testCreateBatchOptions() throws FileNotFoundException { - InputStream fileInputStream = new FileInputStream(CREDENTIALS_FILE); - CreateBatchOptions createBatchOptions = - new CreateBatchOptions.Builder() - .function(CreateBatchOptions.Function.ELEMENT_CLASSIFICATION) - .inputBucketLocation(BUCKET_LOCATION) - .inputBucketName(BUCKET_NAME) - .inputCredentialsFile(fileInputStream) - .model(CreateBatchOptions.Model.CONTRACTS) - .outputBucketLocation(BUCKET_LOCATION) - .outputBucketName(BUCKET_NAME) - .outputCredentialsFile(fileInputStream) - .build(); - createBatchOptions = createBatchOptions.newBuilder().build(); - - assertEquals(CreateBatchOptions.Function.ELEMENT_CLASSIFICATION, createBatchOptions.function()); - assertEquals(BUCKET_LOCATION, createBatchOptions.inputBucketLocation()); - assertEquals(BUCKET_NAME, createBatchOptions.inputBucketName()); - assertEquals(fileInputStream, createBatchOptions.inputCredentialsFile()); - assertEquals(CreateBatchOptions.Model.CONTRACTS, createBatchOptions.model()); - assertEquals(BUCKET_LOCATION, createBatchOptions.outputBucketLocation()); - assertEquals(BUCKET_NAME, createBatchOptions.outputBucketName()); - assertEquals(fileInputStream, createBatchOptions.outputCredentialsFile()); - } + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(query.get("model"), "contracts"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, convertToHtmlPath); + } + + // Test the convertToHtml operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testConvertToHtmlNoOptions() throws Throwable { + // construct the service + constructClientService(); - @Test - public void testDeleteFeedbackOptions() { - DeleteFeedbackOptions deleteFeedbackOptions = - new DeleteFeedbackOptions.Builder() - .feedbackId(FEEDBACK_ID) - .model(DeleteFeedbackOptions.Model.CONTRACTS) - .build(); - deleteFeedbackOptions = deleteFeedbackOptions.newBuilder().build(); + server.enqueue(new MockResponse()); - assertEquals(FEEDBACK_ID, deleteFeedbackOptions.feedbackId()); - assertEquals(DeleteFeedbackOptions.Model.CONTRACTS, deleteFeedbackOptions.model()); + // Invoke operation with null options model (negative test) + compareComplyService.convertToHtml(null).execute(); } @Test - public void testExtractTablesOptions() throws FileNotFoundException { - InputStream fileInputStream = new FileInputStream(SAMPLE_PDF); - ExtractTablesOptions extractTablesOptions = - new ExtractTablesOptions.Builder() - .file(fileInputStream) - .fileContentType(HttpMediaType.APPLICATION_PDF) - .model(ExtractTablesOptions.Model.TABLES) - .build(); - extractTablesOptions = extractTablesOptions.newBuilder().build(); + public void testClassifyElementsWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"document\": {\"title\": \"title\", \"html\": \"html\", \"hash\": \"hash\", \"label\": \"label\"}, \"model_id\": \"modelId\", \"model_version\": \"modelVersion\", \"elements\": [{\"location\": {\"begin\": 5, \"end\": 3}, \"text\": \"text\", \"types\": [{\"label\": {\"nature\": \"nature\", \"party\": \"party\"}, \"provenance_ids\": [\"provenanceIds\"], \"modification\": \"added\"}], \"categories\": [{\"label\": \"Amendments\", \"provenance_ids\": [\"provenanceIds\"], \"modification\": \"added\"}], \"attributes\": [{\"type\": \"Currency\", \"text\": \"text\", \"location\": {\"begin\": 5, \"end\": 3}}]}], \"effective_dates\": [{\"confidence_level\": \"High\", \"text\": \"text\", \"text_normalized\": \"textNormalized\", \"provenance_ids\": [\"provenanceIds\"], \"location\": {\"begin\": 5, \"end\": 3}}], \"contract_amounts\": [{\"confidence_level\": \"High\", \"text\": \"text\", \"text_normalized\": \"textNormalized\", \"interpretation\": {\"value\": \"value\", \"numeric_value\": 12, \"unit\": \"unit\"}, \"provenance_ids\": [\"provenanceIds\"], \"location\": {\"begin\": 5, \"end\": 3}}], \"termination_dates\": [{\"confidence_level\": \"High\", \"text\": \"text\", \"text_normalized\": \"textNormalized\", \"provenance_ids\": [\"provenanceIds\"], \"location\": {\"begin\": 5, \"end\": 3}}], \"contract_types\": [{\"confidence_level\": \"High\", \"text\": \"text\", \"provenance_ids\": [\"provenanceIds\"], \"location\": {\"begin\": 5, \"end\": 3}}], \"contract_terms\": [{\"confidence_level\": \"High\", \"text\": \"text\", \"text_normalized\": \"textNormalized\", \"interpretation\": {\"value\": \"value\", \"numeric_value\": 12, \"unit\": \"unit\"}, \"provenance_ids\": [\"provenanceIds\"], \"location\": {\"begin\": 5, \"end\": 3}}], \"payment_terms\": [{\"confidence_level\": \"High\", \"text\": \"text\", \"text_normalized\": \"textNormalized\", \"interpretation\": {\"value\": \"value\", \"numeric_value\": 12, \"unit\": \"unit\"}, \"provenance_ids\": [\"provenanceIds\"], \"location\": {\"begin\": 5, \"end\": 3}}], \"contract_currencies\": [{\"confidence_level\": \"High\", \"text\": \"text\", \"text_normalized\": \"textNormalized\", \"provenance_ids\": [\"provenanceIds\"], \"location\": {\"begin\": 5, \"end\": 3}}], \"tables\": [{\"location\": {\"begin\": 5, \"end\": 3}, \"text\": \"text\", \"section_title\": {\"text\": \"text\", \"location\": {\"begin\": 5, \"end\": 3}}, \"title\": {\"location\": {\"begin\": 5, \"end\": 3}, \"text\": \"text\"}, \"table_headers\": [{\"cell_id\": \"cellId\", \"location\": {\"mapKey\": \"anyValue\"}, \"text\": \"text\", \"row_index_begin\": 13, \"row_index_end\": 11, \"column_index_begin\": 16, \"column_index_end\": 14}], \"row_headers\": [{\"cell_id\": \"cellId\", \"location\": {\"begin\": 5, \"end\": 3}, \"text\": \"text\", \"text_normalized\": \"textNormalized\", \"row_index_begin\": 13, \"row_index_end\": 11, \"column_index_begin\": 16, \"column_index_end\": 14}], \"column_headers\": [{\"cell_id\": \"cellId\", \"location\": {\"mapKey\": \"anyValue\"}, \"text\": \"text\", \"text_normalized\": \"textNormalized\", \"row_index_begin\": 13, \"row_index_end\": 11, \"column_index_begin\": 16, \"column_index_end\": 14}], \"body_cells\": [{\"cell_id\": \"cellId\", \"location\": {\"begin\": 5, \"end\": 3}, \"text\": \"text\", \"row_index_begin\": 13, \"row_index_end\": 11, \"column_index_begin\": 16, \"column_index_end\": 14, \"row_header_ids\": [\"rowHeaderIds\"], \"row_header_texts\": [\"rowHeaderTexts\"], \"row_header_texts_normalized\": [\"rowHeaderTextsNormalized\"], \"column_header_ids\": [\"columnHeaderIds\"], \"column_header_texts\": [\"columnHeaderTexts\"], \"column_header_texts_normalized\": [\"columnHeaderTextsNormalized\"], \"attributes\": [{\"type\": \"Currency\", \"text\": \"text\", \"location\": {\"begin\": 5, \"end\": 3}}]}], \"contexts\": [{\"text\": \"text\", \"location\": {\"begin\": 5, \"end\": 3}}], \"key_value_pairs\": [{\"key\": {\"cell_id\": \"cellId\", \"location\": {\"begin\": 5, \"end\": 3}, \"text\": \"text\"}, \"value\": [{\"cell_id\": \"cellId\", \"location\": {\"begin\": 5, \"end\": 3}, \"text\": \"text\"}]}]}], \"document_structure\": {\"section_titles\": [{\"text\": \"text\", \"location\": {\"begin\": 5, \"end\": 3}, \"level\": 5, \"element_locations\": [{\"begin\": 5, \"end\": 3}]}], \"leading_sentences\": [{\"text\": \"text\", \"location\": {\"begin\": 5, \"end\": 3}, \"element_locations\": [{\"begin\": 5, \"end\": 3}]}], \"paragraphs\": [{\"location\": {\"begin\": 5, \"end\": 3}}]}, \"parties\": [{\"party\": \"party\", \"role\": \"role\", \"importance\": \"Primary\", \"addresses\": [{\"text\": \"text\", \"location\": {\"begin\": 5, \"end\": 3}}], \"contacts\": [{\"name\": \"name\", \"role\": \"role\"}], \"mentions\": [{\"text\": \"text\", \"location\": {\"begin\": 5, \"end\": 3}}]}]}"; + String classifyElementsPath = "/v1/element_classification"; - assertEquals(fileInputStream, extractTablesOptions.file()); - assertEquals(HttpMediaType.APPLICATION_PDF, extractTablesOptions.fileContentType()); - assertEquals(ExtractTablesOptions.Model.TABLES, extractTablesOptions.model()); - } + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); - @Test - public void testFeedbackDataInput() { - ShortDoc shortDoc = new ShortDoc.Builder().build(); - Location location = new Location.Builder().begin(BEGIN).end(END).build(); - Category category = new Category.Builder().build(); - TypeLabel typeLabel = new TypeLabel.Builder().build(); - OriginalLabelsIn originalLabelsIn = - new OriginalLabelsIn.Builder() - .categories(Collections.singletonList(category)) - .types(Collections.singletonList(typeLabel)) - .build(); - UpdatedLabelsIn updatedLabelsIn = - new UpdatedLabelsIn.Builder() - .categories(Collections.singletonList(category)) - .types(Collections.singletonList(typeLabel)) - .build(); + constructClientService(); - FeedbackDataInput feedbackDataInput = - new FeedbackDataInput.Builder() - .document(shortDoc) - .feedbackType(FEEDBACK_TYPE) - .location(location) - .modelId(MODEL_ID) - .modelVersion(MODEL_VERSION) - .originalLabels(originalLabelsIn) - .text(TEXT) - .updatedLabels(updatedLabelsIn) + // Construct an instance of the ClassifyElementsOptions model + ClassifyElementsOptions classifyElementsOptionsModel = + new ClassifyElementsOptions.Builder() + .file(TestUtilities.createMockStream("This is a mock file.")) + .fileContentType("application/pdf") + .model("contracts") .build(); - assertEquals(shortDoc, feedbackDataInput.document()); - assertEquals(FEEDBACK_TYPE, feedbackDataInput.feedbackType()); - assertEquals(location, feedbackDataInput.location()); - assertEquals(MODEL_ID, feedbackDataInput.modelId()); - assertEquals(MODEL_VERSION, feedbackDataInput.modelVersion()); - assertEquals(originalLabelsIn, feedbackDataInput.originalLabels()); - assertEquals(TEXT, feedbackDataInput.text()); - assertEquals(updatedLabelsIn, feedbackDataInput.updatedLabels()); - } + // Invoke operation with valid options model (positive test) + Response response = + compareComplyService.classifyElements(classifyElementsOptionsModel).execute(); + assertNotNull(response); + ClassifyReturn responseObj = response.getResult(); + assertNotNull(responseObj); - @Test - public void testListBatchesOptions() { - ListBatchesOptions listBatchesOptions = new ListBatchesOptions.Builder().build(); - ListBatchesOptions newListBatchesOptions = listBatchesOptions.newBuilder().build(); + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(query.get("model"), "contracts"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, classifyElementsPath); + } + + // Test the classifyElements operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testClassifyElementsNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); - assertEquals(listBatchesOptions, newListBatchesOptions); + // Invoke operation with null options model (negative test) + compareComplyService.classifyElements(null).execute(); } @Test - public void testGetBatchOptions() { - GetBatchOptions getBatchOptions = new GetBatchOptions.Builder().batchId(BATCH_ID).build(); - getBatchOptions = getBatchOptions.newBuilder().build(); + public void testExtractTablesWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"document\": {\"html\": \"html\", \"title\": \"title\", \"hash\": \"hash\"}, \"model_id\": \"modelId\", \"model_version\": \"modelVersion\", \"tables\": [{\"location\": {\"begin\": 5, \"end\": 3}, \"text\": \"text\", \"section_title\": {\"text\": \"text\", \"location\": {\"begin\": 5, \"end\": 3}}, \"title\": {\"location\": {\"begin\": 5, \"end\": 3}, \"text\": \"text\"}, \"table_headers\": [{\"cell_id\": \"cellId\", \"location\": {\"mapKey\": \"anyValue\"}, \"text\": \"text\", \"row_index_begin\": 13, \"row_index_end\": 11, \"column_index_begin\": 16, \"column_index_end\": 14}], \"row_headers\": [{\"cell_id\": \"cellId\", \"location\": {\"begin\": 5, \"end\": 3}, \"text\": \"text\", \"text_normalized\": \"textNormalized\", \"row_index_begin\": 13, \"row_index_end\": 11, \"column_index_begin\": 16, \"column_index_end\": 14}], \"column_headers\": [{\"cell_id\": \"cellId\", \"location\": {\"mapKey\": \"anyValue\"}, \"text\": \"text\", \"text_normalized\": \"textNormalized\", \"row_index_begin\": 13, \"row_index_end\": 11, \"column_index_begin\": 16, \"column_index_end\": 14}], \"body_cells\": [{\"cell_id\": \"cellId\", \"location\": {\"begin\": 5, \"end\": 3}, \"text\": \"text\", \"row_index_begin\": 13, \"row_index_end\": 11, \"column_index_begin\": 16, \"column_index_end\": 14, \"row_header_ids\": [\"rowHeaderIds\"], \"row_header_texts\": [\"rowHeaderTexts\"], \"row_header_texts_normalized\": [\"rowHeaderTextsNormalized\"], \"column_header_ids\": [\"columnHeaderIds\"], \"column_header_texts\": [\"columnHeaderTexts\"], \"column_header_texts_normalized\": [\"columnHeaderTextsNormalized\"], \"attributes\": [{\"type\": \"Currency\", \"text\": \"text\", \"location\": {\"begin\": 5, \"end\": 3}}]}], \"contexts\": [{\"text\": \"text\", \"location\": {\"begin\": 5, \"end\": 3}}], \"key_value_pairs\": [{\"key\": {\"cell_id\": \"cellId\", \"location\": {\"begin\": 5, \"end\": 3}, \"text\": \"text\"}, \"value\": [{\"cell_id\": \"cellId\", \"location\": {\"begin\": 5, \"end\": 3}, \"text\": \"text\"}]}]}]}"; + String extractTablesPath = "/v1/tables"; - assertEquals(BATCH_ID, getBatchOptions.batchId()); - } + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); - @Test - public void testGetFeedbackOptions() { - GetFeedbackOptions getFeedbackOptions = - new GetFeedbackOptions.Builder() - .feedbackId(FEEDBACK_ID) - .model(GetFeedbackOptions.Model.CONTRACTS) + constructClientService(); + + // Construct an instance of the ExtractTablesOptions model + ExtractTablesOptions extractTablesOptionsModel = + new ExtractTablesOptions.Builder() + .file(TestUtilities.createMockStream("This is a mock file.")) + .fileContentType("application/pdf") + .model("contracts") .build(); - getFeedbackOptions = getFeedbackOptions.newBuilder().build(); - assertEquals(FEEDBACK_ID, getFeedbackOptions.feedbackId()); - assertEquals(GetFeedbackOptions.Model.CONTRACTS, getFeedbackOptions.model()); - } + // Invoke operation with valid options model (positive test) + Response response = + compareComplyService.extractTables(extractTablesOptionsModel).execute(); + assertNotNull(response); + TableReturn responseObj = response.getResult(); + assertNotNull(responseObj); - @Test - public void testLabel() { - Label label = new Label.Builder().nature(NATURE).party(PARTY).build(); + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(query.get("model"), "contracts"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, extractTablesPath); + } + + // Test the extractTables operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testExtractTablesNoOptions() throws Throwable { + // construct the service + constructClientService(); - assertEquals(NATURE, label.nature()); - assertEquals(PARTY, label.party()); - } + server.enqueue(new MockResponse()); - @Test - public void testListFeedbackOptions() { - ListFeedbackOptions listFeedbackOptions = - new ListFeedbackOptions.Builder() - .after(DATE) - .before(DATE) - .categoryAdded(CATEGORY_ADDED) - .categoryRemoved(CATEGORY_REMOVED) - .categoryNotChanged(CATEGORY_NOT_CHANGED) - .pageLimit(PAGE_LIMIT) - .documentTitle(DOCUMENT_TITLE) - .feedbackType(FEEDBACK_TYPE) - .includeTotal(true) - .modelId(MODEL_ID) - .modelVersion(MODEL_VERSION) - .cursor(CURSOR) - .sort(SORT) - .typeAdded(TYPE_ADDED) - .typeRemoved(TYPE_REMOVED) - .typeNotChanged(TYPE_NOT_CHANGED) - .build(); - listFeedbackOptions = listFeedbackOptions.newBuilder().build(); - - assertEquals(DATE, listFeedbackOptions.after()); - assertEquals(DATE, listFeedbackOptions.before()); - assertEquals(CATEGORY_ADDED, listFeedbackOptions.categoryAdded()); - assertEquals(CATEGORY_REMOVED, listFeedbackOptions.categoryRemoved()); - assertEquals(CATEGORY_NOT_CHANGED, listFeedbackOptions.categoryNotChanged()); - assertEquals(PAGE_LIMIT, listFeedbackOptions.pageLimit()); - assertEquals(DOCUMENT_TITLE, listFeedbackOptions.documentTitle()); - assertEquals(FEEDBACK_TYPE, listFeedbackOptions.feedbackType()); - assertEquals(MODEL_ID, listFeedbackOptions.modelId()); - assertEquals(MODEL_VERSION, listFeedbackOptions.modelVersion()); - assertEquals(CURSOR, listFeedbackOptions.cursor()); - assertEquals(TYPE_ADDED, listFeedbackOptions.typeAdded()); - assertEquals(TYPE_REMOVED, listFeedbackOptions.typeRemoved()); - assertEquals(TYPE_NOT_CHANGED, listFeedbackOptions.typeNotChanged()); - assertEquals(true, listFeedbackOptions.includeTotal()); + // Invoke operation with null options model (negative test) + compareComplyService.extractTables(null).execute(); } @Test - public void testLocation() { - Location location = new Location.Builder().begin(BEGIN).end(END).build(); + public void testCompareDocumentsWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"model_id\": \"modelId\", \"model_version\": \"modelVersion\", \"documents\": [{\"title\": \"title\", \"html\": \"html\", \"hash\": \"hash\", \"label\": \"label\"}], \"aligned_elements\": [{\"element_pair\": [{\"document_label\": \"documentLabel\", \"text\": \"text\", \"location\": {\"begin\": 5, \"end\": 3}, \"types\": [{\"label\": {\"nature\": \"nature\", \"party\": \"party\"}}], \"categories\": [{\"label\": \"Amendments\"}], \"attributes\": [{\"type\": \"Currency\", \"text\": \"text\", \"location\": {\"begin\": 5, \"end\": 3}}]}], \"identical_text\": false, \"provenance_ids\": [\"provenanceIds\"], \"significant_elements\": false}], \"unaligned_elements\": [{\"document_label\": \"documentLabel\", \"location\": {\"begin\": 5, \"end\": 3}, \"text\": \"text\", \"types\": [{\"label\": {\"nature\": \"nature\", \"party\": \"party\"}}], \"categories\": [{\"label\": \"Amendments\"}], \"attributes\": [{\"type\": \"Currency\", \"text\": \"text\", \"location\": {\"begin\": 5, \"end\": 3}}]}]}"; + String compareDocumentsPath = "/v1/comparison"; - assertEquals(BEGIN, location.begin()); - assertEquals(END, location.end()); - } + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); - @Test - public void testOriginalLabelsIn() { - Category category = new Category.Builder().build(); - TypeLabel typeLabel = new TypeLabel.Builder().build(); - OriginalLabelsIn originalLabelsIn = - new OriginalLabelsIn.Builder() - .categories(Collections.singletonList(category)) - .types(Collections.singletonList(typeLabel)) + constructClientService(); + + // Construct an instance of the CompareDocumentsOptions model + CompareDocumentsOptions compareDocumentsOptionsModel = + new CompareDocumentsOptions.Builder() + .file1(TestUtilities.createMockStream("This is a mock file.")) + .file2(TestUtilities.createMockStream("This is a mock file.")) + .file1ContentType("application/pdf") + .file2ContentType("application/pdf") + .file1Label("testString") + .file2Label("testString") + .model("contracts") .build(); - assertEquals(category, originalLabelsIn.categories().get(0)); - assertEquals(typeLabel, originalLabelsIn.types().get(0)); - } + // Invoke operation with valid options model (positive test) + Response response = + compareComplyService.compareDocuments(compareDocumentsOptionsModel).execute(); + assertNotNull(response); + CompareReturn responseObj = response.getResult(); + assertNotNull(responseObj); - @Test - public void testShortDoc() { - ShortDoc shortDoc = new ShortDoc.Builder().hash(HASH).title(TITLE).build(); + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(query.get("file_1_label"), "testString"); + assertEquals(query.get("file_2_label"), "testString"); + assertEquals(query.get("model"), "contracts"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, compareDocumentsPath); + } + + // Test the compareDocuments operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCompareDocumentsNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); - assertEquals(HASH, shortDoc.hash()); - assertEquals(TITLE, shortDoc.title()); + // Invoke operation with null options model (negative test) + compareComplyService.compareDocuments(null).execute(); } @Test - public void testTypeLabel() { - Label label = new Label.Builder().nature(NATURE).party(PARTY).build(); - TypeLabel typeLabel = + public void testAddFeedbackWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"feedback_id\": \"feedbackId\", \"user_id\": \"userId\", \"comment\": \"comment\", \"created\": \"2019-01-01T12:00:00\", \"feedback_data\": {\"feedback_type\": \"feedbackType\", \"document\": {\"title\": \"title\", \"hash\": \"hash\"}, \"model_id\": \"modelId\", \"model_version\": \"modelVersion\", \"location\": {\"begin\": 5, \"end\": 3}, \"text\": \"text\", \"original_labels\": {\"types\": [{\"label\": {\"nature\": \"nature\", \"party\": \"party\"}, \"provenance_ids\": [\"provenanceIds\"], \"modification\": \"added\"}], \"categories\": [{\"label\": \"Amendments\", \"provenance_ids\": [\"provenanceIds\"], \"modification\": \"added\"}]}, \"updated_labels\": {\"types\": [{\"label\": {\"nature\": \"nature\", \"party\": \"party\"}, \"provenance_ids\": [\"provenanceIds\"], \"modification\": \"added\"}], \"categories\": [{\"label\": \"Amendments\", \"provenance_ids\": [\"provenanceIds\"], \"modification\": \"added\"}]}, \"pagination\": {\"refresh_cursor\": \"refreshCursor\", \"next_cursor\": \"nextCursor\", \"refresh_url\": \"refreshUrl\", \"next_url\": \"nextUrl\", \"total\": 5}}}"; + String addFeedbackPath = "/v1/feedback"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the ShortDoc model + ShortDoc shortDocModel = new ShortDoc.Builder().title("testString").hash("testString").build(); + + // Construct an instance of the Location model + Location locationModel = + new Location.Builder().begin(Long.valueOf("26")).end(Long.valueOf("26")).build(); + + // Construct an instance of the Label model + Label labelModel = new Label.Builder().nature("testString").party("testString").build(); + + // Construct an instance of the TypeLabel model + TypeLabel typeLabelModel = new TypeLabel.Builder() - .label(label) - .provenanceIds(Collections.singletonList(PROVENANCE_ID)) + .label(labelModel) + .provenanceIds(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .modification("added") .build(); - assertEquals(label, typeLabel.label()); - assertEquals(PROVENANCE_ID, typeLabel.provenanceIds().get(0)); - } - - @Test - public void testUpdateBatchOptions() { - UpdateBatchOptions updateBatchOptions = - new UpdateBatchOptions.Builder() - .action(UpdateBatchOptions.Action.CANCEL) - .batchId(BATCH_ID) - .model(UpdateBatchOptions.Model.CONTRACTS) + // Construct an instance of the Category model + Category categoryModel = + new Category.Builder() + .label("Amendments") + .provenanceIds(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .modification("added") .build(); - updateBatchOptions = updateBatchOptions.newBuilder().build(); - assertEquals(UpdateBatchOptions.Action.CANCEL, updateBatchOptions.action()); - assertEquals(BATCH_ID, updateBatchOptions.batchId()); - assertEquals(UpdateBatchOptions.Model.CONTRACTS, updateBatchOptions.model()); - } + // Construct an instance of the OriginalLabelsIn model + OriginalLabelsIn originalLabelsInModel = + new OriginalLabelsIn.Builder() + .types(new java.util.ArrayList(java.util.Arrays.asList(typeLabelModel))) + .categories(new java.util.ArrayList(java.util.Arrays.asList(categoryModel))) + .build(); - @Test - public void testUpdatedLabelsIn() { - Category category = new Category.Builder().build(); - TypeLabel typeLabel = new TypeLabel.Builder().build(); - UpdatedLabelsIn updatedLabelsIn = + // Construct an instance of the UpdatedLabelsIn model + UpdatedLabelsIn updatedLabelsInModel = new UpdatedLabelsIn.Builder() - .categories(Collections.singletonList(category)) - .types(Collections.singletonList(typeLabel)) + .types(new java.util.ArrayList(java.util.Arrays.asList(typeLabelModel))) + .categories(new java.util.ArrayList(java.util.Arrays.asList(categoryModel))) .build(); - assertEquals(category, updatedLabelsIn.categories().get(0)); - assertEquals(typeLabel, updatedLabelsIn.types().get(0)); - } + // Construct an instance of the FeedbackDataInput model + FeedbackDataInput feedbackDataInputModel = + new FeedbackDataInput.Builder() + .feedbackType("testString") + .document(shortDocModel) + .modelId("testString") + .modelVersion("testString") + .location(locationModel) + .text("testString") + .originalLabels(originalLabelsInModel) + .updatedLabels(updatedLabelsInModel) + .build(); - // --- METHODS --- + // Construct an instance of the AddFeedbackOptions model + AddFeedbackOptions addFeedbackOptionsModel = + new AddFeedbackOptions.Builder() + .feedbackData(feedbackDataInputModel) + .userId("testString") + .comment("testString") + .build(); - @Test - public void testConvertToHtml() throws FileNotFoundException, InterruptedException { - server.enqueue(jsonResponse(convertToHtmlResponse)); + // Invoke operation with valid options model (positive test) + Response response = + compareComplyService.addFeedback(addFeedbackOptionsModel).execute(); + assertNotNull(response); + FeedbackReturn responseObj = response.getResult(); + assertNotNull(responseObj); - ConvertToHtmlOptions convertToHtmlOptions = - new ConvertToHtmlOptions.Builder().file(SAMPLE_PDF).build(); - HTMLReturn response = service.convertToHtml(convertToHtmlOptions).execute().getResult(); + // Verify the contents of the request RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); - assertEquals(CONVERT_TO_HTML_PATH, request.getPath()); - assertEquals(NUM_PAGES, response.getNumPages()); - assertEquals(AUTHOR, response.getAuthor()); - assertEquals(PUBLICATION_DATE, response.getPublicationDate()); - assertEquals(TITLE, response.getTitle()); - assertEquals(HTML, response.getHtml()); + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, addFeedbackPath); } - @Test - public void testClassifyElements() throws FileNotFoundException, InterruptedException { - server.enqueue(jsonResponse(classifyElementsResponse)); + // Test the addFeedback operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAddFeedbackNoOptions() throws Throwable { + // construct the service + constructClientService(); - ClassifyElementsOptions classifyElementsOptions = - new ClassifyElementsOptions.Builder().file(SAMPLE_PDF).build(); - ClassifyReturn response = - service.classifyElements(classifyElementsOptions).execute().getResult(); - RecordedRequest request = server.takeRequest(); + server.enqueue(new MockResponse()); - assertEquals(CLASSIFY_ELEMENTS_PATH, request.getPath()); - assertEquals(TITLE, response.getDocument().getTitle()); - assertEquals(HTML, response.getDocument().getHtml()); - assertEquals(HASH, response.getDocument().getHash()); - assertEquals(LABEL, response.getDocument().getLabel()); - assertEquals(MODEL_ID, response.getModelId()); - assertEquals(MODEL_VERSION, response.getModelVersion()); - assertEquals(BEGIN, response.getElements().get(0).getLocation().begin()); - assertEquals(END, response.getElements().get(0).getLocation().end()); - assertEquals(TEXT, response.getElements().get(0).getText()); - assertEquals(NATURE, response.getElements().get(0).getTypes().get(0).label().nature()); - assertEquals(PARTY, response.getElements().get(0).getTypes().get(0).label().party()); - assertEquals( - PROVENANCE_ID, response.getElements().get(0).getTypes().get(0).provenanceIds().get(0)); - assertEquals(LABEL, response.getElements().get(0).getCategories().get(0).label()); - assertEquals( - PROVENANCE_ID, response.getElements().get(0).getCategories().get(0).provenanceIds().get(0)); - assertEquals(TYPE, response.getElements().get(0).getAttributes().get(0).getType()); - assertEquals(TEXT, response.getElements().get(0).getAttributes().get(0).getText()); - assertEquals(BEGIN, response.getElements().get(0).getAttributes().get(0).getLocation().begin()); - assertEquals(END, response.getElements().get(0).getAttributes().get(0).getLocation().end()); - assertEquals(BEGIN, response.getTables().get(0).getLocation().begin()); - assertEquals(END, response.getTables().get(0).getLocation().end()); - assertEquals(TEXT, response.getTables().get(0).getText()); - assertEquals(BEGIN, response.getTables().get(0).getSectionTitle().getLocation().begin()); - assertEquals(END, response.getTables().get(0).getSectionTitle().getLocation().end()); - assertEquals(CELL_ID, response.getTables().get(0).getTableHeaders().get(0).getCellId()); - assertEquals( - BEGIN_DOUBLE, - response.getTables().get(0).getTableHeaders().get(0).getLocation().get("begin")); - assertEquals( - END_DOUBLE, response.getTables().get(0).getTableHeaders().get(0).getLocation().get("end")); - assertEquals(TEXT, response.getTables().get(0).getTableHeaders().get(0).getText()); - assertEquals( - ROW_INDEX_BEGIN, response.getTables().get(0).getTableHeaders().get(0).getRowIndexBegin()); - assertEquals( - ROW_INDEX_END, response.getTables().get(0).getTableHeaders().get(0).getRowIndexEnd()); - assertEquals( - COLUMN_INDEX_BEGIN, - response.getTables().get(0).getTableHeaders().get(0).getColumnIndexBegin()); - assertEquals( - COLUMN_INDEX_END, response.getTables().get(0).getTableHeaders().get(0).getColumnIndexEnd()); - assertEquals(CELL_ID, response.getTables().get(0).getColumnHeaders().get(0).getCellId()); - assertEquals( - BEGIN_DOUBLE, - response.getTables().get(0).getColumnHeaders().get(0).getLocation().get("begin")); - assertEquals( - END_DOUBLE, response.getTables().get(0).getColumnHeaders().get(0).getLocation().get("end")); - assertEquals(TEXT, response.getTables().get(0).getColumnHeaders().get(0).getText()); - assertEquals( - TEXT_NORMALIZED, response.getTables().get(0).getColumnHeaders().get(0).getTextNormalized()); - assertEquals( - ROW_INDEX_BEGIN, response.getTables().get(0).getColumnHeaders().get(0).getRowIndexBegin()); - assertEquals( - ROW_INDEX_END, response.getTables().get(0).getColumnHeaders().get(0).getRowIndexEnd()); - assertEquals( - COLUMN_INDEX_BEGIN, - response.getTables().get(0).getColumnHeaders().get(0).getColumnIndexBegin()); - assertEquals( - COLUMN_INDEX_END, - response.getTables().get(0).getColumnHeaders().get(0).getColumnIndexEnd()); - assertEquals(CELL_ID, response.getTables().get(0).getRowHeaders().get(0).getCellId()); - assertEquals(BEGIN, response.getTables().get(0).getRowHeaders().get(0).getLocation().begin()); - assertEquals(END, response.getTables().get(0).getRowHeaders().get(0).getLocation().end()); - assertEquals(TEXT, response.getTables().get(0).getRowHeaders().get(0).getText()); - assertEquals( - TEXT_NORMALIZED, response.getTables().get(0).getRowHeaders().get(0).getTextNormalized()); - assertEquals( - ROW_INDEX_BEGIN, response.getTables().get(0).getRowHeaders().get(0).getRowIndexBegin()); - assertEquals( - ROW_INDEX_END, response.getTables().get(0).getRowHeaders().get(0).getRowIndexEnd()); - assertEquals( - COLUMN_INDEX_BEGIN, - response.getTables().get(0).getRowHeaders().get(0).getColumnIndexBegin()); - assertEquals( - COLUMN_INDEX_END, response.getTables().get(0).getRowHeaders().get(0).getColumnIndexEnd()); - assertEquals(CELL_ID, response.getTables().get(0).getBodyCells().get(0).getCellId()); - assertEquals(BEGIN, response.getTables().get(0).getBodyCells().get(0).getLocation().begin()); - assertEquals(END, response.getTables().get(0).getBodyCells().get(0).getLocation().end()); - assertEquals(TEXT, response.getTables().get(0).getBodyCells().get(0).getText()); - assertEquals( - ROW_INDEX_BEGIN, response.getTables().get(0).getBodyCells().get(0).getRowIndexBegin()); - assertEquals(ROW_INDEX_END, response.getTables().get(0).getBodyCells().get(0).getRowIndexEnd()); - assertEquals( - COLUMN_INDEX_BEGIN, - response.getTables().get(0).getBodyCells().get(0).getColumnIndexBegin()); - assertEquals( - COLUMN_INDEX_END, response.getTables().get(0).getBodyCells().get(0).getColumnIndexEnd()); - assertEquals(ID, response.getTables().get(0).getBodyCells().get(0).getRowHeaderIds().get(0)); - assertEquals( - TEXT, response.getTables().get(0).getBodyCells().get(0).getRowHeaderTexts().get(0)); - assertEquals( - TEXT_NORMALIZED, - response.getTables().get(0).getBodyCells().get(0).getRowHeaderTextsNormalized().get(0)); - assertEquals(ID, response.getTables().get(0).getBodyCells().get(0).getColumnHeaderIds().get(0)); - assertEquals( - TEXT, response.getTables().get(0).getBodyCells().get(0).getColumnHeaderTexts().get(0)); - assertEquals( - TEXT_NORMALIZED, - response.getTables().get(0).getBodyCells().get(0).getColumnHeaderTextsNormalized().get(0)); - assertEquals( - TYPE, response.getTables().get(0).getBodyCells().get(0).getAttributes().get(0).getType()); - assertEquals( - TEXT, response.getTables().get(0).getBodyCells().get(0).getAttributes().get(0).getText()); - assertEquals( - BEGIN, - response - .getTables() - .get(0) - .getBodyCells() - .get(0) - .getAttributes() - .get(0) - .getLocation() - .begin()); - assertEquals( - END, - response - .getTables() - .get(0) - .getBodyCells() - .get(0) - .getAttributes() - .get(0) - .getLocation() - .end()); - assertEquals( - CELL_ID, response.getTables().get(0).getKeyValuePairs().get(0).getKey().getCellId()); - assertEquals( - BEGIN, - response.getTables().get(0).getKeyValuePairs().get(0).getKey().getLocation().begin()); - assertEquals( - END, response.getTables().get(0).getKeyValuePairs().get(0).getKey().getLocation().end()); - assertEquals(TEXT, response.getTables().get(0).getKeyValuePairs().get(0).getKey().getText()); - assertEquals( - CELL_ID, - response.getTables().get(0).getKeyValuePairs().get(0).getValue().get(0).getCellId()); - assertEquals( - BEGIN, - response - .getTables() - .get(0) - .getKeyValuePairs() - .get(0) - .getValue() - .get(0) - .getLocation() - .begin()); - assertEquals( - END, - response - .getTables() - .get(0) - .getKeyValuePairs() - .get(0) - .getValue() - .get(0) - .getLocation() - .end()); - assertEquals( - TEXT, response.getTables().get(0).getKeyValuePairs().get(0).getValue().get(0).getText()); - assertEquals(TEXT, response.getTables().get(0).getTitle().getText()); - assertEquals(BEGIN, response.getTables().get(0).getTitle().getLocation().begin()); - assertEquals(END, response.getTables().get(0).getTitle().getLocation().end()); - assertEquals(TEXT, response.getTables().get(0).getContexts().get(0).getText()); - assertEquals(BEGIN, response.getTables().get(0).getContexts().get(0).getLocation().begin()); - assertEquals(END, response.getTables().get(0).getContexts().get(0).getLocation().end()); - assertEquals(TEXT, response.getDocumentStructure().getSectionTitles().get(0).getText()); - assertEquals( - BEGIN, response.getDocumentStructure().getSectionTitles().get(0).getLocation().begin()); - assertEquals( - END, response.getDocumentStructure().getSectionTitles().get(0).getLocation().end()); - assertEquals(LEVEL, response.getDocumentStructure().getSectionTitles().get(0).getLevel()); - assertEquals( - BEGIN, - response - .getDocumentStructure() - .getSectionTitles() - .get(0) - .getElementLocations() - .get(0) - .getBegin()); - assertEquals( - END, - response - .getDocumentStructure() - .getSectionTitles() - .get(0) - .getElementLocations() - .get(0) - .getEnd()); - assertEquals(TEXT, response.getDocumentStructure().getLeadingSentences().get(0).getText()); - assertEquals( - BEGIN, response.getDocumentStructure().getLeadingSentences().get(0).getLocation().begin()); - assertEquals( - END, response.getDocumentStructure().getLeadingSentences().get(0).getLocation().end()); - assertEquals( - BEGIN, - response - .getDocumentStructure() - .getLeadingSentences() - .get(0) - .getElementLocations() - .get(0) - .getBegin()); - assertEquals( - END, - response - .getDocumentStructure() - .getLeadingSentences() - .get(0) - .getElementLocations() - .get(0) - .getEnd()); - assertEquals( - BEGIN, response.getDocumentStructure().getParagraphs().get(0).getLocation().begin()); - assertEquals(END, response.getDocumentStructure().getParagraphs().get(0).getLocation().end()); - assertEquals(PARTY, response.getParties().get(0).getParty()); - assertEquals(Parties.Importance.UNKNOWN, response.getParties().get(0).getImportance()); - assertEquals(ROLE, response.getParties().get(0).getRole()); - assertEquals(TEXT, response.getParties().get(0).getAddresses().get(0).getText()); - assertEquals(BEGIN, response.getParties().get(0).getAddresses().get(0).getLocation().begin()); - assertEquals(END, response.getParties().get(0).getAddresses().get(0).getLocation().end()); - assertEquals(NAME, response.getParties().get(0).getContacts().get(0).getName()); - assertEquals(ROLE, response.getParties().get(0).getContacts().get(0).getRole()); - assertEquals(TEXT, response.getParties().get(0).getMentions().get(0).getText()); - assertEquals(BEGIN, response.getParties().get(0).getMentions().get(0).getLocation().begin()); - assertEquals(END, response.getParties().get(0).getMentions().get(0).getLocation().end()); - assertEquals(TEXT, response.getEffectiveDates().get(0).getText()); - assertEquals(BEGIN, response.getEffectiveDates().get(0).getLocation().begin()); - assertEquals(END, response.getEffectiveDates().get(0).getLocation().end()); - assertEquals( - EffectiveDates.ConfidenceLevel.HIGH, - response.getEffectiveDates().get(0).getConfidenceLevel()); - assertEquals(TEXT_NORMALIZED, response.getEffectiveDates().get(0).getTextNormalized()); - assertEquals(PROVENANCE_ID, response.getEffectiveDates().get(0).getProvenanceIds().get(0)); - assertEquals(TEXT, response.getContractAmounts().get(0).getText()); - assertEquals(BEGIN, response.getContractAmounts().get(0).getLocation().begin()); - assertEquals(END, response.getContractAmounts().get(0).getLocation().end()); - assertEquals( - ContractAmts.ConfidenceLevel.HIGH, - response.getContractAmounts().get(0).getConfidenceLevel()); - assertEquals(TEXT, response.getContractAmounts().get(0).getText()); - assertEquals(TEXT_NORMALIZED, response.getContractAmounts().get(0).getTextNormalized()); - assertEquals(VALUE, response.getContractAmounts().get(0).getInterpretation().getValue()); - assertEquals( - NUMERIC_VALUE, response.getPaymentTerms().get(0).getInterpretation().getNumericValue()); - assertEquals(UNIT, response.getContractAmounts().get(0).getInterpretation().getUnit()); - assertEquals(PROVENANCE_ID, response.getContractAmounts().get(0).getProvenanceIds().get(0)); - assertEquals(BEGIN, response.getContractAmounts().get(0).getLocation().begin()); - assertEquals(END, response.getContractAmounts().get(0).getLocation().end()); - assertEquals(TEXT, response.getTerminationDates().get(0).getText()); - assertEquals(BEGIN, response.getTerminationDates().get(0).getLocation().begin()); - assertEquals(END, response.getTerminationDates().get(0).getLocation().end()); - assertEquals( - TerminationDates.ConfidenceLevel.HIGH, - response.getTerminationDates().get(0).getConfidenceLevel()); - assertEquals(TEXT_NORMALIZED, response.getTerminationDates().get(0).getTextNormalized()); - assertEquals(PROVENANCE_ID, response.getTerminationDates().get(0).getProvenanceIds().get(0)); - assertEquals(TEXT, response.getContractTypes().get(0).getText()); - assertEquals(BEGIN, response.getContractTypes().get(0).getLocation().begin()); - assertEquals(END, response.getContractTypes().get(0).getLocation().end()); - assertEquals( - ContractTypes.ConfidenceLevel.HIGH, - response.getContractTypes().get(0).getConfidenceLevel()); - assertEquals( - ContractTerms.ConfidenceLevel.HIGH, - response.getContractTerms().get(0).getConfidenceLevel()); - assertEquals(TEXT, response.getContractTerms().get(0).getText()); - assertEquals(TEXT_NORMALIZED, response.getContractTerms().get(0).getTextNormalized()); - assertEquals(VALUE, response.getContractTerms().get(0).getInterpretation().getValue()); - assertEquals( - NUMERIC_VALUE, response.getContractTerms().get(0).getInterpretation().getNumericValue()); - assertEquals(UNIT, response.getContractTerms().get(0).getInterpretation().getUnit()); - assertEquals(PROVENANCE_ID, response.getContractTerms().get(0).getProvenanceIds().get(0)); - assertEquals(BEGIN, response.getContractTerms().get(0).getLocation().begin()); - assertEquals(END, response.getContractTerms().get(0).getLocation().end()); - assertEquals( - PaymentTerms.ConfidenceLevel.HIGH, response.getPaymentTerms().get(0).getConfidenceLevel()); - assertEquals(TEXT, response.getPaymentTerms().get(0).getText()); - assertEquals(TEXT_NORMALIZED, response.getPaymentTerms().get(0).getTextNormalized()); - assertEquals(VALUE, response.getPaymentTerms().get(0).getInterpretation().getValue()); - assertEquals( - NUMERIC_VALUE, response.getPaymentTerms().get(0).getInterpretation().getNumericValue()); - assertEquals(UNIT, response.getPaymentTerms().get(0).getInterpretation().getUnit()); - assertEquals(PROVENANCE_ID, response.getPaymentTerms().get(0).getProvenanceIds().get(0)); - assertEquals(BEGIN, response.getPaymentTerms().get(0).getLocation().begin()); - assertEquals(END, response.getPaymentTerms().get(0).getLocation().end()); - assertEquals( - ContractCurrencies.ConfidenceLevel.HIGH, - response.getContractCurrencies().get(0).getConfidenceLevel()); - assertEquals(TEXT, response.getContractCurrencies().get(0).getText()); - assertEquals(TEXT_NORMALIZED, response.getContractCurrencies().get(0).getTextNormalized()); - assertEquals(PROVENANCE_ID, response.getContractCurrencies().get(0).getProvenanceIds().get(0)); - assertEquals(BEGIN, response.getContractCurrencies().get(0).getLocation().begin()); - assertEquals(END, response.getContractCurrencies().get(0).getLocation().end()); + // Invoke operation with null options model (negative test) + compareComplyService.addFeedback(null).execute(); } @Test - public void testExtractTables() throws FileNotFoundException, InterruptedException { - server.enqueue(jsonResponse(extractTablesResponse)); + public void testListFeedbackWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"feedback\": [{\"feedback_id\": \"feedbackId\", \"created\": \"2019-01-01T12:00:00\", \"comment\": \"comment\", \"feedback_data\": {\"feedback_type\": \"feedbackType\", \"document\": {\"title\": \"title\", \"hash\": \"hash\"}, \"model_id\": \"modelId\", \"model_version\": \"modelVersion\", \"location\": {\"begin\": 5, \"end\": 3}, \"text\": \"text\", \"original_labels\": {\"types\": [{\"label\": {\"nature\": \"nature\", \"party\": \"party\"}, \"provenance_ids\": [\"provenanceIds\"], \"modification\": \"added\"}], \"categories\": [{\"label\": \"Amendments\", \"provenance_ids\": [\"provenanceIds\"], \"modification\": \"added\"}]}, \"updated_labels\": {\"types\": [{\"label\": {\"nature\": \"nature\", \"party\": \"party\"}, \"provenance_ids\": [\"provenanceIds\"], \"modification\": \"added\"}], \"categories\": [{\"label\": \"Amendments\", \"provenance_ids\": [\"provenanceIds\"], \"modification\": \"added\"}]}, \"pagination\": {\"refresh_cursor\": \"refreshCursor\", \"next_cursor\": \"nextCursor\", \"refresh_url\": \"refreshUrl\", \"next_url\": \"nextUrl\", \"total\": 5}}}]}"; + String listFeedbackPath = "/v1/feedback"; - ExtractTablesOptions extractTablesOptions = - new ExtractTablesOptions.Builder().file(SAMPLE_PDF).build(); - TableReturn response = service.extractTables(extractTablesOptions).execute().getResult(); - RecordedRequest request = server.takeRequest(); + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); - assertEquals(EXTRACT_TABLES_PATH, request.getPath()); - assertEquals(HTML, response.getDocument().getHtml()); - assertEquals(TITLE, response.getDocument().getTitle()); - assertEquals(HASH, response.getDocument().getHash()); - assertEquals(MODEL_ID, response.getModelId()); - assertEquals(MODEL_VERSION, response.getModelVersion()); - assertEquals(BEGIN, response.getTables().get(0).getLocation().begin()); - assertEquals(END, response.getTables().get(0).getLocation().end()); - assertEquals(TEXT, response.getTables().get(0).getText()); - assertEquals(BEGIN, response.getTables().get(0).getSectionTitle().getLocation().begin()); - assertEquals(END, response.getTables().get(0).getSectionTitle().getLocation().end()); - assertEquals(CELL_ID, response.getTables().get(0).getTableHeaders().get(0).getCellId()); - assertEquals( - BEGIN_DOUBLE, - response.getTables().get(0).getTableHeaders().get(0).getLocation().get("begin")); - assertEquals( - END_DOUBLE, response.getTables().get(0).getTableHeaders().get(0).getLocation().get("end")); - assertEquals(TEXT, response.getTables().get(0).getTableHeaders().get(0).getText()); - assertEquals( - ROW_INDEX_BEGIN, response.getTables().get(0).getTableHeaders().get(0).getRowIndexBegin()); - assertEquals( - ROW_INDEX_END, response.getTables().get(0).getTableHeaders().get(0).getRowIndexEnd()); - assertEquals( - COLUMN_INDEX_BEGIN, - response.getTables().get(0).getTableHeaders().get(0).getColumnIndexBegin()); - assertEquals( - COLUMN_INDEX_END, response.getTables().get(0).getTableHeaders().get(0).getColumnIndexEnd()); - assertEquals(CELL_ID, response.getTables().get(0).getColumnHeaders().get(0).getCellId()); - assertEquals( - BEGIN_DOUBLE, - response.getTables().get(0).getColumnHeaders().get(0).getLocation().get("begin")); - assertEquals( - END_DOUBLE, response.getTables().get(0).getColumnHeaders().get(0).getLocation().get("end")); - assertEquals(TEXT, response.getTables().get(0).getColumnHeaders().get(0).getText()); - assertEquals( - TEXT_NORMALIZED, response.getTables().get(0).getColumnHeaders().get(0).getTextNormalized()); - assertEquals( - ROW_INDEX_BEGIN, response.getTables().get(0).getColumnHeaders().get(0).getRowIndexBegin()); - assertEquals( - ROW_INDEX_END, response.getTables().get(0).getColumnHeaders().get(0).getRowIndexEnd()); - assertEquals( - COLUMN_INDEX_BEGIN, - response.getTables().get(0).getColumnHeaders().get(0).getColumnIndexBegin()); - assertEquals( - COLUMN_INDEX_END, - response.getTables().get(0).getColumnHeaders().get(0).getColumnIndexEnd()); - assertEquals(CELL_ID, response.getTables().get(0).getRowHeaders().get(0).getCellId()); - assertEquals(BEGIN, response.getTables().get(0).getRowHeaders().get(0).getLocation().begin()); - assertEquals(END, response.getTables().get(0).getRowHeaders().get(0).getLocation().end()); - assertEquals(TEXT, response.getTables().get(0).getRowHeaders().get(0).getText()); - assertEquals( - TEXT_NORMALIZED, response.getTables().get(0).getRowHeaders().get(0).getTextNormalized()); - assertEquals( - ROW_INDEX_BEGIN, response.getTables().get(0).getRowHeaders().get(0).getRowIndexBegin()); - assertEquals( - ROW_INDEX_END, response.getTables().get(0).getRowHeaders().get(0).getRowIndexEnd()); - assertEquals( - COLUMN_INDEX_BEGIN, - response.getTables().get(0).getRowHeaders().get(0).getColumnIndexBegin()); - assertEquals( - COLUMN_INDEX_END, response.getTables().get(0).getRowHeaders().get(0).getColumnIndexEnd()); - assertEquals(CELL_ID, response.getTables().get(0).getBodyCells().get(0).getCellId()); - assertEquals(BEGIN, response.getTables().get(0).getBodyCells().get(0).getLocation().begin()); - assertEquals(END, response.getTables().get(0).getBodyCells().get(0).getLocation().end()); - assertEquals(TEXT, response.getTables().get(0).getBodyCells().get(0).getText()); - assertEquals( - ROW_INDEX_BEGIN, response.getTables().get(0).getBodyCells().get(0).getRowIndexBegin()); - assertEquals(ROW_INDEX_END, response.getTables().get(0).getBodyCells().get(0).getRowIndexEnd()); - assertEquals( - COLUMN_INDEX_BEGIN, - response.getTables().get(0).getBodyCells().get(0).getColumnIndexBegin()); - assertEquals( - COLUMN_INDEX_END, response.getTables().get(0).getBodyCells().get(0).getColumnIndexEnd()); - assertEquals(ID, response.getTables().get(0).getBodyCells().get(0).getRowHeaderIds().get(0)); - assertEquals( - TEXT, response.getTables().get(0).getBodyCells().get(0).getRowHeaderTexts().get(0)); - assertEquals( - TEXT_NORMALIZED, - response.getTables().get(0).getBodyCells().get(0).getRowHeaderTextsNormalized().get(0)); - assertEquals(ID, response.getTables().get(0).getBodyCells().get(0).getColumnHeaderIds().get(0)); - assertEquals( - TEXT, response.getTables().get(0).getBodyCells().get(0).getColumnHeaderTexts().get(0)); - assertEquals( - TEXT_NORMALIZED, - response.getTables().get(0).getBodyCells().get(0).getColumnHeaderTextsNormalized().get(0)); - assertEquals( - TYPE, response.getTables().get(0).getBodyCells().get(0).getAttributes().get(0).getType()); - assertEquals( - TEXT, response.getTables().get(0).getBodyCells().get(0).getAttributes().get(0).getText()); - assertEquals( - BEGIN, - response - .getTables() - .get(0) - .getBodyCells() - .get(0) - .getAttributes() - .get(0) - .getLocation() - .begin()); - assertEquals( - END, - response - .getTables() - .get(0) - .getBodyCells() - .get(0) - .getAttributes() - .get(0) - .getLocation() - .end()); - assertEquals( - CELL_ID, response.getTables().get(0).getKeyValuePairs().get(0).getKey().getCellId()); - assertEquals( - BEGIN, - response.getTables().get(0).getKeyValuePairs().get(0).getKey().getLocation().begin()); - assertEquals( - END, response.getTables().get(0).getKeyValuePairs().get(0).getKey().getLocation().end()); - assertEquals(TEXT, response.getTables().get(0).getKeyValuePairs().get(0).getKey().getText()); - assertEquals( - CELL_ID, - response.getTables().get(0).getKeyValuePairs().get(0).getValue().get(0).getCellId()); - assertEquals( - BEGIN, - response - .getTables() - .get(0) - .getKeyValuePairs() - .get(0) - .getValue() - .get(0) - .getLocation() - .begin()); - assertEquals( - END, - response - .getTables() - .get(0) - .getKeyValuePairs() - .get(0) - .getValue() - .get(0) - .getLocation() - .end()); - assertEquals( - TEXT, response.getTables().get(0).getKeyValuePairs().get(0).getValue().get(0).getText()); - } + constructClientService(); - @Test - public void testCompareDocuments() throws FileNotFoundException, InterruptedException { - server.enqueue(jsonResponse(compareDocumentsResponse)); + // Construct an instance of the ListFeedbackOptions model + ListFeedbackOptions listFeedbackOptionsModel = + new ListFeedbackOptions.Builder() + .feedbackType("testString") + .documentTitle("testString") + .modelId("testString") + .modelVersion("testString") + .categoryRemoved("testString") + .categoryAdded("testString") + .categoryNotChanged("testString") + .typeRemoved("testString") + .typeAdded("testString") + .typeNotChanged("testString") + .pageLimit(Long.valueOf("100")) + .cursor("testString") + .sort("testString") + .includeTotal(true) + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + compareComplyService.listFeedback(listFeedbackOptionsModel).execute(); + assertNotNull(response); + FeedbackList responseObj = response.getResult(); + assertNotNull(responseObj); - CompareDocumentsOptions compareDocumentsOptions = - new CompareDocumentsOptions.Builder().file1(SAMPLE_PDF).file2(SAMPLE_PDF).build(); - CompareReturn response = - service.compareDocuments(compareDocumentsOptions).execute().getResult(); + // Verify the contents of the request RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(query.get("feedback_type"), "testString"); + assertEquals(query.get("document_title"), "testString"); + assertEquals(query.get("model_id"), "testString"); + assertEquals(query.get("model_version"), "testString"); + assertEquals(query.get("category_removed"), "testString"); + assertEquals(query.get("category_added"), "testString"); + assertEquals(query.get("category_not_changed"), "testString"); + assertEquals(query.get("type_removed"), "testString"); + assertEquals(query.get("type_added"), "testString"); + assertEquals(query.get("type_not_changed"), "testString"); + assertEquals(Long.valueOf(query.get("page_limit")), Long.valueOf("100")); + assertEquals(query.get("cursor"), "testString"); + assertEquals(query.get("sort"), "testString"); + assertEquals(Boolean.valueOf(query.get("include_total")), Boolean.valueOf(true)); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listFeedbackPath); + } + + @Test + public void testGetFeedbackWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"feedback_id\": \"feedbackId\", \"created\": \"2019-01-01T12:00:00\", \"comment\": \"comment\", \"feedback_data\": {\"feedback_type\": \"feedbackType\", \"document\": {\"title\": \"title\", \"hash\": \"hash\"}, \"model_id\": \"modelId\", \"model_version\": \"modelVersion\", \"location\": {\"begin\": 5, \"end\": 3}, \"text\": \"text\", \"original_labels\": {\"types\": [{\"label\": {\"nature\": \"nature\", \"party\": \"party\"}, \"provenance_ids\": [\"provenanceIds\"], \"modification\": \"added\"}], \"categories\": [{\"label\": \"Amendments\", \"provenance_ids\": [\"provenanceIds\"], \"modification\": \"added\"}]}, \"updated_labels\": {\"types\": [{\"label\": {\"nature\": \"nature\", \"party\": \"party\"}, \"provenance_ids\": [\"provenanceIds\"], \"modification\": \"added\"}], \"categories\": [{\"label\": \"Amendments\", \"provenance_ids\": [\"provenanceIds\"], \"modification\": \"added\"}]}, \"pagination\": {\"refresh_cursor\": \"refreshCursor\", \"next_cursor\": \"nextCursor\", \"refresh_url\": \"refreshUrl\", \"next_url\": \"nextUrl\", \"total\": 5}}}"; + String getFeedbackPath = "/v1/feedback/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the GetFeedbackOptions model + GetFeedbackOptions getFeedbackOptionsModel = + new GetFeedbackOptions.Builder().feedbackId("testString").model("contracts").build(); + + // Invoke operation with valid options model (positive test) + Response response = + compareComplyService.getFeedback(getFeedbackOptionsModel).execute(); + assertNotNull(response); + GetFeedback responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(query.get("model"), "contracts"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getFeedbackPath); + } + + // Test the getFeedback operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetFeedbackNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); - assertEquals(COMPARE_DOCUMENTS_PATH, request.getPath()); - assertEquals(TITLE, response.getDocuments().get(0).getTitle()); - assertEquals(HTML, response.getDocuments().get(0).getHtml()); - assertEquals(HASH, response.getDocuments().get(0).getHash()); - assertEquals(LABEL, response.getDocuments().get(0).getLabel()); - assertEquals( - DOCUMENT_LABEL, - response.getAlignedElements().get(0).getElementPair().get(0).getDocumentLabel()); - assertEquals(TEXT, response.getAlignedElements().get(0).getElementPair().get(0).getText()); - assertEquals( - BEGIN, response.getAlignedElements().get(0).getElementPair().get(0).getLocation().begin()); - assertEquals( - END, response.getAlignedElements().get(0).getElementPair().get(0).getLocation().end()); - assertEquals( - NATURE, - response - .getAlignedElements() - .get(0) - .getElementPair() - .get(0) - .getTypes() - .get(0) - .getLabel() - .nature()); - assertEquals( - PARTY, - response - .getAlignedElements() - .get(0) - .getElementPair() - .get(0) - .getTypes() - .get(0) - .getLabel() - .party()); - assertEquals( - LABEL, - response - .getAlignedElements() - .get(0) - .getElementPair() - .get(0) - .getCategories() - .get(0) - .getLabel()); - assertEquals( - TYPE, - response - .getAlignedElements() - .get(0) - .getElementPair() - .get(0) - .getAttributes() - .get(0) - .getType()); - assertEquals( - TEXT, - response - .getAlignedElements() - .get(0) - .getElementPair() - .get(0) - .getAttributes() - .get(0) - .getText()); - assertEquals( - BEGIN, - response - .getAlignedElements() - .get(0) - .getElementPair() - .get(0) - .getAttributes() - .get(0) - .getLocation() - .begin()); - assertEquals( - END, - response - .getAlignedElements() - .get(0) - .getElementPair() - .get(0) - .getAttributes() - .get(0) - .getLocation() - .end()); - assertEquals(true, response.getAlignedElements().get(0).isIdenticalText()); - assertEquals(PROVENANCE_ID, response.getAlignedElements().get(0).getProvenanceIds().get(0)); - assertTrue(response.getAlignedElements().get(0).isSignificantElements()); - assertEquals(DOCUMENT_LABEL, response.getUnalignedElements().get(0).getDocumentLabel()); - assertEquals(TEXT, response.getUnalignedElements().get(0).getText()); - assertEquals(BEGIN, response.getUnalignedElements().get(0).getLocation().begin()); - assertEquals(END, response.getUnalignedElements().get(0).getLocation().end()); - assertEquals( - NATURE, response.getUnalignedElements().get(0).getTypes().get(0).getLabel().nature()); - assertEquals( - PARTY, response.getUnalignedElements().get(0).getTypes().get(0).getLabel().party()); - assertEquals(LABEL, response.getUnalignedElements().get(0).getCategories().get(0).getLabel()); - assertEquals(TYPE, response.getUnalignedElements().get(0).getAttributes().get(0).getType()); - assertEquals(TEXT, response.getUnalignedElements().get(0).getAttributes().get(0).getText()); - assertEquals( - BEGIN, response.getUnalignedElements().get(0).getAttributes().get(0).getLocation().begin()); - assertEquals( - END, response.getUnalignedElements().get(0).getAttributes().get(0).getLocation().end()); - assertEquals(MODEL_ID, response.getModelId()); - assertEquals(MODEL_VERSION, response.getModelVersion()); + // Invoke operation with null options model (negative test) + compareComplyService.getFeedback(null).execute(); } @Test - public void testAddFeedback() throws InterruptedException { - server.enqueue(jsonResponse(addFeedbackResponse)); + public void testDeleteFeedbackWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = "{\"status\": 6, \"message\": \"message\"}"; + String deleteFeedbackPath = "/v1/feedback/testString"; - Location location = new Location.Builder().begin(BEGIN).end(END).build(); - Category category = new Category.Builder().build(); - TypeLabel typeLabel = new TypeLabel.Builder().build(); - OriginalLabelsIn originalLabelsIn = - new OriginalLabelsIn.Builder() - .categories(Collections.singletonList(category)) - .types(Collections.singletonList(typeLabel)) - .build(); - UpdatedLabelsIn updatedLabelsIn = - new UpdatedLabelsIn.Builder() - .categories(Collections.singletonList(category)) - .types(Collections.singletonList(typeLabel)) - .build(); - FeedbackDataInput feedbackDataInput = - new FeedbackDataInput.Builder() - .feedbackType(FEEDBACK_TYPE) - .location(location) - .originalLabels(originalLabelsIn) - .text(TEXT) - .updatedLabels(updatedLabelsIn) - .build(); - AddFeedbackOptions addFeedbackOptions = - new AddFeedbackOptions.Builder().feedbackData(feedbackDataInput).build(); - FeedbackReturn response = service.addFeedback(addFeedbackOptions).execute().getResult(); - RecordedRequest request = server.takeRequest(); + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); - assertEquals(FEEDBACK_PATH, request.getPath()); - assertEquals(FEEDBACK_ID, response.getFeedbackId()); - assertEquals(USER_ID, response.getUserId()); - assertEquals(COMMENT, response.getComment()); - assertEquals(testDateValue, response.getCreated()); - assertEquals(FEEDBACK_TYPE, response.getFeedbackData().getFeedbackType()); - assertEquals(TITLE, response.getFeedbackData().getDocument().title()); - assertEquals(HASH, response.getFeedbackData().getDocument().hash()); - assertEquals(MODEL_ID, response.getFeedbackData().getModelId()); - assertEquals(MODEL_VERSION, response.getFeedbackData().getModelVersion()); - assertEquals(BEGIN, response.getFeedbackData().getLocation().begin()); - assertEquals(END, response.getFeedbackData().getLocation().end()); - assertEquals(TEXT, response.getFeedbackData().getText()); - assertEquals( - NATURE, response.getFeedbackData().getOriginalLabels().getTypes().get(0).label().nature()); - assertEquals( - PARTY, response.getFeedbackData().getOriginalLabels().getTypes().get(0).label().party()); - assertEquals( - PROVENANCE_ID, - response.getFeedbackData().getOriginalLabels().getTypes().get(0).provenanceIds().get(0)); - assertEquals( - LABEL, response.getFeedbackData().getOriginalLabels().getCategories().get(0).label()); - assertEquals( - PROVENANCE_ID, - response - .getFeedbackData() - .getOriginalLabels() - .getCategories() - .get(0) - .provenanceIds() - .get(0)); - assertEquals( - OriginalLabelsOut.Modification.ADDED, - response.getFeedbackData().getOriginalLabels().getModification()); - assertEquals( - NATURE, response.getFeedbackData().getUpdatedLabels().getTypes().get(0).label().nature()); - assertEquals( - PARTY, response.getFeedbackData().getUpdatedLabels().getTypes().get(0).label().party()); - assertEquals( - PROVENANCE_ID, - response.getFeedbackData().getUpdatedLabels().getTypes().get(0).provenanceIds().get(0)); - assertEquals( - LABEL, response.getFeedbackData().getUpdatedLabels().getCategories().get(0).label()); - assertEquals( - PROVENANCE_ID, - response - .getFeedbackData() - .getUpdatedLabels() - .getCategories() - .get(0) - .provenanceIds() - .get(0)); - assertEquals( - UpdatedLabelsOut.Modification.ADDED, - response.getFeedbackData().getUpdatedLabels().getModification()); - assertEquals(REFRESH_CURSOR, response.getFeedbackData().getPagination().getRefreshCursor()); - assertEquals(NEXT_CURSOR, response.getFeedbackData().getPagination().getNextCursor()); - assertEquals(REFRESH_URL, response.getFeedbackData().getPagination().getRefreshUrl()); - assertEquals(NEXT_URL, response.getFeedbackData().getPagination().getNextUrl()); - assertEquals(TOTAL, response.getFeedbackData().getPagination().getTotal()); - } + constructClientService(); - @Test - public void testDeleteFeedback() throws InterruptedException { - server.enqueue(new MockResponse()); + // Construct an instance of the DeleteFeedbackOptions model + DeleteFeedbackOptions deleteFeedbackOptionsModel = + new DeleteFeedbackOptions.Builder().feedbackId("testString").model("contracts").build(); - DeleteFeedbackOptions deleteFeedbackOptions = - new DeleteFeedbackOptions.Builder().feedbackId(FEEDBACK_ID).build(); - service.deleteFeedback(deleteFeedbackOptions).execute(); + // Invoke operation with valid options model (positive test) + Response response = + compareComplyService.deleteFeedback(deleteFeedbackOptionsModel).execute(); + assertNotNull(response); + FeedbackDeleted responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(query.get("model"), "contracts"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteFeedbackPath); + } + + // Test the deleteFeedback operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteFeedbackNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); - assertEquals(SPECIFIC_FEEDBACK_PATH, request.getPath()); + // Invoke operation with null options model (negative test) + compareComplyService.deleteFeedback(null).execute(); } @Test - public void testGetFeedback() throws InterruptedException { - server.enqueue(jsonResponse(getFeedbackResponse)); + public void testCreateBatchWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"function\": \"element_classification\", \"input_bucket_location\": \"inputBucketLocation\", \"input_bucket_name\": \"inputBucketName\", \"output_bucket_location\": \"outputBucketLocation\", \"output_bucket_name\": \"outputBucketName\", \"batch_id\": \"batchId\", \"document_counts\": {\"total\": 5, \"pending\": 7, \"successful\": 10, \"failed\": 6}, \"status\": \"status\", \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}"; + String createBatchPath = "/v1/batches"; - GetFeedbackOptions getFeedbackOptions = - new GetFeedbackOptions.Builder().feedbackId(FEEDBACK_ID).build(); - GetFeedback response = service.getFeedback(getFeedbackOptions).execute().getResult(); - RecordedRequest request = server.takeRequest(); + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); - assertEquals(SPECIFIC_FEEDBACK_PATH, request.getPath()); - assertEquals(FEEDBACK_ID, response.getFeedbackId()); - assertEquals(COMMENT, response.getComment()); - assertEquals(testDateValue, response.getCreated()); - assertEquals(FEEDBACK_TYPE, response.getFeedbackData().getFeedbackType()); - assertEquals(TITLE, response.getFeedbackData().getDocument().title()); - assertEquals(HASH, response.getFeedbackData().getDocument().hash()); - assertEquals(MODEL_ID, response.getFeedbackData().getModelId()); - assertEquals(MODEL_VERSION, response.getFeedbackData().getModelVersion()); - assertEquals(BEGIN, response.getFeedbackData().getLocation().begin()); - assertEquals(END, response.getFeedbackData().getLocation().end()); - assertEquals(TEXT, response.getFeedbackData().getText()); - assertEquals( - NATURE, response.getFeedbackData().getOriginalLabels().getTypes().get(0).label().nature()); - assertEquals( - PARTY, response.getFeedbackData().getOriginalLabels().getTypes().get(0).label().party()); - assertEquals( - PROVENANCE_ID, - response.getFeedbackData().getOriginalLabels().getTypes().get(0).provenanceIds().get(0)); - assertEquals( - LABEL, response.getFeedbackData().getOriginalLabels().getCategories().get(0).label()); - assertEquals( - PROVENANCE_ID, - response - .getFeedbackData() - .getOriginalLabels() - .getCategories() - .get(0) - .provenanceIds() - .get(0)); - assertEquals( - OriginalLabelsOut.Modification.ADDED, - response.getFeedbackData().getOriginalLabels().getModification()); - assertEquals( - NATURE, response.getFeedbackData().getUpdatedLabels().getTypes().get(0).label().nature()); - assertEquals( - PARTY, response.getFeedbackData().getUpdatedLabels().getTypes().get(0).label().party()); - assertEquals( - PROVENANCE_ID, - response.getFeedbackData().getUpdatedLabels().getTypes().get(0).provenanceIds().get(0)); - assertEquals( - LABEL, response.getFeedbackData().getUpdatedLabels().getCategories().get(0).label()); - assertEquals( - PROVENANCE_ID, - response - .getFeedbackData() - .getUpdatedLabels() - .getCategories() - .get(0) - .provenanceIds() - .get(0)); - assertEquals( - UpdatedLabelsOut.Modification.ADDED, - response.getFeedbackData().getUpdatedLabels().getModification()); - assertEquals(REFRESH_CURSOR, response.getFeedbackData().getPagination().getRefreshCursor()); - assertEquals(NEXT_CURSOR, response.getFeedbackData().getPagination().getNextCursor()); - assertEquals(REFRESH_URL, response.getFeedbackData().getPagination().getRefreshUrl()); - assertEquals(NEXT_URL, response.getFeedbackData().getPagination().getNextUrl()); - assertEquals(TOTAL, response.getFeedbackData().getPagination().getTotal()); - } + constructClientService(); - @Test - public void testListFeedbackWithOptions() throws InterruptedException { - server.enqueue(jsonResponse(listFeedbackResponse)); + // Construct an instance of the CreateBatchOptions model + CreateBatchOptions createBatchOptionsModel = + new CreateBatchOptions.Builder() + .function("html_conversion") + .inputCredentialsFile(TestUtilities.createMockStream("This is a mock file.")) + .inputBucketLocation("testString") + .inputBucketName("testString") + .outputCredentialsFile(TestUtilities.createMockStream("This is a mock file.")) + .outputBucketLocation("testString") + .outputBucketName("testString") + .model("contracts") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + compareComplyService.createBatch(createBatchOptionsModel).execute(); + assertNotNull(response); + BatchStatus responseObj = response.getResult(); + assertNotNull(responseObj); - ListFeedbackOptions listFeedbackOptions = new ListFeedbackOptions.Builder().build(); - FeedbackList response = service.listFeedback(listFeedbackOptions).execute().getResult(); + // Verify the contents of the request RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(query.get("function"), "html_conversion"); + assertEquals(query.get("model"), "contracts"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createBatchPath); + } + + // Test the createBatch operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateBatchNoOptions() throws Throwable { + // construct the service + constructClientService(); - assertFeedbackListResponse(request, response); + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + compareComplyService.createBatch(null).execute(); } @Test - public void testListFeedbackWithoutOptions() throws InterruptedException { - server.enqueue(jsonResponse(listFeedbackResponse)); + public void testListBatchesWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"batches\": [{\"function\": \"element_classification\", \"input_bucket_location\": \"inputBucketLocation\", \"input_bucket_name\": \"inputBucketName\", \"output_bucket_location\": \"outputBucketLocation\", \"output_bucket_name\": \"outputBucketName\", \"batch_id\": \"batchId\", \"document_counts\": {\"total\": 5, \"pending\": 7, \"successful\": 10, \"failed\": 6}, \"status\": \"status\", \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}]}"; + String listBatchesPath = "/v1/batches"; - FeedbackList response = service.listFeedback().execute().getResult(); - RecordedRequest request = server.takeRequest(); + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); - assertFeedbackListResponse(request, response); - } + constructClientService(); - @Test - public void testCreateBatch() throws FileNotFoundException, InterruptedException { - server.enqueue(jsonResponse(batchStatusResponse)); + // Construct an instance of the ListBatchesOptions model + ListBatchesOptions listBatchesOptionsModel = new ListBatchesOptions(); - CreateBatchOptions createBatchOptions = - new CreateBatchOptions.Builder() - .function(CreateBatchOptions.Function.ELEMENT_CLASSIFICATION) - .inputCredentialsFile(CREDENTIALS_FILE) - .inputBucketLocation(BUCKET_LOCATION) - .inputBucketName(BUCKET_NAME) - .outputCredentialsFile(CREDENTIALS_FILE) - .outputBucketLocation(BUCKET_LOCATION) - .outputBucketName(BUCKET_NAME) - .build(); - BatchStatus response = service.createBatch(createBatchOptions).execute().getResult(); + // Invoke operation with valid options model (positive test) + Response response = + compareComplyService.listBatches(listBatchesOptionsModel).execute(); + assertNotNull(response); + Batches responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); - assertEquals(CREATE_BATCH_PATH, request.getPath()); - assertBatchStatusResponse(response); + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listBatchesPath); } @Test - public void testGetBatch() throws InterruptedException { - server.enqueue(jsonResponse(batchStatusResponse)); + public void testGetBatchWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"function\": \"element_classification\", \"input_bucket_location\": \"inputBucketLocation\", \"input_bucket_name\": \"inputBucketName\", \"output_bucket_location\": \"outputBucketLocation\", \"output_bucket_name\": \"outputBucketName\", \"batch_id\": \"batchId\", \"document_counts\": {\"total\": 5, \"pending\": 7, \"successful\": 10, \"failed\": 6}, \"status\": \"status\", \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}"; + String getBatchPath = "/v1/batches/testString"; - GetBatchOptions getBatchOptions = new GetBatchOptions.Builder().batchId(BATCH_ID).build(); - BatchStatus response = service.getBatch(getBatchOptions).execute().getResult(); - RecordedRequest request = server.takeRequest(); + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); - assertEquals(GET_BATCH_PATH, request.getPath()); - assertBatchStatusResponse(response); - } + constructClientService(); - @Test - public void testListBatchesWithOptions() throws InterruptedException { - server.enqueue(jsonResponse(batchesResponse)); + // Construct an instance of the GetBatchOptions model + GetBatchOptions getBatchOptionsModel = + new GetBatchOptions.Builder().batchId("testString").build(); - ListBatchesOptions listBatchesOptions = new ListBatchesOptions.Builder().build(); - Batches response = service.listBatches(listBatchesOptions).execute().getResult(); + // Invoke operation with valid options model (positive test) + Response response = compareComplyService.getBatch(getBatchOptionsModel).execute(); + assertNotNull(response); + BatchStatus responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); - assertBatchesResponse(request, response); + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getBatchPath); } - @Test - public void testListBatchesWithoutOptions() throws InterruptedException { - server.enqueue(jsonResponse(batchesResponse)); + // Test the getBatch operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetBatchNoOptions() throws Throwable { + // construct the service + constructClientService(); - Batches response = service.listBatches().execute().getResult(); - RecordedRequest request = server.takeRequest(); + server.enqueue(new MockResponse()); - assertBatchesResponse(request, response); + // Invoke operation with null options model (negative test) + compareComplyService.getBatch(null).execute(); } @Test - public void testUpdateBatch() throws InterruptedException { - server.enqueue(jsonResponse(batchStatusResponse)); + public void testUpdateBatchWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"function\": \"element_classification\", \"input_bucket_location\": \"inputBucketLocation\", \"input_bucket_name\": \"inputBucketName\", \"output_bucket_location\": \"outputBucketLocation\", \"output_bucket_name\": \"outputBucketName\", \"batch_id\": \"batchId\", \"document_counts\": {\"total\": 5, \"pending\": 7, \"successful\": 10, \"failed\": 6}, \"status\": \"status\", \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}"; + String updateBatchPath = "/v1/batches/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); - UpdateBatchOptions updateBatchOptions = + // Construct an instance of the UpdateBatchOptions model + UpdateBatchOptions updateBatchOptionsModel = new UpdateBatchOptions.Builder() - .action(UpdateBatchOptions.Action.CANCEL) - .batchId(BATCH_ID) + .batchId("testString") + .action("rescan") + .model("contracts") .build(); - BatchStatus response = service.updateBatch(updateBatchOptions).execute().getResult(); + + // Invoke operation with valid options model (positive test) + Response response = + compareComplyService.updateBatch(updateBatchOptionsModel).execute(); + assertNotNull(response); + BatchStatus responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "PUT"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(query.get("action"), "rescan"); + assertEquals(query.get("model"), "contracts"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateBatchPath); + } + + // Test the updateBatch operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateBatchNoOptions() throws Throwable { + // construct the service + constructClientService(); - assertEquals(UPDATE_BATCH_PATH, request.getPath()); - assertBatchStatusResponse(response); - } + server.enqueue(new MockResponse()); - private void assertFeedbackListResponse(RecordedRequest request, FeedbackList response) { - assertEquals(FEEDBACK_PATH, request.getPath()); - assertEquals(FEEDBACK_ID, response.getFeedback().get(0).getFeedbackId()); - assertEquals(COMMENT, response.getFeedback().get(0).getComment()); - assertEquals(testDateValue, response.getFeedback().get(0).getCreated()); - assertEquals(FEEDBACK_TYPE, response.getFeedback().get(0).getFeedbackData().getFeedbackType()); - assertEquals(TITLE, response.getFeedback().get(0).getFeedbackData().getDocument().title()); - assertEquals(HASH, response.getFeedback().get(0).getFeedbackData().getDocument().hash()); - assertEquals(MODEL_ID, response.getFeedback().get(0).getFeedbackData().getModelId()); - assertEquals(MODEL_VERSION, response.getFeedback().get(0).getFeedbackData().getModelVersion()); - assertEquals(BEGIN, response.getFeedback().get(0).getFeedbackData().getLocation().begin()); - assertEquals(END, response.getFeedback().get(0).getFeedbackData().getLocation().end()); - assertEquals(TEXT, response.getFeedback().get(0).getFeedbackData().getText()); - assertEquals( - NATURE, - response - .getFeedback() - .get(0) - .getFeedbackData() - .getOriginalLabels() - .getTypes() - .get(0) - .label() - .nature()); - assertEquals( - PARTY, - response - .getFeedback() - .get(0) - .getFeedbackData() - .getOriginalLabels() - .getTypes() - .get(0) - .label() - .party()); - assertEquals( - PROVENANCE_ID, - response - .getFeedback() - .get(0) - .getFeedbackData() - .getOriginalLabels() - .getTypes() - .get(0) - .provenanceIds() - .get(0)); - assertEquals( - LABEL, - response - .getFeedback() - .get(0) - .getFeedbackData() - .getOriginalLabels() - .getCategories() - .get(0) - .label()); - assertEquals( - PROVENANCE_ID, - response - .getFeedback() - .get(0) - .getFeedbackData() - .getOriginalLabels() - .getCategories() - .get(0) - .provenanceIds() - .get(0)); - assertEquals( - OriginalLabelsOut.Modification.ADDED, - response.getFeedback().get(0).getFeedbackData().getOriginalLabels().getModification()); - assertEquals( - NATURE, - response - .getFeedback() - .get(0) - .getFeedbackData() - .getUpdatedLabels() - .getTypes() - .get(0) - .label() - .nature()); - assertEquals( - PARTY, - response - .getFeedback() - .get(0) - .getFeedbackData() - .getUpdatedLabels() - .getTypes() - .get(0) - .label() - .party()); - assertEquals( - PROVENANCE_ID, - response - .getFeedback() - .get(0) - .getFeedbackData() - .getUpdatedLabels() - .getTypes() - .get(0) - .provenanceIds() - .get(0)); - assertEquals( - LABEL, - response - .getFeedback() - .get(0) - .getFeedbackData() - .getUpdatedLabels() - .getCategories() - .get(0) - .label()); - assertEquals( - PROVENANCE_ID, - response - .getFeedback() - .get(0) - .getFeedbackData() - .getUpdatedLabels() - .getCategories() - .get(0) - .provenanceIds() - .get(0)); - assertEquals( - UpdatedLabelsOut.Modification.ADDED, - response.getFeedback().get(0).getFeedbackData().getUpdatedLabels().getModification()); - assertEquals( - REFRESH_CURSOR, - response.getFeedback().get(0).getFeedbackData().getPagination().getRefreshCursor()); - assertEquals( - NEXT_CURSOR, - response.getFeedback().get(0).getFeedbackData().getPagination().getNextCursor()); - assertEquals( - REFRESH_URL, - response.getFeedback().get(0).getFeedbackData().getPagination().getRefreshUrl()); - assertEquals( - NEXT_URL, response.getFeedback().get(0).getFeedbackData().getPagination().getNextUrl()); - assertEquals(TOTAL, response.getFeedback().get(0).getFeedbackData().getPagination().getTotal()); + // Invoke operation with null options model (negative test) + compareComplyService.updateBatch(null).execute(); } - private void assertBatchStatusResponse(BatchStatus response) { - assertEquals(BatchStatus.Function.ELEMENT_CLASSIFICATION, response.getFunction()); - assertEquals(BUCKET_LOCATION, response.getInputBucketLocation()); - assertEquals(BUCKET_NAME, response.getInputBucketName()); - assertEquals(BUCKET_LOCATION, response.getOutputBucketLocation()); - assertEquals(BUCKET_NAME, response.getOutputBucketName()); - assertEquals(BATCH_ID, response.getBatchId()); - assertEquals(TOTAL, response.getDocumentCounts().getTotal()); - assertEquals(PENDING, response.getDocumentCounts().getPending()); - assertEquals(SUCCESSFUL, response.getDocumentCounts().getSuccessful()); - assertEquals(FAILED, response.getDocumentCounts().getFailed()); - assertEquals(STATUS, response.getStatus()); - assertEquals(testDateValue, response.getCreated()); - assertEquals(testDateValue, response.getUpdated()); + /** Initialize the server */ + @BeforeMethod + public void setUpMockServer() { + try { + server = new MockWebServer(); + // register handler + server.start(); + } catch (IOException err) { + fail("Failed to instantiate mock web server"); + } } - private void assertBatchesResponse(RecordedRequest request, Batches response) { - assertEquals(LIST_BATCHES_PATH, request.getPath()); - assertBatchStatusResponse(response.getBatches().get(0)); + @AfterMethod + public void tearDownMockServer() throws IOException { + server.shutdown(); + compareComplyService = null; } } diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/AddFeedbackOptionsTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/AddFeedbackOptionsTest.java new file mode 100644 index 00000000000..e286b8d59c5 --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/AddFeedbackOptionsTest.java @@ -0,0 +1,129 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the AddFeedbackOptions model. */ +public class AddFeedbackOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAddFeedbackOptions() throws Throwable { + ShortDoc shortDocModel = new ShortDoc.Builder().title("testString").hash("testString").build(); + assertEquals(shortDocModel.title(), "testString"); + assertEquals(shortDocModel.hash(), "testString"); + + Location locationModel = + new Location.Builder().begin(Long.valueOf("26")).end(Long.valueOf("26")).build(); + assertEquals(locationModel.begin(), Long.valueOf("26")); + assertEquals(locationModel.end(), Long.valueOf("26")); + + Label labelModel = new Label.Builder().nature("testString").party("testString").build(); + assertEquals(labelModel.nature(), "testString"); + assertEquals(labelModel.party(), "testString"); + + TypeLabel typeLabelModel = + new TypeLabel.Builder() + .label(labelModel) + .provenanceIds(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .modification("added") + .build(); + assertEquals(typeLabelModel.label(), labelModel); + assertEquals( + typeLabelModel.provenanceIds(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals(typeLabelModel.modification(), "added"); + + Category categoryModel = + new Category.Builder() + .label("Amendments") + .provenanceIds(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .modification("added") + .build(); + assertEquals(categoryModel.label(), "Amendments"); + assertEquals( + categoryModel.provenanceIds(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals(categoryModel.modification(), "added"); + + OriginalLabelsIn originalLabelsInModel = + new OriginalLabelsIn.Builder() + .types(new java.util.ArrayList(java.util.Arrays.asList(typeLabelModel))) + .categories(new java.util.ArrayList(java.util.Arrays.asList(categoryModel))) + .build(); + assertEquals( + originalLabelsInModel.types(), + new java.util.ArrayList(java.util.Arrays.asList(typeLabelModel))); + assertEquals( + originalLabelsInModel.categories(), + new java.util.ArrayList(java.util.Arrays.asList(categoryModel))); + + UpdatedLabelsIn updatedLabelsInModel = + new UpdatedLabelsIn.Builder() + .types(new java.util.ArrayList(java.util.Arrays.asList(typeLabelModel))) + .categories(new java.util.ArrayList(java.util.Arrays.asList(categoryModel))) + .build(); + assertEquals( + updatedLabelsInModel.types(), + new java.util.ArrayList(java.util.Arrays.asList(typeLabelModel))); + assertEquals( + updatedLabelsInModel.categories(), + new java.util.ArrayList(java.util.Arrays.asList(categoryModel))); + + FeedbackDataInput feedbackDataInputModel = + new FeedbackDataInput.Builder() + .feedbackType("testString") + .document(shortDocModel) + .modelId("testString") + .modelVersion("testString") + .location(locationModel) + .text("testString") + .originalLabels(originalLabelsInModel) + .updatedLabels(updatedLabelsInModel) + .build(); + assertEquals(feedbackDataInputModel.feedbackType(), "testString"); + assertEquals(feedbackDataInputModel.document(), shortDocModel); + assertEquals(feedbackDataInputModel.modelId(), "testString"); + assertEquals(feedbackDataInputModel.modelVersion(), "testString"); + assertEquals(feedbackDataInputModel.location(), locationModel); + assertEquals(feedbackDataInputModel.text(), "testString"); + assertEquals(feedbackDataInputModel.originalLabels(), originalLabelsInModel); + assertEquals(feedbackDataInputModel.updatedLabels(), updatedLabelsInModel); + + AddFeedbackOptions addFeedbackOptionsModel = + new AddFeedbackOptions.Builder() + .feedbackData(feedbackDataInputModel) + .userId("testString") + .comment("testString") + .build(); + assertEquals(addFeedbackOptionsModel.feedbackData(), feedbackDataInputModel); + assertEquals(addFeedbackOptionsModel.userId(), "testString"); + assertEquals(addFeedbackOptionsModel.comment(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAddFeedbackOptionsError() throws Throwable { + new AddFeedbackOptions.Builder().build(); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/AddressTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/AddressTest.java new file mode 100644 index 00000000000..6f0c77acdc6 --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/AddressTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Address model. */ +public class AddressTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAddress() throws Throwable { + Address addressModel = new Address(); + assertNull(addressModel.getText()); + assertNull(addressModel.getLocation()); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/AlignedElementTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/AlignedElementTest.java new file mode 100644 index 00000000000..871b31a7325 --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/AlignedElementTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the AlignedElement model. */ +public class AlignedElementTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAlignedElement() throws Throwable { + AlignedElement alignedElementModel = new AlignedElement(); + assertNull(alignedElementModel.getElementPair()); + assertNull(alignedElementModel.isIdenticalText()); + assertNull(alignedElementModel.getProvenanceIds()); + assertNull(alignedElementModel.isSignificantElements()); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/AttributeTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/AttributeTest.java new file mode 100644 index 00000000000..85315c51de7 --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/AttributeTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Attribute model. */ +public class AttributeTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAttribute() throws Throwable { + Attribute attributeModel = new Attribute(); + assertNull(attributeModel.getType()); + assertNull(attributeModel.getText()); + assertNull(attributeModel.getLocation()); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/BatchStatusTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/BatchStatusTest.java new file mode 100644 index 00000000000..d6b71a77976 --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/BatchStatusTest.java @@ -0,0 +1,45 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the BatchStatus model. */ +public class BatchStatusTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testBatchStatus() throws Throwable { + BatchStatus batchStatusModel = new BatchStatus(); + assertNull(batchStatusModel.getFunction()); + assertNull(batchStatusModel.getInputBucketLocation()); + assertNull(batchStatusModel.getInputBucketName()); + assertNull(batchStatusModel.getOutputBucketLocation()); + assertNull(batchStatusModel.getOutputBucketName()); + assertNull(batchStatusModel.getBatchId()); + assertNull(batchStatusModel.getDocumentCounts()); + assertNull(batchStatusModel.getStatus()); + assertNull(batchStatusModel.getCreated()); + assertNull(batchStatusModel.getUpdated()); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/BatchesTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/BatchesTest.java new file mode 100644 index 00000000000..3999e314969 --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/BatchesTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Batches model. */ +public class BatchesTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testBatches() throws Throwable { + Batches batchesModel = new Batches(); + assertNull(batchesModel.getBatches()); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/BodyCellsTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/BodyCellsTest.java new file mode 100644 index 00000000000..29a9e854135 --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/BodyCellsTest.java @@ -0,0 +1,49 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the BodyCells model. */ +public class BodyCellsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testBodyCells() throws Throwable { + BodyCells bodyCellsModel = new BodyCells(); + assertNull(bodyCellsModel.getCellId()); + assertNull(bodyCellsModel.getLocation()); + assertNull(bodyCellsModel.getText()); + assertNull(bodyCellsModel.getRowIndexBegin()); + assertNull(bodyCellsModel.getRowIndexEnd()); + assertNull(bodyCellsModel.getColumnIndexBegin()); + assertNull(bodyCellsModel.getColumnIndexEnd()); + assertNull(bodyCellsModel.getRowHeaderIds()); + assertNull(bodyCellsModel.getRowHeaderTexts()); + assertNull(bodyCellsModel.getRowHeaderTextsNormalized()); + assertNull(bodyCellsModel.getColumnHeaderIds()); + assertNull(bodyCellsModel.getColumnHeaderTexts()); + assertNull(bodyCellsModel.getColumnHeaderTextsNormalized()); + assertNull(bodyCellsModel.getAttributes()); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/CategoryComparisonTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/CategoryComparisonTest.java new file mode 100644 index 00000000000..0c396eadde7 --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/CategoryComparisonTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CategoryComparison model. */ +public class CategoryComparisonTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCategoryComparison() throws Throwable { + CategoryComparison categoryComparisonModel = new CategoryComparison(); + assertNull(categoryComparisonModel.getLabel()); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/CategoryTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/CategoryTest.java new file mode 100644 index 00000000000..2f73a77c8d9 --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/CategoryTest.java @@ -0,0 +1,52 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Category model. */ +public class CategoryTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCategory() throws Throwable { + Category categoryModel = + new Category.Builder() + .label("Amendments") + .provenanceIds(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .modification("added") + .build(); + assertEquals(categoryModel.label(), "Amendments"); + assertEquals( + categoryModel.provenanceIds(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals(categoryModel.modification(), "added"); + + String json = TestUtilities.serialize(categoryModel); + + Category categoryModelNew = TestUtilities.deserialize(json, Category.class); + assertTrue(categoryModelNew instanceof Category); + assertEquals(categoryModelNew.label(), "Amendments"); + assertEquals(categoryModelNew.modification(), "added"); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ClassifyElementsOptionsTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ClassifyElementsOptionsTest.java new file mode 100644 index 00000000000..c6d8ec1090d --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ClassifyElementsOptionsTest.java @@ -0,0 +1,51 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.apache.commons.io.IOUtils; +import org.testng.annotations.Test; + +/** Unit test class for the ClassifyElementsOptions model. */ +public class ClassifyElementsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testClassifyElementsOptions() throws Throwable { + ClassifyElementsOptions classifyElementsOptionsModel = + new ClassifyElementsOptions.Builder() + .file(TestUtilities.createMockStream("This is a mock file.")) + .fileContentType("application/pdf") + .model("contracts") + .build(); + assertEquals( + IOUtils.toString(classifyElementsOptionsModel.file()), + IOUtils.toString(TestUtilities.createMockStream("This is a mock file."))); + assertEquals(classifyElementsOptionsModel.fileContentType(), "application/pdf"); + assertEquals(classifyElementsOptionsModel.model(), "contracts"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testClassifyElementsOptionsError() throws Throwable { + new ClassifyElementsOptions.Builder().build(); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ClassifyReturnTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ClassifyReturnTest.java new file mode 100644 index 00000000000..c66517eeba6 --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ClassifyReturnTest.java @@ -0,0 +1,49 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ClassifyReturn model. */ +public class ClassifyReturnTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testClassifyReturn() throws Throwable { + ClassifyReturn classifyReturnModel = new ClassifyReturn(); + assertNull(classifyReturnModel.getDocument()); + assertNull(classifyReturnModel.getModelId()); + assertNull(classifyReturnModel.getModelVersion()); + assertNull(classifyReturnModel.getElements()); + assertNull(classifyReturnModel.getEffectiveDates()); + assertNull(classifyReturnModel.getContractAmounts()); + assertNull(classifyReturnModel.getTerminationDates()); + assertNull(classifyReturnModel.getContractTypes()); + assertNull(classifyReturnModel.getContractTerms()); + assertNull(classifyReturnModel.getPaymentTerms()); + assertNull(classifyReturnModel.getContractCurrencies()); + assertNull(classifyReturnModel.getTables()); + assertNull(classifyReturnModel.getDocumentStructure()); + assertNull(classifyReturnModel.getParties()); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ColumnHeadersTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ColumnHeadersTest.java new file mode 100644 index 00000000000..9a055c7d262 --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ColumnHeadersTest.java @@ -0,0 +1,43 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ColumnHeaders model. */ +public class ColumnHeadersTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testColumnHeaders() throws Throwable { + ColumnHeaders columnHeadersModel = new ColumnHeaders(); + assertNull(columnHeadersModel.getCellId()); + assertNull(columnHeadersModel.getLocation()); + assertNull(columnHeadersModel.getText()); + assertNull(columnHeadersModel.getTextNormalized()); + assertNull(columnHeadersModel.getRowIndexBegin()); + assertNull(columnHeadersModel.getRowIndexEnd()); + assertNull(columnHeadersModel.getColumnIndexBegin()); + assertNull(columnHeadersModel.getColumnIndexEnd()); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/CompareDocumentsOptionsTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/CompareDocumentsOptionsTest.java new file mode 100644 index 00000000000..e08164e25e4 --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/CompareDocumentsOptionsTest.java @@ -0,0 +1,61 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.apache.commons.io.IOUtils; +import org.testng.annotations.Test; + +/** Unit test class for the CompareDocumentsOptions model. */ +public class CompareDocumentsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCompareDocumentsOptions() throws Throwable { + CompareDocumentsOptions compareDocumentsOptionsModel = + new CompareDocumentsOptions.Builder() + .file1(TestUtilities.createMockStream("This is a mock file.")) + .file2(TestUtilities.createMockStream("This is a mock file.")) + .file1ContentType("application/pdf") + .file2ContentType("application/pdf") + .file1Label("testString") + .file2Label("testString") + .model("contracts") + .build(); + assertEquals( + IOUtils.toString(compareDocumentsOptionsModel.file1()), + IOUtils.toString(TestUtilities.createMockStream("This is a mock file."))); + assertEquals( + IOUtils.toString(compareDocumentsOptionsModel.file2()), + IOUtils.toString(TestUtilities.createMockStream("This is a mock file."))); + assertEquals(compareDocumentsOptionsModel.file1ContentType(), "application/pdf"); + assertEquals(compareDocumentsOptionsModel.file2ContentType(), "application/pdf"); + assertEquals(compareDocumentsOptionsModel.file1Label(), "testString"); + assertEquals(compareDocumentsOptionsModel.file2Label(), "testString"); + assertEquals(compareDocumentsOptionsModel.model(), "contracts"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCompareDocumentsOptionsError() throws Throwable { + new CompareDocumentsOptions.Builder().build(); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/CompareReturnTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/CompareReturnTest.java new file mode 100644 index 00000000000..0084a1eb732 --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/CompareReturnTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CompareReturn model. */ +public class CompareReturnTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCompareReturn() throws Throwable { + CompareReturn compareReturnModel = new CompareReturn(); + assertNull(compareReturnModel.getModelId()); + assertNull(compareReturnModel.getModelVersion()); + assertNull(compareReturnModel.getDocuments()); + assertNull(compareReturnModel.getAlignedElements()); + assertNull(compareReturnModel.getUnalignedElements()); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ContactTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ContactTest.java new file mode 100644 index 00000000000..384469aaf0f --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ContactTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Contact model. */ +public class ContactTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testContact() throws Throwable { + Contact contactModel = new Contact(); + assertNull(contactModel.getName()); + assertNull(contactModel.getRole()); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ContextsTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ContextsTest.java new file mode 100644 index 00000000000..d6cda28dc12 --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ContextsTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Contexts model. */ +public class ContextsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testContexts() throws Throwable { + Contexts contextsModel = new Contexts(); + assertNull(contextsModel.getText()); + assertNull(contextsModel.getLocation()); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ContractAmtsTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ContractAmtsTest.java new file mode 100644 index 00000000000..7523646697f --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ContractAmtsTest.java @@ -0,0 +1,41 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ContractAmts model. */ +public class ContractAmtsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testContractAmts() throws Throwable { + ContractAmts contractAmtsModel = new ContractAmts(); + assertNull(contractAmtsModel.getConfidenceLevel()); + assertNull(contractAmtsModel.getText()); + assertNull(contractAmtsModel.getTextNormalized()); + assertNull(contractAmtsModel.getInterpretation()); + assertNull(contractAmtsModel.getProvenanceIds()); + assertNull(contractAmtsModel.getLocation()); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ContractCurrenciesTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ContractCurrenciesTest.java new file mode 100644 index 00000000000..295353bd3e3 --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ContractCurrenciesTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ContractCurrencies model. */ +public class ContractCurrenciesTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testContractCurrencies() throws Throwable { + ContractCurrencies contractCurrenciesModel = new ContractCurrencies(); + assertNull(contractCurrenciesModel.getConfidenceLevel()); + assertNull(contractCurrenciesModel.getText()); + assertNull(contractCurrenciesModel.getTextNormalized()); + assertNull(contractCurrenciesModel.getProvenanceIds()); + assertNull(contractCurrenciesModel.getLocation()); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ContractTermsTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ContractTermsTest.java new file mode 100644 index 00000000000..2c27e247b66 --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ContractTermsTest.java @@ -0,0 +1,41 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ContractTerms model. */ +public class ContractTermsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testContractTerms() throws Throwable { + ContractTerms contractTermsModel = new ContractTerms(); + assertNull(contractTermsModel.getConfidenceLevel()); + assertNull(contractTermsModel.getText()); + assertNull(contractTermsModel.getTextNormalized()); + assertNull(contractTermsModel.getInterpretation()); + assertNull(contractTermsModel.getProvenanceIds()); + assertNull(contractTermsModel.getLocation()); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ContractTypesTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ContractTypesTest.java new file mode 100644 index 00000000000..19ec307f108 --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ContractTypesTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ContractTypes model. */ +public class ContractTypesTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testContractTypes() throws Throwable { + ContractTypes contractTypesModel = new ContractTypes(); + assertNull(contractTypesModel.getConfidenceLevel()); + assertNull(contractTypesModel.getText()); + assertNull(contractTypesModel.getProvenanceIds()); + assertNull(contractTypesModel.getLocation()); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ConvertToHtmlOptionsTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ConvertToHtmlOptionsTest.java new file mode 100644 index 00000000000..d8c5310e822 --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ConvertToHtmlOptionsTest.java @@ -0,0 +1,51 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.apache.commons.io.IOUtils; +import org.testng.annotations.Test; + +/** Unit test class for the ConvertToHtmlOptions model. */ +public class ConvertToHtmlOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testConvertToHtmlOptions() throws Throwable { + ConvertToHtmlOptions convertToHtmlOptionsModel = + new ConvertToHtmlOptions.Builder() + .file(TestUtilities.createMockStream("This is a mock file.")) + .fileContentType("application/pdf") + .model("contracts") + .build(); + assertEquals( + IOUtils.toString(convertToHtmlOptionsModel.file()), + IOUtils.toString(TestUtilities.createMockStream("This is a mock file."))); + assertEquals(convertToHtmlOptionsModel.fileContentType(), "application/pdf"); + assertEquals(convertToHtmlOptionsModel.model(), "contracts"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testConvertToHtmlOptionsError() throws Throwable { + new ConvertToHtmlOptions.Builder().build(); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/CreateBatchOptionsTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/CreateBatchOptionsTest.java new file mode 100644 index 00000000000..a637904428a --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/CreateBatchOptionsTest.java @@ -0,0 +1,63 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.apache.commons.io.IOUtils; +import org.testng.annotations.Test; + +/** Unit test class for the CreateBatchOptions model. */ +public class CreateBatchOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateBatchOptions() throws Throwable { + CreateBatchOptions createBatchOptionsModel = + new CreateBatchOptions.Builder() + .function("html_conversion") + .inputCredentialsFile(TestUtilities.createMockStream("This is a mock file.")) + .inputBucketLocation("testString") + .inputBucketName("testString") + .outputCredentialsFile(TestUtilities.createMockStream("This is a mock file.")) + .outputBucketLocation("testString") + .outputBucketName("testString") + .model("contracts") + .build(); + assertEquals(createBatchOptionsModel.function(), "html_conversion"); + assertEquals( + IOUtils.toString(createBatchOptionsModel.inputCredentialsFile()), + IOUtils.toString(TestUtilities.createMockStream("This is a mock file."))); + assertEquals(createBatchOptionsModel.inputBucketLocation(), "testString"); + assertEquals(createBatchOptionsModel.inputBucketName(), "testString"); + assertEquals( + IOUtils.toString(createBatchOptionsModel.outputCredentialsFile()), + IOUtils.toString(TestUtilities.createMockStream("This is a mock file."))); + assertEquals(createBatchOptionsModel.outputBucketLocation(), "testString"); + assertEquals(createBatchOptionsModel.outputBucketName(), "testString"); + assertEquals(createBatchOptionsModel.model(), "contracts"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateBatchOptionsError() throws Throwable { + new CreateBatchOptions.Builder().build(); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/DeleteFeedbackOptionsTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/DeleteFeedbackOptionsTest.java new file mode 100644 index 00000000000..5bb0dd1460d --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/DeleteFeedbackOptionsTest.java @@ -0,0 +1,43 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteFeedbackOptions model. */ +public class DeleteFeedbackOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteFeedbackOptions() throws Throwable { + DeleteFeedbackOptions deleteFeedbackOptionsModel = + new DeleteFeedbackOptions.Builder().feedbackId("testString").model("contracts").build(); + assertEquals(deleteFeedbackOptionsModel.feedbackId(), "testString"); + assertEquals(deleteFeedbackOptionsModel.model(), "contracts"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteFeedbackOptionsError() throws Throwable { + new DeleteFeedbackOptions.Builder().build(); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/DocCountsTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/DocCountsTest.java new file mode 100644 index 00000000000..7f14a6185a4 --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/DocCountsTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DocCounts model. */ +public class DocCountsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDocCounts() throws Throwable { + DocCounts docCountsModel = new DocCounts(); + assertNull(docCountsModel.getTotal()); + assertNull(docCountsModel.getPending()); + assertNull(docCountsModel.getSuccessful()); + assertNull(docCountsModel.getFailed()); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/DocInfoTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/DocInfoTest.java new file mode 100644 index 00000000000..6328af2c777 --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/DocInfoTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DocInfo model. */ +public class DocInfoTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDocInfo() throws Throwable { + DocInfo docInfoModel = new DocInfo(); + assertNull(docInfoModel.getHtml()); + assertNull(docInfoModel.getTitle()); + assertNull(docInfoModel.getHash()); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/DocStructureTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/DocStructureTest.java new file mode 100644 index 00000000000..7e2a7705b8b --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/DocStructureTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DocStructure model. */ +public class DocStructureTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDocStructure() throws Throwable { + DocStructure docStructureModel = new DocStructure(); + assertNull(docStructureModel.getSectionTitles()); + assertNull(docStructureModel.getLeadingSentences()); + assertNull(docStructureModel.getParagraphs()); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/DocumentTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/DocumentTest.java new file mode 100644 index 00000000000..1f534f0e9f6 --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/DocumentTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Document model. */ +public class DocumentTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDocument() throws Throwable { + Document documentModel = new Document(); + assertNull(documentModel.getTitle()); + assertNull(documentModel.getHtml()); + assertNull(documentModel.getHash()); + assertNull(documentModel.getLabel()); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/EffectiveDatesTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/EffectiveDatesTest.java new file mode 100644 index 00000000000..f272b282a40 --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/EffectiveDatesTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the EffectiveDates model. */ +public class EffectiveDatesTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testEffectiveDates() throws Throwable { + EffectiveDates effectiveDatesModel = new EffectiveDates(); + assertNull(effectiveDatesModel.getConfidenceLevel()); + assertNull(effectiveDatesModel.getText()); + assertNull(effectiveDatesModel.getTextNormalized()); + assertNull(effectiveDatesModel.getProvenanceIds()); + assertNull(effectiveDatesModel.getLocation()); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ElementLocationsTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ElementLocationsTest.java new file mode 100644 index 00000000000..a5e9d42c3e7 --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ElementLocationsTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ElementLocations model. */ +public class ElementLocationsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testElementLocations() throws Throwable { + ElementLocations elementLocationsModel = new ElementLocations(); + assertNull(elementLocationsModel.getBegin()); + assertNull(elementLocationsModel.getEnd()); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ElementPairTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ElementPairTest.java new file mode 100644 index 00000000000..e2cee143db4 --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ElementPairTest.java @@ -0,0 +1,41 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ElementPair model. */ +public class ElementPairTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testElementPair() throws Throwable { + ElementPair elementPairModel = new ElementPair(); + assertNull(elementPairModel.getDocumentLabel()); + assertNull(elementPairModel.getText()); + assertNull(elementPairModel.getLocation()); + assertNull(elementPairModel.getTypes()); + assertNull(elementPairModel.getCategories()); + assertNull(elementPairModel.getAttributes()); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ElementTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ElementTest.java new file mode 100644 index 00000000000..7c2c05808ef --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ElementTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Element model. */ +public class ElementTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testElement() throws Throwable { + Element elementModel = new Element(); + assertNull(elementModel.getLocation()); + assertNull(elementModel.getText()); + assertNull(elementModel.getTypes()); + assertNull(elementModel.getCategories()); + assertNull(elementModel.getAttributes()); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ExtractTablesOptionsTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ExtractTablesOptionsTest.java new file mode 100644 index 00000000000..77918844a61 --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ExtractTablesOptionsTest.java @@ -0,0 +1,51 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.apache.commons.io.IOUtils; +import org.testng.annotations.Test; + +/** Unit test class for the ExtractTablesOptions model. */ +public class ExtractTablesOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testExtractTablesOptions() throws Throwable { + ExtractTablesOptions extractTablesOptionsModel = + new ExtractTablesOptions.Builder() + .file(TestUtilities.createMockStream("This is a mock file.")) + .fileContentType("application/pdf") + .model("contracts") + .build(); + assertEquals( + IOUtils.toString(extractTablesOptionsModel.file()), + IOUtils.toString(TestUtilities.createMockStream("This is a mock file."))); + assertEquals(extractTablesOptionsModel.fileContentType(), "application/pdf"); + assertEquals(extractTablesOptionsModel.model(), "contracts"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testExtractTablesOptionsError() throws Throwable { + new ExtractTablesOptions.Builder().build(); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/FeedbackDataInputTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/FeedbackDataInputTest.java new file mode 100644 index 00000000000..616c7fcbd93 --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/FeedbackDataInputTest.java @@ -0,0 +1,135 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the FeedbackDataInput model. */ +public class FeedbackDataInputTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testFeedbackDataInput() throws Throwable { + ShortDoc shortDocModel = new ShortDoc.Builder().title("testString").hash("testString").build(); + assertEquals(shortDocModel.title(), "testString"); + assertEquals(shortDocModel.hash(), "testString"); + + Location locationModel = + new Location.Builder().begin(Long.valueOf("26")).end(Long.valueOf("26")).build(); + assertEquals(locationModel.begin(), Long.valueOf("26")); + assertEquals(locationModel.end(), Long.valueOf("26")); + + Label labelModel = new Label.Builder().nature("testString").party("testString").build(); + assertEquals(labelModel.nature(), "testString"); + assertEquals(labelModel.party(), "testString"); + + TypeLabel typeLabelModel = + new TypeLabel.Builder() + .label(labelModel) + .provenanceIds(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .modification("added") + .build(); + assertEquals(typeLabelModel.label(), labelModel); + assertEquals( + typeLabelModel.provenanceIds(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals(typeLabelModel.modification(), "added"); + + Category categoryModel = + new Category.Builder() + .label("Amendments") + .provenanceIds(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .modification("added") + .build(); + assertEquals(categoryModel.label(), "Amendments"); + assertEquals( + categoryModel.provenanceIds(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals(categoryModel.modification(), "added"); + + OriginalLabelsIn originalLabelsInModel = + new OriginalLabelsIn.Builder() + .types(new java.util.ArrayList(java.util.Arrays.asList(typeLabelModel))) + .categories(new java.util.ArrayList(java.util.Arrays.asList(categoryModel))) + .build(); + assertEquals( + originalLabelsInModel.types(), + new java.util.ArrayList(java.util.Arrays.asList(typeLabelModel))); + assertEquals( + originalLabelsInModel.categories(), + new java.util.ArrayList(java.util.Arrays.asList(categoryModel))); + + UpdatedLabelsIn updatedLabelsInModel = + new UpdatedLabelsIn.Builder() + .types(new java.util.ArrayList(java.util.Arrays.asList(typeLabelModel))) + .categories(new java.util.ArrayList(java.util.Arrays.asList(categoryModel))) + .build(); + assertEquals( + updatedLabelsInModel.types(), + new java.util.ArrayList(java.util.Arrays.asList(typeLabelModel))); + assertEquals( + updatedLabelsInModel.categories(), + new java.util.ArrayList(java.util.Arrays.asList(categoryModel))); + + FeedbackDataInput feedbackDataInputModel = + new FeedbackDataInput.Builder() + .feedbackType("testString") + .document(shortDocModel) + .modelId("testString") + .modelVersion("testString") + .location(locationModel) + .text("testString") + .originalLabels(originalLabelsInModel) + .updatedLabels(updatedLabelsInModel) + .build(); + assertEquals(feedbackDataInputModel.feedbackType(), "testString"); + assertEquals(feedbackDataInputModel.document(), shortDocModel); + assertEquals(feedbackDataInputModel.modelId(), "testString"); + assertEquals(feedbackDataInputModel.modelVersion(), "testString"); + assertEquals(feedbackDataInputModel.location(), locationModel); + assertEquals(feedbackDataInputModel.text(), "testString"); + assertEquals(feedbackDataInputModel.originalLabels(), originalLabelsInModel); + assertEquals(feedbackDataInputModel.updatedLabels(), updatedLabelsInModel); + + String json = TestUtilities.serialize(feedbackDataInputModel); + + FeedbackDataInput feedbackDataInputModelNew = + TestUtilities.deserialize(json, FeedbackDataInput.class); + assertTrue(feedbackDataInputModelNew instanceof FeedbackDataInput); + assertEquals(feedbackDataInputModelNew.feedbackType(), "testString"); + assertEquals(feedbackDataInputModelNew.document().toString(), shortDocModel.toString()); + assertEquals(feedbackDataInputModelNew.modelId(), "testString"); + assertEquals(feedbackDataInputModelNew.modelVersion(), "testString"); + assertEquals(feedbackDataInputModelNew.location().toString(), locationModel.toString()); + assertEquals(feedbackDataInputModelNew.text(), "testString"); + assertEquals( + feedbackDataInputModelNew.originalLabels().toString(), originalLabelsInModel.toString()); + assertEquals( + feedbackDataInputModelNew.updatedLabels().toString(), updatedLabelsInModel.toString()); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testFeedbackDataInputError() throws Throwable { + new FeedbackDataInput.Builder().build(); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/FeedbackDataOutputTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/FeedbackDataOutputTest.java new file mode 100644 index 00000000000..83f141d3a16 --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/FeedbackDataOutputTest.java @@ -0,0 +1,44 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the FeedbackDataOutput model. */ +public class FeedbackDataOutputTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testFeedbackDataOutput() throws Throwable { + FeedbackDataOutput feedbackDataOutputModel = new FeedbackDataOutput(); + assertNull(feedbackDataOutputModel.getFeedbackType()); + assertNull(feedbackDataOutputModel.getDocument()); + assertNull(feedbackDataOutputModel.getModelId()); + assertNull(feedbackDataOutputModel.getModelVersion()); + assertNull(feedbackDataOutputModel.getLocation()); + assertNull(feedbackDataOutputModel.getText()); + assertNull(feedbackDataOutputModel.getOriginalLabels()); + assertNull(feedbackDataOutputModel.getUpdatedLabels()); + assertNull(feedbackDataOutputModel.getPagination()); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/FeedbackDeletedTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/FeedbackDeletedTest.java new file mode 100644 index 00000000000..ba14d0e0f63 --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/FeedbackDeletedTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the FeedbackDeleted model. */ +public class FeedbackDeletedTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testFeedbackDeleted() throws Throwable { + FeedbackDeleted feedbackDeletedModel = new FeedbackDeleted(); + assertNull(feedbackDeletedModel.getStatus()); + assertNull(feedbackDeletedModel.getMessage()); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/FeedbackListTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/FeedbackListTest.java new file mode 100644 index 00000000000..f197d670415 --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/FeedbackListTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the FeedbackList model. */ +public class FeedbackListTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testFeedbackList() throws Throwable { + FeedbackList feedbackListModel = new FeedbackList(); + assertNull(feedbackListModel.getFeedback()); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/FeedbackReturnTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/FeedbackReturnTest.java new file mode 100644 index 00000000000..f6d6500550d --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/FeedbackReturnTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the FeedbackReturn model. */ +public class FeedbackReturnTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testFeedbackReturn() throws Throwable { + FeedbackReturn feedbackReturnModel = new FeedbackReturn(); + assertNull(feedbackReturnModel.getFeedbackId()); + assertNull(feedbackReturnModel.getUserId()); + assertNull(feedbackReturnModel.getComment()); + assertNull(feedbackReturnModel.getCreated()); + assertNull(feedbackReturnModel.getFeedbackData()); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/GetBatchOptionsTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/GetBatchOptionsTest.java new file mode 100644 index 00000000000..d2654857c7d --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/GetBatchOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetBatchOptions model. */ +public class GetBatchOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetBatchOptions() throws Throwable { + GetBatchOptions getBatchOptionsModel = + new GetBatchOptions.Builder().batchId("testString").build(); + assertEquals(getBatchOptionsModel.batchId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetBatchOptionsError() throws Throwable { + new GetBatchOptions.Builder().build(); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/GetFeedbackOptionsTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/GetFeedbackOptionsTest.java new file mode 100644 index 00000000000..4b8f8e5bf2a --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/GetFeedbackOptionsTest.java @@ -0,0 +1,43 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetFeedbackOptions model. */ +public class GetFeedbackOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetFeedbackOptions() throws Throwable { + GetFeedbackOptions getFeedbackOptionsModel = + new GetFeedbackOptions.Builder().feedbackId("testString").model("contracts").build(); + assertEquals(getFeedbackOptionsModel.feedbackId(), "testString"); + assertEquals(getFeedbackOptionsModel.model(), "contracts"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetFeedbackOptionsError() throws Throwable { + new GetFeedbackOptions.Builder().build(); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/GetFeedbackTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/GetFeedbackTest.java new file mode 100644 index 00000000000..d9de89a49ec --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/GetFeedbackTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetFeedback model. */ +public class GetFeedbackTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetFeedback() throws Throwable { + GetFeedback getFeedbackModel = new GetFeedback(); + assertNull(getFeedbackModel.getFeedbackId()); + assertNull(getFeedbackModel.getCreated()); + assertNull(getFeedbackModel.getComment()); + assertNull(getFeedbackModel.getFeedbackData()); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/HTMLReturnTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/HTMLReturnTest.java new file mode 100644 index 00000000000..dc3bc6b48dd --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/HTMLReturnTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the HTMLReturn model. */ +public class HTMLReturnTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testHTMLReturn() throws Throwable { + HTMLReturn htmlReturnModel = new HTMLReturn(); + assertNull(htmlReturnModel.getNumPages()); + assertNull(htmlReturnModel.getAuthor()); + assertNull(htmlReturnModel.getPublicationDate()); + assertNull(htmlReturnModel.getTitle()); + assertNull(htmlReturnModel.getHtml()); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/InterpretationTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/InterpretationTest.java new file mode 100644 index 00000000000..ed832194cf2 --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/InterpretationTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Interpretation model. */ +public class InterpretationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testInterpretation() throws Throwable { + Interpretation interpretationModel = new Interpretation(); + assertNull(interpretationModel.getValue()); + assertNull(interpretationModel.getNumericValue()); + assertNull(interpretationModel.getUnit()); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/KeyTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/KeyTest.java new file mode 100644 index 00000000000..f4e6b53afab --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/KeyTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Key model. */ +public class KeyTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testKey() throws Throwable { + Key keyModel = new Key(); + assertNull(keyModel.getCellId()); + assertNull(keyModel.getLocation()); + assertNull(keyModel.getText()); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/KeyValuePairTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/KeyValuePairTest.java new file mode 100644 index 00000000000..db2a7c0a6b0 --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/KeyValuePairTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the KeyValuePair model. */ +public class KeyValuePairTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testKeyValuePair() throws Throwable { + KeyValuePair keyValuePairModel = new KeyValuePair(); + assertNull(keyValuePairModel.getKey()); + assertNull(keyValuePairModel.getValue()); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/LabelTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/LabelTest.java new file mode 100644 index 00000000000..8ebeeec9ab3 --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/LabelTest.java @@ -0,0 +1,49 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Label model. */ +public class LabelTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testLabel() throws Throwable { + Label labelModel = new Label.Builder().nature("testString").party("testString").build(); + assertEquals(labelModel.nature(), "testString"); + assertEquals(labelModel.party(), "testString"); + + String json = TestUtilities.serialize(labelModel); + + Label labelModelNew = TestUtilities.deserialize(json, Label.class); + assertTrue(labelModelNew instanceof Label); + assertEquals(labelModelNew.nature(), "testString"); + assertEquals(labelModelNew.party(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testLabelError() throws Throwable { + new Label.Builder().build(); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/LeadingSentenceTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/LeadingSentenceTest.java new file mode 100644 index 00000000000..543e0ff76f4 --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/LeadingSentenceTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the LeadingSentence model. */ +public class LeadingSentenceTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testLeadingSentence() throws Throwable { + LeadingSentence leadingSentenceModel = new LeadingSentence(); + assertNull(leadingSentenceModel.getText()); + assertNull(leadingSentenceModel.getLocation()); + assertNull(leadingSentenceModel.getElementLocations()); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ListBatchesOptionsTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ListBatchesOptionsTest.java new file mode 100644 index 00000000000..b87980628b9 --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ListBatchesOptionsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListBatchesOptions model. */ +public class ListBatchesOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListBatchesOptions() throws Throwable { + ListBatchesOptions listBatchesOptionsModel = new ListBatchesOptions(); + assertNotNull(listBatchesOptionsModel); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ListFeedbackOptionsTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ListFeedbackOptionsTest.java new file mode 100644 index 00000000000..3db445d51c0 --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ListFeedbackOptionsTest.java @@ -0,0 +1,65 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListFeedbackOptions model. */ +public class ListFeedbackOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListFeedbackOptions() throws Throwable { + ListFeedbackOptions listFeedbackOptionsModel = + new ListFeedbackOptions.Builder() + .feedbackType("testString") + .documentTitle("testString") + .modelId("testString") + .modelVersion("testString") + .categoryRemoved("testString") + .categoryAdded("testString") + .categoryNotChanged("testString") + .typeRemoved("testString") + .typeAdded("testString") + .typeNotChanged("testString") + .pageLimit(Long.valueOf("100")) + .cursor("testString") + .sort("testString") + .includeTotal(true) + .build(); + assertEquals(listFeedbackOptionsModel.feedbackType(), "testString"); + assertEquals(listFeedbackOptionsModel.documentTitle(), "testString"); + assertEquals(listFeedbackOptionsModel.modelId(), "testString"); + assertEquals(listFeedbackOptionsModel.modelVersion(), "testString"); + assertEquals(listFeedbackOptionsModel.categoryRemoved(), "testString"); + assertEquals(listFeedbackOptionsModel.categoryAdded(), "testString"); + assertEquals(listFeedbackOptionsModel.categoryNotChanged(), "testString"); + assertEquals(listFeedbackOptionsModel.typeRemoved(), "testString"); + assertEquals(listFeedbackOptionsModel.typeAdded(), "testString"); + assertEquals(listFeedbackOptionsModel.typeNotChanged(), "testString"); + assertEquals(listFeedbackOptionsModel.pageLimit(), Long.valueOf("100")); + assertEquals(listFeedbackOptionsModel.cursor(), "testString"); + assertEquals(listFeedbackOptionsModel.sort(), "testString"); + assertEquals(listFeedbackOptionsModel.includeTotal(), Boolean.valueOf(true)); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/LocationTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/LocationTest.java new file mode 100644 index 00000000000..b738cc95536 --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/LocationTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Location model. */ +public class LocationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testLocation() throws Throwable { + Location locationModel = + new Location.Builder().begin(Long.valueOf("26")).end(Long.valueOf("26")).build(); + assertEquals(locationModel.begin(), Long.valueOf("26")); + assertEquals(locationModel.end(), Long.valueOf("26")); + + String json = TestUtilities.serialize(locationModel); + + Location locationModelNew = TestUtilities.deserialize(json, Location.class); + assertTrue(locationModelNew instanceof Location); + assertEquals(locationModelNew.begin(), Long.valueOf("26")); + assertEquals(locationModelNew.end(), Long.valueOf("26")); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testLocationError() throws Throwable { + new Location.Builder().build(); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/MentionTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/MentionTest.java new file mode 100644 index 00000000000..bf8af362341 --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/MentionTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Mention model. */ +public class MentionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMention() throws Throwable { + Mention mentionModel = new Mention(); + assertNull(mentionModel.getText()); + assertNull(mentionModel.getLocation()); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/OriginalLabelsInTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/OriginalLabelsInTest.java new file mode 100644 index 00000000000..b4e29d36d1a --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/OriginalLabelsInTest.java @@ -0,0 +1,84 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the OriginalLabelsIn model. */ +public class OriginalLabelsInTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testOriginalLabelsIn() throws Throwable { + Label labelModel = new Label.Builder().nature("testString").party("testString").build(); + assertEquals(labelModel.nature(), "testString"); + assertEquals(labelModel.party(), "testString"); + + TypeLabel typeLabelModel = + new TypeLabel.Builder() + .label(labelModel) + .provenanceIds(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .modification("added") + .build(); + assertEquals(typeLabelModel.label(), labelModel); + assertEquals( + typeLabelModel.provenanceIds(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals(typeLabelModel.modification(), "added"); + + Category categoryModel = + new Category.Builder() + .label("Amendments") + .provenanceIds(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .modification("added") + .build(); + assertEquals(categoryModel.label(), "Amendments"); + assertEquals( + categoryModel.provenanceIds(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals(categoryModel.modification(), "added"); + + OriginalLabelsIn originalLabelsInModel = + new OriginalLabelsIn.Builder() + .types(new java.util.ArrayList(java.util.Arrays.asList(typeLabelModel))) + .categories(new java.util.ArrayList(java.util.Arrays.asList(categoryModel))) + .build(); + assertEquals( + originalLabelsInModel.types(), + new java.util.ArrayList(java.util.Arrays.asList(typeLabelModel))); + assertEquals( + originalLabelsInModel.categories(), + new java.util.ArrayList(java.util.Arrays.asList(categoryModel))); + + String json = TestUtilities.serialize(originalLabelsInModel); + + OriginalLabelsIn originalLabelsInModelNew = + TestUtilities.deserialize(json, OriginalLabelsIn.class); + assertTrue(originalLabelsInModelNew instanceof OriginalLabelsIn); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testOriginalLabelsInError() throws Throwable { + new OriginalLabelsIn.Builder().build(); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/OriginalLabelsOutTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/OriginalLabelsOutTest.java new file mode 100644 index 00000000000..918a6a8bd4f --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/OriginalLabelsOutTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the OriginalLabelsOut model. */ +public class OriginalLabelsOutTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testOriginalLabelsOut() throws Throwable { + OriginalLabelsOut originalLabelsOutModel = new OriginalLabelsOut(); + assertNull(originalLabelsOutModel.getTypes()); + assertNull(originalLabelsOutModel.getCategories()); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/PaginationTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/PaginationTest.java new file mode 100644 index 00000000000..5961169b473 --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/PaginationTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Pagination model. */ +public class PaginationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testPagination() throws Throwable { + Pagination paginationModel = new Pagination(); + assertNull(paginationModel.getRefreshCursor()); + assertNull(paginationModel.getNextCursor()); + assertNull(paginationModel.getRefreshUrl()); + assertNull(paginationModel.getNextUrl()); + assertNull(paginationModel.getTotal()); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ParagraphsTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ParagraphsTest.java new file mode 100644 index 00000000000..d3a00c0d02f --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ParagraphsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Paragraphs model. */ +public class ParagraphsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testParagraphs() throws Throwable { + Paragraphs paragraphsModel = new Paragraphs(); + assertNull(paragraphsModel.getLocation()); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/PartiesTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/PartiesTest.java new file mode 100644 index 00000000000..770da14c232 --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/PartiesTest.java @@ -0,0 +1,41 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Parties model. */ +public class PartiesTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testParties() throws Throwable { + Parties partiesModel = new Parties(); + assertNull(partiesModel.getParty()); + assertNull(partiesModel.getRole()); + assertNull(partiesModel.getImportance()); + assertNull(partiesModel.getAddresses()); + assertNull(partiesModel.getContacts()); + assertNull(partiesModel.getMentions()); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/PaymentTermsTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/PaymentTermsTest.java new file mode 100644 index 00000000000..baa5000d7e8 --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/PaymentTermsTest.java @@ -0,0 +1,41 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the PaymentTerms model. */ +public class PaymentTermsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testPaymentTerms() throws Throwable { + PaymentTerms paymentTermsModel = new PaymentTerms(); + assertNull(paymentTermsModel.getConfidenceLevel()); + assertNull(paymentTermsModel.getText()); + assertNull(paymentTermsModel.getTextNormalized()); + assertNull(paymentTermsModel.getInterpretation()); + assertNull(paymentTermsModel.getProvenanceIds()); + assertNull(paymentTermsModel.getLocation()); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/RowHeadersTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/RowHeadersTest.java new file mode 100644 index 00000000000..52589c60811 --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/RowHeadersTest.java @@ -0,0 +1,43 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RowHeaders model. */ +public class RowHeadersTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRowHeaders() throws Throwable { + RowHeaders rowHeadersModel = new RowHeaders(); + assertNull(rowHeadersModel.getCellId()); + assertNull(rowHeadersModel.getLocation()); + assertNull(rowHeadersModel.getText()); + assertNull(rowHeadersModel.getTextNormalized()); + assertNull(rowHeadersModel.getRowIndexBegin()); + assertNull(rowHeadersModel.getRowIndexEnd()); + assertNull(rowHeadersModel.getColumnIndexBegin()); + assertNull(rowHeadersModel.getColumnIndexEnd()); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/SectionTitleTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/SectionTitleTest.java new file mode 100644 index 00000000000..9856d17c13e --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/SectionTitleTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SectionTitle model. */ +public class SectionTitleTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSectionTitle() throws Throwable { + SectionTitle sectionTitleModel = new SectionTitle(); + assertNull(sectionTitleModel.getText()); + assertNull(sectionTitleModel.getLocation()); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/SectionTitlesTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/SectionTitlesTest.java new file mode 100644 index 00000000000..a40e01af08e --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/SectionTitlesTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SectionTitles model. */ +public class SectionTitlesTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSectionTitles() throws Throwable { + SectionTitles sectionTitlesModel = new SectionTitles(); + assertNull(sectionTitlesModel.getText()); + assertNull(sectionTitlesModel.getLocation()); + assertNull(sectionTitlesModel.getLevel()); + assertNull(sectionTitlesModel.getElementLocations()); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ShortDocTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ShortDocTest.java new file mode 100644 index 00000000000..b5b2fe3939e --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ShortDocTest.java @@ -0,0 +1,44 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ShortDoc model. */ +public class ShortDocTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testShortDoc() throws Throwable { + ShortDoc shortDocModel = new ShortDoc.Builder().title("testString").hash("testString").build(); + assertEquals(shortDocModel.title(), "testString"); + assertEquals(shortDocModel.hash(), "testString"); + + String json = TestUtilities.serialize(shortDocModel); + + ShortDoc shortDocModelNew = TestUtilities.deserialize(json, ShortDoc.class); + assertTrue(shortDocModelNew instanceof ShortDoc); + assertEquals(shortDocModelNew.title(), "testString"); + assertEquals(shortDocModelNew.hash(), "testString"); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/TableHeadersTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/TableHeadersTest.java new file mode 100644 index 00000000000..c34892a9be5 --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/TableHeadersTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TableHeaders model. */ +public class TableHeadersTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTableHeaders() throws Throwable { + TableHeaders tableHeadersModel = new TableHeaders(); + assertNull(tableHeadersModel.getCellId()); + assertNull(tableHeadersModel.getLocation()); + assertNull(tableHeadersModel.getText()); + assertNull(tableHeadersModel.getRowIndexBegin()); + assertNull(tableHeadersModel.getRowIndexEnd()); + assertNull(tableHeadersModel.getColumnIndexBegin()); + assertNull(tableHeadersModel.getColumnIndexEnd()); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/TableReturnTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/TableReturnTest.java new file mode 100644 index 00000000000..2ef7920bbb9 --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/TableReturnTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TableReturn model. */ +public class TableReturnTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTableReturn() throws Throwable { + TableReturn tableReturnModel = new TableReturn(); + assertNull(tableReturnModel.getDocument()); + assertNull(tableReturnModel.getModelId()); + assertNull(tableReturnModel.getModelVersion()); + assertNull(tableReturnModel.getTables()); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/TableTitleTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/TableTitleTest.java new file mode 100644 index 00000000000..f6eb837dcdf --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/TableTitleTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TableTitle model. */ +public class TableTitleTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTableTitle() throws Throwable { + TableTitle tableTitleModel = new TableTitle(); + assertNull(tableTitleModel.getLocation()); + assertNull(tableTitleModel.getText()); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/TablesTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/TablesTest.java new file mode 100644 index 00000000000..a5043c9bdab --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/TablesTest.java @@ -0,0 +1,45 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Tables model. */ +public class TablesTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTables() throws Throwable { + Tables tablesModel = new Tables(); + assertNull(tablesModel.getLocation()); + assertNull(tablesModel.getText()); + assertNull(tablesModel.getSectionTitle()); + assertNull(tablesModel.getTitle()); + assertNull(tablesModel.getTableHeaders()); + assertNull(tablesModel.getRowHeaders()); + assertNull(tablesModel.getColumnHeaders()); + assertNull(tablesModel.getBodyCells()); + assertNull(tablesModel.getContexts()); + assertNull(tablesModel.getKeyValuePairs()); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/TerminationDatesTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/TerminationDatesTest.java new file mode 100644 index 00000000000..b6ece51eac0 --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/TerminationDatesTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TerminationDates model. */ +public class TerminationDatesTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTerminationDates() throws Throwable { + TerminationDates terminationDatesModel = new TerminationDates(); + assertNull(terminationDatesModel.getConfidenceLevel()); + assertNull(terminationDatesModel.getText()); + assertNull(terminationDatesModel.getTextNormalized()); + assertNull(terminationDatesModel.getProvenanceIds()); + assertNull(terminationDatesModel.getLocation()); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/TypeLabelComparisonTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/TypeLabelComparisonTest.java new file mode 100644 index 00000000000..7d6f5cae6cc --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/TypeLabelComparisonTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TypeLabelComparison model. */ +public class TypeLabelComparisonTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTypeLabelComparison() throws Throwable { + TypeLabelComparison typeLabelComparisonModel = new TypeLabelComparison(); + assertNull(typeLabelComparisonModel.getLabel()); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/TypeLabelTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/TypeLabelTest.java new file mode 100644 index 00000000000..9bbd6680869 --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/TypeLabelTest.java @@ -0,0 +1,56 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TypeLabel model. */ +public class TypeLabelTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTypeLabel() throws Throwable { + Label labelModel = new Label.Builder().nature("testString").party("testString").build(); + assertEquals(labelModel.nature(), "testString"); + assertEquals(labelModel.party(), "testString"); + + TypeLabel typeLabelModel = + new TypeLabel.Builder() + .label(labelModel) + .provenanceIds(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .modification("added") + .build(); + assertEquals(typeLabelModel.label(), labelModel); + assertEquals( + typeLabelModel.provenanceIds(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals(typeLabelModel.modification(), "added"); + + String json = TestUtilities.serialize(typeLabelModel); + + TypeLabel typeLabelModelNew = TestUtilities.deserialize(json, TypeLabel.class); + assertTrue(typeLabelModelNew instanceof TypeLabel); + assertEquals(typeLabelModelNew.label().toString(), labelModel.toString()); + assertEquals(typeLabelModelNew.modification(), "added"); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/UnalignedElementTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/UnalignedElementTest.java new file mode 100644 index 00000000000..5cf65559cac --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/UnalignedElementTest.java @@ -0,0 +1,41 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the UnalignedElement model. */ +public class UnalignedElementTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUnalignedElement() throws Throwable { + UnalignedElement unalignedElementModel = new UnalignedElement(); + assertNull(unalignedElementModel.getDocumentLabel()); + assertNull(unalignedElementModel.getLocation()); + assertNull(unalignedElementModel.getText()); + assertNull(unalignedElementModel.getTypes()); + assertNull(unalignedElementModel.getCategories()); + assertNull(unalignedElementModel.getAttributes()); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/UpdateBatchOptionsTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/UpdateBatchOptionsTest.java new file mode 100644 index 00000000000..74b06d549a0 --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/UpdateBatchOptionsTest.java @@ -0,0 +1,48 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the UpdateBatchOptions model. */ +public class UpdateBatchOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateBatchOptions() throws Throwable { + UpdateBatchOptions updateBatchOptionsModel = + new UpdateBatchOptions.Builder() + .batchId("testString") + .action("rescan") + .model("contracts") + .build(); + assertEquals(updateBatchOptionsModel.batchId(), "testString"); + assertEquals(updateBatchOptionsModel.action(), "rescan"); + assertEquals(updateBatchOptionsModel.model(), "contracts"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateBatchOptionsError() throws Throwable { + new UpdateBatchOptions.Builder().build(); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/UpdatedLabelsInTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/UpdatedLabelsInTest.java new file mode 100644 index 00000000000..c73da99d169 --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/UpdatedLabelsInTest.java @@ -0,0 +1,84 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the UpdatedLabelsIn model. */ +public class UpdatedLabelsInTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdatedLabelsIn() throws Throwable { + Label labelModel = new Label.Builder().nature("testString").party("testString").build(); + assertEquals(labelModel.nature(), "testString"); + assertEquals(labelModel.party(), "testString"); + + TypeLabel typeLabelModel = + new TypeLabel.Builder() + .label(labelModel) + .provenanceIds(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .modification("added") + .build(); + assertEquals(typeLabelModel.label(), labelModel); + assertEquals( + typeLabelModel.provenanceIds(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals(typeLabelModel.modification(), "added"); + + Category categoryModel = + new Category.Builder() + .label("Amendments") + .provenanceIds(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .modification("added") + .build(); + assertEquals(categoryModel.label(), "Amendments"); + assertEquals( + categoryModel.provenanceIds(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals(categoryModel.modification(), "added"); + + UpdatedLabelsIn updatedLabelsInModel = + new UpdatedLabelsIn.Builder() + .types(new java.util.ArrayList(java.util.Arrays.asList(typeLabelModel))) + .categories(new java.util.ArrayList(java.util.Arrays.asList(categoryModel))) + .build(); + assertEquals( + updatedLabelsInModel.types(), + new java.util.ArrayList(java.util.Arrays.asList(typeLabelModel))); + assertEquals( + updatedLabelsInModel.categories(), + new java.util.ArrayList(java.util.Arrays.asList(categoryModel))); + + String json = TestUtilities.serialize(updatedLabelsInModel); + + UpdatedLabelsIn updatedLabelsInModelNew = + TestUtilities.deserialize(json, UpdatedLabelsIn.class); + assertTrue(updatedLabelsInModelNew instanceof UpdatedLabelsIn); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdatedLabelsInError() throws Throwable { + new UpdatedLabelsIn.Builder().build(); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/UpdatedLabelsOutTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/UpdatedLabelsOutTest.java new file mode 100644 index 00000000000..4184cd4ed5f --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/UpdatedLabelsOutTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the UpdatedLabelsOut model. */ +public class UpdatedLabelsOutTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdatedLabelsOut() throws Throwable { + UpdatedLabelsOut updatedLabelsOutModel = new UpdatedLabelsOut(); + assertNull(updatedLabelsOutModel.getTypes()); + assertNull(updatedLabelsOutModel.getCategories()); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ValueTest.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ValueTest.java new file mode 100644 index 00000000000..49a9313a8db --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/model/ValueTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.compare_comply.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Value model. */ +public class ValueTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testValue() throws Throwable { + Value valueModel = new Value(); + assertNull(valueModel.getCellId()); + assertNull(valueModel.getLocation()); + assertNull(valueModel.getText()); + } +} diff --git a/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/utils/TestUtilities.java b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/utils/TestUtilities.java new file mode 100644 index 00000000000..9da4aa5265c --- /dev/null +++ b/compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/utils/TestUtilities.java @@ -0,0 +1,128 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.compare_comply.v1.utils; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.cloud.sdk.core.util.GsonSingleton; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import okhttp3.HttpUrl; +import okhttp3.mockwebserver.RecordedRequest; + +/** A class used by the unit tests containing utility functions. */ +public class TestUtilities { + public static Map createMockMap() { + Map mockMap = new HashMap<>(); + mockMap.put("foo", "bar"); + return mockMap; + } + + public static HashMap createMockStreamMap() { + return new HashMap() { + { + put("key1", createMockStream("This is a mock file.")); + } + }; + } + + public static Map parseQueryString(RecordedRequest req) { + Map queryMap = new HashMap<>(); + + try { + HttpUrl requestUrl = req.getRequestUrl(); + + if (requestUrl != null) { + Set queryParamsNames = requestUrl.queryParameterNames(); + // map the parameter name to its corresponding value + for (String p : queryParamsNames) { + // get the corresponding value for the parameter (p) + List val = requestUrl.queryParameterValues(p); + if (val != null && !val.isEmpty()) { + String joinedQuery = String.join(",", val); + queryMap.put(p, joinedQuery); + } + } + } + if (queryMap.isEmpty()) { + return null; + } + } catch (Exception e) { + return null; + } + + return queryMap; + } + + public static String parseReqPath(RecordedRequest req) { + String parsedPath = null; + + try { + String fullPath = req.getPath(); + if (fullPath != null && !fullPath.isEmpty()) { + // retrieve the path segment before the query parameter + parsedPath = fullPath.split("\\?", 2)[0]; + } + if (parsedPath.isEmpty() || parsedPath == null) { + return null; + } + + } catch (Exception e) { + return null; + } + + return parsedPath; + } + + public static String serialize(Object obj) { + return GsonSingleton.getGson().toJson(obj); + } + + public static T deserialize(String json, Class clazz) { + return GsonSingleton.getGson().fromJson(json, clazz); + } + + public static InputStream createMockStream(String s) { + return new ByteArrayInputStream(s.getBytes()); + } + + public static List creatMockListFileWithMetadata() { + List list = new ArrayList(); + byte[] fileBytes = {(byte) 0xde, (byte) 0xad, (byte) 0xbe, (byte) 0xef}; + InputStream inputStream = new ByteArrayInputStream(fileBytes); + FileWithMetadata.Builder builder = new FileWithMetadata.Builder(); + builder.data(inputStream); + FileWithMetadata fileWithMetadata = builder.build(); + list.add(fileWithMetadata); + + return list; + } + + public static byte[] createMockByteArray(String bytes) { + return bytes.getBytes(); + } + + public static Date createMockDate(String date) throws Exception { + return new SimpleDateFormat("yyyy-MM-dd").parse(date); + } + + public static Date createMockDateTime(String date) throws Exception { + return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").parse(date); + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java index 3e0137c7d44..0d737412726 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -10,6 +10,11 @@ * 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. */ + +/* + * IBM OpenAPI SDK Code Generator Version: 99-SNAPSHOT-7cc05500-20201106-154555 + */ + package com.ibm.watson.discovery.v1; import com.google.gson.JsonObject; @@ -19,6 +24,7 @@ import com.ibm.cloud.sdk.core.security.Authenticator; import com.ibm.cloud.sdk.core.security.ConfigBasedAuthenticatorFactory; import com.ibm.cloud.sdk.core.service.BaseService; +import com.ibm.cloud.sdk.core.util.DateUtils; import com.ibm.cloud.sdk.core.util.RequestUtils; import com.ibm.cloud.sdk.core.util.ResponseConverterUtils; import com.ibm.watson.common.SdkCommon; @@ -116,81 +122,105 @@ import com.ibm.watson.discovery.v1.model.UpdateDocumentOptions; import com.ibm.watson.discovery.v1.model.UpdateEnvironmentOptions; import com.ibm.watson.discovery.v1.model.UpdateTrainingExampleOptions; +import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; import okhttp3.MultipartBody; /** - * IBM Watson™ Discovery is a cognitive search and content analytics engine that you can add - * to applications to identify patterns, trends and actionable insights to drive better + * IBM Watson&trade; Discovery is a cognitive search and content analytics engine that you can + * add to applications to identify patterns, trends and actionable insights to drive better * decision-making. Securely unify structured and unstructured data with pre-enriched content, and * use a simplified query language to eliminate the need for manual filtering of results. * * @version v1 - * @see Discovery + * @see Discovery */ public class Discovery extends BaseService { - private static final String DEFAULT_SERVICE_NAME = "discovery"; + public static final String DEFAULT_SERVICE_NAME = "discovery"; - private static final String DEFAULT_SERVICE_URL = + public static final String DEFAULT_SERVICE_URL = "https://api.us-south.discovery.watson.cloud.ibm.com"; - private String versionDate; + private String version; /** - * Constructs a new `Discovery` client using the DEFAULT_SERVICE_NAME. + * Constructs an instance of the `Discovery` client. The default service name is used to configure + * the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value - * will keep your API calls from failing when the service introduces breaking changes. + * @param version Release date of the version of the API you want to use. Specify dates in + * YYYY-MM-DD format. The current version is `2019-04-30`. */ - public Discovery(String versionDate) { + public Discovery(String version) { this( - versionDate, + version, DEFAULT_SERVICE_NAME, ConfigBasedAuthenticatorFactory.getAuthenticator(DEFAULT_SERVICE_NAME)); } /** - * Constructs a new `Discovery` client with the DEFAULT_SERVICE_NAME and the specified - * Authenticator. + * Constructs an instance of the `Discovery` client. The default service name and specified + * authenticator are used to configure the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value - * will keep your API calls from failing when the service introduces breaking changes. - * @param authenticator the Authenticator instance to be configured for this service + * @param version Release date of the version of the API you want to use. Specify dates in + * YYYY-MM-DD format. The current version is `2019-04-30`. + * @param authenticator the {@link Authenticator} instance to be configured for this client */ - public Discovery(String versionDate, Authenticator authenticator) { - this(versionDate, DEFAULT_SERVICE_NAME, authenticator); + public Discovery(String version, Authenticator authenticator) { + this(version, DEFAULT_SERVICE_NAME, authenticator); } /** - * Constructs a new `Discovery` client with the specified serviceName. + * Constructs an instance of the `Discovery` client. The specified service name is used to + * configure the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value - * will keep your API calls from failing when the service introduces breaking changes. - * @param serviceName The name of the service to configure. + * @param version Release date of the version of the API you want to use. Specify dates in + * YYYY-MM-DD format. The current version is `2019-04-30`. + * @param serviceName the service name to be used when configuring the client instance */ - public Discovery(String versionDate, String serviceName) { - this(versionDate, serviceName, ConfigBasedAuthenticatorFactory.getAuthenticator(serviceName)); + public Discovery(String version, String serviceName) { + this(version, serviceName, ConfigBasedAuthenticatorFactory.getAuthenticator(serviceName)); } /** - * Constructs a new `Discovery` client with the specified Authenticator and serviceName. + * Constructs an instance of the `Discovery` client. The specified service name and authenticator + * are used to configure the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value - * will keep your API calls from failing when the service introduces breaking changes. - * @param serviceName The name of the service to configure. - * @param authenticator the Authenticator instance to be configured for this service + * @param version Release date of the version of the API you want to use. Specify dates in + * YYYY-MM-DD format. The current version is `2019-04-30`. + * @param serviceName the service name to be used when configuring the client instance + * @param authenticator the {@link Authenticator} instance to be configured for this client */ - public Discovery(String versionDate, String serviceName, Authenticator authenticator) { + public Discovery(String version, String serviceName, Authenticator authenticator) { super(serviceName, authenticator); setServiceUrl(DEFAULT_SERVICE_URL); - com.ibm.cloud.sdk.core.util.Validator.isTrue( - (versionDate != null) && !versionDate.isEmpty(), "version cannot be null."); - this.versionDate = versionDate; + setVersion(version); this.configureService(serviceName); } + /** + * Gets the version. + * + *

Release date of the version of the API you want to use. Specify dates in YYYY-MM-DD format. + * The current version is `2019-04-30`. + * + * @return the version + */ + public String getVersion() { + return this.version; + } + + /** + * Sets the version. + * + * @param version the new version + */ + public void setVersion(final String version) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(version, "version cannot be empty."); + this.version = version; + } + /** * Create an environment. * @@ -202,22 +232,21 @@ public Discovery(String versionDate, String serviceName, Authenticator authentic * * @param createEnvironmentOptions the {@link CreateEnvironmentOptions} containing the options for * the call - * @return a {@link ServiceCall} with a response type of {@link Environment} + * @return a {@link ServiceCall} with a result of type {@link Environment} */ public ServiceCall createEnvironment( CreateEnvironmentOptions createEnvironmentOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( createEnvironmentOptions, "createEnvironmentOptions cannot be null"); - String[] pathSegments = {"v1/environments"}; RequestBuilder builder = - RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); + RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/environments")); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "createEnvironment"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); final JsonObject contentJson = new JsonObject(); contentJson.addProperty("name", createEnvironmentOptions.name()); if (createEnvironmentOptions.description() != null) { @@ -240,23 +269,23 @@ public ServiceCall createEnvironment( * * @param listEnvironmentsOptions the {@link ListEnvironmentsOptions} containing the options for * the call - * @return a {@link ServiceCall} with a response type of {@link ListEnvironmentsResponse} + * @return a {@link ServiceCall} with a result of type {@link ListEnvironmentsResponse} */ public ServiceCall listEnvironments( ListEnvironmentsOptions listEnvironmentsOptions) { - String[] pathSegments = {"v1/environments"}; + if (listEnvironmentsOptions == null) { + listEnvironmentsOptions = new ListEnvironmentsOptions.Builder().build(); + } RequestBuilder builder = - RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); + RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/environments")); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "listEnvironments"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - if (listEnvironmentsOptions != null) { - if (listEnvironmentsOptions.name() != null) { - builder.query("name", listEnvironmentsOptions.name()); - } + builder.query("version", String.valueOf(this.version)); + if (listEnvironmentsOptions.name() != null) { + builder.query("name", String.valueOf(listEnvironmentsOptions.name())); } ResponseConverter responseConverter = ResponseConverterUtils.getValue( @@ -269,7 +298,7 @@ public ServiceCall listEnvironments( * *

List existing environments for the service instance. * - * @return a {@link ServiceCall} with a response type of {@link ListEnvironmentsResponse} + * @return a {@link ServiceCall} with a result of type {@link ListEnvironmentsResponse} */ public ServiceCall listEnvironments() { return listEnvironments(null); @@ -280,23 +309,23 @@ public ServiceCall listEnvironments() { * * @param getEnvironmentOptions the {@link GetEnvironmentOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of {@link Environment} + * @return a {@link ServiceCall} with a result of type {@link Environment} */ public ServiceCall getEnvironment(GetEnvironmentOptions getEnvironmentOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( getEnvironmentOptions, "getEnvironmentOptions cannot be null"); - String[] pathSegments = {"v1/environments"}; - String[] pathParameters = {getEnvironmentOptions.environmentId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("environment_id", getEnvironmentOptions.environmentId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/environments/{environment_id}", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "getEnvironment"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken() {}.getType()); @@ -311,24 +340,25 @@ public ServiceCall getEnvironment(GetEnvironmentOptions getEnvironm * * @param updateEnvironmentOptions the {@link UpdateEnvironmentOptions} containing the options for * the call - * @return a {@link ServiceCall} with a response type of {@link Environment} + * @return a {@link ServiceCall} with a result of type {@link Environment} */ public ServiceCall updateEnvironment( UpdateEnvironmentOptions updateEnvironmentOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( updateEnvironmentOptions, "updateEnvironmentOptions cannot be null"); - String[] pathSegments = {"v1/environments"}; - String[] pathParameters = {updateEnvironmentOptions.environmentId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("environment_id", updateEnvironmentOptions.environmentId()); RequestBuilder builder = RequestBuilder.put( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/environments/{environment_id}", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "updateEnvironment"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); final JsonObject contentJson = new JsonObject(); if (updateEnvironmentOptions.name() != null) { contentJson.addProperty("name", updateEnvironmentOptions.name()); @@ -351,25 +381,25 @@ public ServiceCall updateEnvironment( * * @param deleteEnvironmentOptions the {@link DeleteEnvironmentOptions} containing the options for * the call - * @return a {@link ServiceCall} with a response type of {@link DeleteEnvironmentResponse} + * @return a {@link ServiceCall} with a result of type {@link DeleteEnvironmentResponse} */ public ServiceCall deleteEnvironment( DeleteEnvironmentOptions deleteEnvironmentOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( deleteEnvironmentOptions, "deleteEnvironmentOptions cannot be null"); - String[] pathSegments = {"v1/environments"}; - String[] pathParameters = {deleteEnvironmentOptions.environmentId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("environment_id", deleteEnvironmentOptions.environmentId()); RequestBuilder builder = RequestBuilder.delete( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/environments/{environment_id}", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "deleteEnvironment"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken() {}.getType()); @@ -383,22 +413,23 @@ public ServiceCall deleteEnvironment( * collections. * * @param listFieldsOptions the {@link ListFieldsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link ListCollectionFieldsResponse} + * @return a {@link ServiceCall} with a result of type {@link ListCollectionFieldsResponse} */ public ServiceCall listFields(ListFieldsOptions listFieldsOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( listFieldsOptions, "listFieldsOptions cannot be null"); - String[] pathSegments = {"v1/environments", "fields"}; - String[] pathParameters = {listFieldsOptions.environmentId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("environment_id", listFieldsOptions.environmentId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/environments/{environment_id}/fields", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "listFields"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); builder.query("collection_ids", RequestUtils.join(listFieldsOptions.collectionIds(), ",")); ResponseConverter responseConverter = ResponseConverterUtils.getValue( @@ -422,24 +453,27 @@ public ServiceCall listFields(ListFieldsOptions li * * @param createConfigurationOptions the {@link CreateConfigurationOptions} containing the options * for the call - * @return a {@link ServiceCall} with a response type of {@link Configuration} + * @return a {@link ServiceCall} with a result of type {@link Configuration} */ public ServiceCall createConfiguration( CreateConfigurationOptions createConfigurationOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( createConfigurationOptions, "createConfigurationOptions cannot be null"); - String[] pathSegments = {"v1/environments", "configurations"}; - String[] pathParameters = {createConfigurationOptions.environmentId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("environment_id", createConfigurationOptions.environmentId()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/environments/{environment_id}/configurations", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "createConfiguration"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); final JsonObject contentJson = new JsonObject(); contentJson.addProperty("name", createConfigurationOptions.name()); if (createConfigurationOptions.description() != null) { @@ -483,26 +517,29 @@ public ServiceCall createConfiguration( * * @param listConfigurationsOptions the {@link ListConfigurationsOptions} containing the options * for the call - * @return a {@link ServiceCall} with a response type of {@link ListConfigurationsResponse} + * @return a {@link ServiceCall} with a result of type {@link ListConfigurationsResponse} */ public ServiceCall listConfigurations( ListConfigurationsOptions listConfigurationsOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( listConfigurationsOptions, "listConfigurationsOptions cannot be null"); - String[] pathSegments = {"v1/environments", "configurations"}; - String[] pathParameters = {listConfigurationsOptions.environmentId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("environment_id", listConfigurationsOptions.environmentId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/environments/{environment_id}/configurations", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "listConfigurations"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (listConfigurationsOptions.name() != null) { - builder.query("name", listConfigurationsOptions.name()); + builder.query("name", String.valueOf(listConfigurationsOptions.name())); } ResponseConverter responseConverter = ResponseConverterUtils.getValue( @@ -515,26 +552,27 @@ public ServiceCall listConfigurations( * * @param getConfigurationOptions the {@link GetConfigurationOptions} containing the options for * the call - * @return a {@link ServiceCall} with a response type of {@link Configuration} + * @return a {@link ServiceCall} with a result of type {@link Configuration} */ public ServiceCall getConfiguration( GetConfigurationOptions getConfigurationOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( getConfigurationOptions, "getConfigurationOptions cannot be null"); - String[] pathSegments = {"v1/environments", "configurations"}; - String[] pathParameters = { - getConfigurationOptions.environmentId(), getConfigurationOptions.configurationId() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("environment_id", getConfigurationOptions.environmentId()); + pathParamsMap.put("configuration_id", getConfigurationOptions.configurationId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/environments/{environment_id}/configurations/{configuration_id}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "getConfiguration"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken() {}.getType()); @@ -553,26 +591,28 @@ public ServiceCall getConfiguration( * * @param updateConfigurationOptions the {@link UpdateConfigurationOptions} containing the options * for the call - * @return a {@link ServiceCall} with a response type of {@link Configuration} + * @return a {@link ServiceCall} with a result of type {@link Configuration} */ public ServiceCall updateConfiguration( UpdateConfigurationOptions updateConfigurationOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( updateConfigurationOptions, "updateConfigurationOptions cannot be null"); - String[] pathSegments = {"v1/environments", "configurations"}; - String[] pathParameters = { - updateConfigurationOptions.environmentId(), updateConfigurationOptions.configurationId() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("environment_id", updateConfigurationOptions.environmentId()); + pathParamsMap.put("configuration_id", updateConfigurationOptions.configurationId()); RequestBuilder builder = RequestBuilder.put( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/environments/{environment_id}/configurations/{configuration_id}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "updateConfiguration"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); final JsonObject contentJson = new JsonObject(); contentJson.addProperty("name", updateConfigurationOptions.name()); if (updateConfigurationOptions.description() != null) { @@ -620,27 +660,28 @@ public ServiceCall updateConfiguration( * * @param deleteConfigurationOptions the {@link DeleteConfigurationOptions} containing the options * for the call - * @return a {@link ServiceCall} with a response type of {@link DeleteConfigurationResponse} + * @return a {@link ServiceCall} with a result of type {@link DeleteConfigurationResponse} */ public ServiceCall deleteConfiguration( DeleteConfigurationOptions deleteConfigurationOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( deleteConfigurationOptions, "deleteConfigurationOptions cannot be null"); - String[] pathSegments = {"v1/environments", "configurations"}; - String[] pathParameters = { - deleteConfigurationOptions.environmentId(), deleteConfigurationOptions.configurationId() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("environment_id", deleteConfigurationOptions.environmentId()); + pathParamsMap.put("configuration_id", deleteConfigurationOptions.configurationId()); RequestBuilder builder = RequestBuilder.delete( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/environments/{environment_id}/configurations/{configuration_id}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "deleteConfiguration"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken() {}.getType()); @@ -652,22 +693,23 @@ public ServiceCall deleteConfiguration( * * @param createCollectionOptions the {@link CreateCollectionOptions} containing the options for * the call - * @return a {@link ServiceCall} with a response type of {@link Collection} + * @return a {@link ServiceCall} with a result of type {@link Collection} */ public ServiceCall createCollection(CreateCollectionOptions createCollectionOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( createCollectionOptions, "createCollectionOptions cannot be null"); - String[] pathSegments = {"v1/environments", "collections"}; - String[] pathParameters = {createCollectionOptions.environmentId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("environment_id", createCollectionOptions.environmentId()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/environments/{environment_id}/collections", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "createCollection"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); final JsonObject contentJson = new JsonObject(); contentJson.addProperty("name", createCollectionOptions.name()); if (createCollectionOptions.description() != null) { @@ -693,25 +735,26 @@ public ServiceCall createCollection(CreateCollectionOptions createCo * * @param listCollectionsOptions the {@link ListCollectionsOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of {@link ListCollectionsResponse} + * @return a {@link ServiceCall} with a result of type {@link ListCollectionsResponse} */ public ServiceCall listCollections( ListCollectionsOptions listCollectionsOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( listCollectionsOptions, "listCollectionsOptions cannot be null"); - String[] pathSegments = {"v1/environments", "collections"}; - String[] pathParameters = {listCollectionsOptions.environmentId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("environment_id", listCollectionsOptions.environmentId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/environments/{environment_id}/collections", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "listCollections"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (listCollectionsOptions.name() != null) { - builder.query("name", listCollectionsOptions.name()); + builder.query("name", String.valueOf(listCollectionsOptions.name())); } ResponseConverter responseConverter = ResponseConverterUtils.getValue( @@ -724,25 +767,26 @@ public ServiceCall listCollections( * * @param getCollectionOptions the {@link GetCollectionOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of {@link Collection} + * @return a {@link ServiceCall} with a result of type {@link Collection} */ public ServiceCall getCollection(GetCollectionOptions getCollectionOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( getCollectionOptions, "getCollectionOptions cannot be null"); - String[] pathSegments = {"v1/environments", "collections"}; - String[] pathParameters = { - getCollectionOptions.environmentId(), getCollectionOptions.collectionId() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("environment_id", getCollectionOptions.environmentId()); + pathParamsMap.put("collection_id", getCollectionOptions.collectionId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/environments/{environment_id}/collections/{collection_id}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "getCollection"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken() {}.getType()); @@ -754,24 +798,26 @@ public ServiceCall getCollection(GetCollectionOptions getCollectionO * * @param updateCollectionOptions the {@link UpdateCollectionOptions} containing the options for * the call - * @return a {@link ServiceCall} with a response type of {@link Collection} + * @return a {@link ServiceCall} with a result of type {@link Collection} */ public ServiceCall updateCollection(UpdateCollectionOptions updateCollectionOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( updateCollectionOptions, "updateCollectionOptions cannot be null"); - String[] pathSegments = {"v1/environments", "collections"}; - String[] pathParameters = { - updateCollectionOptions.environmentId(), updateCollectionOptions.collectionId() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("environment_id", updateCollectionOptions.environmentId()); + pathParamsMap.put("collection_id", updateCollectionOptions.collectionId()); RequestBuilder builder = RequestBuilder.put( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/environments/{environment_id}/collections/{collection_id}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "updateCollection"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); final JsonObject contentJson = new JsonObject(); contentJson.addProperty("name", updateCollectionOptions.name()); if (updateCollectionOptions.description() != null) { @@ -792,26 +838,27 @@ public ServiceCall updateCollection(UpdateCollectionOptions updateCo * * @param deleteCollectionOptions the {@link DeleteCollectionOptions} containing the options for * the call - * @return a {@link ServiceCall} with a response type of {@link DeleteCollectionResponse} + * @return a {@link ServiceCall} with a result of type {@link DeleteCollectionResponse} */ public ServiceCall deleteCollection( DeleteCollectionOptions deleteCollectionOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( deleteCollectionOptions, "deleteCollectionOptions cannot be null"); - String[] pathSegments = {"v1/environments", "collections"}; - String[] pathParameters = { - deleteCollectionOptions.environmentId(), deleteCollectionOptions.collectionId() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("environment_id", deleteCollectionOptions.environmentId()); + pathParamsMap.put("collection_id", deleteCollectionOptions.collectionId()); RequestBuilder builder = RequestBuilder.delete( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/environments/{environment_id}/collections/{collection_id}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "deleteCollection"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken() {}.getType()); @@ -825,27 +872,28 @@ public ServiceCall deleteCollection( * * @param listCollectionFieldsOptions the {@link ListCollectionFieldsOptions} containing the * options for the call - * @return a {@link ServiceCall} with a response type of {@link ListCollectionFieldsResponse} + * @return a {@link ServiceCall} with a result of type {@link ListCollectionFieldsResponse} */ public ServiceCall listCollectionFields( ListCollectionFieldsOptions listCollectionFieldsOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( listCollectionFieldsOptions, "listCollectionFieldsOptions cannot be null"); - String[] pathSegments = {"v1/environments", "collections", "fields"}; - String[] pathParameters = { - listCollectionFieldsOptions.environmentId(), listCollectionFieldsOptions.collectionId() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("environment_id", listCollectionFieldsOptions.environmentId()); + pathParamsMap.put("collection_id", listCollectionFieldsOptions.collectionId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/environments/{environment_id}/collections/{collection_id}/fields", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "listCollectionFields"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken() {}.getType()); @@ -860,25 +908,26 @@ public ServiceCall listCollectionFields( * * @param listExpansionsOptions the {@link ListExpansionsOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of {@link Expansions} + * @return a {@link ServiceCall} with a result of type {@link Expansions} */ public ServiceCall listExpansions(ListExpansionsOptions listExpansionsOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( listExpansionsOptions, "listExpansionsOptions cannot be null"); - String[] pathSegments = {"v1/environments", "collections", "expansions"}; - String[] pathParameters = { - listExpansionsOptions.environmentId(), listExpansionsOptions.collectionId() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("environment_id", listExpansionsOptions.environmentId()); + pathParamsMap.put("collection_id", listExpansionsOptions.collectionId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/environments/{environment_id}/collections/{collection_id}/expansions", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "listExpansions"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken() {}.getType()); @@ -894,24 +943,26 @@ public ServiceCall listExpansions(ListExpansionsOptions listExpansio * * @param createExpansionsOptions the {@link CreateExpansionsOptions} containing the options for * the call - * @return a {@link ServiceCall} with a response type of {@link Expansions} + * @return a {@link ServiceCall} with a result of type {@link Expansions} */ public ServiceCall createExpansions(CreateExpansionsOptions createExpansionsOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( createExpansionsOptions, "createExpansionsOptions cannot be null"); - String[] pathSegments = {"v1/environments", "collections", "expansions"}; - String[] pathParameters = { - createExpansionsOptions.environmentId(), createExpansionsOptions.collectionId() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("environment_id", createExpansionsOptions.environmentId()); + pathParamsMap.put("collection_id", createExpansionsOptions.collectionId()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/environments/{environment_id}/collections/{collection_id}/expansions", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "createExpansions"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); final JsonObject contentJson = new JsonObject(); contentJson.add( "expansions", @@ -932,24 +983,25 @@ public ServiceCall createExpansions(CreateExpansionsOptions createEx * * @param deleteExpansionsOptions the {@link DeleteExpansionsOptions} containing the options for * the call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteExpansions(DeleteExpansionsOptions deleteExpansionsOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( deleteExpansionsOptions, "deleteExpansionsOptions cannot be null"); - String[] pathSegments = {"v1/environments", "collections", "expansions"}; - String[] pathParameters = { - deleteExpansionsOptions.environmentId(), deleteExpansionsOptions.collectionId() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("environment_id", deleteExpansionsOptions.environmentId()); + pathParamsMap.put("collection_id", deleteExpansionsOptions.collectionId()); RequestBuilder builder = RequestBuilder.delete( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/environments/{environment_id}/collections/{collection_id}/expansions", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "deleteExpansions"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -961,31 +1013,29 @@ public ServiceCall deleteExpansions(DeleteExpansionsOptions deleteExpansio * * @param getTokenizationDictionaryStatusOptions the {@link * GetTokenizationDictionaryStatusOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link TokenDictStatusResponse} + * @return a {@link ServiceCall} with a result of type {@link TokenDictStatusResponse} */ public ServiceCall getTokenizationDictionaryStatus( GetTokenizationDictionaryStatusOptions getTokenizationDictionaryStatusOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( getTokenizationDictionaryStatusOptions, "getTokenizationDictionaryStatusOptions cannot be null"); - String[] pathSegments = { - "v1/environments", "collections", "word_lists/tokenization_dictionary" - }; - String[] pathParameters = { - getTokenizationDictionaryStatusOptions.environmentId(), - getTokenizationDictionaryStatusOptions.collectionId() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("environment_id", getTokenizationDictionaryStatusOptions.environmentId()); + pathParamsMap.put("collection_id", getTokenizationDictionaryStatusOptions.collectionId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/environments/{environment_id}/collections/{collection_id}/word_lists/tokenization_dictionary", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "getTokenizationDictionaryStatus"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken() {}.getType()); @@ -999,29 +1049,28 @@ public ServiceCall getTokenizationDictionaryStatus( * * @param createTokenizationDictionaryOptions the {@link CreateTokenizationDictionaryOptions} * containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link TokenDictStatusResponse} + * @return a {@link ServiceCall} with a result of type {@link TokenDictStatusResponse} */ public ServiceCall createTokenizationDictionary( CreateTokenizationDictionaryOptions createTokenizationDictionaryOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( createTokenizationDictionaryOptions, "createTokenizationDictionaryOptions cannot be null"); - String[] pathSegments = { - "v1/environments", "collections", "word_lists/tokenization_dictionary" - }; - String[] pathParameters = { - createTokenizationDictionaryOptions.environmentId(), - createTokenizationDictionaryOptions.collectionId() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("environment_id", createTokenizationDictionaryOptions.environmentId()); + pathParamsMap.put("collection_id", createTokenizationDictionaryOptions.collectionId()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/environments/{environment_id}/collections/{collection_id}/word_lists/tokenization_dictionary", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "createTokenizationDictionary"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); final JsonObject contentJson = new JsonObject(); if (createTokenizationDictionaryOptions.tokenizationRules() != null) { contentJson.add( @@ -1043,29 +1092,27 @@ public ServiceCall createTokenizationDictionary( * * @param deleteTokenizationDictionaryOptions the {@link DeleteTokenizationDictionaryOptions} * containing the options for the call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteTokenizationDictionary( DeleteTokenizationDictionaryOptions deleteTokenizationDictionaryOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( deleteTokenizationDictionaryOptions, "deleteTokenizationDictionaryOptions cannot be null"); - String[] pathSegments = { - "v1/environments", "collections", "word_lists/tokenization_dictionary" - }; - String[] pathParameters = { - deleteTokenizationDictionaryOptions.environmentId(), - deleteTokenizationDictionaryOptions.collectionId() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("environment_id", deleteTokenizationDictionaryOptions.environmentId()); + pathParamsMap.put("collection_id", deleteTokenizationDictionaryOptions.collectionId()); RequestBuilder builder = RequestBuilder.delete( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/environments/{environment_id}/collections/{collection_id}/word_lists/tokenization_dictionary", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "deleteTokenizationDictionary"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -1077,27 +1124,28 @@ public ServiceCall deleteTokenizationDictionary( * * @param getStopwordListStatusOptions the {@link GetStopwordListStatusOptions} containing the * options for the call - * @return a {@link ServiceCall} with a response type of {@link TokenDictStatusResponse} + * @return a {@link ServiceCall} with a result of type {@link TokenDictStatusResponse} */ public ServiceCall getStopwordListStatus( GetStopwordListStatusOptions getStopwordListStatusOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( getStopwordListStatusOptions, "getStopwordListStatusOptions cannot be null"); - String[] pathSegments = {"v1/environments", "collections", "word_lists/stopwords"}; - String[] pathParameters = { - getStopwordListStatusOptions.environmentId(), getStopwordListStatusOptions.collectionId() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("environment_id", getStopwordListStatusOptions.environmentId()); + pathParamsMap.put("collection_id", getStopwordListStatusOptions.collectionId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/environments/{environment_id}/collections/{collection_id}/word_lists/stopwords", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "getStopwordListStatus"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken() {}.getType()); @@ -1111,26 +1159,28 @@ public ServiceCall getStopwordListStatus( * * @param createStopwordListOptions the {@link CreateStopwordListOptions} containing the options * for the call - * @return a {@link ServiceCall} with a response type of {@link TokenDictStatusResponse} + * @return a {@link ServiceCall} with a result of type {@link TokenDictStatusResponse} */ public ServiceCall createStopwordList( CreateStopwordListOptions createStopwordListOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( createStopwordListOptions, "createStopwordListOptions cannot be null"); - String[] pathSegments = {"v1/environments", "collections", "word_lists/stopwords"}; - String[] pathParameters = { - createStopwordListOptions.environmentId(), createStopwordListOptions.collectionId() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("environment_id", createStopwordListOptions.environmentId()); + pathParamsMap.put("collection_id", createStopwordListOptions.collectionId()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/environments/{environment_id}/collections/{collection_id}/word_lists/stopwords", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "createStopwordList"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); multipartBuilder.setType(MultipartBody.FORM); okhttp3.RequestBody stopwordFileBody = @@ -1153,25 +1203,26 @@ public ServiceCall createStopwordList( * * @param deleteStopwordListOptions the {@link DeleteStopwordListOptions} containing the options * for the call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteStopwordList(DeleteStopwordListOptions deleteStopwordListOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( deleteStopwordListOptions, "deleteStopwordListOptions cannot be null"); - String[] pathSegments = {"v1/environments", "collections", "word_lists/stopwords"}; - String[] pathParameters = { - deleteStopwordListOptions.environmentId(), deleteStopwordListOptions.collectionId() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("environment_id", deleteStopwordListOptions.environmentId()); + pathParamsMap.put("collection_id", deleteStopwordListOptions.collectionId()); RequestBuilder builder = RequestBuilder.delete( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/environments/{environment_id}/collections/{collection_id}/word_lists/stopwords", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "deleteStopwordList"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -1205,7 +1256,7 @@ public ServiceCall deleteStopwordList(DeleteStopwordListOptions deleteStop * **_/v1/environments/{environment_id}/collections/{collection_id}/documents** method. * * @param addDocumentOptions the {@link AddDocumentOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link DocumentAccepted} + * @return a {@link ServiceCall} with a result of type {@link DocumentAccepted} */ public ServiceCall addDocument(AddDocumentOptions addDocumentOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( @@ -1213,19 +1264,21 @@ public ServiceCall addDocument(AddDocumentOptions addDocumentO com.ibm.cloud.sdk.core.util.Validator.isTrue( (addDocumentOptions.file() != null) || (addDocumentOptions.metadata() != null), "At least one of file or metadata must be supplied."); - String[] pathSegments = {"v1/environments", "collections", "documents"}; - String[] pathParameters = { - addDocumentOptions.environmentId(), addDocumentOptions.collectionId() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("environment_id", addDocumentOptions.environmentId()); + pathParamsMap.put("collection_id", addDocumentOptions.collectionId()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/environments/{environment_id}/collections/{collection_id}/documents", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "addDocument"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); multipartBuilder.setType(MultipartBody.FORM); if (addDocumentOptions.file() != null) { @@ -1254,29 +1307,29 @@ public ServiceCall addDocument(AddDocumentOptions addDocumentO * * @param getDocumentStatusOptions the {@link GetDocumentStatusOptions} containing the options for * the call - * @return a {@link ServiceCall} with a response type of {@link DocumentStatus} + * @return a {@link ServiceCall} with a result of type {@link DocumentStatus} */ public ServiceCall getDocumentStatus( GetDocumentStatusOptions getDocumentStatusOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( getDocumentStatusOptions, "getDocumentStatusOptions cannot be null"); - String[] pathSegments = {"v1/environments", "collections", "documents"}; - String[] pathParameters = { - getDocumentStatusOptions.environmentId(), - getDocumentStatusOptions.collectionId(), - getDocumentStatusOptions.documentId() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("environment_id", getDocumentStatusOptions.environmentId()); + pathParamsMap.put("collection_id", getDocumentStatusOptions.collectionId()); + pathParamsMap.put("document_id", getDocumentStatusOptions.documentId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/environments/{environment_id}/collections/{collection_id}/documents/{document_id}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "getDocumentStatus"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken() {}.getType()); @@ -1294,7 +1347,7 @@ public ServiceCall getDocumentStatus( * * @param updateDocumentOptions the {@link UpdateDocumentOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of {@link DocumentAccepted} + * @return a {@link ServiceCall} with a result of type {@link DocumentAccepted} */ public ServiceCall updateDocument(UpdateDocumentOptions updateDocumentOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( @@ -1302,21 +1355,22 @@ public ServiceCall updateDocument(UpdateDocumentOptions update com.ibm.cloud.sdk.core.util.Validator.isTrue( (updateDocumentOptions.file() != null) || (updateDocumentOptions.metadata() != null), "At least one of file or metadata must be supplied."); - String[] pathSegments = {"v1/environments", "collections", "documents"}; - String[] pathParameters = { - updateDocumentOptions.environmentId(), - updateDocumentOptions.collectionId(), - updateDocumentOptions.documentId() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("environment_id", updateDocumentOptions.environmentId()); + pathParamsMap.put("collection_id", updateDocumentOptions.collectionId()); + pathParamsMap.put("document_id", updateDocumentOptions.documentId()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/environments/{environment_id}/collections/{collection_id}/documents/{document_id}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "updateDocument"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); multipartBuilder.setType(MultipartBody.FORM); if (updateDocumentOptions.file() != null) { @@ -1343,28 +1397,28 @@ public ServiceCall updateDocument(UpdateDocumentOptions update * * @param deleteDocumentOptions the {@link DeleteDocumentOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of {@link DeleteDocumentResponse} + * @return a {@link ServiceCall} with a result of type {@link DeleteDocumentResponse} */ public ServiceCall deleteDocument( DeleteDocumentOptions deleteDocumentOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( deleteDocumentOptions, "deleteDocumentOptions cannot be null"); - String[] pathSegments = {"v1/environments", "collections", "documents"}; - String[] pathParameters = { - deleteDocumentOptions.environmentId(), - deleteDocumentOptions.collectionId(), - deleteDocumentOptions.documentId() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("environment_id", deleteDocumentOptions.environmentId()); + pathParamsMap.put("collection_id", deleteDocumentOptions.collectionId()); + pathParamsMap.put("document_id", deleteDocumentOptions.documentId()); RequestBuilder builder = RequestBuilder.delete( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/environments/{environment_id}/collections/{collection_id}/documents/{document_id}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "deleteDocument"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken() {}.getType()); @@ -1378,16 +1432,19 @@ public ServiceCall deleteDocument( * documentation](https://cloud.ibm.com/docs/discovery?topic=discovery-query-concepts#query-concepts). * * @param queryOptions the {@link QueryOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link QueryResponse} + * @return a {@link ServiceCall} with a result of type {@link QueryResponse} */ public ServiceCall query(QueryOptions queryOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull(queryOptions, "queryOptions cannot be null"); - String[] pathSegments = {"v1/environments", "collections", "query"}; - String[] pathParameters = {queryOptions.environmentId(), queryOptions.collectionId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("environment_id", queryOptions.environmentId()); + pathParamsMap.put("collection_id", queryOptions.collectionId()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/environments/{environment_id}/collections/{collection_id}/query", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "query"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); @@ -1396,6 +1453,7 @@ public ServiceCall query(QueryOptions queryOptions) { if (queryOptions.xWatsonLoggingOptOut() != null) { builder.header("X-Watson-Logging-Opt-Out", queryOptions.xWatsonLoggingOptOut()); } + builder.query("version", String.valueOf(this.version)); final JsonObject contentJson = new JsonObject(); if (queryOptions.filter() != null) { contentJson.addProperty("filter", queryOptions.filter()); @@ -1474,38 +1532,41 @@ public ServiceCall query(QueryOptions queryOptions) { * for more details on the query language. * * @param queryNoticesOptions the {@link QueryNoticesOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link QueryNoticesResponse} + * @return a {@link ServiceCall} with a result of type {@link QueryNoticesResponse} */ public ServiceCall queryNotices(QueryNoticesOptions queryNoticesOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( queryNoticesOptions, "queryNoticesOptions cannot be null"); - String[] pathSegments = {"v1/environments", "collections", "notices"}; - String[] pathParameters = { - queryNoticesOptions.environmentId(), queryNoticesOptions.collectionId() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("environment_id", queryNoticesOptions.environmentId()); + pathParamsMap.put("collection_id", queryNoticesOptions.collectionId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/environments/{environment_id}/collections/{collection_id}/notices", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "queryNotices"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (queryNoticesOptions.filter() != null) { - builder.query("filter", queryNoticesOptions.filter()); + builder.query("filter", String.valueOf(queryNoticesOptions.filter())); } if (queryNoticesOptions.query() != null) { - builder.query("query", queryNoticesOptions.query()); + builder.query("query", String.valueOf(queryNoticesOptions.query())); } if (queryNoticesOptions.naturalLanguageQuery() != null) { - builder.query("natural_language_query", queryNoticesOptions.naturalLanguageQuery()); + builder.query( + "natural_language_query", String.valueOf(queryNoticesOptions.naturalLanguageQuery())); } if (queryNoticesOptions.passages() != null) { builder.query("passages", String.valueOf(queryNoticesOptions.passages())); } if (queryNoticesOptions.aggregation() != null) { - builder.query("aggregation", queryNoticesOptions.aggregation()); + builder.query("aggregation", String.valueOf(queryNoticesOptions.aggregation())); } if (queryNoticesOptions.count() != null) { builder.query("count", String.valueOf(queryNoticesOptions.count())); @@ -1534,7 +1595,7 @@ public ServiceCall queryNotices(QueryNoticesOptions queryN "passages.characters", String.valueOf(queryNoticesOptions.passagesCharacters())); } if (queryNoticesOptions.deduplicateField() != null) { - builder.query("deduplicate.field", queryNoticesOptions.deduplicateField()); + builder.query("deduplicate.field", String.valueOf(queryNoticesOptions.deduplicateField())); } if (queryNoticesOptions.similar() != null) { builder.query("similar", String.valueOf(queryNoticesOptions.similar())); @@ -1561,17 +1622,17 @@ public ServiceCall queryNotices(QueryNoticesOptions queryN * * @param federatedQueryOptions the {@link FederatedQueryOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of {@link QueryResponse} + * @return a {@link ServiceCall} with a result of type {@link QueryResponse} */ public ServiceCall federatedQuery(FederatedQueryOptions federatedQueryOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( federatedQueryOptions, "federatedQueryOptions cannot be null"); - String[] pathSegments = {"v1/environments", "query"}; - String[] pathParameters = {federatedQueryOptions.environmentId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("environment_id", federatedQueryOptions.environmentId()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/environments/{environment_id}/query", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "federatedQuery"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); @@ -1580,6 +1641,7 @@ public ServiceCall federatedQuery(FederatedQueryOptions federated if (federatedQueryOptions.xWatsonLoggingOptOut() != null) { builder.header("X-Watson-Logging-Opt-Out", federatedQueryOptions.xWatsonLoggingOptOut()); } + builder.query("version", String.valueOf(this.version)); final JsonObject contentJson = new JsonObject(); contentJson.addProperty("collection_ids", federatedQueryOptions.collectionIds()); if (federatedQueryOptions.filter() != null) { @@ -1658,37 +1720,40 @@ public ServiceCall federatedQuery(FederatedQueryOptions federated * * @param federatedQueryNoticesOptions the {@link FederatedQueryNoticesOptions} containing the * options for the call - * @return a {@link ServiceCall} with a response type of {@link QueryNoticesResponse} + * @return a {@link ServiceCall} with a result of type {@link QueryNoticesResponse} */ public ServiceCall federatedQueryNotices( FederatedQueryNoticesOptions federatedQueryNoticesOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( federatedQueryNoticesOptions, "federatedQueryNoticesOptions cannot be null"); - String[] pathSegments = {"v1/environments", "notices"}; - String[] pathParameters = {federatedQueryNoticesOptions.environmentId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("environment_id", federatedQueryNoticesOptions.environmentId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/environments/{environment_id}/notices", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "federatedQueryNotices"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); builder.query( "collection_ids", RequestUtils.join(federatedQueryNoticesOptions.collectionIds(), ",")); if (federatedQueryNoticesOptions.filter() != null) { - builder.query("filter", federatedQueryNoticesOptions.filter()); + builder.query("filter", String.valueOf(federatedQueryNoticesOptions.filter())); } if (federatedQueryNoticesOptions.query() != null) { - builder.query("query", federatedQueryNoticesOptions.query()); + builder.query("query", String.valueOf(federatedQueryNoticesOptions.query())); } if (federatedQueryNoticesOptions.naturalLanguageQuery() != null) { - builder.query("natural_language_query", federatedQueryNoticesOptions.naturalLanguageQuery()); + builder.query( + "natural_language_query", + String.valueOf(federatedQueryNoticesOptions.naturalLanguageQuery())); } if (federatedQueryNoticesOptions.aggregation() != null) { - builder.query("aggregation", federatedQueryNoticesOptions.aggregation()); + builder.query("aggregation", String.valueOf(federatedQueryNoticesOptions.aggregation())); } if (federatedQueryNoticesOptions.count() != null) { builder.query("count", String.valueOf(federatedQueryNoticesOptions.count())); @@ -1706,7 +1771,8 @@ public ServiceCall federatedQueryNotices( builder.query("highlight", String.valueOf(federatedQueryNoticesOptions.highlight())); } if (federatedQueryNoticesOptions.deduplicateField() != null) { - builder.query("deduplicate.field", federatedQueryNoticesOptions.deduplicateField()); + builder.query( + "deduplicate.field", String.valueOf(federatedQueryNoticesOptions.deduplicateField())); } if (federatedQueryNoticesOptions.similar() != null) { builder.query("similar", String.valueOf(federatedQueryNoticesOptions.similar())); @@ -1734,29 +1800,31 @@ public ServiceCall federatedQueryNotices( * * @param getAutocompletionOptions the {@link GetAutocompletionOptions} containing the options for * the call - * @return a {@link ServiceCall} with a response type of {@link Completions} + * @return a {@link ServiceCall} with a result of type {@link Completions} */ public ServiceCall getAutocompletion( GetAutocompletionOptions getAutocompletionOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( getAutocompletionOptions, "getAutocompletionOptions cannot be null"); - String[] pathSegments = {"v1/environments", "collections", "autocompletion"}; - String[] pathParameters = { - getAutocompletionOptions.environmentId(), getAutocompletionOptions.collectionId() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("environment_id", getAutocompletionOptions.environmentId()); + pathParamsMap.put("collection_id", getAutocompletionOptions.collectionId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/environments/{environment_id}/collections/{collection_id}/autocompletion", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "getAutocompletion"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - builder.query("prefix", getAutocompletionOptions.prefix()); + builder.query("version", String.valueOf(this.version)); + builder.query("prefix", String.valueOf(getAutocompletionOptions.prefix())); if (getAutocompletionOptions.field() != null) { - builder.query("field", getAutocompletionOptions.field()); + builder.query("field", String.valueOf(getAutocompletionOptions.field())); } if (getAutocompletionOptions.count() != null) { builder.query("count", String.valueOf(getAutocompletionOptions.count())); @@ -1774,26 +1842,27 @@ public ServiceCall getAutocompletion( * * @param listTrainingDataOptions the {@link ListTrainingDataOptions} containing the options for * the call - * @return a {@link ServiceCall} with a response type of {@link TrainingDataSet} + * @return a {@link ServiceCall} with a result of type {@link TrainingDataSet} */ public ServiceCall listTrainingData( ListTrainingDataOptions listTrainingDataOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( listTrainingDataOptions, "listTrainingDataOptions cannot be null"); - String[] pathSegments = {"v1/environments", "collections", "training_data"}; - String[] pathParameters = { - listTrainingDataOptions.environmentId(), listTrainingDataOptions.collectionId() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("environment_id", listTrainingDataOptions.environmentId()); + pathParamsMap.put("collection_id", listTrainingDataOptions.collectionId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/environments/{environment_id}/collections/{collection_id}/training_data", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "listTrainingData"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken() {}.getType()); @@ -1808,24 +1877,26 @@ public ServiceCall listTrainingData( * * @param addTrainingDataOptions the {@link AddTrainingDataOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of {@link TrainingQuery} + * @return a {@link ServiceCall} with a result of type {@link TrainingQuery} */ public ServiceCall addTrainingData(AddTrainingDataOptions addTrainingDataOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( addTrainingDataOptions, "addTrainingDataOptions cannot be null"); - String[] pathSegments = {"v1/environments", "collections", "training_data"}; - String[] pathParameters = { - addTrainingDataOptions.environmentId(), addTrainingDataOptions.collectionId() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("environment_id", addTrainingDataOptions.environmentId()); + pathParamsMap.put("collection_id", addTrainingDataOptions.collectionId()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/environments/{environment_id}/collections/{collection_id}/training_data", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "addTrainingData"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); final JsonObject contentJson = new JsonObject(); if (addTrainingDataOptions.naturalLanguageQuery() != null) { contentJson.addProperty( @@ -1854,26 +1925,27 @@ public ServiceCall addTrainingData(AddTrainingDataOptions addTrai * * @param deleteAllTrainingDataOptions the {@link DeleteAllTrainingDataOptions} containing the * options for the call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteAllTrainingData( DeleteAllTrainingDataOptions deleteAllTrainingDataOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( deleteAllTrainingDataOptions, "deleteAllTrainingDataOptions cannot be null"); - String[] pathSegments = {"v1/environments", "collections", "training_data"}; - String[] pathParameters = { - deleteAllTrainingDataOptions.environmentId(), deleteAllTrainingDataOptions.collectionId() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("environment_id", deleteAllTrainingDataOptions.environmentId()); + pathParamsMap.put("collection_id", deleteAllTrainingDataOptions.collectionId()); RequestBuilder builder = RequestBuilder.delete( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/environments/{environment_id}/collections/{collection_id}/training_data", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "deleteAllTrainingData"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -1886,27 +1958,27 @@ public ServiceCall deleteAllTrainingData( * * @param getTrainingDataOptions the {@link GetTrainingDataOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of {@link TrainingQuery} + * @return a {@link ServiceCall} with a result of type {@link TrainingQuery} */ public ServiceCall getTrainingData(GetTrainingDataOptions getTrainingDataOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( getTrainingDataOptions, "getTrainingDataOptions cannot be null"); - String[] pathSegments = {"v1/environments", "collections", "training_data"}; - String[] pathParameters = { - getTrainingDataOptions.environmentId(), - getTrainingDataOptions.collectionId(), - getTrainingDataOptions.queryId() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("environment_id", getTrainingDataOptions.environmentId()); + pathParamsMap.put("collection_id", getTrainingDataOptions.collectionId()); + pathParamsMap.put("query_id", getTrainingDataOptions.queryId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/environments/{environment_id}/collections/{collection_id}/training_data/{query_id}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "getTrainingData"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken() {}.getType()); @@ -1920,27 +1992,27 @@ public ServiceCall getTrainingData(GetTrainingDataOptions getTrai * * @param deleteTrainingDataOptions the {@link DeleteTrainingDataOptions} containing the options * for the call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteTrainingData(DeleteTrainingDataOptions deleteTrainingDataOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( deleteTrainingDataOptions, "deleteTrainingDataOptions cannot be null"); - String[] pathSegments = {"v1/environments", "collections", "training_data"}; - String[] pathParameters = { - deleteTrainingDataOptions.environmentId(), - deleteTrainingDataOptions.collectionId(), - deleteTrainingDataOptions.queryId() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("environment_id", deleteTrainingDataOptions.environmentId()); + pathParamsMap.put("collection_id", deleteTrainingDataOptions.collectionId()); + pathParamsMap.put("query_id", deleteTrainingDataOptions.queryId()); RequestBuilder builder = RequestBuilder.delete( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/environments/{environment_id}/collections/{collection_id}/training_data/{query_id}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "deleteTrainingData"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -1952,29 +2024,29 @@ public ServiceCall deleteTrainingData(DeleteTrainingDataOptions deleteTrai * * @param listTrainingExamplesOptions the {@link ListTrainingExamplesOptions} containing the * options for the call - * @return a {@link ServiceCall} with a response type of {@link TrainingExampleList} + * @return a {@link ServiceCall} with a result of type {@link TrainingExampleList} */ public ServiceCall listTrainingExamples( ListTrainingExamplesOptions listTrainingExamplesOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( listTrainingExamplesOptions, "listTrainingExamplesOptions cannot be null"); - String[] pathSegments = {"v1/environments", "collections", "training_data", "examples"}; - String[] pathParameters = { - listTrainingExamplesOptions.environmentId(), - listTrainingExamplesOptions.collectionId(), - listTrainingExamplesOptions.queryId() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("environment_id", listTrainingExamplesOptions.environmentId()); + pathParamsMap.put("collection_id", listTrainingExamplesOptions.collectionId()); + pathParamsMap.put("query_id", listTrainingExamplesOptions.queryId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/environments/{environment_id}/collections/{collection_id}/training_data/{query_id}/examples", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "listTrainingExamples"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken() {}.getType()); @@ -1988,28 +2060,29 @@ public ServiceCall listTrainingExamples( * * @param createTrainingExampleOptions the {@link CreateTrainingExampleOptions} containing the * options for the call - * @return a {@link ServiceCall} with a response type of {@link TrainingExample} + * @return a {@link ServiceCall} with a result of type {@link TrainingExample} */ public ServiceCall createTrainingExample( CreateTrainingExampleOptions createTrainingExampleOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( createTrainingExampleOptions, "createTrainingExampleOptions cannot be null"); - String[] pathSegments = {"v1/environments", "collections", "training_data", "examples"}; - String[] pathParameters = { - createTrainingExampleOptions.environmentId(), - createTrainingExampleOptions.collectionId(), - createTrainingExampleOptions.queryId() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("environment_id", createTrainingExampleOptions.environmentId()); + pathParamsMap.put("collection_id", createTrainingExampleOptions.collectionId()); + pathParamsMap.put("query_id", createTrainingExampleOptions.queryId()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/environments/{environment_id}/collections/{collection_id}/training_data/{query_id}/examples", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "createTrainingExample"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); final JsonObject contentJson = new JsonObject(); if (createTrainingExampleOptions.documentId() != null) { contentJson.addProperty("document_id", createTrainingExampleOptions.documentId()); @@ -2034,29 +2107,29 @@ public ServiceCall createTrainingExample( * * @param deleteTrainingExampleOptions the {@link DeleteTrainingExampleOptions} containing the * options for the call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteTrainingExample( DeleteTrainingExampleOptions deleteTrainingExampleOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( deleteTrainingExampleOptions, "deleteTrainingExampleOptions cannot be null"); - String[] pathSegments = {"v1/environments", "collections", "training_data", "examples"}; - String[] pathParameters = { - deleteTrainingExampleOptions.environmentId(), - deleteTrainingExampleOptions.collectionId(), - deleteTrainingExampleOptions.queryId(), - deleteTrainingExampleOptions.exampleId() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("environment_id", deleteTrainingExampleOptions.environmentId()); + pathParamsMap.put("collection_id", deleteTrainingExampleOptions.collectionId()); + pathParamsMap.put("query_id", deleteTrainingExampleOptions.queryId()); + pathParamsMap.put("example_id", deleteTrainingExampleOptions.exampleId()); RequestBuilder builder = RequestBuilder.delete( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/environments/{environment_id}/collections/{collection_id}/training_data/{query_id}/examples/{example_id}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "deleteTrainingExample"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -2068,29 +2141,30 @@ public ServiceCall deleteTrainingExample( * * @param updateTrainingExampleOptions the {@link UpdateTrainingExampleOptions} containing the * options for the call - * @return a {@link ServiceCall} with a response type of {@link TrainingExample} + * @return a {@link ServiceCall} with a result of type {@link TrainingExample} */ public ServiceCall updateTrainingExample( UpdateTrainingExampleOptions updateTrainingExampleOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( updateTrainingExampleOptions, "updateTrainingExampleOptions cannot be null"); - String[] pathSegments = {"v1/environments", "collections", "training_data", "examples"}; - String[] pathParameters = { - updateTrainingExampleOptions.environmentId(), - updateTrainingExampleOptions.collectionId(), - updateTrainingExampleOptions.queryId(), - updateTrainingExampleOptions.exampleId() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("environment_id", updateTrainingExampleOptions.environmentId()); + pathParamsMap.put("collection_id", updateTrainingExampleOptions.collectionId()); + pathParamsMap.put("query_id", updateTrainingExampleOptions.queryId()); + pathParamsMap.put("example_id", updateTrainingExampleOptions.exampleId()); RequestBuilder builder = RequestBuilder.put( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/environments/{environment_id}/collections/{collection_id}/training_data/{query_id}/examples/{example_id}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "updateTrainingExample"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); final JsonObject contentJson = new JsonObject(); if (updateTrainingExampleOptions.crossReference() != null) { contentJson.addProperty("cross_reference", updateTrainingExampleOptions.crossReference()); @@ -2112,30 +2186,30 @@ public ServiceCall updateTrainingExample( * * @param getTrainingExampleOptions the {@link GetTrainingExampleOptions} containing the options * for the call - * @return a {@link ServiceCall} with a response type of {@link TrainingExample} + * @return a {@link ServiceCall} with a result of type {@link TrainingExample} */ public ServiceCall getTrainingExample( GetTrainingExampleOptions getTrainingExampleOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( getTrainingExampleOptions, "getTrainingExampleOptions cannot be null"); - String[] pathSegments = {"v1/environments", "collections", "training_data", "examples"}; - String[] pathParameters = { - getTrainingExampleOptions.environmentId(), - getTrainingExampleOptions.collectionId(), - getTrainingExampleOptions.queryId(), - getTrainingExampleOptions.exampleId() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("environment_id", getTrainingExampleOptions.environmentId()); + pathParamsMap.put("collection_id", getTrainingExampleOptions.collectionId()); + pathParamsMap.put("query_id", getTrainingExampleOptions.queryId()); + pathParamsMap.put("example_id", getTrainingExampleOptions.exampleId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/environments/{environment_id}/collections/{collection_id}/training_data/{query_id}/examples/{example_id}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "getTrainingExample"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken() {}.getType()); @@ -2155,20 +2229,19 @@ public ServiceCall getTrainingExample( * * @param deleteUserDataOptions the {@link DeleteUserDataOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteUserData(DeleteUserDataOptions deleteUserDataOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( deleteUserDataOptions, "deleteUserDataOptions cannot be null"); - String[] pathSegments = {"v1/user_data"}; RequestBuilder builder = - RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); + RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/user_data")); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "deleteUserData"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } - builder.query("customer_id", deleteUserDataOptions.customerId()); + builder.query("version", String.valueOf(this.version)); + builder.query("customer_id", String.valueOf(deleteUserDataOptions.customerId())); ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -2181,20 +2254,19 @@ public ServiceCall deleteUserData(DeleteUserDataOptions deleteUserDataOpti * user and when that click occurred. * * @param createEventOptions the {@link CreateEventOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link CreateEventResponse} + * @return a {@link ServiceCall} with a result of type {@link CreateEventResponse} */ public ServiceCall createEvent(CreateEventOptions createEventOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( createEventOptions, "createEventOptions cannot be null"); - String[] pathSegments = {"v1/events"}; RequestBuilder builder = - RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); + RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/events")); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "createEvent"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); final JsonObject contentJson = new JsonObject(); contentJson.addProperty("type", createEventOptions.type()); contentJson.add( @@ -2215,34 +2287,34 @@ public ServiceCall createEvent(CreateEventOptions createEve * that are supported. * * @param queryLogOptions the {@link QueryLogOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link LogQueryResponse} + * @return a {@link ServiceCall} with a result of type {@link LogQueryResponse} */ public ServiceCall queryLog(QueryLogOptions queryLogOptions) { - String[] pathSegments = {"v1/logs"}; + if (queryLogOptions == null) { + queryLogOptions = new QueryLogOptions.Builder().build(); + } RequestBuilder builder = - RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); + RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/logs")); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "queryLog"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - if (queryLogOptions != null) { - if (queryLogOptions.filter() != null) { - builder.query("filter", queryLogOptions.filter()); - } - if (queryLogOptions.query() != null) { - builder.query("query", queryLogOptions.query()); - } - if (queryLogOptions.count() != null) { - builder.query("count", String.valueOf(queryLogOptions.count())); - } - if (queryLogOptions.offset() != null) { - builder.query("offset", String.valueOf(queryLogOptions.offset())); - } - if (queryLogOptions.sort() != null) { - builder.query("sort", RequestUtils.join(queryLogOptions.sort(), ",")); - } + builder.query("version", String.valueOf(this.version)); + if (queryLogOptions.filter() != null) { + builder.query("filter", String.valueOf(queryLogOptions.filter())); + } + if (queryLogOptions.query() != null) { + builder.query("query", String.valueOf(queryLogOptions.query())); + } + if (queryLogOptions.count() != null) { + builder.query("count", String.valueOf(queryLogOptions.count())); + } + if (queryLogOptions.offset() != null) { + builder.query("offset", String.valueOf(queryLogOptions.offset())); + } + if (queryLogOptions.sort() != null) { + builder.query("sort", RequestUtils.join(queryLogOptions.sort(), ",")); } ResponseConverter responseConverter = ResponseConverterUtils.getValue( @@ -2257,7 +2329,7 @@ public ServiceCall queryLog(QueryLogOptions queryLogOptions) { * Searching the **logs** endpoint uses the standard Discovery query syntax for the parameters * that are supported. * - * @return a {@link ServiceCall} with a response type of {@link LogQueryResponse} + * @return a {@link ServiceCall} with a result of type {@link LogQueryResponse} */ public ServiceCall queryLog() { return queryLog(null); @@ -2271,29 +2343,30 @@ public ServiceCall queryLog() { * * @param getMetricsQueryOptions the {@link GetMetricsQueryOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of {@link MetricResponse} + * @return a {@link ServiceCall} with a result of type {@link MetricResponse} */ public ServiceCall getMetricsQuery( GetMetricsQueryOptions getMetricsQueryOptions) { - String[] pathSegments = {"v1/metrics/number_of_queries"}; + if (getMetricsQueryOptions == null) { + getMetricsQueryOptions = new GetMetricsQueryOptions.Builder().build(); + } RequestBuilder builder = - RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); + RequestBuilder.get( + RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/metrics/number_of_queries")); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "getMetricsQuery"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - if (getMetricsQueryOptions != null) { - if (getMetricsQueryOptions.startTime() != null) { - builder.query("start_time", String.valueOf(getMetricsQueryOptions.startTime())); - } - if (getMetricsQueryOptions.endTime() != null) { - builder.query("end_time", String.valueOf(getMetricsQueryOptions.endTime())); - } - if (getMetricsQueryOptions.resultType() != null) { - builder.query("result_type", getMetricsQueryOptions.resultType()); - } + builder.query("version", String.valueOf(this.version)); + if (getMetricsQueryOptions.startTime() != null) { + builder.query("start_time", DateUtils.formatAsDateTime(getMetricsQueryOptions.startTime())); + } + if (getMetricsQueryOptions.endTime() != null) { + builder.query("end_time", DateUtils.formatAsDateTime(getMetricsQueryOptions.endTime())); + } + if (getMetricsQueryOptions.resultType() != null) { + builder.query("result_type", String.valueOf(getMetricsQueryOptions.resultType())); } ResponseConverter responseConverter = ResponseConverterUtils.getValue( @@ -2307,7 +2380,7 @@ public ServiceCall getMetricsQuery( *

Total number of queries using the **natural_language_query** parameter over a specific time * window. * - * @return a {@link ServiceCall} with a response type of {@link MetricResponse} + * @return a {@link ServiceCall} with a result of type {@link MetricResponse} */ public ServiceCall getMetricsQuery() { return getMetricsQuery(null); @@ -2322,30 +2395,33 @@ public ServiceCall getMetricsQuery() { * * @param getMetricsQueryEventOptions the {@link GetMetricsQueryEventOptions} containing the * options for the call - * @return a {@link ServiceCall} with a response type of {@link MetricResponse} + * @return a {@link ServiceCall} with a result of type {@link MetricResponse} */ public ServiceCall getMetricsQueryEvent( GetMetricsQueryEventOptions getMetricsQueryEventOptions) { - String[] pathSegments = {"v1/metrics/number_of_queries_with_event"}; + if (getMetricsQueryEventOptions == null) { + getMetricsQueryEventOptions = new GetMetricsQueryEventOptions.Builder().build(); + } RequestBuilder builder = - RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/metrics/number_of_queries_with_event")); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "getMetricsQueryEvent"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - if (getMetricsQueryEventOptions != null) { - if (getMetricsQueryEventOptions.startTime() != null) { - builder.query("start_time", String.valueOf(getMetricsQueryEventOptions.startTime())); - } - if (getMetricsQueryEventOptions.endTime() != null) { - builder.query("end_time", String.valueOf(getMetricsQueryEventOptions.endTime())); - } - if (getMetricsQueryEventOptions.resultType() != null) { - builder.query("result_type", getMetricsQueryEventOptions.resultType()); - } + builder.query("version", String.valueOf(this.version)); + if (getMetricsQueryEventOptions.startTime() != null) { + builder.query( + "start_time", DateUtils.formatAsDateTime(getMetricsQueryEventOptions.startTime())); + } + if (getMetricsQueryEventOptions.endTime() != null) { + builder.query("end_time", DateUtils.formatAsDateTime(getMetricsQueryEventOptions.endTime())); + } + if (getMetricsQueryEventOptions.resultType() != null) { + builder.query("result_type", String.valueOf(getMetricsQueryEventOptions.resultType())); } ResponseConverter responseConverter = ResponseConverterUtils.getValue( @@ -2360,7 +2436,7 @@ public ServiceCall getMetricsQueryEvent( * corresponding "click" event over a specified time window. This metric requires having * integrated event tracking in your application using the **Events** API. * - * @return a {@link ServiceCall} with a response type of {@link MetricResponse} + * @return a {@link ServiceCall} with a result of type {@link MetricResponse} */ public ServiceCall getMetricsQueryEvent() { return getMetricsQueryEvent(null); @@ -2374,30 +2450,34 @@ public ServiceCall getMetricsQueryEvent() { * * @param getMetricsQueryNoResultsOptions the {@link GetMetricsQueryNoResultsOptions} containing * the options for the call - * @return a {@link ServiceCall} with a response type of {@link MetricResponse} + * @return a {@link ServiceCall} with a result of type {@link MetricResponse} */ public ServiceCall getMetricsQueryNoResults( GetMetricsQueryNoResultsOptions getMetricsQueryNoResultsOptions) { - String[] pathSegments = {"v1/metrics/number_of_queries_with_no_search_results"}; + if (getMetricsQueryNoResultsOptions == null) { + getMetricsQueryNoResultsOptions = new GetMetricsQueryNoResultsOptions.Builder().build(); + } RequestBuilder builder = - RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/metrics/number_of_queries_with_no_search_results")); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "getMetricsQueryNoResults"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - if (getMetricsQueryNoResultsOptions != null) { - if (getMetricsQueryNoResultsOptions.startTime() != null) { - builder.query("start_time", String.valueOf(getMetricsQueryNoResultsOptions.startTime())); - } - if (getMetricsQueryNoResultsOptions.endTime() != null) { - builder.query("end_time", String.valueOf(getMetricsQueryNoResultsOptions.endTime())); - } - if (getMetricsQueryNoResultsOptions.resultType() != null) { - builder.query("result_type", getMetricsQueryNoResultsOptions.resultType()); - } + builder.query("version", String.valueOf(this.version)); + if (getMetricsQueryNoResultsOptions.startTime() != null) { + builder.query( + "start_time", DateUtils.formatAsDateTime(getMetricsQueryNoResultsOptions.startTime())); + } + if (getMetricsQueryNoResultsOptions.endTime() != null) { + builder.query( + "end_time", DateUtils.formatAsDateTime(getMetricsQueryNoResultsOptions.endTime())); + } + if (getMetricsQueryNoResultsOptions.resultType() != null) { + builder.query("result_type", String.valueOf(getMetricsQueryNoResultsOptions.resultType())); } ResponseConverter responseConverter = ResponseConverterUtils.getValue( @@ -2411,7 +2491,7 @@ public ServiceCall getMetricsQueryNoResults( *

Total number of queries using the **natural_language_query** parameter that have no results * returned over a specified time window. * - * @return a {@link ServiceCall} with a response type of {@link MetricResponse} + * @return a {@link ServiceCall} with a result of type {@link MetricResponse} */ public ServiceCall getMetricsQueryNoResults() { return getMetricsQueryNoResults(null); @@ -2426,30 +2506,32 @@ public ServiceCall getMetricsQueryNoResults() { * * @param getMetricsEventRateOptions the {@link GetMetricsEventRateOptions} containing the options * for the call - * @return a {@link ServiceCall} with a response type of {@link MetricResponse} + * @return a {@link ServiceCall} with a result of type {@link MetricResponse} */ public ServiceCall getMetricsEventRate( GetMetricsEventRateOptions getMetricsEventRateOptions) { - String[] pathSegments = {"v1/metrics/event_rate"}; + if (getMetricsEventRateOptions == null) { + getMetricsEventRateOptions = new GetMetricsEventRateOptions.Builder().build(); + } RequestBuilder builder = - RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); + RequestBuilder.get( + RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/metrics/event_rate")); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "getMetricsEventRate"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - if (getMetricsEventRateOptions != null) { - if (getMetricsEventRateOptions.startTime() != null) { - builder.query("start_time", String.valueOf(getMetricsEventRateOptions.startTime())); - } - if (getMetricsEventRateOptions.endTime() != null) { - builder.query("end_time", String.valueOf(getMetricsEventRateOptions.endTime())); - } - if (getMetricsEventRateOptions.resultType() != null) { - builder.query("result_type", getMetricsEventRateOptions.resultType()); - } + builder.query("version", String.valueOf(this.version)); + if (getMetricsEventRateOptions.startTime() != null) { + builder.query( + "start_time", DateUtils.formatAsDateTime(getMetricsEventRateOptions.startTime())); + } + if (getMetricsEventRateOptions.endTime() != null) { + builder.query("end_time", DateUtils.formatAsDateTime(getMetricsEventRateOptions.endTime())); + } + if (getMetricsEventRateOptions.resultType() != null) { + builder.query("result_type", String.valueOf(getMetricsEventRateOptions.resultType())); } ResponseConverter responseConverter = ResponseConverterUtils.getValue( @@ -2464,7 +2546,7 @@ public ServiceCall getMetricsEventRate( * corresponding "click" event over a specified time window. This metric requires having * integrated event tracking in your application using the **Events** API. * - * @return a {@link ServiceCall} with a response type of {@link MetricResponse} + * @return a {@link ServiceCall} with a result of type {@link MetricResponse} */ public ServiceCall getMetricsEventRate() { return getMetricsEventRate(null); @@ -2479,24 +2561,26 @@ public ServiceCall getMetricsEventRate() { * * @param getMetricsQueryTokenEventOptions the {@link GetMetricsQueryTokenEventOptions} containing * the options for the call - * @return a {@link ServiceCall} with a response type of {@link MetricTokenResponse} + * @return a {@link ServiceCall} with a result of type {@link MetricTokenResponse} */ public ServiceCall getMetricsQueryTokenEvent( GetMetricsQueryTokenEventOptions getMetricsQueryTokenEventOptions) { - String[] pathSegments = {"v1/metrics/top_query_tokens_with_event_rate"}; + if (getMetricsQueryTokenEventOptions == null) { + getMetricsQueryTokenEventOptions = new GetMetricsQueryTokenEventOptions.Builder().build(); + } RequestBuilder builder = - RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); + RequestBuilder.get( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/metrics/top_query_tokens_with_event_rate")); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "getMetricsQueryTokenEvent"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - if (getMetricsQueryTokenEventOptions != null) { - if (getMetricsQueryTokenEventOptions.count() != null) { - builder.query("count", String.valueOf(getMetricsQueryTokenEventOptions.count())); - } + builder.query("version", String.valueOf(this.version)); + if (getMetricsQueryTokenEventOptions.count() != null) { + builder.query("count", String.valueOf(getMetricsQueryTokenEventOptions.count())); } ResponseConverter responseConverter = ResponseConverterUtils.getValue( @@ -2511,7 +2595,7 @@ public ServiceCall getMetricsQueryTokenEvent( * their corresponding "click" event rate within the recording period (queries and events are * stored for 30 days). A query token is an individual word or unigram within the query string. * - * @return a {@link ServiceCall} with a response type of {@link MetricTokenResponse} + * @return a {@link ServiceCall} with a result of type {@link MetricTokenResponse} */ public ServiceCall getMetricsQueryTokenEvent() { return getMetricsQueryTokenEvent(null); @@ -2526,24 +2610,24 @@ public ServiceCall getMetricsQueryTokenEvent() { * * @param listCredentialsOptions the {@link ListCredentialsOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of {@link CredentialsList} + * @return a {@link ServiceCall} with a result of type {@link CredentialsList} */ public ServiceCall listCredentials( ListCredentialsOptions listCredentialsOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( listCredentialsOptions, "listCredentialsOptions cannot be null"); - String[] pathSegments = {"v1/environments", "credentials"}; - String[] pathParameters = {listCredentialsOptions.environmentId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("environment_id", listCredentialsOptions.environmentId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/environments/{environment_id}/credentials", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "listCredentials"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken() {}.getType()); @@ -2560,24 +2644,25 @@ public ServiceCall listCredentials( * * @param createCredentialsOptions the {@link CreateCredentialsOptions} containing the options for * the call - * @return a {@link ServiceCall} with a response type of {@link Credentials} + * @return a {@link ServiceCall} with a result of type {@link Credentials} */ public ServiceCall createCredentials( CreateCredentialsOptions createCredentialsOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( createCredentialsOptions, "createCredentialsOptions cannot be null"); - String[] pathSegments = {"v1/environments", "credentials"}; - String[] pathParameters = {createCredentialsOptions.environmentId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("environment_id", createCredentialsOptions.environmentId()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/environments/{environment_id}/credentials", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "createCredentials"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); final JsonObject contentJson = new JsonObject(); if (createCredentialsOptions.sourceType() != null) { contentJson.addProperty("source_type", createCredentialsOptions.sourceType()); @@ -2608,25 +2693,26 @@ public ServiceCall createCredentials( * * @param getCredentialsOptions the {@link GetCredentialsOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of {@link Credentials} + * @return a {@link ServiceCall} with a result of type {@link Credentials} */ public ServiceCall getCredentials(GetCredentialsOptions getCredentialsOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( getCredentialsOptions, "getCredentialsOptions cannot be null"); - String[] pathSegments = {"v1/environments", "credentials"}; - String[] pathParameters = { - getCredentialsOptions.environmentId(), getCredentialsOptions.credentialId() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("environment_id", getCredentialsOptions.environmentId()); + pathParamsMap.put("credential_id", getCredentialsOptions.credentialId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/environments/{environment_id}/credentials/{credential_id}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "getCredentials"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken() {}.getType()); @@ -2642,26 +2728,28 @@ public ServiceCall getCredentials(GetCredentialsOptions getCredenti * * @param updateCredentialsOptions the {@link UpdateCredentialsOptions} containing the options for * the call - * @return a {@link ServiceCall} with a response type of {@link Credentials} + * @return a {@link ServiceCall} with a result of type {@link Credentials} */ public ServiceCall updateCredentials( UpdateCredentialsOptions updateCredentialsOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( updateCredentialsOptions, "updateCredentialsOptions cannot be null"); - String[] pathSegments = {"v1/environments", "credentials"}; - String[] pathParameters = { - updateCredentialsOptions.environmentId(), updateCredentialsOptions.credentialId() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("environment_id", updateCredentialsOptions.environmentId()); + pathParamsMap.put("credential_id", updateCredentialsOptions.credentialId()); RequestBuilder builder = RequestBuilder.put( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/environments/{environment_id}/credentials/{credential_id}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "updateCredentials"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); final JsonObject contentJson = new JsonObject(); if (updateCredentialsOptions.sourceType() != null) { contentJson.addProperty("source_type", updateCredentialsOptions.sourceType()); @@ -2689,27 +2777,28 @@ public ServiceCall updateCredentials( * * @param deleteCredentialsOptions the {@link DeleteCredentialsOptions} containing the options for * the call - * @return a {@link ServiceCall} with a response type of {@link DeleteCredentials} + * @return a {@link ServiceCall} with a result of type {@link DeleteCredentials} */ public ServiceCall deleteCredentials( DeleteCredentialsOptions deleteCredentialsOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( deleteCredentialsOptions, "deleteCredentialsOptions cannot be null"); - String[] pathSegments = {"v1/environments", "credentials"}; - String[] pathParameters = { - deleteCredentialsOptions.environmentId(), deleteCredentialsOptions.credentialId() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("environment_id", deleteCredentialsOptions.environmentId()); + pathParamsMap.put("credential_id", deleteCredentialsOptions.credentialId()); RequestBuilder builder = RequestBuilder.delete( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/environments/{environment_id}/credentials/{credential_id}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "deleteCredentials"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken() {}.getType()); @@ -2722,23 +2811,23 @@ public ServiceCall deleteCredentials( *

List the currently configured gateways. * * @param listGatewaysOptions the {@link ListGatewaysOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link GatewayList} + * @return a {@link ServiceCall} with a result of type {@link GatewayList} */ public ServiceCall listGateways(ListGatewaysOptions listGatewaysOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( listGatewaysOptions, "listGatewaysOptions cannot be null"); - String[] pathSegments = {"v1/environments", "gateways"}; - String[] pathParameters = {listGatewaysOptions.environmentId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("environment_id", listGatewaysOptions.environmentId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/environments/{environment_id}/gateways", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "listGateways"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken() {}.getType()); @@ -2752,22 +2841,23 @@ public ServiceCall listGateways(ListGatewaysOptions listGatewaysOpt * * @param createGatewayOptions the {@link CreateGatewayOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of {@link Gateway} + * @return a {@link ServiceCall} with a result of type {@link Gateway} */ public ServiceCall createGateway(CreateGatewayOptions createGatewayOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( createGatewayOptions, "createGatewayOptions cannot be null"); - String[] pathSegments = {"v1/environments", "gateways"}; - String[] pathParameters = {createGatewayOptions.environmentId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("environment_id", createGatewayOptions.environmentId()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/environments/{environment_id}/gateways", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "createGateway"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); final JsonObject contentJson = new JsonObject(); if (createGatewayOptions.name() != null) { contentJson.addProperty("name", createGatewayOptions.name()); @@ -2785,23 +2875,26 @@ public ServiceCall createGateway(CreateGatewayOptions createGatewayOpti *

List information about the specified gateway. * * @param getGatewayOptions the {@link GetGatewayOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Gateway} + * @return a {@link ServiceCall} with a result of type {@link Gateway} */ public ServiceCall getGateway(GetGatewayOptions getGatewayOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( getGatewayOptions, "getGatewayOptions cannot be null"); - String[] pathSegments = {"v1/environments", "gateways"}; - String[] pathParameters = {getGatewayOptions.environmentId(), getGatewayOptions.gatewayId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("environment_id", getGatewayOptions.environmentId()); + pathParamsMap.put("gateway_id", getGatewayOptions.gatewayId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/environments/{environment_id}/gateways/{gateway_id}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "getGateway"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken() {}.getType()); @@ -2815,25 +2908,26 @@ public ServiceCall getGateway(GetGatewayOptions getGatewayOptions) { * * @param deleteGatewayOptions the {@link DeleteGatewayOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of {@link GatewayDelete} + * @return a {@link ServiceCall} with a result of type {@link GatewayDelete} */ public ServiceCall deleteGateway(DeleteGatewayOptions deleteGatewayOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( deleteGatewayOptions, "deleteGatewayOptions cannot be null"); - String[] pathSegments = {"v1/environments", "gateways"}; - String[] pathParameters = { - deleteGatewayOptions.environmentId(), deleteGatewayOptions.gatewayId() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("environment_id", deleteGatewayOptions.environmentId()); + pathParamsMap.put("gateway_id", deleteGatewayOptions.gatewayId()); RequestBuilder builder = RequestBuilder.delete( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/environments/{environment_id}/gateways/{gateway_id}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "deleteGateway"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken() {}.getType()); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/AddDocumentOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/AddDocumentOptions.java index afa4edce96c..c0ed2fe0d6b 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/AddDocumentOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/AddDocumentOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -63,7 +63,7 @@ public Builder(String environmentId, String collectionId) { /** * Builds a AddDocumentOptions. * - * @return the addDocumentOptions + * @return the new AddDocumentOptions instance */ public AddDocumentOptions build() { return new AddDocumentOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/AddTrainingDataOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/AddTrainingDataOptions.java index 0d01fbc818e..0a2312cf662 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/AddTrainingDataOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/AddTrainingDataOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -58,7 +58,7 @@ public Builder(String environmentId, String collectionId) { /** * Builds a AddTrainingDataOptions. * - * @return the addTrainingDataOptions + * @return the new AddTrainingDataOptions instance */ public AddTrainingDataOptions build() { return new AddTrainingDataOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/AggregationResult.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/AggregationResult.java index 47fa2ad05cb..5433bed01f4 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/AggregationResult.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/AggregationResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Calculation.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Calculation.java index 609626b25c5..03388aa09a2 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Calculation.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Calculation.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Collection.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Collection.java index 9b9337e5af9..3f31d1def11 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Collection.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Collection.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CollectionCrawlStatus.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CollectionCrawlStatus.java index d110dcaf4f3..167fdc7725d 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CollectionCrawlStatus.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CollectionCrawlStatus.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CollectionDiskUsage.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CollectionDiskUsage.java index 5404cbfcac4..9c8e82ffa9f 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CollectionDiskUsage.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CollectionDiskUsage.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CollectionUsage.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CollectionUsage.java index 5d032292573..eb0fc69b5fc 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CollectionUsage.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CollectionUsage.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Completions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Completions.java index 5dd9434dac6..b6feb64bca2 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Completions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Completions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Configuration.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Configuration.java index 506372f469c..ee8de344f92 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Configuration.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Configuration.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -35,10 +35,7 @@ public class Configuration extends GenericModel { /** Builder. */ public static class Builder { - private String configurationId; private String name; - private Date created; - private Date updated; private String description; private Conversions conversions; private List enrichments; @@ -46,10 +43,7 @@ public static class Builder { private Source source; private Builder(Configuration configuration) { - this.configurationId = configuration.configurationId; this.name = configuration.name; - this.created = configuration.created; - this.updated = configuration.updated; this.description = configuration.description; this.conversions = configuration.conversions; this.enrichments = configuration.enrichments; @@ -72,7 +66,7 @@ public Builder(String name) { /** * Builds a Configuration. * - * @return the configuration + * @return the new Configuration instance */ public Configuration build() { return new Configuration(this); @@ -108,17 +102,6 @@ public Builder addNormalization(NormalizationOperation normalization) { return this; } - /** - * Set the configurationId. - * - * @param configurationId the configurationId - * @return the Configuration builder - */ - public Builder configurationId(String configurationId) { - this.configurationId = configurationId; - return this; - } - /** * Set the name. * @@ -130,28 +113,6 @@ public Builder name(String name) { return this; } - /** - * Set the created. - * - * @param created the created - * @return the Configuration builder - */ - public Builder created(Date created) { - this.created = created; - return this; - } - - /** - * Set the updated. - * - * @param updated the updated - * @return the Configuration builder - */ - public Builder updated(Date updated) { - this.updated = updated; - return this; - } - /** * Set the description. * @@ -210,10 +171,7 @@ public Builder source(Source source) { protected Configuration(Builder builder) { com.ibm.cloud.sdk.core.util.Validator.notNull(builder.name, "name cannot be null"); - configurationId = builder.configurationId; name = builder.name; - created = builder.created; - updated = builder.updated; description = builder.description; conversions = builder.conversions; enrichments = builder.enrichments; diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Conversions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Conversions.java index fa7b8e239e8..723a4d672aa 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Conversions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Conversions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -55,7 +55,7 @@ public Builder() {} /** * Builds a Conversions. * - * @return the conversions + * @return the new Conversions instance */ public Conversions build() { return new Conversions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateCollectionOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateCollectionOptions.java index ca4675a9cb0..fbd4ac8e677 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateCollectionOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateCollectionOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -85,7 +85,7 @@ public Builder(String environmentId, String name) { /** * Builds a CreateCollectionOptions. * - * @return the createCollectionOptions + * @return the new CreateCollectionOptions instance */ public CreateCollectionOptions build() { return new CreateCollectionOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateConfigurationOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateConfigurationOptions.java index 482ab875d1b..97a8541aff6 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateConfigurationOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateConfigurationOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -64,7 +64,7 @@ public Builder(String environmentId, String name) { /** * Builds a CreateConfigurationOptions. * - * @return the createConfigurationOptions + * @return the new CreateConfigurationOptions instance */ public CreateConfigurationOptions build() { return new CreateConfigurationOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateCredentialsOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateCredentialsOptions.java index 71d6d4c479b..c389ff9ef54 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateCredentialsOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateCredentialsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -85,7 +85,7 @@ public Builder(String environmentId) { /** * Builds a CreateCredentialsOptions. * - * @return the createCredentialsOptions + * @return the new CreateCredentialsOptions instance */ public CreateCredentialsOptions build() { return new CreateCredentialsOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateEnvironmentOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateEnvironmentOptions.java index d66f1eba799..bca9ed5edce 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateEnvironmentOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateEnvironmentOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -75,7 +75,7 @@ public Builder(String name) { /** * Builds a CreateEnvironmentOptions. * - * @return the createEnvironmentOptions + * @return the new CreateEnvironmentOptions instance */ public CreateEnvironmentOptions build() { return new CreateEnvironmentOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateEventOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateEventOptions.java index e480a8072ac..9cd19582626 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateEventOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateEventOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -53,7 +53,7 @@ public Builder(String type, EventData data) { /** * Builds a CreateEventOptions. * - * @return the createEventOptions + * @return the new CreateEventOptions instance */ public CreateEventOptions build() { return new CreateEventOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateEventResponse.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateEventResponse.java index 16ebbd60c08..1d175c4f237 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateEventResponse.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateEventResponse.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateExpansionsOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateExpansionsOptions.java index bce53448d61..81f1fbc3301 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateExpansionsOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateExpansionsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -54,7 +54,7 @@ public Builder(String environmentId, String collectionId, List expans /** * Builds a CreateExpansionsOptions. * - * @return the createExpansionsOptions + * @return the new CreateExpansionsOptions instance */ public CreateExpansionsOptions build() { return new CreateExpansionsOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateGatewayOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateGatewayOptions.java index 12677f57da7..49a2deb2297 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateGatewayOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateGatewayOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -45,7 +45,7 @@ public Builder(String environmentId) { /** * Builds a CreateGatewayOptions. * - * @return the createGatewayOptions + * @return the new CreateGatewayOptions instance */ public CreateGatewayOptions build() { return new CreateGatewayOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateStopwordListOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateStopwordListOptions.java index e309528ee78..047a5820584 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateStopwordListOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateStopwordListOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -65,7 +65,7 @@ public Builder( /** * Builds a CreateStopwordListOptions. * - * @return the createStopwordListOptions + * @return the new CreateStopwordListOptions instance */ public CreateStopwordListOptions build() { return new CreateStopwordListOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateTokenizationDictionaryOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateTokenizationDictionaryOptions.java index 5d9fe2a6b41..e318d9ff1f5 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateTokenizationDictionaryOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateTokenizationDictionaryOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -52,7 +52,7 @@ public Builder(String environmentId, String collectionId) { /** * Builds a CreateTokenizationDictionaryOptions. * - * @return the createTokenizationDictionaryOptions + * @return the new CreateTokenizationDictionaryOptions instance */ public CreateTokenizationDictionaryOptions build() { return new CreateTokenizationDictionaryOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateTrainingExampleOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateTrainingExampleOptions.java index 08300351008..1f51c19328e 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateTrainingExampleOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CreateTrainingExampleOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -61,7 +61,7 @@ public Builder(String environmentId, String collectionId, String queryId) { /** * Builds a CreateTrainingExampleOptions. * - * @return the createTrainingExampleOptions + * @return the new CreateTrainingExampleOptions instance */ public CreateTrainingExampleOptions build() { return new CreateTrainingExampleOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CredentialDetails.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CredentialDetails.java index 894ca91c0b4..2642fb4c311 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CredentialDetails.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CredentialDetails.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -39,7 +39,7 @@ public interface CredentialType { /** saml. */ String SAML = "saml"; /** username_password. */ - String USERNAME_PASSWORD = "username_password"; // pragma: whitelist secret + String USERNAME_PASSWORD = "username_password"; /** noauth. */ String NOAUTH = "noauth"; /** basic. */ @@ -141,7 +141,7 @@ private Builder(CredentialDetails credentialDetails) { this.publicKeyId = credentialDetails.publicKeyId; this.privateKey = credentialDetails.privateKey; this.passphrase = credentialDetails.passphrase; - this.password = credentialDetails.password; // pragma: whitelist secret + this.password = credentialDetails.password; this.gatewayId = credentialDetails.gatewayId; this.sourceVersion = credentialDetails.sourceVersion; this.webApplicationUrl = credentialDetails.webApplicationUrl; @@ -157,7 +157,7 @@ public Builder() {} /** * Builds a CredentialDetails. * - * @return the credentialDetails + * @return the new CredentialDetails instance */ public CredentialDetails build() { return new CredentialDetails(this); @@ -291,7 +291,7 @@ public Builder passphrase(String passphrase) { * @return the CredentialDetails builder */ public Builder password(String password) { - this.password = password; // pragma: whitelist secret + this.password = password; return this; } @@ -385,7 +385,7 @@ protected CredentialDetails(Builder builder) { publicKeyId = builder.publicKeyId; privateKey = builder.privateKey; passphrase = builder.passphrase; - password = builder.password; // pragma: whitelist secret + password = builder.password; gatewayId = builder.gatewayId; sourceVersion = builder.sourceVersion; webApplicationUrl = builder.webApplicationUrl; diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Credentials.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Credentials.java index 72cae71930b..e7cf2cb400d 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Credentials.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Credentials.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -65,13 +65,11 @@ public interface Status { /** Builder. */ public static class Builder { - private String credentialId; private String sourceType; private CredentialDetails credentialDetails; private String status; private Builder(Credentials credentials) { - this.credentialId = credentials.credentialId; this.sourceType = credentials.sourceType; this.credentialDetails = credentials.credentialDetails; this.status = credentials.status; @@ -83,23 +81,12 @@ public Builder() {} /** * Builds a Credentials. * - * @return the credentials + * @return the new Credentials instance */ public Credentials build() { return new Credentials(this); } - /** - * Set the credentialId. - * - * @param credentialId the credentialId - * @return the Credentials builder - */ - public Builder credentialId(String credentialId) { - this.credentialId = credentialId; - return this; - } - /** * Set the sourceType. * @@ -135,7 +122,6 @@ public Builder status(String status) { } protected Credentials(Builder builder) { - credentialId = builder.credentialId; sourceType = builder.sourceType; credentialDetails = builder.credentialDetails; status = builder.status; diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CredentialsList.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CredentialsList.java index 515b03e893b..c47bbea4e70 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CredentialsList.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/CredentialsList.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteAllTrainingDataOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteAllTrainingDataOptions.java index e830d04547e..07e2de50a6e 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteAllTrainingDataOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteAllTrainingDataOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -47,7 +47,7 @@ public Builder(String environmentId, String collectionId) { /** * Builds a DeleteAllTrainingDataOptions. * - * @return the deleteAllTrainingDataOptions + * @return the new DeleteAllTrainingDataOptions instance */ public DeleteAllTrainingDataOptions build() { return new DeleteAllTrainingDataOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteCollectionOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteCollectionOptions.java index e0022e455b3..428373a6e7d 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteCollectionOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteCollectionOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -47,7 +47,7 @@ public Builder(String environmentId, String collectionId) { /** * Builds a DeleteCollectionOptions. * - * @return the deleteCollectionOptions + * @return the new DeleteCollectionOptions instance */ public DeleteCollectionOptions build() { return new DeleteCollectionOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteCollectionResponse.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteCollectionResponse.java index a0655bc7cdd..4d1dae3790c 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteCollectionResponse.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteCollectionResponse.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteConfigurationOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteConfigurationOptions.java index d42e0e500e7..88250f50c4f 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteConfigurationOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteConfigurationOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -47,7 +47,7 @@ public Builder(String environmentId, String configurationId) { /** * Builds a DeleteConfigurationOptions. * - * @return the deleteConfigurationOptions + * @return the new DeleteConfigurationOptions instance */ public DeleteConfigurationOptions build() { return new DeleteConfigurationOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteConfigurationResponse.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteConfigurationResponse.java index 992f844d02f..95cc5f2d820 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteConfigurationResponse.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteConfigurationResponse.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteCredentials.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteCredentials.java index b36080407b7..bcf38cfa4d0 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteCredentials.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteCredentials.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteCredentialsOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteCredentialsOptions.java index d8dad58bc88..b1c8b77da2c 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteCredentialsOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteCredentialsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -47,7 +47,7 @@ public Builder(String environmentId, String credentialId) { /** * Builds a DeleteCredentialsOptions. * - * @return the deleteCredentialsOptions + * @return the new DeleteCredentialsOptions instance */ public DeleteCredentialsOptions build() { return new DeleteCredentialsOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteDocumentOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteDocumentOptions.java index 165f42f5dfb..f69b7fb1353 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteDocumentOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteDocumentOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -52,7 +52,7 @@ public Builder(String environmentId, String collectionId, String documentId) { /** * Builds a DeleteDocumentOptions. * - * @return the deleteDocumentOptions + * @return the new DeleteDocumentOptions instance */ public DeleteDocumentOptions build() { return new DeleteDocumentOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteDocumentResponse.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteDocumentResponse.java index a8ff4d1f30a..e92d0303744 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteDocumentResponse.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteDocumentResponse.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteEnvironmentOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteEnvironmentOptions.java index 7d37fdaa462..1e964e06d37 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteEnvironmentOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteEnvironmentOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -42,7 +42,7 @@ public Builder(String environmentId) { /** * Builds a DeleteEnvironmentOptions. * - * @return the deleteEnvironmentOptions + * @return the new DeleteEnvironmentOptions instance */ public DeleteEnvironmentOptions build() { return new DeleteEnvironmentOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteEnvironmentResponse.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteEnvironmentResponse.java index 01aa96512c5..a45dd261e0c 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteEnvironmentResponse.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteEnvironmentResponse.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteExpansionsOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteExpansionsOptions.java index 903e4ec343c..0f5d687053f 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteExpansionsOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteExpansionsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -47,7 +47,7 @@ public Builder(String environmentId, String collectionId) { /** * Builds a DeleteExpansionsOptions. * - * @return the deleteExpansionsOptions + * @return the new DeleteExpansionsOptions instance */ public DeleteExpansionsOptions build() { return new DeleteExpansionsOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteGatewayOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteGatewayOptions.java index 2577e58c87f..8159149de9a 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteGatewayOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteGatewayOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -47,7 +47,7 @@ public Builder(String environmentId, String gatewayId) { /** * Builds a DeleteGatewayOptions. * - * @return the deleteGatewayOptions + * @return the new DeleteGatewayOptions instance */ public DeleteGatewayOptions build() { return new DeleteGatewayOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteStopwordListOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteStopwordListOptions.java index 880c303cbeb..727959c6fc8 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteStopwordListOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteStopwordListOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -47,7 +47,7 @@ public Builder(String environmentId, String collectionId) { /** * Builds a DeleteStopwordListOptions. * - * @return the deleteStopwordListOptions + * @return the new DeleteStopwordListOptions instance */ public DeleteStopwordListOptions build() { return new DeleteStopwordListOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteTokenizationDictionaryOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteTokenizationDictionaryOptions.java index ca3e743104a..cefdfbcbd07 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteTokenizationDictionaryOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteTokenizationDictionaryOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -47,7 +47,7 @@ public Builder(String environmentId, String collectionId) { /** * Builds a DeleteTokenizationDictionaryOptions. * - * @return the deleteTokenizationDictionaryOptions + * @return the new DeleteTokenizationDictionaryOptions instance */ public DeleteTokenizationDictionaryOptions build() { return new DeleteTokenizationDictionaryOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteTrainingDataOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteTrainingDataOptions.java index e986dd9ca1b..909033c2fe4 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteTrainingDataOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteTrainingDataOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -52,7 +52,7 @@ public Builder(String environmentId, String collectionId, String queryId) { /** * Builds a DeleteTrainingDataOptions. * - * @return the deleteTrainingDataOptions + * @return the new DeleteTrainingDataOptions instance */ public DeleteTrainingDataOptions build() { return new DeleteTrainingDataOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteTrainingExampleOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteTrainingExampleOptions.java index 279c5ec9e35..ad74fe80920 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteTrainingExampleOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteTrainingExampleOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -57,7 +57,7 @@ public Builder(String environmentId, String collectionId, String queryId, String /** * Builds a DeleteTrainingExampleOptions. * - * @return the deleteTrainingExampleOptions + * @return the new DeleteTrainingExampleOptions instance */ public DeleteTrainingExampleOptions build() { return new DeleteTrainingExampleOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteUserDataOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteUserDataOptions.java index 21b407298e0..4f34a79ea94 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteUserDataOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DeleteUserDataOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -42,7 +42,7 @@ public Builder(String customerId) { /** * Builds a DeleteUserDataOptions. * - * @return the deleteUserDataOptions + * @return the new DeleteUserDataOptions instance */ public DeleteUserDataOptions build() { return new DeleteUserDataOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DiskUsage.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DiskUsage.java index b7453eed7c1..33a3990b500 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DiskUsage.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DiskUsage.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DocumentAccepted.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DocumentAccepted.java index e704edc94eb..f3943684731 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DocumentAccepted.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DocumentAccepted.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DocumentCounts.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DocumentCounts.java index a87bad8d6ae..8b813696849 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DocumentCounts.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DocumentCounts.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DocumentStatus.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DocumentStatus.java index a9359b2e5fb..c8b32dd80d1 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DocumentStatus.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/DocumentStatus.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Enrichment.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Enrichment.java index 23eed7f1e74..921e23596ff 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Enrichment.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Enrichment.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -76,7 +76,7 @@ public Builder(String destinationField, String sourceField, String enrichment) { /** * Builds a Enrichment. * - * @return the enrichment + * @return the new Enrichment instance */ public Enrichment build() { return new Enrichment(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/EnrichmentOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/EnrichmentOptions.java index 79cc6b108bd..233f1687f59 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/EnrichmentOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/EnrichmentOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -67,7 +67,7 @@ public Builder() {} /** * Builds a EnrichmentOptions. * - * @return the enrichmentOptions + * @return the new EnrichmentOptions instance */ public EnrichmentOptions build() { return new EnrichmentOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Environment.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Environment.java index f05fcdb5fbb..f0863c12794 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Environment.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Environment.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/EnvironmentDocuments.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/EnvironmentDocuments.java index 8059a889201..2c5b63f6932 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/EnvironmentDocuments.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/EnvironmentDocuments.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/EventData.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/EventData.java index 90350d73a99..c0779b233b4 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/EventData.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/EventData.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -48,7 +48,6 @@ public static class Builder { private Long displayRank; private String collectionId; private String documentId; - private String queryId; private Builder(EventData eventData) { this.environmentId = eventData.environmentId; @@ -57,7 +56,6 @@ private Builder(EventData eventData) { this.displayRank = eventData.displayRank; this.collectionId = eventData.collectionId; this.documentId = eventData.documentId; - this.queryId = eventData.queryId; } /** Instantiates a new builder. */ @@ -82,7 +80,7 @@ public Builder( /** * Builds a EventData. * - * @return the eventData + * @return the new EventData instance */ public EventData build() { return new EventData(this); @@ -153,17 +151,6 @@ public Builder documentId(String documentId) { this.documentId = documentId; return this; } - - /** - * Set the queryId. - * - * @param queryId the queryId - * @return the EventData builder - */ - public Builder queryId(String queryId) { - this.queryId = queryId; - return this; - } } protected EventData(Builder builder) { @@ -180,7 +167,6 @@ protected EventData(Builder builder) { displayRank = builder.displayRank; collectionId = builder.collectionId; documentId = builder.documentId; - queryId = builder.queryId; } /** diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Expansion.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Expansion.java index 37a6d49ea2e..a3fed55bd62 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Expansion.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Expansion.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -55,7 +55,7 @@ public Builder(List expandedTerms) { /** * Builds a Expansion. * - * @return the expansion + * @return the new Expansion instance */ public Expansion build() { return new Expansion(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Expansions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Expansions.java index e7470d3bb22..95fff9be62c 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Expansions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Expansions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -44,7 +44,7 @@ public Builder(List expansions) { /** * Builds a Expansions. * - * @return the expansions + * @return the new Expansions instance */ public Expansions build() { return new Expansions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/FederatedQueryNoticesOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/FederatedQueryNoticesOptions.java index 12f22a753d1..87125bfa401 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/FederatedQueryNoticesOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/FederatedQueryNoticesOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -88,7 +88,7 @@ public Builder(String environmentId, List collectionIds) { /** * Builds a FederatedQueryNoticesOptions. * - * @return the federatedQueryNoticesOptions + * @return the new FederatedQueryNoticesOptions instance */ public FederatedQueryNoticesOptions build() { return new FederatedQueryNoticesOptions(this); @@ -491,7 +491,7 @@ public List sort() { * Gets the highlight. * *

When true, a highlight field is returned for each result which contains the fields which - * match the query with `` tags around the matching query terms. + * match the query with `<em></em>` tags around the matching query terms. * * @return the highlight */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/FederatedQueryOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/FederatedQueryOptions.java index 77f70bc15ac..d3496538e0f 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/FederatedQueryOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/FederatedQueryOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -107,7 +107,7 @@ public Builder(String environmentId, String collectionIds) { /** * Builds a FederatedQueryOptions. * - * @return the federatedQueryOptions + * @return the new FederatedQueryOptions instance */ public FederatedQueryOptions build() { return new FederatedQueryOptions(this); @@ -529,7 +529,7 @@ public String sort() { * Gets the highlight. * *

When true, a highlight field is returned for each result which contains the fields which - * match the query with `` tags around the matching query terms. + * match the query with `<em></em>` tags around the matching query terms. * * @return the highlight */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Field.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Field.java index 9c02e7b568b..6d65ffe4db4 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Field.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Field.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Filter.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Filter.java index 2900514b516..d6612369988 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Filter.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Filter.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/FontSetting.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/FontSetting.java index 77024b11fb8..90bba751d6e 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/FontSetting.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/FontSetting.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -54,7 +54,7 @@ public Builder() {} /** * Builds a FontSetting. * - * @return the fontSetting + * @return the new FontSetting instance */ public FontSetting build() { return new FontSetting(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Gateway.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Gateway.java index 3594fe9e954..7c057320909 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Gateway.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Gateway.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GatewayDelete.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GatewayDelete.java index 218a9844d0c..765590d81c3 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GatewayDelete.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GatewayDelete.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GatewayList.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GatewayList.java index 84a8cf9d87f..194efb793a9 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GatewayList.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GatewayList.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetAutocompletionOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetAutocompletionOptions.java index 4d8f4aacac5..d00a7038029 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetAutocompletionOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetAutocompletionOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -58,7 +58,7 @@ public Builder(String environmentId, String collectionId, String prefix) { /** * Builds a GetAutocompletionOptions. * - * @return the getAutocompletionOptions + * @return the new GetAutocompletionOptions instance */ public GetAutocompletionOptions build() { return new GetAutocompletionOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetCollectionOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetCollectionOptions.java index aaee6c01c5f..d020e5c2c14 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetCollectionOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetCollectionOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -47,7 +47,7 @@ public Builder(String environmentId, String collectionId) { /** * Builds a GetCollectionOptions. * - * @return the getCollectionOptions + * @return the new GetCollectionOptions instance */ public GetCollectionOptions build() { return new GetCollectionOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetConfigurationOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetConfigurationOptions.java index 0aec31ae7de..c2e47bd9af4 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetConfigurationOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetConfigurationOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -47,7 +47,7 @@ public Builder(String environmentId, String configurationId) { /** * Builds a GetConfigurationOptions. * - * @return the getConfigurationOptions + * @return the new GetConfigurationOptions instance */ public GetConfigurationOptions build() { return new GetConfigurationOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetCredentialsOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetCredentialsOptions.java index 0168696ca68..360c82709a6 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetCredentialsOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetCredentialsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -47,7 +47,7 @@ public Builder(String environmentId, String credentialId) { /** * Builds a GetCredentialsOptions. * - * @return the getCredentialsOptions + * @return the new GetCredentialsOptions instance */ public GetCredentialsOptions build() { return new GetCredentialsOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetDocumentStatusOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetDocumentStatusOptions.java index 27c9e0467b7..bd49625a965 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetDocumentStatusOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetDocumentStatusOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -52,7 +52,7 @@ public Builder(String environmentId, String collectionId, String documentId) { /** * Builds a GetDocumentStatusOptions. * - * @return the getDocumentStatusOptions + * @return the new GetDocumentStatusOptions instance */ public GetDocumentStatusOptions build() { return new GetDocumentStatusOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetEnvironmentOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetEnvironmentOptions.java index 4719bb8d30f..548ebc416e8 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetEnvironmentOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetEnvironmentOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -42,7 +42,7 @@ public Builder(String environmentId) { /** * Builds a GetEnvironmentOptions. * - * @return the getEnvironmentOptions + * @return the new GetEnvironmentOptions instance */ public GetEnvironmentOptions build() { return new GetEnvironmentOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetGatewayOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetGatewayOptions.java index 90e9b8928e4..13e3cd8c854 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetGatewayOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetGatewayOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -47,7 +47,7 @@ public Builder(String environmentId, String gatewayId) { /** * Builds a GetGatewayOptions. * - * @return the getGatewayOptions + * @return the new GetGatewayOptions instance */ public GetGatewayOptions build() { return new GetGatewayOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetMetricsEventRateOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetMetricsEventRateOptions.java index 52ca7fe20b2..3602003af78 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetMetricsEventRateOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetMetricsEventRateOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -46,7 +46,7 @@ public Builder() {} /** * Builds a GetMetricsEventRateOptions. * - * @return the getMetricsEventRateOptions + * @return the new GetMetricsEventRateOptions instance */ public GetMetricsEventRateOptions build() { return new GetMetricsEventRateOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetMetricsQueryEventOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetMetricsQueryEventOptions.java index 94329780d03..5b742334350 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetMetricsQueryEventOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetMetricsQueryEventOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -46,7 +46,7 @@ public Builder() {} /** * Builds a GetMetricsQueryEventOptions. * - * @return the getMetricsQueryEventOptions + * @return the new GetMetricsQueryEventOptions instance */ public GetMetricsQueryEventOptions build() { return new GetMetricsQueryEventOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetMetricsQueryNoResultsOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetMetricsQueryNoResultsOptions.java index 42690f84da4..da41f68ffd3 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetMetricsQueryNoResultsOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetMetricsQueryNoResultsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -46,7 +46,7 @@ public Builder() {} /** * Builds a GetMetricsQueryNoResultsOptions. * - * @return the getMetricsQueryNoResultsOptions + * @return the new GetMetricsQueryNoResultsOptions instance */ public GetMetricsQueryNoResultsOptions build() { return new GetMetricsQueryNoResultsOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetMetricsQueryOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetMetricsQueryOptions.java index 30ca1990e73..e9476958ba2 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetMetricsQueryOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetMetricsQueryOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -46,7 +46,7 @@ public Builder() {} /** * Builds a GetMetricsQueryOptions. * - * @return the getMetricsQueryOptions + * @return the new GetMetricsQueryOptions instance */ public GetMetricsQueryOptions build() { return new GetMetricsQueryOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetMetricsQueryTokenEventOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetMetricsQueryTokenEventOptions.java index 5b89a7223d0..3d4864ec727 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetMetricsQueryTokenEventOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetMetricsQueryTokenEventOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -33,7 +33,7 @@ public Builder() {} /** * Builds a GetMetricsQueryTokenEventOptions. * - * @return the getMetricsQueryTokenEventOptions + * @return the new GetMetricsQueryTokenEventOptions instance */ public GetMetricsQueryTokenEventOptions build() { return new GetMetricsQueryTokenEventOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetStopwordListStatusOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetStopwordListStatusOptions.java index ed9769b3950..703c4292ee9 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetStopwordListStatusOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetStopwordListStatusOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -47,7 +47,7 @@ public Builder(String environmentId, String collectionId) { /** * Builds a GetStopwordListStatusOptions. * - * @return the getStopwordListStatusOptions + * @return the new GetStopwordListStatusOptions instance */ public GetStopwordListStatusOptions build() { return new GetStopwordListStatusOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetTokenizationDictionaryStatusOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetTokenizationDictionaryStatusOptions.java index 52da3d178c6..6e6d19ec3eb 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetTokenizationDictionaryStatusOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetTokenizationDictionaryStatusOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -47,7 +47,7 @@ public Builder(String environmentId, String collectionId) { /** * Builds a GetTokenizationDictionaryStatusOptions. * - * @return the getTokenizationDictionaryStatusOptions + * @return the new GetTokenizationDictionaryStatusOptions instance */ public GetTokenizationDictionaryStatusOptions build() { return new GetTokenizationDictionaryStatusOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetTrainingDataOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetTrainingDataOptions.java index d18ad2708d0..2413ab4b2a1 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetTrainingDataOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetTrainingDataOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -52,7 +52,7 @@ public Builder(String environmentId, String collectionId, String queryId) { /** * Builds a GetTrainingDataOptions. * - * @return the getTrainingDataOptions + * @return the new GetTrainingDataOptions instance */ public GetTrainingDataOptions build() { return new GetTrainingDataOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetTrainingExampleOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetTrainingExampleOptions.java index b2c76ed29ef..b7c6a9c8962 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetTrainingExampleOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetTrainingExampleOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -57,7 +57,7 @@ public Builder(String environmentId, String collectionId, String queryId, String /** * Builds a GetTrainingExampleOptions. * - * @return the getTrainingExampleOptions + * @return the new GetTrainingExampleOptions instance */ public GetTrainingExampleOptions build() { return new GetTrainingExampleOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Histogram.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Histogram.java index 7a941b868a0..ed7ef470337 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Histogram.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Histogram.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/HtmlSettings.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/HtmlSettings.java index 4adb904dab7..11b08229198 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/HtmlSettings.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/HtmlSettings.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -62,7 +62,7 @@ public Builder() {} /** * Builds a HtmlSettings. * - * @return the htmlSettings + * @return the new HtmlSettings instance */ public HtmlSettings build() { return new HtmlSettings(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/IndexCapacity.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/IndexCapacity.java index b961b7d25e0..baa11a504d4 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/IndexCapacity.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/IndexCapacity.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListCollectionFieldsOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListCollectionFieldsOptions.java index 41257c2110a..5808c645536 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListCollectionFieldsOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListCollectionFieldsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -47,7 +47,7 @@ public Builder(String environmentId, String collectionId) { /** * Builds a ListCollectionFieldsOptions. * - * @return the listCollectionFieldsOptions + * @return the new ListCollectionFieldsOptions instance */ public ListCollectionFieldsOptions build() { return new ListCollectionFieldsOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListCollectionFieldsResponse.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListCollectionFieldsResponse.java index ce9543747d6..7e66ef9e308 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListCollectionFieldsResponse.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListCollectionFieldsResponse.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListCollectionsOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListCollectionsOptions.java index d56ecdaa393..722be246672 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListCollectionsOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListCollectionsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -45,7 +45,7 @@ public Builder(String environmentId) { /** * Builds a ListCollectionsOptions. * - * @return the listCollectionsOptions + * @return the new ListCollectionsOptions instance */ public ListCollectionsOptions build() { return new ListCollectionsOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListCollectionsResponse.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListCollectionsResponse.java index 23c9531642a..f5c72c6e281 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListCollectionsResponse.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListCollectionsResponse.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListConfigurationsOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListConfigurationsOptions.java index 453876dce6b..3e120753801 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListConfigurationsOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListConfigurationsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -45,7 +45,7 @@ public Builder(String environmentId) { /** * Builds a ListConfigurationsOptions. * - * @return the listConfigurationsOptions + * @return the new ListConfigurationsOptions instance */ public ListConfigurationsOptions build() { return new ListConfigurationsOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListConfigurationsResponse.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListConfigurationsResponse.java index 87c1f47d841..93b434e1b99 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListConfigurationsResponse.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListConfigurationsResponse.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListCredentialsOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListCredentialsOptions.java index 2605ce2985f..a1d342e75a2 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListCredentialsOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListCredentialsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -42,7 +42,7 @@ public Builder(String environmentId) { /** * Builds a ListCredentialsOptions. * - * @return the listCredentialsOptions + * @return the new ListCredentialsOptions instance */ public ListCredentialsOptions build() { return new ListCredentialsOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListEnvironmentsOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListEnvironmentsOptions.java index e135aa4eab0..0d1190d83aa 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListEnvironmentsOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListEnvironmentsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -33,7 +33,7 @@ public Builder() {} /** * Builds a ListEnvironmentsOptions. * - * @return the listEnvironmentsOptions + * @return the new ListEnvironmentsOptions instance */ public ListEnvironmentsOptions build() { return new ListEnvironmentsOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListEnvironmentsResponse.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListEnvironmentsResponse.java index 32a4b1791c1..c3cc750b703 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListEnvironmentsResponse.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListEnvironmentsResponse.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListExpansionsOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListExpansionsOptions.java index 41f84d7977b..66c3f780a3c 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListExpansionsOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListExpansionsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -47,7 +47,7 @@ public Builder(String environmentId, String collectionId) { /** * Builds a ListExpansionsOptions. * - * @return the listExpansionsOptions + * @return the new ListExpansionsOptions instance */ public ListExpansionsOptions build() { return new ListExpansionsOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListFieldsOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListFieldsOptions.java index 807ab274973..cec5a7b65cb 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListFieldsOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListFieldsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -49,7 +49,7 @@ public Builder(String environmentId, List collectionIds) { /** * Builds a ListFieldsOptions. * - * @return the listFieldsOptions + * @return the new ListFieldsOptions instance */ public ListFieldsOptions build() { return new ListFieldsOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListGatewaysOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListGatewaysOptions.java index 73462441069..ce5693ccac5 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListGatewaysOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListGatewaysOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -42,7 +42,7 @@ public Builder(String environmentId) { /** * Builds a ListGatewaysOptions. * - * @return the listGatewaysOptions + * @return the new ListGatewaysOptions instance */ public ListGatewaysOptions build() { return new ListGatewaysOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListTrainingDataOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListTrainingDataOptions.java index d0d158cf04f..9cc3a55b1d9 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListTrainingDataOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListTrainingDataOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -47,7 +47,7 @@ public Builder(String environmentId, String collectionId) { /** * Builds a ListTrainingDataOptions. * - * @return the listTrainingDataOptions + * @return the new ListTrainingDataOptions instance */ public ListTrainingDataOptions build() { return new ListTrainingDataOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListTrainingExamplesOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListTrainingExamplesOptions.java index 95c0bec734d..f2004b28016 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListTrainingExamplesOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/ListTrainingExamplesOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -52,7 +52,7 @@ public Builder(String environmentId, String collectionId, String queryId) { /** * Builds a ListTrainingExamplesOptions. * - * @return the listTrainingExamplesOptions + * @return the new ListTrainingExamplesOptions instance */ public ListTrainingExamplesOptions build() { return new ListTrainingExamplesOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/LogQueryResponse.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/LogQueryResponse.java index 5430b345f2a..55bad014279 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/LogQueryResponse.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/LogQueryResponse.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/LogQueryResponseResult.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/LogQueryResponseResult.java index 88252435093..6dc27a061d9 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/LogQueryResponseResult.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/LogQueryResponseResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/LogQueryResponseResultDocuments.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/LogQueryResponseResultDocuments.java index c5290023164..efe117c0c33 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/LogQueryResponseResultDocuments.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/LogQueryResponseResultDocuments.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/LogQueryResponseResultDocumentsResult.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/LogQueryResponseResultDocumentsResult.java index fa6f97b1326..2c2edb489ba 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/LogQueryResponseResultDocumentsResult.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/LogQueryResponseResultDocumentsResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/MetricAggregation.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/MetricAggregation.java index 8585ba09844..f7ddabfbc48 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/MetricAggregation.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/MetricAggregation.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/MetricAggregationResult.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/MetricAggregationResult.java index 425f81bc86b..d088342af72 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/MetricAggregationResult.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/MetricAggregationResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/MetricResponse.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/MetricResponse.java index 225af597e60..77e828c8391 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/MetricResponse.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/MetricResponse.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/MetricTokenAggregation.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/MetricTokenAggregation.java index 2ff8a54728b..d7b6c4710fc 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/MetricTokenAggregation.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/MetricTokenAggregation.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/MetricTokenAggregationResult.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/MetricTokenAggregationResult.java index 829fc0c7184..cd5d59075cd 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/MetricTokenAggregationResult.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/MetricTokenAggregationResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/MetricTokenResponse.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/MetricTokenResponse.java index 158719c9096..133d15cb399 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/MetricTokenResponse.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/MetricTokenResponse.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Nested.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Nested.java index a9d824b4d53..005b905556c 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Nested.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Nested.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentConcepts.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentConcepts.java index b50b79612ec..931ef962ab6 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentConcepts.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentConcepts.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -33,7 +33,7 @@ public Builder() {} /** * Builds a NluEnrichmentConcepts. * - * @return the nluEnrichmentConcepts + * @return the new NluEnrichmentConcepts instance */ public NluEnrichmentConcepts build() { return new NluEnrichmentConcepts(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentEmotion.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentEmotion.java index a4ec3ba4cba..2e6a4fed4f7 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentEmotion.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentEmotion.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -38,7 +38,7 @@ public Builder() {} /** * Builds a NluEnrichmentEmotion. * - * @return the nluEnrichmentEmotion + * @return the new NluEnrichmentEmotion instance */ public NluEnrichmentEmotion build() { return new NluEnrichmentEmotion(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentEntities.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentEntities.java index 63c50fa3479..688ed53edf5 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentEntities.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentEntities.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -57,7 +57,7 @@ public Builder() {} /** * Builds a NluEnrichmentEntities. * - * @return the nluEnrichmentEntities + * @return the new NluEnrichmentEntities instance */ public NluEnrichmentEntities build() { return new NluEnrichmentEntities(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentFeatures.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentFeatures.java index a1d0d44aae0..1135d9c193d 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentFeatures.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentFeatures.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -14,6 +14,7 @@ import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.Map; /** Object containing Natural Language Understanding features to be used. */ public class NluEnrichmentFeatures extends GenericModel { @@ -22,7 +23,7 @@ public class NluEnrichmentFeatures extends GenericModel { protected NluEnrichmentEntities entities; protected NluEnrichmentSentiment sentiment; protected NluEnrichmentEmotion emotion; - protected NluEnrichmentCategories categories; + protected Map categories; @SerializedName("semantic_roles") protected NluEnrichmentSemanticRoles semanticRoles; @@ -36,7 +37,7 @@ public static class Builder { private NluEnrichmentEntities entities; private NluEnrichmentSentiment sentiment; private NluEnrichmentEmotion emotion; - private NluEnrichmentCategories categories; + private Map categories; private NluEnrichmentSemanticRoles semanticRoles; private NluEnrichmentRelations relations; private NluEnrichmentConcepts concepts; @@ -58,7 +59,7 @@ public Builder() {} /** * Builds a NluEnrichmentFeatures. * - * @return the nluEnrichmentFeatures + * @return the new NluEnrichmentFeatures instance */ public NluEnrichmentFeatures build() { return new NluEnrichmentFeatures(this); @@ -114,7 +115,7 @@ public Builder emotion(NluEnrichmentEmotion emotion) { * @param categories the categories * @return the NluEnrichmentFeatures builder */ - public Builder categories(NluEnrichmentCategories categories) { + public Builder categories(Map categories) { this.categories = categories; return this; } @@ -224,7 +225,7 @@ public NluEnrichmentEmotion emotion() { * * @return the categories */ - public NluEnrichmentCategories categories() { + public Map categories() { return categories; } diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentKeywords.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentKeywords.java index c4934a053f4..e7fe53e476c 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentKeywords.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentKeywords.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -39,7 +39,7 @@ public Builder() {} /** * Builds a NluEnrichmentKeywords. * - * @return the nluEnrichmentKeywords + * @return the new NluEnrichmentKeywords instance */ public NluEnrichmentKeywords build() { return new NluEnrichmentKeywords(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentRelations.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentRelations.java index 7a1a3783c05..a36fc5ee6d9 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentRelations.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentRelations.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -33,7 +33,7 @@ public Builder() {} /** * Builds a NluEnrichmentRelations. * - * @return the nluEnrichmentRelations + * @return the new NluEnrichmentRelations instance */ public NluEnrichmentRelations build() { return new NluEnrichmentRelations(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentSemanticRoles.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentSemanticRoles.java index 9bf7a46115c..87dabfc930e 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentSemanticRoles.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentSemanticRoles.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -39,7 +39,7 @@ public Builder() {} /** * Builds a NluEnrichmentSemanticRoles. * - * @return the nluEnrichmentSemanticRoles + * @return the new NluEnrichmentSemanticRoles instance */ public NluEnrichmentSemanticRoles build() { return new NluEnrichmentSemanticRoles(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentSentiment.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentSentiment.java index d471913b506..13647cc7c16 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentSentiment.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentSentiment.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -38,7 +38,7 @@ public Builder() {} /** * Builds a NluEnrichmentSentiment. * - * @return the nluEnrichmentSentiment + * @return the new NluEnrichmentSentiment instance */ public NluEnrichmentSentiment build() { return new NluEnrichmentSentiment(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NormalizationOperation.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NormalizationOperation.java index 3bdcfe16592..f92ad9a7282 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NormalizationOperation.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NormalizationOperation.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -86,7 +86,7 @@ public Builder() {} /** * Builds a NormalizationOperation. * - * @return the normalizationOperation + * @return the new NormalizationOperation instance */ public NormalizationOperation build() { return new NormalizationOperation(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Notice.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Notice.java index b1ceaad16d3..e51939be66e 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Notice.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Notice.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/PdfHeadingDetection.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/PdfHeadingDetection.java index 2f18d08b094..54e4559cc43 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/PdfHeadingDetection.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/PdfHeadingDetection.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -35,7 +35,7 @@ public Builder() {} /** * Builds a PdfHeadingDetection. * - * @return the pdfHeadingDetection + * @return the new PdfHeadingDetection instance */ public PdfHeadingDetection build() { return new PdfHeadingDetection(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/PdfSettings.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/PdfSettings.java index 25233dc69e5..2e149637d62 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/PdfSettings.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/PdfSettings.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -33,7 +33,7 @@ public Builder() {} /** * Builds a PdfSettings. * - * @return the pdfSettings + * @return the new PdfSettings instance */ public PdfSettings build() { return new PdfSettings(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryAggregation.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryAggregation.java index 748c8cae0c0..bdd5023e04a 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryAggregation.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryAggregation.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryLogOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryLogOptions.java index 29486ab052f..c66ae8ce726 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryLogOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryLogOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -47,7 +47,7 @@ public Builder() {} /** * Builds a QueryLogOptions. * - * @return the queryLogOptions + * @return the new QueryLogOptions instance */ public QueryLogOptions build() { return new QueryLogOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryNoticesOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryNoticesOptions.java index 8b9452005be..5247d55d77a 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryNoticesOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryNoticesOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -100,7 +100,7 @@ public Builder(String environmentId, String collectionId) { /** * Builds a QueryNoticesOptions. * - * @return the queryNoticesOptions + * @return the new QueryNoticesOptions instance */ public QueryNoticesOptions build() { return new QueryNoticesOptions(this); @@ -563,7 +563,7 @@ public List sort() { * Gets the highlight. * *

When true, a highlight field is returned for each result which contains the fields which - * match the query with `` tags around the matching query terms. + * match the query with `<em></em>` tags around the matching query terms. * * @return the highlight */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryNoticesResponse.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryNoticesResponse.java index e506c148550..d1388caadd6 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryNoticesResponse.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryNoticesResponse.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryNoticesResult.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryNoticesResult.java index 9dfb9603eae..72f00abc742 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryNoticesResult.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryNoticesResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryOptions.java index 28a09f7d1b6..2ba01676ddc 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -110,7 +110,7 @@ public Builder(String environmentId, String collectionId) { /** * Builds a QueryOptions. * - * @return the queryOptions + * @return the new QueryOptions instance */ public QueryOptions build() { return new QueryOptions(this); @@ -544,7 +544,7 @@ public String sort() { * Gets the highlight. * *

When true, a highlight field is returned for each result which contains the fields which - * match the query with `` tags around the matching query terms. + * match the query with `<em></em>` tags around the matching query terms. * * @return the highlight */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryPassages.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryPassages.java index 4792174722e..5d14fd994fc 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryPassages.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryPassages.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryResponse.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryResponse.java index 989b7040955..68725db2663 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryResponse.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryResponse.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryResult.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryResult.java index eebea29e8e1..e9724ffbeef 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryResult.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryResultMetadata.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryResultMetadata.java index d9cb0de64a3..c502e7336db 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryResultMetadata.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/QueryResultMetadata.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/RetrievalDetails.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/RetrievalDetails.java index ca8a718a128..7d77d54b108 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/RetrievalDetails.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/RetrievalDetails.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SduStatus.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SduStatus.java index db595e0bba6..a43b2c3ddaa 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SduStatus.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SduStatus.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SduStatusCustomFields.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SduStatusCustomFields.java index 5f592193566..a4b038ad58c 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SduStatusCustomFields.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SduStatusCustomFields.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SearchStatus.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SearchStatus.java index 2cb9c929d72..f4bb0ddd978 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SearchStatus.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SearchStatus.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SegmentSettings.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SegmentSettings.java index 8cb8d506121..70c0c76310c 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SegmentSettings.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SegmentSettings.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -46,7 +46,7 @@ public Builder() {} /** * Builds a SegmentSettings. * - * @return the segmentSettings + * @return the new SegmentSettings instance */ public SegmentSettings build() { return new SegmentSettings(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Source.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Source.java index 29bd0e1c634..26cb906e379 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Source.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Source.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -66,7 +66,7 @@ public Builder() {} /** * Builds a Source. * - * @return the source + * @return the new Source instance */ public Source build() { return new Source(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SourceOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SourceOptions.java index dad0bb7336d..ca715dc0c4e 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SourceOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SourceOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -56,7 +56,7 @@ public Builder() {} /** * Builds a SourceOptions. * - * @return the sourceOptions + * @return the new SourceOptions instance */ public SourceOptions build() { return new SourceOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SourceOptionsBuckets.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SourceOptionsBuckets.java index 906dbdb9905..b9306c93e80 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SourceOptionsBuckets.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SourceOptionsBuckets.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -45,7 +45,7 @@ public Builder(String name) { /** * Builds a SourceOptionsBuckets. * - * @return the sourceOptionsBuckets + * @return the new SourceOptionsBuckets instance */ public SourceOptionsBuckets build() { return new SourceOptionsBuckets(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SourceOptionsFolder.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SourceOptionsFolder.java index 0b02f6c7790..50015e32eab 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SourceOptionsFolder.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SourceOptionsFolder.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -55,7 +55,7 @@ public Builder(String ownerUserId, String folderId) { /** * Builds a SourceOptionsFolder. * - * @return the sourceOptionsFolder + * @return the new SourceOptionsFolder instance */ public SourceOptionsFolder build() { return new SourceOptionsFolder(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SourceOptionsObject.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SourceOptionsObject.java index 10e6a29c0f4..4ae8a5bc7a6 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SourceOptionsObject.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SourceOptionsObject.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -45,7 +45,7 @@ public Builder(String name) { /** * Builds a SourceOptionsObject. * - * @return the sourceOptionsObject + * @return the new SourceOptionsObject instance */ public SourceOptionsObject build() { return new SourceOptionsObject(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SourceOptionsSiteColl.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SourceOptionsSiteColl.java index e76657578ac..e56915149d6 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SourceOptionsSiteColl.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SourceOptionsSiteColl.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -48,7 +48,7 @@ public Builder(String siteCollectionPath) { /** * Builds a SourceOptionsSiteColl. * - * @return the sourceOptionsSiteColl + * @return the new SourceOptionsSiteColl instance */ public SourceOptionsSiteColl build() { return new SourceOptionsSiteColl(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SourceOptionsWebCrawl.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SourceOptionsWebCrawl.java index 76d58c4cddb..5b4e1b7c918 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SourceOptionsWebCrawl.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SourceOptionsWebCrawl.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -94,7 +94,7 @@ public Builder(String url) { /** * Builds a SourceOptionsWebCrawl. * - * @return the sourceOptionsWebCrawl + * @return the new SourceOptionsWebCrawl instance */ public SourceOptionsWebCrawl build() { return new SourceOptionsWebCrawl(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SourceSchedule.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SourceSchedule.java index 2485bf16a30..015bd5bc1d2 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SourceSchedule.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SourceSchedule.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -63,7 +63,7 @@ public Builder() {} /** * Builds a SourceSchedule. * - * @return the sourceSchedule + * @return the new SourceSchedule instance */ public SourceSchedule build() { return new SourceSchedule(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SourceStatus.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SourceStatus.java index 4f3a66d1803..789059c0df9 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SourceStatus.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/SourceStatus.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Term.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Term.java index 97b7116cca8..a2d85ef4ae6 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Term.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Term.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Timeslice.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Timeslice.java index eeddad45a22..01625292d22 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Timeslice.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/Timeslice.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TokenDictRule.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TokenDictRule.java index 90675b43d44..d0603b4920b 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TokenDictRule.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TokenDictRule.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -60,7 +60,7 @@ public Builder(String text, List tokens, String partOfSpeech) { /** * Builds a TokenDictRule. * - * @return the tokenDictRule + * @return the new TokenDictRule instance */ public TokenDictRule build() { return new TokenDictRule(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TokenDictStatusResponse.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TokenDictStatusResponse.java index d91e4792278..a6ba2544be3 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TokenDictStatusResponse.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TokenDictStatusResponse.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TopHits.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TopHits.java index 4436c90904c..e3eab84432b 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TopHits.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TopHits.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TopHitsResults.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TopHitsResults.java index 4f3147d3cfa..16b27f57bba 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TopHitsResults.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TopHitsResults.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TrainingDataSet.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TrainingDataSet.java index a5c72f06e66..4df2ed70689 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TrainingDataSet.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TrainingDataSet.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TrainingExample.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TrainingExample.java index cc704280589..b8ecaa19f8a 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TrainingExample.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TrainingExample.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -44,7 +44,7 @@ public Builder() {} /** * Builds a TrainingExample. * - * @return the trainingExample + * @return the new TrainingExample instance */ public TrainingExample build() { return new TrainingExample(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TrainingExampleList.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TrainingExampleList.java index fe6ffef2a81..529fab93096 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TrainingExampleList.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TrainingExampleList.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TrainingQuery.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TrainingQuery.java index cd5791da9ae..d532b21b0b4 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TrainingQuery.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TrainingQuery.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TrainingStatus.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TrainingStatus.java index e308c85b6d2..0630e3b39cc 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TrainingStatus.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/TrainingStatus.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/UpdateCollectionOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/UpdateCollectionOptions.java index 6253c681413..35b1751e979 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/UpdateCollectionOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/UpdateCollectionOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -58,7 +58,7 @@ public Builder(String environmentId, String collectionId, String name) { /** * Builds a UpdateCollectionOptions. * - * @return the updateCollectionOptions + * @return the new UpdateCollectionOptions instance */ public UpdateCollectionOptions build() { return new UpdateCollectionOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/UpdateConfigurationOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/UpdateConfigurationOptions.java index 722479d77f1..7dab4952882 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/UpdateConfigurationOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/UpdateConfigurationOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -69,7 +69,7 @@ public Builder(String environmentId, String configurationId, String name) { /** * Builds a UpdateConfigurationOptions. * - * @return the updateConfigurationOptions + * @return the new UpdateConfigurationOptions instance */ public UpdateConfigurationOptions build() { return new UpdateConfigurationOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/UpdateCredentialsOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/UpdateCredentialsOptions.java index bc38f14e346..f1132deba72 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/UpdateCredentialsOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/UpdateCredentialsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -90,7 +90,7 @@ public Builder(String environmentId, String credentialId) { /** * Builds a UpdateCredentialsOptions. * - * @return the updateCredentialsOptions + * @return the new UpdateCredentialsOptions instance */ public UpdateCredentialsOptions build() { return new UpdateCredentialsOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/UpdateDocumentOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/UpdateDocumentOptions.java index 4f0aab00a9e..636f2184d97 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/UpdateDocumentOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/UpdateDocumentOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -68,7 +68,7 @@ public Builder(String environmentId, String collectionId, String documentId) { /** * Builds a UpdateDocumentOptions. * - * @return the updateDocumentOptions + * @return the new UpdateDocumentOptions instance */ public UpdateDocumentOptions build() { return new UpdateDocumentOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/UpdateEnvironmentOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/UpdateEnvironmentOptions.java index 7d8f88fcabb..b1034248222 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/UpdateEnvironmentOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/UpdateEnvironmentOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -74,7 +74,7 @@ public Builder(String environmentId) { /** * Builds a UpdateEnvironmentOptions. * - * @return the updateEnvironmentOptions + * @return the new UpdateEnvironmentOptions instance */ public UpdateEnvironmentOptions build() { return new UpdateEnvironmentOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/UpdateTrainingExampleOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/UpdateTrainingExampleOptions.java index 884efc3f8c4..518b58ae292 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/UpdateTrainingExampleOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/UpdateTrainingExampleOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -63,7 +63,7 @@ public Builder(String environmentId, String collectionId, String queryId, String /** * Builds a UpdateTrainingExampleOptions. * - * @return the updateTrainingExampleOptions + * @return the new UpdateTrainingExampleOptions instance */ public UpdateTrainingExampleOptions build() { return new UpdateTrainingExampleOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/WordHeadingDetection.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/WordHeadingDetection.java index 04b05047c26..566b55be1f5 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/WordHeadingDetection.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/WordHeadingDetection.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -38,7 +38,7 @@ public Builder() {} /** * Builds a WordHeadingDetection. * - * @return the wordHeadingDetection + * @return the new WordHeadingDetection instance */ public WordHeadingDetection build() { return new WordHeadingDetection(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/WordSettings.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/WordSettings.java index 6a74e18b169..48c671c8a91 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/WordSettings.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/WordSettings.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -33,7 +33,7 @@ public Builder() {} /** * Builds a WordSettings. * - * @return the wordSettings + * @return the new WordSettings instance */ public WordSettings build() { return new WordSettings(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/WordStyle.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/WordStyle.java index a6887106f45..9de6ca531a1 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/WordStyle.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/WordStyle.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -38,7 +38,7 @@ public Builder() {} /** * Builds a WordStyle. * - * @return the wordStyle + * @return the new WordStyle instance */ public WordStyle build() { return new WordStyle(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/XPathPatterns.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/XPathPatterns.java index 93faf864893..8c08fcdce84 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/XPathPatterns.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/model/XPathPatterns.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -35,7 +35,7 @@ public Builder() {} /** * Builds a XPathPatterns. * - * @return the xPathPatterns + * @return the new XPathPatterns instance */ public XPathPatterns build() { return new XPathPatterns(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/package-info.java b/discovery/src/main/java/com/ibm/watson/discovery/v1/package-info.java index 7918da3fedc..b50dd3a84e5 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/package-info.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v1/package-info.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/Discovery.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/Discovery.java index ef5d5b8fd5d..70b422bf15c 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/Discovery.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/Discovery.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -10,6 +10,11 @@ * 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. */ + +/* + * IBM OpenAPI SDK Code Generator Version: 99-SNAPSHOT-7cc05500-20201106-154555 + */ + package com.ibm.watson.discovery.v2; import com.google.gson.JsonObject; @@ -23,6 +28,8 @@ import com.ibm.cloud.sdk.core.util.ResponseConverterUtils; import com.ibm.watson.common.SdkCommon; import com.ibm.watson.discovery.v2.model.AddDocumentOptions; +import com.ibm.watson.discovery.v2.model.AnalyzeDocumentOptions; +import com.ibm.watson.discovery.v2.model.AnalyzedDocument; import com.ibm.watson.discovery.v2.model.CollectionDetails; import com.ibm.watson.discovery.v2.model.Completions; import com.ibm.watson.discovery.v2.model.ComponentSettingsResponse; @@ -66,81 +73,105 @@ import com.ibm.watson.discovery.v2.model.UpdateEnrichmentOptions; import com.ibm.watson.discovery.v2.model.UpdateProjectOptions; import com.ibm.watson.discovery.v2.model.UpdateTrainingQueryOptions; +import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; import okhttp3.MultipartBody; /** - * IBM Watson™ Discovery is a cognitive search and content analytics engine that you can add - * to applications to identify patterns, trends and actionable insights to drive better + * IBM Watson&trade; Discovery is a cognitive search and content analytics engine that you can + * add to applications to identify patterns, trends and actionable insights to drive better * decision-making. Securely unify structured and unstructured data with pre-enriched content, and * use a simplified query language to eliminate the need for manual filtering of results. * * @version v2 - * @see Discovery + * @see Discovery */ public class Discovery extends BaseService { - private static final String DEFAULT_SERVICE_NAME = "discovery"; + public static final String DEFAULT_SERVICE_NAME = "discovery"; - private static final String DEFAULT_SERVICE_URL = + public static final String DEFAULT_SERVICE_URL = "https://api.us-south.discovery.watson.cloud.ibm.com"; - private String versionDate; + private String version; /** - * Constructs a new `Discovery` client using the DEFAULT_SERVICE_NAME. + * Constructs an instance of the `Discovery` client. The default service name is used to configure + * the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value - * will keep your API calls from failing when the service introduces breaking changes. + * @param version Release date of the version of the API you want to use. Specify dates in + * YYYY-MM-DD format. The current version is `2019-11-22`. */ - public Discovery(String versionDate) { + public Discovery(String version) { this( - versionDate, + version, DEFAULT_SERVICE_NAME, ConfigBasedAuthenticatorFactory.getAuthenticator(DEFAULT_SERVICE_NAME)); } /** - * Constructs a new `Discovery` client with the DEFAULT_SERVICE_NAME and the specified - * Authenticator. + * Constructs an instance of the `Discovery` client. The default service name and specified + * authenticator are used to configure the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value - * will keep your API calls from failing when the service introduces breaking changes. - * @param authenticator the Authenticator instance to be configured for this service + * @param version Release date of the version of the API you want to use. Specify dates in + * YYYY-MM-DD format. The current version is `2019-11-22`. + * @param authenticator the {@link Authenticator} instance to be configured for this client */ - public Discovery(String versionDate, Authenticator authenticator) { - this(versionDate, DEFAULT_SERVICE_NAME, authenticator); + public Discovery(String version, Authenticator authenticator) { + this(version, DEFAULT_SERVICE_NAME, authenticator); } /** - * Constructs a new `Discovery` client with the specified serviceName. + * Constructs an instance of the `Discovery` client. The specified service name is used to + * configure the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value - * will keep your API calls from failing when the service introduces breaking changes. - * @param serviceName The name of the service to configure. + * @param version Release date of the version of the API you want to use. Specify dates in + * YYYY-MM-DD format. The current version is `2019-11-22`. + * @param serviceName the service name to be used when configuring the client instance */ - public Discovery(String versionDate, String serviceName) { - this(versionDate, serviceName, ConfigBasedAuthenticatorFactory.getAuthenticator(serviceName)); + public Discovery(String version, String serviceName) { + this(version, serviceName, ConfigBasedAuthenticatorFactory.getAuthenticator(serviceName)); } /** - * Constructs a new `Discovery` client with the specified Authenticator and serviceName. + * Constructs an instance of the `Discovery` client. The specified service name and authenticator + * are used to configure the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value - * will keep your API calls from failing when the service introduces breaking changes. - * @param serviceName The name of the service to configure. - * @param authenticator the Authenticator instance to be configured for this service + * @param version Release date of the version of the API you want to use. Specify dates in + * YYYY-MM-DD format. The current version is `2019-11-22`. + * @param serviceName the service name to be used when configuring the client instance + * @param authenticator the {@link Authenticator} instance to be configured for this client */ - public Discovery(String versionDate, String serviceName, Authenticator authenticator) { + public Discovery(String version, String serviceName, Authenticator authenticator) { super(serviceName, authenticator); setServiceUrl(DEFAULT_SERVICE_URL); - com.ibm.cloud.sdk.core.util.Validator.isTrue( - (versionDate != null) && !versionDate.isEmpty(), "version cannot be null."); - this.versionDate = versionDate; + setVersion(version); this.configureService(serviceName); } + /** + * Gets the version. + * + *

Release date of the version of the API you want to use. Specify dates in YYYY-MM-DD format. + * The current version is `2019-11-22`. + * + * @return the version + */ + public String getVersion() { + return this.version; + } + + /** + * Sets the version. + * + * @param version the new version + */ + public void setVersion(final String version) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(version, "version cannot be empty."); + this.version = version; + } + /** * List collections. * @@ -148,24 +179,24 @@ public Discovery(String versionDate, String serviceName, Authenticator authentic * * @param listCollectionsOptions the {@link ListCollectionsOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of {@link ListCollectionsResponse} + * @return a {@link ServiceCall} with a result of type {@link ListCollectionsResponse} */ public ServiceCall listCollections( ListCollectionsOptions listCollectionsOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( listCollectionsOptions, "listCollectionsOptions cannot be null"); - String[] pathSegments = {"v2/projects", "collections"}; - String[] pathParameters = {listCollectionsOptions.projectId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", listCollectionsOptions.projectId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v2/projects/{project_id}/collections", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "listCollections"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken() {}.getType()); @@ -179,23 +210,24 @@ public ServiceCall listCollections( * * @param createCollectionOptions the {@link CreateCollectionOptions} containing the options for * the call - * @return a {@link ServiceCall} with a response type of {@link CollectionDetails} + * @return a {@link ServiceCall} with a result of type {@link CollectionDetails} */ public ServiceCall createCollection( CreateCollectionOptions createCollectionOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( createCollectionOptions, "createCollectionOptions cannot be null"); - String[] pathSegments = {"v2/projects", "collections"}; - String[] pathParameters = {createCollectionOptions.projectId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", createCollectionOptions.projectId()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v2/projects/{project_id}/collections", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "createCollection"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); final JsonObject contentJson = new JsonObject(); contentJson.addProperty("name", createCollectionOptions.name()); if (createCollectionOptions.description() != null) { @@ -224,25 +256,26 @@ public ServiceCall createCollection( * * @param getCollectionOptions the {@link GetCollectionOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of {@link CollectionDetails} + * @return a {@link ServiceCall} with a result of type {@link CollectionDetails} */ public ServiceCall getCollection(GetCollectionOptions getCollectionOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( getCollectionOptions, "getCollectionOptions cannot be null"); - String[] pathSegments = {"v2/projects", "collections"}; - String[] pathParameters = { - getCollectionOptions.projectId(), getCollectionOptions.collectionId() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", getCollectionOptions.projectId()); + pathParamsMap.put("collection_id", getCollectionOptions.collectionId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/projects/{project_id}/collections/{collection_id}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "getCollection"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken() {}.getType()); @@ -256,25 +289,27 @@ public ServiceCall getCollection(GetCollectionOptions getColl * * @param updateCollectionOptions the {@link UpdateCollectionOptions} containing the options for * the call - * @return a {@link ServiceCall} with a response type of {@link CollectionDetails} + * @return a {@link ServiceCall} with a result of type {@link CollectionDetails} */ public ServiceCall updateCollection( UpdateCollectionOptions updateCollectionOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( updateCollectionOptions, "updateCollectionOptions cannot be null"); - String[] pathSegments = {"v2/projects", "collections"}; - String[] pathParameters = { - updateCollectionOptions.projectId(), updateCollectionOptions.collectionId() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", updateCollectionOptions.projectId()); + pathParamsMap.put("collection_id", updateCollectionOptions.collectionId()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/projects/{project_id}/collections/{collection_id}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "updateCollection"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); final JsonObject contentJson = new JsonObject(); if (updateCollectionOptions.name() != null) { contentJson.addProperty("name", updateCollectionOptions.name()); @@ -303,24 +338,25 @@ public ServiceCall updateCollection( * * @param deleteCollectionOptions the {@link DeleteCollectionOptions} containing the options for * the call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteCollection(DeleteCollectionOptions deleteCollectionOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( deleteCollectionOptions, "deleteCollectionOptions cannot be null"); - String[] pathSegments = {"v2/projects", "collections"}; - String[] pathParameters = { - deleteCollectionOptions.projectId(), deleteCollectionOptions.collectionId() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", deleteCollectionOptions.projectId()); + pathParamsMap.put("collection_id", deleteCollectionOptions.collectionId()); RequestBuilder builder = RequestBuilder.delete( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/projects/{project_id}/collections/{collection_id}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "deleteCollection"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -336,21 +372,22 @@ public ServiceCall deleteCollection(DeleteCollectionOptions deleteCollecti * documentation](#create-project) for details about how to set custom default query settings. * * @param queryOptions the {@link QueryOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link QueryResponse} + * @return a {@link ServiceCall} with a result of type {@link QueryResponse} */ public ServiceCall query(QueryOptions queryOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull(queryOptions, "queryOptions cannot be null"); - String[] pathSegments = {"v2/projects", "query"}; - String[] pathParameters = {queryOptions.projectId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", queryOptions.projectId()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v2/projects/{project_id}/query", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "query"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); final JsonObject contentJson = new JsonObject(); if (queryOptions.collectionIds() != null) { contentJson.add( @@ -421,31 +458,32 @@ public ServiceCall query(QueryOptions queryOptions) { * * @param getAutocompletionOptions the {@link GetAutocompletionOptions} containing the options for * the call - * @return a {@link ServiceCall} with a response type of {@link Completions} + * @return a {@link ServiceCall} with a result of type {@link Completions} */ public ServiceCall getAutocompletion( GetAutocompletionOptions getAutocompletionOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( getAutocompletionOptions, "getAutocompletionOptions cannot be null"); - String[] pathSegments = {"v2/projects", "autocompletion"}; - String[] pathParameters = {getAutocompletionOptions.projectId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", getAutocompletionOptions.projectId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v2/projects/{project_id}/autocompletion", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "getAutocompletion"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - builder.query("prefix", getAutocompletionOptions.prefix()); + builder.query("version", String.valueOf(this.version)); + builder.query("prefix", String.valueOf(getAutocompletionOptions.prefix())); if (getAutocompletionOptions.collectionIds() != null) { builder.query( "collection_ids", RequestUtils.join(getAutocompletionOptions.collectionIds(), ",")); } if (getAutocompletionOptions.field() != null) { - builder.query("field", getAutocompletionOptions.field()); + builder.query("field", String.valueOf(getAutocompletionOptions.field())); } if (getAutocompletionOptions.count() != null) { builder.query("count", String.valueOf(getAutocompletionOptions.count())); @@ -463,30 +501,32 @@ public ServiceCall getAutocompletion( * Notices are generated when ingesting documents and performing relevance training. * * @param queryNoticesOptions the {@link QueryNoticesOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link QueryNoticesResponse} + * @return a {@link ServiceCall} with a result of type {@link QueryNoticesResponse} */ public ServiceCall queryNotices(QueryNoticesOptions queryNoticesOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( queryNoticesOptions, "queryNoticesOptions cannot be null"); - String[] pathSegments = {"v2/projects", "notices"}; - String[] pathParameters = {queryNoticesOptions.projectId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", queryNoticesOptions.projectId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v2/projects/{project_id}/notices", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "queryNotices"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (queryNoticesOptions.filter() != null) { - builder.query("filter", queryNoticesOptions.filter()); + builder.query("filter", String.valueOf(queryNoticesOptions.filter())); } if (queryNoticesOptions.query() != null) { - builder.query("query", queryNoticesOptions.query()); + builder.query("query", String.valueOf(queryNoticesOptions.query())); } if (queryNoticesOptions.naturalLanguageQuery() != null) { - builder.query("natural_language_query", queryNoticesOptions.naturalLanguageQuery()); + builder.query( + "natural_language_query", String.valueOf(queryNoticesOptions.naturalLanguageQuery())); } if (queryNoticesOptions.count() != null) { builder.query("count", String.valueOf(queryNoticesOptions.count())); @@ -506,22 +546,23 @@ public ServiceCall queryNotices(QueryNoticesOptions queryN *

Gets a list of the unique fields (and their types) stored in the the specified collections. * * @param listFieldsOptions the {@link ListFieldsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link ListFieldsResponse} + * @return a {@link ServiceCall} with a result of type {@link ListFieldsResponse} */ public ServiceCall listFields(ListFieldsOptions listFieldsOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( listFieldsOptions, "listFieldsOptions cannot be null"); - String[] pathSegments = {"v2/projects", "fields"}; - String[] pathParameters = {listFieldsOptions.projectId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", listFieldsOptions.projectId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v2/projects/{project_id}/fields", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "listFields"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); if (listFieldsOptions.collectionIds() != null) { builder.query("collection_ids", RequestUtils.join(listFieldsOptions.collectionIds(), ",")); } @@ -538,25 +579,25 @@ public ServiceCall listFields(ListFieldsOptions listFieldsOp * * @param getComponentSettingsOptions the {@link GetComponentSettingsOptions} containing the * options for the call - * @return a {@link ServiceCall} with a response type of {@link ComponentSettingsResponse} + * @return a {@link ServiceCall} with a result of type {@link ComponentSettingsResponse} */ public ServiceCall getComponentSettings( GetComponentSettingsOptions getComponentSettingsOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( getComponentSettingsOptions, "getComponentSettingsOptions cannot be null"); - String[] pathSegments = {"v2/projects", "component_settings"}; - String[] pathParameters = {getComponentSettingsOptions.projectId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", getComponentSettingsOptions.projectId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v2/projects/{project_id}/component_settings", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "getComponentSettings"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken() {}.getType()); @@ -597,7 +638,7 @@ public ServiceCall getComponentSettings( * SharePoint. * * @param addDocumentOptions the {@link AddDocumentOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link DocumentAccepted} + * @return a {@link ServiceCall} with a result of type {@link DocumentAccepted} */ public ServiceCall addDocument(AddDocumentOptions addDocumentOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( @@ -605,12 +646,15 @@ public ServiceCall addDocument(AddDocumentOptions addDocumentO com.ibm.cloud.sdk.core.util.Validator.isTrue( (addDocumentOptions.file() != null) || (addDocumentOptions.metadata() != null), "At least one of file or metadata must be supplied."); - String[] pathSegments = {"v2/projects", "collections", "documents"}; - String[] pathParameters = {addDocumentOptions.projectId(), addDocumentOptions.collectionId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", addDocumentOptions.projectId()); + pathParamsMap.put("collection_id", addDocumentOptions.collectionId()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/projects/{project_id}/collections/{collection_id}/documents", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "addDocument"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); @@ -619,6 +663,7 @@ public ServiceCall addDocument(AddDocumentOptions addDocumentO if (addDocumentOptions.xWatsonDiscoveryForce() != null) { builder.header("X-Watson-Discovery-Force", addDocumentOptions.xWatsonDiscoveryForce()); } + builder.query("version", String.valueOf(this.version)); MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); multipartBuilder.setType(MultipartBody.FORM); if (addDocumentOptions.file() != null) { @@ -658,7 +703,7 @@ public ServiceCall addDocument(AddDocumentOptions addDocumentO * * @param updateDocumentOptions the {@link UpdateDocumentOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of {@link DocumentAccepted} + * @return a {@link ServiceCall} with a result of type {@link DocumentAccepted} */ public ServiceCall updateDocument(UpdateDocumentOptions updateDocumentOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( @@ -666,16 +711,16 @@ public ServiceCall updateDocument(UpdateDocumentOptions update com.ibm.cloud.sdk.core.util.Validator.isTrue( (updateDocumentOptions.file() != null) || (updateDocumentOptions.metadata() != null), "At least one of file or metadata must be supplied."); - String[] pathSegments = {"v2/projects", "collections", "documents"}; - String[] pathParameters = { - updateDocumentOptions.projectId(), - updateDocumentOptions.collectionId(), - updateDocumentOptions.documentId() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", updateDocumentOptions.projectId()); + pathParamsMap.put("collection_id", updateDocumentOptions.collectionId()); + pathParamsMap.put("document_id", updateDocumentOptions.documentId()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/projects/{project_id}/collections/{collection_id}/documents/{document_id}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "updateDocument"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); @@ -684,6 +729,7 @@ public ServiceCall updateDocument(UpdateDocumentOptions update if (updateDocumentOptions.xWatsonDiscoveryForce() != null) { builder.header("X-Watson-Discovery-Force", updateDocumentOptions.xWatsonDiscoveryForce()); } + builder.query("version", String.valueOf(this.version)); MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); multipartBuilder.setType(MultipartBody.FORM); if (updateDocumentOptions.file() != null) { @@ -717,22 +763,22 @@ public ServiceCall updateDocument(UpdateDocumentOptions update * * @param deleteDocumentOptions the {@link DeleteDocumentOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of {@link DeleteDocumentResponse} + * @return a {@link ServiceCall} with a result of type {@link DeleteDocumentResponse} */ public ServiceCall deleteDocument( DeleteDocumentOptions deleteDocumentOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( deleteDocumentOptions, "deleteDocumentOptions cannot be null"); - String[] pathSegments = {"v2/projects", "collections", "documents"}; - String[] pathParameters = { - deleteDocumentOptions.projectId(), - deleteDocumentOptions.collectionId(), - deleteDocumentOptions.documentId() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", deleteDocumentOptions.projectId()); + pathParamsMap.put("collection_id", deleteDocumentOptions.collectionId()); + pathParamsMap.put("document_id", deleteDocumentOptions.documentId()); RequestBuilder builder = RequestBuilder.delete( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/projects/{project_id}/collections/{collection_id}/documents/{document_id}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "deleteDocument"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); @@ -741,6 +787,7 @@ public ServiceCall deleteDocument( if (deleteDocumentOptions.xWatsonDiscoveryForce() != null) { builder.header("X-Watson-Discovery-Force", deleteDocumentOptions.xWatsonDiscoveryForce()); } + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken() {}.getType()); @@ -754,25 +801,25 @@ public ServiceCall deleteDocument( * * @param listTrainingQueriesOptions the {@link ListTrainingQueriesOptions} containing the options * for the call - * @return a {@link ServiceCall} with a response type of {@link TrainingQuerySet} + * @return a {@link ServiceCall} with a result of type {@link TrainingQuerySet} */ public ServiceCall listTrainingQueries( ListTrainingQueriesOptions listTrainingQueriesOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( listTrainingQueriesOptions, "listTrainingQueriesOptions cannot be null"); - String[] pathSegments = {"v2/projects", "training_data/queries"}; - String[] pathParameters = {listTrainingQueriesOptions.projectId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", listTrainingQueriesOptions.projectId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v2/projects/{project_id}/training_data/queries", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "listTrainingQueries"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken() {}.getType()); @@ -786,24 +833,24 @@ public ServiceCall listTrainingQueries( * * @param deleteTrainingQueriesOptions the {@link DeleteTrainingQueriesOptions} containing the * options for the call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteTrainingQueries( DeleteTrainingQueriesOptions deleteTrainingQueriesOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( deleteTrainingQueriesOptions, "deleteTrainingQueriesOptions cannot be null"); - String[] pathSegments = {"v2/projects", "training_data/queries"}; - String[] pathParameters = {deleteTrainingQueriesOptions.projectId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", deleteTrainingQueriesOptions.projectId()); RequestBuilder builder = RequestBuilder.delete( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v2/projects/{project_id}/training_data/queries", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "deleteTrainingQueries"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -816,24 +863,25 @@ public ServiceCall deleteTrainingQueries( * * @param createTrainingQueryOptions the {@link CreateTrainingQueryOptions} containing the options * for the call - * @return a {@link ServiceCall} with a response type of {@link TrainingQuery} + * @return a {@link ServiceCall} with a result of type {@link TrainingQuery} */ public ServiceCall createTrainingQuery( CreateTrainingQueryOptions createTrainingQueryOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( createTrainingQueryOptions, "createTrainingQueryOptions cannot be null"); - String[] pathSegments = {"v2/projects", "training_data/queries"}; - String[] pathParameters = {createTrainingQueryOptions.projectId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", createTrainingQueryOptions.projectId()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v2/projects/{project_id}/training_data/queries", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "createTrainingQuery"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); final JsonObject contentJson = new JsonObject(); contentJson.addProperty( "natural_language_query", createTrainingQueryOptions.naturalLanguageQuery()); @@ -858,26 +906,27 @@ public ServiceCall createTrainingQuery( * * @param getTrainingQueryOptions the {@link GetTrainingQueryOptions} containing the options for * the call - * @return a {@link ServiceCall} with a response type of {@link TrainingQuery} + * @return a {@link ServiceCall} with a result of type {@link TrainingQuery} */ public ServiceCall getTrainingQuery( GetTrainingQueryOptions getTrainingQueryOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( getTrainingQueryOptions, "getTrainingQueryOptions cannot be null"); - String[] pathSegments = {"v2/projects", "training_data/queries"}; - String[] pathParameters = { - getTrainingQueryOptions.projectId(), getTrainingQueryOptions.queryId() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", getTrainingQueryOptions.projectId()); + pathParamsMap.put("query_id", getTrainingQueryOptions.queryId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/projects/{project_id}/training_data/queries/{query_id}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "getTrainingQuery"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken() {}.getType()); @@ -891,26 +940,28 @@ public ServiceCall getTrainingQuery( * * @param updateTrainingQueryOptions the {@link UpdateTrainingQueryOptions} containing the options * for the call - * @return a {@link ServiceCall} with a response type of {@link TrainingQuery} + * @return a {@link ServiceCall} with a result of type {@link TrainingQuery} */ public ServiceCall updateTrainingQuery( UpdateTrainingQueryOptions updateTrainingQueryOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( updateTrainingQueryOptions, "updateTrainingQueryOptions cannot be null"); - String[] pathSegments = {"v2/projects", "training_data/queries"}; - String[] pathParameters = { - updateTrainingQueryOptions.projectId(), updateTrainingQueryOptions.queryId() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", updateTrainingQueryOptions.projectId()); + pathParamsMap.put("query_id", updateTrainingQueryOptions.queryId()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/projects/{project_id}/training_data/queries/{query_id}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "updateTrainingQuery"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); final JsonObject contentJson = new JsonObject(); contentJson.addProperty( "natural_language_query", updateTrainingQueryOptions.naturalLanguageQuery()); @@ -928,6 +979,59 @@ public ServiceCall updateTrainingQuery( return createServiceCall(builder.build(), responseConverter); } + /** + * Analyze a Document. + * + *

Process a document using the specified collection's settings and return it for realtime use. + * + *

**Note:** Documents processed using this method are not added to the specified collection. + * + *

**Note:** This method is only supported on IBM Cloud Pak for Data instances of Discovery. + * + * @param analyzeDocumentOptions the {@link AnalyzeDocumentOptions} containing the options for the + * call + * @return a {@link ServiceCall} with a result of type {@link AnalyzedDocument} + */ + public ServiceCall analyzeDocument( + AnalyzeDocumentOptions analyzeDocumentOptions) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + analyzeDocumentOptions, "analyzeDocumentOptions cannot be null"); + com.ibm.cloud.sdk.core.util.Validator.isTrue( + (analyzeDocumentOptions.file() != null) || (analyzeDocumentOptions.metadata() != null), + "At least one of file or metadata must be supplied."); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", analyzeDocumentOptions.projectId()); + pathParamsMap.put("collection_id", analyzeDocumentOptions.collectionId()); + RequestBuilder builder = + RequestBuilder.post( + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/projects/{project_id}/collections/{collection_id}/analyze", + pathParamsMap)); + Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "analyzeDocument"); + for (Entry header : sdkHeaders.entrySet()) { + builder.header(header.getKey(), header.getValue()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); + multipartBuilder.setType(MultipartBody.FORM); + if (analyzeDocumentOptions.file() != null) { + okhttp3.RequestBody fileBody = + RequestUtils.inputStreamBody( + analyzeDocumentOptions.file(), analyzeDocumentOptions.fileContentType()); + multipartBuilder.addFormDataPart("file", analyzeDocumentOptions.filename(), fileBody); + } + if (analyzeDocumentOptions.metadata() != null) { + multipartBuilder.addFormDataPart("metadata", analyzeDocumentOptions.metadata()); + } + builder.body(multipartBuilder.build()); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + /** * List Enrichments. * @@ -935,23 +1039,23 @@ public ServiceCall updateTrainingQuery( * * @param listEnrichmentsOptions the {@link ListEnrichmentsOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of {@link Enrichments} + * @return a {@link ServiceCall} with a result of type {@link Enrichments} */ public ServiceCall listEnrichments(ListEnrichmentsOptions listEnrichmentsOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( listEnrichmentsOptions, "listEnrichmentsOptions cannot be null"); - String[] pathSegments = {"v2/projects", "enrichments"}; - String[] pathParameters = {listEnrichmentsOptions.projectId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", listEnrichmentsOptions.projectId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v2/projects/{project_id}/enrichments", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "listEnrichments"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken() {}.getType()); @@ -965,22 +1069,23 @@ public ServiceCall listEnrichments(ListEnrichmentsOptions listEnric * * @param createEnrichmentOptions the {@link CreateEnrichmentOptions} containing the options for * the call - * @return a {@link ServiceCall} with a response type of {@link Enrichment} + * @return a {@link ServiceCall} with a result of type {@link Enrichment} */ public ServiceCall createEnrichment(CreateEnrichmentOptions createEnrichmentOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( createEnrichmentOptions, "createEnrichmentOptions cannot be null"); - String[] pathSegments = {"v2/projects", "enrichments"}; - String[] pathParameters = {createEnrichmentOptions.projectId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", createEnrichmentOptions.projectId()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v2/projects/{project_id}/enrichments", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "createEnrichment"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); multipartBuilder.setType(MultipartBody.FORM); multipartBuilder.addFormDataPart("enrichment", createEnrichmentOptions.enrichment().toString()); @@ -1003,25 +1108,26 @@ public ServiceCall createEnrichment(CreateEnrichmentOptions createEn * * @param getEnrichmentOptions the {@link GetEnrichmentOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of {@link Enrichment} + * @return a {@link ServiceCall} with a result of type {@link Enrichment} */ public ServiceCall getEnrichment(GetEnrichmentOptions getEnrichmentOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( getEnrichmentOptions, "getEnrichmentOptions cannot be null"); - String[] pathSegments = {"v2/projects", "enrichments"}; - String[] pathParameters = { - getEnrichmentOptions.projectId(), getEnrichmentOptions.enrichmentId() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", getEnrichmentOptions.projectId()); + pathParamsMap.put("enrichment_id", getEnrichmentOptions.enrichmentId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/projects/{project_id}/enrichments/{enrichment_id}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "getEnrichment"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken() {}.getType()); @@ -1035,24 +1141,26 @@ public ServiceCall getEnrichment(GetEnrichmentOptions getEnrichmentO * * @param updateEnrichmentOptions the {@link UpdateEnrichmentOptions} containing the options for * the call - * @return a {@link ServiceCall} with a response type of {@link Enrichment} + * @return a {@link ServiceCall} with a result of type {@link Enrichment} */ public ServiceCall updateEnrichment(UpdateEnrichmentOptions updateEnrichmentOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( updateEnrichmentOptions, "updateEnrichmentOptions cannot be null"); - String[] pathSegments = {"v2/projects", "enrichments"}; - String[] pathParameters = { - updateEnrichmentOptions.projectId(), updateEnrichmentOptions.enrichmentId() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", updateEnrichmentOptions.projectId()); + pathParamsMap.put("enrichment_id", updateEnrichmentOptions.enrichmentId()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/projects/{project_id}/enrichments/{enrichment_id}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "updateEnrichment"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); final JsonObject contentJson = new JsonObject(); contentJson.addProperty("name", updateEnrichmentOptions.name()); if (updateEnrichmentOptions.description() != null) { @@ -1074,24 +1182,25 @@ public ServiceCall updateEnrichment(UpdateEnrichmentOptions updateEn * * @param deleteEnrichmentOptions the {@link DeleteEnrichmentOptions} containing the options for * the call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteEnrichment(DeleteEnrichmentOptions deleteEnrichmentOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( deleteEnrichmentOptions, "deleteEnrichmentOptions cannot be null"); - String[] pathSegments = {"v2/projects", "enrichments"}; - String[] pathParameters = { - deleteEnrichmentOptions.projectId(), deleteEnrichmentOptions.enrichmentId() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", deleteEnrichmentOptions.projectId()); + pathParamsMap.put("enrichment_id", deleteEnrichmentOptions.enrichmentId()); RequestBuilder builder = RequestBuilder.delete( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v2/projects/{project_id}/enrichments/{enrichment_id}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "deleteEnrichment"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -1102,20 +1211,17 @@ public ServiceCall deleteEnrichment(DeleteEnrichmentOptions deleteEnrichme *

Lists existing projects for this instance. * * @param listProjectsOptions the {@link ListProjectsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link ListProjectsResponse} + * @return a {@link ServiceCall} with a result of type {@link ListProjectsResponse} */ public ServiceCall listProjects(ListProjectsOptions listProjectsOptions) { - String[] pathSegments = {"v2/projects"}; RequestBuilder builder = - RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); + RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v2/projects")); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "listProjects"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - if (listProjectsOptions != null) {} - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken() {}.getType()); @@ -1127,7 +1233,7 @@ public ServiceCall listProjects(ListProjectsOptions listPr * *

Lists existing projects for this instance. * - * @return a {@link ServiceCall} with a response type of {@link ListProjectsResponse} + * @return a {@link ServiceCall} with a result of type {@link ListProjectsResponse} */ public ServiceCall listProjects() { return listProjects(null); @@ -1140,20 +1246,19 @@ public ServiceCall listProjects() { * * @param createProjectOptions the {@link CreateProjectOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of {@link ProjectDetails} + * @return a {@link ServiceCall} with a result of type {@link ProjectDetails} */ public ServiceCall createProject(CreateProjectOptions createProjectOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( createProjectOptions, "createProjectOptions cannot be null"); - String[] pathSegments = {"v2/projects"}; RequestBuilder builder = - RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); + RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v2/projects")); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "createProject"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); final JsonObject contentJson = new JsonObject(); contentJson.addProperty("name", createProjectOptions.name()); contentJson.addProperty("type", createProjectOptions.type()); @@ -1176,23 +1281,23 @@ public ServiceCall createProject(CreateProjectOptions createProj *

Get details on the specified project. * * @param getProjectOptions the {@link GetProjectOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link ProjectDetails} + * @return a {@link ServiceCall} with a result of type {@link ProjectDetails} */ public ServiceCall getProject(GetProjectOptions getProjectOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( getProjectOptions, "getProjectOptions cannot be null"); - String[] pathSegments = {"v2/projects"}; - String[] pathParameters = {getProjectOptions.projectId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", getProjectOptions.projectId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v2/projects/{project_id}", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "getProject"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken() {}.getType()); @@ -1206,22 +1311,23 @@ public ServiceCall getProject(GetProjectOptions getProjectOption * * @param updateProjectOptions the {@link UpdateProjectOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of {@link ProjectDetails} + * @return a {@link ServiceCall} with a result of type {@link ProjectDetails} */ public ServiceCall updateProject(UpdateProjectOptions updateProjectOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( updateProjectOptions, "updateProjectOptions cannot be null"); - String[] pathSegments = {"v2/projects"}; - String[] pathParameters = {updateProjectOptions.projectId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", updateProjectOptions.projectId()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v2/projects/{project_id}", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "updateProject"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); final JsonObject contentJson = new JsonObject(); if (updateProjectOptions.name() != null) { contentJson.addProperty("name", updateProjectOptions.name()); @@ -1243,22 +1349,22 @@ public ServiceCall updateProject(UpdateProjectOptions updateProj * * @param deleteProjectOptions the {@link DeleteProjectOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteProject(DeleteProjectOptions deleteProjectOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( deleteProjectOptions, "deleteProjectOptions cannot be null"); - String[] pathSegments = {"v2/projects"}; - String[] pathParameters = {deleteProjectOptions.projectId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("project_id", deleteProjectOptions.projectId()); RequestBuilder builder = RequestBuilder.delete( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v2/projects/{project_id}", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "deleteProject"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -1278,20 +1384,19 @@ public ServiceCall deleteProject(DeleteProjectOptions deleteProjectOptions * * @param deleteUserDataOptions the {@link DeleteUserDataOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteUserData(DeleteUserDataOptions deleteUserDataOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( deleteUserDataOptions, "deleteUserDataOptions cannot be null"); - String[] pathSegments = {"v2/user_data"}; RequestBuilder builder = - RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); + RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v2/user_data")); Map sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v2", "deleteUserData"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } - builder.query("customer_id", deleteUserDataOptions.customerId()); + builder.query("version", String.valueOf(this.version)); + builder.query("customer_id", String.valueOf(deleteUserDataOptions.customerId())); ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/AddDocumentOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/AddDocumentOptions.java index 81f2eaa2cbb..a9152244ebe 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/AddDocumentOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/AddDocumentOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -66,7 +66,7 @@ public Builder(String projectId, String collectionId) { /** * Builds a AddDocumentOptions. * - * @return the addDocumentOptions + * @return the new AddDocumentOptions instance */ public AddDocumentOptions build() { return new AddDocumentOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/AnalyzeDocumentOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/AnalyzeDocumentOptions.java new file mode 100644 index 00000000000..0d1ec520bef --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/AnalyzeDocumentOptions.java @@ -0,0 +1,248 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.InputStream; + +/** The analyzeDocument options. */ +public class AnalyzeDocumentOptions extends GenericModel { + + protected String projectId; + protected String collectionId; + protected InputStream file; + protected String filename; + protected String fileContentType; + protected String metadata; + + /** Builder. */ + public static class Builder { + private String projectId; + private String collectionId; + private InputStream file; + private String filename; + private String fileContentType; + private String metadata; + + private Builder(AnalyzeDocumentOptions analyzeDocumentOptions) { + this.projectId = analyzeDocumentOptions.projectId; + this.collectionId = analyzeDocumentOptions.collectionId; + this.file = analyzeDocumentOptions.file; + this.filename = analyzeDocumentOptions.filename; + this.fileContentType = analyzeDocumentOptions.fileContentType; + this.metadata = analyzeDocumentOptions.metadata; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param projectId the projectId + * @param collectionId the collectionId + */ + public Builder(String projectId, String collectionId) { + this.projectId = projectId; + this.collectionId = collectionId; + } + + /** + * Builds a AnalyzeDocumentOptions. + * + * @return the new AnalyzeDocumentOptions instance + */ + public AnalyzeDocumentOptions build() { + return new AnalyzeDocumentOptions(this); + } + + /** + * Set the projectId. + * + * @param projectId the projectId + * @return the AnalyzeDocumentOptions builder + */ + public Builder projectId(String projectId) { + this.projectId = projectId; + return this; + } + + /** + * Set the collectionId. + * + * @param collectionId the collectionId + * @return the AnalyzeDocumentOptions builder + */ + public Builder collectionId(String collectionId) { + this.collectionId = collectionId; + return this; + } + + /** + * Set the file. + * + * @param file the file + * @return the AnalyzeDocumentOptions builder + */ + public Builder file(InputStream file) { + this.file = file; + return this; + } + + /** + * Set the filename. + * + * @param filename the filename + * @return the AnalyzeDocumentOptions builder + */ + public Builder filename(String filename) { + this.filename = filename; + return this; + } + + /** + * Set the fileContentType. + * + * @param fileContentType the fileContentType + * @return the AnalyzeDocumentOptions builder + */ + public Builder fileContentType(String fileContentType) { + this.fileContentType = fileContentType; + return this; + } + + /** + * Set the metadata. + * + * @param metadata the metadata + * @return the AnalyzeDocumentOptions builder + */ + public Builder metadata(String metadata) { + this.metadata = metadata; + return this; + } + + /** + * Set the file. + * + * @param file the file + * @return the AnalyzeDocumentOptions builder + * @throws FileNotFoundException if the file could not be found + */ + public Builder file(File file) throws FileNotFoundException { + this.file = new FileInputStream(file); + this.filename = file.getName(); + return this; + } + } + + protected AnalyzeDocumentOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.projectId, "projectId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.collectionId, "collectionId cannot be empty"); + com.ibm.cloud.sdk.core.util.Validator.isTrue( + (builder.file == null) || (builder.filename != null), + "filename cannot be null if file is not null."); + projectId = builder.projectId; + collectionId = builder.collectionId; + file = builder.file; + filename = builder.filename; + fileContentType = builder.fileContentType; + metadata = builder.metadata; + } + + /** + * New builder. + * + * @return a AnalyzeDocumentOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the projectId. + * + *

The ID of the project. This information can be found from the deploy page of the Discovery + * administrative tooling. + * + * @return the projectId + */ + public String projectId() { + return projectId; + } + + /** + * Gets the collectionId. + * + *

The ID of the collection. + * + * @return the collectionId + */ + public String collectionId() { + return collectionId; + } + + /** + * Gets the file. + * + *

The content of the document to ingest. The maximum supported file size when adding a file to + * a collection is 50 megabytes, the maximum supported file size when testing a configuration is 1 + * megabyte. Files larger than the supported size are rejected. + * + * @return the file + */ + public InputStream file() { + return file; + } + + /** + * Gets the filename. + * + *

The filename for file. + * + * @return the filename + */ + public String filename() { + return filename; + } + + /** + * Gets the fileContentType. + * + *

The content type of file. Values for this parameter can be obtained from the HttpMediaType + * class. + * + * @return the fileContentType + */ + public String fileContentType() { + return fileContentType; + } + + /** + * Gets the metadata. + * + *

The maximum supported metadata file size is 1 MB. Metadata parts larger than 1 MB are + * rejected. + * + *

Example: ``` { "Creator": "Johnny Appleseed", "Subject": "Apples" } ```. + * + * @return the metadata + */ + public String metadata() { + return metadata; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/AnalyzedDocument.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/AnalyzedDocument.java new file mode 100644 index 00000000000..dc53fd9ac76 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/AnalyzedDocument.java @@ -0,0 +1,45 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** An object containing the converted document and any identified enrichments. */ +public class AnalyzedDocument extends GenericModel { + + protected List notices; + protected AnalyzedResult result; + + /** + * Gets the notices. + * + *

Array of document results that match the query. + * + * @return the notices + */ + public List getNotices() { + return notices; + } + + /** + * Gets the result. + * + *

Result of the document analysis. + * + * @return the result + */ + public AnalyzedResult getResult() { + return result; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentCategories.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/AnalyzedResult.java similarity index 56% rename from discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentCategories.java rename to discovery/src/main/java/com/ibm/watson/discovery/v2/model/AnalyzedResult.java index 6017471b4eb..680b59e7692 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v1/model/NluEnrichmentCategories.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/AnalyzedResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -10,15 +10,31 @@ * 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.watson.discovery.v1.model; +package com.ibm.watson.discovery.v2.model; +import com.google.gson.annotations.SerializedName; import com.google.gson.reflect.TypeToken; import com.ibm.cloud.sdk.core.service.model.DynamicModel; +import java.util.Map; -/** An object that indicates the Categories enrichment will be applied to the specified field. */ -public class NluEnrichmentCategories extends DynamicModel { +/** Result of the document analysis. */ +public class AnalyzedResult extends DynamicModel { - public NluEnrichmentCategories() { + @SerializedName("metadata") + protected Map metadata; + + public AnalyzedResult() { super(new TypeToken() {}); } + + /** + * Gets the metadata. + * + *

Metadata of the document. + * + * @return the metadata + */ + public Map getMetadata() { + return this.metadata; + } } diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/Collection.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/Collection.java index 93d14e6f419..bbe9344b681 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/Collection.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/Collection.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CollectionDetails.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CollectionDetails.java index 467981bdd0d..4bde67858a5 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CollectionDetails.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CollectionDetails.java @@ -32,18 +32,14 @@ public class CollectionDetails extends GenericModel { /** Builder. */ public static class Builder { - private String collectionId; private String name; private String description; - private Date created; private String language; private List enrichments; private Builder(CollectionDetails collectionDetails) { - this.collectionId = collectionDetails.collectionId; this.name = collectionDetails.name; this.description = collectionDetails.description; - this.created = collectionDetails.created; this.language = collectionDetails.language; this.enrichments = collectionDetails.enrichments; } @@ -63,7 +59,7 @@ public Builder(String name) { /** * Builds a CollectionDetails. * - * @return the collectionDetails + * @return the new CollectionDetails instance */ public CollectionDetails build() { return new CollectionDetails(this); @@ -84,17 +80,6 @@ public Builder addEnrichments(CollectionEnrichment enrichments) { return this; } - /** - * Set the collectionId. - * - * @param collectionId the collectionId - * @return the CollectionDetails builder - */ - public Builder collectionId(String collectionId) { - this.collectionId = collectionId; - return this; - } - /** * Set the name. * @@ -117,17 +102,6 @@ public Builder description(String description) { return this; } - /** - * Set the created. - * - * @param created the created - * @return the CollectionDetails builder - */ - public Builder created(Date created) { - this.created = created; - return this; - } - /** * Set the language. * @@ -153,10 +127,8 @@ public Builder enrichments(List enrichments) { protected CollectionDetails(Builder builder) { com.ibm.cloud.sdk.core.util.Validator.notNull(builder.name, "name cannot be null"); - collectionId = builder.collectionId; name = builder.name; description = builder.description; - created = builder.created; language = builder.language; enrichments = builder.enrichments; } diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CollectionEnrichment.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CollectionEnrichment.java index e87336b5db4..3fcd3f0730d 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CollectionEnrichment.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CollectionEnrichment.java @@ -41,7 +41,7 @@ public Builder() {} /** * Builds a CollectionEnrichment. * - * @return the collectionEnrichment + * @return the new CollectionEnrichment instance */ public CollectionEnrichment build() { return new CollectionEnrichment(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/Completions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/Completions.java index 5413bf801bf..9eadcc78bc9 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/Completions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/Completions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -23,7 +23,7 @@ public class Completions extends GenericModel { /** * Gets the completions. * - *

Array of autcomplete suggestion based on the provided prefix. + *

Array of autocomplete suggestion based on the provided prefix. * * @return the completions */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ComponentSettingsAggregation.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ComponentSettingsAggregation.java index 9ae2b6babec..2f43ff849a9 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ComponentSettingsAggregation.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ComponentSettingsAggregation.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ComponentSettingsFieldsShown.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ComponentSettingsFieldsShown.java index e8e953c4e4b..1187c7dcecd 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ComponentSettingsFieldsShown.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ComponentSettingsFieldsShown.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ComponentSettingsFieldsShownBody.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ComponentSettingsFieldsShownBody.java index 8849d918ded..b12c5fa44af 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ComponentSettingsFieldsShownBody.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ComponentSettingsFieldsShownBody.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ComponentSettingsFieldsShownTitle.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ComponentSettingsFieldsShownTitle.java index 5534b8a3b70..93a08f74849 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ComponentSettingsFieldsShownTitle.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ComponentSettingsFieldsShownTitle.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ComponentSettingsResponse.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ComponentSettingsResponse.java index 655d178837b..5874bab2374 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ComponentSettingsResponse.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ComponentSettingsResponse.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CreateCollectionOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CreateCollectionOptions.java index 85a39ed3907..13b5bff1295 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CreateCollectionOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CreateCollectionOptions.java @@ -58,7 +58,7 @@ public Builder(String projectId, String name) { /** * Builds a CreateCollectionOptions. * - * @return the createCollectionOptions + * @return the new CreateCollectionOptions instance */ public CreateCollectionOptions build() { return new CreateCollectionOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CreateEnrichment.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CreateEnrichment.java index 8284d5b47c8..c7552e52a4f 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CreateEnrichment.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CreateEnrichment.java @@ -56,7 +56,7 @@ public Builder() {} /** * Builds a CreateEnrichment. * - * @return the createEnrichment + * @return the new CreateEnrichment instance */ public CreateEnrichment build() { return new CreateEnrichment(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CreateEnrichmentOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CreateEnrichmentOptions.java index bcd5727f4a0..11a7dcadbe3 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CreateEnrichmentOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CreateEnrichmentOptions.java @@ -54,7 +54,7 @@ public Builder(String projectId, CreateEnrichment enrichment) { /** * Builds a CreateEnrichmentOptions. * - * @return the createEnrichmentOptions + * @return the new CreateEnrichmentOptions instance */ public CreateEnrichmentOptions build() { return new CreateEnrichmentOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CreateProjectOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CreateProjectOptions.java index af8456ea53b..da885ed9c0f 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CreateProjectOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CreateProjectOptions.java @@ -62,7 +62,7 @@ public Builder(String name, String type) { /** * Builds a CreateProjectOptions. * - * @return the createProjectOptions + * @return the new CreateProjectOptions instance */ public CreateProjectOptions build() { return new CreateProjectOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CreateTrainingQueryOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CreateTrainingQueryOptions.java index 7ce550d5c33..980c415429b 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CreateTrainingQueryOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CreateTrainingQueryOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -57,7 +57,7 @@ public Builder(String projectId, String naturalLanguageQuery, ListWhen `true`, a spelling suggestions for the query are retuned by default. + *

When `true`, a spelling suggestions for the query are returned by default. * * @return the spellingSuggestions */ @@ -315,7 +315,7 @@ public Boolean spellingSuggestions() { /** * Gets the highlight. * - *

When `true`, a highlights for the query are retuned by default. + *

When `true`, a highlights for the query are returned by default. * * @return the highlight */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DefaultQueryParamsPassages.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DefaultQueryParamsPassages.java index 225d7af9484..99172e40bcd 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DefaultQueryParamsPassages.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DefaultQueryParamsPassages.java @@ -55,7 +55,7 @@ public Builder() {} /** * Builds a DefaultQueryParamsPassages. * - * @return the defaultQueryParamsPassages + * @return the new DefaultQueryParamsPassages instance */ public DefaultQueryParamsPassages build() { return new DefaultQueryParamsPassages(this); @@ -186,7 +186,7 @@ public Long count() { /** * Gets the fields. * - *

An array of field names to perfom the passage search on. + *

An array of field names to perform the passage search on. * * @return the fields */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DefaultQueryParamsSuggestedRefinements.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DefaultQueryParamsSuggestedRefinements.java index ad36a784d52..9d79d4fb7c5 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DefaultQueryParamsSuggestedRefinements.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DefaultQueryParamsSuggestedRefinements.java @@ -36,7 +36,7 @@ public Builder() {} /** * Builds a DefaultQueryParamsSuggestedRefinements. * - * @return the defaultQueryParamsSuggestedRefinements + * @return the new DefaultQueryParamsSuggestedRefinements instance */ public DefaultQueryParamsSuggestedRefinements build() { return new DefaultQueryParamsSuggestedRefinements(this); @@ -82,7 +82,7 @@ public Builder newBuilder() { /** * Gets the enabled. * - *

When `true`, a suggested refinements for the query are retuned by default. + *

When `true`, a suggested refinements for the query are returned by default. * * @return the enabled */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DefaultQueryParamsTableResults.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DefaultQueryParamsTableResults.java index bb2c683bd51..5604660befa 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DefaultQueryParamsTableResults.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DefaultQueryParamsTableResults.java @@ -42,7 +42,7 @@ public Builder() {} /** * Builds a DefaultQueryParamsTableResults. * - * @return the defaultQueryParamsTableResults + * @return the new DefaultQueryParamsTableResults instance */ public DefaultQueryParamsTableResults build() { return new DefaultQueryParamsTableResults(this); @@ -100,7 +100,7 @@ public Builder newBuilder() { /** * Gets the enabled. * - *

When `true`, a table results for the query are retuned by default. + *

When `true`, a table results for the query are returned by default. * * @return the enabled */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteCollectionOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteCollectionOptions.java index 8fcc8578a3e..048c615d4b9 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteCollectionOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteCollectionOptions.java @@ -47,7 +47,7 @@ public Builder(String projectId, String collectionId) { /** * Builds a DeleteCollectionOptions. * - * @return the deleteCollectionOptions + * @return the new DeleteCollectionOptions instance */ public DeleteCollectionOptions build() { return new DeleteCollectionOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteDocumentOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteDocumentOptions.java index cb950bdfb62..b5f59e06eb7 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteDocumentOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteDocumentOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -55,7 +55,7 @@ public Builder(String projectId, String collectionId, String documentId) { /** * Builds a DeleteDocumentOptions. * - * @return the deleteDocumentOptions + * @return the new DeleteDocumentOptions instance */ public DeleteDocumentOptions build() { return new DeleteDocumentOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteDocumentResponse.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteDocumentResponse.java index dd3961ca4d4..30a06b8414c 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteDocumentResponse.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteDocumentResponse.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteEnrichmentOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteEnrichmentOptions.java index 8f696a62f22..83bc296d4f6 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteEnrichmentOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteEnrichmentOptions.java @@ -47,7 +47,7 @@ public Builder(String projectId, String enrichmentId) { /** * Builds a DeleteEnrichmentOptions. * - * @return the deleteEnrichmentOptions + * @return the new DeleteEnrichmentOptions instance */ public DeleteEnrichmentOptions build() { return new DeleteEnrichmentOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteProjectOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteProjectOptions.java index 8398b3eeac4..22947dcdf84 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteProjectOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteProjectOptions.java @@ -42,7 +42,7 @@ public Builder(String projectId) { /** * Builds a DeleteProjectOptions. * - * @return the deleteProjectOptions + * @return the new DeleteProjectOptions instance */ public DeleteProjectOptions build() { return new DeleteProjectOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteTrainingQueriesOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteTrainingQueriesOptions.java index 54dae520209..12eec6c03fe 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteTrainingQueriesOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteTrainingQueriesOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -42,7 +42,7 @@ public Builder(String projectId) { /** * Builds a DeleteTrainingQueriesOptions. * - * @return the deleteTrainingQueriesOptions + * @return the new DeleteTrainingQueriesOptions instance */ public DeleteTrainingQueriesOptions build() { return new DeleteTrainingQueriesOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteUserDataOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteUserDataOptions.java index 3ecda460e6f..0cf9b947640 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteUserDataOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteUserDataOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -42,7 +42,7 @@ public Builder(String customerId) { /** * Builds a DeleteUserDataOptions. * - * @return the deleteUserDataOptions + * @return the new DeleteUserDataOptions instance */ public DeleteUserDataOptions build() { return new DeleteUserDataOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DocumentAccepted.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DocumentAccepted.java index 9266a29478a..cfa3a472453 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DocumentAccepted.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DocumentAccepted.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DocumentAttribute.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DocumentAttribute.java index 93372e78b53..9b3ffd94819 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DocumentAttribute.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DocumentAttribute.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/EnrichmentOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/EnrichmentOptions.java index 37c3ec7bb92..47fc4dad78d 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/EnrichmentOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/EnrichmentOptions.java @@ -51,7 +51,7 @@ public Builder() {} /** * Builds a EnrichmentOptions. * - * @return the enrichmentOptions + * @return the new EnrichmentOptions instance */ public EnrichmentOptions build() { return new EnrichmentOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/Field.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/Field.java index f03a11eec9d..389367e842a 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/Field.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/Field.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetAutocompletionOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetAutocompletionOptions.java index 1033f5242ba..9e1ec7257da 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetAutocompletionOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetAutocompletionOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -58,7 +58,7 @@ public Builder(String projectId, String prefix) { /** * Builds a GetAutocompletionOptions. * - * @return the getAutocompletionOptions + * @return the new GetAutocompletionOptions instance */ public GetAutocompletionOptions build() { return new GetAutocompletionOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetCollectionOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetCollectionOptions.java index 36916890396..efbf13eedd4 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetCollectionOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetCollectionOptions.java @@ -47,7 +47,7 @@ public Builder(String projectId, String collectionId) { /** * Builds a GetCollectionOptions. * - * @return the getCollectionOptions + * @return the new GetCollectionOptions instance */ public GetCollectionOptions build() { return new GetCollectionOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetComponentSettingsOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetComponentSettingsOptions.java index ef14df25800..13a2d34b695 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetComponentSettingsOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetComponentSettingsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -42,7 +42,7 @@ public Builder(String projectId) { /** * Builds a GetComponentSettingsOptions. * - * @return the getComponentSettingsOptions + * @return the new GetComponentSettingsOptions instance */ public GetComponentSettingsOptions build() { return new GetComponentSettingsOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetEnrichmentOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetEnrichmentOptions.java index 0ccdcc08e49..c5be8cd9968 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetEnrichmentOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetEnrichmentOptions.java @@ -47,7 +47,7 @@ public Builder(String projectId, String enrichmentId) { /** * Builds a GetEnrichmentOptions. * - * @return the getEnrichmentOptions + * @return the new GetEnrichmentOptions instance */ public GetEnrichmentOptions build() { return new GetEnrichmentOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetProjectOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetProjectOptions.java index 2c91d440177..fa1b02c5d2b 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetProjectOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetProjectOptions.java @@ -42,7 +42,7 @@ public Builder(String projectId) { /** * Builds a GetProjectOptions. * - * @return the getProjectOptions + * @return the new GetProjectOptions instance */ public GetProjectOptions build() { return new GetProjectOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetTrainingQueryOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetTrainingQueryOptions.java index a00bd946aca..61e65c7bd9a 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetTrainingQueryOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetTrainingQueryOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -47,7 +47,7 @@ public Builder(String projectId, String queryId) { /** * Builds a GetTrainingQueryOptions. * - * @return the getTrainingQueryOptions + * @return the new GetTrainingQueryOptions instance */ public GetTrainingQueryOptions build() { return new GetTrainingQueryOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListCollectionsOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListCollectionsOptions.java index 5ee0ace0844..fdc375053ef 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListCollectionsOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListCollectionsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -42,7 +42,7 @@ public Builder(String projectId) { /** * Builds a ListCollectionsOptions. * - * @return the listCollectionsOptions + * @return the new ListCollectionsOptions instance */ public ListCollectionsOptions build() { return new ListCollectionsOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListCollectionsResponse.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListCollectionsResponse.java index 642b50f0230..c7768aab966 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListCollectionsResponse.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListCollectionsResponse.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListEnrichmentsOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListEnrichmentsOptions.java index 5621e154955..25eaed8f182 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListEnrichmentsOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListEnrichmentsOptions.java @@ -42,7 +42,7 @@ public Builder(String projectId) { /** * Builds a ListEnrichmentsOptions. * - * @return the listEnrichmentsOptions + * @return the new ListEnrichmentsOptions instance */ public ListEnrichmentsOptions build() { return new ListEnrichmentsOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListFieldsOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListFieldsOptions.java index 65b54e68499..b2c6f4d43fd 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListFieldsOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListFieldsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -47,7 +47,7 @@ public Builder(String projectId) { /** * Builds a ListFieldsOptions. * - * @return the listFieldsOptions + * @return the new ListFieldsOptions instance */ public ListFieldsOptions build() { return new ListFieldsOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListFieldsResponse.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListFieldsResponse.java index f6c28ea271d..77ffb49c766 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListFieldsResponse.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListFieldsResponse.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListTrainingQueriesOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListTrainingQueriesOptions.java index de2b99aaca4..66a4175bc11 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListTrainingQueriesOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListTrainingQueriesOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -42,7 +42,7 @@ public Builder(String projectId) { /** * Builds a ListTrainingQueriesOptions. * - * @return the listTrainingQueriesOptions + * @return the new ListTrainingQueriesOptions instance */ public ListTrainingQueriesOptions build() { return new ListTrainingQueriesOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/Notice.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/Notice.java index 8a3a4dc7f8d..3407f613395 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/Notice.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/Notice.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ProjectListDetailsRelevancyTrainingStatus.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ProjectListDetailsRelevancyTrainingStatus.java index ae538244d51..d8d50f8c419 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ProjectListDetailsRelevancyTrainingStatus.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ProjectListDetailsRelevancyTrainingStatus.java @@ -66,7 +66,7 @@ public Long getTotalExamples() { /** * Gets the sufficientLabelDiversity. * - *

When `true`, sufficent label diversity is present to allow training for this project. + *

When `true`, sufficient label diversity is present to allow training for this project. * * @return the sufficientLabelDiversity */ @@ -99,7 +99,7 @@ public Boolean isMinimumExamplesAdded() { /** * Gets the successfullyTrained. * - *

The time that the most recent successful training occured. + *

The time that the most recent successful training occurred. * * @return the successfullyTrained */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryAggregation.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryAggregation.java index 7059f519f1a..6a5ab4f1e7f 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryAggregation.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryAggregation.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryCalculationAggregation.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryCalculationAggregation.java index 40cb8b1be94..39a3ea0f8e6 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryCalculationAggregation.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryCalculationAggregation.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryFilterAggregation.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryFilterAggregation.java index d56c3eb87e4..627201a52f8 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryFilterAggregation.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryFilterAggregation.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryHistogramAggregation.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryHistogramAggregation.java index cb2c52dd203..f456b77b59a 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryHistogramAggregation.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryHistogramAggregation.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryHistogramAggregationResult.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryHistogramAggregationResult.java index 2b16b8c3a73..3869fb26bfa 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryHistogramAggregationResult.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryHistogramAggregationResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryLargePassages.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryLargePassages.java index 0b46f405945..2faa29b92ad 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryLargePassages.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryLargePassages.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -56,7 +56,7 @@ public Builder() {} /** * Builds a QueryLargePassages. * - * @return the queryLargePassages + * @return the new QueryLargePassages instance */ public QueryLargePassages build() { return new QueryLargePassages(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryLargeSuggestedRefinements.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryLargeSuggestedRefinements.java index 57135ee6793..c538fb65474 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryLargeSuggestedRefinements.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryLargeSuggestedRefinements.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -36,7 +36,7 @@ public Builder() {} /** * Builds a QueryLargeSuggestedRefinements. * - * @return the queryLargeSuggestedRefinements + * @return the new QueryLargeSuggestedRefinements instance */ public QueryLargeSuggestedRefinements build() { return new QueryLargeSuggestedRefinements(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryLargeTableResults.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryLargeTableResults.java index 6cd05c9dbc0..5c901a7dd92 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryLargeTableResults.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryLargeTableResults.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -36,7 +36,7 @@ public Builder() {} /** * Builds a QueryLargeTableResults. * - * @return the queryLargeTableResults + * @return the new QueryLargeTableResults instance */ public QueryLargeTableResults build() { return new QueryLargeTableResults(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryNestedAggregation.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryNestedAggregation.java index 7b0a1e4ab71..ed8691965e2 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryNestedAggregation.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryNestedAggregation.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryNoticesOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryNoticesOptions.java index 2e92f894cc9..667bf2ed3ad 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryNoticesOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryNoticesOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -57,7 +57,7 @@ public Builder(String projectId) { /** * Builds a QueryNoticesOptions. * - * @return the queryNoticesOptions + * @return the new QueryNoticesOptions instance */ public QueryNoticesOptions build() { return new QueryNoticesOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryNoticesResponse.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryNoticesResponse.java index 8f180bd9f50..383d4b3de6e 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryNoticesResponse.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryNoticesResponse.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryNoticesResult.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryNoticesResult.java deleted file mode 100644 index 92d296f0c8c..00000000000 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryNoticesResult.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.watson.discovery.v2.model; - -import com.google.gson.annotations.SerializedName; -import com.google.gson.reflect.TypeToken; -import com.ibm.cloud.sdk.core.service.model.DynamicModel; -import java.util.List; -import java.util.Map; - -/** Result document for the specified query. */ -public class QueryNoticesResult extends DynamicModel { - /** The type of the original source file. */ - public interface FileType { - /** pdf. */ - String PDF = "pdf"; - /** html. */ - String HTML = "html"; - /** word. */ - String WORD = "word"; - /** json. */ - String JSON = "json"; - } - - @SerializedName("document_id") - private String documentId; - - @SerializedName("metadata") - private Map metadata; - - @SerializedName("result_metadata") - private QueryResultMetadata resultMetadata; - - @SerializedName("document_passages") - private List documentPassages; - - @SerializedName("code") - private Long code; - - @SerializedName("filename") - private String filename; - - @SerializedName("file_type") - private String fileType; - - @SerializedName("sha1") - private String sha1; - - @SerializedName("notices") - private List notices; - - public QueryNoticesResult() { - super(new TypeToken() {}); - } - - /** - * Gets the documentId. - * - *

The unique identifier of the document. - * - * @return the documentId - */ - public String getDocumentId() { - return this.documentId; - } - - /** - * Gets the metadata. - * - *

Metadata of the document. - * - * @return the metadata - */ - public Map getMetadata() { - return this.metadata; - } - - /** - * Gets the resultMetadata. - * - *

Metadata of a query result. - * - * @return the resultMetadata - */ - public QueryResultMetadata getResultMetadata() { - return this.resultMetadata; - } - - /** - * Gets the documentPassages. - * - *

Passages returned by Discovery. - * - * @return the documentPassages - */ - public List getDocumentPassages() { - return this.documentPassages; - } - - /** - * Gets the code. - * - *

The internal status code returned by the ingestion subsystem indicating the overall result - * of ingesting the source document. - * - * @return the code - */ - public Long getCode() { - return this.code; - } - - /** - * Gets the filename. - * - *

Name of the original source file (if available). - * - * @return the filename - */ - public String getFilename() { - return this.filename; - } - - /** - * Gets the fileType. - * - *

The type of the original source file. - * - * @return the fileType - */ - public String getFileType() { - return this.fileType; - } - - /** - * Gets the sha1. - * - *

The SHA-1 hash of the original source file (formatted as a hexadecimal string). - * - * @return the sha1 - */ - public String getSha1() { - return this.sha1; - } - - /** - * Gets the notices. - * - *

Array of notices for the document. - * - * @return the notices - */ - public List getNotices() { - return this.notices; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryOptions.java index 4a9e6e0ffc0..3c191326810 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -86,7 +86,7 @@ public Builder(String projectId) { /** * Builds a QueryOptions. * - * @return the queryOptions + * @return the new QueryOptions instance */ public QueryOptions build() { return new QueryOptions(this); @@ -442,7 +442,7 @@ public String sort() { * Gets the highlight. * *

When `true`, a highlight field is returned for each result which contains the fields which - * match the query with `` tags around the matching query terms. + * match the query with `<em></em>` tags around the matching query terms. * * @return the highlight */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryResponse.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryResponse.java index d31ed6b8ac9..038f8dce427 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryResponse.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryResponse.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryResponsePassage.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryResponsePassage.java index 610724a73ae..2242f671665 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryResponsePassage.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryResponsePassage.java @@ -52,8 +52,7 @@ public String getPassageText() { /** * Gets the passageScore. * - *

The confidence score of the passages's analysis. A higher score indicates greater - * confidence. + *

The confidence score of the passage's analysis. A higher score indicates greater confidence. * * @return the passageScore */ diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryResult.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryResult.java index db222fb873c..9b7f200361c 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryResult.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryResultMetadata.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryResultMetadata.java index 83452594629..31798319b80 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryResultMetadata.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryResultMetadata.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryResultPassage.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryResultPassage.java index 8a16dcdf59c..25277e570e6 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryResultPassage.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryResultPassage.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QuerySuggestedRefinement.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QuerySuggestedRefinement.java index 4e662c513d1..306454c047e 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QuerySuggestedRefinement.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QuerySuggestedRefinement.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTableResult.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTableResult.java index 63f67642a47..ab8f816bcc1 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTableResult.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTableResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTermAggregation.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTermAggregation.java index e331ec8a970..76fe7229042 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTermAggregation.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTermAggregation.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTermAggregationResult.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTermAggregationResult.java index 61c8764f937..a7793635665 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTermAggregationResult.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTermAggregationResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTimesliceAggregation.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTimesliceAggregation.java index bfbaefebae0..f79b3a9f6b5 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTimesliceAggregation.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTimesliceAggregation.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTimesliceAggregationResult.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTimesliceAggregationResult.java index 2c706d0025a..82e3d4f550d 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTimesliceAggregationResult.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTimesliceAggregationResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTopHitsAggregation.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTopHitsAggregation.java index 6089ab2dad6..3756c13be5c 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTopHitsAggregation.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTopHitsAggregation.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTopHitsAggregationResult.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTopHitsAggregationResult.java index 20c29f5d400..3a316100fdf 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTopHitsAggregationResult.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTopHitsAggregationResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/RetrievalDetails.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/RetrievalDetails.java index 659d854efaf..28242aacfa3 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/RetrievalDetails.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/RetrievalDetails.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableBodyCells.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableBodyCells.java index db12f281fa4..ada26347b57 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableBodyCells.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableBodyCells.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableCellKey.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableCellKey.java index 13c16b71e41..8e99b957809 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableCellKey.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableCellKey.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableCellValues.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableCellValues.java index cf9ed887097..1152d41b793 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableCellValues.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableCellValues.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableColumnHeaderIds.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableColumnHeaderIds.java index 5102f6867e0..bdd3672060f 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableColumnHeaderIds.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableColumnHeaderIds.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableColumnHeaderTexts.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableColumnHeaderTexts.java index 4c785cac224..f55e1630541 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableColumnHeaderTexts.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableColumnHeaderTexts.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableColumnHeaderTextsNormalized.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableColumnHeaderTextsNormalized.java index a3799ea14af..ee73c31d10c 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableColumnHeaderTextsNormalized.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableColumnHeaderTextsNormalized.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableColumnHeaders.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableColumnHeaders.java index cc45308b615..86ef11276f9 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableColumnHeaders.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableColumnHeaders.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableElementLocation.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableElementLocation.java index 717202c265c..7eed140a380 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableElementLocation.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableElementLocation.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableHeaders.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableHeaders.java index f9a79a7b7eb..58b8fe8a5b7 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableHeaders.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableHeaders.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableKeyValuePairs.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableKeyValuePairs.java index 37d5b89e942..e77d9d69aec 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableKeyValuePairs.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableKeyValuePairs.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableResultTable.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableResultTable.java index 7823d437f81..b62f603c2fd 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableResultTable.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableResultTable.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableRowHeaderIds.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableRowHeaderIds.java index fbc2ab4d052..2c4b218086d 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableRowHeaderIds.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableRowHeaderIds.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableRowHeaderTexts.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableRowHeaderTexts.java index 8f44e0222b3..e8b3b373110 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableRowHeaderTexts.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableRowHeaderTexts.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableRowHeaderTextsNormalized.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableRowHeaderTextsNormalized.java index 75599d8eec3..e8bd010b77d 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableRowHeaderTextsNormalized.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableRowHeaderTextsNormalized.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableRowHeaders.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableRowHeaders.java index f3be2a90e52..23a41a1f0a5 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableRowHeaders.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableRowHeaders.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableTextLocation.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableTextLocation.java index 85e4067ab9a..c770291fb93 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableTextLocation.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableTextLocation.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TrainingExample.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TrainingExample.java index e4e05770366..6517acac089 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TrainingExample.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TrainingExample.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -34,15 +34,11 @@ public static class Builder { private String documentId; private String collectionId; private Long relevance; - private Date created; - private Date updated; private Builder(TrainingExample trainingExample) { this.documentId = trainingExample.documentId; this.collectionId = trainingExample.collectionId; this.relevance = trainingExample.relevance; - this.created = trainingExample.created; - this.updated = trainingExample.updated; } /** Instantiates a new builder. */ @@ -64,7 +60,7 @@ public Builder(String documentId, String collectionId, Long relevance) { /** * Builds a TrainingExample. * - * @return the trainingExample + * @return the new TrainingExample instance */ public TrainingExample build() { return new TrainingExample(this); @@ -102,28 +98,6 @@ public Builder relevance(long relevance) { this.relevance = relevance; return this; } - - /** - * Set the created. - * - * @param created the created - * @return the TrainingExample builder - */ - public Builder created(Date created) { - this.created = created; - return this; - } - - /** - * Set the updated. - * - * @param updated the updated - * @return the TrainingExample builder - */ - public Builder updated(Date updated) { - this.updated = updated; - return this; - } } protected TrainingExample(Builder builder) { @@ -134,8 +108,6 @@ protected TrainingExample(Builder builder) { documentId = builder.documentId; collectionId = builder.collectionId; relevance = builder.relevance; - created = builder.created; - updated = builder.updated; } /** diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TrainingQuery.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TrainingQuery.java index 37042c330d5..0b16c0715f6 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TrainingQuery.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TrainingQuery.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -34,19 +34,13 @@ public class TrainingQuery extends GenericModel { /** Builder. */ public static class Builder { - private String queryId; private String naturalLanguageQuery; private String filter; - private Date created; - private Date updated; private List examples; private Builder(TrainingQuery trainingQuery) { - this.queryId = trainingQuery.queryId; this.naturalLanguageQuery = trainingQuery.naturalLanguageQuery; this.filter = trainingQuery.filter; - this.created = trainingQuery.created; - this.updated = trainingQuery.updated; this.examples = trainingQuery.examples; } @@ -67,7 +61,7 @@ public Builder(String naturalLanguageQuery, List examples) { /** * Builds a TrainingQuery. * - * @return the trainingQuery + * @return the new TrainingQuery instance */ public TrainingQuery build() { return new TrainingQuery(this); @@ -88,17 +82,6 @@ public Builder addExamples(TrainingExample examples) { return this; } - /** - * Set the queryId. - * - * @param queryId the queryId - * @return the TrainingQuery builder - */ - public Builder queryId(String queryId) { - this.queryId = queryId; - return this; - } - /** * Set the naturalLanguageQuery. * @@ -121,28 +104,6 @@ public Builder filter(String filter) { return this; } - /** - * Set the created. - * - * @param created the created - * @return the TrainingQuery builder - */ - public Builder created(Date created) { - this.created = created; - return this; - } - - /** - * Set the updated. - * - * @param updated the updated - * @return the TrainingQuery builder - */ - public Builder updated(Date updated) { - this.updated = updated; - return this; - } - /** * Set the examples. Existing examples will be replaced. * @@ -159,11 +120,8 @@ protected TrainingQuery(Builder builder) { com.ibm.cloud.sdk.core.util.Validator.notNull( builder.naturalLanguageQuery, "naturalLanguageQuery cannot be null"); com.ibm.cloud.sdk.core.util.Validator.notNull(builder.examples, "examples cannot be null"); - queryId = builder.queryId; naturalLanguageQuery = builder.naturalLanguageQuery; filter = builder.filter; - created = builder.created; - updated = builder.updated; examples = builder.examples; } diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TrainingQuerySet.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TrainingQuerySet.java index 70be9ba871c..b18390b9057 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TrainingQuerySet.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TrainingQuerySet.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/UpdateCollectionOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/UpdateCollectionOptions.java index 521c10421e7..29988aac03b 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/UpdateCollectionOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/UpdateCollectionOptions.java @@ -58,7 +58,7 @@ public Builder(String projectId, String collectionId) { /** * Builds a UpdateCollectionOptions. * - * @return the updateCollectionOptions + * @return the new UpdateCollectionOptions instance */ public UpdateCollectionOptions build() { return new UpdateCollectionOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/UpdateDocumentOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/UpdateDocumentOptions.java index 7b877d1b8a9..24b376c84cd 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/UpdateDocumentOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/UpdateDocumentOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -71,7 +71,7 @@ public Builder(String projectId, String collectionId, String documentId) { /** * Builds a UpdateDocumentOptions. * - * @return the updateDocumentOptions + * @return the new UpdateDocumentOptions instance */ public UpdateDocumentOptions build() { return new UpdateDocumentOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/UpdateEnrichmentOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/UpdateEnrichmentOptions.java index 1d3c8aa9b39..a8a1ff006d6 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/UpdateEnrichmentOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/UpdateEnrichmentOptions.java @@ -55,7 +55,7 @@ public Builder(String projectId, String enrichmentId, String name) { /** * Builds a UpdateEnrichmentOptions. * - * @return the updateEnrichmentOptions + * @return the new UpdateEnrichmentOptions instance */ public UpdateEnrichmentOptions build() { return new UpdateEnrichmentOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/UpdateProjectOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/UpdateProjectOptions.java index 495198b5631..05ce3996dea 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/UpdateProjectOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/UpdateProjectOptions.java @@ -45,7 +45,7 @@ public Builder(String projectId) { /** * Builds a UpdateProjectOptions. * - * @return the updateProjectOptions + * @return the new UpdateProjectOptions instance */ public UpdateProjectOptions build() { return new UpdateProjectOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/UpdateTrainingQueryOptions.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/UpdateTrainingQueryOptions.java index cf7df206c93..552e3b01111 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/model/UpdateTrainingQueryOptions.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/UpdateTrainingQueryOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -66,7 +66,7 @@ public Builder( /** * Builds a UpdateTrainingQueryOptions. * - * @return the updateTrainingQueryOptions + * @return the new UpdateTrainingQueryOptions instance */ public UpdateTrainingQueryOptions build() { return new UpdateTrainingQueryOptions(this); diff --git a/discovery/src/main/java/com/ibm/watson/discovery/v2/package-info.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/package-info.java index cbaa3e0ed7f..1b392cb7a09 100644 --- a/discovery/src/main/java/com/ibm/watson/discovery/v2/package-info.java +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/package-info.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/DiscoveryServiceIT.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/DiscoveryServiceIT.java index f86ab6f90df..718cba82ef2 100644 --- a/discovery/src/test/java/com/ibm/watson/discovery/v1/DiscoveryServiceIT.java +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/DiscoveryServiceIT.java @@ -24,7 +24,6 @@ import com.google.gson.internal.LazilyParsedNumber; import com.ibm.cloud.sdk.core.http.HttpConfigOptions; import com.ibm.cloud.sdk.core.http.HttpMediaType; -import com.ibm.cloud.sdk.core.http.Response; import com.ibm.cloud.sdk.core.security.Authenticator; import com.ibm.cloud.sdk.core.security.BasicAuthenticator; import com.ibm.cloud.sdk.core.security.BearerTokenAuthenticator; @@ -38,7 +37,6 @@ import com.ibm.watson.discovery.query.Operator; import com.ibm.watson.discovery.v1.model.*; import com.ibm.watson.discovery.v1.model.NormalizationOperation.Operation; - import java.awt.*; import java.io.ByteArrayInputStream; import java.io.FileInputStream; diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/DiscoveryTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/DiscoveryTest.java new file mode 100644 index 00000000000..bbe2f9e5a06 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/DiscoveryTest.java @@ -0,0 +1,4373 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.http.Response; +import com.ibm.cloud.sdk.core.security.Authenticator; +import com.ibm.cloud.sdk.core.security.NoAuthAuthenticator; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.cloud.sdk.core.util.RequestUtils; +import com.ibm.watson.discovery.v1.model.AddDocumentOptions; +import com.ibm.watson.discovery.v1.model.AddTrainingDataOptions; +import com.ibm.watson.discovery.v1.model.Collection; +import com.ibm.watson.discovery.v1.model.Completions; +import com.ibm.watson.discovery.v1.model.Configuration; +import com.ibm.watson.discovery.v1.model.Conversions; +import com.ibm.watson.discovery.v1.model.CreateCollectionOptions; +import com.ibm.watson.discovery.v1.model.CreateConfigurationOptions; +import com.ibm.watson.discovery.v1.model.CreateCredentialsOptions; +import com.ibm.watson.discovery.v1.model.CreateEnvironmentOptions; +import com.ibm.watson.discovery.v1.model.CreateEventOptions; +import com.ibm.watson.discovery.v1.model.CreateEventResponse; +import com.ibm.watson.discovery.v1.model.CreateExpansionsOptions; +import com.ibm.watson.discovery.v1.model.CreateGatewayOptions; +import com.ibm.watson.discovery.v1.model.CreateStopwordListOptions; +import com.ibm.watson.discovery.v1.model.CreateTokenizationDictionaryOptions; +import com.ibm.watson.discovery.v1.model.CreateTrainingExampleOptions; +import com.ibm.watson.discovery.v1.model.CredentialDetails; +import com.ibm.watson.discovery.v1.model.Credentials; +import com.ibm.watson.discovery.v1.model.CredentialsList; +import com.ibm.watson.discovery.v1.model.DeleteAllTrainingDataOptions; +import com.ibm.watson.discovery.v1.model.DeleteCollectionOptions; +import com.ibm.watson.discovery.v1.model.DeleteCollectionResponse; +import com.ibm.watson.discovery.v1.model.DeleteConfigurationOptions; +import com.ibm.watson.discovery.v1.model.DeleteConfigurationResponse; +import com.ibm.watson.discovery.v1.model.DeleteCredentials; +import com.ibm.watson.discovery.v1.model.DeleteCredentialsOptions; +import com.ibm.watson.discovery.v1.model.DeleteDocumentOptions; +import com.ibm.watson.discovery.v1.model.DeleteDocumentResponse; +import com.ibm.watson.discovery.v1.model.DeleteEnvironmentOptions; +import com.ibm.watson.discovery.v1.model.DeleteEnvironmentResponse; +import com.ibm.watson.discovery.v1.model.DeleteExpansionsOptions; +import com.ibm.watson.discovery.v1.model.DeleteGatewayOptions; +import com.ibm.watson.discovery.v1.model.DeleteStopwordListOptions; +import com.ibm.watson.discovery.v1.model.DeleteTokenizationDictionaryOptions; +import com.ibm.watson.discovery.v1.model.DeleteTrainingDataOptions; +import com.ibm.watson.discovery.v1.model.DeleteTrainingExampleOptions; +import com.ibm.watson.discovery.v1.model.DeleteUserDataOptions; +import com.ibm.watson.discovery.v1.model.DocumentAccepted; +import com.ibm.watson.discovery.v1.model.DocumentStatus; +import com.ibm.watson.discovery.v1.model.Enrichment; +import com.ibm.watson.discovery.v1.model.EnrichmentOptions; +import com.ibm.watson.discovery.v1.model.Environment; +import com.ibm.watson.discovery.v1.model.EventData; +import com.ibm.watson.discovery.v1.model.Expansion; +import com.ibm.watson.discovery.v1.model.Expansions; +import com.ibm.watson.discovery.v1.model.FederatedQueryNoticesOptions; +import com.ibm.watson.discovery.v1.model.FederatedQueryOptions; +import com.ibm.watson.discovery.v1.model.FontSetting; +import com.ibm.watson.discovery.v1.model.Gateway; +import com.ibm.watson.discovery.v1.model.GatewayDelete; +import com.ibm.watson.discovery.v1.model.GatewayList; +import com.ibm.watson.discovery.v1.model.GetAutocompletionOptions; +import com.ibm.watson.discovery.v1.model.GetCollectionOptions; +import com.ibm.watson.discovery.v1.model.GetConfigurationOptions; +import com.ibm.watson.discovery.v1.model.GetCredentialsOptions; +import com.ibm.watson.discovery.v1.model.GetDocumentStatusOptions; +import com.ibm.watson.discovery.v1.model.GetEnvironmentOptions; +import com.ibm.watson.discovery.v1.model.GetGatewayOptions; +import com.ibm.watson.discovery.v1.model.GetMetricsEventRateOptions; +import com.ibm.watson.discovery.v1.model.GetMetricsQueryEventOptions; +import com.ibm.watson.discovery.v1.model.GetMetricsQueryNoResultsOptions; +import com.ibm.watson.discovery.v1.model.GetMetricsQueryOptions; +import com.ibm.watson.discovery.v1.model.GetMetricsQueryTokenEventOptions; +import com.ibm.watson.discovery.v1.model.GetStopwordListStatusOptions; +import com.ibm.watson.discovery.v1.model.GetTokenizationDictionaryStatusOptions; +import com.ibm.watson.discovery.v1.model.GetTrainingDataOptions; +import com.ibm.watson.discovery.v1.model.GetTrainingExampleOptions; +import com.ibm.watson.discovery.v1.model.HtmlSettings; +import com.ibm.watson.discovery.v1.model.ListCollectionFieldsOptions; +import com.ibm.watson.discovery.v1.model.ListCollectionFieldsResponse; +import com.ibm.watson.discovery.v1.model.ListCollectionsOptions; +import com.ibm.watson.discovery.v1.model.ListCollectionsResponse; +import com.ibm.watson.discovery.v1.model.ListConfigurationsOptions; +import com.ibm.watson.discovery.v1.model.ListConfigurationsResponse; +import com.ibm.watson.discovery.v1.model.ListCredentialsOptions; +import com.ibm.watson.discovery.v1.model.ListEnvironmentsOptions; +import com.ibm.watson.discovery.v1.model.ListEnvironmentsResponse; +import com.ibm.watson.discovery.v1.model.ListExpansionsOptions; +import com.ibm.watson.discovery.v1.model.ListFieldsOptions; +import com.ibm.watson.discovery.v1.model.ListGatewaysOptions; +import com.ibm.watson.discovery.v1.model.ListTrainingDataOptions; +import com.ibm.watson.discovery.v1.model.ListTrainingExamplesOptions; +import com.ibm.watson.discovery.v1.model.LogQueryResponse; +import com.ibm.watson.discovery.v1.model.MetricResponse; +import com.ibm.watson.discovery.v1.model.MetricTokenResponse; +import com.ibm.watson.discovery.v1.model.NluEnrichmentConcepts; +import com.ibm.watson.discovery.v1.model.NluEnrichmentEmotion; +import com.ibm.watson.discovery.v1.model.NluEnrichmentEntities; +import com.ibm.watson.discovery.v1.model.NluEnrichmentFeatures; +import com.ibm.watson.discovery.v1.model.NluEnrichmentKeywords; +import com.ibm.watson.discovery.v1.model.NluEnrichmentRelations; +import com.ibm.watson.discovery.v1.model.NluEnrichmentSemanticRoles; +import com.ibm.watson.discovery.v1.model.NluEnrichmentSentiment; +import com.ibm.watson.discovery.v1.model.NormalizationOperation; +import com.ibm.watson.discovery.v1.model.PdfHeadingDetection; +import com.ibm.watson.discovery.v1.model.PdfSettings; +import com.ibm.watson.discovery.v1.model.QueryLogOptions; +import com.ibm.watson.discovery.v1.model.QueryNoticesOptions; +import com.ibm.watson.discovery.v1.model.QueryNoticesResponse; +import com.ibm.watson.discovery.v1.model.QueryOptions; +import com.ibm.watson.discovery.v1.model.QueryResponse; +import com.ibm.watson.discovery.v1.model.SegmentSettings; +import com.ibm.watson.discovery.v1.model.Source; +import com.ibm.watson.discovery.v1.model.SourceOptions; +import com.ibm.watson.discovery.v1.model.SourceOptionsBuckets; +import com.ibm.watson.discovery.v1.model.SourceOptionsFolder; +import com.ibm.watson.discovery.v1.model.SourceOptionsObject; +import com.ibm.watson.discovery.v1.model.SourceOptionsSiteColl; +import com.ibm.watson.discovery.v1.model.SourceOptionsWebCrawl; +import com.ibm.watson.discovery.v1.model.SourceSchedule; +import com.ibm.watson.discovery.v1.model.TokenDictRule; +import com.ibm.watson.discovery.v1.model.TokenDictStatusResponse; +import com.ibm.watson.discovery.v1.model.TrainingDataSet; +import com.ibm.watson.discovery.v1.model.TrainingExample; +import com.ibm.watson.discovery.v1.model.TrainingExampleList; +import com.ibm.watson.discovery.v1.model.TrainingQuery; +import com.ibm.watson.discovery.v1.model.UpdateCollectionOptions; +import com.ibm.watson.discovery.v1.model.UpdateConfigurationOptions; +import com.ibm.watson.discovery.v1.model.UpdateCredentialsOptions; +import com.ibm.watson.discovery.v1.model.UpdateDocumentOptions; +import com.ibm.watson.discovery.v1.model.UpdateEnvironmentOptions; +import com.ibm.watson.discovery.v1.model.UpdateTrainingExampleOptions; +import com.ibm.watson.discovery.v1.model.WordHeadingDetection; +import com.ibm.watson.discovery.v1.model.WordSettings; +import com.ibm.watson.discovery.v1.model.WordStyle; +import com.ibm.watson.discovery.v1.model.XPathPatterns; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; +import okhttp3.mockwebserver.RecordedRequest; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +/** Unit test class for the Discovery service. */ +public class DiscoveryTest { + + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + protected MockWebServer server; + protected Discovery discoveryService; + + public void constructClientService() throws Throwable { + final String serviceName = "testService"; + // set mock values for global params + String version = "testString"; + + final Authenticator authenticator = new NoAuthAuthenticator(); + + discoveryService = new Discovery(version, serviceName, authenticator); + String url = server.url("/").toString(); + discoveryService.setServiceUrl(url); + } + + /** Negative Test - construct the service with a null authenticator. */ + @Test(expectedExceptions = IllegalArgumentException.class) + public void testConstructorWithNullAuthenticator() throws Throwable { + final String serviceName = "testService"; + // set mock values for global params + String version = "testString"; + + new Discovery(version, serviceName, null); + } + + @Test + public void testGetVersion() throws Throwable { + constructClientService(); + assertEquals(discoveryService.getVersion(), "testString"); + } + + @Test + public void testCreateEnvironmentWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"environment_id\": \"environmentId\", \"name\": \"name\", \"description\": \"description\", \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\", \"status\": \"active\", \"read_only\": true, \"size\": \"LT\", \"requested_size\": \"requestedSize\", \"index_capacity\": {\"documents\": {\"available\": 9, \"maximum_allowed\": 14}, \"disk_usage\": {\"used_bytes\": 9, \"maximum_allowed_bytes\": 19}, \"collections\": {\"available\": 9, \"maximum_allowed\": 14}}, \"search_status\": {\"scope\": \"scope\", \"status\": \"NO_DATA\", \"status_description\": \"statusDescription\", \"last_trained\": \"2019-01-01\"}}"; + String createEnvironmentPath = "/v1/environments"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(201) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the CreateEnvironmentOptions model + CreateEnvironmentOptions createEnvironmentOptionsModel = + new CreateEnvironmentOptions.Builder() + .name("testString") + .description("testString") + .size("LT") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.createEnvironment(createEnvironmentOptionsModel).execute(); + assertNotNull(response); + Environment responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createEnvironmentPath); + } + + // Test the createEnvironment operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateEnvironmentNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.createEnvironment(null).execute(); + } + + @Test + public void testListEnvironmentsWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"environments\": [{\"environment_id\": \"environmentId\", \"name\": \"name\", \"description\": \"description\", \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\", \"status\": \"active\", \"read_only\": true, \"size\": \"LT\", \"requested_size\": \"requestedSize\", \"index_capacity\": {\"documents\": {\"available\": 9, \"maximum_allowed\": 14}, \"disk_usage\": {\"used_bytes\": 9, \"maximum_allowed_bytes\": 19}, \"collections\": {\"available\": 9, \"maximum_allowed\": 14}}, \"search_status\": {\"scope\": \"scope\", \"status\": \"NO_DATA\", \"status_description\": \"statusDescription\", \"last_trained\": \"2019-01-01\"}}]}"; + String listEnvironmentsPath = "/v1/environments"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the ListEnvironmentsOptions model + ListEnvironmentsOptions listEnvironmentsOptionsModel = + new ListEnvironmentsOptions.Builder().name("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.listEnvironments(listEnvironmentsOptionsModel).execute(); + assertNotNull(response); + ListEnvironmentsResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(query.get("name"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listEnvironmentsPath); + } + + @Test + public void testGetEnvironmentWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"environment_id\": \"environmentId\", \"name\": \"name\", \"description\": \"description\", \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\", \"status\": \"active\", \"read_only\": true, \"size\": \"LT\", \"requested_size\": \"requestedSize\", \"index_capacity\": {\"documents\": {\"available\": 9, \"maximum_allowed\": 14}, \"disk_usage\": {\"used_bytes\": 9, \"maximum_allowed_bytes\": 19}, \"collections\": {\"available\": 9, \"maximum_allowed\": 14}}, \"search_status\": {\"scope\": \"scope\", \"status\": \"NO_DATA\", \"status_description\": \"statusDescription\", \"last_trained\": \"2019-01-01\"}}"; + String getEnvironmentPath = "/v1/environments/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the GetEnvironmentOptions model + GetEnvironmentOptions getEnvironmentOptionsModel = + new GetEnvironmentOptions.Builder().environmentId("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.getEnvironment(getEnvironmentOptionsModel).execute(); + assertNotNull(response); + Environment responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getEnvironmentPath); + } + + // Test the getEnvironment operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetEnvironmentNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.getEnvironment(null).execute(); + } + + @Test + public void testUpdateEnvironmentWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"environment_id\": \"environmentId\", \"name\": \"name\", \"description\": \"description\", \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\", \"status\": \"active\", \"read_only\": true, \"size\": \"LT\", \"requested_size\": \"requestedSize\", \"index_capacity\": {\"documents\": {\"available\": 9, \"maximum_allowed\": 14}, \"disk_usage\": {\"used_bytes\": 9, \"maximum_allowed_bytes\": 19}, \"collections\": {\"available\": 9, \"maximum_allowed\": 14}}, \"search_status\": {\"scope\": \"scope\", \"status\": \"NO_DATA\", \"status_description\": \"statusDescription\", \"last_trained\": \"2019-01-01\"}}"; + String updateEnvironmentPath = "/v1/environments/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the UpdateEnvironmentOptions model + UpdateEnvironmentOptions updateEnvironmentOptionsModel = + new UpdateEnvironmentOptions.Builder() + .environmentId("testString") + .name("testString") + .description("testString") + .size("S") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.updateEnvironment(updateEnvironmentOptionsModel).execute(); + assertNotNull(response); + Environment responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "PUT"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateEnvironmentPath); + } + + // Test the updateEnvironment operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateEnvironmentNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.updateEnvironment(null).execute(); + } + + @Test + public void testDeleteEnvironmentWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = "{\"environment_id\": \"environmentId\", \"status\": \"deleted\"}"; + String deleteEnvironmentPath = "/v1/environments/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the DeleteEnvironmentOptions model + DeleteEnvironmentOptions deleteEnvironmentOptionsModel = + new DeleteEnvironmentOptions.Builder().environmentId("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.deleteEnvironment(deleteEnvironmentOptionsModel).execute(); + assertNotNull(response); + DeleteEnvironmentResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteEnvironmentPath); + } + + // Test the deleteEnvironment operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteEnvironmentNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.deleteEnvironment(null).execute(); + } + + @Test + public void testListFieldsWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = "{\"fields\": [{\"field\": \"field\", \"type\": \"nested\"}]}"; + String listFieldsPath = "/v1/environments/testString/fields"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the ListFieldsOptions model + ListFieldsOptions listFieldsOptionsModel = + new ListFieldsOptions.Builder() + .environmentId("testString") + .collectionIds(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.listFields(listFieldsOptionsModel).execute(); + assertNotNull(response); + ListCollectionFieldsResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals( + query.get("collection_ids"), + RequestUtils.join( + new java.util.ArrayList(java.util.Arrays.asList("testString")), ",")); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listFieldsPath); + } + + // Test the listFields operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListFieldsNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.listFields(null).execute(); + } + + @Test + public void testCreateConfigurationWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"configuration_id\": \"configurationId\", \"name\": \"name\", \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\", \"description\": \"description\", \"conversions\": {\"pdf\": {\"heading\": {\"fonts\": [{\"level\": 5, \"min_size\": 7, \"max_size\": 7, \"bold\": true, \"italic\": true, \"name\": \"name\"}]}}, \"word\": {\"heading\": {\"fonts\": [{\"level\": 5, \"min_size\": 7, \"max_size\": 7, \"bold\": true, \"italic\": true, \"name\": \"name\"}], \"styles\": [{\"level\": 5, \"names\": [\"names\"]}]}}, \"html\": {\"exclude_tags_completely\": [\"excludeTagsCompletely\"], \"exclude_tags_keep_content\": [\"excludeTagsKeepContent\"], \"keep_content\": {\"xpaths\": [\"xpaths\"]}, \"exclude_content\": {\"xpaths\": [\"xpaths\"]}, \"keep_tag_attributes\": [\"keepTagAttributes\"], \"exclude_tag_attributes\": [\"excludeTagAttributes\"]}, \"segment\": {\"enabled\": false, \"selector_tags\": [\"selectorTags\"], \"annotated_fields\": [\"annotatedFields\"]}, \"json_normalizations\": [{\"operation\": \"copy\", \"source_field\": \"sourceField\", \"destination_field\": \"destinationField\"}], \"image_text_recognition\": true}, \"enrichments\": [{\"description\": \"description\", \"destination_field\": \"destinationField\", \"source_field\": \"sourceField\", \"overwrite\": false, \"enrichment\": \"enrichment\", \"ignore_downstream_errors\": true, \"options\": {\"features\": {\"keywords\": {\"sentiment\": false, \"emotion\": false, \"limit\": 5}, \"entities\": {\"sentiment\": false, \"emotion\": false, \"limit\": 5, \"mentions\": true, \"mention_types\": true, \"sentence_locations\": false, \"model\": \"model\"}, \"sentiment\": {\"document\": true, \"targets\": [\"target\"]}, \"emotion\": {\"document\": true, \"targets\": [\"target\"]}, \"categories\": {\"mapKey\": \"anyValue\"}, \"semantic_roles\": {\"entities\": true, \"keywords\": true, \"limit\": 5}, \"relations\": {\"model\": \"model\"}, \"concepts\": {\"limit\": 5}}, \"language\": \"ar\", \"model\": \"model\"}}], \"normalizations\": [{\"operation\": \"copy\", \"source_field\": \"sourceField\", \"destination_field\": \"destinationField\"}], \"source\": {\"type\": \"box\", \"credential_id\": \"credentialId\", \"schedule\": {\"enabled\": false, \"time_zone\": \"timeZone\", \"frequency\": \"daily\"}, \"options\": {\"folders\": [{\"owner_user_id\": \"ownerUserId\", \"folder_id\": \"folderId\", \"limit\": 5}], \"objects\": [{\"name\": \"name\", \"limit\": 5}], \"site_collections\": [{\"site_collection_path\": \"siteCollectionPath\", \"limit\": 5}], \"urls\": [{\"url\": \"url\", \"limit_to_starting_hosts\": true, \"crawl_speed\": \"gentle\", \"allow_untrusted_certificate\": false, \"maximum_hops\": 11, \"request_timeout\": 14, \"override_robots_txt\": false, \"blacklist\": [\"blacklist\"]}], \"buckets\": [{\"name\": \"name\", \"limit\": 5}], \"crawl_all_buckets\": false}}}"; + String createConfigurationPath = "/v1/environments/testString/configurations"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(201) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the FontSetting model + FontSetting fontSettingModel = + new FontSetting.Builder() + .level(Long.valueOf("26")) + .minSize(Long.valueOf("26")) + .maxSize(Long.valueOf("26")) + .bold(true) + .italic(true) + .name("testString") + .build(); + + // Construct an instance of the PdfHeadingDetection model + PdfHeadingDetection pdfHeadingDetectionModel = + new PdfHeadingDetection.Builder() + .fonts(new java.util.ArrayList(java.util.Arrays.asList(fontSettingModel))) + .build(); + + // Construct an instance of the PdfSettings model + PdfSettings pdfSettingsModel = + new PdfSettings.Builder().heading(pdfHeadingDetectionModel).build(); + + // Construct an instance of the WordStyle model + WordStyle wordStyleModel = + new WordStyle.Builder() + .level(Long.valueOf("26")) + .names(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + + // Construct an instance of the WordHeadingDetection model + WordHeadingDetection wordHeadingDetectionModel = + new WordHeadingDetection.Builder() + .fonts(new java.util.ArrayList(java.util.Arrays.asList(fontSettingModel))) + .styles(new java.util.ArrayList(java.util.Arrays.asList(wordStyleModel))) + .build(); + + // Construct an instance of the WordSettings model + WordSettings wordSettingsModel = + new WordSettings.Builder().heading(wordHeadingDetectionModel).build(); + + // Construct an instance of the XPathPatterns model + XPathPatterns xPathPatternsModel = + new XPathPatterns.Builder() + .xpaths(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + + // Construct an instance of the HtmlSettings model + HtmlSettings htmlSettingsModel = + new HtmlSettings.Builder() + .excludeTagsCompletely( + new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .excludeTagsKeepContent( + new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .keepContent(xPathPatternsModel) + .excludeContent(xPathPatternsModel) + .keepTagAttributes( + new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .excludeTagAttributes( + new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + + // Construct an instance of the SegmentSettings model + SegmentSettings segmentSettingsModel = + new SegmentSettings.Builder() + .enabled(true) + .selectorTags(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .annotatedFields(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + + // Construct an instance of the NormalizationOperation model + NormalizationOperation normalizationOperationModel = + new NormalizationOperation.Builder() + .operation("copy") + .sourceField("testString") + .destinationField("testString") + .build(); + + // Construct an instance of the Conversions model + Conversions conversionsModel = + new Conversions.Builder() + .pdf(pdfSettingsModel) + .word(wordSettingsModel) + .html(htmlSettingsModel) + .segment(segmentSettingsModel) + .jsonNormalizations( + new java.util.ArrayList( + java.util.Arrays.asList(normalizationOperationModel))) + .imageTextRecognition(true) + .build(); + + // Construct an instance of the NluEnrichmentKeywords model + NluEnrichmentKeywords nluEnrichmentKeywordsModel = + new NluEnrichmentKeywords.Builder() + .sentiment(true) + .emotion(true) + .limit(Long.valueOf("26")) + .build(); + + // Construct an instance of the NluEnrichmentEntities model + NluEnrichmentEntities nluEnrichmentEntitiesModel = + new NluEnrichmentEntities.Builder() + .sentiment(true) + .emotion(true) + .limit(Long.valueOf("26")) + .mentions(true) + .mentionTypes(true) + .sentenceLocations(true) + .model("testString") + .build(); + + // Construct an instance of the NluEnrichmentSentiment model + NluEnrichmentSentiment nluEnrichmentSentimentModel = + new NluEnrichmentSentiment.Builder() + .document(true) + .targets(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + + // Construct an instance of the NluEnrichmentEmotion model + NluEnrichmentEmotion nluEnrichmentEmotionModel = + new NluEnrichmentEmotion.Builder() + .document(true) + .targets(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + + // Construct an instance of the NluEnrichmentSemanticRoles model + NluEnrichmentSemanticRoles nluEnrichmentSemanticRolesModel = + new NluEnrichmentSemanticRoles.Builder() + .entities(true) + .keywords(true) + .limit(Long.valueOf("26")) + .build(); + + // Construct an instance of the NluEnrichmentRelations model + NluEnrichmentRelations nluEnrichmentRelationsModel = + new NluEnrichmentRelations.Builder().model("testString").build(); + + // Construct an instance of the NluEnrichmentConcepts model + NluEnrichmentConcepts nluEnrichmentConceptsModel = + new NluEnrichmentConcepts.Builder().limit(Long.valueOf("26")).build(); + + // Construct an instance of the NluEnrichmentFeatures model + NluEnrichmentFeatures nluEnrichmentFeaturesModel = + new NluEnrichmentFeatures.Builder() + .keywords(nluEnrichmentKeywordsModel) + .entities(nluEnrichmentEntitiesModel) + .sentiment(nluEnrichmentSentimentModel) + .emotion(nluEnrichmentEmotionModel) + .categories( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .semanticRoles(nluEnrichmentSemanticRolesModel) + .relations(nluEnrichmentRelationsModel) + .concepts(nluEnrichmentConceptsModel) + .build(); + + // Construct an instance of the EnrichmentOptions model + EnrichmentOptions enrichmentOptionsModel = + new EnrichmentOptions.Builder() + .features(nluEnrichmentFeaturesModel) + .language("ar") + .model("testString") + .build(); + + // Construct an instance of the Enrichment model + Enrichment enrichmentModel = + new Enrichment.Builder() + .description("testString") + .destinationField("testString") + .sourceField("testString") + .overwrite(true) + .enrichment("testString") + .ignoreDownstreamErrors(true) + .options(enrichmentOptionsModel) + .build(); + + // Construct an instance of the SourceSchedule model + SourceSchedule sourceScheduleModel = + new SourceSchedule.Builder() + .enabled(true) + .timeZone("testString") + .frequency("daily") + .build(); + + // Construct an instance of the SourceOptionsFolder model + SourceOptionsFolder sourceOptionsFolderModel = + new SourceOptionsFolder.Builder() + .ownerUserId("testString") + .folderId("testString") + .limit(Long.valueOf("26")) + .build(); + + // Construct an instance of the SourceOptionsObject model + SourceOptionsObject sourceOptionsObjectModel = + new SourceOptionsObject.Builder().name("testString").limit(Long.valueOf("26")).build(); + + // Construct an instance of the SourceOptionsSiteColl model + SourceOptionsSiteColl sourceOptionsSiteCollModel = + new SourceOptionsSiteColl.Builder() + .siteCollectionPath("testString") + .limit(Long.valueOf("26")) + .build(); + + // Construct an instance of the SourceOptionsWebCrawl model + SourceOptionsWebCrawl sourceOptionsWebCrawlModel = + new SourceOptionsWebCrawl.Builder() + .url("testString") + .limitToStartingHosts(true) + .crawlSpeed("gentle") + .allowUntrustedCertificate(true) + .maximumHops(Long.valueOf("26")) + .requestTimeout(Long.valueOf("26")) + .overrideRobotsTxt(true) + .blacklist(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + + // Construct an instance of the SourceOptionsBuckets model + SourceOptionsBuckets sourceOptionsBucketsModel = + new SourceOptionsBuckets.Builder().name("testString").limit(Long.valueOf("26")).build(); + + // Construct an instance of the SourceOptions model + SourceOptions sourceOptionsModel = + new SourceOptions.Builder() + .folders( + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsFolderModel))) + .objects( + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsObjectModel))) + .siteCollections( + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsSiteCollModel))) + .urls( + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsWebCrawlModel))) + .buckets( + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsBucketsModel))) + .crawlAllBuckets(true) + .build(); + + // Construct an instance of the Source model + Source sourceModel = + new Source.Builder() + .type("box") + .credentialId("testString") + .schedule(sourceScheduleModel) + .options(sourceOptionsModel) + .build(); + + // Construct an instance of the CreateConfigurationOptions model + CreateConfigurationOptions createConfigurationOptionsModel = + new CreateConfigurationOptions.Builder() + .environmentId("testString") + .name("testString") + .description("testString") + .conversions(conversionsModel) + .enrichments( + new java.util.ArrayList(java.util.Arrays.asList(enrichmentModel))) + .normalizations( + new java.util.ArrayList( + java.util.Arrays.asList(normalizationOperationModel))) + .source(sourceModel) + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.createConfiguration(createConfigurationOptionsModel).execute(); + assertNotNull(response); + Configuration responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createConfigurationPath); + } + + // Test the createConfiguration operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateConfigurationNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.createConfiguration(null).execute(); + } + + @Test + public void testListConfigurationsWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"configurations\": [{\"configuration_id\": \"configurationId\", \"name\": \"name\", \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\", \"description\": \"description\", \"conversions\": {\"pdf\": {\"heading\": {\"fonts\": [{\"level\": 5, \"min_size\": 7, \"max_size\": 7, \"bold\": true, \"italic\": true, \"name\": \"name\"}]}}, \"word\": {\"heading\": {\"fonts\": [{\"level\": 5, \"min_size\": 7, \"max_size\": 7, \"bold\": true, \"italic\": true, \"name\": \"name\"}], \"styles\": [{\"level\": 5, \"names\": [\"names\"]}]}}, \"html\": {\"exclude_tags_completely\": [\"excludeTagsCompletely\"], \"exclude_tags_keep_content\": [\"excludeTagsKeepContent\"], \"keep_content\": {\"xpaths\": [\"xpaths\"]}, \"exclude_content\": {\"xpaths\": [\"xpaths\"]}, \"keep_tag_attributes\": [\"keepTagAttributes\"], \"exclude_tag_attributes\": [\"excludeTagAttributes\"]}, \"segment\": {\"enabled\": false, \"selector_tags\": [\"selectorTags\"], \"annotated_fields\": [\"annotatedFields\"]}, \"json_normalizations\": [{\"operation\": \"copy\", \"source_field\": \"sourceField\", \"destination_field\": \"destinationField\"}], \"image_text_recognition\": true}, \"enrichments\": [{\"description\": \"description\", \"destination_field\": \"destinationField\", \"source_field\": \"sourceField\", \"overwrite\": false, \"enrichment\": \"enrichment\", \"ignore_downstream_errors\": true, \"options\": {\"features\": {\"keywords\": {\"sentiment\": false, \"emotion\": false, \"limit\": 5}, \"entities\": {\"sentiment\": false, \"emotion\": false, \"limit\": 5, \"mentions\": true, \"mention_types\": true, \"sentence_locations\": false, \"model\": \"model\"}, \"sentiment\": {\"document\": true, \"targets\": [\"target\"]}, \"emotion\": {\"document\": true, \"targets\": [\"target\"]}, \"categories\": {\"mapKey\": \"anyValue\"}, \"semantic_roles\": {\"entities\": true, \"keywords\": true, \"limit\": 5}, \"relations\": {\"model\": \"model\"}, \"concepts\": {\"limit\": 5}}, \"language\": \"ar\", \"model\": \"model\"}}], \"normalizations\": [{\"operation\": \"copy\", \"source_field\": \"sourceField\", \"destination_field\": \"destinationField\"}], \"source\": {\"type\": \"box\", \"credential_id\": \"credentialId\", \"schedule\": {\"enabled\": false, \"time_zone\": \"timeZone\", \"frequency\": \"daily\"}, \"options\": {\"folders\": [{\"owner_user_id\": \"ownerUserId\", \"folder_id\": \"folderId\", \"limit\": 5}], \"objects\": [{\"name\": \"name\", \"limit\": 5}], \"site_collections\": [{\"site_collection_path\": \"siteCollectionPath\", \"limit\": 5}], \"urls\": [{\"url\": \"url\", \"limit_to_starting_hosts\": true, \"crawl_speed\": \"gentle\", \"allow_untrusted_certificate\": false, \"maximum_hops\": 11, \"request_timeout\": 14, \"override_robots_txt\": false, \"blacklist\": [\"blacklist\"]}], \"buckets\": [{\"name\": \"name\", \"limit\": 5}], \"crawl_all_buckets\": false}}}]}"; + String listConfigurationsPath = "/v1/environments/testString/configurations"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the ListConfigurationsOptions model + ListConfigurationsOptions listConfigurationsOptionsModel = + new ListConfigurationsOptions.Builder() + .environmentId("testString") + .name("testString") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.listConfigurations(listConfigurationsOptionsModel).execute(); + assertNotNull(response); + ListConfigurationsResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(query.get("name"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listConfigurationsPath); + } + + // Test the listConfigurations operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListConfigurationsNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.listConfigurations(null).execute(); + } + + @Test + public void testGetConfigurationWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"configuration_id\": \"configurationId\", \"name\": \"name\", \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\", \"description\": \"description\", \"conversions\": {\"pdf\": {\"heading\": {\"fonts\": [{\"level\": 5, \"min_size\": 7, \"max_size\": 7, \"bold\": true, \"italic\": true, \"name\": \"name\"}]}}, \"word\": {\"heading\": {\"fonts\": [{\"level\": 5, \"min_size\": 7, \"max_size\": 7, \"bold\": true, \"italic\": true, \"name\": \"name\"}], \"styles\": [{\"level\": 5, \"names\": [\"names\"]}]}}, \"html\": {\"exclude_tags_completely\": [\"excludeTagsCompletely\"], \"exclude_tags_keep_content\": [\"excludeTagsKeepContent\"], \"keep_content\": {\"xpaths\": [\"xpaths\"]}, \"exclude_content\": {\"xpaths\": [\"xpaths\"]}, \"keep_tag_attributes\": [\"keepTagAttributes\"], \"exclude_tag_attributes\": [\"excludeTagAttributes\"]}, \"segment\": {\"enabled\": false, \"selector_tags\": [\"selectorTags\"], \"annotated_fields\": [\"annotatedFields\"]}, \"json_normalizations\": [{\"operation\": \"copy\", \"source_field\": \"sourceField\", \"destination_field\": \"destinationField\"}], \"image_text_recognition\": true}, \"enrichments\": [{\"description\": \"description\", \"destination_field\": \"destinationField\", \"source_field\": \"sourceField\", \"overwrite\": false, \"enrichment\": \"enrichment\", \"ignore_downstream_errors\": true, \"options\": {\"features\": {\"keywords\": {\"sentiment\": false, \"emotion\": false, \"limit\": 5}, \"entities\": {\"sentiment\": false, \"emotion\": false, \"limit\": 5, \"mentions\": true, \"mention_types\": true, \"sentence_locations\": false, \"model\": \"model\"}, \"sentiment\": {\"document\": true, \"targets\": [\"target\"]}, \"emotion\": {\"document\": true, \"targets\": [\"target\"]}, \"categories\": {\"mapKey\": \"anyValue\"}, \"semantic_roles\": {\"entities\": true, \"keywords\": true, \"limit\": 5}, \"relations\": {\"model\": \"model\"}, \"concepts\": {\"limit\": 5}}, \"language\": \"ar\", \"model\": \"model\"}}], \"normalizations\": [{\"operation\": \"copy\", \"source_field\": \"sourceField\", \"destination_field\": \"destinationField\"}], \"source\": {\"type\": \"box\", \"credential_id\": \"credentialId\", \"schedule\": {\"enabled\": false, \"time_zone\": \"timeZone\", \"frequency\": \"daily\"}, \"options\": {\"folders\": [{\"owner_user_id\": \"ownerUserId\", \"folder_id\": \"folderId\", \"limit\": 5}], \"objects\": [{\"name\": \"name\", \"limit\": 5}], \"site_collections\": [{\"site_collection_path\": \"siteCollectionPath\", \"limit\": 5}], \"urls\": [{\"url\": \"url\", \"limit_to_starting_hosts\": true, \"crawl_speed\": \"gentle\", \"allow_untrusted_certificate\": false, \"maximum_hops\": 11, \"request_timeout\": 14, \"override_robots_txt\": false, \"blacklist\": [\"blacklist\"]}], \"buckets\": [{\"name\": \"name\", \"limit\": 5}], \"crawl_all_buckets\": false}}}"; + String getConfigurationPath = "/v1/environments/testString/configurations/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the GetConfigurationOptions model + GetConfigurationOptions getConfigurationOptionsModel = + new GetConfigurationOptions.Builder() + .environmentId("testString") + .configurationId("testString") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.getConfiguration(getConfigurationOptionsModel).execute(); + assertNotNull(response); + Configuration responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getConfigurationPath); + } + + // Test the getConfiguration operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetConfigurationNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.getConfiguration(null).execute(); + } + + @Test + public void testUpdateConfigurationWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"configuration_id\": \"configurationId\", \"name\": \"name\", \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\", \"description\": \"description\", \"conversions\": {\"pdf\": {\"heading\": {\"fonts\": [{\"level\": 5, \"min_size\": 7, \"max_size\": 7, \"bold\": true, \"italic\": true, \"name\": \"name\"}]}}, \"word\": {\"heading\": {\"fonts\": [{\"level\": 5, \"min_size\": 7, \"max_size\": 7, \"bold\": true, \"italic\": true, \"name\": \"name\"}], \"styles\": [{\"level\": 5, \"names\": [\"names\"]}]}}, \"html\": {\"exclude_tags_completely\": [\"excludeTagsCompletely\"], \"exclude_tags_keep_content\": [\"excludeTagsKeepContent\"], \"keep_content\": {\"xpaths\": [\"xpaths\"]}, \"exclude_content\": {\"xpaths\": [\"xpaths\"]}, \"keep_tag_attributes\": [\"keepTagAttributes\"], \"exclude_tag_attributes\": [\"excludeTagAttributes\"]}, \"segment\": {\"enabled\": false, \"selector_tags\": [\"selectorTags\"], \"annotated_fields\": [\"annotatedFields\"]}, \"json_normalizations\": [{\"operation\": \"copy\", \"source_field\": \"sourceField\", \"destination_field\": \"destinationField\"}], \"image_text_recognition\": true}, \"enrichments\": [{\"description\": \"description\", \"destination_field\": \"destinationField\", \"source_field\": \"sourceField\", \"overwrite\": false, \"enrichment\": \"enrichment\", \"ignore_downstream_errors\": true, \"options\": {\"features\": {\"keywords\": {\"sentiment\": false, \"emotion\": false, \"limit\": 5}, \"entities\": {\"sentiment\": false, \"emotion\": false, \"limit\": 5, \"mentions\": true, \"mention_types\": true, \"sentence_locations\": false, \"model\": \"model\"}, \"sentiment\": {\"document\": true, \"targets\": [\"target\"]}, \"emotion\": {\"document\": true, \"targets\": [\"target\"]}, \"categories\": {\"mapKey\": \"anyValue\"}, \"semantic_roles\": {\"entities\": true, \"keywords\": true, \"limit\": 5}, \"relations\": {\"model\": \"model\"}, \"concepts\": {\"limit\": 5}}, \"language\": \"ar\", \"model\": \"model\"}}], \"normalizations\": [{\"operation\": \"copy\", \"source_field\": \"sourceField\", \"destination_field\": \"destinationField\"}], \"source\": {\"type\": \"box\", \"credential_id\": \"credentialId\", \"schedule\": {\"enabled\": false, \"time_zone\": \"timeZone\", \"frequency\": \"daily\"}, \"options\": {\"folders\": [{\"owner_user_id\": \"ownerUserId\", \"folder_id\": \"folderId\", \"limit\": 5}], \"objects\": [{\"name\": \"name\", \"limit\": 5}], \"site_collections\": [{\"site_collection_path\": \"siteCollectionPath\", \"limit\": 5}], \"urls\": [{\"url\": \"url\", \"limit_to_starting_hosts\": true, \"crawl_speed\": \"gentle\", \"allow_untrusted_certificate\": false, \"maximum_hops\": 11, \"request_timeout\": 14, \"override_robots_txt\": false, \"blacklist\": [\"blacklist\"]}], \"buckets\": [{\"name\": \"name\", \"limit\": 5}], \"crawl_all_buckets\": false}}}"; + String updateConfigurationPath = "/v1/environments/testString/configurations/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the FontSetting model + FontSetting fontSettingModel = + new FontSetting.Builder() + .level(Long.valueOf("26")) + .minSize(Long.valueOf("26")) + .maxSize(Long.valueOf("26")) + .bold(true) + .italic(true) + .name("testString") + .build(); + + // Construct an instance of the PdfHeadingDetection model + PdfHeadingDetection pdfHeadingDetectionModel = + new PdfHeadingDetection.Builder() + .fonts(new java.util.ArrayList(java.util.Arrays.asList(fontSettingModel))) + .build(); + + // Construct an instance of the PdfSettings model + PdfSettings pdfSettingsModel = + new PdfSettings.Builder().heading(pdfHeadingDetectionModel).build(); + + // Construct an instance of the WordStyle model + WordStyle wordStyleModel = + new WordStyle.Builder() + .level(Long.valueOf("26")) + .names(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + + // Construct an instance of the WordHeadingDetection model + WordHeadingDetection wordHeadingDetectionModel = + new WordHeadingDetection.Builder() + .fonts(new java.util.ArrayList(java.util.Arrays.asList(fontSettingModel))) + .styles(new java.util.ArrayList(java.util.Arrays.asList(wordStyleModel))) + .build(); + + // Construct an instance of the WordSettings model + WordSettings wordSettingsModel = + new WordSettings.Builder().heading(wordHeadingDetectionModel).build(); + + // Construct an instance of the XPathPatterns model + XPathPatterns xPathPatternsModel = + new XPathPatterns.Builder() + .xpaths(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + + // Construct an instance of the HtmlSettings model + HtmlSettings htmlSettingsModel = + new HtmlSettings.Builder() + .excludeTagsCompletely( + new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .excludeTagsKeepContent( + new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .keepContent(xPathPatternsModel) + .excludeContent(xPathPatternsModel) + .keepTagAttributes( + new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .excludeTagAttributes( + new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + + // Construct an instance of the SegmentSettings model + SegmentSettings segmentSettingsModel = + new SegmentSettings.Builder() + .enabled(true) + .selectorTags(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .annotatedFields(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + + // Construct an instance of the NormalizationOperation model + NormalizationOperation normalizationOperationModel = + new NormalizationOperation.Builder() + .operation("copy") + .sourceField("testString") + .destinationField("testString") + .build(); + + // Construct an instance of the Conversions model + Conversions conversionsModel = + new Conversions.Builder() + .pdf(pdfSettingsModel) + .word(wordSettingsModel) + .html(htmlSettingsModel) + .segment(segmentSettingsModel) + .jsonNormalizations( + new java.util.ArrayList( + java.util.Arrays.asList(normalizationOperationModel))) + .imageTextRecognition(true) + .build(); + + // Construct an instance of the NluEnrichmentKeywords model + NluEnrichmentKeywords nluEnrichmentKeywordsModel = + new NluEnrichmentKeywords.Builder() + .sentiment(true) + .emotion(true) + .limit(Long.valueOf("26")) + .build(); + + // Construct an instance of the NluEnrichmentEntities model + NluEnrichmentEntities nluEnrichmentEntitiesModel = + new NluEnrichmentEntities.Builder() + .sentiment(true) + .emotion(true) + .limit(Long.valueOf("26")) + .mentions(true) + .mentionTypes(true) + .sentenceLocations(true) + .model("testString") + .build(); + + // Construct an instance of the NluEnrichmentSentiment model + NluEnrichmentSentiment nluEnrichmentSentimentModel = + new NluEnrichmentSentiment.Builder() + .document(true) + .targets(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + + // Construct an instance of the NluEnrichmentEmotion model + NluEnrichmentEmotion nluEnrichmentEmotionModel = + new NluEnrichmentEmotion.Builder() + .document(true) + .targets(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + + // Construct an instance of the NluEnrichmentSemanticRoles model + NluEnrichmentSemanticRoles nluEnrichmentSemanticRolesModel = + new NluEnrichmentSemanticRoles.Builder() + .entities(true) + .keywords(true) + .limit(Long.valueOf("26")) + .build(); + + // Construct an instance of the NluEnrichmentRelations model + NluEnrichmentRelations nluEnrichmentRelationsModel = + new NluEnrichmentRelations.Builder().model("testString").build(); + + // Construct an instance of the NluEnrichmentConcepts model + NluEnrichmentConcepts nluEnrichmentConceptsModel = + new NluEnrichmentConcepts.Builder().limit(Long.valueOf("26")).build(); + + // Construct an instance of the NluEnrichmentFeatures model + NluEnrichmentFeatures nluEnrichmentFeaturesModel = + new NluEnrichmentFeatures.Builder() + .keywords(nluEnrichmentKeywordsModel) + .entities(nluEnrichmentEntitiesModel) + .sentiment(nluEnrichmentSentimentModel) + .emotion(nluEnrichmentEmotionModel) + .categories( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .semanticRoles(nluEnrichmentSemanticRolesModel) + .relations(nluEnrichmentRelationsModel) + .concepts(nluEnrichmentConceptsModel) + .build(); + + // Construct an instance of the EnrichmentOptions model + EnrichmentOptions enrichmentOptionsModel = + new EnrichmentOptions.Builder() + .features(nluEnrichmentFeaturesModel) + .language("ar") + .model("testString") + .build(); + + // Construct an instance of the Enrichment model + Enrichment enrichmentModel = + new Enrichment.Builder() + .description("testString") + .destinationField("testString") + .sourceField("testString") + .overwrite(true) + .enrichment("testString") + .ignoreDownstreamErrors(true) + .options(enrichmentOptionsModel) + .build(); + + // Construct an instance of the SourceSchedule model + SourceSchedule sourceScheduleModel = + new SourceSchedule.Builder() + .enabled(true) + .timeZone("testString") + .frequency("daily") + .build(); + + // Construct an instance of the SourceOptionsFolder model + SourceOptionsFolder sourceOptionsFolderModel = + new SourceOptionsFolder.Builder() + .ownerUserId("testString") + .folderId("testString") + .limit(Long.valueOf("26")) + .build(); + + // Construct an instance of the SourceOptionsObject model + SourceOptionsObject sourceOptionsObjectModel = + new SourceOptionsObject.Builder().name("testString").limit(Long.valueOf("26")).build(); + + // Construct an instance of the SourceOptionsSiteColl model + SourceOptionsSiteColl sourceOptionsSiteCollModel = + new SourceOptionsSiteColl.Builder() + .siteCollectionPath("testString") + .limit(Long.valueOf("26")) + .build(); + + // Construct an instance of the SourceOptionsWebCrawl model + SourceOptionsWebCrawl sourceOptionsWebCrawlModel = + new SourceOptionsWebCrawl.Builder() + .url("testString") + .limitToStartingHosts(true) + .crawlSpeed("gentle") + .allowUntrustedCertificate(true) + .maximumHops(Long.valueOf("26")) + .requestTimeout(Long.valueOf("26")) + .overrideRobotsTxt(true) + .blacklist(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + + // Construct an instance of the SourceOptionsBuckets model + SourceOptionsBuckets sourceOptionsBucketsModel = + new SourceOptionsBuckets.Builder().name("testString").limit(Long.valueOf("26")).build(); + + // Construct an instance of the SourceOptions model + SourceOptions sourceOptionsModel = + new SourceOptions.Builder() + .folders( + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsFolderModel))) + .objects( + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsObjectModel))) + .siteCollections( + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsSiteCollModel))) + .urls( + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsWebCrawlModel))) + .buckets( + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsBucketsModel))) + .crawlAllBuckets(true) + .build(); + + // Construct an instance of the Source model + Source sourceModel = + new Source.Builder() + .type("box") + .credentialId("testString") + .schedule(sourceScheduleModel) + .options(sourceOptionsModel) + .build(); + + // Construct an instance of the UpdateConfigurationOptions model + UpdateConfigurationOptions updateConfigurationOptionsModel = + new UpdateConfigurationOptions.Builder() + .environmentId("testString") + .configurationId("testString") + .name("testString") + .description("testString") + .conversions(conversionsModel) + .enrichments( + new java.util.ArrayList(java.util.Arrays.asList(enrichmentModel))) + .normalizations( + new java.util.ArrayList( + java.util.Arrays.asList(normalizationOperationModel))) + .source(sourceModel) + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.updateConfiguration(updateConfigurationOptionsModel).execute(); + assertNotNull(response); + Configuration responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "PUT"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateConfigurationPath); + } + + // Test the updateConfiguration operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateConfigurationNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.updateConfiguration(null).execute(); + } + + @Test + public void testDeleteConfigurationWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"configuration_id\": \"configurationId\", \"status\": \"deleted\", \"notices\": [{\"notice_id\": \"noticeId\", \"created\": \"2019-01-01T12:00:00\", \"document_id\": \"documentId\", \"query_id\": \"queryId\", \"severity\": \"warning\", \"step\": \"step\", \"description\": \"description\"}]}"; + String deleteConfigurationPath = "/v1/environments/testString/configurations/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the DeleteConfigurationOptions model + DeleteConfigurationOptions deleteConfigurationOptionsModel = + new DeleteConfigurationOptions.Builder() + .environmentId("testString") + .configurationId("testString") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.deleteConfiguration(deleteConfigurationOptionsModel).execute(); + assertNotNull(response); + DeleteConfigurationResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteConfigurationPath); + } + + // Test the deleteConfiguration operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteConfigurationNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.deleteConfiguration(null).execute(); + } + + @Test + public void testCreateCollectionWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"collection_id\": \"collectionId\", \"name\": \"name\", \"description\": \"description\", \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\", \"status\": \"active\", \"configuration_id\": \"configurationId\", \"language\": \"language\", \"document_counts\": {\"available\": 9, \"processing\": 10, \"failed\": 6, \"pending\": 7}, \"disk_usage\": {\"used_bytes\": 9}, \"training_status\": {\"total_examples\": 13, \"available\": false, \"processing\": true, \"minimum_queries_added\": false, \"minimum_examples_added\": true, \"sufficient_label_diversity\": true, \"notices\": 7, \"successfully_trained\": \"2019-01-01T12:00:00\", \"data_updated\": \"2019-01-01T12:00:00\"}, \"crawl_status\": {\"source_crawl\": {\"status\": \"running\", \"next_crawl\": \"2019-01-01T12:00:00\"}}, \"smart_document_understanding\": {\"enabled\": false, \"total_annotated_pages\": 19, \"total_pages\": 10, \"total_documents\": 14, \"custom_fields\": {\"defined\": 7, \"maximum_allowed\": 14}}}"; + String createCollectionPath = "/v1/environments/testString/collections"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(201) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the CreateCollectionOptions model + CreateCollectionOptions createCollectionOptionsModel = + new CreateCollectionOptions.Builder() + .environmentId("testString") + .name("testString") + .description("testString") + .configurationId("testString") + .language("en") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.createCollection(createCollectionOptionsModel).execute(); + assertNotNull(response); + Collection responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createCollectionPath); + } + + // Test the createCollection operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateCollectionNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.createCollection(null).execute(); + } + + @Test + public void testListCollectionsWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"collections\": [{\"collection_id\": \"collectionId\", \"name\": \"name\", \"description\": \"description\", \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\", \"status\": \"active\", \"configuration_id\": \"configurationId\", \"language\": \"language\", \"document_counts\": {\"available\": 9, \"processing\": 10, \"failed\": 6, \"pending\": 7}, \"disk_usage\": {\"used_bytes\": 9}, \"training_status\": {\"total_examples\": 13, \"available\": false, \"processing\": true, \"minimum_queries_added\": false, \"minimum_examples_added\": true, \"sufficient_label_diversity\": true, \"notices\": 7, \"successfully_trained\": \"2019-01-01T12:00:00\", \"data_updated\": \"2019-01-01T12:00:00\"}, \"crawl_status\": {\"source_crawl\": {\"status\": \"running\", \"next_crawl\": \"2019-01-01T12:00:00\"}}, \"smart_document_understanding\": {\"enabled\": false, \"total_annotated_pages\": 19, \"total_pages\": 10, \"total_documents\": 14, \"custom_fields\": {\"defined\": 7, \"maximum_allowed\": 14}}}]}"; + String listCollectionsPath = "/v1/environments/testString/collections"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the ListCollectionsOptions model + ListCollectionsOptions listCollectionsOptionsModel = + new ListCollectionsOptions.Builder().environmentId("testString").name("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.listCollections(listCollectionsOptionsModel).execute(); + assertNotNull(response); + ListCollectionsResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(query.get("name"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listCollectionsPath); + } + + // Test the listCollections operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListCollectionsNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.listCollections(null).execute(); + } + + @Test + public void testGetCollectionWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"collection_id\": \"collectionId\", \"name\": \"name\", \"description\": \"description\", \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\", \"status\": \"active\", \"configuration_id\": \"configurationId\", \"language\": \"language\", \"document_counts\": {\"available\": 9, \"processing\": 10, \"failed\": 6, \"pending\": 7}, \"disk_usage\": {\"used_bytes\": 9}, \"training_status\": {\"total_examples\": 13, \"available\": false, \"processing\": true, \"minimum_queries_added\": false, \"minimum_examples_added\": true, \"sufficient_label_diversity\": true, \"notices\": 7, \"successfully_trained\": \"2019-01-01T12:00:00\", \"data_updated\": \"2019-01-01T12:00:00\"}, \"crawl_status\": {\"source_crawl\": {\"status\": \"running\", \"next_crawl\": \"2019-01-01T12:00:00\"}}, \"smart_document_understanding\": {\"enabled\": false, \"total_annotated_pages\": 19, \"total_pages\": 10, \"total_documents\": 14, \"custom_fields\": {\"defined\": 7, \"maximum_allowed\": 14}}}"; + String getCollectionPath = "/v1/environments/testString/collections/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the GetCollectionOptions model + GetCollectionOptions getCollectionOptionsModel = + new GetCollectionOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.getCollection(getCollectionOptionsModel).execute(); + assertNotNull(response); + Collection responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getCollectionPath); + } + + // Test the getCollection operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetCollectionNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.getCollection(null).execute(); + } + + @Test + public void testUpdateCollectionWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"collection_id\": \"collectionId\", \"name\": \"name\", \"description\": \"description\", \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\", \"status\": \"active\", \"configuration_id\": \"configurationId\", \"language\": \"language\", \"document_counts\": {\"available\": 9, \"processing\": 10, \"failed\": 6, \"pending\": 7}, \"disk_usage\": {\"used_bytes\": 9}, \"training_status\": {\"total_examples\": 13, \"available\": false, \"processing\": true, \"minimum_queries_added\": false, \"minimum_examples_added\": true, \"sufficient_label_diversity\": true, \"notices\": 7, \"successfully_trained\": \"2019-01-01T12:00:00\", \"data_updated\": \"2019-01-01T12:00:00\"}, \"crawl_status\": {\"source_crawl\": {\"status\": \"running\", \"next_crawl\": \"2019-01-01T12:00:00\"}}, \"smart_document_understanding\": {\"enabled\": false, \"total_annotated_pages\": 19, \"total_pages\": 10, \"total_documents\": 14, \"custom_fields\": {\"defined\": 7, \"maximum_allowed\": 14}}}"; + String updateCollectionPath = "/v1/environments/testString/collections/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(201) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the UpdateCollectionOptions model + UpdateCollectionOptions updateCollectionOptionsModel = + new UpdateCollectionOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .name("testString") + .description("testString") + .configurationId("testString") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.updateCollection(updateCollectionOptionsModel).execute(); + assertNotNull(response); + Collection responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "PUT"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateCollectionPath); + } + + // Test the updateCollection operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateCollectionNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.updateCollection(null).execute(); + } + + @Test + public void testDeleteCollectionWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = "{\"collection_id\": \"collectionId\", \"status\": \"deleted\"}"; + String deleteCollectionPath = "/v1/environments/testString/collections/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the DeleteCollectionOptions model + DeleteCollectionOptions deleteCollectionOptionsModel = + new DeleteCollectionOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.deleteCollection(deleteCollectionOptionsModel).execute(); + assertNotNull(response); + DeleteCollectionResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteCollectionPath); + } + + // Test the deleteCollection operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteCollectionNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.deleteCollection(null).execute(); + } + + @Test + public void testListCollectionFieldsWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = "{\"fields\": [{\"field\": \"field\", \"type\": \"nested\"}]}"; + String listCollectionFieldsPath = "/v1/environments/testString/collections/testString/fields"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the ListCollectionFieldsOptions model + ListCollectionFieldsOptions listCollectionFieldsOptionsModel = + new ListCollectionFieldsOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.listCollectionFields(listCollectionFieldsOptionsModel).execute(); + assertNotNull(response); + ListCollectionFieldsResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listCollectionFieldsPath); + } + + // Test the listCollectionFields operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListCollectionFieldsNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.listCollectionFields(null).execute(); + } + + @Test + public void testListExpansionsWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"expansions\": [{\"input_terms\": [\"inputTerms\"], \"expanded_terms\": [\"expandedTerms\"]}]}"; + String listExpansionsPath = "/v1/environments/testString/collections/testString/expansions"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the ListExpansionsOptions model + ListExpansionsOptions listExpansionsOptionsModel = + new ListExpansionsOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.listExpansions(listExpansionsOptionsModel).execute(); + assertNotNull(response); + Expansions responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listExpansionsPath); + } + + // Test the listExpansions operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListExpansionsNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.listExpansions(null).execute(); + } + + @Test + public void testCreateExpansionsWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"expansions\": [{\"input_terms\": [\"inputTerms\"], \"expanded_terms\": [\"expandedTerms\"]}]}"; + String createExpansionsPath = "/v1/environments/testString/collections/testString/expansions"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the Expansion model + Expansion expansionModel = + new Expansion.Builder() + .inputTerms(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .expandedTerms(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + + // Construct an instance of the CreateExpansionsOptions model + CreateExpansionsOptions createExpansionsOptionsModel = + new CreateExpansionsOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .expansions(new java.util.ArrayList(java.util.Arrays.asList(expansionModel))) + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.createExpansions(createExpansionsOptionsModel).execute(); + assertNotNull(response); + Expansions responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createExpansionsPath); + } + + // Test the createExpansions operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateExpansionsNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.createExpansions(null).execute(); + } + + @Test + public void testDeleteExpansionsWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String deleteExpansionsPath = "/v1/environments/testString/collections/testString/expansions"; + + server.enqueue(new MockResponse().setResponseCode(204).setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the DeleteExpansionsOptions model + DeleteExpansionsOptions deleteExpansionsOptionsModel = + new DeleteExpansionsOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.deleteExpansions(deleteExpansionsOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteExpansionsPath); + } + + // Test the deleteExpansions operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteExpansionsNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.deleteExpansions(null).execute(); + } + + @Test + public void testGetTokenizationDictionaryStatusWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = "{\"status\": \"active\", \"type\": \"type\"}"; + String getTokenizationDictionaryStatusPath = + "/v1/environments/testString/collections/testString/word_lists/tokenization_dictionary"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the GetTokenizationDictionaryStatusOptions model + GetTokenizationDictionaryStatusOptions getTokenizationDictionaryStatusOptionsModel = + new GetTokenizationDictionaryStatusOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService + .getTokenizationDictionaryStatus(getTokenizationDictionaryStatusOptionsModel) + .execute(); + assertNotNull(response); + TokenDictStatusResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getTokenizationDictionaryStatusPath); + } + + // Test the getTokenizationDictionaryStatus operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetTokenizationDictionaryStatusNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.getTokenizationDictionaryStatus(null).execute(); + } + + @Test + public void testCreateTokenizationDictionaryWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = "{\"status\": \"active\", \"type\": \"type\"}"; + String createTokenizationDictionaryPath = + "/v1/environments/testString/collections/testString/word_lists/tokenization_dictionary"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(202) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the TokenDictRule model + TokenDictRule tokenDictRuleModel = + new TokenDictRule.Builder() + .text("testString") + .tokens(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .readings(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .partOfSpeech("testString") + .build(); + + // Construct an instance of the CreateTokenizationDictionaryOptions model + CreateTokenizationDictionaryOptions createTokenizationDictionaryOptionsModel = + new CreateTokenizationDictionaryOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .tokenizationRules( + new java.util.ArrayList(java.util.Arrays.asList(tokenDictRuleModel))) + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService + .createTokenizationDictionary(createTokenizationDictionaryOptionsModel) + .execute(); + assertNotNull(response); + TokenDictStatusResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createTokenizationDictionaryPath); + } + + // Test the createTokenizationDictionary operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateTokenizationDictionaryNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.createTokenizationDictionary(null).execute(); + } + + @Test + public void testDeleteTokenizationDictionaryWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String deleteTokenizationDictionaryPath = + "/v1/environments/testString/collections/testString/word_lists/tokenization_dictionary"; + + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the DeleteTokenizationDictionaryOptions model + DeleteTokenizationDictionaryOptions deleteTokenizationDictionaryOptionsModel = + new DeleteTokenizationDictionaryOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService + .deleteTokenizationDictionary(deleteTokenizationDictionaryOptionsModel) + .execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteTokenizationDictionaryPath); + } + + // Test the deleteTokenizationDictionary operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteTokenizationDictionaryNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.deleteTokenizationDictionary(null).execute(); + } + + @Test + public void testGetStopwordListStatusWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = "{\"status\": \"active\", \"type\": \"type\"}"; + String getStopwordListStatusPath = + "/v1/environments/testString/collections/testString/word_lists/stopwords"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the GetStopwordListStatusOptions model + GetStopwordListStatusOptions getStopwordListStatusOptionsModel = + new GetStopwordListStatusOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.getStopwordListStatus(getStopwordListStatusOptionsModel).execute(); + assertNotNull(response); + TokenDictStatusResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getStopwordListStatusPath); + } + + // Test the getStopwordListStatus operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetStopwordListStatusNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.getStopwordListStatus(null).execute(); + } + + @Test + public void testCreateStopwordListWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = "{\"status\": \"active\", \"type\": \"type\"}"; + String createStopwordListPath = + "/v1/environments/testString/collections/testString/word_lists/stopwords"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the CreateStopwordListOptions model + CreateStopwordListOptions createStopwordListOptionsModel = + new CreateStopwordListOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .stopwordFile(TestUtilities.createMockStream("This is a mock file.")) + .stopwordFilename("testString") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.createStopwordList(createStopwordListOptionsModel).execute(); + assertNotNull(response); + TokenDictStatusResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createStopwordListPath); + } + + // Test the createStopwordList operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateStopwordListNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.createStopwordList(null).execute(); + } + + @Test + public void testDeleteStopwordListWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String deleteStopwordListPath = + "/v1/environments/testString/collections/testString/word_lists/stopwords"; + + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the DeleteStopwordListOptions model + DeleteStopwordListOptions deleteStopwordListOptionsModel = + new DeleteStopwordListOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.deleteStopwordList(deleteStopwordListOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteStopwordListPath); + } + + // Test the deleteStopwordList operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteStopwordListNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.deleteStopwordList(null).execute(); + } + + @Test + public void testAddDocumentWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"document_id\": \"documentId\", \"status\": \"processing\", \"notices\": [{\"notice_id\": \"noticeId\", \"created\": \"2019-01-01T12:00:00\", \"document_id\": \"documentId\", \"query_id\": \"queryId\", \"severity\": \"warning\", \"step\": \"step\", \"description\": \"description\"}]}"; + String addDocumentPath = "/v1/environments/testString/collections/testString/documents"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(202) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the AddDocumentOptions model + AddDocumentOptions addDocumentOptionsModel = + new AddDocumentOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .file(TestUtilities.createMockStream("This is a mock file.")) + .filename("testString") + .fileContentType("application/json") + .metadata("testString") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.addDocument(addDocumentOptionsModel).execute(); + assertNotNull(response); + DocumentAccepted responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, addDocumentPath); + } + + // Test the addDocument operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAddDocumentNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.addDocument(null).execute(); + } + + @Test + public void testGetDocumentStatusWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"document_id\": \"documentId\", \"configuration_id\": \"configurationId\", \"status\": \"available\", \"status_description\": \"statusDescription\", \"filename\": \"filename\", \"file_type\": \"pdf\", \"sha1\": \"sha1\", \"notices\": [{\"notice_id\": \"noticeId\", \"created\": \"2019-01-01T12:00:00\", \"document_id\": \"documentId\", \"query_id\": \"queryId\", \"severity\": \"warning\", \"step\": \"step\", \"description\": \"description\"}]}"; + String getDocumentStatusPath = + "/v1/environments/testString/collections/testString/documents/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the GetDocumentStatusOptions model + GetDocumentStatusOptions getDocumentStatusOptionsModel = + new GetDocumentStatusOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .documentId("testString") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.getDocumentStatus(getDocumentStatusOptionsModel).execute(); + assertNotNull(response); + DocumentStatus responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getDocumentStatusPath); + } + + // Test the getDocumentStatus operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetDocumentStatusNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.getDocumentStatus(null).execute(); + } + + @Test + public void testUpdateDocumentWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"document_id\": \"documentId\", \"status\": \"processing\", \"notices\": [{\"notice_id\": \"noticeId\", \"created\": \"2019-01-01T12:00:00\", \"document_id\": \"documentId\", \"query_id\": \"queryId\", \"severity\": \"warning\", \"step\": \"step\", \"description\": \"description\"}]}"; + String updateDocumentPath = + "/v1/environments/testString/collections/testString/documents/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(202) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the UpdateDocumentOptions model + UpdateDocumentOptions updateDocumentOptionsModel = + new UpdateDocumentOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .documentId("testString") + .file(TestUtilities.createMockStream("This is a mock file.")) + .filename("testString") + .fileContentType("application/json") + .metadata("testString") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.updateDocument(updateDocumentOptionsModel).execute(); + assertNotNull(response); + DocumentAccepted responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateDocumentPath); + } + + // Test the updateDocument operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateDocumentNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.updateDocument(null).execute(); + } + + @Test + public void testDeleteDocumentWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = "{\"document_id\": \"documentId\", \"status\": \"deleted\"}"; + String deleteDocumentPath = + "/v1/environments/testString/collections/testString/documents/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the DeleteDocumentOptions model + DeleteDocumentOptions deleteDocumentOptionsModel = + new DeleteDocumentOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .documentId("testString") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.deleteDocument(deleteDocumentOptionsModel).execute(); + assertNotNull(response); + DeleteDocumentResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteDocumentPath); + } + + // Test the deleteDocument operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteDocumentNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.deleteDocument(null).execute(); + } + + @Test + public void testQueryWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"matching_results\": 15, \"results\": [{\"id\": \"id\", \"metadata\": {\"mapKey\": \"anyValue\"}, \"collection_id\": \"collectionId\", \"result_metadata\": {\"score\": 5, \"confidence\": 10}}], \"aggregations\": [{\"type\": \"histogram\", \"matching_results\": 15, \"field\": \"field\", \"interval\": 8}], \"passages\": [{\"document_id\": \"documentId\", \"passage_score\": 12, \"passage_text\": \"passageText\", \"start_offset\": 11, \"end_offset\": 9, \"field\": \"field\"}], \"duplicates_removed\": 17, \"session_token\": \"sessionToken\", \"retrieval_details\": {\"document_retrieval_strategy\": \"untrained\"}, \"suggested_query\": \"suggestedQuery\"}"; + String queryPath = "/v1/environments/testString/collections/testString/query"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the QueryOptions model + QueryOptions queryOptionsModel = + new QueryOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .filter("testString") + .query("testString") + .naturalLanguageQuery("testString") + .passages(true) + .aggregation("testString") + .count(Long.valueOf("26")) + .xReturn("testString") + .offset(Long.valueOf("26")) + .sort("testString") + .highlight(true) + .passagesFields("testString") + .passagesCount(Long.valueOf("100")) + .passagesCharacters(Long.valueOf("50")) + .deduplicate(true) + .deduplicateField("testString") + .similar(true) + .similarDocumentIds("testString") + .similarFields("testString") + .bias("testString") + .spellingSuggestions(true) + .xWatsonLoggingOptOut(true) + .build(); + + // Invoke operation with valid options model (positive test) + Response response = discoveryService.query(queryOptionsModel).execute(); + assertNotNull(response); + QueryResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, queryPath); + } + + // Test the query operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testQueryNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.query(null).execute(); + } + + @Test + public void testQueryNoticesWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"matching_results\": 15, \"results\": [{\"id\": \"id\", \"metadata\": {\"mapKey\": \"anyValue\"}, \"collection_id\": \"collectionId\", \"result_metadata\": {\"score\": 5, \"confidence\": 10}, \"code\": 4, \"filename\": \"filename\", \"file_type\": \"pdf\", \"sha1\": \"sha1\", \"notices\": [{\"notice_id\": \"noticeId\", \"created\": \"2019-01-01T12:00:00\", \"document_id\": \"documentId\", \"query_id\": \"queryId\", \"severity\": \"warning\", \"step\": \"step\", \"description\": \"description\"}]}], \"aggregations\": [{\"type\": \"histogram\", \"matching_results\": 15, \"field\": \"field\", \"interval\": 8}], \"passages\": [{\"document_id\": \"documentId\", \"passage_score\": 12, \"passage_text\": \"passageText\", \"start_offset\": 11, \"end_offset\": 9, \"field\": \"field\"}], \"duplicates_removed\": 17}"; + String queryNoticesPath = "/v1/environments/testString/collections/testString/notices"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the QueryNoticesOptions model + QueryNoticesOptions queryNoticesOptionsModel = + new QueryNoticesOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .filter("testString") + .query("testString") + .naturalLanguageQuery("testString") + .passages(true) + .aggregation("testString") + .count(Long.valueOf("26")) + .xReturn(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .offset(Long.valueOf("26")) + .sort(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .highlight(true) + .passagesFields(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .passagesCount(Long.valueOf("100")) + .passagesCharacters(Long.valueOf("50")) + .deduplicateField("testString") + .similar(true) + .similarDocumentIds( + new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .similarFields(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.queryNotices(queryNoticesOptionsModel).execute(); + assertNotNull(response); + QueryNoticesResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(query.get("filter"), "testString"); + assertEquals(query.get("query"), "testString"); + assertEquals(query.get("natural_language_query"), "testString"); + assertEquals(Boolean.valueOf(query.get("passages")), Boolean.valueOf(true)); + assertEquals(query.get("aggregation"), "testString"); + assertEquals(Long.valueOf(query.get("count")), Long.valueOf("26")); + assertEquals( + query.get("return"), + RequestUtils.join( + new java.util.ArrayList(java.util.Arrays.asList("testString")), ",")); + assertEquals(Long.valueOf(query.get("offset")), Long.valueOf("26")); + assertEquals( + query.get("sort"), + RequestUtils.join( + new java.util.ArrayList(java.util.Arrays.asList("testString")), ",")); + assertEquals(Boolean.valueOf(query.get("highlight")), Boolean.valueOf(true)); + assertEquals( + query.get("passages.fields"), + RequestUtils.join( + new java.util.ArrayList(java.util.Arrays.asList("testString")), ",")); + assertEquals(Long.valueOf(query.get("passages.count")), Long.valueOf("100")); + assertEquals(Long.valueOf(query.get("passages.characters")), Long.valueOf("50")); + assertEquals(query.get("deduplicate.field"), "testString"); + assertEquals(Boolean.valueOf(query.get("similar")), Boolean.valueOf(true)); + assertEquals( + query.get("similar.document_ids"), + RequestUtils.join( + new java.util.ArrayList(java.util.Arrays.asList("testString")), ",")); + assertEquals( + query.get("similar.fields"), + RequestUtils.join( + new java.util.ArrayList(java.util.Arrays.asList("testString")), ",")); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, queryNoticesPath); + } + + // Test the queryNotices operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testQueryNoticesNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.queryNotices(null).execute(); + } + + @Test + public void testFederatedQueryWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"matching_results\": 15, \"results\": [{\"id\": \"id\", \"metadata\": {\"mapKey\": \"anyValue\"}, \"collection_id\": \"collectionId\", \"result_metadata\": {\"score\": 5, \"confidence\": 10}}], \"aggregations\": [{\"type\": \"histogram\", \"matching_results\": 15, \"field\": \"field\", \"interval\": 8}], \"passages\": [{\"document_id\": \"documentId\", \"passage_score\": 12, \"passage_text\": \"passageText\", \"start_offset\": 11, \"end_offset\": 9, \"field\": \"field\"}], \"duplicates_removed\": 17, \"session_token\": \"sessionToken\", \"retrieval_details\": {\"document_retrieval_strategy\": \"untrained\"}, \"suggested_query\": \"suggestedQuery\"}"; + String federatedQueryPath = "/v1/environments/testString/query"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the FederatedQueryOptions model + FederatedQueryOptions federatedQueryOptionsModel = + new FederatedQueryOptions.Builder() + .environmentId("testString") + .collectionIds("testString") + .filter("testString") + .query("testString") + .naturalLanguageQuery("testString") + .passages(true) + .aggregation("testString") + .count(Long.valueOf("26")) + .xReturn("testString") + .offset(Long.valueOf("26")) + .sort("testString") + .highlight(true) + .passagesFields("testString") + .passagesCount(Long.valueOf("100")) + .passagesCharacters(Long.valueOf("50")) + .deduplicate(true) + .deduplicateField("testString") + .similar(true) + .similarDocumentIds("testString") + .similarFields("testString") + .bias("testString") + .xWatsonLoggingOptOut(true) + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.federatedQuery(federatedQueryOptionsModel).execute(); + assertNotNull(response); + QueryResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, federatedQueryPath); + } + + // Test the federatedQuery operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testFederatedQueryNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.federatedQuery(null).execute(); + } + + @Test + public void testFederatedQueryNoticesWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"matching_results\": 15, \"results\": [{\"id\": \"id\", \"metadata\": {\"mapKey\": \"anyValue\"}, \"collection_id\": \"collectionId\", \"result_metadata\": {\"score\": 5, \"confidence\": 10}, \"code\": 4, \"filename\": \"filename\", \"file_type\": \"pdf\", \"sha1\": \"sha1\", \"notices\": [{\"notice_id\": \"noticeId\", \"created\": \"2019-01-01T12:00:00\", \"document_id\": \"documentId\", \"query_id\": \"queryId\", \"severity\": \"warning\", \"step\": \"step\", \"description\": \"description\"}]}], \"aggregations\": [{\"type\": \"histogram\", \"matching_results\": 15, \"field\": \"field\", \"interval\": 8}], \"passages\": [{\"document_id\": \"documentId\", \"passage_score\": 12, \"passage_text\": \"passageText\", \"start_offset\": 11, \"end_offset\": 9, \"field\": \"field\"}], \"duplicates_removed\": 17}"; + String federatedQueryNoticesPath = "/v1/environments/testString/notices"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the FederatedQueryNoticesOptions model + FederatedQueryNoticesOptions federatedQueryNoticesOptionsModel = + new FederatedQueryNoticesOptions.Builder() + .environmentId("testString") + .collectionIds(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .filter("testString") + .query("testString") + .naturalLanguageQuery("testString") + .aggregation("testString") + .count(Long.valueOf("26")) + .xReturn(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .offset(Long.valueOf("26")) + .sort(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .highlight(true) + .deduplicateField("testString") + .similar(true) + .similarDocumentIds( + new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .similarFields(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.federatedQueryNotices(federatedQueryNoticesOptionsModel).execute(); + assertNotNull(response); + QueryNoticesResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals( + query.get("collection_ids"), + RequestUtils.join( + new java.util.ArrayList(java.util.Arrays.asList("testString")), ",")); + assertEquals(query.get("filter"), "testString"); + assertEquals(query.get("query"), "testString"); + assertEquals(query.get("natural_language_query"), "testString"); + assertEquals(query.get("aggregation"), "testString"); + assertEquals(Long.valueOf(query.get("count")), Long.valueOf("26")); + assertEquals( + query.get("return"), + RequestUtils.join( + new java.util.ArrayList(java.util.Arrays.asList("testString")), ",")); + assertEquals(Long.valueOf(query.get("offset")), Long.valueOf("26")); + assertEquals( + query.get("sort"), + RequestUtils.join( + new java.util.ArrayList(java.util.Arrays.asList("testString")), ",")); + assertEquals(Boolean.valueOf(query.get("highlight")), Boolean.valueOf(true)); + assertEquals(query.get("deduplicate.field"), "testString"); + assertEquals(Boolean.valueOf(query.get("similar")), Boolean.valueOf(true)); + assertEquals( + query.get("similar.document_ids"), + RequestUtils.join( + new java.util.ArrayList(java.util.Arrays.asList("testString")), ",")); + assertEquals( + query.get("similar.fields"), + RequestUtils.join( + new java.util.ArrayList(java.util.Arrays.asList("testString")), ",")); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, federatedQueryNoticesPath); + } + + // Test the federatedQueryNotices operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testFederatedQueryNoticesNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.federatedQueryNotices(null).execute(); + } + + @Test + public void testGetAutocompletionWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = "{\"completions\": [\"completions\"]}"; + String getAutocompletionPath = + "/v1/environments/testString/collections/testString/autocompletion"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the GetAutocompletionOptions model + GetAutocompletionOptions getAutocompletionOptionsModel = + new GetAutocompletionOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .prefix("testString") + .field("testString") + .count(Long.valueOf("26")) + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.getAutocompletion(getAutocompletionOptionsModel).execute(); + assertNotNull(response); + Completions responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(query.get("prefix"), "testString"); + assertEquals(query.get("field"), "testString"); + assertEquals(Long.valueOf(query.get("count")), Long.valueOf("26")); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getAutocompletionPath); + } + + // Test the getAutocompletion operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetAutocompletionNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.getAutocompletion(null).execute(); + } + + @Test + public void testListTrainingDataWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"environment_id\": \"environmentId\", \"collection_id\": \"collectionId\", \"queries\": [{\"query_id\": \"queryId\", \"natural_language_query\": \"naturalLanguageQuery\", \"filter\": \"filter\", \"examples\": [{\"document_id\": \"documentId\", \"cross_reference\": \"crossReference\", \"relevance\": 9}]}]}"; + String listTrainingDataPath = + "/v1/environments/testString/collections/testString/training_data"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the ListTrainingDataOptions model + ListTrainingDataOptions listTrainingDataOptionsModel = + new ListTrainingDataOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.listTrainingData(listTrainingDataOptionsModel).execute(); + assertNotNull(response); + TrainingDataSet responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listTrainingDataPath); + } + + // Test the listTrainingData operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListTrainingDataNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.listTrainingData(null).execute(); + } + + @Test + public void testAddTrainingDataWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"query_id\": \"queryId\", \"natural_language_query\": \"naturalLanguageQuery\", \"filter\": \"filter\", \"examples\": [{\"document_id\": \"documentId\", \"cross_reference\": \"crossReference\", \"relevance\": 9}]}"; + String addTrainingDataPath = "/v1/environments/testString/collections/testString/training_data"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the TrainingExample model + TrainingExample trainingExampleModel = + new TrainingExample.Builder() + .documentId("testString") + .crossReference("testString") + .relevance(Long.valueOf("26")) + .build(); + + // Construct an instance of the AddTrainingDataOptions model + AddTrainingDataOptions addTrainingDataOptionsModel = + new AddTrainingDataOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .naturalLanguageQuery("testString") + .filter("testString") + .examples( + new java.util.ArrayList( + java.util.Arrays.asList(trainingExampleModel))) + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.addTrainingData(addTrainingDataOptionsModel).execute(); + assertNotNull(response); + TrainingQuery responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, addTrainingDataPath); + } + + // Test the addTrainingData operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAddTrainingDataNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.addTrainingData(null).execute(); + } + + @Test + public void testDeleteAllTrainingDataWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String deleteAllTrainingDataPath = + "/v1/environments/testString/collections/testString/training_data"; + + server.enqueue(new MockResponse().setResponseCode(204).setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the DeleteAllTrainingDataOptions model + DeleteAllTrainingDataOptions deleteAllTrainingDataOptionsModel = + new DeleteAllTrainingDataOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.deleteAllTrainingData(deleteAllTrainingDataOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteAllTrainingDataPath); + } + + // Test the deleteAllTrainingData operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteAllTrainingDataNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.deleteAllTrainingData(null).execute(); + } + + @Test + public void testGetTrainingDataWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"query_id\": \"queryId\", \"natural_language_query\": \"naturalLanguageQuery\", \"filter\": \"filter\", \"examples\": [{\"document_id\": \"documentId\", \"cross_reference\": \"crossReference\", \"relevance\": 9}]}"; + String getTrainingDataPath = + "/v1/environments/testString/collections/testString/training_data/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the GetTrainingDataOptions model + GetTrainingDataOptions getTrainingDataOptionsModel = + new GetTrainingDataOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .queryId("testString") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.getTrainingData(getTrainingDataOptionsModel).execute(); + assertNotNull(response); + TrainingQuery responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getTrainingDataPath); + } + + // Test the getTrainingData operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetTrainingDataNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.getTrainingData(null).execute(); + } + + @Test + public void testDeleteTrainingDataWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String deleteTrainingDataPath = + "/v1/environments/testString/collections/testString/training_data/testString"; + + server.enqueue(new MockResponse().setResponseCode(204).setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the DeleteTrainingDataOptions model + DeleteTrainingDataOptions deleteTrainingDataOptionsModel = + new DeleteTrainingDataOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .queryId("testString") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.deleteTrainingData(deleteTrainingDataOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteTrainingDataPath); + } + + // Test the deleteTrainingData operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteTrainingDataNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.deleteTrainingData(null).execute(); + } + + @Test + public void testListTrainingExamplesWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"examples\": [{\"document_id\": \"documentId\", \"cross_reference\": \"crossReference\", \"relevance\": 9}]}"; + String listTrainingExamplesPath = + "/v1/environments/testString/collections/testString/training_data/testString/examples"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the ListTrainingExamplesOptions model + ListTrainingExamplesOptions listTrainingExamplesOptionsModel = + new ListTrainingExamplesOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .queryId("testString") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.listTrainingExamples(listTrainingExamplesOptionsModel).execute(); + assertNotNull(response); + TrainingExampleList responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listTrainingExamplesPath); + } + + // Test the listTrainingExamples operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListTrainingExamplesNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.listTrainingExamples(null).execute(); + } + + @Test + public void testCreateTrainingExampleWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"document_id\": \"documentId\", \"cross_reference\": \"crossReference\", \"relevance\": 9}"; + String createTrainingExamplePath = + "/v1/environments/testString/collections/testString/training_data/testString/examples"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(201) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the CreateTrainingExampleOptions model + CreateTrainingExampleOptions createTrainingExampleOptionsModel = + new CreateTrainingExampleOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .queryId("testString") + .documentId("testString") + .crossReference("testString") + .relevance(Long.valueOf("26")) + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.createTrainingExample(createTrainingExampleOptionsModel).execute(); + assertNotNull(response); + TrainingExample responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createTrainingExamplePath); + } + + // Test the createTrainingExample operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateTrainingExampleNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.createTrainingExample(null).execute(); + } + + @Test + public void testDeleteTrainingExampleWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String deleteTrainingExamplePath = + "/v1/environments/testString/collections/testString/training_data/testString/examples/testString"; + + server.enqueue(new MockResponse().setResponseCode(204).setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the DeleteTrainingExampleOptions model + DeleteTrainingExampleOptions deleteTrainingExampleOptionsModel = + new DeleteTrainingExampleOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .queryId("testString") + .exampleId("testString") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.deleteTrainingExample(deleteTrainingExampleOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteTrainingExamplePath); + } + + // Test the deleteTrainingExample operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteTrainingExampleNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.deleteTrainingExample(null).execute(); + } + + @Test + public void testUpdateTrainingExampleWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"document_id\": \"documentId\", \"cross_reference\": \"crossReference\", \"relevance\": 9}"; + String updateTrainingExamplePath = + "/v1/environments/testString/collections/testString/training_data/testString/examples/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the UpdateTrainingExampleOptions model + UpdateTrainingExampleOptions updateTrainingExampleOptionsModel = + new UpdateTrainingExampleOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .queryId("testString") + .exampleId("testString") + .crossReference("testString") + .relevance(Long.valueOf("26")) + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.updateTrainingExample(updateTrainingExampleOptionsModel).execute(); + assertNotNull(response); + TrainingExample responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "PUT"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateTrainingExamplePath); + } + + // Test the updateTrainingExample operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateTrainingExampleNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.updateTrainingExample(null).execute(); + } + + @Test + public void testGetTrainingExampleWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"document_id\": \"documentId\", \"cross_reference\": \"crossReference\", \"relevance\": 9}"; + String getTrainingExamplePath = + "/v1/environments/testString/collections/testString/training_data/testString/examples/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the GetTrainingExampleOptions model + GetTrainingExampleOptions getTrainingExampleOptionsModel = + new GetTrainingExampleOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .queryId("testString") + .exampleId("testString") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.getTrainingExample(getTrainingExampleOptionsModel).execute(); + assertNotNull(response); + TrainingExample responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getTrainingExamplePath); + } + + // Test the getTrainingExample operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetTrainingExampleNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.getTrainingExample(null).execute(); + } + + @Test + public void testDeleteUserDataWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String deleteUserDataPath = "/v1/user_data"; + + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the DeleteUserDataOptions model + DeleteUserDataOptions deleteUserDataOptionsModel = + new DeleteUserDataOptions.Builder().customerId("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = discoveryService.deleteUserData(deleteUserDataOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(query.get("customer_id"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteUserDataPath); + } + + // Test the deleteUserData operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteUserDataNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.deleteUserData(null).execute(); + } + + @Test + public void testCreateEventWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"type\": \"click\", \"data\": {\"environment_id\": \"environmentId\", \"session_token\": \"sessionToken\", \"client_timestamp\": \"2019-01-01T12:00:00\", \"display_rank\": 11, \"collection_id\": \"collectionId\", \"document_id\": \"documentId\", \"query_id\": \"queryId\"}}"; + String createEventPath = "/v1/events"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(201) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the EventData model + EventData eventDataModel = + new EventData.Builder() + .environmentId("testString") + .sessionToken("testString") + .clientTimestamp(TestUtilities.createMockDateTime("2019-01-01T12:00:00")) + .displayRank(Long.valueOf("26")) + .collectionId("testString") + .documentId("testString") + .build(); + + // Construct an instance of the CreateEventOptions model + CreateEventOptions createEventOptionsModel = + new CreateEventOptions.Builder().type("click").data(eventDataModel).build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.createEvent(createEventOptionsModel).execute(); + assertNotNull(response); + CreateEventResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createEventPath); + } + + // Test the createEvent operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateEventNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.createEvent(null).execute(); + } + + @Test + public void testQueryLogWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"matching_results\": 15, \"results\": [{\"environment_id\": \"environmentId\", \"customer_id\": \"customerId\", \"document_type\": \"query\", \"natural_language_query\": \"naturalLanguageQuery\", \"document_results\": {\"results\": [{\"position\": 8, \"document_id\": \"documentId\", \"score\": 5, \"confidence\": 10, \"collection_id\": \"collectionId\"}], \"count\": 5}, \"created_timestamp\": \"2019-01-01T12:00:00\", \"client_timestamp\": \"2019-01-01T12:00:00\", \"query_id\": \"queryId\", \"session_token\": \"sessionToken\", \"collection_id\": \"collectionId\", \"display_rank\": 11, \"document_id\": \"documentId\", \"event_type\": \"click\", \"result_type\": \"document\"}]}"; + String queryLogPath = "/v1/logs"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the QueryLogOptions model + QueryLogOptions queryLogOptionsModel = + new QueryLogOptions.Builder() + .filter("testString") + .query("testString") + .count(Long.valueOf("26")) + .offset(Long.valueOf("26")) + .sort(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + + // Invoke operation with valid options model (positive test) + Response response = discoveryService.queryLog(queryLogOptionsModel).execute(); + assertNotNull(response); + LogQueryResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(query.get("filter"), "testString"); + assertEquals(query.get("query"), "testString"); + assertEquals(Long.valueOf(query.get("count")), Long.valueOf("26")); + assertEquals(Long.valueOf(query.get("offset")), Long.valueOf("26")); + assertEquals( + query.get("sort"), + RequestUtils.join( + new java.util.ArrayList(java.util.Arrays.asList("testString")), ",")); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, queryLogPath); + } + + @Test + public void testGetMetricsQueryWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"aggregations\": [{\"interval\": \"interval\", \"event_type\": \"eventType\", \"results\": [{\"key_as_string\": \"2019-01-01T12:00:00\", \"key\": 3, \"matching_results\": 15, \"event_rate\": 9}]}]}"; + String getMetricsQueryPath = "/v1/metrics/number_of_queries"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the GetMetricsQueryOptions model + GetMetricsQueryOptions getMetricsQueryOptionsModel = + new GetMetricsQueryOptions.Builder() + .startTime(TestUtilities.createMockDateTime("2019-01-01T12:00:00")) + .endTime(TestUtilities.createMockDateTime("2019-01-01T12:00:00")) + .resultType("document") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.getMetricsQuery(getMetricsQueryOptionsModel).execute(); + assertNotNull(response); + MetricResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(query.get("result_type"), "document"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getMetricsQueryPath); + } + + @Test + public void testGetMetricsQueryEventWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"aggregations\": [{\"interval\": \"interval\", \"event_type\": \"eventType\", \"results\": [{\"key_as_string\": \"2019-01-01T12:00:00\", \"key\": 3, \"matching_results\": 15, \"event_rate\": 9}]}]}"; + String getMetricsQueryEventPath = "/v1/metrics/number_of_queries_with_event"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the GetMetricsQueryEventOptions model + GetMetricsQueryEventOptions getMetricsQueryEventOptionsModel = + new GetMetricsQueryEventOptions.Builder() + .startTime(TestUtilities.createMockDateTime("2019-01-01T12:00:00")) + .endTime(TestUtilities.createMockDateTime("2019-01-01T12:00:00")) + .resultType("document") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.getMetricsQueryEvent(getMetricsQueryEventOptionsModel).execute(); + assertNotNull(response); + MetricResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(query.get("result_type"), "document"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getMetricsQueryEventPath); + } + + @Test + public void testGetMetricsQueryNoResultsWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"aggregations\": [{\"interval\": \"interval\", \"event_type\": \"eventType\", \"results\": [{\"key_as_string\": \"2019-01-01T12:00:00\", \"key\": 3, \"matching_results\": 15, \"event_rate\": 9}]}]}"; + String getMetricsQueryNoResultsPath = "/v1/metrics/number_of_queries_with_no_search_results"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the GetMetricsQueryNoResultsOptions model + GetMetricsQueryNoResultsOptions getMetricsQueryNoResultsOptionsModel = + new GetMetricsQueryNoResultsOptions.Builder() + .startTime(TestUtilities.createMockDateTime("2019-01-01T12:00:00")) + .endTime(TestUtilities.createMockDateTime("2019-01-01T12:00:00")) + .resultType("document") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.getMetricsQueryNoResults(getMetricsQueryNoResultsOptionsModel).execute(); + assertNotNull(response); + MetricResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(query.get("result_type"), "document"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getMetricsQueryNoResultsPath); + } + + @Test + public void testGetMetricsEventRateWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"aggregations\": [{\"interval\": \"interval\", \"event_type\": \"eventType\", \"results\": [{\"key_as_string\": \"2019-01-01T12:00:00\", \"key\": 3, \"matching_results\": 15, \"event_rate\": 9}]}]}"; + String getMetricsEventRatePath = "/v1/metrics/event_rate"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the GetMetricsEventRateOptions model + GetMetricsEventRateOptions getMetricsEventRateOptionsModel = + new GetMetricsEventRateOptions.Builder() + .startTime(TestUtilities.createMockDateTime("2019-01-01T12:00:00")) + .endTime(TestUtilities.createMockDateTime("2019-01-01T12:00:00")) + .resultType("document") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.getMetricsEventRate(getMetricsEventRateOptionsModel).execute(); + assertNotNull(response); + MetricResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(query.get("result_type"), "document"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getMetricsEventRatePath); + } + + @Test + public void testGetMetricsQueryTokenEventWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"aggregations\": [{\"event_type\": \"eventType\", \"results\": [{\"key\": \"key\", \"matching_results\": 15, \"event_rate\": 9}]}]}"; + String getMetricsQueryTokenEventPath = "/v1/metrics/top_query_tokens_with_event_rate"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the GetMetricsQueryTokenEventOptions model + GetMetricsQueryTokenEventOptions getMetricsQueryTokenEventOptionsModel = + new GetMetricsQueryTokenEventOptions.Builder().count(Long.valueOf("26")).build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.getMetricsQueryTokenEvent(getMetricsQueryTokenEventOptionsModel).execute(); + assertNotNull(response); + MetricTokenResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(Long.valueOf(query.get("count")), Long.valueOf("26")); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getMetricsQueryTokenEventPath); + } + + @Test + public void testListCredentialsWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"credentials\": [{\"credential_id\": \"credentialId\", \"source_type\": \"box\", \"credential_details\": {\"credential_type\": \"oauth2\", \"client_id\": \"clientId\", \"enterprise_id\": \"enterpriseId\", \"url\": \"url\", \"username\": \"username\", \"organization_url\": \"organizationUrl\", \"site_collection.path\": \"siteCollectionPath\", \"client_secret\": \"clientSecret\", \"public_key_id\": \"publicKeyId\", \"private_key\": \"privateKey\", \"passphrase\": \"passphrase\", \"password\": \"password\", \"gateway_id\": \"gatewayId\", \"source_version\": \"online\", \"web_application_url\": \"webApplicationUrl\", \"domain\": \"domain\", \"endpoint\": \"endpoint\", \"access_key_id\": \"accessKeyId\", \"secret_access_key\": \"secretAccessKey\"}, \"status\": \"connected\"}]}"; + String listCredentialsPath = "/v1/environments/testString/credentials"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the ListCredentialsOptions model + ListCredentialsOptions listCredentialsOptionsModel = + new ListCredentialsOptions.Builder().environmentId("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.listCredentials(listCredentialsOptionsModel).execute(); + assertNotNull(response); + CredentialsList responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listCredentialsPath); + } + + // Test the listCredentials operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListCredentialsNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.listCredentials(null).execute(); + } + + @Test + public void testCreateCredentialsWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"credential_id\": \"credentialId\", \"source_type\": \"box\", \"credential_details\": {\"credential_type\": \"oauth2\", \"client_id\": \"clientId\", \"enterprise_id\": \"enterpriseId\", \"url\": \"url\", \"username\": \"username\", \"organization_url\": \"organizationUrl\", \"site_collection.path\": \"siteCollectionPath\", \"client_secret\": \"clientSecret\", \"public_key_id\": \"publicKeyId\", \"private_key\": \"privateKey\", \"passphrase\": \"passphrase\", \"password\": \"password\", \"gateway_id\": \"gatewayId\", \"source_version\": \"online\", \"web_application_url\": \"webApplicationUrl\", \"domain\": \"domain\", \"endpoint\": \"endpoint\", \"access_key_id\": \"accessKeyId\", \"secret_access_key\": \"secretAccessKey\"}, \"status\": \"connected\"}"; + String createCredentialsPath = "/v1/environments/testString/credentials"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the CredentialDetails model + CredentialDetails credentialDetailsModel = + new CredentialDetails.Builder() + .credentialType("oauth2") + .clientId("testString") + .enterpriseId("testString") + .url("testString") + .username("testString") + .organizationUrl("testString") + .siteCollectionPath("testString") + .clientSecret("testString") + .publicKeyId("testString") + .privateKey("testString") + .passphrase("testString") + .password("testString") + .gatewayId("testString") + .sourceVersion("online") + .webApplicationUrl("testString") + .domain("testString") + .endpoint("testString") + .accessKeyId("testString") + .secretAccessKey("testString") + .build(); + + // Construct an instance of the CreateCredentialsOptions model + CreateCredentialsOptions createCredentialsOptionsModel = + new CreateCredentialsOptions.Builder() + .environmentId("testString") + .sourceType("box") + .credentialDetails(credentialDetailsModel) + .status("connected") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.createCredentials(createCredentialsOptionsModel).execute(); + assertNotNull(response); + Credentials responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createCredentialsPath); + } + + // Test the createCredentials operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateCredentialsNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.createCredentials(null).execute(); + } + + @Test + public void testGetCredentialsWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"credential_id\": \"credentialId\", \"source_type\": \"box\", \"credential_details\": {\"credential_type\": \"oauth2\", \"client_id\": \"clientId\", \"enterprise_id\": \"enterpriseId\", \"url\": \"url\", \"username\": \"username\", \"organization_url\": \"organizationUrl\", \"site_collection.path\": \"siteCollectionPath\", \"client_secret\": \"clientSecret\", \"public_key_id\": \"publicKeyId\", \"private_key\": \"privateKey\", \"passphrase\": \"passphrase\", \"password\": \"password\", \"gateway_id\": \"gatewayId\", \"source_version\": \"online\", \"web_application_url\": \"webApplicationUrl\", \"domain\": \"domain\", \"endpoint\": \"endpoint\", \"access_key_id\": \"accessKeyId\", \"secret_access_key\": \"secretAccessKey\"}, \"status\": \"connected\"}"; + String getCredentialsPath = "/v1/environments/testString/credentials/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the GetCredentialsOptions model + GetCredentialsOptions getCredentialsOptionsModel = + new GetCredentialsOptions.Builder() + .environmentId("testString") + .credentialId("testString") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.getCredentials(getCredentialsOptionsModel).execute(); + assertNotNull(response); + Credentials responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getCredentialsPath); + } + + // Test the getCredentials operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetCredentialsNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.getCredentials(null).execute(); + } + + @Test + public void testUpdateCredentialsWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"credential_id\": \"credentialId\", \"source_type\": \"box\", \"credential_details\": {\"credential_type\": \"oauth2\", \"client_id\": \"clientId\", \"enterprise_id\": \"enterpriseId\", \"url\": \"url\", \"username\": \"username\", \"organization_url\": \"organizationUrl\", \"site_collection.path\": \"siteCollectionPath\", \"client_secret\": \"clientSecret\", \"public_key_id\": \"publicKeyId\", \"private_key\": \"privateKey\", \"passphrase\": \"passphrase\", \"password\": \"password\", \"gateway_id\": \"gatewayId\", \"source_version\": \"online\", \"web_application_url\": \"webApplicationUrl\", \"domain\": \"domain\", \"endpoint\": \"endpoint\", \"access_key_id\": \"accessKeyId\", \"secret_access_key\": \"secretAccessKey\"}, \"status\": \"connected\"}"; + String updateCredentialsPath = "/v1/environments/testString/credentials/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the CredentialDetails model + CredentialDetails credentialDetailsModel = + new CredentialDetails.Builder() + .credentialType("oauth2") + .clientId("testString") + .enterpriseId("testString") + .url("testString") + .username("testString") + .organizationUrl("testString") + .siteCollectionPath("testString") + .clientSecret("testString") + .publicKeyId("testString") + .privateKey("testString") + .passphrase("testString") + .password("testString") + .gatewayId("testString") + .sourceVersion("online") + .webApplicationUrl("testString") + .domain("testString") + .endpoint("testString") + .accessKeyId("testString") + .secretAccessKey("testString") + .build(); + + // Construct an instance of the UpdateCredentialsOptions model + UpdateCredentialsOptions updateCredentialsOptionsModel = + new UpdateCredentialsOptions.Builder() + .environmentId("testString") + .credentialId("testString") + .sourceType("box") + .credentialDetails(credentialDetailsModel) + .status("connected") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.updateCredentials(updateCredentialsOptionsModel).execute(); + assertNotNull(response); + Credentials responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "PUT"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateCredentialsPath); + } + + // Test the updateCredentials operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateCredentialsNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.updateCredentials(null).execute(); + } + + @Test + public void testDeleteCredentialsWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = "{\"credential_id\": \"credentialId\", \"status\": \"deleted\"}"; + String deleteCredentialsPath = "/v1/environments/testString/credentials/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the DeleteCredentialsOptions model + DeleteCredentialsOptions deleteCredentialsOptionsModel = + new DeleteCredentialsOptions.Builder() + .environmentId("testString") + .credentialId("testString") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.deleteCredentials(deleteCredentialsOptionsModel).execute(); + assertNotNull(response); + DeleteCredentials responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteCredentialsPath); + } + + // Test the deleteCredentials operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteCredentialsNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.deleteCredentials(null).execute(); + } + + @Test + public void testListGatewaysWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"gateways\": [{\"gateway_id\": \"gatewayId\", \"name\": \"name\", \"status\": \"connected\", \"token\": \"token\", \"token_id\": \"tokenId\"}]}"; + String listGatewaysPath = "/v1/environments/testString/gateways"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the ListGatewaysOptions model + ListGatewaysOptions listGatewaysOptionsModel = + new ListGatewaysOptions.Builder().environmentId("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.listGateways(listGatewaysOptionsModel).execute(); + assertNotNull(response); + GatewayList responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listGatewaysPath); + } + + // Test the listGateways operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListGatewaysNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.listGateways(null).execute(); + } + + @Test + public void testCreateGatewayWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"gateway_id\": \"gatewayId\", \"name\": \"name\", \"status\": \"connected\", \"token\": \"token\", \"token_id\": \"tokenId\"}"; + String createGatewayPath = "/v1/environments/testString/gateways"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the CreateGatewayOptions model + CreateGatewayOptions createGatewayOptionsModel = + new CreateGatewayOptions.Builder().environmentId("testString").name("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.createGateway(createGatewayOptionsModel).execute(); + assertNotNull(response); + Gateway responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createGatewayPath); + } + + // Test the createGateway operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateGatewayNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.createGateway(null).execute(); + } + + @Test + public void testGetGatewayWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"gateway_id\": \"gatewayId\", \"name\": \"name\", \"status\": \"connected\", \"token\": \"token\", \"token_id\": \"tokenId\"}"; + String getGatewayPath = "/v1/environments/testString/gateways/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the GetGatewayOptions model + GetGatewayOptions getGatewayOptionsModel = + new GetGatewayOptions.Builder().environmentId("testString").gatewayId("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = discoveryService.getGateway(getGatewayOptionsModel).execute(); + assertNotNull(response); + Gateway responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getGatewayPath); + } + + // Test the getGateway operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetGatewayNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.getGateway(null).execute(); + } + + @Test + public void testDeleteGatewayWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = "{\"gateway_id\": \"gatewayId\", \"status\": \"status\"}"; + String deleteGatewayPath = "/v1/environments/testString/gateways/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the DeleteGatewayOptions model + DeleteGatewayOptions deleteGatewayOptionsModel = + new DeleteGatewayOptions.Builder() + .environmentId("testString") + .gatewayId("testString") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.deleteGateway(deleteGatewayOptionsModel).execute(); + assertNotNull(response); + GatewayDelete responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteGatewayPath); + } + + // Test the deleteGateway operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteGatewayNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.deleteGateway(null).execute(); + } + + /** Initialize the server */ + @BeforeMethod + public void setUpMockServer() { + try { + server = new MockWebServer(); + // register handler + server.start(); + } catch (IOException err) { + fail("Failed to instantiate mock web server"); + } + } + + @AfterMethod + public void tearDownMockServer() throws IOException { + server.shutdown(); + discoveryService = null; + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/AddDocumentOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/AddDocumentOptionsTest.java new file mode 100644 index 00000000000..88437423d46 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/AddDocumentOptionsTest.java @@ -0,0 +1,57 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.apache.commons.io.IOUtils; +import org.testng.annotations.Test; + +/** Unit test class for the AddDocumentOptions model. */ +public class AddDocumentOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAddDocumentOptions() throws Throwable { + AddDocumentOptions addDocumentOptionsModel = + new AddDocumentOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .file(TestUtilities.createMockStream("This is a mock file.")) + .filename("testString") + .fileContentType("application/json") + .metadata("testString") + .build(); + assertEquals(addDocumentOptionsModel.environmentId(), "testString"); + assertEquals(addDocumentOptionsModel.collectionId(), "testString"); + assertEquals( + IOUtils.toString(addDocumentOptionsModel.file()), + IOUtils.toString(TestUtilities.createMockStream("This is a mock file."))); + assertEquals(addDocumentOptionsModel.filename(), "testString"); + assertEquals(addDocumentOptionsModel.fileContentType(), "application/json"); + assertEquals(addDocumentOptionsModel.metadata(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAddDocumentOptionsError() throws Throwable { + new AddDocumentOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/AddTrainingDataOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/AddTrainingDataOptionsTest.java new file mode 100644 index 00000000000..dd3a2bfd8e6 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/AddTrainingDataOptionsTest.java @@ -0,0 +1,66 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the AddTrainingDataOptions model. */ +public class AddTrainingDataOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAddTrainingDataOptions() throws Throwable { + TrainingExample trainingExampleModel = + new TrainingExample.Builder() + .documentId("testString") + .crossReference("testString") + .relevance(Long.valueOf("26")) + .build(); + assertEquals(trainingExampleModel.documentId(), "testString"); + assertEquals(trainingExampleModel.crossReference(), "testString"); + assertEquals(trainingExampleModel.relevance(), Long.valueOf("26")); + + AddTrainingDataOptions addTrainingDataOptionsModel = + new AddTrainingDataOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .naturalLanguageQuery("testString") + .filter("testString") + .examples( + new java.util.ArrayList( + java.util.Arrays.asList(trainingExampleModel))) + .build(); + assertEquals(addTrainingDataOptionsModel.environmentId(), "testString"); + assertEquals(addTrainingDataOptionsModel.collectionId(), "testString"); + assertEquals(addTrainingDataOptionsModel.naturalLanguageQuery(), "testString"); + assertEquals(addTrainingDataOptionsModel.filter(), "testString"); + assertEquals( + addTrainingDataOptionsModel.examples(), + new java.util.ArrayList(java.util.Arrays.asList(trainingExampleModel))); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAddTrainingDataOptionsError() throws Throwable { + new AddTrainingDataOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/AggregationResultTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/AggregationResultTest.java new file mode 100644 index 00000000000..efdc950afa3 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/AggregationResultTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the AggregationResult model. */ +public class AggregationResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAggregationResult() throws Throwable { + AggregationResult aggregationResultModel = new AggregationResult(); + assertNull(aggregationResultModel.getKey()); + assertNull(aggregationResultModel.getMatchingResults()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CalculationTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CalculationTest.java new file mode 100644 index 00000000000..7da638fae81 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CalculationTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Calculation model. */ +public class CalculationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCalculation() throws Throwable { + Calculation calculationModel = new Calculation(); + assertNull(calculationModel.getType()); + assertNull(calculationModel.getMatchingResults()); + assertNull(calculationModel.getField()); + assertNull(calculationModel.getValue()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CollectionCrawlStatusTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CollectionCrawlStatusTest.java new file mode 100644 index 00000000000..ae741e6669c --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CollectionCrawlStatusTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CollectionCrawlStatus model. */ +public class CollectionCrawlStatusTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCollectionCrawlStatus() throws Throwable { + CollectionCrawlStatus collectionCrawlStatusModel = new CollectionCrawlStatus(); + assertNull(collectionCrawlStatusModel.getSourceCrawl()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CollectionDiskUsageTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CollectionDiskUsageTest.java new file mode 100644 index 00000000000..a19af35a193 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CollectionDiskUsageTest.java @@ -0,0 +1,35 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CollectionDiskUsage model. */ +public class CollectionDiskUsageTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCollectionDiskUsage() throws Throwable { + CollectionDiskUsage collectionDiskUsageModel = new CollectionDiskUsage(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CollectionTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CollectionTest.java new file mode 100644 index 00000000000..7d36e3dc9dc --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CollectionTest.java @@ -0,0 +1,44 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Collection model. */ +public class CollectionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCollection() throws Throwable { + Collection collectionModel = new Collection(); + assertNull(collectionModel.getName()); + assertNull(collectionModel.getDescription()); + assertNull(collectionModel.getConfigurationId()); + assertNull(collectionModel.getLanguage()); + assertNull(collectionModel.getDocumentCounts()); + assertNull(collectionModel.getDiskUsage()); + assertNull(collectionModel.getTrainingStatus()); + assertNull(collectionModel.getCrawlStatus()); + assertNull(collectionModel.getSmartDocumentUnderstanding()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CollectionUsageTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CollectionUsageTest.java new file mode 100644 index 00000000000..1e774a26a37 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CollectionUsageTest.java @@ -0,0 +1,35 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CollectionUsage model. */ +public class CollectionUsageTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCollectionUsage() throws Throwable { + CollectionUsage collectionUsageModel = new CollectionUsage(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CompletionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CompletionsTest.java new file mode 100644 index 00000000000..99b2749bbd8 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CompletionsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Completions model. */ +public class CompletionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCompletions() throws Throwable { + Completions completionsModel = new Completions(); + assertNull(completionsModel.getCompletions()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/ConfigurationTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/ConfigurationTest.java new file mode 100644 index 00000000000..9b6415ce09e --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/ConfigurationTest.java @@ -0,0 +1,444 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Configuration model. */ +public class ConfigurationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testConfiguration() throws Throwable { + FontSetting fontSettingModel = + new FontSetting.Builder() + .level(Long.valueOf("26")) + .minSize(Long.valueOf("26")) + .maxSize(Long.valueOf("26")) + .bold(true) + .italic(true) + .name("testString") + .build(); + assertEquals(fontSettingModel.level(), Long.valueOf("26")); + assertEquals(fontSettingModel.minSize(), Long.valueOf("26")); + assertEquals(fontSettingModel.maxSize(), Long.valueOf("26")); + assertEquals(fontSettingModel.bold(), Boolean.valueOf(true)); + assertEquals(fontSettingModel.italic(), Boolean.valueOf(true)); + assertEquals(fontSettingModel.name(), "testString"); + + PdfHeadingDetection pdfHeadingDetectionModel = + new PdfHeadingDetection.Builder() + .fonts(new java.util.ArrayList(java.util.Arrays.asList(fontSettingModel))) + .build(); + assertEquals( + pdfHeadingDetectionModel.fonts(), + new java.util.ArrayList(java.util.Arrays.asList(fontSettingModel))); + + PdfSettings pdfSettingsModel = + new PdfSettings.Builder().heading(pdfHeadingDetectionModel).build(); + assertEquals(pdfSettingsModel.heading(), pdfHeadingDetectionModel); + + WordStyle wordStyleModel = + new WordStyle.Builder() + .level(Long.valueOf("26")) + .names(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals(wordStyleModel.level(), Long.valueOf("26")); + assertEquals( + wordStyleModel.names(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + WordHeadingDetection wordHeadingDetectionModel = + new WordHeadingDetection.Builder() + .fonts(new java.util.ArrayList(java.util.Arrays.asList(fontSettingModel))) + .styles(new java.util.ArrayList(java.util.Arrays.asList(wordStyleModel))) + .build(); + assertEquals( + wordHeadingDetectionModel.fonts(), + new java.util.ArrayList(java.util.Arrays.asList(fontSettingModel))); + assertEquals( + wordHeadingDetectionModel.styles(), + new java.util.ArrayList(java.util.Arrays.asList(wordStyleModel))); + + WordSettings wordSettingsModel = + new WordSettings.Builder().heading(wordHeadingDetectionModel).build(); + assertEquals(wordSettingsModel.heading(), wordHeadingDetectionModel); + + XPathPatterns xPathPatternsModel = + new XPathPatterns.Builder() + .xpaths(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals( + xPathPatternsModel.xpaths(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + HtmlSettings htmlSettingsModel = + new HtmlSettings.Builder() + .excludeTagsCompletely( + new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .excludeTagsKeepContent( + new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .keepContent(xPathPatternsModel) + .excludeContent(xPathPatternsModel) + .keepTagAttributes( + new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .excludeTagAttributes( + new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals( + htmlSettingsModel.excludeTagsCompletely(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals( + htmlSettingsModel.excludeTagsKeepContent(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals(htmlSettingsModel.keepContent(), xPathPatternsModel); + assertEquals(htmlSettingsModel.excludeContent(), xPathPatternsModel); + assertEquals( + htmlSettingsModel.keepTagAttributes(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals( + htmlSettingsModel.excludeTagAttributes(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + SegmentSettings segmentSettingsModel = + new SegmentSettings.Builder() + .enabled(true) + .selectorTags(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .annotatedFields(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals(segmentSettingsModel.enabled(), Boolean.valueOf(true)); + assertEquals( + segmentSettingsModel.selectorTags(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals( + segmentSettingsModel.annotatedFields(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + NormalizationOperation normalizationOperationModel = + new NormalizationOperation.Builder() + .operation("move") + .sourceField("extracted_metadata.title") + .destinationField("metadata.title") + .build(); + assertEquals(normalizationOperationModel.operation(), "move"); + assertEquals(normalizationOperationModel.sourceField(), "extracted_metadata.title"); + assertEquals(normalizationOperationModel.destinationField(), "metadata.title"); + + Conversions conversionsModel = + new Conversions.Builder() + .pdf(pdfSettingsModel) + .word(wordSettingsModel) + .html(htmlSettingsModel) + .segment(segmentSettingsModel) + .jsonNormalizations( + new java.util.ArrayList( + java.util.Arrays.asList(normalizationOperationModel))) + .imageTextRecognition(true) + .build(); + assertEquals(conversionsModel.pdf(), pdfSettingsModel); + assertEquals(conversionsModel.word(), wordSettingsModel); + assertEquals(conversionsModel.html(), htmlSettingsModel); + assertEquals(conversionsModel.segment(), segmentSettingsModel); + assertEquals( + conversionsModel.jsonNormalizations(), + new java.util.ArrayList( + java.util.Arrays.asList(normalizationOperationModel))); + assertEquals(conversionsModel.imageTextRecognition(), Boolean.valueOf(true)); + + NluEnrichmentKeywords nluEnrichmentKeywordsModel = + new NluEnrichmentKeywords.Builder() + .sentiment(true) + .emotion(false) + .limit(Long.valueOf("50")) + .build(); + assertEquals(nluEnrichmentKeywordsModel.sentiment(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentKeywordsModel.emotion(), Boolean.valueOf(false)); + assertEquals(nluEnrichmentKeywordsModel.limit(), Long.valueOf("50")); + + NluEnrichmentEntities nluEnrichmentEntitiesModel = + new NluEnrichmentEntities.Builder() + .sentiment(true) + .emotion(false) + .limit(Long.valueOf("50")) + .mentions(true) + .mentionTypes(true) + .sentenceLocations(true) + .model("WKS-model-id") + .build(); + assertEquals(nluEnrichmentEntitiesModel.sentiment(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentEntitiesModel.emotion(), Boolean.valueOf(false)); + assertEquals(nluEnrichmentEntitiesModel.limit(), Long.valueOf("50")); + assertEquals(nluEnrichmentEntitiesModel.mentions(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentEntitiesModel.mentionTypes(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentEntitiesModel.sentenceLocations(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentEntitiesModel.model(), "WKS-model-id"); + + NluEnrichmentSentiment nluEnrichmentSentimentModel = + new NluEnrichmentSentiment.Builder() + .document(true) + .targets(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals(nluEnrichmentSentimentModel.document(), Boolean.valueOf(true)); + assertEquals( + nluEnrichmentSentimentModel.targets(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + NluEnrichmentEmotion nluEnrichmentEmotionModel = + new NluEnrichmentEmotion.Builder() + .document(true) + .targets(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals(nluEnrichmentEmotionModel.document(), Boolean.valueOf(true)); + assertEquals( + nluEnrichmentEmotionModel.targets(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + NluEnrichmentSemanticRoles nluEnrichmentSemanticRolesModel = + new NluEnrichmentSemanticRoles.Builder() + .entities(true) + .keywords(true) + .limit(Long.valueOf("50")) + .build(); + assertEquals(nluEnrichmentSemanticRolesModel.entities(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentSemanticRolesModel.keywords(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentSemanticRolesModel.limit(), Long.valueOf("50")); + + NluEnrichmentRelations nluEnrichmentRelationsModel = + new NluEnrichmentRelations.Builder().model("WKS-model-id").build(); + assertEquals(nluEnrichmentRelationsModel.model(), "WKS-model-id"); + + NluEnrichmentConcepts nluEnrichmentConceptsModel = + new NluEnrichmentConcepts.Builder().limit(Long.valueOf("8")).build(); + assertEquals(nluEnrichmentConceptsModel.limit(), Long.valueOf("8")); + + NluEnrichmentFeatures nluEnrichmentFeaturesModel = + new NluEnrichmentFeatures.Builder() + .keywords(nluEnrichmentKeywordsModel) + .entities(nluEnrichmentEntitiesModel) + .sentiment(nluEnrichmentSentimentModel) + .emotion(nluEnrichmentEmotionModel) + .categories( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .semanticRoles(nluEnrichmentSemanticRolesModel) + .relations(nluEnrichmentRelationsModel) + .concepts(nluEnrichmentConceptsModel) + .build(); + assertEquals(nluEnrichmentFeaturesModel.keywords(), nluEnrichmentKeywordsModel); + assertEquals(nluEnrichmentFeaturesModel.entities(), nluEnrichmentEntitiesModel); + assertEquals(nluEnrichmentFeaturesModel.sentiment(), nluEnrichmentSentimentModel); + assertEquals(nluEnrichmentFeaturesModel.emotion(), nluEnrichmentEmotionModel); + assertEquals( + nluEnrichmentFeaturesModel.categories(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals(nluEnrichmentFeaturesModel.semanticRoles(), nluEnrichmentSemanticRolesModel); + assertEquals(nluEnrichmentFeaturesModel.relations(), nluEnrichmentRelationsModel); + assertEquals(nluEnrichmentFeaturesModel.concepts(), nluEnrichmentConceptsModel); + + EnrichmentOptions enrichmentOptionsModel = + new EnrichmentOptions.Builder() + .features(nluEnrichmentFeaturesModel) + .language("ar") + .model("testString") + .build(); + assertEquals(enrichmentOptionsModel.features(), nluEnrichmentFeaturesModel); + assertEquals(enrichmentOptionsModel.language(), "ar"); + assertEquals(enrichmentOptionsModel.model(), "testString"); + + Enrichment enrichmentModel = + new Enrichment.Builder() + .description("testString") + .destinationField("enriched_title") + .sourceField("title") + .overwrite(true) + .enrichment("natural_language_understanding") + .ignoreDownstreamErrors(true) + .options(enrichmentOptionsModel) + .build(); + assertEquals(enrichmentModel.description(), "testString"); + assertEquals(enrichmentModel.destinationField(), "enriched_title"); + assertEquals(enrichmentModel.sourceField(), "title"); + assertEquals(enrichmentModel.overwrite(), Boolean.valueOf(true)); + assertEquals(enrichmentModel.enrichment(), "natural_language_understanding"); + assertEquals(enrichmentModel.ignoreDownstreamErrors(), Boolean.valueOf(true)); + assertEquals(enrichmentModel.options(), enrichmentOptionsModel); + + SourceSchedule sourceScheduleModel = + new SourceSchedule.Builder() + .enabled(true) + .timeZone("America/New_York") + .frequency("weekly") + .build(); + assertEquals(sourceScheduleModel.enabled(), Boolean.valueOf(true)); + assertEquals(sourceScheduleModel.timeZone(), "America/New_York"); + assertEquals(sourceScheduleModel.frequency(), "weekly"); + + SourceOptionsFolder sourceOptionsFolderModel = + new SourceOptionsFolder.Builder() + .ownerUserId("testString") + .folderId("testString") + .limit(Long.valueOf("26")) + .build(); + assertEquals(sourceOptionsFolderModel.ownerUserId(), "testString"); + assertEquals(sourceOptionsFolderModel.folderId(), "testString"); + assertEquals(sourceOptionsFolderModel.limit(), Long.valueOf("26")); + + SourceOptionsObject sourceOptionsObjectModel = + new SourceOptionsObject.Builder().name("testString").limit(Long.valueOf("26")).build(); + assertEquals(sourceOptionsObjectModel.name(), "testString"); + assertEquals(sourceOptionsObjectModel.limit(), Long.valueOf("26")); + + SourceOptionsSiteColl sourceOptionsSiteCollModel = + new SourceOptionsSiteColl.Builder() + .siteCollectionPath("/sites/TestSiteA") + .limit(Long.valueOf("10")) + .build(); + assertEquals(sourceOptionsSiteCollModel.siteCollectionPath(), "/sites/TestSiteA"); + assertEquals(sourceOptionsSiteCollModel.limit(), Long.valueOf("10")); + + SourceOptionsWebCrawl sourceOptionsWebCrawlModel = + new SourceOptionsWebCrawl.Builder() + .url("testString") + .limitToStartingHosts(true) + .crawlSpeed("gentle") + .allowUntrustedCertificate(true) + .maximumHops(Long.valueOf("26")) + .requestTimeout(Long.valueOf("26")) + .overrideRobotsTxt(true) + .blacklist(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals(sourceOptionsWebCrawlModel.url(), "testString"); + assertEquals(sourceOptionsWebCrawlModel.limitToStartingHosts(), Boolean.valueOf(true)); + assertEquals(sourceOptionsWebCrawlModel.crawlSpeed(), "gentle"); + assertEquals(sourceOptionsWebCrawlModel.allowUntrustedCertificate(), Boolean.valueOf(true)); + assertEquals(sourceOptionsWebCrawlModel.maximumHops(), Long.valueOf("26")); + assertEquals(sourceOptionsWebCrawlModel.requestTimeout(), Long.valueOf("26")); + assertEquals(sourceOptionsWebCrawlModel.overrideRobotsTxt(), Boolean.valueOf(true)); + assertEquals( + sourceOptionsWebCrawlModel.blacklist(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + SourceOptionsBuckets sourceOptionsBucketsModel = + new SourceOptionsBuckets.Builder().name("testString").limit(Long.valueOf("26")).build(); + assertEquals(sourceOptionsBucketsModel.name(), "testString"); + assertEquals(sourceOptionsBucketsModel.limit(), Long.valueOf("26")); + + SourceOptions sourceOptionsModel = + new SourceOptions.Builder() + .folders( + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsFolderModel))) + .objects( + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsObjectModel))) + .siteCollections( + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsSiteCollModel))) + .urls( + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsWebCrawlModel))) + .buckets( + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsBucketsModel))) + .crawlAllBuckets(true) + .build(); + assertEquals( + sourceOptionsModel.folders(), + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsFolderModel))); + assertEquals( + sourceOptionsModel.objects(), + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsObjectModel))); + assertEquals( + sourceOptionsModel.siteCollections(), + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsSiteCollModel))); + assertEquals( + sourceOptionsModel.urls(), + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsWebCrawlModel))); + assertEquals( + sourceOptionsModel.buckets(), + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsBucketsModel))); + assertEquals(sourceOptionsModel.crawlAllBuckets(), Boolean.valueOf(true)); + + Source sourceModel = + new Source.Builder() + .type("salesforce") + .credentialId("00ad0000-0000-11e8-ba89-0ed5f00f718b") + .schedule(sourceScheduleModel) + .options(sourceOptionsModel) + .build(); + assertEquals(sourceModel.type(), "salesforce"); + assertEquals(sourceModel.credentialId(), "00ad0000-0000-11e8-ba89-0ed5f00f718b"); + assertEquals(sourceModel.schedule(), sourceScheduleModel); + assertEquals(sourceModel.options(), sourceOptionsModel); + + Configuration configurationModel = + new Configuration.Builder() + .name("testString") + .description("testString") + .conversions(conversionsModel) + .enrichments( + new java.util.ArrayList(java.util.Arrays.asList(enrichmentModel))) + .normalizations( + new java.util.ArrayList( + java.util.Arrays.asList(normalizationOperationModel))) + .source(sourceModel) + .build(); + assertEquals(configurationModel.name(), "testString"); + assertEquals(configurationModel.description(), "testString"); + assertEquals(configurationModel.conversions(), conversionsModel); + assertEquals( + configurationModel.enrichments(), + new java.util.ArrayList(java.util.Arrays.asList(enrichmentModel))); + assertEquals( + configurationModel.normalizations(), + new java.util.ArrayList( + java.util.Arrays.asList(normalizationOperationModel))); + assertEquals(configurationModel.source(), sourceModel); + + String json = TestUtilities.serialize(configurationModel); + + Configuration configurationModelNew = TestUtilities.deserialize(json, Configuration.class); + assertTrue(configurationModelNew instanceof Configuration); + assertEquals(configurationModelNew.name(), "testString"); + assertEquals(configurationModelNew.description(), "testString"); + assertEquals(configurationModelNew.conversions().toString(), conversionsModel.toString()); + assertEquals(configurationModelNew.source().toString(), sourceModel.toString()); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testConfigurationError() throws Throwable { + new Configuration.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/ConversionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/ConversionsTest.java new file mode 100644 index 00000000000..621ed9a606f --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/ConversionsTest.java @@ -0,0 +1,178 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Conversions model. */ +public class ConversionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testConversions() throws Throwable { + FontSetting fontSettingModel = + new FontSetting.Builder() + .level(Long.valueOf("26")) + .minSize(Long.valueOf("26")) + .maxSize(Long.valueOf("26")) + .bold(true) + .italic(true) + .name("testString") + .build(); + assertEquals(fontSettingModel.level(), Long.valueOf("26")); + assertEquals(fontSettingModel.minSize(), Long.valueOf("26")); + assertEquals(fontSettingModel.maxSize(), Long.valueOf("26")); + assertEquals(fontSettingModel.bold(), Boolean.valueOf(true)); + assertEquals(fontSettingModel.italic(), Boolean.valueOf(true)); + assertEquals(fontSettingModel.name(), "testString"); + + PdfHeadingDetection pdfHeadingDetectionModel = + new PdfHeadingDetection.Builder() + .fonts(new java.util.ArrayList(java.util.Arrays.asList(fontSettingModel))) + .build(); + assertEquals( + pdfHeadingDetectionModel.fonts(), + new java.util.ArrayList(java.util.Arrays.asList(fontSettingModel))); + + PdfSettings pdfSettingsModel = + new PdfSettings.Builder().heading(pdfHeadingDetectionModel).build(); + assertEquals(pdfSettingsModel.heading(), pdfHeadingDetectionModel); + + WordStyle wordStyleModel = + new WordStyle.Builder() + .level(Long.valueOf("26")) + .names(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals(wordStyleModel.level(), Long.valueOf("26")); + assertEquals( + wordStyleModel.names(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + WordHeadingDetection wordHeadingDetectionModel = + new WordHeadingDetection.Builder() + .fonts(new java.util.ArrayList(java.util.Arrays.asList(fontSettingModel))) + .styles(new java.util.ArrayList(java.util.Arrays.asList(wordStyleModel))) + .build(); + assertEquals( + wordHeadingDetectionModel.fonts(), + new java.util.ArrayList(java.util.Arrays.asList(fontSettingModel))); + assertEquals( + wordHeadingDetectionModel.styles(), + new java.util.ArrayList(java.util.Arrays.asList(wordStyleModel))); + + WordSettings wordSettingsModel = + new WordSettings.Builder().heading(wordHeadingDetectionModel).build(); + assertEquals(wordSettingsModel.heading(), wordHeadingDetectionModel); + + XPathPatterns xPathPatternsModel = + new XPathPatterns.Builder() + .xpaths(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals( + xPathPatternsModel.xpaths(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + HtmlSettings htmlSettingsModel = + new HtmlSettings.Builder() + .excludeTagsCompletely( + new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .excludeTagsKeepContent( + new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .keepContent(xPathPatternsModel) + .excludeContent(xPathPatternsModel) + .keepTagAttributes( + new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .excludeTagAttributes( + new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals( + htmlSettingsModel.excludeTagsCompletely(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals( + htmlSettingsModel.excludeTagsKeepContent(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals(htmlSettingsModel.keepContent(), xPathPatternsModel); + assertEquals(htmlSettingsModel.excludeContent(), xPathPatternsModel); + assertEquals( + htmlSettingsModel.keepTagAttributes(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals( + htmlSettingsModel.excludeTagAttributes(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + SegmentSettings segmentSettingsModel = + new SegmentSettings.Builder() + .enabled(true) + .selectorTags(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .annotatedFields(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals(segmentSettingsModel.enabled(), Boolean.valueOf(true)); + assertEquals( + segmentSettingsModel.selectorTags(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals( + segmentSettingsModel.annotatedFields(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + NormalizationOperation normalizationOperationModel = + new NormalizationOperation.Builder() + .operation("copy") + .sourceField("testString") + .destinationField("testString") + .build(); + assertEquals(normalizationOperationModel.operation(), "copy"); + assertEquals(normalizationOperationModel.sourceField(), "testString"); + assertEquals(normalizationOperationModel.destinationField(), "testString"); + + Conversions conversionsModel = + new Conversions.Builder() + .pdf(pdfSettingsModel) + .word(wordSettingsModel) + .html(htmlSettingsModel) + .segment(segmentSettingsModel) + .jsonNormalizations( + new java.util.ArrayList( + java.util.Arrays.asList(normalizationOperationModel))) + .imageTextRecognition(true) + .build(); + assertEquals(conversionsModel.pdf(), pdfSettingsModel); + assertEquals(conversionsModel.word(), wordSettingsModel); + assertEquals(conversionsModel.html(), htmlSettingsModel); + assertEquals(conversionsModel.segment(), segmentSettingsModel); + assertEquals( + conversionsModel.jsonNormalizations(), + new java.util.ArrayList( + java.util.Arrays.asList(normalizationOperationModel))); + assertEquals(conversionsModel.imageTextRecognition(), Boolean.valueOf(true)); + + String json = TestUtilities.serialize(conversionsModel); + + Conversions conversionsModelNew = TestUtilities.deserialize(json, Conversions.class); + assertTrue(conversionsModelNew instanceof Conversions); + assertEquals(conversionsModelNew.pdf().toString(), pdfSettingsModel.toString()); + assertEquals(conversionsModelNew.word().toString(), wordSettingsModel.toString()); + assertEquals(conversionsModelNew.html().toString(), htmlSettingsModel.toString()); + assertEquals(conversionsModelNew.segment().toString(), segmentSettingsModel.toString()); + assertEquals(conversionsModelNew.imageTextRecognition(), Boolean.valueOf(true)); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CreateCollectionOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CreateCollectionOptionsTest.java new file mode 100644 index 00000000000..d5a6dc30a8b --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CreateCollectionOptionsTest.java @@ -0,0 +1,52 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateCollectionOptions model. */ +public class CreateCollectionOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateCollectionOptions() throws Throwable { + CreateCollectionOptions createCollectionOptionsModel = + new CreateCollectionOptions.Builder() + .environmentId("testString") + .name("testString") + .description("testString") + .configurationId("testString") + .language("en") + .build(); + assertEquals(createCollectionOptionsModel.environmentId(), "testString"); + assertEquals(createCollectionOptionsModel.name(), "testString"); + assertEquals(createCollectionOptionsModel.description(), "testString"); + assertEquals(createCollectionOptionsModel.configurationId(), "testString"); + assertEquals(createCollectionOptionsModel.language(), "en"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateCollectionOptionsError() throws Throwable { + new CreateCollectionOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CreateConfigurationOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CreateConfigurationOptionsTest.java new file mode 100644 index 00000000000..c176c9a55a7 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CreateConfigurationOptionsTest.java @@ -0,0 +1,437 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateConfigurationOptions model. */ +public class CreateConfigurationOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateConfigurationOptions() throws Throwable { + FontSetting fontSettingModel = + new FontSetting.Builder() + .level(Long.valueOf("26")) + .minSize(Long.valueOf("26")) + .maxSize(Long.valueOf("26")) + .bold(true) + .italic(true) + .name("testString") + .build(); + assertEquals(fontSettingModel.level(), Long.valueOf("26")); + assertEquals(fontSettingModel.minSize(), Long.valueOf("26")); + assertEquals(fontSettingModel.maxSize(), Long.valueOf("26")); + assertEquals(fontSettingModel.bold(), Boolean.valueOf(true)); + assertEquals(fontSettingModel.italic(), Boolean.valueOf(true)); + assertEquals(fontSettingModel.name(), "testString"); + + PdfHeadingDetection pdfHeadingDetectionModel = + new PdfHeadingDetection.Builder() + .fonts(new java.util.ArrayList(java.util.Arrays.asList(fontSettingModel))) + .build(); + assertEquals( + pdfHeadingDetectionModel.fonts(), + new java.util.ArrayList(java.util.Arrays.asList(fontSettingModel))); + + PdfSettings pdfSettingsModel = + new PdfSettings.Builder().heading(pdfHeadingDetectionModel).build(); + assertEquals(pdfSettingsModel.heading(), pdfHeadingDetectionModel); + + WordStyle wordStyleModel = + new WordStyle.Builder() + .level(Long.valueOf("26")) + .names(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals(wordStyleModel.level(), Long.valueOf("26")); + assertEquals( + wordStyleModel.names(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + WordHeadingDetection wordHeadingDetectionModel = + new WordHeadingDetection.Builder() + .fonts(new java.util.ArrayList(java.util.Arrays.asList(fontSettingModel))) + .styles(new java.util.ArrayList(java.util.Arrays.asList(wordStyleModel))) + .build(); + assertEquals( + wordHeadingDetectionModel.fonts(), + new java.util.ArrayList(java.util.Arrays.asList(fontSettingModel))); + assertEquals( + wordHeadingDetectionModel.styles(), + new java.util.ArrayList(java.util.Arrays.asList(wordStyleModel))); + + WordSettings wordSettingsModel = + new WordSettings.Builder().heading(wordHeadingDetectionModel).build(); + assertEquals(wordSettingsModel.heading(), wordHeadingDetectionModel); + + XPathPatterns xPathPatternsModel = + new XPathPatterns.Builder() + .xpaths(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals( + xPathPatternsModel.xpaths(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + HtmlSettings htmlSettingsModel = + new HtmlSettings.Builder() + .excludeTagsCompletely( + new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .excludeTagsKeepContent( + new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .keepContent(xPathPatternsModel) + .excludeContent(xPathPatternsModel) + .keepTagAttributes( + new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .excludeTagAttributes( + new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals( + htmlSettingsModel.excludeTagsCompletely(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals( + htmlSettingsModel.excludeTagsKeepContent(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals(htmlSettingsModel.keepContent(), xPathPatternsModel); + assertEquals(htmlSettingsModel.excludeContent(), xPathPatternsModel); + assertEquals( + htmlSettingsModel.keepTagAttributes(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals( + htmlSettingsModel.excludeTagAttributes(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + SegmentSettings segmentSettingsModel = + new SegmentSettings.Builder() + .enabled(true) + .selectorTags(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .annotatedFields(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals(segmentSettingsModel.enabled(), Boolean.valueOf(true)); + assertEquals( + segmentSettingsModel.selectorTags(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals( + segmentSettingsModel.annotatedFields(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + NormalizationOperation normalizationOperationModel = + new NormalizationOperation.Builder() + .operation("copy") + .sourceField("testString") + .destinationField("testString") + .build(); + assertEquals(normalizationOperationModel.operation(), "copy"); + assertEquals(normalizationOperationModel.sourceField(), "testString"); + assertEquals(normalizationOperationModel.destinationField(), "testString"); + + Conversions conversionsModel = + new Conversions.Builder() + .pdf(pdfSettingsModel) + .word(wordSettingsModel) + .html(htmlSettingsModel) + .segment(segmentSettingsModel) + .jsonNormalizations( + new java.util.ArrayList( + java.util.Arrays.asList(normalizationOperationModel))) + .imageTextRecognition(true) + .build(); + assertEquals(conversionsModel.pdf(), pdfSettingsModel); + assertEquals(conversionsModel.word(), wordSettingsModel); + assertEquals(conversionsModel.html(), htmlSettingsModel); + assertEquals(conversionsModel.segment(), segmentSettingsModel); + assertEquals( + conversionsModel.jsonNormalizations(), + new java.util.ArrayList( + java.util.Arrays.asList(normalizationOperationModel))); + assertEquals(conversionsModel.imageTextRecognition(), Boolean.valueOf(true)); + + NluEnrichmentKeywords nluEnrichmentKeywordsModel = + new NluEnrichmentKeywords.Builder() + .sentiment(true) + .emotion(true) + .limit(Long.valueOf("26")) + .build(); + assertEquals(nluEnrichmentKeywordsModel.sentiment(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentKeywordsModel.emotion(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentKeywordsModel.limit(), Long.valueOf("26")); + + NluEnrichmentEntities nluEnrichmentEntitiesModel = + new NluEnrichmentEntities.Builder() + .sentiment(true) + .emotion(true) + .limit(Long.valueOf("26")) + .mentions(true) + .mentionTypes(true) + .sentenceLocations(true) + .model("testString") + .build(); + assertEquals(nluEnrichmentEntitiesModel.sentiment(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentEntitiesModel.emotion(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentEntitiesModel.limit(), Long.valueOf("26")); + assertEquals(nluEnrichmentEntitiesModel.mentions(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentEntitiesModel.mentionTypes(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentEntitiesModel.sentenceLocations(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentEntitiesModel.model(), "testString"); + + NluEnrichmentSentiment nluEnrichmentSentimentModel = + new NluEnrichmentSentiment.Builder() + .document(true) + .targets(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals(nluEnrichmentSentimentModel.document(), Boolean.valueOf(true)); + assertEquals( + nluEnrichmentSentimentModel.targets(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + NluEnrichmentEmotion nluEnrichmentEmotionModel = + new NluEnrichmentEmotion.Builder() + .document(true) + .targets(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals(nluEnrichmentEmotionModel.document(), Boolean.valueOf(true)); + assertEquals( + nluEnrichmentEmotionModel.targets(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + NluEnrichmentSemanticRoles nluEnrichmentSemanticRolesModel = + new NluEnrichmentSemanticRoles.Builder() + .entities(true) + .keywords(true) + .limit(Long.valueOf("26")) + .build(); + assertEquals(nluEnrichmentSemanticRolesModel.entities(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentSemanticRolesModel.keywords(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentSemanticRolesModel.limit(), Long.valueOf("26")); + + NluEnrichmentRelations nluEnrichmentRelationsModel = + new NluEnrichmentRelations.Builder().model("testString").build(); + assertEquals(nluEnrichmentRelationsModel.model(), "testString"); + + NluEnrichmentConcepts nluEnrichmentConceptsModel = + new NluEnrichmentConcepts.Builder().limit(Long.valueOf("26")).build(); + assertEquals(nluEnrichmentConceptsModel.limit(), Long.valueOf("26")); + + NluEnrichmentFeatures nluEnrichmentFeaturesModel = + new NluEnrichmentFeatures.Builder() + .keywords(nluEnrichmentKeywordsModel) + .entities(nluEnrichmentEntitiesModel) + .sentiment(nluEnrichmentSentimentModel) + .emotion(nluEnrichmentEmotionModel) + .categories( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .semanticRoles(nluEnrichmentSemanticRolesModel) + .relations(nluEnrichmentRelationsModel) + .concepts(nluEnrichmentConceptsModel) + .build(); + assertEquals(nluEnrichmentFeaturesModel.keywords(), nluEnrichmentKeywordsModel); + assertEquals(nluEnrichmentFeaturesModel.entities(), nluEnrichmentEntitiesModel); + assertEquals(nluEnrichmentFeaturesModel.sentiment(), nluEnrichmentSentimentModel); + assertEquals(nluEnrichmentFeaturesModel.emotion(), nluEnrichmentEmotionModel); + assertEquals( + nluEnrichmentFeaturesModel.categories(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals(nluEnrichmentFeaturesModel.semanticRoles(), nluEnrichmentSemanticRolesModel); + assertEquals(nluEnrichmentFeaturesModel.relations(), nluEnrichmentRelationsModel); + assertEquals(nluEnrichmentFeaturesModel.concepts(), nluEnrichmentConceptsModel); + + EnrichmentOptions enrichmentOptionsModel = + new EnrichmentOptions.Builder() + .features(nluEnrichmentFeaturesModel) + .language("ar") + .model("testString") + .build(); + assertEquals(enrichmentOptionsModel.features(), nluEnrichmentFeaturesModel); + assertEquals(enrichmentOptionsModel.language(), "ar"); + assertEquals(enrichmentOptionsModel.model(), "testString"); + + Enrichment enrichmentModel = + new Enrichment.Builder() + .description("testString") + .destinationField("testString") + .sourceField("testString") + .overwrite(true) + .enrichment("testString") + .ignoreDownstreamErrors(true) + .options(enrichmentOptionsModel) + .build(); + assertEquals(enrichmentModel.description(), "testString"); + assertEquals(enrichmentModel.destinationField(), "testString"); + assertEquals(enrichmentModel.sourceField(), "testString"); + assertEquals(enrichmentModel.overwrite(), Boolean.valueOf(true)); + assertEquals(enrichmentModel.enrichment(), "testString"); + assertEquals(enrichmentModel.ignoreDownstreamErrors(), Boolean.valueOf(true)); + assertEquals(enrichmentModel.options(), enrichmentOptionsModel); + + SourceSchedule sourceScheduleModel = + new SourceSchedule.Builder() + .enabled(true) + .timeZone("testString") + .frequency("daily") + .build(); + assertEquals(sourceScheduleModel.enabled(), Boolean.valueOf(true)); + assertEquals(sourceScheduleModel.timeZone(), "testString"); + assertEquals(sourceScheduleModel.frequency(), "daily"); + + SourceOptionsFolder sourceOptionsFolderModel = + new SourceOptionsFolder.Builder() + .ownerUserId("testString") + .folderId("testString") + .limit(Long.valueOf("26")) + .build(); + assertEquals(sourceOptionsFolderModel.ownerUserId(), "testString"); + assertEquals(sourceOptionsFolderModel.folderId(), "testString"); + assertEquals(sourceOptionsFolderModel.limit(), Long.valueOf("26")); + + SourceOptionsObject sourceOptionsObjectModel = + new SourceOptionsObject.Builder().name("testString").limit(Long.valueOf("26")).build(); + assertEquals(sourceOptionsObjectModel.name(), "testString"); + assertEquals(sourceOptionsObjectModel.limit(), Long.valueOf("26")); + + SourceOptionsSiteColl sourceOptionsSiteCollModel = + new SourceOptionsSiteColl.Builder() + .siteCollectionPath("testString") + .limit(Long.valueOf("26")) + .build(); + assertEquals(sourceOptionsSiteCollModel.siteCollectionPath(), "testString"); + assertEquals(sourceOptionsSiteCollModel.limit(), Long.valueOf("26")); + + SourceOptionsWebCrawl sourceOptionsWebCrawlModel = + new SourceOptionsWebCrawl.Builder() + .url("testString") + .limitToStartingHosts(true) + .crawlSpeed("gentle") + .allowUntrustedCertificate(true) + .maximumHops(Long.valueOf("26")) + .requestTimeout(Long.valueOf("26")) + .overrideRobotsTxt(true) + .blacklist(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals(sourceOptionsWebCrawlModel.url(), "testString"); + assertEquals(sourceOptionsWebCrawlModel.limitToStartingHosts(), Boolean.valueOf(true)); + assertEquals(sourceOptionsWebCrawlModel.crawlSpeed(), "gentle"); + assertEquals(sourceOptionsWebCrawlModel.allowUntrustedCertificate(), Boolean.valueOf(true)); + assertEquals(sourceOptionsWebCrawlModel.maximumHops(), Long.valueOf("26")); + assertEquals(sourceOptionsWebCrawlModel.requestTimeout(), Long.valueOf("26")); + assertEquals(sourceOptionsWebCrawlModel.overrideRobotsTxt(), Boolean.valueOf(true)); + assertEquals( + sourceOptionsWebCrawlModel.blacklist(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + SourceOptionsBuckets sourceOptionsBucketsModel = + new SourceOptionsBuckets.Builder().name("testString").limit(Long.valueOf("26")).build(); + assertEquals(sourceOptionsBucketsModel.name(), "testString"); + assertEquals(sourceOptionsBucketsModel.limit(), Long.valueOf("26")); + + SourceOptions sourceOptionsModel = + new SourceOptions.Builder() + .folders( + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsFolderModel))) + .objects( + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsObjectModel))) + .siteCollections( + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsSiteCollModel))) + .urls( + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsWebCrawlModel))) + .buckets( + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsBucketsModel))) + .crawlAllBuckets(true) + .build(); + assertEquals( + sourceOptionsModel.folders(), + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsFolderModel))); + assertEquals( + sourceOptionsModel.objects(), + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsObjectModel))); + assertEquals( + sourceOptionsModel.siteCollections(), + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsSiteCollModel))); + assertEquals( + sourceOptionsModel.urls(), + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsWebCrawlModel))); + assertEquals( + sourceOptionsModel.buckets(), + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsBucketsModel))); + assertEquals(sourceOptionsModel.crawlAllBuckets(), Boolean.valueOf(true)); + + Source sourceModel = + new Source.Builder() + .type("box") + .credentialId("testString") + .schedule(sourceScheduleModel) + .options(sourceOptionsModel) + .build(); + assertEquals(sourceModel.type(), "box"); + assertEquals(sourceModel.credentialId(), "testString"); + assertEquals(sourceModel.schedule(), sourceScheduleModel); + assertEquals(sourceModel.options(), sourceOptionsModel); + + CreateConfigurationOptions createConfigurationOptionsModel = + new CreateConfigurationOptions.Builder() + .environmentId("testString") + .name("testString") + .description("testString") + .conversions(conversionsModel) + .enrichments( + new java.util.ArrayList(java.util.Arrays.asList(enrichmentModel))) + .normalizations( + new java.util.ArrayList( + java.util.Arrays.asList(normalizationOperationModel))) + .source(sourceModel) + .build(); + assertEquals(createConfigurationOptionsModel.environmentId(), "testString"); + assertEquals(createConfigurationOptionsModel.name(), "testString"); + assertEquals(createConfigurationOptionsModel.description(), "testString"); + assertEquals(createConfigurationOptionsModel.conversions(), conversionsModel); + assertEquals( + createConfigurationOptionsModel.enrichments(), + new java.util.ArrayList(java.util.Arrays.asList(enrichmentModel))); + assertEquals( + createConfigurationOptionsModel.normalizations(), + new java.util.ArrayList( + java.util.Arrays.asList(normalizationOperationModel))); + assertEquals(createConfigurationOptionsModel.source(), sourceModel); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateConfigurationOptionsError() throws Throwable { + new CreateConfigurationOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CreateCredentialsOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CreateCredentialsOptionsTest.java new file mode 100644 index 00000000000..d37bed5ce76 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CreateCredentialsOptionsTest.java @@ -0,0 +1,92 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateCredentialsOptions model. */ +public class CreateCredentialsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateCredentialsOptions() throws Throwable { + CredentialDetails credentialDetailsModel = + new CredentialDetails.Builder() + .credentialType("oauth2") + .clientId("testString") + .enterpriseId("testString") + .url("testString") + .username("testString") + .organizationUrl("testString") + .siteCollectionPath("testString") + .clientSecret("testString") + .publicKeyId("testString") + .privateKey("testString") + .passphrase("testString") + .password("testString") + .gatewayId("testString") + .sourceVersion("online") + .webApplicationUrl("testString") + .domain("testString") + .endpoint("testString") + .accessKeyId("testString") + .secretAccessKey("testString") + .build(); + assertEquals(credentialDetailsModel.credentialType(), "oauth2"); + assertEquals(credentialDetailsModel.clientId(), "testString"); + assertEquals(credentialDetailsModel.enterpriseId(), "testString"); + assertEquals(credentialDetailsModel.url(), "testString"); + assertEquals(credentialDetailsModel.username(), "testString"); + assertEquals(credentialDetailsModel.organizationUrl(), "testString"); + assertEquals(credentialDetailsModel.siteCollectionPath(), "testString"); + assertEquals(credentialDetailsModel.clientSecret(), "testString"); + assertEquals(credentialDetailsModel.publicKeyId(), "testString"); + assertEquals(credentialDetailsModel.privateKey(), "testString"); + assertEquals(credentialDetailsModel.passphrase(), "testString"); + assertEquals(credentialDetailsModel.password(), "testString"); + assertEquals(credentialDetailsModel.gatewayId(), "testString"); + assertEquals(credentialDetailsModel.sourceVersion(), "online"); + assertEquals(credentialDetailsModel.webApplicationUrl(), "testString"); + assertEquals(credentialDetailsModel.domain(), "testString"); + assertEquals(credentialDetailsModel.endpoint(), "testString"); + assertEquals(credentialDetailsModel.accessKeyId(), "testString"); + assertEquals(credentialDetailsModel.secretAccessKey(), "testString"); + + CreateCredentialsOptions createCredentialsOptionsModel = + new CreateCredentialsOptions.Builder() + .environmentId("testString") + .sourceType("box") + .credentialDetails(credentialDetailsModel) + .status("connected") + .build(); + assertEquals(createCredentialsOptionsModel.environmentId(), "testString"); + assertEquals(createCredentialsOptionsModel.sourceType(), "box"); + assertEquals(createCredentialsOptionsModel.credentialDetails(), credentialDetailsModel); + assertEquals(createCredentialsOptionsModel.status(), "connected"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateCredentialsOptionsError() throws Throwable { + new CreateCredentialsOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CreateEnvironmentOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CreateEnvironmentOptionsTest.java new file mode 100644 index 00000000000..4283c9a6d4a --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CreateEnvironmentOptionsTest.java @@ -0,0 +1,48 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateEnvironmentOptions model. */ +public class CreateEnvironmentOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateEnvironmentOptions() throws Throwable { + CreateEnvironmentOptions createEnvironmentOptionsModel = + new CreateEnvironmentOptions.Builder() + .name("testString") + .description("testString") + .size("LT") + .build(); + assertEquals(createEnvironmentOptionsModel.name(), "testString"); + assertEquals(createEnvironmentOptionsModel.description(), "testString"); + assertEquals(createEnvironmentOptionsModel.size(), "LT"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateEnvironmentOptionsError() throws Throwable { + new CreateEnvironmentOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CreateEventOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CreateEventOptionsTest.java new file mode 100644 index 00000000000..cf5a0997a00 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CreateEventOptionsTest.java @@ -0,0 +1,60 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateEventOptions model. */ +public class CreateEventOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateEventOptions() throws Throwable { + EventData eventDataModel = + new EventData.Builder() + .environmentId("testString") + .sessionToken("testString") + .clientTimestamp(TestUtilities.createMockDateTime("2019-01-01T12:00:00")) + .displayRank(Long.valueOf("26")) + .collectionId("testString") + .documentId("testString") + .build(); + assertEquals(eventDataModel.environmentId(), "testString"); + assertEquals(eventDataModel.sessionToken(), "testString"); + assertEquals( + eventDataModel.clientTimestamp(), TestUtilities.createMockDateTime("2019-01-01T12:00:00")); + assertEquals(eventDataModel.displayRank(), Long.valueOf("26")); + assertEquals(eventDataModel.collectionId(), "testString"); + assertEquals(eventDataModel.documentId(), "testString"); + + CreateEventOptions createEventOptionsModel = + new CreateEventOptions.Builder().type("click").data(eventDataModel).build(); + assertEquals(createEventOptionsModel.type(), "click"); + assertEquals(createEventOptionsModel.data(), eventDataModel); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateEventOptionsError() throws Throwable { + new CreateEventOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CreateEventResponseTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CreateEventResponseTest.java new file mode 100644 index 00000000000..c71eb32399e --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CreateEventResponseTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateEventResponse model. */ +public class CreateEventResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateEventResponse() throws Throwable { + CreateEventResponse createEventResponseModel = new CreateEventResponse(); + assertNull(createEventResponseModel.getType()); + assertNull(createEventResponseModel.getData()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CreateExpansionsOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CreateExpansionsOptionsTest.java new file mode 100644 index 00000000000..09e5d53d353 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CreateExpansionsOptionsTest.java @@ -0,0 +1,62 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateExpansionsOptions model. */ +public class CreateExpansionsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateExpansionsOptions() throws Throwable { + Expansion expansionModel = + new Expansion.Builder() + .inputTerms(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .expandedTerms(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals( + expansionModel.inputTerms(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals( + expansionModel.expandedTerms(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + CreateExpansionsOptions createExpansionsOptionsModel = + new CreateExpansionsOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .expansions(new java.util.ArrayList(java.util.Arrays.asList(expansionModel))) + .build(); + assertEquals(createExpansionsOptionsModel.environmentId(), "testString"); + assertEquals(createExpansionsOptionsModel.collectionId(), "testString"); + assertEquals( + createExpansionsOptionsModel.expansions(), + new java.util.ArrayList(java.util.Arrays.asList(expansionModel))); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateExpansionsOptionsError() throws Throwable { + new CreateExpansionsOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CreateGatewayOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CreateGatewayOptionsTest.java new file mode 100644 index 00000000000..9f237623fa3 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CreateGatewayOptionsTest.java @@ -0,0 +1,43 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateGatewayOptions model. */ +public class CreateGatewayOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateGatewayOptions() throws Throwable { + CreateGatewayOptions createGatewayOptionsModel = + new CreateGatewayOptions.Builder().environmentId("testString").name("testString").build(); + assertEquals(createGatewayOptionsModel.environmentId(), "testString"); + assertEquals(createGatewayOptionsModel.name(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateGatewayOptionsError() throws Throwable { + new CreateGatewayOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CreateStopwordListOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CreateStopwordListOptionsTest.java new file mode 100644 index 00000000000..cbf77840724 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CreateStopwordListOptionsTest.java @@ -0,0 +1,53 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.apache.commons.io.IOUtils; +import org.testng.annotations.Test; + +/** Unit test class for the CreateStopwordListOptions model. */ +public class CreateStopwordListOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateStopwordListOptions() throws Throwable { + CreateStopwordListOptions createStopwordListOptionsModel = + new CreateStopwordListOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .stopwordFile(TestUtilities.createMockStream("This is a mock file.")) + .stopwordFilename("testString") + .build(); + assertEquals(createStopwordListOptionsModel.environmentId(), "testString"); + assertEquals(createStopwordListOptionsModel.collectionId(), "testString"); + assertEquals( + IOUtils.toString(createStopwordListOptionsModel.stopwordFile()), + IOUtils.toString(TestUtilities.createMockStream("This is a mock file."))); + assertEquals(createStopwordListOptionsModel.stopwordFilename(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateStopwordListOptionsError() throws Throwable { + new CreateStopwordListOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CreateTokenizationDictionaryOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CreateTokenizationDictionaryOptionsTest.java new file mode 100644 index 00000000000..753432a39b8 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CreateTokenizationDictionaryOptionsTest.java @@ -0,0 +1,67 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateTokenizationDictionaryOptions model. */ +public class CreateTokenizationDictionaryOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateTokenizationDictionaryOptions() throws Throwable { + TokenDictRule tokenDictRuleModel = + new TokenDictRule.Builder() + .text("testString") + .tokens(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .readings(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .partOfSpeech("testString") + .build(); + assertEquals(tokenDictRuleModel.text(), "testString"); + assertEquals( + tokenDictRuleModel.tokens(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals( + tokenDictRuleModel.readings(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals(tokenDictRuleModel.partOfSpeech(), "testString"); + + CreateTokenizationDictionaryOptions createTokenizationDictionaryOptionsModel = + new CreateTokenizationDictionaryOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .tokenizationRules( + new java.util.ArrayList(java.util.Arrays.asList(tokenDictRuleModel))) + .build(); + assertEquals(createTokenizationDictionaryOptionsModel.environmentId(), "testString"); + assertEquals(createTokenizationDictionaryOptionsModel.collectionId(), "testString"); + assertEquals( + createTokenizationDictionaryOptionsModel.tokenizationRules(), + new java.util.ArrayList(java.util.Arrays.asList(tokenDictRuleModel))); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateTokenizationDictionaryOptionsError() throws Throwable { + new CreateTokenizationDictionaryOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CreateTrainingExampleOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CreateTrainingExampleOptionsTest.java new file mode 100644 index 00000000000..e9083adcafd --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CreateTrainingExampleOptionsTest.java @@ -0,0 +1,54 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateTrainingExampleOptions model. */ +public class CreateTrainingExampleOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateTrainingExampleOptions() throws Throwable { + CreateTrainingExampleOptions createTrainingExampleOptionsModel = + new CreateTrainingExampleOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .queryId("testString") + .documentId("testString") + .crossReference("testString") + .relevance(Long.valueOf("26")) + .build(); + assertEquals(createTrainingExampleOptionsModel.environmentId(), "testString"); + assertEquals(createTrainingExampleOptionsModel.collectionId(), "testString"); + assertEquals(createTrainingExampleOptionsModel.queryId(), "testString"); + assertEquals(createTrainingExampleOptionsModel.documentId(), "testString"); + assertEquals(createTrainingExampleOptionsModel.crossReference(), "testString"); + assertEquals(createTrainingExampleOptionsModel.relevance(), Long.valueOf("26")); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateTrainingExampleOptionsError() throws Throwable { + new CreateTrainingExampleOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CredentialDetailsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CredentialDetailsTest.java new file mode 100644 index 00000000000..22fc188c139 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CredentialDetailsTest.java @@ -0,0 +1,100 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CredentialDetails model. */ +public class CredentialDetailsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCredentialDetails() throws Throwable { + CredentialDetails credentialDetailsModel = + new CredentialDetails.Builder() + .credentialType("oauth2") + .clientId("testString") + .enterpriseId("testString") + .url("testString") + .username("testString") + .organizationUrl("testString") + .siteCollectionPath("testString") + .clientSecret("testString") + .publicKeyId("testString") + .privateKey("testString") + .passphrase("testString") + .password("testString") + .gatewayId("testString") + .sourceVersion("online") + .webApplicationUrl("testString") + .domain("testString") + .endpoint("testString") + .accessKeyId("testString") + .secretAccessKey("testString") + .build(); + assertEquals(credentialDetailsModel.credentialType(), "oauth2"); + assertEquals(credentialDetailsModel.clientId(), "testString"); + assertEquals(credentialDetailsModel.enterpriseId(), "testString"); + assertEquals(credentialDetailsModel.url(), "testString"); + assertEquals(credentialDetailsModel.username(), "testString"); + assertEquals(credentialDetailsModel.organizationUrl(), "testString"); + assertEquals(credentialDetailsModel.siteCollectionPath(), "testString"); + assertEquals(credentialDetailsModel.clientSecret(), "testString"); + assertEquals(credentialDetailsModel.publicKeyId(), "testString"); + assertEquals(credentialDetailsModel.privateKey(), "testString"); + assertEquals(credentialDetailsModel.passphrase(), "testString"); + assertEquals(credentialDetailsModel.password(), "testString"); + assertEquals(credentialDetailsModel.gatewayId(), "testString"); + assertEquals(credentialDetailsModel.sourceVersion(), "online"); + assertEquals(credentialDetailsModel.webApplicationUrl(), "testString"); + assertEquals(credentialDetailsModel.domain(), "testString"); + assertEquals(credentialDetailsModel.endpoint(), "testString"); + assertEquals(credentialDetailsModel.accessKeyId(), "testString"); + assertEquals(credentialDetailsModel.secretAccessKey(), "testString"); + + String json = TestUtilities.serialize(credentialDetailsModel); + + CredentialDetails credentialDetailsModelNew = + TestUtilities.deserialize(json, CredentialDetails.class); + assertTrue(credentialDetailsModelNew instanceof CredentialDetails); + assertEquals(credentialDetailsModelNew.credentialType(), "oauth2"); + assertEquals(credentialDetailsModelNew.clientId(), "testString"); + assertEquals(credentialDetailsModelNew.enterpriseId(), "testString"); + assertEquals(credentialDetailsModelNew.url(), "testString"); + assertEquals(credentialDetailsModelNew.username(), "testString"); + assertEquals(credentialDetailsModelNew.organizationUrl(), "testString"); + assertEquals(credentialDetailsModelNew.siteCollectionPath(), "testString"); + assertEquals(credentialDetailsModelNew.clientSecret(), "testString"); + assertEquals(credentialDetailsModelNew.publicKeyId(), "testString"); + assertEquals(credentialDetailsModelNew.privateKey(), "testString"); + assertEquals(credentialDetailsModelNew.passphrase(), "testString"); + assertEquals(credentialDetailsModelNew.password(), "testString"); + assertEquals(credentialDetailsModelNew.gatewayId(), "testString"); + assertEquals(credentialDetailsModelNew.sourceVersion(), "online"); + assertEquals(credentialDetailsModelNew.webApplicationUrl(), "testString"); + assertEquals(credentialDetailsModelNew.domain(), "testString"); + assertEquals(credentialDetailsModelNew.endpoint(), "testString"); + assertEquals(credentialDetailsModelNew.accessKeyId(), "testString"); + assertEquals(credentialDetailsModelNew.secretAccessKey(), "testString"); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CredentialsListTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CredentialsListTest.java new file mode 100644 index 00000000000..454c7734f2f --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CredentialsListTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CredentialsList model. */ +public class CredentialsListTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCredentialsList() throws Throwable { + CredentialsList credentialsListModel = new CredentialsList(); + assertNull(credentialsListModel.getCredentials()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CredentialsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CredentialsTest.java new file mode 100644 index 00000000000..b2c2bb595f3 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/CredentialsTest.java @@ -0,0 +1,94 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Credentials model. */ +public class CredentialsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCredentials() throws Throwable { + CredentialDetails credentialDetailsModel = + new CredentialDetails.Builder() + .credentialType("username_password") + .clientId("testString") + .enterpriseId("testString") + .url("login.salesforce.com") + .username("user@email.address") + .organizationUrl("testString") + .siteCollectionPath("testString") + .clientSecret("testString") + .publicKeyId("testString") + .privateKey("testString") + .passphrase("testString") + .password("testString") + .gatewayId("testString") + .sourceVersion("online") + .webApplicationUrl("testString") + .domain("testString") + .endpoint("testString") + .accessKeyId("testString") + .secretAccessKey("testString") + .build(); + assertEquals(credentialDetailsModel.credentialType(), "username_password"); + assertEquals(credentialDetailsModel.clientId(), "testString"); + assertEquals(credentialDetailsModel.enterpriseId(), "testString"); + assertEquals(credentialDetailsModel.url(), "login.salesforce.com"); + assertEquals(credentialDetailsModel.username(), "user@email.address"); + assertEquals(credentialDetailsModel.organizationUrl(), "testString"); + assertEquals(credentialDetailsModel.siteCollectionPath(), "testString"); + assertEquals(credentialDetailsModel.clientSecret(), "testString"); + assertEquals(credentialDetailsModel.publicKeyId(), "testString"); + assertEquals(credentialDetailsModel.privateKey(), "testString"); + assertEquals(credentialDetailsModel.passphrase(), "testString"); + assertEquals(credentialDetailsModel.password(), "testString"); + assertEquals(credentialDetailsModel.gatewayId(), "testString"); + assertEquals(credentialDetailsModel.sourceVersion(), "online"); + assertEquals(credentialDetailsModel.webApplicationUrl(), "testString"); + assertEquals(credentialDetailsModel.domain(), "testString"); + assertEquals(credentialDetailsModel.endpoint(), "testString"); + assertEquals(credentialDetailsModel.accessKeyId(), "testString"); + assertEquals(credentialDetailsModel.secretAccessKey(), "testString"); + + Credentials credentialsModel = + new Credentials.Builder() + .sourceType("box") + .credentialDetails(credentialDetailsModel) + .status("connected") + .build(); + assertEquals(credentialsModel.sourceType(), "box"); + assertEquals(credentialsModel.credentialDetails(), credentialDetailsModel); + assertEquals(credentialsModel.status(), "connected"); + + String json = TestUtilities.serialize(credentialsModel); + + Credentials credentialsModelNew = TestUtilities.deserialize(json, Credentials.class); + assertTrue(credentialsModelNew instanceof Credentials); + assertEquals(credentialsModelNew.sourceType(), "box"); + assertEquals( + credentialsModelNew.credentialDetails().toString(), credentialDetailsModel.toString()); + assertEquals(credentialsModelNew.status(), "connected"); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DeleteAllTrainingDataOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DeleteAllTrainingDataOptionsTest.java new file mode 100644 index 00000000000..39e24cfd3db --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DeleteAllTrainingDataOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteAllTrainingDataOptions model. */ +public class DeleteAllTrainingDataOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteAllTrainingDataOptions() throws Throwable { + DeleteAllTrainingDataOptions deleteAllTrainingDataOptionsModel = + new DeleteAllTrainingDataOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .build(); + assertEquals(deleteAllTrainingDataOptionsModel.environmentId(), "testString"); + assertEquals(deleteAllTrainingDataOptionsModel.collectionId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteAllTrainingDataOptionsError() throws Throwable { + new DeleteAllTrainingDataOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DeleteCollectionOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DeleteCollectionOptionsTest.java new file mode 100644 index 00000000000..0cd82847ae8 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DeleteCollectionOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteCollectionOptions model. */ +public class DeleteCollectionOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteCollectionOptions() throws Throwable { + DeleteCollectionOptions deleteCollectionOptionsModel = + new DeleteCollectionOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .build(); + assertEquals(deleteCollectionOptionsModel.environmentId(), "testString"); + assertEquals(deleteCollectionOptionsModel.collectionId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteCollectionOptionsError() throws Throwable { + new DeleteCollectionOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DeleteCollectionResponseTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DeleteCollectionResponseTest.java new file mode 100644 index 00000000000..eeb2269bfb1 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DeleteCollectionResponseTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteCollectionResponse model. */ +public class DeleteCollectionResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteCollectionResponse() throws Throwable { + DeleteCollectionResponse deleteCollectionResponseModel = new DeleteCollectionResponse(); + assertNull(deleteCollectionResponseModel.getCollectionId()); + assertNull(deleteCollectionResponseModel.getStatus()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DeleteConfigurationOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DeleteConfigurationOptionsTest.java new file mode 100644 index 00000000000..0b1b1d146b6 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DeleteConfigurationOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteConfigurationOptions model. */ +public class DeleteConfigurationOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteConfigurationOptions() throws Throwable { + DeleteConfigurationOptions deleteConfigurationOptionsModel = + new DeleteConfigurationOptions.Builder() + .environmentId("testString") + .configurationId("testString") + .build(); + assertEquals(deleteConfigurationOptionsModel.environmentId(), "testString"); + assertEquals(deleteConfigurationOptionsModel.configurationId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteConfigurationOptionsError() throws Throwable { + new DeleteConfigurationOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DeleteConfigurationResponseTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DeleteConfigurationResponseTest.java new file mode 100644 index 00000000000..b714bca5b45 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DeleteConfigurationResponseTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteConfigurationResponse model. */ +public class DeleteConfigurationResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteConfigurationResponse() throws Throwable { + DeleteConfigurationResponse deleteConfigurationResponseModel = + new DeleteConfigurationResponse(); + assertNull(deleteConfigurationResponseModel.getConfigurationId()); + assertNull(deleteConfigurationResponseModel.getStatus()); + assertNull(deleteConfigurationResponseModel.getNotices()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DeleteCredentialsOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DeleteCredentialsOptionsTest.java new file mode 100644 index 00000000000..3b3a6d1c89f --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DeleteCredentialsOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteCredentialsOptions model. */ +public class DeleteCredentialsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteCredentialsOptions() throws Throwable { + DeleteCredentialsOptions deleteCredentialsOptionsModel = + new DeleteCredentialsOptions.Builder() + .environmentId("testString") + .credentialId("testString") + .build(); + assertEquals(deleteCredentialsOptionsModel.environmentId(), "testString"); + assertEquals(deleteCredentialsOptionsModel.credentialId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteCredentialsOptionsError() throws Throwable { + new DeleteCredentialsOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DeleteCredentialsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DeleteCredentialsTest.java new file mode 100644 index 00000000000..3a8742589be --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DeleteCredentialsTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteCredentials model. */ +public class DeleteCredentialsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteCredentials() throws Throwable { + DeleteCredentials deleteCredentialsModel = new DeleteCredentials(); + assertNull(deleteCredentialsModel.getCredentialId()); + assertNull(deleteCredentialsModel.getStatus()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DeleteDocumentOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DeleteDocumentOptionsTest.java new file mode 100644 index 00000000000..2e4b5e02208 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DeleteDocumentOptionsTest.java @@ -0,0 +1,48 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteDocumentOptions model. */ +public class DeleteDocumentOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteDocumentOptions() throws Throwable { + DeleteDocumentOptions deleteDocumentOptionsModel = + new DeleteDocumentOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .documentId("testString") + .build(); + assertEquals(deleteDocumentOptionsModel.environmentId(), "testString"); + assertEquals(deleteDocumentOptionsModel.collectionId(), "testString"); + assertEquals(deleteDocumentOptionsModel.documentId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteDocumentOptionsError() throws Throwable { + new DeleteDocumentOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DeleteDocumentResponseTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DeleteDocumentResponseTest.java new file mode 100644 index 00000000000..0845324279c --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DeleteDocumentResponseTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteDocumentResponse model. */ +public class DeleteDocumentResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteDocumentResponse() throws Throwable { + DeleteDocumentResponse deleteDocumentResponseModel = new DeleteDocumentResponse(); + assertNull(deleteDocumentResponseModel.getDocumentId()); + assertNull(deleteDocumentResponseModel.getStatus()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DeleteEnvironmentOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DeleteEnvironmentOptionsTest.java new file mode 100644 index 00000000000..eb8c5784d9f --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DeleteEnvironmentOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteEnvironmentOptions model. */ +public class DeleteEnvironmentOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteEnvironmentOptions() throws Throwable { + DeleteEnvironmentOptions deleteEnvironmentOptionsModel = + new DeleteEnvironmentOptions.Builder().environmentId("testString").build(); + assertEquals(deleteEnvironmentOptionsModel.environmentId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteEnvironmentOptionsError() throws Throwable { + new DeleteEnvironmentOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DeleteEnvironmentResponseTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DeleteEnvironmentResponseTest.java new file mode 100644 index 00000000000..05f7324d4b4 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DeleteEnvironmentResponseTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteEnvironmentResponse model. */ +public class DeleteEnvironmentResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteEnvironmentResponse() throws Throwable { + DeleteEnvironmentResponse deleteEnvironmentResponseModel = new DeleteEnvironmentResponse(); + assertNull(deleteEnvironmentResponseModel.getEnvironmentId()); + assertNull(deleteEnvironmentResponseModel.getStatus()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DeleteExpansionsOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DeleteExpansionsOptionsTest.java new file mode 100644 index 00000000000..db2475920ed --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DeleteExpansionsOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteExpansionsOptions model. */ +public class DeleteExpansionsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteExpansionsOptions() throws Throwable { + DeleteExpansionsOptions deleteExpansionsOptionsModel = + new DeleteExpansionsOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .build(); + assertEquals(deleteExpansionsOptionsModel.environmentId(), "testString"); + assertEquals(deleteExpansionsOptionsModel.collectionId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteExpansionsOptionsError() throws Throwable { + new DeleteExpansionsOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DeleteGatewayOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DeleteGatewayOptionsTest.java new file mode 100644 index 00000000000..dc9bba850d4 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DeleteGatewayOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteGatewayOptions model. */ +public class DeleteGatewayOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteGatewayOptions() throws Throwable { + DeleteGatewayOptions deleteGatewayOptionsModel = + new DeleteGatewayOptions.Builder() + .environmentId("testString") + .gatewayId("testString") + .build(); + assertEquals(deleteGatewayOptionsModel.environmentId(), "testString"); + assertEquals(deleteGatewayOptionsModel.gatewayId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteGatewayOptionsError() throws Throwable { + new DeleteGatewayOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DeleteStopwordListOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DeleteStopwordListOptionsTest.java new file mode 100644 index 00000000000..aa5cfce9608 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DeleteStopwordListOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteStopwordListOptions model. */ +public class DeleteStopwordListOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteStopwordListOptions() throws Throwable { + DeleteStopwordListOptions deleteStopwordListOptionsModel = + new DeleteStopwordListOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .build(); + assertEquals(deleteStopwordListOptionsModel.environmentId(), "testString"); + assertEquals(deleteStopwordListOptionsModel.collectionId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteStopwordListOptionsError() throws Throwable { + new DeleteStopwordListOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DeleteTokenizationDictionaryOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DeleteTokenizationDictionaryOptionsTest.java new file mode 100644 index 00000000000..fdead2c11fc --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DeleteTokenizationDictionaryOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteTokenizationDictionaryOptions model. */ +public class DeleteTokenizationDictionaryOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteTokenizationDictionaryOptions() throws Throwable { + DeleteTokenizationDictionaryOptions deleteTokenizationDictionaryOptionsModel = + new DeleteTokenizationDictionaryOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .build(); + assertEquals(deleteTokenizationDictionaryOptionsModel.environmentId(), "testString"); + assertEquals(deleteTokenizationDictionaryOptionsModel.collectionId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteTokenizationDictionaryOptionsError() throws Throwable { + new DeleteTokenizationDictionaryOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DeleteTrainingDataOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DeleteTrainingDataOptionsTest.java new file mode 100644 index 00000000000..41345051a17 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DeleteTrainingDataOptionsTest.java @@ -0,0 +1,48 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteTrainingDataOptions model. */ +public class DeleteTrainingDataOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteTrainingDataOptions() throws Throwable { + DeleteTrainingDataOptions deleteTrainingDataOptionsModel = + new DeleteTrainingDataOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .queryId("testString") + .build(); + assertEquals(deleteTrainingDataOptionsModel.environmentId(), "testString"); + assertEquals(deleteTrainingDataOptionsModel.collectionId(), "testString"); + assertEquals(deleteTrainingDataOptionsModel.queryId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteTrainingDataOptionsError() throws Throwable { + new DeleteTrainingDataOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DeleteTrainingExampleOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DeleteTrainingExampleOptionsTest.java new file mode 100644 index 00000000000..a9221301a57 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DeleteTrainingExampleOptionsTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteTrainingExampleOptions model. */ +public class DeleteTrainingExampleOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteTrainingExampleOptions() throws Throwable { + DeleteTrainingExampleOptions deleteTrainingExampleOptionsModel = + new DeleteTrainingExampleOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .queryId("testString") + .exampleId("testString") + .build(); + assertEquals(deleteTrainingExampleOptionsModel.environmentId(), "testString"); + assertEquals(deleteTrainingExampleOptionsModel.collectionId(), "testString"); + assertEquals(deleteTrainingExampleOptionsModel.queryId(), "testString"); + assertEquals(deleteTrainingExampleOptionsModel.exampleId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteTrainingExampleOptionsError() throws Throwable { + new DeleteTrainingExampleOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DeleteUserDataOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DeleteUserDataOptionsTest.java new file mode 100644 index 00000000000..491fa5f484e --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DeleteUserDataOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteUserDataOptions model. */ +public class DeleteUserDataOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteUserDataOptions() throws Throwable { + DeleteUserDataOptions deleteUserDataOptionsModel = + new DeleteUserDataOptions.Builder().customerId("testString").build(); + assertEquals(deleteUserDataOptionsModel.customerId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteUserDataOptionsError() throws Throwable { + new DeleteUserDataOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DiskUsageTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DiskUsageTest.java new file mode 100644 index 00000000000..8e4a65aa2c3 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DiskUsageTest.java @@ -0,0 +1,35 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DiskUsage model. */ +public class DiskUsageTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDiskUsage() throws Throwable { + DiskUsage diskUsageModel = new DiskUsage(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DocumentAcceptedTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DocumentAcceptedTest.java new file mode 100644 index 00000000000..bb9399e28f5 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DocumentAcceptedTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DocumentAccepted model. */ +public class DocumentAcceptedTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDocumentAccepted() throws Throwable { + DocumentAccepted documentAcceptedModel = new DocumentAccepted(); + assertNull(documentAcceptedModel.getDocumentId()); + assertNull(documentAcceptedModel.getStatus()); + assertNull(documentAcceptedModel.getNotices()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DocumentCountsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DocumentCountsTest.java new file mode 100644 index 00000000000..605524516ad --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DocumentCountsTest.java @@ -0,0 +1,35 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DocumentCounts model. */ +public class DocumentCountsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDocumentCounts() throws Throwable { + DocumentCounts documentCountsModel = new DocumentCounts(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DocumentStatusTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DocumentStatusTest.java new file mode 100644 index 00000000000..21009a2fe15 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/DocumentStatusTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DocumentStatus model. */ +public class DocumentStatusTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDocumentStatus() throws Throwable { + DocumentStatus documentStatusModel = new DocumentStatus(); + assertNull(documentStatusModel.getFilename()); + assertNull(documentStatusModel.getFileType()); + assertNull(documentStatusModel.getSha1()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/EnrichmentOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/EnrichmentOptionsTest.java new file mode 100644 index 00000000000..60bb82d271f --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/EnrichmentOptionsTest.java @@ -0,0 +1,150 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the EnrichmentOptions model. */ +public class EnrichmentOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testEnrichmentOptions() throws Throwable { + NluEnrichmentKeywords nluEnrichmentKeywordsModel = + new NluEnrichmentKeywords.Builder() + .sentiment(true) + .emotion(true) + .limit(Long.valueOf("26")) + .build(); + assertEquals(nluEnrichmentKeywordsModel.sentiment(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentKeywordsModel.emotion(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentKeywordsModel.limit(), Long.valueOf("26")); + + NluEnrichmentEntities nluEnrichmentEntitiesModel = + new NluEnrichmentEntities.Builder() + .sentiment(true) + .emotion(true) + .limit(Long.valueOf("26")) + .mentions(true) + .mentionTypes(true) + .sentenceLocations(true) + .model("testString") + .build(); + assertEquals(nluEnrichmentEntitiesModel.sentiment(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentEntitiesModel.emotion(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentEntitiesModel.limit(), Long.valueOf("26")); + assertEquals(nluEnrichmentEntitiesModel.mentions(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentEntitiesModel.mentionTypes(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentEntitiesModel.sentenceLocations(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentEntitiesModel.model(), "testString"); + + NluEnrichmentSentiment nluEnrichmentSentimentModel = + new NluEnrichmentSentiment.Builder() + .document(true) + .targets(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals(nluEnrichmentSentimentModel.document(), Boolean.valueOf(true)); + assertEquals( + nluEnrichmentSentimentModel.targets(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + NluEnrichmentEmotion nluEnrichmentEmotionModel = + new NluEnrichmentEmotion.Builder() + .document(true) + .targets(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals(nluEnrichmentEmotionModel.document(), Boolean.valueOf(true)); + assertEquals( + nluEnrichmentEmotionModel.targets(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + NluEnrichmentSemanticRoles nluEnrichmentSemanticRolesModel = + new NluEnrichmentSemanticRoles.Builder() + .entities(true) + .keywords(true) + .limit(Long.valueOf("26")) + .build(); + assertEquals(nluEnrichmentSemanticRolesModel.entities(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentSemanticRolesModel.keywords(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentSemanticRolesModel.limit(), Long.valueOf("26")); + + NluEnrichmentRelations nluEnrichmentRelationsModel = + new NluEnrichmentRelations.Builder().model("testString").build(); + assertEquals(nluEnrichmentRelationsModel.model(), "testString"); + + NluEnrichmentConcepts nluEnrichmentConceptsModel = + new NluEnrichmentConcepts.Builder().limit(Long.valueOf("26")).build(); + assertEquals(nluEnrichmentConceptsModel.limit(), Long.valueOf("26")); + + NluEnrichmentFeatures nluEnrichmentFeaturesModel = + new NluEnrichmentFeatures.Builder() + .keywords(nluEnrichmentKeywordsModel) + .entities(nluEnrichmentEntitiesModel) + .sentiment(nluEnrichmentSentimentModel) + .emotion(nluEnrichmentEmotionModel) + .categories( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .semanticRoles(nluEnrichmentSemanticRolesModel) + .relations(nluEnrichmentRelationsModel) + .concepts(nluEnrichmentConceptsModel) + .build(); + assertEquals(nluEnrichmentFeaturesModel.keywords(), nluEnrichmentKeywordsModel); + assertEquals(nluEnrichmentFeaturesModel.entities(), nluEnrichmentEntitiesModel); + assertEquals(nluEnrichmentFeaturesModel.sentiment(), nluEnrichmentSentimentModel); + assertEquals(nluEnrichmentFeaturesModel.emotion(), nluEnrichmentEmotionModel); + assertEquals( + nluEnrichmentFeaturesModel.categories(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals(nluEnrichmentFeaturesModel.semanticRoles(), nluEnrichmentSemanticRolesModel); + assertEquals(nluEnrichmentFeaturesModel.relations(), nluEnrichmentRelationsModel); + assertEquals(nluEnrichmentFeaturesModel.concepts(), nluEnrichmentConceptsModel); + + EnrichmentOptions enrichmentOptionsModel = + new EnrichmentOptions.Builder() + .features(nluEnrichmentFeaturesModel) + .language("ar") + .model("testString") + .build(); + assertEquals(enrichmentOptionsModel.features(), nluEnrichmentFeaturesModel); + assertEquals(enrichmentOptionsModel.language(), "ar"); + assertEquals(enrichmentOptionsModel.model(), "testString"); + + String json = TestUtilities.serialize(enrichmentOptionsModel); + + EnrichmentOptions enrichmentOptionsModelNew = + TestUtilities.deserialize(json, EnrichmentOptions.class); + assertTrue(enrichmentOptionsModelNew instanceof EnrichmentOptions); + assertEquals( + enrichmentOptionsModelNew.features().toString(), nluEnrichmentFeaturesModel.toString()); + assertEquals(enrichmentOptionsModelNew.language(), "ar"); + assertEquals(enrichmentOptionsModelNew.model(), "testString"); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/EnrichmentTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/EnrichmentTest.java new file mode 100644 index 00000000000..7efe3ec0a90 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/EnrichmentTest.java @@ -0,0 +1,175 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Enrichment model. */ +public class EnrichmentTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testEnrichment() throws Throwable { + NluEnrichmentKeywords nluEnrichmentKeywordsModel = + new NluEnrichmentKeywords.Builder() + .sentiment(true) + .emotion(true) + .limit(Long.valueOf("26")) + .build(); + assertEquals(nluEnrichmentKeywordsModel.sentiment(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentKeywordsModel.emotion(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentKeywordsModel.limit(), Long.valueOf("26")); + + NluEnrichmentEntities nluEnrichmentEntitiesModel = + new NluEnrichmentEntities.Builder() + .sentiment(true) + .emotion(true) + .limit(Long.valueOf("26")) + .mentions(true) + .mentionTypes(true) + .sentenceLocations(true) + .model("testString") + .build(); + assertEquals(nluEnrichmentEntitiesModel.sentiment(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentEntitiesModel.emotion(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentEntitiesModel.limit(), Long.valueOf("26")); + assertEquals(nluEnrichmentEntitiesModel.mentions(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentEntitiesModel.mentionTypes(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentEntitiesModel.sentenceLocations(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentEntitiesModel.model(), "testString"); + + NluEnrichmentSentiment nluEnrichmentSentimentModel = + new NluEnrichmentSentiment.Builder() + .document(true) + .targets(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals(nluEnrichmentSentimentModel.document(), Boolean.valueOf(true)); + assertEquals( + nluEnrichmentSentimentModel.targets(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + NluEnrichmentEmotion nluEnrichmentEmotionModel = + new NluEnrichmentEmotion.Builder() + .document(true) + .targets(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals(nluEnrichmentEmotionModel.document(), Boolean.valueOf(true)); + assertEquals( + nluEnrichmentEmotionModel.targets(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + NluEnrichmentSemanticRoles nluEnrichmentSemanticRolesModel = + new NluEnrichmentSemanticRoles.Builder() + .entities(true) + .keywords(true) + .limit(Long.valueOf("26")) + .build(); + assertEquals(nluEnrichmentSemanticRolesModel.entities(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentSemanticRolesModel.keywords(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentSemanticRolesModel.limit(), Long.valueOf("26")); + + NluEnrichmentRelations nluEnrichmentRelationsModel = + new NluEnrichmentRelations.Builder().model("testString").build(); + assertEquals(nluEnrichmentRelationsModel.model(), "testString"); + + NluEnrichmentConcepts nluEnrichmentConceptsModel = + new NluEnrichmentConcepts.Builder().limit(Long.valueOf("26")).build(); + assertEquals(nluEnrichmentConceptsModel.limit(), Long.valueOf("26")); + + NluEnrichmentFeatures nluEnrichmentFeaturesModel = + new NluEnrichmentFeatures.Builder() + .keywords(nluEnrichmentKeywordsModel) + .entities(nluEnrichmentEntitiesModel) + .sentiment(nluEnrichmentSentimentModel) + .emotion(nluEnrichmentEmotionModel) + .categories( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .semanticRoles(nluEnrichmentSemanticRolesModel) + .relations(nluEnrichmentRelationsModel) + .concepts(nluEnrichmentConceptsModel) + .build(); + assertEquals(nluEnrichmentFeaturesModel.keywords(), nluEnrichmentKeywordsModel); + assertEquals(nluEnrichmentFeaturesModel.entities(), nluEnrichmentEntitiesModel); + assertEquals(nluEnrichmentFeaturesModel.sentiment(), nluEnrichmentSentimentModel); + assertEquals(nluEnrichmentFeaturesModel.emotion(), nluEnrichmentEmotionModel); + assertEquals( + nluEnrichmentFeaturesModel.categories(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals(nluEnrichmentFeaturesModel.semanticRoles(), nluEnrichmentSemanticRolesModel); + assertEquals(nluEnrichmentFeaturesModel.relations(), nluEnrichmentRelationsModel); + assertEquals(nluEnrichmentFeaturesModel.concepts(), nluEnrichmentConceptsModel); + + EnrichmentOptions enrichmentOptionsModel = + new EnrichmentOptions.Builder() + .features(nluEnrichmentFeaturesModel) + .language("ar") + .model("testString") + .build(); + assertEquals(enrichmentOptionsModel.features(), nluEnrichmentFeaturesModel); + assertEquals(enrichmentOptionsModel.language(), "ar"); + assertEquals(enrichmentOptionsModel.model(), "testString"); + + Enrichment enrichmentModel = + new Enrichment.Builder() + .description("testString") + .destinationField("testString") + .sourceField("testString") + .overwrite(true) + .enrichment("testString") + .ignoreDownstreamErrors(true) + .options(enrichmentOptionsModel) + .build(); + assertEquals(enrichmentModel.description(), "testString"); + assertEquals(enrichmentModel.destinationField(), "testString"); + assertEquals(enrichmentModel.sourceField(), "testString"); + assertEquals(enrichmentModel.overwrite(), Boolean.valueOf(true)); + assertEquals(enrichmentModel.enrichment(), "testString"); + assertEquals(enrichmentModel.ignoreDownstreamErrors(), Boolean.valueOf(true)); + assertEquals(enrichmentModel.options(), enrichmentOptionsModel); + + String json = TestUtilities.serialize(enrichmentModel); + + Enrichment enrichmentModelNew = TestUtilities.deserialize(json, Enrichment.class); + assertTrue(enrichmentModelNew instanceof Enrichment); + assertEquals(enrichmentModelNew.description(), "testString"); + assertEquals(enrichmentModelNew.destinationField(), "testString"); + assertEquals(enrichmentModelNew.sourceField(), "testString"); + assertEquals(enrichmentModelNew.overwrite(), Boolean.valueOf(true)); + assertEquals(enrichmentModelNew.enrichment(), "testString"); + assertEquals(enrichmentModelNew.ignoreDownstreamErrors(), Boolean.valueOf(true)); + assertEquals(enrichmentModelNew.options().toString(), enrichmentOptionsModel.toString()); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testEnrichmentError() throws Throwable { + new Enrichment.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/EnvironmentDocumentsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/EnvironmentDocumentsTest.java new file mode 100644 index 00000000000..e7222fc407d --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/EnvironmentDocumentsTest.java @@ -0,0 +1,35 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the EnvironmentDocuments model. */ +public class EnvironmentDocumentsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testEnvironmentDocuments() throws Throwable { + EnvironmentDocuments environmentDocumentsModel = new EnvironmentDocuments(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/EnvironmentTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/EnvironmentTest.java new file mode 100644 index 00000000000..fee64f22d0b --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/EnvironmentTest.java @@ -0,0 +1,41 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Environment model. */ +public class EnvironmentTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testEnvironment() throws Throwable { + Environment environmentModel = new Environment(); + assertNull(environmentModel.getName()); + assertNull(environmentModel.getDescription()); + assertNull(environmentModel.getSize()); + assertNull(environmentModel.getRequestedSize()); + assertNull(environmentModel.getIndexCapacity()); + assertNull(environmentModel.getSearchStatus()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/EventDataTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/EventDataTest.java new file mode 100644 index 00000000000..ee79a3914f3 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/EventDataTest.java @@ -0,0 +1,68 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the EventData model. */ +public class EventDataTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testEventData() throws Throwable { + EventData eventDataModel = + new EventData.Builder() + .environmentId("testString") + .sessionToken("testString") + .clientTimestamp(TestUtilities.createMockDateTime("2019-01-01T12:00:00")) + .displayRank(Long.valueOf("26")) + .collectionId("testString") + .documentId("testString") + .build(); + assertEquals(eventDataModel.environmentId(), "testString"); + assertEquals(eventDataModel.sessionToken(), "testString"); + assertEquals( + eventDataModel.clientTimestamp(), TestUtilities.createMockDateTime("2019-01-01T12:00:00")); + assertEquals(eventDataModel.displayRank(), Long.valueOf("26")); + assertEquals(eventDataModel.collectionId(), "testString"); + assertEquals(eventDataModel.documentId(), "testString"); + + String json = TestUtilities.serialize(eventDataModel); + + EventData eventDataModelNew = TestUtilities.deserialize(json, EventData.class); + assertTrue(eventDataModelNew instanceof EventData); + assertEquals(eventDataModelNew.environmentId(), "testString"); + assertEquals(eventDataModelNew.sessionToken(), "testString"); + assertEquals( + eventDataModelNew.clientTimestamp(), + TestUtilities.createMockDateTime("2019-01-01T12:00:00")); + assertEquals(eventDataModelNew.displayRank(), Long.valueOf("26")); + assertEquals(eventDataModelNew.collectionId(), "testString"); + assertEquals(eventDataModelNew.documentId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testEventDataError() throws Throwable { + new EventData.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/ExpansionTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/ExpansionTest.java new file mode 100644 index 00000000000..644fd8bf89b --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/ExpansionTest.java @@ -0,0 +1,55 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Expansion model. */ +public class ExpansionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testExpansion() throws Throwable { + Expansion expansionModel = + new Expansion.Builder() + .inputTerms(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .expandedTerms(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals( + expansionModel.inputTerms(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals( + expansionModel.expandedTerms(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + String json = TestUtilities.serialize(expansionModel); + + Expansion expansionModelNew = TestUtilities.deserialize(json, Expansion.class); + assertTrue(expansionModelNew instanceof Expansion); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testExpansionError() throws Throwable { + new Expansion.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/ExpansionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/ExpansionsTest.java new file mode 100644 index 00000000000..b2951d68f8c --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/ExpansionsTest.java @@ -0,0 +1,63 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Expansions model. */ +public class ExpansionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testExpansions() throws Throwable { + Expansion expansionModel = + new Expansion.Builder() + .inputTerms(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .expandedTerms(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals( + expansionModel.inputTerms(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals( + expansionModel.expandedTerms(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + Expansions expansionsModel = + new Expansions.Builder() + .expansions(new java.util.ArrayList(java.util.Arrays.asList(expansionModel))) + .build(); + assertEquals( + expansionsModel.expansions(), + new java.util.ArrayList(java.util.Arrays.asList(expansionModel))); + + String json = TestUtilities.serialize(expansionsModel); + + Expansions expansionsModelNew = TestUtilities.deserialize(json, Expansions.class); + assertTrue(expansionsModelNew instanceof Expansions); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testExpansionsError() throws Throwable { + new Expansions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/FederatedQueryNoticesOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/FederatedQueryNoticesOptionsTest.java new file mode 100644 index 00000000000..4b92d816004 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/FederatedQueryNoticesOptionsTest.java @@ -0,0 +1,83 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the FederatedQueryNoticesOptions model. */ +public class FederatedQueryNoticesOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testFederatedQueryNoticesOptions() throws Throwable { + FederatedQueryNoticesOptions federatedQueryNoticesOptionsModel = + new FederatedQueryNoticesOptions.Builder() + .environmentId("testString") + .collectionIds(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .filter("testString") + .query("testString") + .naturalLanguageQuery("testString") + .aggregation("testString") + .count(Long.valueOf("26")) + .xReturn(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .offset(Long.valueOf("26")) + .sort(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .highlight(true) + .deduplicateField("testString") + .similar(true) + .similarDocumentIds( + new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .similarFields(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals(federatedQueryNoticesOptionsModel.environmentId(), "testString"); + assertEquals( + federatedQueryNoticesOptionsModel.collectionIds(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals(federatedQueryNoticesOptionsModel.filter(), "testString"); + assertEquals(federatedQueryNoticesOptionsModel.query(), "testString"); + assertEquals(federatedQueryNoticesOptionsModel.naturalLanguageQuery(), "testString"); + assertEquals(federatedQueryNoticesOptionsModel.aggregation(), "testString"); + assertEquals(federatedQueryNoticesOptionsModel.count(), Long.valueOf("26")); + assertEquals( + federatedQueryNoticesOptionsModel.xReturn(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals(federatedQueryNoticesOptionsModel.offset(), Long.valueOf("26")); + assertEquals( + federatedQueryNoticesOptionsModel.sort(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals(federatedQueryNoticesOptionsModel.highlight(), Boolean.valueOf(true)); + assertEquals(federatedQueryNoticesOptionsModel.deduplicateField(), "testString"); + assertEquals(federatedQueryNoticesOptionsModel.similar(), Boolean.valueOf(true)); + assertEquals( + federatedQueryNoticesOptionsModel.similarDocumentIds(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals( + federatedQueryNoticesOptionsModel.similarFields(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testFederatedQueryNoticesOptionsError() throws Throwable { + new FederatedQueryNoticesOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/FederatedQueryOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/FederatedQueryOptionsTest.java new file mode 100644 index 00000000000..534cf970aab --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/FederatedQueryOptionsTest.java @@ -0,0 +1,86 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the FederatedQueryOptions model. */ +public class FederatedQueryOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testFederatedQueryOptions() throws Throwable { + FederatedQueryOptions federatedQueryOptionsModel = + new FederatedQueryOptions.Builder() + .environmentId("testString") + .collectionIds("testString") + .filter("testString") + .query("testString") + .naturalLanguageQuery("testString") + .passages(true) + .aggregation("testString") + .count(Long.valueOf("26")) + .xReturn("testString") + .offset(Long.valueOf("26")) + .sort("testString") + .highlight(true) + .passagesFields("testString") + .passagesCount(Long.valueOf("100")) + .passagesCharacters(Long.valueOf("50")) + .deduplicate(true) + .deduplicateField("testString") + .similar(true) + .similarDocumentIds("testString") + .similarFields("testString") + .bias("testString") + .xWatsonLoggingOptOut(true) + .build(); + assertEquals(federatedQueryOptionsModel.environmentId(), "testString"); + assertEquals(federatedQueryOptionsModel.collectionIds(), "testString"); + assertEquals(federatedQueryOptionsModel.filter(), "testString"); + assertEquals(federatedQueryOptionsModel.query(), "testString"); + assertEquals(federatedQueryOptionsModel.naturalLanguageQuery(), "testString"); + assertEquals(federatedQueryOptionsModel.passages(), Boolean.valueOf(true)); + assertEquals(federatedQueryOptionsModel.aggregation(), "testString"); + assertEquals(federatedQueryOptionsModel.count(), Long.valueOf("26")); + assertEquals(federatedQueryOptionsModel.xReturn(), "testString"); + assertEquals(federatedQueryOptionsModel.offset(), Long.valueOf("26")); + assertEquals(federatedQueryOptionsModel.sort(), "testString"); + assertEquals(federatedQueryOptionsModel.highlight(), Boolean.valueOf(true)); + assertEquals(federatedQueryOptionsModel.passagesFields(), "testString"); + assertEquals(federatedQueryOptionsModel.passagesCount(), Long.valueOf("100")); + assertEquals(federatedQueryOptionsModel.passagesCharacters(), Long.valueOf("50")); + assertEquals(federatedQueryOptionsModel.deduplicate(), Boolean.valueOf(true)); + assertEquals(federatedQueryOptionsModel.deduplicateField(), "testString"); + assertEquals(federatedQueryOptionsModel.similar(), Boolean.valueOf(true)); + assertEquals(federatedQueryOptionsModel.similarDocumentIds(), "testString"); + assertEquals(federatedQueryOptionsModel.similarFields(), "testString"); + assertEquals(federatedQueryOptionsModel.bias(), "testString"); + assertEquals(federatedQueryOptionsModel.xWatsonLoggingOptOut(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testFederatedQueryOptionsError() throws Throwable { + new FederatedQueryOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/FieldTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/FieldTest.java new file mode 100644 index 00000000000..c0e96eb45c8 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/FieldTest.java @@ -0,0 +1,35 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Field model. */ +public class FieldTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testField() throws Throwable { + Field fieldModel = new Field(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/FilterTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/FilterTest.java new file mode 100644 index 00000000000..38ce76af92f --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/FilterTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Filter model. */ +public class FilterTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testFilter() throws Throwable { + Filter filterModel = new Filter(); + assertNull(filterModel.getType()); + assertNull(filterModel.getMatchingResults()); + assertNull(filterModel.getMatch()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/FontSettingTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/FontSettingTest.java new file mode 100644 index 00000000000..42a095938e1 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/FontSettingTest.java @@ -0,0 +1,60 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the FontSetting model. */ +public class FontSettingTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testFontSetting() throws Throwable { + FontSetting fontSettingModel = + new FontSetting.Builder() + .level(Long.valueOf("26")) + .minSize(Long.valueOf("26")) + .maxSize(Long.valueOf("26")) + .bold(true) + .italic(true) + .name("testString") + .build(); + assertEquals(fontSettingModel.level(), Long.valueOf("26")); + assertEquals(fontSettingModel.minSize(), Long.valueOf("26")); + assertEquals(fontSettingModel.maxSize(), Long.valueOf("26")); + assertEquals(fontSettingModel.bold(), Boolean.valueOf(true)); + assertEquals(fontSettingModel.italic(), Boolean.valueOf(true)); + assertEquals(fontSettingModel.name(), "testString"); + + String json = TestUtilities.serialize(fontSettingModel); + + FontSetting fontSettingModelNew = TestUtilities.deserialize(json, FontSetting.class); + assertTrue(fontSettingModelNew instanceof FontSetting); + assertEquals(fontSettingModelNew.level(), Long.valueOf("26")); + assertEquals(fontSettingModelNew.minSize(), Long.valueOf("26")); + assertEquals(fontSettingModelNew.maxSize(), Long.valueOf("26")); + assertEquals(fontSettingModelNew.bold(), Boolean.valueOf(true)); + assertEquals(fontSettingModelNew.italic(), Boolean.valueOf(true)); + assertEquals(fontSettingModelNew.name(), "testString"); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GatewayDeleteTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GatewayDeleteTest.java new file mode 100644 index 00000000000..4e2442edf25 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GatewayDeleteTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GatewayDelete model. */ +public class GatewayDeleteTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGatewayDelete() throws Throwable { + GatewayDelete gatewayDeleteModel = new GatewayDelete(); + assertNull(gatewayDeleteModel.getGatewayId()); + assertNull(gatewayDeleteModel.getStatus()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GatewayListTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GatewayListTest.java new file mode 100644 index 00000000000..cceccd8dc43 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GatewayListTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GatewayList model. */ +public class GatewayListTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGatewayList() throws Throwable { + GatewayList gatewayListModel = new GatewayList(); + assertNull(gatewayListModel.getGateways()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GatewayTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GatewayTest.java new file mode 100644 index 00000000000..4d35166ea79 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GatewayTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Gateway model. */ +public class GatewayTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGateway() throws Throwable { + Gateway gatewayModel = new Gateway(); + assertNull(gatewayModel.getGatewayId()); + assertNull(gatewayModel.getName()); + assertNull(gatewayModel.getStatus()); + assertNull(gatewayModel.getToken()); + assertNull(gatewayModel.getTokenId()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GetAutocompletionOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GetAutocompletionOptionsTest.java new file mode 100644 index 00000000000..b1b11356513 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GetAutocompletionOptionsTest.java @@ -0,0 +1,52 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetAutocompletionOptions model. */ +public class GetAutocompletionOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetAutocompletionOptions() throws Throwable { + GetAutocompletionOptions getAutocompletionOptionsModel = + new GetAutocompletionOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .prefix("testString") + .field("testString") + .count(Long.valueOf("26")) + .build(); + assertEquals(getAutocompletionOptionsModel.environmentId(), "testString"); + assertEquals(getAutocompletionOptionsModel.collectionId(), "testString"); + assertEquals(getAutocompletionOptionsModel.prefix(), "testString"); + assertEquals(getAutocompletionOptionsModel.field(), "testString"); + assertEquals(getAutocompletionOptionsModel.count(), Long.valueOf("26")); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetAutocompletionOptionsError() throws Throwable { + new GetAutocompletionOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GetCollectionOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GetCollectionOptionsTest.java new file mode 100644 index 00000000000..690a5ca70fb --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GetCollectionOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetCollectionOptions model. */ +public class GetCollectionOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetCollectionOptions() throws Throwable { + GetCollectionOptions getCollectionOptionsModel = + new GetCollectionOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .build(); + assertEquals(getCollectionOptionsModel.environmentId(), "testString"); + assertEquals(getCollectionOptionsModel.collectionId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetCollectionOptionsError() throws Throwable { + new GetCollectionOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GetConfigurationOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GetConfigurationOptionsTest.java new file mode 100644 index 00000000000..b9bc7c7af77 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GetConfigurationOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetConfigurationOptions model. */ +public class GetConfigurationOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetConfigurationOptions() throws Throwable { + GetConfigurationOptions getConfigurationOptionsModel = + new GetConfigurationOptions.Builder() + .environmentId("testString") + .configurationId("testString") + .build(); + assertEquals(getConfigurationOptionsModel.environmentId(), "testString"); + assertEquals(getConfigurationOptionsModel.configurationId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetConfigurationOptionsError() throws Throwable { + new GetConfigurationOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GetCredentialsOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GetCredentialsOptionsTest.java new file mode 100644 index 00000000000..4c7a4cf31e3 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GetCredentialsOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetCredentialsOptions model. */ +public class GetCredentialsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetCredentialsOptions() throws Throwable { + GetCredentialsOptions getCredentialsOptionsModel = + new GetCredentialsOptions.Builder() + .environmentId("testString") + .credentialId("testString") + .build(); + assertEquals(getCredentialsOptionsModel.environmentId(), "testString"); + assertEquals(getCredentialsOptionsModel.credentialId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetCredentialsOptionsError() throws Throwable { + new GetCredentialsOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GetDocumentStatusOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GetDocumentStatusOptionsTest.java new file mode 100644 index 00000000000..e8ada11a6f2 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GetDocumentStatusOptionsTest.java @@ -0,0 +1,48 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetDocumentStatusOptions model. */ +public class GetDocumentStatusOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetDocumentStatusOptions() throws Throwable { + GetDocumentStatusOptions getDocumentStatusOptionsModel = + new GetDocumentStatusOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .documentId("testString") + .build(); + assertEquals(getDocumentStatusOptionsModel.environmentId(), "testString"); + assertEquals(getDocumentStatusOptionsModel.collectionId(), "testString"); + assertEquals(getDocumentStatusOptionsModel.documentId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetDocumentStatusOptionsError() throws Throwable { + new GetDocumentStatusOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GetEnvironmentOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GetEnvironmentOptionsTest.java new file mode 100644 index 00000000000..08fa7ca9d9b --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GetEnvironmentOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetEnvironmentOptions model. */ +public class GetEnvironmentOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetEnvironmentOptions() throws Throwable { + GetEnvironmentOptions getEnvironmentOptionsModel = + new GetEnvironmentOptions.Builder().environmentId("testString").build(); + assertEquals(getEnvironmentOptionsModel.environmentId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetEnvironmentOptionsError() throws Throwable { + new GetEnvironmentOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GetGatewayOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GetGatewayOptionsTest.java new file mode 100644 index 00000000000..9214b446c77 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GetGatewayOptionsTest.java @@ -0,0 +1,43 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetGatewayOptions model. */ +public class GetGatewayOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetGatewayOptions() throws Throwable { + GetGatewayOptions getGatewayOptionsModel = + new GetGatewayOptions.Builder().environmentId("testString").gatewayId("testString").build(); + assertEquals(getGatewayOptionsModel.environmentId(), "testString"); + assertEquals(getGatewayOptionsModel.gatewayId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetGatewayOptionsError() throws Throwable { + new GetGatewayOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GetMetricsEventRateOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GetMetricsEventRateOptionsTest.java new file mode 100644 index 00000000000..769d9d63c94 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GetMetricsEventRateOptionsTest.java @@ -0,0 +1,47 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetMetricsEventRateOptions model. */ +public class GetMetricsEventRateOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetMetricsEventRateOptions() throws Throwable { + GetMetricsEventRateOptions getMetricsEventRateOptionsModel = + new GetMetricsEventRateOptions.Builder() + .startTime(TestUtilities.createMockDateTime("2019-01-01T12:00:00")) + .endTime(TestUtilities.createMockDateTime("2019-01-01T12:00:00")) + .resultType("document") + .build(); + assertEquals( + getMetricsEventRateOptionsModel.startTime(), + TestUtilities.createMockDateTime("2019-01-01T12:00:00")); + assertEquals( + getMetricsEventRateOptionsModel.endTime(), + TestUtilities.createMockDateTime("2019-01-01T12:00:00")); + assertEquals(getMetricsEventRateOptionsModel.resultType(), "document"); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GetMetricsQueryEventOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GetMetricsQueryEventOptionsTest.java new file mode 100644 index 00000000000..1543250ba49 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GetMetricsQueryEventOptionsTest.java @@ -0,0 +1,47 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetMetricsQueryEventOptions model. */ +public class GetMetricsQueryEventOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetMetricsQueryEventOptions() throws Throwable { + GetMetricsQueryEventOptions getMetricsQueryEventOptionsModel = + new GetMetricsQueryEventOptions.Builder() + .startTime(TestUtilities.createMockDateTime("2019-01-01T12:00:00")) + .endTime(TestUtilities.createMockDateTime("2019-01-01T12:00:00")) + .resultType("document") + .build(); + assertEquals( + getMetricsQueryEventOptionsModel.startTime(), + TestUtilities.createMockDateTime("2019-01-01T12:00:00")); + assertEquals( + getMetricsQueryEventOptionsModel.endTime(), + TestUtilities.createMockDateTime("2019-01-01T12:00:00")); + assertEquals(getMetricsQueryEventOptionsModel.resultType(), "document"); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GetMetricsQueryNoResultsOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GetMetricsQueryNoResultsOptionsTest.java new file mode 100644 index 00000000000..08e0cf80865 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GetMetricsQueryNoResultsOptionsTest.java @@ -0,0 +1,47 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetMetricsQueryNoResultsOptions model. */ +public class GetMetricsQueryNoResultsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetMetricsQueryNoResultsOptions() throws Throwable { + GetMetricsQueryNoResultsOptions getMetricsQueryNoResultsOptionsModel = + new GetMetricsQueryNoResultsOptions.Builder() + .startTime(TestUtilities.createMockDateTime("2019-01-01T12:00:00")) + .endTime(TestUtilities.createMockDateTime("2019-01-01T12:00:00")) + .resultType("document") + .build(); + assertEquals( + getMetricsQueryNoResultsOptionsModel.startTime(), + TestUtilities.createMockDateTime("2019-01-01T12:00:00")); + assertEquals( + getMetricsQueryNoResultsOptionsModel.endTime(), + TestUtilities.createMockDateTime("2019-01-01T12:00:00")); + assertEquals(getMetricsQueryNoResultsOptionsModel.resultType(), "document"); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GetMetricsQueryOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GetMetricsQueryOptionsTest.java new file mode 100644 index 00000000000..2ad9abdebac --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GetMetricsQueryOptionsTest.java @@ -0,0 +1,47 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetMetricsQueryOptions model. */ +public class GetMetricsQueryOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetMetricsQueryOptions() throws Throwable { + GetMetricsQueryOptions getMetricsQueryOptionsModel = + new GetMetricsQueryOptions.Builder() + .startTime(TestUtilities.createMockDateTime("2019-01-01T12:00:00")) + .endTime(TestUtilities.createMockDateTime("2019-01-01T12:00:00")) + .resultType("document") + .build(); + assertEquals( + getMetricsQueryOptionsModel.startTime(), + TestUtilities.createMockDateTime("2019-01-01T12:00:00")); + assertEquals( + getMetricsQueryOptionsModel.endTime(), + TestUtilities.createMockDateTime("2019-01-01T12:00:00")); + assertEquals(getMetricsQueryOptionsModel.resultType(), "document"); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GetMetricsQueryTokenEventOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GetMetricsQueryTokenEventOptionsTest.java new file mode 100644 index 00000000000..2ebbb7efd5c --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GetMetricsQueryTokenEventOptionsTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetMetricsQueryTokenEventOptions model. */ +public class GetMetricsQueryTokenEventOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetMetricsQueryTokenEventOptions() throws Throwable { + GetMetricsQueryTokenEventOptions getMetricsQueryTokenEventOptionsModel = + new GetMetricsQueryTokenEventOptions.Builder().count(Long.valueOf("26")).build(); + assertEquals(getMetricsQueryTokenEventOptionsModel.count(), Long.valueOf("26")); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GetStopwordListStatusOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GetStopwordListStatusOptionsTest.java new file mode 100644 index 00000000000..e3f9455c1eb --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GetStopwordListStatusOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetStopwordListStatusOptions model. */ +public class GetStopwordListStatusOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetStopwordListStatusOptions() throws Throwable { + GetStopwordListStatusOptions getStopwordListStatusOptionsModel = + new GetStopwordListStatusOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .build(); + assertEquals(getStopwordListStatusOptionsModel.environmentId(), "testString"); + assertEquals(getStopwordListStatusOptionsModel.collectionId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetStopwordListStatusOptionsError() throws Throwable { + new GetStopwordListStatusOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GetTokenizationDictionaryStatusOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GetTokenizationDictionaryStatusOptionsTest.java new file mode 100644 index 00000000000..72ca1cff4a3 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GetTokenizationDictionaryStatusOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetTokenizationDictionaryStatusOptions model. */ +public class GetTokenizationDictionaryStatusOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetTokenizationDictionaryStatusOptions() throws Throwable { + GetTokenizationDictionaryStatusOptions getTokenizationDictionaryStatusOptionsModel = + new GetTokenizationDictionaryStatusOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .build(); + assertEquals(getTokenizationDictionaryStatusOptionsModel.environmentId(), "testString"); + assertEquals(getTokenizationDictionaryStatusOptionsModel.collectionId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetTokenizationDictionaryStatusOptionsError() throws Throwable { + new GetTokenizationDictionaryStatusOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GetTrainingDataOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GetTrainingDataOptionsTest.java new file mode 100644 index 00000000000..21a4fa68a0d --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GetTrainingDataOptionsTest.java @@ -0,0 +1,48 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetTrainingDataOptions model. */ +public class GetTrainingDataOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetTrainingDataOptions() throws Throwable { + GetTrainingDataOptions getTrainingDataOptionsModel = + new GetTrainingDataOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .queryId("testString") + .build(); + assertEquals(getTrainingDataOptionsModel.environmentId(), "testString"); + assertEquals(getTrainingDataOptionsModel.collectionId(), "testString"); + assertEquals(getTrainingDataOptionsModel.queryId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetTrainingDataOptionsError() throws Throwable { + new GetTrainingDataOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GetTrainingExampleOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GetTrainingExampleOptionsTest.java new file mode 100644 index 00000000000..1b984d66cad --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/GetTrainingExampleOptionsTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetTrainingExampleOptions model. */ +public class GetTrainingExampleOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetTrainingExampleOptions() throws Throwable { + GetTrainingExampleOptions getTrainingExampleOptionsModel = + new GetTrainingExampleOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .queryId("testString") + .exampleId("testString") + .build(); + assertEquals(getTrainingExampleOptionsModel.environmentId(), "testString"); + assertEquals(getTrainingExampleOptionsModel.collectionId(), "testString"); + assertEquals(getTrainingExampleOptionsModel.queryId(), "testString"); + assertEquals(getTrainingExampleOptionsModel.exampleId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetTrainingExampleOptionsError() throws Throwable { + new GetTrainingExampleOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/HistogramTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/HistogramTest.java new file mode 100644 index 00000000000..1c0e3ce098e --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/HistogramTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Histogram model. */ +public class HistogramTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testHistogram() throws Throwable { + Histogram histogramModel = new Histogram(); + assertNull(histogramModel.getType()); + assertNull(histogramModel.getMatchingResults()); + assertNull(histogramModel.getField()); + assertNull(histogramModel.getInterval()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/HtmlSettingsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/HtmlSettingsTest.java new file mode 100644 index 00000000000..51e901d4808 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/HtmlSettingsTest.java @@ -0,0 +1,76 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the HtmlSettings model. */ +public class HtmlSettingsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testHtmlSettings() throws Throwable { + XPathPatterns xPathPatternsModel = + new XPathPatterns.Builder() + .xpaths(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals( + xPathPatternsModel.xpaths(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + HtmlSettings htmlSettingsModel = + new HtmlSettings.Builder() + .excludeTagsCompletely( + new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .excludeTagsKeepContent( + new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .keepContent(xPathPatternsModel) + .excludeContent(xPathPatternsModel) + .keepTagAttributes( + new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .excludeTagAttributes( + new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals( + htmlSettingsModel.excludeTagsCompletely(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals( + htmlSettingsModel.excludeTagsKeepContent(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals(htmlSettingsModel.keepContent(), xPathPatternsModel); + assertEquals(htmlSettingsModel.excludeContent(), xPathPatternsModel); + assertEquals( + htmlSettingsModel.keepTagAttributes(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals( + htmlSettingsModel.excludeTagAttributes(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + String json = TestUtilities.serialize(htmlSettingsModel); + + HtmlSettings htmlSettingsModelNew = TestUtilities.deserialize(json, HtmlSettings.class); + assertTrue(htmlSettingsModelNew instanceof HtmlSettings); + assertEquals(htmlSettingsModelNew.keepContent().toString(), xPathPatternsModel.toString()); + assertEquals(htmlSettingsModelNew.excludeContent().toString(), xPathPatternsModel.toString()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/IndexCapacityTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/IndexCapacityTest.java new file mode 100644 index 00000000000..582875bf601 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/IndexCapacityTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the IndexCapacity model. */ +public class IndexCapacityTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testIndexCapacity() throws Throwable { + IndexCapacity indexCapacityModel = new IndexCapacity(); + assertNull(indexCapacityModel.getDocuments()); + assertNull(indexCapacityModel.getDiskUsage()); + assertNull(indexCapacityModel.getCollections()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/ListCollectionFieldsOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/ListCollectionFieldsOptionsTest.java new file mode 100644 index 00000000000..80194e357a2 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/ListCollectionFieldsOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListCollectionFieldsOptions model. */ +public class ListCollectionFieldsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListCollectionFieldsOptions() throws Throwable { + ListCollectionFieldsOptions listCollectionFieldsOptionsModel = + new ListCollectionFieldsOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .build(); + assertEquals(listCollectionFieldsOptionsModel.environmentId(), "testString"); + assertEquals(listCollectionFieldsOptionsModel.collectionId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListCollectionFieldsOptionsError() throws Throwable { + new ListCollectionFieldsOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/ListCollectionFieldsResponseTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/ListCollectionFieldsResponseTest.java new file mode 100644 index 00000000000..e2f68335ced --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/ListCollectionFieldsResponseTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListCollectionFieldsResponse model. */ +public class ListCollectionFieldsResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListCollectionFieldsResponse() throws Throwable { + ListCollectionFieldsResponse listCollectionFieldsResponseModel = + new ListCollectionFieldsResponse(); + assertNull(listCollectionFieldsResponseModel.getFields()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/ListCollectionsOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/ListCollectionsOptionsTest.java new file mode 100644 index 00000000000..dfd2bd7cf60 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/ListCollectionsOptionsTest.java @@ -0,0 +1,43 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListCollectionsOptions model. */ +public class ListCollectionsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListCollectionsOptions() throws Throwable { + ListCollectionsOptions listCollectionsOptionsModel = + new ListCollectionsOptions.Builder().environmentId("testString").name("testString").build(); + assertEquals(listCollectionsOptionsModel.environmentId(), "testString"); + assertEquals(listCollectionsOptionsModel.name(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListCollectionsOptionsError() throws Throwable { + new ListCollectionsOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/ListCollectionsResponseTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/ListCollectionsResponseTest.java new file mode 100644 index 00000000000..87a68a9ed87 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/ListCollectionsResponseTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListCollectionsResponse model. */ +public class ListCollectionsResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListCollectionsResponse() throws Throwable { + ListCollectionsResponse listCollectionsResponseModel = new ListCollectionsResponse(); + assertNull(listCollectionsResponseModel.getCollections()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/ListConfigurationsOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/ListConfigurationsOptionsTest.java new file mode 100644 index 00000000000..cfc6d5a42fa --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/ListConfigurationsOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListConfigurationsOptions model. */ +public class ListConfigurationsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListConfigurationsOptions() throws Throwable { + ListConfigurationsOptions listConfigurationsOptionsModel = + new ListConfigurationsOptions.Builder() + .environmentId("testString") + .name("testString") + .build(); + assertEquals(listConfigurationsOptionsModel.environmentId(), "testString"); + assertEquals(listConfigurationsOptionsModel.name(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListConfigurationsOptionsError() throws Throwable { + new ListConfigurationsOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/ListConfigurationsResponseTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/ListConfigurationsResponseTest.java new file mode 100644 index 00000000000..ebd8ad4d4fc --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/ListConfigurationsResponseTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListConfigurationsResponse model. */ +public class ListConfigurationsResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListConfigurationsResponse() throws Throwable { + ListConfigurationsResponse listConfigurationsResponseModel = new ListConfigurationsResponse(); + assertNull(listConfigurationsResponseModel.getConfigurations()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/ListCredentialsOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/ListCredentialsOptionsTest.java new file mode 100644 index 00000000000..d3fbbd93587 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/ListCredentialsOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListCredentialsOptions model. */ +public class ListCredentialsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListCredentialsOptions() throws Throwable { + ListCredentialsOptions listCredentialsOptionsModel = + new ListCredentialsOptions.Builder().environmentId("testString").build(); + assertEquals(listCredentialsOptionsModel.environmentId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListCredentialsOptionsError() throws Throwable { + new ListCredentialsOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/ListEnvironmentsOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/ListEnvironmentsOptionsTest.java new file mode 100644 index 00000000000..951d62f7296 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/ListEnvironmentsOptionsTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListEnvironmentsOptions model. */ +public class ListEnvironmentsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListEnvironmentsOptions() throws Throwable { + ListEnvironmentsOptions listEnvironmentsOptionsModel = + new ListEnvironmentsOptions.Builder().name("testString").build(); + assertEquals(listEnvironmentsOptionsModel.name(), "testString"); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/ListEnvironmentsResponseTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/ListEnvironmentsResponseTest.java new file mode 100644 index 00000000000..9f21d05ab57 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/ListEnvironmentsResponseTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListEnvironmentsResponse model. */ +public class ListEnvironmentsResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListEnvironmentsResponse() throws Throwable { + ListEnvironmentsResponse listEnvironmentsResponseModel = new ListEnvironmentsResponse(); + assertNull(listEnvironmentsResponseModel.getEnvironments()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/ListExpansionsOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/ListExpansionsOptionsTest.java new file mode 100644 index 00000000000..127a09598f0 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/ListExpansionsOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListExpansionsOptions model. */ +public class ListExpansionsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListExpansionsOptions() throws Throwable { + ListExpansionsOptions listExpansionsOptionsModel = + new ListExpansionsOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .build(); + assertEquals(listExpansionsOptionsModel.environmentId(), "testString"); + assertEquals(listExpansionsOptionsModel.collectionId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListExpansionsOptionsError() throws Throwable { + new ListExpansionsOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/ListFieldsOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/ListFieldsOptionsTest.java new file mode 100644 index 00000000000..e129c13958f --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/ListFieldsOptionsTest.java @@ -0,0 +1,48 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListFieldsOptions model. */ +public class ListFieldsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListFieldsOptions() throws Throwable { + ListFieldsOptions listFieldsOptionsModel = + new ListFieldsOptions.Builder() + .environmentId("testString") + .collectionIds(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals(listFieldsOptionsModel.environmentId(), "testString"); + assertEquals( + listFieldsOptionsModel.collectionIds(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListFieldsOptionsError() throws Throwable { + new ListFieldsOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/ListGatewaysOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/ListGatewaysOptionsTest.java new file mode 100644 index 00000000000..69ea7382000 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/ListGatewaysOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListGatewaysOptions model. */ +public class ListGatewaysOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListGatewaysOptions() throws Throwable { + ListGatewaysOptions listGatewaysOptionsModel = + new ListGatewaysOptions.Builder().environmentId("testString").build(); + assertEquals(listGatewaysOptionsModel.environmentId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListGatewaysOptionsError() throws Throwable { + new ListGatewaysOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/ListTrainingDataOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/ListTrainingDataOptionsTest.java new file mode 100644 index 00000000000..2e13dcffdc4 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/ListTrainingDataOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListTrainingDataOptions model. */ +public class ListTrainingDataOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListTrainingDataOptions() throws Throwable { + ListTrainingDataOptions listTrainingDataOptionsModel = + new ListTrainingDataOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .build(); + assertEquals(listTrainingDataOptionsModel.environmentId(), "testString"); + assertEquals(listTrainingDataOptionsModel.collectionId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListTrainingDataOptionsError() throws Throwable { + new ListTrainingDataOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/ListTrainingExamplesOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/ListTrainingExamplesOptionsTest.java new file mode 100644 index 00000000000..c4160649b1d --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/ListTrainingExamplesOptionsTest.java @@ -0,0 +1,48 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListTrainingExamplesOptions model. */ +public class ListTrainingExamplesOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListTrainingExamplesOptions() throws Throwable { + ListTrainingExamplesOptions listTrainingExamplesOptionsModel = + new ListTrainingExamplesOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .queryId("testString") + .build(); + assertEquals(listTrainingExamplesOptionsModel.environmentId(), "testString"); + assertEquals(listTrainingExamplesOptionsModel.collectionId(), "testString"); + assertEquals(listTrainingExamplesOptionsModel.queryId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListTrainingExamplesOptionsError() throws Throwable { + new ListTrainingExamplesOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/LogQueryResponseResultDocumentsResultTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/LogQueryResponseResultDocumentsResultTest.java new file mode 100644 index 00000000000..b771dc71ba4 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/LogQueryResponseResultDocumentsResultTest.java @@ -0,0 +1,41 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the LogQueryResponseResultDocumentsResult model. */ +public class LogQueryResponseResultDocumentsResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testLogQueryResponseResultDocumentsResult() throws Throwable { + LogQueryResponseResultDocumentsResult logQueryResponseResultDocumentsResultModel = + new LogQueryResponseResultDocumentsResult(); + assertNull(logQueryResponseResultDocumentsResultModel.getPosition()); + assertNull(logQueryResponseResultDocumentsResultModel.getDocumentId()); + assertNull(logQueryResponseResultDocumentsResultModel.getScore()); + assertNull(logQueryResponseResultDocumentsResultModel.getConfidence()); + assertNull(logQueryResponseResultDocumentsResultModel.getCollectionId()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/LogQueryResponseResultDocumentsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/LogQueryResponseResultDocumentsTest.java new file mode 100644 index 00000000000..eecaec4069d --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/LogQueryResponseResultDocumentsTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the LogQueryResponseResultDocuments model. */ +public class LogQueryResponseResultDocumentsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testLogQueryResponseResultDocuments() throws Throwable { + LogQueryResponseResultDocuments logQueryResponseResultDocumentsModel = + new LogQueryResponseResultDocuments(); + assertNull(logQueryResponseResultDocumentsModel.getResults()); + assertNull(logQueryResponseResultDocumentsModel.getCount()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/LogQueryResponseResultTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/LogQueryResponseResultTest.java new file mode 100644 index 00000000000..f9a47ecd4d8 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/LogQueryResponseResultTest.java @@ -0,0 +1,49 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the LogQueryResponseResult model. */ +public class LogQueryResponseResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testLogQueryResponseResult() throws Throwable { + LogQueryResponseResult logQueryResponseResultModel = new LogQueryResponseResult(); + assertNull(logQueryResponseResultModel.getEnvironmentId()); + assertNull(logQueryResponseResultModel.getCustomerId()); + assertNull(logQueryResponseResultModel.getDocumentType()); + assertNull(logQueryResponseResultModel.getNaturalLanguageQuery()); + assertNull(logQueryResponseResultModel.getDocumentResults()); + assertNull(logQueryResponseResultModel.getCreatedTimestamp()); + assertNull(logQueryResponseResultModel.getClientTimestamp()); + assertNull(logQueryResponseResultModel.getQueryId()); + assertNull(logQueryResponseResultModel.getSessionToken()); + assertNull(logQueryResponseResultModel.getCollectionId()); + assertNull(logQueryResponseResultModel.getDisplayRank()); + assertNull(logQueryResponseResultModel.getDocumentId()); + assertNull(logQueryResponseResultModel.getEventType()); + assertNull(logQueryResponseResultModel.getResultType()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/LogQueryResponseTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/LogQueryResponseTest.java new file mode 100644 index 00000000000..609abffe157 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/LogQueryResponseTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the LogQueryResponse model. */ +public class LogQueryResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testLogQueryResponse() throws Throwable { + LogQueryResponse logQueryResponseModel = new LogQueryResponse(); + assertNull(logQueryResponseModel.getMatchingResults()); + assertNull(logQueryResponseModel.getResults()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/MetricAggregationResultTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/MetricAggregationResultTest.java new file mode 100644 index 00000000000..c776ce9e687 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/MetricAggregationResultTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MetricAggregationResult model. */ +public class MetricAggregationResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMetricAggregationResult() throws Throwable { + MetricAggregationResult metricAggregationResultModel = new MetricAggregationResult(); + assertNull(metricAggregationResultModel.getKeyAsString()); + assertNull(metricAggregationResultModel.getKey()); + assertNull(metricAggregationResultModel.getMatchingResults()); + assertNull(metricAggregationResultModel.getEventRate()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/MetricAggregationTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/MetricAggregationTest.java new file mode 100644 index 00000000000..c57836b3abd --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/MetricAggregationTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MetricAggregation model. */ +public class MetricAggregationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMetricAggregation() throws Throwable { + MetricAggregation metricAggregationModel = new MetricAggregation(); + assertNull(metricAggregationModel.getInterval()); + assertNull(metricAggregationModel.getEventType()); + assertNull(metricAggregationModel.getResults()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/MetricResponseTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/MetricResponseTest.java new file mode 100644 index 00000000000..6040800f5a7 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/MetricResponseTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MetricResponse model. */ +public class MetricResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMetricResponse() throws Throwable { + MetricResponse metricResponseModel = new MetricResponse(); + assertNull(metricResponseModel.getAggregations()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/MetricTokenAggregationResultTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/MetricTokenAggregationResultTest.java new file mode 100644 index 00000000000..e06d469376a --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/MetricTokenAggregationResultTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MetricTokenAggregationResult model. */ +public class MetricTokenAggregationResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMetricTokenAggregationResult() throws Throwable { + MetricTokenAggregationResult metricTokenAggregationResultModel = + new MetricTokenAggregationResult(); + assertNull(metricTokenAggregationResultModel.getKey()); + assertNull(metricTokenAggregationResultModel.getMatchingResults()); + assertNull(metricTokenAggregationResultModel.getEventRate()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/MetricTokenAggregationTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/MetricTokenAggregationTest.java new file mode 100644 index 00000000000..0944f3f501d --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/MetricTokenAggregationTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MetricTokenAggregation model. */ +public class MetricTokenAggregationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMetricTokenAggregation() throws Throwable { + MetricTokenAggregation metricTokenAggregationModel = new MetricTokenAggregation(); + assertNull(metricTokenAggregationModel.getEventType()); + assertNull(metricTokenAggregationModel.getResults()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/MetricTokenResponseTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/MetricTokenResponseTest.java new file mode 100644 index 00000000000..d7e6acf5547 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/MetricTokenResponseTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the MetricTokenResponse model. */ +public class MetricTokenResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testMetricTokenResponse() throws Throwable { + MetricTokenResponse metricTokenResponseModel = new MetricTokenResponse(); + assertNull(metricTokenResponseModel.getAggregations()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/NestedTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/NestedTest.java new file mode 100644 index 00000000000..e17e1ab00b0 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/NestedTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Nested model. */ +public class NestedTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testNested() throws Throwable { + Nested nestedModel = new Nested(); + assertNull(nestedModel.getType()); + assertNull(nestedModel.getMatchingResults()); + assertNull(nestedModel.getPath()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/NluEnrichmentConceptsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/NluEnrichmentConceptsTest.java new file mode 100644 index 00000000000..8a3a337ab43 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/NluEnrichmentConceptsTest.java @@ -0,0 +1,44 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the NluEnrichmentConcepts model. */ +public class NluEnrichmentConceptsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testNluEnrichmentConcepts() throws Throwable { + NluEnrichmentConcepts nluEnrichmentConceptsModel = + new NluEnrichmentConcepts.Builder().limit(Long.valueOf("26")).build(); + assertEquals(nluEnrichmentConceptsModel.limit(), Long.valueOf("26")); + + String json = TestUtilities.serialize(nluEnrichmentConceptsModel); + + NluEnrichmentConcepts nluEnrichmentConceptsModelNew = + TestUtilities.deserialize(json, NluEnrichmentConcepts.class); + assertTrue(nluEnrichmentConceptsModelNew instanceof NluEnrichmentConcepts); + assertEquals(nluEnrichmentConceptsModelNew.limit(), Long.valueOf("26")); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/NluEnrichmentEmotionTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/NluEnrichmentEmotionTest.java new file mode 100644 index 00000000000..fa00b1c045c --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/NluEnrichmentEmotionTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the NluEnrichmentEmotion model. */ +public class NluEnrichmentEmotionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testNluEnrichmentEmotion() throws Throwable { + NluEnrichmentEmotion nluEnrichmentEmotionModel = + new NluEnrichmentEmotion.Builder() + .document(true) + .targets(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals(nluEnrichmentEmotionModel.document(), Boolean.valueOf(true)); + assertEquals( + nluEnrichmentEmotionModel.targets(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + String json = TestUtilities.serialize(nluEnrichmentEmotionModel); + + NluEnrichmentEmotion nluEnrichmentEmotionModelNew = + TestUtilities.deserialize(json, NluEnrichmentEmotion.class); + assertTrue(nluEnrichmentEmotionModelNew instanceof NluEnrichmentEmotion); + assertEquals(nluEnrichmentEmotionModelNew.document(), Boolean.valueOf(true)); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/NluEnrichmentEntitiesTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/NluEnrichmentEntitiesTest.java new file mode 100644 index 00000000000..d05172a0a64 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/NluEnrichmentEntitiesTest.java @@ -0,0 +1,64 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the NluEnrichmentEntities model. */ +public class NluEnrichmentEntitiesTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testNluEnrichmentEntities() throws Throwable { + NluEnrichmentEntities nluEnrichmentEntitiesModel = + new NluEnrichmentEntities.Builder() + .sentiment(true) + .emotion(true) + .limit(Long.valueOf("26")) + .mentions(true) + .mentionTypes(true) + .sentenceLocations(true) + .model("testString") + .build(); + assertEquals(nluEnrichmentEntitiesModel.sentiment(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentEntitiesModel.emotion(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentEntitiesModel.limit(), Long.valueOf("26")); + assertEquals(nluEnrichmentEntitiesModel.mentions(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentEntitiesModel.mentionTypes(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentEntitiesModel.sentenceLocations(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentEntitiesModel.model(), "testString"); + + String json = TestUtilities.serialize(nluEnrichmentEntitiesModel); + + NluEnrichmentEntities nluEnrichmentEntitiesModelNew = + TestUtilities.deserialize(json, NluEnrichmentEntities.class); + assertTrue(nluEnrichmentEntitiesModelNew instanceof NluEnrichmentEntities); + assertEquals(nluEnrichmentEntitiesModelNew.sentiment(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentEntitiesModelNew.emotion(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentEntitiesModelNew.limit(), Long.valueOf("26")); + assertEquals(nluEnrichmentEntitiesModelNew.mentions(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentEntitiesModelNew.mentionTypes(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentEntitiesModelNew.sentenceLocations(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentEntitiesModelNew.model(), "testString"); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/NluEnrichmentFeaturesTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/NluEnrichmentFeaturesTest.java new file mode 100644 index 00000000000..ae5d54e1860 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/NluEnrichmentFeaturesTest.java @@ -0,0 +1,153 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the NluEnrichmentFeatures model. */ +public class NluEnrichmentFeaturesTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testNluEnrichmentFeatures() throws Throwable { + NluEnrichmentKeywords nluEnrichmentKeywordsModel = + new NluEnrichmentKeywords.Builder() + .sentiment(true) + .emotion(true) + .limit(Long.valueOf("26")) + .build(); + assertEquals(nluEnrichmentKeywordsModel.sentiment(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentKeywordsModel.emotion(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentKeywordsModel.limit(), Long.valueOf("26")); + + NluEnrichmentEntities nluEnrichmentEntitiesModel = + new NluEnrichmentEntities.Builder() + .sentiment(true) + .emotion(true) + .limit(Long.valueOf("26")) + .mentions(true) + .mentionTypes(true) + .sentenceLocations(true) + .model("testString") + .build(); + assertEquals(nluEnrichmentEntitiesModel.sentiment(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentEntitiesModel.emotion(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentEntitiesModel.limit(), Long.valueOf("26")); + assertEquals(nluEnrichmentEntitiesModel.mentions(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentEntitiesModel.mentionTypes(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentEntitiesModel.sentenceLocations(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentEntitiesModel.model(), "testString"); + + NluEnrichmentSentiment nluEnrichmentSentimentModel = + new NluEnrichmentSentiment.Builder() + .document(true) + .targets(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals(nluEnrichmentSentimentModel.document(), Boolean.valueOf(true)); + assertEquals( + nluEnrichmentSentimentModel.targets(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + NluEnrichmentEmotion nluEnrichmentEmotionModel = + new NluEnrichmentEmotion.Builder() + .document(true) + .targets(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals(nluEnrichmentEmotionModel.document(), Boolean.valueOf(true)); + assertEquals( + nluEnrichmentEmotionModel.targets(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + NluEnrichmentSemanticRoles nluEnrichmentSemanticRolesModel = + new NluEnrichmentSemanticRoles.Builder() + .entities(true) + .keywords(true) + .limit(Long.valueOf("26")) + .build(); + assertEquals(nluEnrichmentSemanticRolesModel.entities(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentSemanticRolesModel.keywords(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentSemanticRolesModel.limit(), Long.valueOf("26")); + + NluEnrichmentRelations nluEnrichmentRelationsModel = + new NluEnrichmentRelations.Builder().model("testString").build(); + assertEquals(nluEnrichmentRelationsModel.model(), "testString"); + + NluEnrichmentConcepts nluEnrichmentConceptsModel = + new NluEnrichmentConcepts.Builder().limit(Long.valueOf("26")).build(); + assertEquals(nluEnrichmentConceptsModel.limit(), Long.valueOf("26")); + + NluEnrichmentFeatures nluEnrichmentFeaturesModel = + new NluEnrichmentFeatures.Builder() + .keywords(nluEnrichmentKeywordsModel) + .entities(nluEnrichmentEntitiesModel) + .sentiment(nluEnrichmentSentimentModel) + .emotion(nluEnrichmentEmotionModel) + .categories( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .semanticRoles(nluEnrichmentSemanticRolesModel) + .relations(nluEnrichmentRelationsModel) + .concepts(nluEnrichmentConceptsModel) + .build(); + assertEquals(nluEnrichmentFeaturesModel.keywords(), nluEnrichmentKeywordsModel); + assertEquals(nluEnrichmentFeaturesModel.entities(), nluEnrichmentEntitiesModel); + assertEquals(nluEnrichmentFeaturesModel.sentiment(), nluEnrichmentSentimentModel); + assertEquals(nluEnrichmentFeaturesModel.emotion(), nluEnrichmentEmotionModel); + assertEquals( + nluEnrichmentFeaturesModel.categories(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals(nluEnrichmentFeaturesModel.semanticRoles(), nluEnrichmentSemanticRolesModel); + assertEquals(nluEnrichmentFeaturesModel.relations(), nluEnrichmentRelationsModel); + assertEquals(nluEnrichmentFeaturesModel.concepts(), nluEnrichmentConceptsModel); + + String json = TestUtilities.serialize(nluEnrichmentFeaturesModel); + + NluEnrichmentFeatures nluEnrichmentFeaturesModelNew = + TestUtilities.deserialize(json, NluEnrichmentFeatures.class); + assertTrue(nluEnrichmentFeaturesModelNew instanceof NluEnrichmentFeatures); + assertEquals( + nluEnrichmentFeaturesModelNew.keywords().toString(), nluEnrichmentKeywordsModel.toString()); + assertEquals( + nluEnrichmentFeaturesModelNew.entities().toString(), nluEnrichmentEntitiesModel.toString()); + assertEquals( + nluEnrichmentFeaturesModelNew.sentiment().toString(), + nluEnrichmentSentimentModel.toString()); + assertEquals( + nluEnrichmentFeaturesModelNew.emotion().toString(), nluEnrichmentEmotionModel.toString()); + assertEquals( + nluEnrichmentFeaturesModelNew.semanticRoles().toString(), + nluEnrichmentSemanticRolesModel.toString()); + assertEquals( + nluEnrichmentFeaturesModelNew.relations().toString(), + nluEnrichmentRelationsModel.toString()); + assertEquals( + nluEnrichmentFeaturesModelNew.concepts().toString(), nluEnrichmentConceptsModel.toString()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/NluEnrichmentKeywordsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/NluEnrichmentKeywordsTest.java new file mode 100644 index 00000000000..cea1b8cf10a --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/NluEnrichmentKeywordsTest.java @@ -0,0 +1,52 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the NluEnrichmentKeywords model. */ +public class NluEnrichmentKeywordsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testNluEnrichmentKeywords() throws Throwable { + NluEnrichmentKeywords nluEnrichmentKeywordsModel = + new NluEnrichmentKeywords.Builder() + .sentiment(true) + .emotion(true) + .limit(Long.valueOf("26")) + .build(); + assertEquals(nluEnrichmentKeywordsModel.sentiment(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentKeywordsModel.emotion(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentKeywordsModel.limit(), Long.valueOf("26")); + + String json = TestUtilities.serialize(nluEnrichmentKeywordsModel); + + NluEnrichmentKeywords nluEnrichmentKeywordsModelNew = + TestUtilities.deserialize(json, NluEnrichmentKeywords.class); + assertTrue(nluEnrichmentKeywordsModelNew instanceof NluEnrichmentKeywords); + assertEquals(nluEnrichmentKeywordsModelNew.sentiment(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentKeywordsModelNew.emotion(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentKeywordsModelNew.limit(), Long.valueOf("26")); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/NluEnrichmentRelationsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/NluEnrichmentRelationsTest.java new file mode 100644 index 00000000000..777e296b325 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/NluEnrichmentRelationsTest.java @@ -0,0 +1,44 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the NluEnrichmentRelations model. */ +public class NluEnrichmentRelationsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testNluEnrichmentRelations() throws Throwable { + NluEnrichmentRelations nluEnrichmentRelationsModel = + new NluEnrichmentRelations.Builder().model("testString").build(); + assertEquals(nluEnrichmentRelationsModel.model(), "testString"); + + String json = TestUtilities.serialize(nluEnrichmentRelationsModel); + + NluEnrichmentRelations nluEnrichmentRelationsModelNew = + TestUtilities.deserialize(json, NluEnrichmentRelations.class); + assertTrue(nluEnrichmentRelationsModelNew instanceof NluEnrichmentRelations); + assertEquals(nluEnrichmentRelationsModelNew.model(), "testString"); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/NluEnrichmentSemanticRolesTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/NluEnrichmentSemanticRolesTest.java new file mode 100644 index 00000000000..1df2e7c2902 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/NluEnrichmentSemanticRolesTest.java @@ -0,0 +1,52 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the NluEnrichmentSemanticRoles model. */ +public class NluEnrichmentSemanticRolesTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testNluEnrichmentSemanticRoles() throws Throwable { + NluEnrichmentSemanticRoles nluEnrichmentSemanticRolesModel = + new NluEnrichmentSemanticRoles.Builder() + .entities(true) + .keywords(true) + .limit(Long.valueOf("26")) + .build(); + assertEquals(nluEnrichmentSemanticRolesModel.entities(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentSemanticRolesModel.keywords(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentSemanticRolesModel.limit(), Long.valueOf("26")); + + String json = TestUtilities.serialize(nluEnrichmentSemanticRolesModel); + + NluEnrichmentSemanticRoles nluEnrichmentSemanticRolesModelNew = + TestUtilities.deserialize(json, NluEnrichmentSemanticRoles.class); + assertTrue(nluEnrichmentSemanticRolesModelNew instanceof NluEnrichmentSemanticRoles); + assertEquals(nluEnrichmentSemanticRolesModelNew.entities(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentSemanticRolesModelNew.keywords(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentSemanticRolesModelNew.limit(), Long.valueOf("26")); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/NluEnrichmentSentimentTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/NluEnrichmentSentimentTest.java new file mode 100644 index 00000000000..dbd80ccef68 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/NluEnrichmentSentimentTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the NluEnrichmentSentiment model. */ +public class NluEnrichmentSentimentTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testNluEnrichmentSentiment() throws Throwable { + NluEnrichmentSentiment nluEnrichmentSentimentModel = + new NluEnrichmentSentiment.Builder() + .document(true) + .targets(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals(nluEnrichmentSentimentModel.document(), Boolean.valueOf(true)); + assertEquals( + nluEnrichmentSentimentModel.targets(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + String json = TestUtilities.serialize(nluEnrichmentSentimentModel); + + NluEnrichmentSentiment nluEnrichmentSentimentModelNew = + TestUtilities.deserialize(json, NluEnrichmentSentiment.class); + assertTrue(nluEnrichmentSentimentModelNew instanceof NluEnrichmentSentiment); + assertEquals(nluEnrichmentSentimentModelNew.document(), Boolean.valueOf(true)); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/NormalizationOperationTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/NormalizationOperationTest.java new file mode 100644 index 00000000000..1000f68fa00 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/NormalizationOperationTest.java @@ -0,0 +1,52 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the NormalizationOperation model. */ +public class NormalizationOperationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testNormalizationOperation() throws Throwable { + NormalizationOperation normalizationOperationModel = + new NormalizationOperation.Builder() + .operation("copy") + .sourceField("testString") + .destinationField("testString") + .build(); + assertEquals(normalizationOperationModel.operation(), "copy"); + assertEquals(normalizationOperationModel.sourceField(), "testString"); + assertEquals(normalizationOperationModel.destinationField(), "testString"); + + String json = TestUtilities.serialize(normalizationOperationModel); + + NormalizationOperation normalizationOperationModelNew = + TestUtilities.deserialize(json, NormalizationOperation.class); + assertTrue(normalizationOperationModelNew instanceof NormalizationOperation); + assertEquals(normalizationOperationModelNew.operation(), "copy"); + assertEquals(normalizationOperationModelNew.sourceField(), "testString"); + assertEquals(normalizationOperationModelNew.destinationField(), "testString"); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/NoticeTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/NoticeTest.java new file mode 100644 index 00000000000..5f4d6a40324 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/NoticeTest.java @@ -0,0 +1,35 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Notice model. */ +public class NoticeTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testNotice() throws Throwable { + Notice noticeModel = new Notice(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/PdfHeadingDetectionTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/PdfHeadingDetectionTest.java new file mode 100644 index 00000000000..4085626fdcf --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/PdfHeadingDetectionTest.java @@ -0,0 +1,63 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the PdfHeadingDetection model. */ +public class PdfHeadingDetectionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testPdfHeadingDetection() throws Throwable { + FontSetting fontSettingModel = + new FontSetting.Builder() + .level(Long.valueOf("26")) + .minSize(Long.valueOf("26")) + .maxSize(Long.valueOf("26")) + .bold(true) + .italic(true) + .name("testString") + .build(); + assertEquals(fontSettingModel.level(), Long.valueOf("26")); + assertEquals(fontSettingModel.minSize(), Long.valueOf("26")); + assertEquals(fontSettingModel.maxSize(), Long.valueOf("26")); + assertEquals(fontSettingModel.bold(), Boolean.valueOf(true)); + assertEquals(fontSettingModel.italic(), Boolean.valueOf(true)); + assertEquals(fontSettingModel.name(), "testString"); + + PdfHeadingDetection pdfHeadingDetectionModel = + new PdfHeadingDetection.Builder() + .fonts(new java.util.ArrayList(java.util.Arrays.asList(fontSettingModel))) + .build(); + assertEquals( + pdfHeadingDetectionModel.fonts(), + new java.util.ArrayList(java.util.Arrays.asList(fontSettingModel))); + + String json = TestUtilities.serialize(pdfHeadingDetectionModel); + + PdfHeadingDetection pdfHeadingDetectionModelNew = + TestUtilities.deserialize(json, PdfHeadingDetection.class); + assertTrue(pdfHeadingDetectionModelNew instanceof PdfHeadingDetection); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/PdfSettingsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/PdfSettingsTest.java new file mode 100644 index 00000000000..24fb8ab8ffc --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/PdfSettingsTest.java @@ -0,0 +1,67 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the PdfSettings model. */ +public class PdfSettingsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testPdfSettings() throws Throwable { + FontSetting fontSettingModel = + new FontSetting.Builder() + .level(Long.valueOf("26")) + .minSize(Long.valueOf("26")) + .maxSize(Long.valueOf("26")) + .bold(true) + .italic(true) + .name("testString") + .build(); + assertEquals(fontSettingModel.level(), Long.valueOf("26")); + assertEquals(fontSettingModel.minSize(), Long.valueOf("26")); + assertEquals(fontSettingModel.maxSize(), Long.valueOf("26")); + assertEquals(fontSettingModel.bold(), Boolean.valueOf(true)); + assertEquals(fontSettingModel.italic(), Boolean.valueOf(true)); + assertEquals(fontSettingModel.name(), "testString"); + + PdfHeadingDetection pdfHeadingDetectionModel = + new PdfHeadingDetection.Builder() + .fonts(new java.util.ArrayList(java.util.Arrays.asList(fontSettingModel))) + .build(); + assertEquals( + pdfHeadingDetectionModel.fonts(), + new java.util.ArrayList(java.util.Arrays.asList(fontSettingModel))); + + PdfSettings pdfSettingsModel = + new PdfSettings.Builder().heading(pdfHeadingDetectionModel).build(); + assertEquals(pdfSettingsModel.heading(), pdfHeadingDetectionModel); + + String json = TestUtilities.serialize(pdfSettingsModel); + + PdfSettings pdfSettingsModelNew = TestUtilities.deserialize(json, PdfSettings.class); + assertTrue(pdfSettingsModelNew instanceof PdfSettings); + assertEquals(pdfSettingsModelNew.heading().toString(), pdfHeadingDetectionModel.toString()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/QueryAggregationTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/QueryAggregationTest.java new file mode 100644 index 00000000000..1618a0e836a --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/QueryAggregationTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryAggregation model. */ +public class QueryAggregationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + // TODO: Add tests for models that are abstract + @Test + public void testQueryAggregation() throws Throwable { + QueryAggregation queryAggregationModel = new QueryAggregation(); + assertNotNull(queryAggregationModel); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/QueryLogOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/QueryLogOptionsTest.java new file mode 100644 index 00000000000..535ad129f80 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/QueryLogOptionsTest.java @@ -0,0 +1,49 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryLogOptions model. */ +public class QueryLogOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryLogOptions() throws Throwable { + QueryLogOptions queryLogOptionsModel = + new QueryLogOptions.Builder() + .filter("testString") + .query("testString") + .count(Long.valueOf("26")) + .offset(Long.valueOf("26")) + .sort(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals(queryLogOptionsModel.filter(), "testString"); + assertEquals(queryLogOptionsModel.query(), "testString"); + assertEquals(queryLogOptionsModel.count(), Long.valueOf("26")); + assertEquals(queryLogOptionsModel.offset(), Long.valueOf("26")); + assertEquals( + queryLogOptionsModel.sort(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/QueryNoticesOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/QueryNoticesOptionsTest.java new file mode 100644 index 00000000000..da784165dda --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/QueryNoticesOptionsTest.java @@ -0,0 +1,91 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryNoticesOptions model. */ +public class QueryNoticesOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryNoticesOptions() throws Throwable { + QueryNoticesOptions queryNoticesOptionsModel = + new QueryNoticesOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .filter("testString") + .query("testString") + .naturalLanguageQuery("testString") + .passages(true) + .aggregation("testString") + .count(Long.valueOf("26")) + .xReturn(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .offset(Long.valueOf("26")) + .sort(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .highlight(true) + .passagesFields(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .passagesCount(Long.valueOf("100")) + .passagesCharacters(Long.valueOf("50")) + .deduplicateField("testString") + .similar(true) + .similarDocumentIds( + new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .similarFields(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals(queryNoticesOptionsModel.environmentId(), "testString"); + assertEquals(queryNoticesOptionsModel.collectionId(), "testString"); + assertEquals(queryNoticesOptionsModel.filter(), "testString"); + assertEquals(queryNoticesOptionsModel.query(), "testString"); + assertEquals(queryNoticesOptionsModel.naturalLanguageQuery(), "testString"); + assertEquals(queryNoticesOptionsModel.passages(), Boolean.valueOf(true)); + assertEquals(queryNoticesOptionsModel.aggregation(), "testString"); + assertEquals(queryNoticesOptionsModel.count(), Long.valueOf("26")); + assertEquals( + queryNoticesOptionsModel.xReturn(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals(queryNoticesOptionsModel.offset(), Long.valueOf("26")); + assertEquals( + queryNoticesOptionsModel.sort(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals(queryNoticesOptionsModel.highlight(), Boolean.valueOf(true)); + assertEquals( + queryNoticesOptionsModel.passagesFields(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals(queryNoticesOptionsModel.passagesCount(), Long.valueOf("100")); + assertEquals(queryNoticesOptionsModel.passagesCharacters(), Long.valueOf("50")); + assertEquals(queryNoticesOptionsModel.deduplicateField(), "testString"); + assertEquals(queryNoticesOptionsModel.similar(), Boolean.valueOf(true)); + assertEquals( + queryNoticesOptionsModel.similarDocumentIds(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals( + queryNoticesOptionsModel.similarFields(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testQueryNoticesOptionsError() throws Throwable { + new QueryNoticesOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/QueryNoticesResponseTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/QueryNoticesResponseTest.java new file mode 100644 index 00000000000..f22556ec0e6 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/QueryNoticesResponseTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryNoticesResponse model. */ +public class QueryNoticesResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryNoticesResponse() throws Throwable { + QueryNoticesResponse queryNoticesResponseModel = new QueryNoticesResponse(); + assertNull(queryNoticesResponseModel.getMatchingResults()); + assertNull(queryNoticesResponseModel.getResults()); + assertNull(queryNoticesResponseModel.getAggregations()); + assertNull(queryNoticesResponseModel.getPassages()); + assertNull(queryNoticesResponseModel.getDuplicatesRemoved()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/QueryNoticesResultTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/QueryNoticesResultTest.java new file mode 100644 index 00000000000..8d3d190eddc --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/QueryNoticesResultTest.java @@ -0,0 +1,44 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryNoticesResult model. */ +public class QueryNoticesResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryNoticesResult() throws Throwable { + QueryNoticesResult queryNoticesResultModel = new QueryNoticesResult(); + assertNull(queryNoticesResultModel.getId()); + assertNull(queryNoticesResultModel.getMetadata()); + assertNull(queryNoticesResultModel.getCollectionId()); + assertNull(queryNoticesResultModel.getResultMetadata()); + assertNull(queryNoticesResultModel.getCode()); + assertNull(queryNoticesResultModel.getFilename()); + assertNull(queryNoticesResultModel.getFileType()); + assertNull(queryNoticesResultModel.getSha1()); + assertNull(queryNoticesResultModel.getNotices()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/QueryOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/QueryOptionsTest.java new file mode 100644 index 00000000000..92f0506ad06 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/QueryOptionsTest.java @@ -0,0 +1,88 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryOptions model. */ +public class QueryOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryOptions() throws Throwable { + QueryOptions queryOptionsModel = + new QueryOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .filter("testString") + .query("testString") + .naturalLanguageQuery("testString") + .passages(true) + .aggregation("testString") + .count(Long.valueOf("26")) + .xReturn("testString") + .offset(Long.valueOf("26")) + .sort("testString") + .highlight(true) + .passagesFields("testString") + .passagesCount(Long.valueOf("100")) + .passagesCharacters(Long.valueOf("50")) + .deduplicate(true) + .deduplicateField("testString") + .similar(true) + .similarDocumentIds("testString") + .similarFields("testString") + .bias("testString") + .spellingSuggestions(true) + .xWatsonLoggingOptOut(true) + .build(); + assertEquals(queryOptionsModel.environmentId(), "testString"); + assertEquals(queryOptionsModel.collectionId(), "testString"); + assertEquals(queryOptionsModel.filter(), "testString"); + assertEquals(queryOptionsModel.query(), "testString"); + assertEquals(queryOptionsModel.naturalLanguageQuery(), "testString"); + assertEquals(queryOptionsModel.passages(), Boolean.valueOf(true)); + assertEquals(queryOptionsModel.aggregation(), "testString"); + assertEquals(queryOptionsModel.count(), Long.valueOf("26")); + assertEquals(queryOptionsModel.xReturn(), "testString"); + assertEquals(queryOptionsModel.offset(), Long.valueOf("26")); + assertEquals(queryOptionsModel.sort(), "testString"); + assertEquals(queryOptionsModel.highlight(), Boolean.valueOf(true)); + assertEquals(queryOptionsModel.passagesFields(), "testString"); + assertEquals(queryOptionsModel.passagesCount(), Long.valueOf("100")); + assertEquals(queryOptionsModel.passagesCharacters(), Long.valueOf("50")); + assertEquals(queryOptionsModel.deduplicate(), Boolean.valueOf(true)); + assertEquals(queryOptionsModel.deduplicateField(), "testString"); + assertEquals(queryOptionsModel.similar(), Boolean.valueOf(true)); + assertEquals(queryOptionsModel.similarDocumentIds(), "testString"); + assertEquals(queryOptionsModel.similarFields(), "testString"); + assertEquals(queryOptionsModel.bias(), "testString"); + assertEquals(queryOptionsModel.spellingSuggestions(), Boolean.valueOf(true)); + assertEquals(queryOptionsModel.xWatsonLoggingOptOut(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testQueryOptionsError() throws Throwable { + new QueryOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/QueryPassagesTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/QueryPassagesTest.java new file mode 100644 index 00000000000..62ba7f801e1 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/QueryPassagesTest.java @@ -0,0 +1,41 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryPassages model. */ +public class QueryPassagesTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryPassages() throws Throwable { + QueryPassages queryPassagesModel = new QueryPassages(); + assertNull(queryPassagesModel.getDocumentId()); + assertNull(queryPassagesModel.getPassageScore()); + assertNull(queryPassagesModel.getPassageText()); + assertNull(queryPassagesModel.getStartOffset()); + assertNull(queryPassagesModel.getEndOffset()); + assertNull(queryPassagesModel.getField()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/QueryResponseTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/QueryResponseTest.java new file mode 100644 index 00000000000..07ca90ddda4 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/QueryResponseTest.java @@ -0,0 +1,43 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryResponse model. */ +public class QueryResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryResponse() throws Throwable { + QueryResponse queryResponseModel = new QueryResponse(); + assertNull(queryResponseModel.getMatchingResults()); + assertNull(queryResponseModel.getResults()); + assertNull(queryResponseModel.getAggregations()); + assertNull(queryResponseModel.getPassages()); + assertNull(queryResponseModel.getDuplicatesRemoved()); + assertNull(queryResponseModel.getSessionToken()); + assertNull(queryResponseModel.getRetrievalDetails()); + assertNull(queryResponseModel.getSuggestedQuery()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/QueryResultMetadataTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/QueryResultMetadataTest.java new file mode 100644 index 00000000000..fd9230b5283 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/QueryResultMetadataTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryResultMetadata model. */ +public class QueryResultMetadataTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryResultMetadata() throws Throwable { + QueryResultMetadata queryResultMetadataModel = new QueryResultMetadata(); + assertNull(queryResultMetadataModel.getScore()); + assertNull(queryResultMetadataModel.getConfidence()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/QueryResultTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/QueryResultTest.java new file mode 100644 index 00000000000..11b72ce56b9 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/QueryResultTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryResult model. */ +public class QueryResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryResult() throws Throwable { + QueryResult queryResultModel = new QueryResult(); + assertNull(queryResultModel.getId()); + assertNull(queryResultModel.getMetadata()); + assertNull(queryResultModel.getCollectionId()); + assertNull(queryResultModel.getResultMetadata()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/RetrievalDetailsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/RetrievalDetailsTest.java new file mode 100644 index 00000000000..b330baa87b7 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/RetrievalDetailsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RetrievalDetails model. */ +public class RetrievalDetailsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRetrievalDetails() throws Throwable { + RetrievalDetails retrievalDetailsModel = new RetrievalDetails(); + assertNull(retrievalDetailsModel.getDocumentRetrievalStrategy()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/SduStatusCustomFieldsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/SduStatusCustomFieldsTest.java new file mode 100644 index 00000000000..449ad4b31bb --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/SduStatusCustomFieldsTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SduStatusCustomFields model. */ +public class SduStatusCustomFieldsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSduStatusCustomFields() throws Throwable { + SduStatusCustomFields sduStatusCustomFieldsModel = new SduStatusCustomFields(); + assertNull(sduStatusCustomFieldsModel.getDefined()); + assertNull(sduStatusCustomFieldsModel.getMaximumAllowed()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/SduStatusTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/SduStatusTest.java new file mode 100644 index 00000000000..2dc022fa53f --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/SduStatusTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SduStatus model. */ +public class SduStatusTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSduStatus() throws Throwable { + SduStatus sduStatusModel = new SduStatus(); + assertNull(sduStatusModel.isEnabled()); + assertNull(sduStatusModel.getTotalAnnotatedPages()); + assertNull(sduStatusModel.getTotalPages()); + assertNull(sduStatusModel.getTotalDocuments()); + assertNull(sduStatusModel.getCustomFields()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/SearchStatusTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/SearchStatusTest.java new file mode 100644 index 00000000000..557c077f5e9 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/SearchStatusTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SearchStatus model. */ +public class SearchStatusTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSearchStatus() throws Throwable { + SearchStatus searchStatusModel = new SearchStatus(); + assertNull(searchStatusModel.getScope()); + assertNull(searchStatusModel.getStatus()); + assertNull(searchStatusModel.getStatusDescription()); + assertNull(searchStatusModel.getLastTrained()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/SegmentSettingsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/SegmentSettingsTest.java new file mode 100644 index 00000000000..ef8374de227 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/SegmentSettingsTest.java @@ -0,0 +1,54 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SegmentSettings model. */ +public class SegmentSettingsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSegmentSettings() throws Throwable { + SegmentSettings segmentSettingsModel = + new SegmentSettings.Builder() + .enabled(true) + .selectorTags(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .annotatedFields(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals(segmentSettingsModel.enabled(), Boolean.valueOf(true)); + assertEquals( + segmentSettingsModel.selectorTags(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals( + segmentSettingsModel.annotatedFields(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + String json = TestUtilities.serialize(segmentSettingsModel); + + SegmentSettings segmentSettingsModelNew = + TestUtilities.deserialize(json, SegmentSettings.class); + assertTrue(segmentSettingsModelNew instanceof SegmentSettings); + assertEquals(segmentSettingsModelNew.enabled(), Boolean.valueOf(true)); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/SourceOptionsBucketsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/SourceOptionsBucketsTest.java new file mode 100644 index 00000000000..bcd8445aa7d --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/SourceOptionsBucketsTest.java @@ -0,0 +1,51 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SourceOptionsBuckets model. */ +public class SourceOptionsBucketsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSourceOptionsBuckets() throws Throwable { + SourceOptionsBuckets sourceOptionsBucketsModel = + new SourceOptionsBuckets.Builder().name("testString").limit(Long.valueOf("26")).build(); + assertEquals(sourceOptionsBucketsModel.name(), "testString"); + assertEquals(sourceOptionsBucketsModel.limit(), Long.valueOf("26")); + + String json = TestUtilities.serialize(sourceOptionsBucketsModel); + + SourceOptionsBuckets sourceOptionsBucketsModelNew = + TestUtilities.deserialize(json, SourceOptionsBuckets.class); + assertTrue(sourceOptionsBucketsModelNew instanceof SourceOptionsBuckets); + assertEquals(sourceOptionsBucketsModelNew.name(), "testString"); + assertEquals(sourceOptionsBucketsModelNew.limit(), Long.valueOf("26")); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testSourceOptionsBucketsError() throws Throwable { + new SourceOptionsBuckets.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/SourceOptionsFolderTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/SourceOptionsFolderTest.java new file mode 100644 index 00000000000..c8a7b2aa599 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/SourceOptionsFolderTest.java @@ -0,0 +1,57 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SourceOptionsFolder model. */ +public class SourceOptionsFolderTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSourceOptionsFolder() throws Throwable { + SourceOptionsFolder sourceOptionsFolderModel = + new SourceOptionsFolder.Builder() + .ownerUserId("testString") + .folderId("testString") + .limit(Long.valueOf("26")) + .build(); + assertEquals(sourceOptionsFolderModel.ownerUserId(), "testString"); + assertEquals(sourceOptionsFolderModel.folderId(), "testString"); + assertEquals(sourceOptionsFolderModel.limit(), Long.valueOf("26")); + + String json = TestUtilities.serialize(sourceOptionsFolderModel); + + SourceOptionsFolder sourceOptionsFolderModelNew = + TestUtilities.deserialize(json, SourceOptionsFolder.class); + assertTrue(sourceOptionsFolderModelNew instanceof SourceOptionsFolder); + assertEquals(sourceOptionsFolderModelNew.ownerUserId(), "testString"); + assertEquals(sourceOptionsFolderModelNew.folderId(), "testString"); + assertEquals(sourceOptionsFolderModelNew.limit(), Long.valueOf("26")); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testSourceOptionsFolderError() throws Throwable { + new SourceOptionsFolder.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/SourceOptionsObjectTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/SourceOptionsObjectTest.java new file mode 100644 index 00000000000..b3c12a7d9aa --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/SourceOptionsObjectTest.java @@ -0,0 +1,51 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SourceOptionsObject model. */ +public class SourceOptionsObjectTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSourceOptionsObject() throws Throwable { + SourceOptionsObject sourceOptionsObjectModel = + new SourceOptionsObject.Builder().name("testString").limit(Long.valueOf("26")).build(); + assertEquals(sourceOptionsObjectModel.name(), "testString"); + assertEquals(sourceOptionsObjectModel.limit(), Long.valueOf("26")); + + String json = TestUtilities.serialize(sourceOptionsObjectModel); + + SourceOptionsObject sourceOptionsObjectModelNew = + TestUtilities.deserialize(json, SourceOptionsObject.class); + assertTrue(sourceOptionsObjectModelNew instanceof SourceOptionsObject); + assertEquals(sourceOptionsObjectModelNew.name(), "testString"); + assertEquals(sourceOptionsObjectModelNew.limit(), Long.valueOf("26")); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testSourceOptionsObjectError() throws Throwable { + new SourceOptionsObject.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/SourceOptionsSiteCollTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/SourceOptionsSiteCollTest.java new file mode 100644 index 00000000000..1316e7b5372 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/SourceOptionsSiteCollTest.java @@ -0,0 +1,54 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SourceOptionsSiteColl model. */ +public class SourceOptionsSiteCollTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSourceOptionsSiteColl() throws Throwable { + SourceOptionsSiteColl sourceOptionsSiteCollModel = + new SourceOptionsSiteColl.Builder() + .siteCollectionPath("testString") + .limit(Long.valueOf("26")) + .build(); + assertEquals(sourceOptionsSiteCollModel.siteCollectionPath(), "testString"); + assertEquals(sourceOptionsSiteCollModel.limit(), Long.valueOf("26")); + + String json = TestUtilities.serialize(sourceOptionsSiteCollModel); + + SourceOptionsSiteColl sourceOptionsSiteCollModelNew = + TestUtilities.deserialize(json, SourceOptionsSiteColl.class); + assertTrue(sourceOptionsSiteCollModelNew instanceof SourceOptionsSiteColl); + assertEquals(sourceOptionsSiteCollModelNew.siteCollectionPath(), "testString"); + assertEquals(sourceOptionsSiteCollModelNew.limit(), Long.valueOf("26")); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testSourceOptionsSiteCollError() throws Throwable { + new SourceOptionsSiteColl.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/SourceOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/SourceOptionsTest.java new file mode 100644 index 00000000000..cf25f11ce0c --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/SourceOptionsTest.java @@ -0,0 +1,130 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SourceOptions model. */ +public class SourceOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSourceOptions() throws Throwable { + SourceOptionsFolder sourceOptionsFolderModel = + new SourceOptionsFolder.Builder() + .ownerUserId("testString") + .folderId("testString") + .limit(Long.valueOf("26")) + .build(); + assertEquals(sourceOptionsFolderModel.ownerUserId(), "testString"); + assertEquals(sourceOptionsFolderModel.folderId(), "testString"); + assertEquals(sourceOptionsFolderModel.limit(), Long.valueOf("26")); + + SourceOptionsObject sourceOptionsObjectModel = + new SourceOptionsObject.Builder().name("testString").limit(Long.valueOf("26")).build(); + assertEquals(sourceOptionsObjectModel.name(), "testString"); + assertEquals(sourceOptionsObjectModel.limit(), Long.valueOf("26")); + + SourceOptionsSiteColl sourceOptionsSiteCollModel = + new SourceOptionsSiteColl.Builder() + .siteCollectionPath("testString") + .limit(Long.valueOf("26")) + .build(); + assertEquals(sourceOptionsSiteCollModel.siteCollectionPath(), "testString"); + assertEquals(sourceOptionsSiteCollModel.limit(), Long.valueOf("26")); + + SourceOptionsWebCrawl sourceOptionsWebCrawlModel = + new SourceOptionsWebCrawl.Builder() + .url("testString") + .limitToStartingHosts(true) + .crawlSpeed("gentle") + .allowUntrustedCertificate(true) + .maximumHops(Long.valueOf("26")) + .requestTimeout(Long.valueOf("26")) + .overrideRobotsTxt(true) + .blacklist(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals(sourceOptionsWebCrawlModel.url(), "testString"); + assertEquals(sourceOptionsWebCrawlModel.limitToStartingHosts(), Boolean.valueOf(true)); + assertEquals(sourceOptionsWebCrawlModel.crawlSpeed(), "gentle"); + assertEquals(sourceOptionsWebCrawlModel.allowUntrustedCertificate(), Boolean.valueOf(true)); + assertEquals(sourceOptionsWebCrawlModel.maximumHops(), Long.valueOf("26")); + assertEquals(sourceOptionsWebCrawlModel.requestTimeout(), Long.valueOf("26")); + assertEquals(sourceOptionsWebCrawlModel.overrideRobotsTxt(), Boolean.valueOf(true)); + assertEquals( + sourceOptionsWebCrawlModel.blacklist(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + SourceOptionsBuckets sourceOptionsBucketsModel = + new SourceOptionsBuckets.Builder().name("testString").limit(Long.valueOf("26")).build(); + assertEquals(sourceOptionsBucketsModel.name(), "testString"); + assertEquals(sourceOptionsBucketsModel.limit(), Long.valueOf("26")); + + SourceOptions sourceOptionsModel = + new SourceOptions.Builder() + .folders( + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsFolderModel))) + .objects( + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsObjectModel))) + .siteCollections( + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsSiteCollModel))) + .urls( + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsWebCrawlModel))) + .buckets( + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsBucketsModel))) + .crawlAllBuckets(true) + .build(); + assertEquals( + sourceOptionsModel.folders(), + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsFolderModel))); + assertEquals( + sourceOptionsModel.objects(), + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsObjectModel))); + assertEquals( + sourceOptionsModel.siteCollections(), + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsSiteCollModel))); + assertEquals( + sourceOptionsModel.urls(), + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsWebCrawlModel))); + assertEquals( + sourceOptionsModel.buckets(), + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsBucketsModel))); + assertEquals(sourceOptionsModel.crawlAllBuckets(), Boolean.valueOf(true)); + + String json = TestUtilities.serialize(sourceOptionsModel); + + SourceOptions sourceOptionsModelNew = TestUtilities.deserialize(json, SourceOptions.class); + assertTrue(sourceOptionsModelNew instanceof SourceOptions); + assertEquals(sourceOptionsModelNew.crawlAllBuckets(), Boolean.valueOf(true)); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/SourceOptionsWebCrawlTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/SourceOptionsWebCrawlTest.java new file mode 100644 index 00000000000..dabe0340df8 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/SourceOptionsWebCrawlTest.java @@ -0,0 +1,73 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SourceOptionsWebCrawl model. */ +public class SourceOptionsWebCrawlTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSourceOptionsWebCrawl() throws Throwable { + SourceOptionsWebCrawl sourceOptionsWebCrawlModel = + new SourceOptionsWebCrawl.Builder() + .url("testString") + .limitToStartingHosts(true) + .crawlSpeed("gentle") + .allowUntrustedCertificate(true) + .maximumHops(Long.valueOf("26")) + .requestTimeout(Long.valueOf("26")) + .overrideRobotsTxt(true) + .blacklist(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals(sourceOptionsWebCrawlModel.url(), "testString"); + assertEquals(sourceOptionsWebCrawlModel.limitToStartingHosts(), Boolean.valueOf(true)); + assertEquals(sourceOptionsWebCrawlModel.crawlSpeed(), "gentle"); + assertEquals(sourceOptionsWebCrawlModel.allowUntrustedCertificate(), Boolean.valueOf(true)); + assertEquals(sourceOptionsWebCrawlModel.maximumHops(), Long.valueOf("26")); + assertEquals(sourceOptionsWebCrawlModel.requestTimeout(), Long.valueOf("26")); + assertEquals(sourceOptionsWebCrawlModel.overrideRobotsTxt(), Boolean.valueOf(true)); + assertEquals( + sourceOptionsWebCrawlModel.blacklist(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + String json = TestUtilities.serialize(sourceOptionsWebCrawlModel); + + SourceOptionsWebCrawl sourceOptionsWebCrawlModelNew = + TestUtilities.deserialize(json, SourceOptionsWebCrawl.class); + assertTrue(sourceOptionsWebCrawlModelNew instanceof SourceOptionsWebCrawl); + assertEquals(sourceOptionsWebCrawlModelNew.url(), "testString"); + assertEquals(sourceOptionsWebCrawlModelNew.limitToStartingHosts(), Boolean.valueOf(true)); + assertEquals(sourceOptionsWebCrawlModelNew.crawlSpeed(), "gentle"); + assertEquals(sourceOptionsWebCrawlModelNew.allowUntrustedCertificate(), Boolean.valueOf(true)); + assertEquals(sourceOptionsWebCrawlModelNew.maximumHops(), Long.valueOf("26")); + assertEquals(sourceOptionsWebCrawlModelNew.requestTimeout(), Long.valueOf("26")); + assertEquals(sourceOptionsWebCrawlModelNew.overrideRobotsTxt(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testSourceOptionsWebCrawlError() throws Throwable { + new SourceOptionsWebCrawl.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/SourceScheduleTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/SourceScheduleTest.java new file mode 100644 index 00000000000..e725a8682fc --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/SourceScheduleTest.java @@ -0,0 +1,51 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SourceSchedule model. */ +public class SourceScheduleTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSourceSchedule() throws Throwable { + SourceSchedule sourceScheduleModel = + new SourceSchedule.Builder() + .enabled(true) + .timeZone("testString") + .frequency("daily") + .build(); + assertEquals(sourceScheduleModel.enabled(), Boolean.valueOf(true)); + assertEquals(sourceScheduleModel.timeZone(), "testString"); + assertEquals(sourceScheduleModel.frequency(), "daily"); + + String json = TestUtilities.serialize(sourceScheduleModel); + + SourceSchedule sourceScheduleModelNew = TestUtilities.deserialize(json, SourceSchedule.class); + assertTrue(sourceScheduleModelNew instanceof SourceSchedule); + assertEquals(sourceScheduleModelNew.enabled(), Boolean.valueOf(true)); + assertEquals(sourceScheduleModelNew.timeZone(), "testString"); + assertEquals(sourceScheduleModelNew.frequency(), "daily"); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/SourceStatusTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/SourceStatusTest.java new file mode 100644 index 00000000000..307714a701c --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/SourceStatusTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SourceStatus model. */ +public class SourceStatusTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSourceStatus() throws Throwable { + SourceStatus sourceStatusModel = new SourceStatus(); + assertNull(sourceStatusModel.getStatus()); + assertNull(sourceStatusModel.getNextCrawl()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/SourceTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/SourceTest.java new file mode 100644 index 00000000000..842e85fe5a6 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/SourceTest.java @@ -0,0 +1,155 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Source model. */ +public class SourceTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSource() throws Throwable { + SourceSchedule sourceScheduleModel = + new SourceSchedule.Builder() + .enabled(true) + .timeZone("testString") + .frequency("daily") + .build(); + assertEquals(sourceScheduleModel.enabled(), Boolean.valueOf(true)); + assertEquals(sourceScheduleModel.timeZone(), "testString"); + assertEquals(sourceScheduleModel.frequency(), "daily"); + + SourceOptionsFolder sourceOptionsFolderModel = + new SourceOptionsFolder.Builder() + .ownerUserId("testString") + .folderId("testString") + .limit(Long.valueOf("26")) + .build(); + assertEquals(sourceOptionsFolderModel.ownerUserId(), "testString"); + assertEquals(sourceOptionsFolderModel.folderId(), "testString"); + assertEquals(sourceOptionsFolderModel.limit(), Long.valueOf("26")); + + SourceOptionsObject sourceOptionsObjectModel = + new SourceOptionsObject.Builder().name("testString").limit(Long.valueOf("26")).build(); + assertEquals(sourceOptionsObjectModel.name(), "testString"); + assertEquals(sourceOptionsObjectModel.limit(), Long.valueOf("26")); + + SourceOptionsSiteColl sourceOptionsSiteCollModel = + new SourceOptionsSiteColl.Builder() + .siteCollectionPath("testString") + .limit(Long.valueOf("26")) + .build(); + assertEquals(sourceOptionsSiteCollModel.siteCollectionPath(), "testString"); + assertEquals(sourceOptionsSiteCollModel.limit(), Long.valueOf("26")); + + SourceOptionsWebCrawl sourceOptionsWebCrawlModel = + new SourceOptionsWebCrawl.Builder() + .url("testString") + .limitToStartingHosts(true) + .crawlSpeed("gentle") + .allowUntrustedCertificate(true) + .maximumHops(Long.valueOf("26")) + .requestTimeout(Long.valueOf("26")) + .overrideRobotsTxt(true) + .blacklist(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals(sourceOptionsWebCrawlModel.url(), "testString"); + assertEquals(sourceOptionsWebCrawlModel.limitToStartingHosts(), Boolean.valueOf(true)); + assertEquals(sourceOptionsWebCrawlModel.crawlSpeed(), "gentle"); + assertEquals(sourceOptionsWebCrawlModel.allowUntrustedCertificate(), Boolean.valueOf(true)); + assertEquals(sourceOptionsWebCrawlModel.maximumHops(), Long.valueOf("26")); + assertEquals(sourceOptionsWebCrawlModel.requestTimeout(), Long.valueOf("26")); + assertEquals(sourceOptionsWebCrawlModel.overrideRobotsTxt(), Boolean.valueOf(true)); + assertEquals( + sourceOptionsWebCrawlModel.blacklist(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + SourceOptionsBuckets sourceOptionsBucketsModel = + new SourceOptionsBuckets.Builder().name("testString").limit(Long.valueOf("26")).build(); + assertEquals(sourceOptionsBucketsModel.name(), "testString"); + assertEquals(sourceOptionsBucketsModel.limit(), Long.valueOf("26")); + + SourceOptions sourceOptionsModel = + new SourceOptions.Builder() + .folders( + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsFolderModel))) + .objects( + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsObjectModel))) + .siteCollections( + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsSiteCollModel))) + .urls( + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsWebCrawlModel))) + .buckets( + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsBucketsModel))) + .crawlAllBuckets(true) + .build(); + assertEquals( + sourceOptionsModel.folders(), + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsFolderModel))); + assertEquals( + sourceOptionsModel.objects(), + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsObjectModel))); + assertEquals( + sourceOptionsModel.siteCollections(), + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsSiteCollModel))); + assertEquals( + sourceOptionsModel.urls(), + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsWebCrawlModel))); + assertEquals( + sourceOptionsModel.buckets(), + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsBucketsModel))); + assertEquals(sourceOptionsModel.crawlAllBuckets(), Boolean.valueOf(true)); + + Source sourceModel = + new Source.Builder() + .type("box") + .credentialId("testString") + .schedule(sourceScheduleModel) + .options(sourceOptionsModel) + .build(); + assertEquals(sourceModel.type(), "box"); + assertEquals(sourceModel.credentialId(), "testString"); + assertEquals(sourceModel.schedule(), sourceScheduleModel); + assertEquals(sourceModel.options(), sourceOptionsModel); + + String json = TestUtilities.serialize(sourceModel); + + Source sourceModelNew = TestUtilities.deserialize(json, Source.class); + assertTrue(sourceModelNew instanceof Source); + assertEquals(sourceModelNew.type(), "box"); + assertEquals(sourceModelNew.credentialId(), "testString"); + assertEquals(sourceModelNew.schedule().toString(), sourceScheduleModel.toString()); + assertEquals(sourceModelNew.options().toString(), sourceOptionsModel.toString()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/TermTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/TermTest.java new file mode 100644 index 00000000000..b51892762e5 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/TermTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Term model. */ +public class TermTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTerm() throws Throwable { + Term termModel = new Term(); + assertNull(termModel.getType()); + assertNull(termModel.getMatchingResults()); + assertNull(termModel.getField()); + assertNull(termModel.getCount()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/TimesliceTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/TimesliceTest.java new file mode 100644 index 00000000000..c87ee36964e --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/TimesliceTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Timeslice model. */ +public class TimesliceTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTimeslice() throws Throwable { + Timeslice timesliceModel = new Timeslice(); + assertNull(timesliceModel.getType()); + assertNull(timesliceModel.getMatchingResults()); + assertNull(timesliceModel.getField()); + assertNull(timesliceModel.getInterval()); + assertNull(timesliceModel.isAnomaly()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/TokenDictRuleTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/TokenDictRuleTest.java new file mode 100644 index 00000000000..628823545db --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/TokenDictRuleTest.java @@ -0,0 +1,61 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TokenDictRule model. */ +public class TokenDictRuleTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTokenDictRule() throws Throwable { + TokenDictRule tokenDictRuleModel = + new TokenDictRule.Builder() + .text("testString") + .tokens(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .readings(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .partOfSpeech("testString") + .build(); + assertEquals(tokenDictRuleModel.text(), "testString"); + assertEquals( + tokenDictRuleModel.tokens(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals( + tokenDictRuleModel.readings(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals(tokenDictRuleModel.partOfSpeech(), "testString"); + + String json = TestUtilities.serialize(tokenDictRuleModel); + + TokenDictRule tokenDictRuleModelNew = TestUtilities.deserialize(json, TokenDictRule.class); + assertTrue(tokenDictRuleModelNew instanceof TokenDictRule); + assertEquals(tokenDictRuleModelNew.text(), "testString"); + assertEquals(tokenDictRuleModelNew.partOfSpeech(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testTokenDictRuleError() throws Throwable { + new TokenDictRule.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/TokenDictStatusResponseTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/TokenDictStatusResponseTest.java new file mode 100644 index 00000000000..7243225b393 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/TokenDictStatusResponseTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TokenDictStatusResponse model. */ +public class TokenDictStatusResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTokenDictStatusResponse() throws Throwable { + TokenDictStatusResponse tokenDictStatusResponseModel = new TokenDictStatusResponse(); + assertNull(tokenDictStatusResponseModel.getStatus()); + assertNull(tokenDictStatusResponseModel.getType()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/TopHitsResultsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/TopHitsResultsTest.java new file mode 100644 index 00000000000..7495172a3af --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/TopHitsResultsTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TopHitsResults model. */ +public class TopHitsResultsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTopHitsResults() throws Throwable { + TopHitsResults topHitsResultsModel = new TopHitsResults(); + assertNull(topHitsResultsModel.getMatchingResults()); + assertNull(topHitsResultsModel.getHits()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/TopHitsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/TopHitsTest.java new file mode 100644 index 00000000000..a13e7ea7cce --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/TopHitsTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TopHits model. */ +public class TopHitsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTopHits() throws Throwable { + TopHits topHitsModel = new TopHits(); + assertNull(topHitsModel.getType()); + assertNull(topHitsModel.getMatchingResults()); + assertNull(topHitsModel.getSize()); + assertNull(topHitsModel.getHits()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/TrainingDataSetTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/TrainingDataSetTest.java new file mode 100644 index 00000000000..e21cbe3bff3 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/TrainingDataSetTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TrainingDataSet model. */ +public class TrainingDataSetTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTrainingDataSet() throws Throwable { + TrainingDataSet trainingDataSetModel = new TrainingDataSet(); + assertNull(trainingDataSetModel.getEnvironmentId()); + assertNull(trainingDataSetModel.getCollectionId()); + assertNull(trainingDataSetModel.getQueries()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/TrainingExampleListTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/TrainingExampleListTest.java new file mode 100644 index 00000000000..6ac589a45d8 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/TrainingExampleListTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TrainingExampleList model. */ +public class TrainingExampleListTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTrainingExampleList() throws Throwable { + TrainingExampleList trainingExampleListModel = new TrainingExampleList(); + assertNull(trainingExampleListModel.getExamples()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/TrainingExampleTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/TrainingExampleTest.java new file mode 100644 index 00000000000..bf6456ad7dc --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/TrainingExampleTest.java @@ -0,0 +1,52 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TrainingExample model. */ +public class TrainingExampleTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTrainingExample() throws Throwable { + TrainingExample trainingExampleModel = + new TrainingExample.Builder() + .documentId("testString") + .crossReference("testString") + .relevance(Long.valueOf("26")) + .build(); + assertEquals(trainingExampleModel.documentId(), "testString"); + assertEquals(trainingExampleModel.crossReference(), "testString"); + assertEquals(trainingExampleModel.relevance(), Long.valueOf("26")); + + String json = TestUtilities.serialize(trainingExampleModel); + + TrainingExample trainingExampleModelNew = + TestUtilities.deserialize(json, TrainingExample.class); + assertTrue(trainingExampleModelNew instanceof TrainingExample); + assertEquals(trainingExampleModelNew.documentId(), "testString"); + assertEquals(trainingExampleModelNew.crossReference(), "testString"); + assertEquals(trainingExampleModelNew.relevance(), Long.valueOf("26")); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/TrainingQueryTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/TrainingQueryTest.java new file mode 100644 index 00000000000..231000a0d3a --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/TrainingQueryTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TrainingQuery model. */ +public class TrainingQueryTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTrainingQuery() throws Throwable { + TrainingQuery trainingQueryModel = new TrainingQuery(); + assertNull(trainingQueryModel.getQueryId()); + assertNull(trainingQueryModel.getNaturalLanguageQuery()); + assertNull(trainingQueryModel.getFilter()); + assertNull(trainingQueryModel.getExamples()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/TrainingStatusTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/TrainingStatusTest.java new file mode 100644 index 00000000000..e21cb3199b3 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/TrainingStatusTest.java @@ -0,0 +1,44 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TrainingStatus model. */ +public class TrainingStatusTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTrainingStatus() throws Throwable { + TrainingStatus trainingStatusModel = new TrainingStatus(); + assertNull(trainingStatusModel.getTotalExamples()); + assertNull(trainingStatusModel.isAvailable()); + assertNull(trainingStatusModel.isProcessing()); + assertNull(trainingStatusModel.isMinimumQueriesAdded()); + assertNull(trainingStatusModel.isMinimumExamplesAdded()); + assertNull(trainingStatusModel.isSufficientLabelDiversity()); + assertNull(trainingStatusModel.getNotices()); + assertNull(trainingStatusModel.getSuccessfullyTrained()); + assertNull(trainingStatusModel.getDataUpdated()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/UpdateCollectionOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/UpdateCollectionOptionsTest.java new file mode 100644 index 00000000000..8c3e814df61 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/UpdateCollectionOptionsTest.java @@ -0,0 +1,52 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the UpdateCollectionOptions model. */ +public class UpdateCollectionOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateCollectionOptions() throws Throwable { + UpdateCollectionOptions updateCollectionOptionsModel = + new UpdateCollectionOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .name("testString") + .description("testString") + .configurationId("testString") + .build(); + assertEquals(updateCollectionOptionsModel.environmentId(), "testString"); + assertEquals(updateCollectionOptionsModel.collectionId(), "testString"); + assertEquals(updateCollectionOptionsModel.name(), "testString"); + assertEquals(updateCollectionOptionsModel.description(), "testString"); + assertEquals(updateCollectionOptionsModel.configurationId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateCollectionOptionsError() throws Throwable { + new UpdateCollectionOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/UpdateConfigurationOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/UpdateConfigurationOptionsTest.java new file mode 100644 index 00000000000..196eae8a717 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/UpdateConfigurationOptionsTest.java @@ -0,0 +1,439 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the UpdateConfigurationOptions model. */ +public class UpdateConfigurationOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateConfigurationOptions() throws Throwable { + FontSetting fontSettingModel = + new FontSetting.Builder() + .level(Long.valueOf("26")) + .minSize(Long.valueOf("26")) + .maxSize(Long.valueOf("26")) + .bold(true) + .italic(true) + .name("testString") + .build(); + assertEquals(fontSettingModel.level(), Long.valueOf("26")); + assertEquals(fontSettingModel.minSize(), Long.valueOf("26")); + assertEquals(fontSettingModel.maxSize(), Long.valueOf("26")); + assertEquals(fontSettingModel.bold(), Boolean.valueOf(true)); + assertEquals(fontSettingModel.italic(), Boolean.valueOf(true)); + assertEquals(fontSettingModel.name(), "testString"); + + PdfHeadingDetection pdfHeadingDetectionModel = + new PdfHeadingDetection.Builder() + .fonts(new java.util.ArrayList(java.util.Arrays.asList(fontSettingModel))) + .build(); + assertEquals( + pdfHeadingDetectionModel.fonts(), + new java.util.ArrayList(java.util.Arrays.asList(fontSettingModel))); + + PdfSettings pdfSettingsModel = + new PdfSettings.Builder().heading(pdfHeadingDetectionModel).build(); + assertEquals(pdfSettingsModel.heading(), pdfHeadingDetectionModel); + + WordStyle wordStyleModel = + new WordStyle.Builder() + .level(Long.valueOf("26")) + .names(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals(wordStyleModel.level(), Long.valueOf("26")); + assertEquals( + wordStyleModel.names(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + WordHeadingDetection wordHeadingDetectionModel = + new WordHeadingDetection.Builder() + .fonts(new java.util.ArrayList(java.util.Arrays.asList(fontSettingModel))) + .styles(new java.util.ArrayList(java.util.Arrays.asList(wordStyleModel))) + .build(); + assertEquals( + wordHeadingDetectionModel.fonts(), + new java.util.ArrayList(java.util.Arrays.asList(fontSettingModel))); + assertEquals( + wordHeadingDetectionModel.styles(), + new java.util.ArrayList(java.util.Arrays.asList(wordStyleModel))); + + WordSettings wordSettingsModel = + new WordSettings.Builder().heading(wordHeadingDetectionModel).build(); + assertEquals(wordSettingsModel.heading(), wordHeadingDetectionModel); + + XPathPatterns xPathPatternsModel = + new XPathPatterns.Builder() + .xpaths(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals( + xPathPatternsModel.xpaths(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + HtmlSettings htmlSettingsModel = + new HtmlSettings.Builder() + .excludeTagsCompletely( + new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .excludeTagsKeepContent( + new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .keepContent(xPathPatternsModel) + .excludeContent(xPathPatternsModel) + .keepTagAttributes( + new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .excludeTagAttributes( + new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals( + htmlSettingsModel.excludeTagsCompletely(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals( + htmlSettingsModel.excludeTagsKeepContent(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals(htmlSettingsModel.keepContent(), xPathPatternsModel); + assertEquals(htmlSettingsModel.excludeContent(), xPathPatternsModel); + assertEquals( + htmlSettingsModel.keepTagAttributes(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals( + htmlSettingsModel.excludeTagAttributes(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + SegmentSettings segmentSettingsModel = + new SegmentSettings.Builder() + .enabled(true) + .selectorTags(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .annotatedFields(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals(segmentSettingsModel.enabled(), Boolean.valueOf(true)); + assertEquals( + segmentSettingsModel.selectorTags(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals( + segmentSettingsModel.annotatedFields(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + NormalizationOperation normalizationOperationModel = + new NormalizationOperation.Builder() + .operation("copy") + .sourceField("testString") + .destinationField("testString") + .build(); + assertEquals(normalizationOperationModel.operation(), "copy"); + assertEquals(normalizationOperationModel.sourceField(), "testString"); + assertEquals(normalizationOperationModel.destinationField(), "testString"); + + Conversions conversionsModel = + new Conversions.Builder() + .pdf(pdfSettingsModel) + .word(wordSettingsModel) + .html(htmlSettingsModel) + .segment(segmentSettingsModel) + .jsonNormalizations( + new java.util.ArrayList( + java.util.Arrays.asList(normalizationOperationModel))) + .imageTextRecognition(true) + .build(); + assertEquals(conversionsModel.pdf(), pdfSettingsModel); + assertEquals(conversionsModel.word(), wordSettingsModel); + assertEquals(conversionsModel.html(), htmlSettingsModel); + assertEquals(conversionsModel.segment(), segmentSettingsModel); + assertEquals( + conversionsModel.jsonNormalizations(), + new java.util.ArrayList( + java.util.Arrays.asList(normalizationOperationModel))); + assertEquals(conversionsModel.imageTextRecognition(), Boolean.valueOf(true)); + + NluEnrichmentKeywords nluEnrichmentKeywordsModel = + new NluEnrichmentKeywords.Builder() + .sentiment(true) + .emotion(true) + .limit(Long.valueOf("26")) + .build(); + assertEquals(nluEnrichmentKeywordsModel.sentiment(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentKeywordsModel.emotion(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentKeywordsModel.limit(), Long.valueOf("26")); + + NluEnrichmentEntities nluEnrichmentEntitiesModel = + new NluEnrichmentEntities.Builder() + .sentiment(true) + .emotion(true) + .limit(Long.valueOf("26")) + .mentions(true) + .mentionTypes(true) + .sentenceLocations(true) + .model("testString") + .build(); + assertEquals(nluEnrichmentEntitiesModel.sentiment(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentEntitiesModel.emotion(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentEntitiesModel.limit(), Long.valueOf("26")); + assertEquals(nluEnrichmentEntitiesModel.mentions(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentEntitiesModel.mentionTypes(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentEntitiesModel.sentenceLocations(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentEntitiesModel.model(), "testString"); + + NluEnrichmentSentiment nluEnrichmentSentimentModel = + new NluEnrichmentSentiment.Builder() + .document(true) + .targets(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals(nluEnrichmentSentimentModel.document(), Boolean.valueOf(true)); + assertEquals( + nluEnrichmentSentimentModel.targets(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + NluEnrichmentEmotion nluEnrichmentEmotionModel = + new NluEnrichmentEmotion.Builder() + .document(true) + .targets(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals(nluEnrichmentEmotionModel.document(), Boolean.valueOf(true)); + assertEquals( + nluEnrichmentEmotionModel.targets(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + NluEnrichmentSemanticRoles nluEnrichmentSemanticRolesModel = + new NluEnrichmentSemanticRoles.Builder() + .entities(true) + .keywords(true) + .limit(Long.valueOf("26")) + .build(); + assertEquals(nluEnrichmentSemanticRolesModel.entities(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentSemanticRolesModel.keywords(), Boolean.valueOf(true)); + assertEquals(nluEnrichmentSemanticRolesModel.limit(), Long.valueOf("26")); + + NluEnrichmentRelations nluEnrichmentRelationsModel = + new NluEnrichmentRelations.Builder().model("testString").build(); + assertEquals(nluEnrichmentRelationsModel.model(), "testString"); + + NluEnrichmentConcepts nluEnrichmentConceptsModel = + new NluEnrichmentConcepts.Builder().limit(Long.valueOf("26")).build(); + assertEquals(nluEnrichmentConceptsModel.limit(), Long.valueOf("26")); + + NluEnrichmentFeatures nluEnrichmentFeaturesModel = + new NluEnrichmentFeatures.Builder() + .keywords(nluEnrichmentKeywordsModel) + .entities(nluEnrichmentEntitiesModel) + .sentiment(nluEnrichmentSentimentModel) + .emotion(nluEnrichmentEmotionModel) + .categories( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .semanticRoles(nluEnrichmentSemanticRolesModel) + .relations(nluEnrichmentRelationsModel) + .concepts(nluEnrichmentConceptsModel) + .build(); + assertEquals(nluEnrichmentFeaturesModel.keywords(), nluEnrichmentKeywordsModel); + assertEquals(nluEnrichmentFeaturesModel.entities(), nluEnrichmentEntitiesModel); + assertEquals(nluEnrichmentFeaturesModel.sentiment(), nluEnrichmentSentimentModel); + assertEquals(nluEnrichmentFeaturesModel.emotion(), nluEnrichmentEmotionModel); + assertEquals( + nluEnrichmentFeaturesModel.categories(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals(nluEnrichmentFeaturesModel.semanticRoles(), nluEnrichmentSemanticRolesModel); + assertEquals(nluEnrichmentFeaturesModel.relations(), nluEnrichmentRelationsModel); + assertEquals(nluEnrichmentFeaturesModel.concepts(), nluEnrichmentConceptsModel); + + EnrichmentOptions enrichmentOptionsModel = + new EnrichmentOptions.Builder() + .features(nluEnrichmentFeaturesModel) + .language("ar") + .model("testString") + .build(); + assertEquals(enrichmentOptionsModel.features(), nluEnrichmentFeaturesModel); + assertEquals(enrichmentOptionsModel.language(), "ar"); + assertEquals(enrichmentOptionsModel.model(), "testString"); + + Enrichment enrichmentModel = + new Enrichment.Builder() + .description("testString") + .destinationField("testString") + .sourceField("testString") + .overwrite(true) + .enrichment("testString") + .ignoreDownstreamErrors(true) + .options(enrichmentOptionsModel) + .build(); + assertEquals(enrichmentModel.description(), "testString"); + assertEquals(enrichmentModel.destinationField(), "testString"); + assertEquals(enrichmentModel.sourceField(), "testString"); + assertEquals(enrichmentModel.overwrite(), Boolean.valueOf(true)); + assertEquals(enrichmentModel.enrichment(), "testString"); + assertEquals(enrichmentModel.ignoreDownstreamErrors(), Boolean.valueOf(true)); + assertEquals(enrichmentModel.options(), enrichmentOptionsModel); + + SourceSchedule sourceScheduleModel = + new SourceSchedule.Builder() + .enabled(true) + .timeZone("testString") + .frequency("daily") + .build(); + assertEquals(sourceScheduleModel.enabled(), Boolean.valueOf(true)); + assertEquals(sourceScheduleModel.timeZone(), "testString"); + assertEquals(sourceScheduleModel.frequency(), "daily"); + + SourceOptionsFolder sourceOptionsFolderModel = + new SourceOptionsFolder.Builder() + .ownerUserId("testString") + .folderId("testString") + .limit(Long.valueOf("26")) + .build(); + assertEquals(sourceOptionsFolderModel.ownerUserId(), "testString"); + assertEquals(sourceOptionsFolderModel.folderId(), "testString"); + assertEquals(sourceOptionsFolderModel.limit(), Long.valueOf("26")); + + SourceOptionsObject sourceOptionsObjectModel = + new SourceOptionsObject.Builder().name("testString").limit(Long.valueOf("26")).build(); + assertEquals(sourceOptionsObjectModel.name(), "testString"); + assertEquals(sourceOptionsObjectModel.limit(), Long.valueOf("26")); + + SourceOptionsSiteColl sourceOptionsSiteCollModel = + new SourceOptionsSiteColl.Builder() + .siteCollectionPath("testString") + .limit(Long.valueOf("26")) + .build(); + assertEquals(sourceOptionsSiteCollModel.siteCollectionPath(), "testString"); + assertEquals(sourceOptionsSiteCollModel.limit(), Long.valueOf("26")); + + SourceOptionsWebCrawl sourceOptionsWebCrawlModel = + new SourceOptionsWebCrawl.Builder() + .url("testString") + .limitToStartingHosts(true) + .crawlSpeed("gentle") + .allowUntrustedCertificate(true) + .maximumHops(Long.valueOf("26")) + .requestTimeout(Long.valueOf("26")) + .overrideRobotsTxt(true) + .blacklist(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals(sourceOptionsWebCrawlModel.url(), "testString"); + assertEquals(sourceOptionsWebCrawlModel.limitToStartingHosts(), Boolean.valueOf(true)); + assertEquals(sourceOptionsWebCrawlModel.crawlSpeed(), "gentle"); + assertEquals(sourceOptionsWebCrawlModel.allowUntrustedCertificate(), Boolean.valueOf(true)); + assertEquals(sourceOptionsWebCrawlModel.maximumHops(), Long.valueOf("26")); + assertEquals(sourceOptionsWebCrawlModel.requestTimeout(), Long.valueOf("26")); + assertEquals(sourceOptionsWebCrawlModel.overrideRobotsTxt(), Boolean.valueOf(true)); + assertEquals( + sourceOptionsWebCrawlModel.blacklist(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + SourceOptionsBuckets sourceOptionsBucketsModel = + new SourceOptionsBuckets.Builder().name("testString").limit(Long.valueOf("26")).build(); + assertEquals(sourceOptionsBucketsModel.name(), "testString"); + assertEquals(sourceOptionsBucketsModel.limit(), Long.valueOf("26")); + + SourceOptions sourceOptionsModel = + new SourceOptions.Builder() + .folders( + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsFolderModel))) + .objects( + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsObjectModel))) + .siteCollections( + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsSiteCollModel))) + .urls( + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsWebCrawlModel))) + .buckets( + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsBucketsModel))) + .crawlAllBuckets(true) + .build(); + assertEquals( + sourceOptionsModel.folders(), + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsFolderModel))); + assertEquals( + sourceOptionsModel.objects(), + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsObjectModel))); + assertEquals( + sourceOptionsModel.siteCollections(), + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsSiteCollModel))); + assertEquals( + sourceOptionsModel.urls(), + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsWebCrawlModel))); + assertEquals( + sourceOptionsModel.buckets(), + new java.util.ArrayList( + java.util.Arrays.asList(sourceOptionsBucketsModel))); + assertEquals(sourceOptionsModel.crawlAllBuckets(), Boolean.valueOf(true)); + + Source sourceModel = + new Source.Builder() + .type("box") + .credentialId("testString") + .schedule(sourceScheduleModel) + .options(sourceOptionsModel) + .build(); + assertEquals(sourceModel.type(), "box"); + assertEquals(sourceModel.credentialId(), "testString"); + assertEquals(sourceModel.schedule(), sourceScheduleModel); + assertEquals(sourceModel.options(), sourceOptionsModel); + + UpdateConfigurationOptions updateConfigurationOptionsModel = + new UpdateConfigurationOptions.Builder() + .environmentId("testString") + .configurationId("testString") + .name("testString") + .description("testString") + .conversions(conversionsModel) + .enrichments( + new java.util.ArrayList(java.util.Arrays.asList(enrichmentModel))) + .normalizations( + new java.util.ArrayList( + java.util.Arrays.asList(normalizationOperationModel))) + .source(sourceModel) + .build(); + assertEquals(updateConfigurationOptionsModel.environmentId(), "testString"); + assertEquals(updateConfigurationOptionsModel.configurationId(), "testString"); + assertEquals(updateConfigurationOptionsModel.name(), "testString"); + assertEquals(updateConfigurationOptionsModel.description(), "testString"); + assertEquals(updateConfigurationOptionsModel.conversions(), conversionsModel); + assertEquals( + updateConfigurationOptionsModel.enrichments(), + new java.util.ArrayList(java.util.Arrays.asList(enrichmentModel))); + assertEquals( + updateConfigurationOptionsModel.normalizations(), + new java.util.ArrayList( + java.util.Arrays.asList(normalizationOperationModel))); + assertEquals(updateConfigurationOptionsModel.source(), sourceModel); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateConfigurationOptionsError() throws Throwable { + new UpdateConfigurationOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/UpdateCredentialsOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/UpdateCredentialsOptionsTest.java new file mode 100644 index 00000000000..dd04b8eb536 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/UpdateCredentialsOptionsTest.java @@ -0,0 +1,94 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the UpdateCredentialsOptions model. */ +public class UpdateCredentialsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateCredentialsOptions() throws Throwable { + CredentialDetails credentialDetailsModel = + new CredentialDetails.Builder() + .credentialType("oauth2") + .clientId("testString") + .enterpriseId("testString") + .url("testString") + .username("testString") + .organizationUrl("testString") + .siteCollectionPath("testString") + .clientSecret("testString") + .publicKeyId("testString") + .privateKey("testString") + .passphrase("testString") + .password("testString") + .gatewayId("testString") + .sourceVersion("online") + .webApplicationUrl("testString") + .domain("testString") + .endpoint("testString") + .accessKeyId("testString") + .secretAccessKey("testString") + .build(); + assertEquals(credentialDetailsModel.credentialType(), "oauth2"); + assertEquals(credentialDetailsModel.clientId(), "testString"); + assertEquals(credentialDetailsModel.enterpriseId(), "testString"); + assertEquals(credentialDetailsModel.url(), "testString"); + assertEquals(credentialDetailsModel.username(), "testString"); + assertEquals(credentialDetailsModel.organizationUrl(), "testString"); + assertEquals(credentialDetailsModel.siteCollectionPath(), "testString"); + assertEquals(credentialDetailsModel.clientSecret(), "testString"); + assertEquals(credentialDetailsModel.publicKeyId(), "testString"); + assertEquals(credentialDetailsModel.privateKey(), "testString"); + assertEquals(credentialDetailsModel.passphrase(), "testString"); + assertEquals(credentialDetailsModel.password(), "testString"); + assertEquals(credentialDetailsModel.gatewayId(), "testString"); + assertEquals(credentialDetailsModel.sourceVersion(), "online"); + assertEquals(credentialDetailsModel.webApplicationUrl(), "testString"); + assertEquals(credentialDetailsModel.domain(), "testString"); + assertEquals(credentialDetailsModel.endpoint(), "testString"); + assertEquals(credentialDetailsModel.accessKeyId(), "testString"); + assertEquals(credentialDetailsModel.secretAccessKey(), "testString"); + + UpdateCredentialsOptions updateCredentialsOptionsModel = + new UpdateCredentialsOptions.Builder() + .environmentId("testString") + .credentialId("testString") + .sourceType("box") + .credentialDetails(credentialDetailsModel) + .status("connected") + .build(); + assertEquals(updateCredentialsOptionsModel.environmentId(), "testString"); + assertEquals(updateCredentialsOptionsModel.credentialId(), "testString"); + assertEquals(updateCredentialsOptionsModel.sourceType(), "box"); + assertEquals(updateCredentialsOptionsModel.credentialDetails(), credentialDetailsModel); + assertEquals(updateCredentialsOptionsModel.status(), "connected"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateCredentialsOptionsError() throws Throwable { + new UpdateCredentialsOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/UpdateDocumentOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/UpdateDocumentOptionsTest.java new file mode 100644 index 00000000000..0f5bcbbc4e8 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/UpdateDocumentOptionsTest.java @@ -0,0 +1,59 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.apache.commons.io.IOUtils; +import org.testng.annotations.Test; + +/** Unit test class for the UpdateDocumentOptions model. */ +public class UpdateDocumentOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateDocumentOptions() throws Throwable { + UpdateDocumentOptions updateDocumentOptionsModel = + new UpdateDocumentOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .documentId("testString") + .file(TestUtilities.createMockStream("This is a mock file.")) + .filename("testString") + .fileContentType("application/json") + .metadata("testString") + .build(); + assertEquals(updateDocumentOptionsModel.environmentId(), "testString"); + assertEquals(updateDocumentOptionsModel.collectionId(), "testString"); + assertEquals(updateDocumentOptionsModel.documentId(), "testString"); + assertEquals( + IOUtils.toString(updateDocumentOptionsModel.file()), + IOUtils.toString(TestUtilities.createMockStream("This is a mock file."))); + assertEquals(updateDocumentOptionsModel.filename(), "testString"); + assertEquals(updateDocumentOptionsModel.fileContentType(), "application/json"); + assertEquals(updateDocumentOptionsModel.metadata(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateDocumentOptionsError() throws Throwable { + new UpdateDocumentOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/UpdateEnvironmentOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/UpdateEnvironmentOptionsTest.java new file mode 100644 index 00000000000..b13b98c389b --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/UpdateEnvironmentOptionsTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the UpdateEnvironmentOptions model. */ +public class UpdateEnvironmentOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateEnvironmentOptions() throws Throwable { + UpdateEnvironmentOptions updateEnvironmentOptionsModel = + new UpdateEnvironmentOptions.Builder() + .environmentId("testString") + .name("testString") + .description("testString") + .size("S") + .build(); + assertEquals(updateEnvironmentOptionsModel.environmentId(), "testString"); + assertEquals(updateEnvironmentOptionsModel.name(), "testString"); + assertEquals(updateEnvironmentOptionsModel.description(), "testString"); + assertEquals(updateEnvironmentOptionsModel.size(), "S"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateEnvironmentOptionsError() throws Throwable { + new UpdateEnvironmentOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/UpdateTrainingExampleOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/UpdateTrainingExampleOptionsTest.java new file mode 100644 index 00000000000..9b847e2bc8c --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/UpdateTrainingExampleOptionsTest.java @@ -0,0 +1,54 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the UpdateTrainingExampleOptions model. */ +public class UpdateTrainingExampleOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateTrainingExampleOptions() throws Throwable { + UpdateTrainingExampleOptions updateTrainingExampleOptionsModel = + new UpdateTrainingExampleOptions.Builder() + .environmentId("testString") + .collectionId("testString") + .queryId("testString") + .exampleId("testString") + .crossReference("testString") + .relevance(Long.valueOf("26")) + .build(); + assertEquals(updateTrainingExampleOptionsModel.environmentId(), "testString"); + assertEquals(updateTrainingExampleOptionsModel.collectionId(), "testString"); + assertEquals(updateTrainingExampleOptionsModel.queryId(), "testString"); + assertEquals(updateTrainingExampleOptionsModel.exampleId(), "testString"); + assertEquals(updateTrainingExampleOptionsModel.crossReference(), "testString"); + assertEquals(updateTrainingExampleOptionsModel.relevance(), Long.valueOf("26")); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateTrainingExampleOptionsError() throws Throwable { + new UpdateTrainingExampleOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/WordHeadingDetectionTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/WordHeadingDetectionTest.java new file mode 100644 index 00000000000..1bde9e61b7d --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/WordHeadingDetectionTest.java @@ -0,0 +1,77 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the WordHeadingDetection model. */ +public class WordHeadingDetectionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testWordHeadingDetection() throws Throwable { + FontSetting fontSettingModel = + new FontSetting.Builder() + .level(Long.valueOf("26")) + .minSize(Long.valueOf("26")) + .maxSize(Long.valueOf("26")) + .bold(true) + .italic(true) + .name("testString") + .build(); + assertEquals(fontSettingModel.level(), Long.valueOf("26")); + assertEquals(fontSettingModel.minSize(), Long.valueOf("26")); + assertEquals(fontSettingModel.maxSize(), Long.valueOf("26")); + assertEquals(fontSettingModel.bold(), Boolean.valueOf(true)); + assertEquals(fontSettingModel.italic(), Boolean.valueOf(true)); + assertEquals(fontSettingModel.name(), "testString"); + + WordStyle wordStyleModel = + new WordStyle.Builder() + .level(Long.valueOf("26")) + .names(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals(wordStyleModel.level(), Long.valueOf("26")); + assertEquals( + wordStyleModel.names(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + WordHeadingDetection wordHeadingDetectionModel = + new WordHeadingDetection.Builder() + .fonts(new java.util.ArrayList(java.util.Arrays.asList(fontSettingModel))) + .styles(new java.util.ArrayList(java.util.Arrays.asList(wordStyleModel))) + .build(); + assertEquals( + wordHeadingDetectionModel.fonts(), + new java.util.ArrayList(java.util.Arrays.asList(fontSettingModel))); + assertEquals( + wordHeadingDetectionModel.styles(), + new java.util.ArrayList(java.util.Arrays.asList(wordStyleModel))); + + String json = TestUtilities.serialize(wordHeadingDetectionModel); + + WordHeadingDetection wordHeadingDetectionModelNew = + TestUtilities.deserialize(json, WordHeadingDetection.class); + assertTrue(wordHeadingDetectionModelNew instanceof WordHeadingDetection); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/WordSettingsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/WordSettingsTest.java new file mode 100644 index 00000000000..ff69e39ef2a --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/WordSettingsTest.java @@ -0,0 +1,81 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the WordSettings model. */ +public class WordSettingsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testWordSettings() throws Throwable { + FontSetting fontSettingModel = + new FontSetting.Builder() + .level(Long.valueOf("26")) + .minSize(Long.valueOf("26")) + .maxSize(Long.valueOf("26")) + .bold(true) + .italic(true) + .name("testString") + .build(); + assertEquals(fontSettingModel.level(), Long.valueOf("26")); + assertEquals(fontSettingModel.minSize(), Long.valueOf("26")); + assertEquals(fontSettingModel.maxSize(), Long.valueOf("26")); + assertEquals(fontSettingModel.bold(), Boolean.valueOf(true)); + assertEquals(fontSettingModel.italic(), Boolean.valueOf(true)); + assertEquals(fontSettingModel.name(), "testString"); + + WordStyle wordStyleModel = + new WordStyle.Builder() + .level(Long.valueOf("26")) + .names(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals(wordStyleModel.level(), Long.valueOf("26")); + assertEquals( + wordStyleModel.names(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + WordHeadingDetection wordHeadingDetectionModel = + new WordHeadingDetection.Builder() + .fonts(new java.util.ArrayList(java.util.Arrays.asList(fontSettingModel))) + .styles(new java.util.ArrayList(java.util.Arrays.asList(wordStyleModel))) + .build(); + assertEquals( + wordHeadingDetectionModel.fonts(), + new java.util.ArrayList(java.util.Arrays.asList(fontSettingModel))); + assertEquals( + wordHeadingDetectionModel.styles(), + new java.util.ArrayList(java.util.Arrays.asList(wordStyleModel))); + + WordSettings wordSettingsModel = + new WordSettings.Builder().heading(wordHeadingDetectionModel).build(); + assertEquals(wordSettingsModel.heading(), wordHeadingDetectionModel); + + String json = TestUtilities.serialize(wordSettingsModel); + + WordSettings wordSettingsModelNew = TestUtilities.deserialize(json, WordSettings.class); + assertTrue(wordSettingsModelNew instanceof WordSettings); + assertEquals(wordSettingsModelNew.heading().toString(), wordHeadingDetectionModel.toString()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/WordStyleTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/WordStyleTest.java new file mode 100644 index 00000000000..80b867d49bd --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/WordStyleTest.java @@ -0,0 +1,49 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the WordStyle model. */ +public class WordStyleTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testWordStyle() throws Throwable { + WordStyle wordStyleModel = + new WordStyle.Builder() + .level(Long.valueOf("26")) + .names(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals(wordStyleModel.level(), Long.valueOf("26")); + assertEquals( + wordStyleModel.names(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + String json = TestUtilities.serialize(wordStyleModel); + + WordStyle wordStyleModelNew = TestUtilities.deserialize(json, WordStyle.class); + assertTrue(wordStyleModelNew instanceof WordStyle); + assertEquals(wordStyleModelNew.level(), Long.valueOf("26")); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/model/XPathPatternsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/XPathPatternsTest.java new file mode 100644 index 00000000000..abf95bc02aa --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/model/XPathPatternsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the XPathPatterns model. */ +public class XPathPatternsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testXPathPatterns() throws Throwable { + XPathPatterns xPathPatternsModel = + new XPathPatterns.Builder() + .xpaths(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals( + xPathPatternsModel.xpaths(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + String json = TestUtilities.serialize(xPathPatternsModel); + + XPathPatterns xPathPatternsModelNew = TestUtilities.deserialize(json, XPathPatterns.class); + assertTrue(xPathPatternsModelNew instanceof XPathPatterns); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v1/utils/TestUtilities.java b/discovery/src/test/java/com/ibm/watson/discovery/v1/utils/TestUtilities.java new file mode 100644 index 00000000000..825710d38e6 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v1/utils/TestUtilities.java @@ -0,0 +1,128 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v1.utils; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.cloud.sdk.core.util.GsonSingleton; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import okhttp3.HttpUrl; +import okhttp3.mockwebserver.RecordedRequest; + +/** A class used by the unit tests containing utility functions. */ +public class TestUtilities { + public static Map createMockMap() { + Map mockMap = new HashMap<>(); + mockMap.put("foo", "bar"); + return mockMap; + } + + public static HashMap createMockStreamMap() { + return new HashMap() { + { + put("key1", createMockStream("This is a mock file.")); + } + }; + } + + public static Map parseQueryString(RecordedRequest req) { + Map queryMap = new HashMap<>(); + + try { + HttpUrl requestUrl = req.getRequestUrl(); + + if (requestUrl != null) { + Set queryParamsNames = requestUrl.queryParameterNames(); + // map the parameter name to its corresponding value + for (String p : queryParamsNames) { + // get the corresponding value for the parameter (p) + List val = requestUrl.queryParameterValues(p); + if (val != null && !val.isEmpty()) { + String joinedQuery = String.join(",", val); + queryMap.put(p, joinedQuery); + } + } + } + if (queryMap.isEmpty()) { + return null; + } + } catch (Exception e) { + return null; + } + + return queryMap; + } + + public static String parseReqPath(RecordedRequest req) { + String parsedPath = null; + + try { + String fullPath = req.getPath(); + if (fullPath != null && !fullPath.isEmpty()) { + // retrieve the path segment before the query parameter + parsedPath = fullPath.split("\\?", 2)[0]; + } + if (parsedPath.isEmpty() || parsedPath == null) { + return null; + } + + } catch (Exception e) { + return null; + } + + return parsedPath; + } + + public static String serialize(Object obj) { + return GsonSingleton.getGson().toJson(obj); + } + + public static T deserialize(String json, Class clazz) { + return GsonSingleton.getGson().fromJson(json, clazz); + } + + public static InputStream createMockStream(String s) { + return new ByteArrayInputStream(s.getBytes()); + } + + public static List creatMockListFileWithMetadata() { + List list = new ArrayList(); + byte[] fileBytes = {(byte) 0xde, (byte) 0xad, (byte) 0xbe, (byte) 0xef}; + InputStream inputStream = new ByteArrayInputStream(fileBytes); + FileWithMetadata.Builder builder = new FileWithMetadata.Builder(); + builder.data(inputStream); + FileWithMetadata fileWithMetadata = builder.build(); + list.add(fileWithMetadata); + + return list; + } + + public static byte[] createMockByteArray(String bytes) { + return bytes.getBytes(); + } + + public static Date createMockDate(String date) throws Exception { + return new SimpleDateFormat("yyyy-MM-dd").parse(date); + } + + public static Date createMockDateTime(String date) throws Exception { + return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").parse(date); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/DiscoveryTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/DiscoveryTest.java index 33c9dbb32ba..f4be850c474 100644 --- a/discovery/src/test/java/com/ibm/watson/discovery/v2/DiscoveryTest.java +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/DiscoveryTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -12,28 +12,55 @@ */ package com.ibm.watson.discovery.v2; -import static junit.framework.TestCase.assertEquals; -import static junit.framework.TestCase.assertTrue; +import static org.testng.Assert.*; +import com.ibm.cloud.sdk.core.http.Response; import com.ibm.cloud.sdk.core.security.Authenticator; import com.ibm.cloud.sdk.core.security.NoAuthAuthenticator; -import com.ibm.watson.common.WatsonServiceUnitTest; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.cloud.sdk.core.util.RequestUtils; import com.ibm.watson.discovery.v2.model.AddDocumentOptions; +import com.ibm.watson.discovery.v2.model.AnalyzeDocumentOptions; +import com.ibm.watson.discovery.v2.model.AnalyzedDocument; +import com.ibm.watson.discovery.v2.model.CollectionDetails; +import com.ibm.watson.discovery.v2.model.CollectionEnrichment; import com.ibm.watson.discovery.v2.model.Completions; import com.ibm.watson.discovery.v2.model.ComponentSettingsResponse; +import com.ibm.watson.discovery.v2.model.CreateCollectionOptions; +import com.ibm.watson.discovery.v2.model.CreateEnrichment; +import com.ibm.watson.discovery.v2.model.CreateEnrichmentOptions; +import com.ibm.watson.discovery.v2.model.CreateProjectOptions; import com.ibm.watson.discovery.v2.model.CreateTrainingQueryOptions; +import com.ibm.watson.discovery.v2.model.DefaultQueryParams; +import com.ibm.watson.discovery.v2.model.DefaultQueryParamsPassages; +import com.ibm.watson.discovery.v2.model.DefaultQueryParamsSuggestedRefinements; +import com.ibm.watson.discovery.v2.model.DefaultQueryParamsTableResults; +import com.ibm.watson.discovery.v2.model.DeleteCollectionOptions; import com.ibm.watson.discovery.v2.model.DeleteDocumentOptions; import com.ibm.watson.discovery.v2.model.DeleteDocumentResponse; +import com.ibm.watson.discovery.v2.model.DeleteEnrichmentOptions; +import com.ibm.watson.discovery.v2.model.DeleteProjectOptions; import com.ibm.watson.discovery.v2.model.DeleteTrainingQueriesOptions; +import com.ibm.watson.discovery.v2.model.DeleteUserDataOptions; import com.ibm.watson.discovery.v2.model.DocumentAccepted; +import com.ibm.watson.discovery.v2.model.Enrichment; +import com.ibm.watson.discovery.v2.model.EnrichmentOptions; +import com.ibm.watson.discovery.v2.model.Enrichments; import com.ibm.watson.discovery.v2.model.GetAutocompletionOptions; +import com.ibm.watson.discovery.v2.model.GetCollectionOptions; import com.ibm.watson.discovery.v2.model.GetComponentSettingsOptions; +import com.ibm.watson.discovery.v2.model.GetEnrichmentOptions; +import com.ibm.watson.discovery.v2.model.GetProjectOptions; import com.ibm.watson.discovery.v2.model.GetTrainingQueryOptions; import com.ibm.watson.discovery.v2.model.ListCollectionsOptions; import com.ibm.watson.discovery.v2.model.ListCollectionsResponse; +import com.ibm.watson.discovery.v2.model.ListEnrichmentsOptions; import com.ibm.watson.discovery.v2.model.ListFieldsOptions; import com.ibm.watson.discovery.v2.model.ListFieldsResponse; +import com.ibm.watson.discovery.v2.model.ListProjectsOptions; +import com.ibm.watson.discovery.v2.model.ListProjectsResponse; import com.ibm.watson.discovery.v2.model.ListTrainingQueriesOptions; +import com.ibm.watson.discovery.v2.model.ProjectDetails; import com.ibm.watson.discovery.v2.model.QueryLargePassages; import com.ibm.watson.discovery.v2.model.QueryLargeSuggestedRefinements; import com.ibm.watson.discovery.v2.model.QueryLargeTableResults; @@ -44,1121 +71,1871 @@ import com.ibm.watson.discovery.v2.model.TrainingExample; import com.ibm.watson.discovery.v2.model.TrainingQuery; import com.ibm.watson.discovery.v2.model.TrainingQuerySet; +import com.ibm.watson.discovery.v2.model.UpdateCollectionOptions; import com.ibm.watson.discovery.v2.model.UpdateDocumentOptions; +import com.ibm.watson.discovery.v2.model.UpdateEnrichmentOptions; +import com.ibm.watson.discovery.v2.model.UpdateProjectOptions; import com.ibm.watson.discovery.v2.model.UpdateTrainingQueryOptions; -import java.io.FileInputStream; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.IOException; import java.io.InputStream; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; +import java.util.HashMap; import java.util.List; -import java.util.Locale; +import java.util.Map; import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; import okhttp3.mockwebserver.RecordedRequest; -import org.junit.Before; -import org.junit.Test; - -/** The Class DiscoveryTest. */ -public class DiscoveryTest extends WatsonServiceUnitTest { - private static final String VERSION = "2019-11-22"; - private static final String RESOURCE = "src/test/resources/discovery/v2/"; - - private static final String PROJECT_ID = "project_id"; - private static final String COLLECTION_ID = "collection_id"; - private static final String FILENAME = "filename"; - private static final String FILE_CONTENT_TYPE = "application/pdf"; - private static final String METADATA = "metadata"; - private static final String NATURAL_LANGUAGE_QUERY = "natural_language_query"; - private static final String FILTER = "filter"; - private static final String DOCUMENT_ID = "document_id"; - private static final Long RELEVANCE = 1L; - private static final String FIELD = "field"; - private static final String PREFIX = "prefix"; - private static final Long COUNT = 2L; - private static final String QUERY_ID = "query_id"; - private static final Long MAX_PER_DOCUMENT = 3L; - private static final Long CHARACTERS = 4L; - private static final String QUERY = "query"; - private static final String AGGREGATION = "aggregation"; - private static final String RETURN = "return"; - private static final Long OFFSET = 5L; - private static final String SORT = "sort"; - private static final String NAME = "name"; - private static final Long MATCHING_RESULTS = 6L; - private static final String SUGGESTED_QUERY = "suggested_query"; - private static final String DOCUMENT_RETRIEVAL_SOURCE = "document_retrieval_source"; - private static final Double CONFIDENCE = 0.0; - private static final String PASSAGE_TEXT = "passage_text"; - private static final Long START_OFFSET = 7L; - private static final Long END_OFFSET = 8L; - private static final String TYPE = "type"; - private static final String DOCUMENT_RETRIEVAL_STRATEGY = "document_retrieval_strategy"; - private static final String TEXT = "text"; - private static final String TABLE_ID = "table_id"; - private static final String SOURCE_DOCUMENT_ID = "source_document_id"; - private static final String TABLE_HTML = "table_html"; - private static final Long TABLE_HTML_OFFSET = 9L; - private static final Long BEGIN = 10L; - private static final Long END = 11L; - private static final String CELL_ID = "cell_id"; - private static final Long ROW_INDEX_BEGIN = 12L; - private static final Long ROW_INDEX_END = 13L; - private static final Long COLUMN_INDEX_BEGIN = 14L; - private static final Long COLUMN_INDEX_END = 15L; - private static final String TEXT_NORMALIZED = "text_normalized"; - private static final String ID = "id"; - private static final String COMPLETION = "completion"; - private static final String NOTICE_ID = "notice_id"; - private static final String SEVERITY = "severity"; - private static final String STEP = "step"; - private static final String DESCRIPTION = "description"; - private static final Long RESULTS_PER_PAGE = 17L; - private static final String LABEL = "label"; - private static final String VISUALIZATION_TYPE = "visualization_type"; - private static final String STATUS = "status"; - - private InputStream testDocument; - private Date testDate; - private TrainingExample trainingExampleMock; - private QueryLargeTableResults queryLargeTableResults; - private QueryLargeSuggestedRefinements queryLargeSuggestedRefinements; - private QueryLargePassages queryLargePassages; - - private ListCollectionsResponse listCollectionsResponse; - private QueryResponse queryResponse; - private Completions completions; - private QueryNoticesResponse queryNoticesResponse; - private ListFieldsResponse listFieldsResponse; - private ComponentSettingsResponse componentSettingsResponse; - private DocumentAccepted documentAccepted; - private DeleteDocumentResponse deleteDocumentResponse; - private TrainingQuerySet trainingQuerySet; - private TrainingQuery trainingQuery; - - private Discovery service; - - /** - * Sets up the tests. - * - * @throws Exception the exception - */ - /* - * (non-Javadoc) - * @see com.ibm.watson.common.WatsonServiceUnitTest#setUp() - */ - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - - service = new Discovery(VERSION, new NoAuthAuthenticator()); - service.setServiceUrl(getMockWebServerUrl()); - - // Create test models. - testDocument = new FileInputStream(RESOURCE + "test-pdf.pdf"); - String dateString = "1995-06-12T01:11:11.111+0000"; - DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ", Locale.ENGLISH); - testDate = dateFormat.parse(dateString); - trainingExampleMock = - new TrainingExample.Builder() - .documentId(DOCUMENT_ID) - .collectionId(COLLECTION_ID) - .relevance(RELEVANCE) - .build(); - queryLargeTableResults = new QueryLargeTableResults.Builder().build(); - queryLargeSuggestedRefinements = new QueryLargeSuggestedRefinements.Builder().build(); - queryLargePassages = new QueryLargePassages.Builder().build(); - - // load mock responses - listCollectionsResponse = - loadFixture(RESOURCE + "list-collections-response.json", ListCollectionsResponse.class); - queryResponse = loadFixture(RESOURCE + "query-response.json", QueryResponse.class); - completions = loadFixture(RESOURCE + "completions.json", Completions.class); - queryNoticesResponse = - loadFixture(RESOURCE + "query-notices-response.json", QueryNoticesResponse.class); - listFieldsResponse = - loadFixture(RESOURCE + "list-fields-response.json", ListFieldsResponse.class); - componentSettingsResponse = - loadFixture(RESOURCE + "component-settings-response.json", ComponentSettingsResponse.class); - documentAccepted = loadFixture(RESOURCE + "document-accepted.json", DocumentAccepted.class); - deleteDocumentResponse = - loadFixture(RESOURCE + "delete-document-response.json", DeleteDocumentResponse.class); - trainingQuerySet = loadFixture(RESOURCE + "training-query-set.json", TrainingQuerySet.class); - trainingQuery = loadFixture(RESOURCE + "training-query.json", TrainingQuery.class); - } - - /** Test config based constructor. */ +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +/** Unit test class for the Discovery service. */ +public class DiscoveryTest { + + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + protected MockWebServer server; + protected Discovery discoveryService; + + public void constructClientService() throws Throwable { + final String serviceName = "testService"; + // set mock values for global params + String version = "testString"; + + final Authenticator authenticator = new NoAuthAuthenticator(); + + discoveryService = new Discovery(version, serviceName, authenticator); + String url = server.url("/").toString(); + discoveryService.setServiceUrl(url); + } + + /** Negative Test - construct the service with a null authenticator. */ + @Test(expectedExceptions = IllegalArgumentException.class) + public void testConstructorWithNullAuthenticator() throws Throwable { + final String serviceName = "testService"; + // set mock values for global params + String version = "testString"; + + new Discovery(version, serviceName, null); + } + @Test - public void testConfigBasedConstructor() { - Discovery service = new Discovery(VERSION); - assertEquals(Authenticator.AUTHTYPE_BASIC, service.getAuthenticator().authenticationType()); + public void testGetVersion() throws Throwable { + constructClientService(); + assertEquals(discoveryService.getVersion(), "testString"); } - /** Test add document options. */ @Test - public void testAddDocumentOptions() { - AddDocumentOptions options = - new AddDocumentOptions.Builder() - .projectId(PROJECT_ID) - .collectionId(COLLECTION_ID) - .file(testDocument) - .filename(FILENAME) - .fileContentType(FILE_CONTENT_TYPE) - .metadata(METADATA) - .xWatsonDiscoveryForce(true) - .build(); - options = options.newBuilder().build(); + public void testListCollectionsWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"collections\": [{\"collection_id\": \"collectionId\", \"name\": \"name\"}]}"; + String listCollectionsPath = "/v2/projects/testString/collections"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the ListCollectionsOptions model + ListCollectionsOptions listCollectionsOptionsModel = + new ListCollectionsOptions.Builder().projectId("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.listCollections(listCollectionsOptionsModel).execute(); + assertNotNull(response); + ListCollectionsResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listCollectionsPath); + } - assertEquals(PROJECT_ID, options.projectId()); - assertEquals(COLLECTION_ID, options.collectionId()); - assertEquals(testDocument, options.file()); - assertEquals(FILENAME, options.filename()); - assertEquals(FILE_CONTENT_TYPE, options.fileContentType()); - assertEquals(METADATA, options.metadata()); - assertTrue(options.xWatsonDiscoveryForce()); + // Test the listCollections operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListCollectionsNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.listCollections(null).execute(); } - /** Test create training query options. */ @Test - public void testCreateTrainingQueryOptions() { - List exampleList = new ArrayList<>(); - exampleList.add(trainingExampleMock); + public void testCreateCollectionWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"collection_id\": \"collectionId\", \"name\": \"name\", \"description\": \"description\", \"created\": \"2019-01-01T12:00:00\", \"language\": \"language\", \"enrichments\": [{\"enrichment_id\": \"enrichmentId\", \"fields\": [\"fields\"]}]}"; + String createCollectionPath = "/v2/projects/testString/collections"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the CollectionEnrichment model + CollectionEnrichment collectionEnrichmentModel = + new CollectionEnrichment.Builder() + .enrichmentId("testString") + .fields(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); - CreateTrainingQueryOptions options = - new CreateTrainingQueryOptions.Builder() - .projectId(PROJECT_ID) - .naturalLanguageQuery(NATURAL_LANGUAGE_QUERY) - .filter(FILTER) - .examples(exampleList) - .addExamples(trainingExampleMock) + // Construct an instance of the CreateCollectionOptions model + CreateCollectionOptions createCollectionOptionsModel = + new CreateCollectionOptions.Builder() + .projectId("testString") + .name("testString") + .description("testString") + .language("testString") + .enrichments( + new java.util.ArrayList( + java.util.Arrays.asList(collectionEnrichmentModel))) .build(); - options = options.newBuilder().build(); - assertEquals(PROJECT_ID, options.projectId()); - assertEquals(NATURAL_LANGUAGE_QUERY, options.naturalLanguageQuery()); - assertEquals(FILTER, options.filter()); - assertEquals(2, options.examples().size()); - assertEquals(trainingExampleMock, options.examples().get(0)); + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.createCollection(createCollectionOptionsModel).execute(); + assertNotNull(response); + CollectionDetails responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createCollectionPath); + } + + // Test the createCollection operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateCollectionNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.createCollection(null).execute(); } - /** Test delete document options. */ @Test - public void testDeleteDocumentOptions() { - DeleteDocumentOptions options = - new DeleteDocumentOptions.Builder() - .projectId(PROJECT_ID) - .collectionId(COLLECTION_ID) - .documentId(DOCUMENT_ID) - .xWatsonDiscoveryForce(true) + public void testGetCollectionWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"collection_id\": \"collectionId\", \"name\": \"name\", \"description\": \"description\", \"created\": \"2019-01-01T12:00:00\", \"language\": \"language\", \"enrichments\": [{\"enrichment_id\": \"enrichmentId\", \"fields\": [\"fields\"]}]}"; + String getCollectionPath = "/v2/projects/testString/collections/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the GetCollectionOptions model + GetCollectionOptions getCollectionOptionsModel = + new GetCollectionOptions.Builder() + .projectId("testString") + .collectionId("testString") .build(); - options = options.newBuilder().build(); - assertEquals(PROJECT_ID, options.projectId()); - assertEquals(COLLECTION_ID, options.collectionId()); - assertEquals(DOCUMENT_ID, options.documentId()); - assertTrue(options.xWatsonDiscoveryForce()); + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.getCollection(getCollectionOptionsModel).execute(); + assertNotNull(response); + CollectionDetails responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getCollectionPath); } - /** Test delete training query options. */ - @Test - public void testDeleteTrainingQueryOptions() { - DeleteTrainingQueriesOptions options = - new DeleteTrainingQueriesOptions.Builder().projectId(PROJECT_ID).build(); - options = options.newBuilder().build(); + // Test the getCollection operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetCollectionNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); - assertEquals(PROJECT_ID, options.projectId()); + // Invoke operation with null options model (negative test) + discoveryService.getCollection(null).execute(); } - /** Test get autocompletion options. */ @Test - public void testGetAutocompletionOptions() { - List collectionIds = new ArrayList<>(); - collectionIds.add(COLLECTION_ID); + public void testUpdateCollectionWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"collection_id\": \"collectionId\", \"name\": \"name\", \"description\": \"description\", \"created\": \"2019-01-01T12:00:00\", \"language\": \"language\", \"enrichments\": [{\"enrichment_id\": \"enrichmentId\", \"fields\": [\"fields\"]}]}"; + String updateCollectionPath = "/v2/projects/testString/collections/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the CollectionEnrichment model + CollectionEnrichment collectionEnrichmentModel = + new CollectionEnrichment.Builder() + .enrichmentId("testString") + .fields(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); - GetAutocompletionOptions options = - new GetAutocompletionOptions.Builder() - .projectId(PROJECT_ID) - .collectionIds(collectionIds) - .addCollectionIds(COLLECTION_ID) - .field(FIELD) - .prefix(PREFIX) - .count(COUNT) + // Construct an instance of the UpdateCollectionOptions model + UpdateCollectionOptions updateCollectionOptionsModel = + new UpdateCollectionOptions.Builder() + .projectId("testString") + .collectionId("testString") + .name("testString") + .description("testString") + .enrichments( + new java.util.ArrayList( + java.util.Arrays.asList(collectionEnrichmentModel))) .build(); - options = options.newBuilder().build(); - assertEquals(PROJECT_ID, options.projectId()); - assertEquals(2, options.collectionIds().size()); - assertEquals(COLLECTION_ID, options.collectionIds().get(0)); - assertEquals(FIELD, options.field()); - assertEquals(PREFIX, options.prefix()); - assertEquals(COUNT, options.count()); + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.updateCollection(updateCollectionOptionsModel).execute(); + assertNotNull(response); + CollectionDetails responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateCollectionPath); } - /** Test get component settings options. */ - @Test - public void testGetComponentSettingsOptions() { - GetComponentSettingsOptions options = - new GetComponentSettingsOptions.Builder().projectId(PROJECT_ID).build(); - options = options.newBuilder().build(); + // Test the updateCollection operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateCollectionNoOptions() throws Throwable { + // construct the service + constructClientService(); - assertEquals(PROJECT_ID, options.projectId()); + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.updateCollection(null).execute(); } - /** Test get training query options. */ @Test - public void testGetTrainingQueryOptions() { - GetTrainingQueryOptions options = - new GetTrainingQueryOptions.Builder().projectId(PROJECT_ID).queryId(QUERY_ID).build(); - options = options.newBuilder().build(); + public void testDeleteCollectionWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String deleteCollectionPath = "/v2/projects/testString/collections/testString"; + + server.enqueue(new MockResponse().setResponseCode(204).setBody(mockResponseBody)); - assertEquals(PROJECT_ID, options.projectId()); - assertEquals(QUERY_ID, options.queryId()); + constructClientService(); + + // Construct an instance of the DeleteCollectionOptions model + DeleteCollectionOptions deleteCollectionOptionsModel = + new DeleteCollectionOptions.Builder() + .projectId("testString") + .collectionId("testString") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.deleteCollection(deleteCollectionOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteCollectionPath); } - /** Test list collections options. */ - @Test - public void testListCollectionsOptions() { - ListCollectionsOptions options = - new ListCollectionsOptions.Builder().projectId(PROJECT_ID).build(); - options = options.newBuilder().build(); + // Test the deleteCollection operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteCollectionNoOptions() throws Throwable { + // construct the service + constructClientService(); - assertEquals(PROJECT_ID, options.projectId()); + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.deleteCollection(null).execute(); } - /** Test list fields options. */ @Test - public void testListFieldsOptions() { - List collectionIds = new ArrayList<>(); - collectionIds.add(COLLECTION_ID); + public void testQueryWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"matching_results\": 15, \"results\": [{\"document_id\": \"documentId\", \"metadata\": {\"mapKey\": \"anyValue\"}, \"result_metadata\": {\"document_retrieval_source\": \"search\", \"collection_id\": \"collectionId\", \"confidence\": 10}, \"document_passages\": [{\"passage_text\": \"passageText\", \"start_offset\": 11, \"end_offset\": 9, \"field\": \"field\"}]}], \"aggregations\": [{\"type\": \"filter\", \"match\": \"match\", \"matching_results\": 15}], \"retrieval_details\": {\"document_retrieval_strategy\": \"untrained\"}, \"suggested_query\": \"suggestedQuery\", \"suggested_refinements\": [{\"text\": \"text\"}], \"table_results\": [{\"table_id\": \"tableId\", \"source_document_id\": \"sourceDocumentId\", \"collection_id\": \"collectionId\", \"table_html\": \"tableHtml\", \"table_html_offset\": 15, \"table\": {\"location\": {\"begin\": 5, \"end\": 3}, \"text\": \"text\", \"section_title\": {\"text\": \"text\", \"location\": {\"begin\": 5, \"end\": 3}}, \"title\": {\"text\": \"text\", \"location\": {\"begin\": 5, \"end\": 3}}, \"table_headers\": [{\"cell_id\": \"cellId\", \"location\": {\"mapKey\": \"anyValue\"}, \"text\": \"text\", \"row_index_begin\": 13, \"row_index_end\": 11, \"column_index_begin\": 16, \"column_index_end\": 14}], \"row_headers\": [{\"cell_id\": \"cellId\", \"location\": {\"begin\": 5, \"end\": 3}, \"text\": \"text\", \"text_normalized\": \"textNormalized\", \"row_index_begin\": 13, \"row_index_end\": 11, \"column_index_begin\": 16, \"column_index_end\": 14}], \"column_headers\": [{\"cell_id\": \"cellId\", \"location\": {\"mapKey\": \"anyValue\"}, \"text\": \"text\", \"text_normalized\": \"textNormalized\", \"row_index_begin\": 13, \"row_index_end\": 11, \"column_index_begin\": 16, \"column_index_end\": 14}], \"key_value_pairs\": [{\"key\": {\"cell_id\": \"cellId\", \"location\": {\"begin\": 5, \"end\": 3}, \"text\": \"text\"}, \"value\": [{\"cell_id\": \"cellId\", \"location\": {\"begin\": 5, \"end\": 3}, \"text\": \"text\"}]}], \"body_cells\": [{\"cell_id\": \"cellId\", \"location\": {\"begin\": 5, \"end\": 3}, \"text\": \"text\", \"row_index_begin\": 13, \"row_index_end\": 11, \"column_index_begin\": 16, \"column_index_end\": 14, \"row_header_ids\": [{\"id\": \"id\"}], \"row_header_texts\": [{\"text\": \"text\"}], \"row_header_texts_normalized\": [{\"text_normalized\": \"textNormalized\"}], \"column_header_ids\": [{\"id\": \"id\"}], \"column_header_texts\": [{\"text\": \"text\"}], \"column_header_texts_normalized\": [{\"text_normalized\": \"textNormalized\"}], \"attributes\": [{\"type\": \"type\", \"text\": \"text\", \"location\": {\"begin\": 5, \"end\": 3}}]}], \"contexts\": [{\"text\": \"text\", \"location\": {\"begin\": 5, \"end\": 3}}]}}], \"passages\": [{\"passage_text\": \"passageText\", \"passage_score\": 12, \"document_id\": \"documentId\", \"collection_id\": \"collectionId\", \"start_offset\": 11, \"end_offset\": 9, \"field\": \"field\"}]}"; + String queryPath = "/v2/projects/testString/query"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the QueryLargeTableResults model + QueryLargeTableResults queryLargeTableResultsModel = + new QueryLargeTableResults.Builder().enabled(true).count(Long.valueOf("26")).build(); + + // Construct an instance of the QueryLargeSuggestedRefinements model + QueryLargeSuggestedRefinements queryLargeSuggestedRefinementsModel = + new QueryLargeSuggestedRefinements.Builder().enabled(true).count(Long.valueOf("1")).build(); + + // Construct an instance of the QueryLargePassages model + QueryLargePassages queryLargePassagesModel = + new QueryLargePassages.Builder() + .enabled(true) + .perDocument(true) + .maxPerDocument(Long.valueOf("26")) + .fields(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .count(Long.valueOf("100")) + .characters(Long.valueOf("50")) + .build(); - ListFieldsOptions options = - new ListFieldsOptions.Builder() - .projectId(PROJECT_ID) - .collectionIds(collectionIds) - .addCollectionIds(COLLECTION_ID) + // Construct an instance of the QueryOptions model + QueryOptions queryOptionsModel = + new QueryOptions.Builder() + .projectId("testString") + .collectionIds(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .filter("testString") + .query("testString") + .naturalLanguageQuery("testString") + .aggregation("testString") + .count(Long.valueOf("26")) + .xReturn(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .offset(Long.valueOf("26")) + .sort("testString") + .highlight(true) + .spellingSuggestions(true) + .tableResults(queryLargeTableResultsModel) + .suggestedRefinements(queryLargeSuggestedRefinementsModel) + .passages(queryLargePassagesModel) .build(); - options = options.newBuilder().build(); - assertEquals(PROJECT_ID, options.projectId()); - assertEquals(2, options.collectionIds().size()); - assertEquals(COLLECTION_ID, options.collectionIds().get(0)); + // Invoke operation with valid options model (positive test) + Response response = discoveryService.query(queryOptionsModel).execute(); + assertNotNull(response); + QueryResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, queryPath); } - /** Test list training queries options. */ - @Test - public void testListTrainingQueriesOptions() { - ListTrainingQueriesOptions options = - new ListTrainingQueriesOptions.Builder().projectId(PROJECT_ID).build(); - options = options.newBuilder().build(); + // Test the query operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testQueryNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); - assertEquals(PROJECT_ID, options.projectId()); + // Invoke operation with null options model (negative test) + discoveryService.query(null).execute(); } - /** Test query large passages. */ @Test - public void testQueryLargePassages() { - List fields = new ArrayList<>(); - fields.add(FIELD); + public void testGetAutocompletionWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = "{\"completions\": [\"completions\"]}"; + String getAutocompletionPath = "/v2/projects/testString/autocompletion"; - QueryLargePassages queryLargePassages = - new QueryLargePassages.Builder() - .enabled(true) - .perDocument(true) - .maxPerDocument(MAX_PER_DOCUMENT) - .fields(fields) - .addFields(FIELD) - .count(COUNT) - .characters(CHARACTERS) + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the GetAutocompletionOptions model + GetAutocompletionOptions getAutocompletionOptionsModel = + new GetAutocompletionOptions.Builder() + .projectId("testString") + .prefix("testString") + .collectionIds(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .field("testString") + .count(Long.valueOf("26")) .build(); - queryLargePassages = queryLargePassages.newBuilder().build(); - assertTrue(queryLargePassages.enabled()); - assertTrue(queryLargePassages.perDocument()); - assertEquals(MAX_PER_DOCUMENT, queryLargePassages.maxPerDocument()); - assertEquals(2, queryLargePassages.fields().size()); - assertEquals(FIELD, queryLargePassages.fields().get(0)); - assertEquals(COUNT, queryLargePassages.count()); - assertEquals(CHARACTERS, queryLargePassages.characters()); + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.getAutocompletion(getAutocompletionOptionsModel).execute(); + assertNotNull(response); + Completions responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(query.get("prefix"), "testString"); + assertEquals( + query.get("collection_ids"), + RequestUtils.join( + new java.util.ArrayList(java.util.Arrays.asList("testString")), ",")); + assertEquals(query.get("field"), "testString"); + assertEquals(Long.valueOf(query.get("count")), Long.valueOf("26")); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getAutocompletionPath); } - /** Test query large suggested refinements. */ - @Test - public void testQueryLargeSuggestedRefinements() { - QueryLargeSuggestedRefinements queryLargeSuggestedRefinements = - new QueryLargeSuggestedRefinements.Builder().enabled(true).count(COUNT).build(); - queryLargeSuggestedRefinements = queryLargeSuggestedRefinements.newBuilder().build(); + // Test the getAutocompletion operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetAutocompletionNoOptions() throws Throwable { + // construct the service + constructClientService(); - assertTrue(queryLargeSuggestedRefinements.enabled()); - assertEquals(COUNT, queryLargeSuggestedRefinements.count()); + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.getAutocompletion(null).execute(); } - /** Test query large table results. */ @Test - public void testQueryLargeTableResults() { - QueryLargeTableResults queryLargeTableResults = - new QueryLargeTableResults.Builder().enabled(true).count(COUNT).build(); - queryLargeTableResults = queryLargeTableResults.newBuilder().build(); + public void testQueryNoticesWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"matching_results\": 15, \"notices\": [{\"notice_id\": \"noticeId\", \"created\": \"2019-01-01T12:00:00\", \"document_id\": \"documentId\", \"collection_id\": \"collectionId\", \"query_id\": \"queryId\", \"severity\": \"warning\", \"step\": \"step\", \"description\": \"description\"}]}"; + String queryNoticesPath = "/v2/projects/testString/notices"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the QueryNoticesOptions model + QueryNoticesOptions queryNoticesOptionsModel = + new QueryNoticesOptions.Builder() + .projectId("testString") + .filter("testString") + .query("testString") + .naturalLanguageQuery("testString") + .count(Long.valueOf("26")) + .offset(Long.valueOf("26")) + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.queryNotices(queryNoticesOptionsModel).execute(); + assertNotNull(response); + QueryNoticesResponse responseObj = response.getResult(); + assertNotNull(responseObj); - assertTrue(queryLargeTableResults.enabled()); - assertEquals(COUNT, queryLargeTableResults.count()); + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(query.get("filter"), "testString"); + assertEquals(query.get("query"), "testString"); + assertEquals(query.get("natural_language_query"), "testString"); + assertEquals(Long.valueOf(query.get("count")), Long.valueOf("26")); + assertEquals(Long.valueOf(query.get("offset")), Long.valueOf("26")); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, queryNoticesPath); + } + + // Test the queryNotices operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testQueryNoticesNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.queryNotices(null).execute(); } - /** Test query notices options. */ @Test - public void testQueryNoticesOptions() { - QueryNoticesOptions options = - new QueryNoticesOptions.Builder() - .projectId(PROJECT_ID) - .filter(FILTER) - .query(QUERY) - .naturalLanguageQuery(NATURAL_LANGUAGE_QUERY) - .count(COUNT) - .offset(OFFSET) + public void testListFieldsWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"fields\": [{\"field\": \"field\", \"type\": \"nested\", \"collection_id\": \"collectionId\"}]}"; + String listFieldsPath = "/v2/projects/testString/fields"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the ListFieldsOptions model + ListFieldsOptions listFieldsOptionsModel = + new ListFieldsOptions.Builder() + .projectId("testString") + .collectionIds(new java.util.ArrayList(java.util.Arrays.asList("testString"))) .build(); - options = options.newBuilder().build(); - assertEquals(PROJECT_ID, options.projectId()); - assertEquals(FILTER, options.filter()); - assertEquals(QUERY, options.query()); - assertEquals(NATURAL_LANGUAGE_QUERY, options.naturalLanguageQuery()); - assertEquals(COUNT, options.count()); - assertEquals(OFFSET, options.offset()); + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.listFields(listFieldsOptionsModel).execute(); + assertNotNull(response); + ListFieldsResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals( + query.get("collection_ids"), + RequestUtils.join( + new java.util.ArrayList(java.util.Arrays.asList("testString")), ",")); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listFieldsPath); + } + + // Test the listFields operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListFieldsNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.listFields(null).execute(); } - /** Test query options. */ @Test - public void testQueryOptions() { - List collectionIds = new ArrayList<>(); - collectionIds.add(COLLECTION_ID); - List returnList = new ArrayList<>(); - returnList.add(RETURN); + public void testGetComponentSettingsWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"fields_shown\": {\"body\": {\"use_passage\": true, \"field\": \"field\"}, \"title\": {\"field\": \"field\"}}, \"autocomplete\": true, \"structured_search\": true, \"results_per_page\": 14, \"aggregations\": [{\"name\": \"name\", \"label\": \"label\", \"multiple_selections_allowed\": false, \"visualization_type\": \"auto\"}]}"; + String getComponentSettingsPath = "/v2/projects/testString/component_settings"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the GetComponentSettingsOptions model + GetComponentSettingsOptions getComponentSettingsOptionsModel = + new GetComponentSettingsOptions.Builder().projectId("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.getComponentSettings(getComponentSettingsOptionsModel).execute(); + assertNotNull(response); + ComponentSettingsResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getComponentSettingsPath); + } + + // Test the getComponentSettings operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetComponentSettingsNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.getComponentSettings(null).execute(); + } - QueryOptions options = - new QueryOptions.Builder() - .projectId(PROJECT_ID) - .collectionIds(collectionIds) - .addCollectionIds(COLLECTION_ID) - .filter(FILTER) - .query(QUERY) - .naturalLanguageQuery(NATURAL_LANGUAGE_QUERY) - .aggregation(AGGREGATION) - .count(COUNT) - .xReturn(returnList) - .addReturnField(RETURN) - .offset(OFFSET) - .sort(SORT) - .highlight(true) - .spellingSuggestions(true) - .tableResults(queryLargeTableResults) - .suggestedRefinements(queryLargeSuggestedRefinements) - .passages(queryLargePassages) - .build(); - options = options.newBuilder().build(); - - assertEquals(PROJECT_ID, options.projectId()); - assertEquals(FILTER, options.filter()); - assertEquals(QUERY, options.query()); - assertEquals(NATURAL_LANGUAGE_QUERY, options.naturalLanguageQuery()); - assertEquals(AGGREGATION, options.aggregation()); - assertEquals(COUNT, options.count()); - assertEquals(2, options.xReturn().size()); - assertEquals(RETURN, options.xReturn().get(0)); - assertEquals(OFFSET, options.offset()); - assertEquals(SORT, options.sort()); - assertTrue(options.highlight()); - assertTrue(options.spellingSuggestions()); - assertEquals(queryLargeTableResults, options.tableResults()); - assertEquals(queryLargeSuggestedRefinements, options.suggestedRefinements()); - assertEquals(queryLargePassages, options.passages()); - } - - /** Test training example. */ @Test - public void testTrainingExample() { - TrainingExample trainingExample = - new TrainingExample.Builder() - .documentId(DOCUMENT_ID) - .collectionId(COLLECTION_ID) - .relevance(RELEVANCE) - .created(testDate) - .updated(testDate) + public void testAddDocumentWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = "{\"document_id\": \"documentId\", \"status\": \"processing\"}"; + String addDocumentPath = "/v2/projects/testString/collections/testString/documents"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(202) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the AddDocumentOptions model + AddDocumentOptions addDocumentOptionsModel = + new AddDocumentOptions.Builder() + .projectId("testString") + .collectionId("testString") + .file(TestUtilities.createMockStream("This is a mock file.")) + .filename("testString") + .fileContentType("application/json") + .metadata("testString") + .xWatsonDiscoveryForce(true) .build(); - trainingExample = trainingExample.newBuilder().build(); - assertEquals(DOCUMENT_ID, trainingExample.documentId()); - assertEquals(COLLECTION_ID, trainingExample.collectionId()); - assertEquals(RELEVANCE, trainingExample.relevance()); - assertEquals(testDate, trainingExample.created()); - assertEquals(testDate, trainingExample.updated()); + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.addDocument(addDocumentOptionsModel).execute(); + assertNotNull(response); + DocumentAccepted responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, addDocumentPath); + } + + // Test the addDocument operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAddDocumentNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.addDocument(null).execute(); } - /** Test training query. */ @Test - public void testTrainingQuery() { - List exampleList = new ArrayList<>(); - exampleList.add(trainingExampleMock); - - TrainingQuery trainingQuery = - new TrainingQuery.Builder() - .queryId(QUERY_ID) - .naturalLanguageQuery(NATURAL_LANGUAGE_QUERY) - .filter(FILTER) - .created(testDate) - .updated(testDate) - .examples(exampleList) - .addExamples(trainingExampleMock) + public void testUpdateDocumentWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = "{\"document_id\": \"documentId\", \"status\": \"processing\"}"; + String updateDocumentPath = + "/v2/projects/testString/collections/testString/documents/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(202) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the UpdateDocumentOptions model + UpdateDocumentOptions updateDocumentOptionsModel = + new UpdateDocumentOptions.Builder() + .projectId("testString") + .collectionId("testString") + .documentId("testString") + .file(TestUtilities.createMockStream("This is a mock file.")) + .filename("testString") + .fileContentType("application/json") + .metadata("testString") + .xWatsonDiscoveryForce(true) .build(); - trainingQuery = trainingQuery.newBuilder().build(); - assertEquals(QUERY_ID, trainingQuery.queryId()); - assertEquals(NATURAL_LANGUAGE_QUERY, trainingQuery.naturalLanguageQuery()); - assertEquals(FILTER, trainingQuery.filter()); - assertEquals(testDate, trainingQuery.created()); - assertEquals(testDate, trainingQuery.updated()); - assertEquals(2, trainingQuery.examples().size()); - assertEquals(trainingExampleMock, trainingQuery.examples().get(0)); + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.updateDocument(updateDocumentOptionsModel).execute(); + assertNotNull(response); + DocumentAccepted responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateDocumentPath); + } + + // Test the updateDocument operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateDocumentNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.updateDocument(null).execute(); } - /** Test update document options. */ @Test - public void testUpdateDocumentOptions() { - UpdateDocumentOptions options = - new UpdateDocumentOptions.Builder() - .projectId(PROJECT_ID) - .collectionId(COLLECTION_ID) - .documentId(DOCUMENT_ID) - .file(testDocument) - .filename(FILENAME) - .fileContentType(FILE_CONTENT_TYPE) - .metadata(METADATA) + public void testDeleteDocumentWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = "{\"document_id\": \"documentId\", \"status\": \"deleted\"}"; + String deleteDocumentPath = + "/v2/projects/testString/collections/testString/documents/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the DeleteDocumentOptions model + DeleteDocumentOptions deleteDocumentOptionsModel = + new DeleteDocumentOptions.Builder() + .projectId("testString") + .collectionId("testString") + .documentId("testString") .xWatsonDiscoveryForce(true) .build(); - options = options.newBuilder().build(); - assertEquals(PROJECT_ID, options.projectId()); - assertEquals(COLLECTION_ID, options.collectionId()); - assertEquals(testDocument, options.file()); - assertEquals(FILENAME, options.filename()); - assertEquals(FILE_CONTENT_TYPE, options.fileContentType()); - assertEquals(METADATA, options.metadata()); - assertTrue(options.xWatsonDiscoveryForce()); + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.deleteDocument(deleteDocumentOptionsModel).execute(); + assertNotNull(response); + DeleteDocumentResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteDocumentPath); + } + + // Test the deleteDocument operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteDocumentNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.deleteDocument(null).execute(); } - /** Test update training query options. */ @Test - public void testUpdateTrainingQueryOptions() { - List exampleList = new ArrayList<>(); - exampleList.add(trainingExampleMock); + public void testListTrainingQueriesWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"queries\": [{\"query_id\": \"queryId\", \"natural_language_query\": \"naturalLanguageQuery\", \"filter\": \"filter\", \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\", \"examples\": [{\"document_id\": \"documentId\", \"collection_id\": \"collectionId\", \"relevance\": 9, \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}]}]}"; + String listTrainingQueriesPath = "/v2/projects/testString/training_data/queries"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the ListTrainingQueriesOptions model + ListTrainingQueriesOptions listTrainingQueriesOptionsModel = + new ListTrainingQueriesOptions.Builder().projectId("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.listTrainingQueries(listTrainingQueriesOptionsModel).execute(); + assertNotNull(response); + TrainingQuerySet responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listTrainingQueriesPath); + } - UpdateTrainingQueryOptions options = - new UpdateTrainingQueryOptions.Builder() - .projectId(PROJECT_ID) - .queryId(QUERY_ID) - .naturalLanguageQuery(NATURAL_LANGUAGE_QUERY) - .filter(FILTER) - .examples(exampleList) - .addExamples(trainingExampleMock) - .build(); - options = options.newBuilder().build(); + // Test the listTrainingQueries operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListTrainingQueriesNoOptions() throws Throwable { + // construct the service + constructClientService(); - assertEquals(PROJECT_ID, options.projectId()); - assertEquals(NATURAL_LANGUAGE_QUERY, options.naturalLanguageQuery()); - assertEquals(FILTER, options.filter()); - assertEquals(2, options.examples().size()); - assertEquals(trainingExampleMock, options.examples().get(0)); + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.listTrainingQueries(null).execute(); } - /** Test list collections. */ @Test - public void testListCollections() { - server.enqueue(jsonResponse(listCollectionsResponse)); + public void testDeleteTrainingQueriesWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String deleteTrainingQueriesPath = "/v2/projects/testString/training_data/queries"; + + server.enqueue(new MockResponse().setResponseCode(204).setBody(mockResponseBody)); - ListCollectionsOptions options = - new ListCollectionsOptions.Builder().projectId(PROJECT_ID).build(); - ListCollectionsResponse response = service.listCollections(options).execute().getResult(); + constructClientService(); - assertEquals(COLLECTION_ID, response.getCollections().get(0).getCollectionId()); - assertEquals(NAME, response.getCollections().get(0).getName()); + // Construct an instance of the DeleteTrainingQueriesOptions model + DeleteTrainingQueriesOptions deleteTrainingQueriesOptionsModel = + new DeleteTrainingQueriesOptions.Builder().projectId("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.deleteTrainingQueries(deleteTrainingQueriesOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteTrainingQueriesPath); + } + + // Test the deleteTrainingQueries operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteTrainingQueriesNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.deleteTrainingQueries(null).execute(); } - /** Test query. */ @Test - public void testQuery() { - server.enqueue(jsonResponse(queryResponse)); + public void testCreateTrainingQueryWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"query_id\": \"queryId\", \"natural_language_query\": \"naturalLanguageQuery\", \"filter\": \"filter\", \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\", \"examples\": [{\"document_id\": \"documentId\", \"collection_id\": \"collectionId\", \"relevance\": 9, \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}]}"; + String createTrainingQueryPath = "/v2/projects/testString/training_data/queries"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(201) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the TrainingExample model + TrainingExample trainingExampleModel = + new TrainingExample.Builder() + .documentId("testString") + .collectionId("testString") + .relevance(Long.valueOf("26")) + .build(); - QueryOptions options = new QueryOptions.Builder().projectId(PROJECT_ID).build(); - QueryResponse response = service.query(options).execute().getResult(); + // Construct an instance of the CreateTrainingQueryOptions model + CreateTrainingQueryOptions createTrainingQueryOptionsModel = + new CreateTrainingQueryOptions.Builder() + .projectId("testString") + .naturalLanguageQuery("testString") + .examples( + new java.util.ArrayList( + java.util.Arrays.asList(trainingExampleModel))) + .filter("testString") + .build(); - assertEquals(MATCHING_RESULTS, response.getMatchingResults()); - assertEquals(DOCUMENT_ID, response.getResults().get(0).getDocumentId()); - assertEquals( - DOCUMENT_RETRIEVAL_SOURCE, - response.getResults().get(0).getResultMetadata().getDocumentRetrievalSource()); - assertEquals(COLLECTION_ID, response.getResults().get(0).getResultMetadata().getCollectionId()); - assertEquals(CONFIDENCE, response.getResults().get(0).getResultMetadata().getConfidence()); - assertEquals( - PASSAGE_TEXT, response.getResults().get(0).getDocumentPassages().get(0).getPassageText()); - assertEquals( - START_OFFSET, response.getResults().get(0).getDocumentPassages().get(0).getStartOffset()); - assertEquals( - END_OFFSET, response.getResults().get(0).getDocumentPassages().get(0).getEndOffset()); - assertEquals(FIELD, response.getResults().get(0).getDocumentPassages().get(0).getField()); - assertEquals( - DOCUMENT_RETRIEVAL_STRATEGY, response.getRetrievalDetails().getDocumentRetrievalStrategy()); - assertEquals(SUGGESTED_QUERY, response.getSuggestedQuery()); - assertEquals(TEXT, response.getSuggestedRefinements().get(0).getText()); - assertEquals(TABLE_ID, response.getTableResults().get(0).getTableId()); - assertEquals(SOURCE_DOCUMENT_ID, response.getTableResults().get(0).getSourceDocumentId()); - assertEquals(COLLECTION_ID, response.getTableResults().get(0).getCollectionId()); - assertEquals(TABLE_HTML, response.getTableResults().get(0).getTableHtml()); - assertEquals(TABLE_HTML_OFFSET, response.getTableResults().get(0).getTableHtmlOffset()); - assertEquals(BEGIN, response.getTableResults().get(0).getTable().getLocation().getBegin()); - assertEquals(END, response.getTableResults().get(0).getTable().getLocation().getEnd()); - assertEquals(TEXT, response.getTableResults().get(0).getTable().getText()); - assertEquals(TEXT, response.getTableResults().get(0).getTable().getSectionTitle().getText()); - assertEquals( - BEGIN, - response.getTableResults().get(0).getTable().getSectionTitle().getLocation().getBegin()); - assertEquals( - END, response.getTableResults().get(0).getTable().getSectionTitle().getLocation().getEnd()); - assertEquals(TEXT, response.getTableResults().get(0).getTable().getTitle().getText()); - assertEquals( - BEGIN, response.getTableResults().get(0).getTable().getTitle().getLocation().getBegin()); - assertEquals( - END, response.getTableResults().get(0).getTable().getTitle().getLocation().getEnd()); - assertEquals( - CELL_ID, response.getTableResults().get(0).getTable().getTableHeaders().get(0).getCellId()); - assertEquals( - TEXT, response.getTableResults().get(0).getTable().getTableHeaders().get(0).getText()); - assertEquals( - ROW_INDEX_BEGIN, - response.getTableResults().get(0).getTable().getTableHeaders().get(0).getRowIndexBegin()); - assertEquals( - ROW_INDEX_END, - response.getTableResults().get(0).getTable().getTableHeaders().get(0).getRowIndexEnd()); - assertEquals( - COLUMN_INDEX_BEGIN, - response - .getTableResults() - .get(0) - .getTable() - .getTableHeaders() - .get(0) - .getColumnIndexBegin()); - assertEquals( - COLUMN_INDEX_END, - response.getTableResults().get(0).getTable().getTableHeaders().get(0).getColumnIndexEnd()); - assertEquals( - CELL_ID, response.getTableResults().get(0).getTable().getRowHeaders().get(0).getCellId()); - assertEquals( - BEGIN, - response - .getTableResults() - .get(0) - .getTable() - .getRowHeaders() - .get(0) - .getLocation() - .getBegin()); - assertEquals( - END, - response.getTableResults().get(0).getTable().getRowHeaders().get(0).getLocation().getEnd()); - assertEquals( - TEXT, response.getTableResults().get(0).getTable().getRowHeaders().get(0).getText()); - assertEquals( - ROW_INDEX_BEGIN, - response.getTableResults().get(0).getTable().getRowHeaders().get(0).getRowIndexBegin()); - assertEquals( - ROW_INDEX_END, - response.getTableResults().get(0).getTable().getRowHeaders().get(0).getRowIndexEnd()); - assertEquals( - COLUMN_INDEX_BEGIN, - response.getTableResults().get(0).getTable().getRowHeaders().get(0).getColumnIndexBegin()); - assertEquals( - COLUMN_INDEX_END, - response.getTableResults().get(0).getTable().getRowHeaders().get(0).getColumnIndexEnd()); - assertEquals( - CELL_ID, - response.getTableResults().get(0).getTable().getColumnHeaders().get(0).getCellId()); - assertEquals( - TEXT, response.getTableResults().get(0).getTable().getColumnHeaders().get(0).getText()); - assertEquals( - ROW_INDEX_BEGIN, - response.getTableResults().get(0).getTable().getColumnHeaders().get(0).getRowIndexBegin()); - assertEquals( - ROW_INDEX_END, - response.getTableResults().get(0).getTable().getColumnHeaders().get(0).getRowIndexEnd()); - assertEquals( - COLUMN_INDEX_BEGIN, - response - .getTableResults() - .get(0) - .getTable() - .getColumnHeaders() - .get(0) - .getColumnIndexBegin()); - assertEquals( - COLUMN_INDEX_END, - response.getTableResults().get(0).getTable().getColumnHeaders().get(0).getColumnIndexEnd()); - assertEquals( - CELL_ID, - response - .getTableResults() - .get(0) - .getTable() - .getKeyValuePairs() - .get(0) - .getKey() - .getCellId()); - assertEquals( - BEGIN, - response - .getTableResults() - .get(0) - .getTable() - .getKeyValuePairs() - .get(0) - .getKey() - .getLocation() - .getBegin()); - assertEquals( - END, - response - .getTableResults() - .get(0) - .getTable() - .getKeyValuePairs() - .get(0) - .getKey() - .getLocation() - .getEnd()); - assertEquals( - TEXT, - response.getTableResults().get(0).getTable().getKeyValuePairs().get(0).getKey().getText()); - assertEquals( - CELL_ID, - response - .getTableResults() - .get(0) - .getTable() - .getKeyValuePairs() - .get(0) - .getValue() - .get(0) - .getCellId()); - assertEquals( - BEGIN, - response - .getTableResults() - .get(0) - .getTable() - .getKeyValuePairs() - .get(0) - .getValue() - .get(0) - .getLocation() - .getBegin()); - assertEquals( - END, - response - .getTableResults() - .get(0) - .getTable() - .getKeyValuePairs() - .get(0) - .getValue() - .get(0) - .getLocation() - .getEnd()); - assertEquals( - TEXT, - response - .getTableResults() - .get(0) - .getTable() - .getKeyValuePairs() - .get(0) - .getValue() - .get(0) - .getText()); - assertEquals( - CELL_ID, response.getTableResults().get(0).getTable().getBodyCells().get(0).getCellId()); - assertEquals( - BEGIN, - response - .getTableResults() - .get(0) - .getTable() - .getBodyCells() - .get(0) - .getLocation() - .getBegin()); - assertEquals( - END, - response.getTableResults().get(0).getTable().getBodyCells().get(0).getLocation().getEnd()); - assertEquals( - TEXT, response.getTableResults().get(0).getTable().getBodyCells().get(0).getText()); - assertEquals( - ROW_INDEX_BEGIN, - response.getTableResults().get(0).getTable().getBodyCells().get(0).getRowIndexBegin()); - assertEquals( - ROW_INDEX_END, - response.getTableResults().get(0).getTable().getBodyCells().get(0).getRowIndexEnd()); - assertEquals( - COLUMN_INDEX_BEGIN, - response.getTableResults().get(0).getTable().getBodyCells().get(0).getColumnIndexBegin()); - assertEquals( - COLUMN_INDEX_END, - response.getTableResults().get(0).getTable().getBodyCells().get(0).getColumnIndexEnd()); - assertEquals( - ID, - response - .getTableResults() - .get(0) - .getTable() - .getBodyCells() - .get(0) - .getRowHeaderIds() - .get(0) - .getId()); - assertEquals( - TEXT, - response - .getTableResults() - .get(0) - .getTable() - .getBodyCells() - .get(0) - .getRowHeaderTexts() - .get(0) - .getText()); - assertEquals( - TEXT_NORMALIZED, - response - .getTableResults() - .get(0) - .getTable() - .getBodyCells() - .get(0) - .getRowHeaderTextsNormalized() - .get(0) - .getTextNormalized()); - assertEquals( - ID, - response - .getTableResults() - .get(0) - .getTable() - .getBodyCells() - .get(0) - .getColumnHeaderIds() - .get(0) - .getId()); - assertEquals( - TEXT, - response - .getTableResults() - .get(0) - .getTable() - .getBodyCells() - .get(0) - .getColumnHeaderTexts() - .get(0) - .getText()); - assertEquals( - TEXT_NORMALIZED, - response - .getTableResults() - .get(0) - .getTable() - .getBodyCells() - .get(0) - .getColumnHeaderTextsNormalized() - .get(0) - .getTextNormalized()); - assertEquals( - TYPE, - response - .getTableResults() - .get(0) - .getTable() - .getBodyCells() - .get(0) - .getAttributes() - .get(0) - .getType()); - assertEquals( - TEXT, - response - .getTableResults() - .get(0) - .getTable() - .getBodyCells() - .get(0) - .getAttributes() - .get(0) - .getText()); - assertEquals( - BEGIN, - response - .getTableResults() - .get(0) - .getTable() - .getBodyCells() - .get(0) - .getAttributes() - .get(0) - .getLocation() - .getBegin()); - assertEquals( - END, - response - .getTableResults() - .get(0) - .getTable() - .getBodyCells() - .get(0) - .getAttributes() - .get(0) - .getLocation() - .getEnd()); - assertEquals(TEXT, response.getTableResults().get(0).getTable().getContexts().get(0).getText()); - assertEquals( - BEGIN, - response.getTableResults().get(0).getTable().getContexts().get(0).getLocation().getBegin()); - assertEquals( - END, - response.getTableResults().get(0).getTable().getContexts().get(0).getLocation().getEnd()); + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.createTrainingQuery(createTrainingQueryOptionsModel).execute(); + assertNotNull(response); + TrainingQuery responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createTrainingQueryPath); + } + + // Test the createTrainingQuery operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateTrainingQueryNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.createTrainingQuery(null).execute(); } - /** Test get autocompletion. */ @Test - public void testGetAutocompletion() { - server.enqueue(jsonResponse(completions)); + public void testGetTrainingQueryWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"query_id\": \"queryId\", \"natural_language_query\": \"naturalLanguageQuery\", \"filter\": \"filter\", \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\", \"examples\": [{\"document_id\": \"documentId\", \"collection_id\": \"collectionId\", \"relevance\": 9, \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}]}"; + String getTrainingQueryPath = "/v2/projects/testString/training_data/queries/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the GetTrainingQueryOptions model + GetTrainingQueryOptions getTrainingQueryOptionsModel = + new GetTrainingQueryOptions.Builder().projectId("testString").queryId("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.getTrainingQuery(getTrainingQueryOptionsModel).execute(); + assertNotNull(response); + TrainingQuery responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getTrainingQueryPath); + } - GetAutocompletionOptions options = - new GetAutocompletionOptions.Builder().projectId(PROJECT_ID).prefix(PREFIX).build(); - Completions response = service.getAutocompletion(options).execute().getResult(); + // Test the getTrainingQuery operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetTrainingQueryNoOptions() throws Throwable { + // construct the service + constructClientService(); - assertEquals(COMPLETION, response.getCompletions().get(0)); + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.getTrainingQuery(null).execute(); } - /** Test query notices. */ @Test - public void testQueryNotices() { - server.enqueue(jsonResponse(queryNoticesResponse)); + public void testUpdateTrainingQueryWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"query_id\": \"queryId\", \"natural_language_query\": \"naturalLanguageQuery\", \"filter\": \"filter\", \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\", \"examples\": [{\"document_id\": \"documentId\", \"collection_id\": \"collectionId\", \"relevance\": 9, \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}]}"; + String updateTrainingQueryPath = "/v2/projects/testString/training_data/queries/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(201) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the TrainingExample model + TrainingExample trainingExampleModel = + new TrainingExample.Builder() + .documentId("testString") + .collectionId("testString") + .relevance(Long.valueOf("26")) + .build(); + + // Construct an instance of the UpdateTrainingQueryOptions model + UpdateTrainingQueryOptions updateTrainingQueryOptionsModel = + new UpdateTrainingQueryOptions.Builder() + .projectId("testString") + .queryId("testString") + .naturalLanguageQuery("testString") + .examples( + new java.util.ArrayList( + java.util.Arrays.asList(trainingExampleModel))) + .filter("testString") + .build(); - QueryNoticesOptions options = new QueryNoticesOptions.Builder().projectId(PROJECT_ID).build(); - QueryNoticesResponse response = service.queryNotices(options).execute().getResult(); + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.updateTrainingQuery(updateTrainingQueryOptionsModel).execute(); + assertNotNull(response); + TrainingQuery responseObj = response.getResult(); + assertNotNull(responseObj); - assertEquals(MATCHING_RESULTS, response.getMatchingResults()); - assertEquals(NOTICE_ID, response.getNotices().get(0).getNoticeId()); - assertEquals(testDate, response.getNotices().get(0).getCreated()); - assertEquals(DOCUMENT_ID, response.getNotices().get(0).getDocumentId()); - assertEquals(COLLECTION_ID, response.getNotices().get(0).getCollectionId()); - assertEquals(QUERY_ID, response.getNotices().get(0).getQueryId()); - assertEquals(SEVERITY, response.getNotices().get(0).getSeverity()); - assertEquals(STEP, response.getNotices().get(0).getStep()); - assertEquals(DESCRIPTION, response.getNotices().get(0).getDescription()); + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateTrainingQueryPath); + } + + // Test the updateTrainingQuery operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateTrainingQueryNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.updateTrainingQuery(null).execute(); } - /** Test list fields. */ @Test - public void testListFields() { - server.enqueue(jsonResponse(listFieldsResponse)); + public void testAnalyzeDocumentWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"notices\": [{\"notice_id\": \"noticeId\", \"created\": \"2019-01-01T12:00:00\", \"document_id\": \"documentId\", \"collection_id\": \"collectionId\", \"query_id\": \"queryId\", \"severity\": \"warning\", \"step\": \"step\", \"description\": \"description\"}], \"result\": {\"metadata\": {\"mapKey\": \"anyValue\"}}}"; + String analyzeDocumentPath = "/v2/projects/testString/collections/testString/analyze"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the AnalyzeDocumentOptions model + AnalyzeDocumentOptions analyzeDocumentOptionsModel = + new AnalyzeDocumentOptions.Builder() + .projectId("testString") + .collectionId("testString") + .file(TestUtilities.createMockStream("This is a mock file.")) + .filename("testString") + .fileContentType("application/json") + .metadata("testString") + .build(); - ListFieldsOptions options = new ListFieldsOptions.Builder().projectId(PROJECT_ID).build(); - ListFieldsResponse response = service.listFields(options).execute().getResult(); + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.analyzeDocument(analyzeDocumentOptionsModel).execute(); + assertNotNull(response); + AnalyzedDocument responseObj = response.getResult(); + assertNotNull(responseObj); - assertEquals(FIELD, response.getFields().get(0).getField()); - assertEquals(TYPE, response.getFields().get(0).getType()); - assertEquals(COLLECTION_ID, response.getFields().get(0).getCollectionId()); + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, analyzeDocumentPath); + } + + // Test the analyzeDocument operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAnalyzeDocumentNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.analyzeDocument(null).execute(); } - /** Test get component settings. */ @Test - public void testGetComponentSettings() { - server.enqueue(jsonResponse(componentSettingsResponse)); - - GetComponentSettingsOptions options = - new GetComponentSettingsOptions.Builder().projectId(PROJECT_ID).build(); - ComponentSettingsResponse response = - service.getComponentSettings(options).execute().getResult(); - - assertTrue(response.getFieldsShown().getBody().isUsePassage()); - assertEquals(FIELD, response.getFieldsShown().getBody().getField()); - assertEquals(FIELD, response.getFieldsShown().getTitle().getField()); - assertTrue(response.isAutocomplete()); - assertTrue(response.isStructuredSearch()); - assertEquals(RESULTS_PER_PAGE, response.getResultsPerPage()); - assertEquals(NAME, response.getAggregations().get(0).getName()); - assertEquals(LABEL, response.getAggregations().get(0).getLabel()); - assertTrue(response.getAggregations().get(0).isMultipleSelectionsAllowed()); - assertEquals(VISUALIZATION_TYPE, response.getAggregations().get(0).getVisualizationType()); - } - - /** Test add document. */ + public void testListEnrichmentsWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"enrichments\": [{\"enrichment_id\": \"enrichmentId\", \"name\": \"name\", \"description\": \"description\", \"type\": \"part_of_speech\", \"options\": {\"languages\": [\"languages\"], \"entity_type\": \"entityType\", \"regular_expression\": \"regularExpression\", \"result_field\": \"resultField\"}}]}"; + String listEnrichmentsPath = "/v2/projects/testString/enrichments"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the ListEnrichmentsOptions model + ListEnrichmentsOptions listEnrichmentsOptionsModel = + new ListEnrichmentsOptions.Builder().projectId("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.listEnrichments(listEnrichmentsOptionsModel).execute(); + assertNotNull(response); + Enrichments responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listEnrichmentsPath); + } + + // Test the listEnrichments operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListEnrichmentsNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.listEnrichments(null).execute(); + } + @Test - public void testAddDocument() { - server.enqueue(jsonResponse(documentAccepted)); + public void testCreateEnrichmentWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"enrichment_id\": \"enrichmentId\", \"name\": \"name\", \"description\": \"description\", \"type\": \"part_of_speech\", \"options\": {\"languages\": [\"languages\"], \"entity_type\": \"entityType\", \"regular_expression\": \"regularExpression\", \"result_field\": \"resultField\"}}"; + String createEnrichmentPath = "/v2/projects/testString/enrichments"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(201) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the EnrichmentOptions model + EnrichmentOptions enrichmentOptionsModel = + new EnrichmentOptions.Builder() + .languages(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .entityType("testString") + .regularExpression("testString") + .resultField("testString") + .build(); - AddDocumentOptions options = - new AddDocumentOptions.Builder() - .projectId(PROJECT_ID) - .collectionId(COLLECTION_ID) - .file(testDocument) - .filename(FILENAME) + // Construct an instance of the CreateEnrichment model + CreateEnrichment createEnrichmentModel = + new CreateEnrichment.Builder() + .name("testString") + .description("testString") + .type("dictionary") + .options(enrichmentOptionsModel) + .build(); + + // Construct an instance of the CreateEnrichmentOptions model + CreateEnrichmentOptions createEnrichmentOptionsModel = + new CreateEnrichmentOptions.Builder() + .projectId("testString") + .enrichment(createEnrichmentModel) + .file(TestUtilities.createMockStream("This is a mock file.")) .build(); - DocumentAccepted response = service.addDocument(options).execute().getResult(); - assertEquals(DOCUMENT_ID, response.getDocumentId()); - assertEquals(STATUS, response.getStatus()); + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.createEnrichment(createEnrichmentOptionsModel).execute(); + assertNotNull(response); + Enrichment responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createEnrichmentPath); + } + + // Test the createEnrichment operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateEnrichmentNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.createEnrichment(null).execute(); } - /** Test update document. */ @Test - public void testUpdateDocument() { - server.enqueue(jsonResponse(documentAccepted)); + public void testGetEnrichmentWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"enrichment_id\": \"enrichmentId\", \"name\": \"name\", \"description\": \"description\", \"type\": \"part_of_speech\", \"options\": {\"languages\": [\"languages\"], \"entity_type\": \"entityType\", \"regular_expression\": \"regularExpression\", \"result_field\": \"resultField\"}}"; + String getEnrichmentPath = "/v2/projects/testString/enrichments/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the GetEnrichmentOptions model + GetEnrichmentOptions getEnrichmentOptionsModel = + new GetEnrichmentOptions.Builder() + .projectId("testString") + .enrichmentId("testString") + .build(); - UpdateDocumentOptions options = - new UpdateDocumentOptions.Builder() - .projectId(PROJECT_ID) - .collectionId(COLLECTION_ID) - .documentId(DOCUMENT_ID) - .file(testDocument) - .filename(FILENAME) + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.getEnrichment(getEnrichmentOptionsModel).execute(); + assertNotNull(response); + Enrichment responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getEnrichmentPath); + } + + // Test the getEnrichment operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetEnrichmentNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.getEnrichment(null).execute(); + } + + @Test + public void testUpdateEnrichmentWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"enrichment_id\": \"enrichmentId\", \"name\": \"name\", \"description\": \"description\", \"type\": \"part_of_speech\", \"options\": {\"languages\": [\"languages\"], \"entity_type\": \"entityType\", \"regular_expression\": \"regularExpression\", \"result_field\": \"resultField\"}}"; + String updateEnrichmentPath = "/v2/projects/testString/enrichments/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the UpdateEnrichmentOptions model + UpdateEnrichmentOptions updateEnrichmentOptionsModel = + new UpdateEnrichmentOptions.Builder() + .projectId("testString") + .enrichmentId("testString") + .name("testString") + .description("testString") .build(); - DocumentAccepted response = service.updateDocument(options).execute().getResult(); - assertEquals(DOCUMENT_ID, response.getDocumentId()); - assertEquals(STATUS, response.getStatus()); + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.updateEnrichment(updateEnrichmentOptionsModel).execute(); + assertNotNull(response); + Enrichment responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateEnrichmentPath); + } + + // Test the updateEnrichment operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateEnrichmentNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.updateEnrichment(null).execute(); } - /** Test delete document. */ @Test - public void testDeleteDocument() { - server.enqueue(jsonResponse(deleteDocumentResponse)); + public void testDeleteEnrichmentWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String deleteEnrichmentPath = "/v2/projects/testString/enrichments/testString"; - DeleteDocumentOptions options = - new DeleteDocumentOptions.Builder() - .projectId(PROJECT_ID) - .collectionId(COLLECTION_ID) - .documentId(DOCUMENT_ID) + server.enqueue(new MockResponse().setResponseCode(204).setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the DeleteEnrichmentOptions model + DeleteEnrichmentOptions deleteEnrichmentOptionsModel = + new DeleteEnrichmentOptions.Builder() + .projectId("testString") + .enrichmentId("testString") .build(); - DeleteDocumentResponse response = service.deleteDocument(options).execute().getResult(); - assertEquals(DOCUMENT_ID, response.getDocumentId()); - assertEquals(STATUS, response.getStatus()); + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.deleteEnrichment(deleteEnrichmentOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteEnrichmentPath); + } + + // Test the deleteEnrichment operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteEnrichmentNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.deleteEnrichment(null).execute(); } - /** Test list training queries. */ @Test - public void testListTrainingQueries() { - server.enqueue(jsonResponse(trainingQuerySet)); - - ListTrainingQueriesOptions options = - new ListTrainingQueriesOptions.Builder().projectId(PROJECT_ID).build(); - TrainingQuerySet response = service.listTrainingQueries(options).execute().getResult(); - - assertEquals(QUERY_ID, response.getQueries().get(0).queryId()); - assertEquals(NATURAL_LANGUAGE_QUERY, response.getQueries().get(0).naturalLanguageQuery()); - assertEquals(FILTER, response.getQueries().get(0).filter()); - assertEquals(testDate, response.getQueries().get(0).created()); - assertEquals(testDate, response.getQueries().get(0).updated()); - assertEquals(DOCUMENT_ID, response.getQueries().get(0).examples().get(0).documentId()); - assertEquals(COLLECTION_ID, response.getQueries().get(0).examples().get(0).collectionId()); - assertEquals(RELEVANCE, response.getQueries().get(0).examples().get(0).relevance()); - assertEquals(testDate, response.getQueries().get(0).examples().get(0).created()); - assertEquals(testDate, response.getQueries().get(0).examples().get(0).updated()); - } - - /** - * Test delete training queries. - * - * @throws InterruptedException the interrupted exception - */ + public void testListProjectsWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"projects\": [{\"project_id\": \"projectId\", \"name\": \"name\", \"type\": \"document_retrieval\", \"relevancy_training_status\": {\"data_updated\": \"dataUpdated\", \"total_examples\": 13, \"sufficient_label_diversity\": true, \"processing\": true, \"minimum_examples_added\": true, \"successfully_trained\": \"successfullyTrained\", \"available\": false, \"notices\": 7, \"minimum_queries_added\": false}, \"collection_count\": 15}]}"; + String listProjectsPath = "/v2/projects"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the ListProjectsOptions model + ListProjectsOptions listProjectsOptionsModel = new ListProjectsOptions(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.listProjects(listProjectsOptionsModel).execute(); + assertNotNull(response); + ListProjectsResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listProjectsPath); + } + @Test - public void testDeleteTrainingQueries() throws InterruptedException { + public void testCreateProjectWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"project_id\": \"projectId\", \"name\": \"name\", \"type\": \"document_retrieval\", \"relevancy_training_status\": {\"data_updated\": \"dataUpdated\", \"total_examples\": 13, \"sufficient_label_diversity\": true, \"processing\": true, \"minimum_examples_added\": true, \"successfully_trained\": \"successfullyTrained\", \"available\": false, \"notices\": 7, \"minimum_queries_added\": false}, \"collection_count\": 15, \"default_query_parameters\": {\"collection_ids\": [\"collectionIds\"], \"passages\": {\"enabled\": false, \"count\": 5, \"fields\": [\"fields\"], \"characters\": 10, \"per_document\": false, \"max_per_document\": 14}, \"table_results\": {\"enabled\": false, \"count\": 5, \"per_document\": 11}, \"aggregation\": \"aggregation\", \"suggested_refinements\": {\"enabled\": false, \"count\": 5}, \"spelling_suggestions\": false, \"highlight\": false, \"count\": 5, \"sort\": \"sort\", \"return\": [\"xReturn\"]}}"; + String createProjectPath = "/v2/projects"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the DefaultQueryParamsPassages model + DefaultQueryParamsPassages defaultQueryParamsPassagesModel = + new DefaultQueryParamsPassages.Builder() + .enabled(true) + .count(Long.valueOf("26")) + .fields(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .characters(Long.valueOf("26")) + .perDocument(true) + .maxPerDocument(Long.valueOf("26")) + .build(); + + // Construct an instance of the DefaultQueryParamsTableResults model + DefaultQueryParamsTableResults defaultQueryParamsTableResultsModel = + new DefaultQueryParamsTableResults.Builder() + .enabled(true) + .count(Long.valueOf("26")) + .perDocument(Long.valueOf("26")) + .build(); + + // Construct an instance of the DefaultQueryParamsSuggestedRefinements model + DefaultQueryParamsSuggestedRefinements defaultQueryParamsSuggestedRefinementsModel = + new DefaultQueryParamsSuggestedRefinements.Builder() + .enabled(true) + .count(Long.valueOf("26")) + .build(); + + // Construct an instance of the DefaultQueryParams model + DefaultQueryParams defaultQueryParamsModel = + new DefaultQueryParams.Builder() + .collectionIds(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .passages(defaultQueryParamsPassagesModel) + .tableResults(defaultQueryParamsTableResultsModel) + .aggregation("testString") + .suggestedRefinements(defaultQueryParamsSuggestedRefinementsModel) + .spellingSuggestions(true) + .highlight(true) + .count(Long.valueOf("26")) + .sort("testString") + .xReturn(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + + // Construct an instance of the CreateProjectOptions model + CreateProjectOptions createProjectOptionsModel = + new CreateProjectOptions.Builder() + .name("testString") + .type("document_retrieval") + .defaultQueryParameters(defaultQueryParamsModel) + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.createProject(createProjectOptionsModel).execute(); + assertNotNull(response); + ProjectDetails responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createProjectPath); + } + + // Test the createProject operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateProjectNoOptions() throws Throwable { + // construct the service + constructClientService(); + server.enqueue(new MockResponse()); - DeleteTrainingQueriesOptions options = - new DeleteTrainingQueriesOptions.Builder().projectId(PROJECT_ID).build(); - service.deleteTrainingQueries(options).execute(); + // Invoke operation with null options model (negative test) + discoveryService.createProject(null).execute(); + } + + @Test + public void testGetProjectWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"project_id\": \"projectId\", \"name\": \"name\", \"type\": \"document_retrieval\", \"relevancy_training_status\": {\"data_updated\": \"dataUpdated\", \"total_examples\": 13, \"sufficient_label_diversity\": true, \"processing\": true, \"minimum_examples_added\": true, \"successfully_trained\": \"successfullyTrained\", \"available\": false, \"notices\": 7, \"minimum_queries_added\": false}, \"collection_count\": 15, \"default_query_parameters\": {\"collection_ids\": [\"collectionIds\"], \"passages\": {\"enabled\": false, \"count\": 5, \"fields\": [\"fields\"], \"characters\": 10, \"per_document\": false, \"max_per_document\": 14}, \"table_results\": {\"enabled\": false, \"count\": 5, \"per_document\": 11}, \"aggregation\": \"aggregation\", \"suggested_refinements\": {\"enabled\": false, \"count\": 5}, \"spelling_suggestions\": false, \"highlight\": false, \"count\": 5, \"sort\": \"sort\", \"return\": [\"xReturn\"]}}"; + String getProjectPath = "/v2/projects/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the GetProjectOptions model + GetProjectOptions getProjectOptionsModel = + new GetProjectOptions.Builder().projectId("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.getProject(getProjectOptionsModel).execute(); + assertNotNull(response); + ProjectDetails responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getProjectPath); + } - assertEquals("DELETE", request.getMethod()); + // Test the getProject operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetProjectNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.getProject(null).execute(); } - /** Test create training query. */ @Test - public void testCreateTrainingQuery() { - server.enqueue(jsonResponse(trainingQuery)); + public void testUpdateProjectWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"project_id\": \"projectId\", \"name\": \"name\", \"type\": \"document_retrieval\", \"relevancy_training_status\": {\"data_updated\": \"dataUpdated\", \"total_examples\": 13, \"sufficient_label_diversity\": true, \"processing\": true, \"minimum_examples_added\": true, \"successfully_trained\": \"successfullyTrained\", \"available\": false, \"notices\": 7, \"minimum_queries_added\": false}, \"collection_count\": 15, \"default_query_parameters\": {\"collection_ids\": [\"collectionIds\"], \"passages\": {\"enabled\": false, \"count\": 5, \"fields\": [\"fields\"], \"characters\": 10, \"per_document\": false, \"max_per_document\": 14}, \"table_results\": {\"enabled\": false, \"count\": 5, \"per_document\": 11}, \"aggregation\": \"aggregation\", \"suggested_refinements\": {\"enabled\": false, \"count\": 5}, \"spelling_suggestions\": false, \"highlight\": false, \"count\": 5, \"sort\": \"sort\", \"return\": [\"xReturn\"]}}"; + String updateProjectPath = "/v2/projects/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the UpdateProjectOptions model + UpdateProjectOptions updateProjectOptionsModel = + new UpdateProjectOptions.Builder().projectId("testString").name("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = + discoveryService.updateProject(updateProjectOptionsModel).execute(); + assertNotNull(response); + ProjectDetails responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateProjectPath); + } - CreateTrainingQueryOptions options = - new CreateTrainingQueryOptions.Builder() - .projectId(PROJECT_ID) - .naturalLanguageQuery(NATURAL_LANGUAGE_QUERY) - .addExamples(trainingExampleMock) - .build(); - TrainingQuery response = service.createTrainingQuery(options).execute().getResult(); + // Test the updateProject operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateProjectNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); - assertEquals(QUERY_ID, response.queryId()); - assertEquals(NATURAL_LANGUAGE_QUERY, response.naturalLanguageQuery()); - assertEquals(FILTER, response.filter()); - assertEquals(testDate, response.created()); - assertEquals(testDate, response.updated()); - assertEquals(DOCUMENT_ID, response.examples().get(0).documentId()); - assertEquals(COLLECTION_ID, response.examples().get(0).collectionId()); - assertEquals(RELEVANCE, response.examples().get(0).relevance()); - assertEquals(testDate, response.examples().get(0).created()); - assertEquals(testDate, response.examples().get(0).updated()); + // Invoke operation with null options model (negative test) + discoveryService.updateProject(null).execute(); } - /** Test get training query. */ @Test - public void testGetTrainingQuery() { - server.enqueue(jsonResponse(trainingQuery)); - - GetTrainingQueryOptions options = - new GetTrainingQueryOptions.Builder().projectId(PROJECT_ID).queryId(QUERY_ID).build(); - TrainingQuery response = service.getTrainingQuery(options).execute().getResult(); - - assertEquals(QUERY_ID, response.queryId()); - assertEquals(NATURAL_LANGUAGE_QUERY, response.naturalLanguageQuery()); - assertEquals(FILTER, response.filter()); - assertEquals(testDate, response.created()); - assertEquals(testDate, response.updated()); - assertEquals(DOCUMENT_ID, response.examples().get(0).documentId()); - assertEquals(COLLECTION_ID, response.examples().get(0).collectionId()); - assertEquals(RELEVANCE, response.examples().get(0).relevance()); - assertEquals(testDate, response.examples().get(0).created()); - assertEquals(testDate, response.examples().get(0).updated()); - } - - /** Test update training query. */ + public void testDeleteProjectWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String deleteProjectPath = "/v2/projects/testString"; + + server.enqueue(new MockResponse().setResponseCode(204).setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the DeleteProjectOptions model + DeleteProjectOptions deleteProjectOptionsModel = + new DeleteProjectOptions.Builder().projectId("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = discoveryService.deleteProject(deleteProjectOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteProjectPath); + } + + // Test the deleteProject operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteProjectNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.deleteProject(null).execute(); + } + @Test - public void testUpdateTrainingQuery() { - server.enqueue(jsonResponse(trainingQuery)); + public void testDeleteUserDataWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String deleteUserDataPath = "/v2/user_data"; - UpdateTrainingQueryOptions options = - new UpdateTrainingQueryOptions.Builder() - .projectId(PROJECT_ID) - .queryId(QUERY_ID) - .naturalLanguageQuery(NATURAL_LANGUAGE_QUERY) - .addExamples(trainingExampleMock) - .build(); - TrainingQuery response = service.updateTrainingQuery(options).execute().getResult(); - - assertEquals(QUERY_ID, response.queryId()); - assertEquals(NATURAL_LANGUAGE_QUERY, response.naturalLanguageQuery()); - assertEquals(FILTER, response.filter()); - assertEquals(testDate, response.created()); - assertEquals(testDate, response.updated()); - assertEquals(DOCUMENT_ID, response.examples().get(0).documentId()); - assertEquals(COLLECTION_ID, response.examples().get(0).collectionId()); - assertEquals(RELEVANCE, response.examples().get(0).relevance()); - assertEquals(testDate, response.examples().get(0).created()); - assertEquals(testDate, response.examples().get(0).updated()); + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the DeleteUserDataOptions model + DeleteUserDataOptions deleteUserDataOptionsModel = + new DeleteUserDataOptions.Builder().customerId("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = discoveryService.deleteUserData(deleteUserDataOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(query.get("customer_id"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteUserDataPath); + } + + // Test the deleteUserData operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteUserDataNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + discoveryService.deleteUserData(null).execute(); + } + + /** Initialize the server */ + @BeforeMethod + public void setUpMockServer() { + try { + server = new MockWebServer(); + // register handler + server.start(); + } catch (IOException err) { + fail("Failed to instantiate mock web server"); + } + } + + @AfterMethod + public void tearDownMockServer() throws IOException { + server.shutdown(); + discoveryService = null; } } diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/AddDocumentOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/AddDocumentOptionsTest.java new file mode 100644 index 00000000000..dba85215a36 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/AddDocumentOptionsTest.java @@ -0,0 +1,59 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.apache.commons.io.IOUtils; +import org.testng.annotations.Test; + +/** Unit test class for the AddDocumentOptions model. */ +public class AddDocumentOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAddDocumentOptions() throws Throwable { + AddDocumentOptions addDocumentOptionsModel = + new AddDocumentOptions.Builder() + .projectId("testString") + .collectionId("testString") + .file(TestUtilities.createMockStream("This is a mock file.")) + .filename("testString") + .fileContentType("application/json") + .metadata("testString") + .xWatsonDiscoveryForce(true) + .build(); + assertEquals(addDocumentOptionsModel.projectId(), "testString"); + assertEquals(addDocumentOptionsModel.collectionId(), "testString"); + assertEquals( + IOUtils.toString(addDocumentOptionsModel.file()), + IOUtils.toString(TestUtilities.createMockStream("This is a mock file."))); + assertEquals(addDocumentOptionsModel.filename(), "testString"); + assertEquals(addDocumentOptionsModel.fileContentType(), "application/json"); + assertEquals(addDocumentOptionsModel.metadata(), "testString"); + assertEquals(addDocumentOptionsModel.xWatsonDiscoveryForce(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAddDocumentOptionsError() throws Throwable { + new AddDocumentOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/AnalyzeDocumentOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/AnalyzeDocumentOptionsTest.java new file mode 100644 index 00000000000..b33d816f5b6 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/AnalyzeDocumentOptionsTest.java @@ -0,0 +1,57 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.apache.commons.io.IOUtils; +import org.testng.annotations.Test; + +/** Unit test class for the AnalyzeDocumentOptions model. */ +public class AnalyzeDocumentOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAnalyzeDocumentOptions() throws Throwable { + AnalyzeDocumentOptions analyzeDocumentOptionsModel = + new AnalyzeDocumentOptions.Builder() + .projectId("testString") + .collectionId("testString") + .file(TestUtilities.createMockStream("This is a mock file.")) + .filename("testString") + .fileContentType("application/json") + .metadata("testString") + .build(); + assertEquals(analyzeDocumentOptionsModel.projectId(), "testString"); + assertEquals(analyzeDocumentOptionsModel.collectionId(), "testString"); + assertEquals( + IOUtils.toString(analyzeDocumentOptionsModel.file()), + IOUtils.toString(TestUtilities.createMockStream("This is a mock file."))); + assertEquals(analyzeDocumentOptionsModel.filename(), "testString"); + assertEquals(analyzeDocumentOptionsModel.fileContentType(), "application/json"); + assertEquals(analyzeDocumentOptionsModel.metadata(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAnalyzeDocumentOptionsError() throws Throwable { + new AnalyzeDocumentOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/AnalyzedDocumentTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/AnalyzedDocumentTest.java new file mode 100644 index 00000000000..e964ee1f25d --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/AnalyzedDocumentTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the AnalyzedDocument model. */ +public class AnalyzedDocumentTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAnalyzedDocument() throws Throwable { + AnalyzedDocument analyzedDocumentModel = new AnalyzedDocument(); + assertNull(analyzedDocumentModel.getNotices()); + assertNull(analyzedDocumentModel.getResult()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/AnalyzedResultTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/AnalyzedResultTest.java new file mode 100644 index 00000000000..ff705a6d2e1 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/AnalyzedResultTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the AnalyzedResult model. */ +public class AnalyzedResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAnalyzedResult() throws Throwable { + AnalyzedResult analyzedResultModel = new AnalyzedResult(); + assertNull(analyzedResultModel.getMetadata()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CollectionDetailsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CollectionDetailsTest.java new file mode 100644 index 00000000000..f543af09eba --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CollectionDetailsTest.java @@ -0,0 +1,74 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CollectionDetails model. */ +public class CollectionDetailsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCollectionDetails() throws Throwable { + CollectionEnrichment collectionEnrichmentModel = + new CollectionEnrichment.Builder() + .enrichmentId("testString") + .fields(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals(collectionEnrichmentModel.enrichmentId(), "testString"); + assertEquals( + collectionEnrichmentModel.fields(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + CollectionDetails collectionDetailsModel = + new CollectionDetails.Builder() + .name("testString") + .description("testString") + .language("testString") + .enrichments( + new java.util.ArrayList( + java.util.Arrays.asList(collectionEnrichmentModel))) + .build(); + assertEquals(collectionDetailsModel.name(), "testString"); + assertEquals(collectionDetailsModel.description(), "testString"); + assertEquals(collectionDetailsModel.language(), "testString"); + assertEquals( + collectionDetailsModel.enrichments(), + new java.util.ArrayList( + java.util.Arrays.asList(collectionEnrichmentModel))); + + String json = TestUtilities.serialize(collectionDetailsModel); + + CollectionDetails collectionDetailsModelNew = + TestUtilities.deserialize(json, CollectionDetails.class); + assertTrue(collectionDetailsModelNew instanceof CollectionDetails); + assertEquals(collectionDetailsModelNew.name(), "testString"); + assertEquals(collectionDetailsModelNew.description(), "testString"); + assertEquals(collectionDetailsModelNew.language(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCollectionDetailsError() throws Throwable { + new CollectionDetails.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CollectionEnrichmentTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CollectionEnrichmentTest.java new file mode 100644 index 00000000000..5e0d29f7d7a --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CollectionEnrichmentTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CollectionEnrichment model. */ +public class CollectionEnrichmentTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCollectionEnrichment() throws Throwable { + CollectionEnrichment collectionEnrichmentModel = + new CollectionEnrichment.Builder() + .enrichmentId("testString") + .fields(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals(collectionEnrichmentModel.enrichmentId(), "testString"); + assertEquals( + collectionEnrichmentModel.fields(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + String json = TestUtilities.serialize(collectionEnrichmentModel); + + CollectionEnrichment collectionEnrichmentModelNew = + TestUtilities.deserialize(json, CollectionEnrichment.class); + assertTrue(collectionEnrichmentModelNew instanceof CollectionEnrichment); + assertEquals(collectionEnrichmentModelNew.enrichmentId(), "testString"); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CollectionTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CollectionTest.java new file mode 100644 index 00000000000..0c6f2e02d08 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CollectionTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Collection model. */ +public class CollectionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCollection() throws Throwable { + Collection collectionModel = new Collection(); + assertNull(collectionModel.getName()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CompletionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CompletionsTest.java new file mode 100644 index 00000000000..dc199076bad --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CompletionsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Completions model. */ +public class CompletionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCompletions() throws Throwable { + Completions completionsModel = new Completions(); + assertNull(completionsModel.getCompletions()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ComponentSettingsAggregationTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ComponentSettingsAggregationTest.java new file mode 100644 index 00000000000..7c55dca445e --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ComponentSettingsAggregationTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ComponentSettingsAggregation model. */ +public class ComponentSettingsAggregationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testComponentSettingsAggregation() throws Throwable { + ComponentSettingsAggregation componentSettingsAggregationModel = + new ComponentSettingsAggregation(); + assertNull(componentSettingsAggregationModel.getName()); + assertNull(componentSettingsAggregationModel.getLabel()); + assertNull(componentSettingsAggregationModel.isMultipleSelectionsAllowed()); + assertNull(componentSettingsAggregationModel.getVisualizationType()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ComponentSettingsFieldsShownBodyTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ComponentSettingsFieldsShownBodyTest.java new file mode 100644 index 00000000000..2fdac048013 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ComponentSettingsFieldsShownBodyTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ComponentSettingsFieldsShownBody model. */ +public class ComponentSettingsFieldsShownBodyTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testComponentSettingsFieldsShownBody() throws Throwable { + ComponentSettingsFieldsShownBody componentSettingsFieldsShownBodyModel = + new ComponentSettingsFieldsShownBody(); + assertNull(componentSettingsFieldsShownBodyModel.isUsePassage()); + assertNull(componentSettingsFieldsShownBodyModel.getField()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ComponentSettingsFieldsShownTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ComponentSettingsFieldsShownTest.java new file mode 100644 index 00000000000..542c3b111ad --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ComponentSettingsFieldsShownTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ComponentSettingsFieldsShown model. */ +public class ComponentSettingsFieldsShownTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testComponentSettingsFieldsShown() throws Throwable { + ComponentSettingsFieldsShown componentSettingsFieldsShownModel = + new ComponentSettingsFieldsShown(); + assertNull(componentSettingsFieldsShownModel.getBody()); + assertNull(componentSettingsFieldsShownModel.getTitle()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ComponentSettingsFieldsShownTitleTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ComponentSettingsFieldsShownTitleTest.java new file mode 100644 index 00000000000..ae57721543a --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ComponentSettingsFieldsShownTitleTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ComponentSettingsFieldsShownTitle model. */ +public class ComponentSettingsFieldsShownTitleTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testComponentSettingsFieldsShownTitle() throws Throwable { + ComponentSettingsFieldsShownTitle componentSettingsFieldsShownTitleModel = + new ComponentSettingsFieldsShownTitle(); + assertNull(componentSettingsFieldsShownTitleModel.getField()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ComponentSettingsResponseTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ComponentSettingsResponseTest.java new file mode 100644 index 00000000000..cf632f92abd --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ComponentSettingsResponseTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ComponentSettingsResponse model. */ +public class ComponentSettingsResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testComponentSettingsResponse() throws Throwable { + ComponentSettingsResponse componentSettingsResponseModel = new ComponentSettingsResponse(); + assertNull(componentSettingsResponseModel.getFieldsShown()); + assertNull(componentSettingsResponseModel.isAutocomplete()); + assertNull(componentSettingsResponseModel.isStructuredSearch()); + assertNull(componentSettingsResponseModel.getResultsPerPage()); + assertNull(componentSettingsResponseModel.getAggregations()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CreateCollectionOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CreateCollectionOptionsTest.java new file mode 100644 index 00000000000..5f30786dd80 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CreateCollectionOptionsTest.java @@ -0,0 +1,67 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateCollectionOptions model. */ +public class CreateCollectionOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateCollectionOptions() throws Throwable { + CollectionEnrichment collectionEnrichmentModel = + new CollectionEnrichment.Builder() + .enrichmentId("testString") + .fields(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals(collectionEnrichmentModel.enrichmentId(), "testString"); + assertEquals( + collectionEnrichmentModel.fields(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + CreateCollectionOptions createCollectionOptionsModel = + new CreateCollectionOptions.Builder() + .projectId("testString") + .name("testString") + .description("testString") + .language("testString") + .enrichments( + new java.util.ArrayList( + java.util.Arrays.asList(collectionEnrichmentModel))) + .build(); + assertEquals(createCollectionOptionsModel.projectId(), "testString"); + assertEquals(createCollectionOptionsModel.name(), "testString"); + assertEquals(createCollectionOptionsModel.description(), "testString"); + assertEquals(createCollectionOptionsModel.language(), "testString"); + assertEquals( + createCollectionOptionsModel.enrichments(), + new java.util.ArrayList( + java.util.Arrays.asList(collectionEnrichmentModel))); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateCollectionOptionsError() throws Throwable { + new CreateCollectionOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CreateEnrichmentOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CreateEnrichmentOptionsTest.java new file mode 100644 index 00000000000..ee57e612940 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CreateEnrichmentOptionsTest.java @@ -0,0 +1,77 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.apache.commons.io.IOUtils; +import org.testng.annotations.Test; + +/** Unit test class for the CreateEnrichmentOptions model. */ +public class CreateEnrichmentOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateEnrichmentOptions() throws Throwable { + EnrichmentOptions enrichmentOptionsModel = + new EnrichmentOptions.Builder() + .languages(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .entityType("testString") + .regularExpression("testString") + .resultField("testString") + .build(); + assertEquals( + enrichmentOptionsModel.languages(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals(enrichmentOptionsModel.entityType(), "testString"); + assertEquals(enrichmentOptionsModel.regularExpression(), "testString"); + assertEquals(enrichmentOptionsModel.resultField(), "testString"); + + CreateEnrichment createEnrichmentModel = + new CreateEnrichment.Builder() + .name("testString") + .description("testString") + .type("dictionary") + .options(enrichmentOptionsModel) + .build(); + assertEquals(createEnrichmentModel.name(), "testString"); + assertEquals(createEnrichmentModel.description(), "testString"); + assertEquals(createEnrichmentModel.type(), "dictionary"); + assertEquals(createEnrichmentModel.options(), enrichmentOptionsModel); + + CreateEnrichmentOptions createEnrichmentOptionsModel = + new CreateEnrichmentOptions.Builder() + .projectId("testString") + .enrichment(createEnrichmentModel) + .file(TestUtilities.createMockStream("This is a mock file.")) + .build(); + assertEquals(createEnrichmentOptionsModel.projectId(), "testString"); + assertEquals(createEnrichmentOptionsModel.enrichment(), createEnrichmentModel); + assertEquals( + IOUtils.toString(createEnrichmentOptionsModel.file()), + IOUtils.toString(TestUtilities.createMockStream("This is a mock file."))); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateEnrichmentOptionsError() throws Throwable { + new CreateEnrichmentOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CreateEnrichmentTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CreateEnrichmentTest.java new file mode 100644 index 00000000000..73a583d878c --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CreateEnrichmentTest.java @@ -0,0 +1,69 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateEnrichment model. */ +public class CreateEnrichmentTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateEnrichment() throws Throwable { + EnrichmentOptions enrichmentOptionsModel = + new EnrichmentOptions.Builder() + .languages(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .entityType("testString") + .regularExpression("testString") + .resultField("testString") + .build(); + assertEquals( + enrichmentOptionsModel.languages(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals(enrichmentOptionsModel.entityType(), "testString"); + assertEquals(enrichmentOptionsModel.regularExpression(), "testString"); + assertEquals(enrichmentOptionsModel.resultField(), "testString"); + + CreateEnrichment createEnrichmentModel = + new CreateEnrichment.Builder() + .name("testString") + .description("testString") + .type("dictionary") + .options(enrichmentOptionsModel) + .build(); + assertEquals(createEnrichmentModel.name(), "testString"); + assertEquals(createEnrichmentModel.description(), "testString"); + assertEquals(createEnrichmentModel.type(), "dictionary"); + assertEquals(createEnrichmentModel.options(), enrichmentOptionsModel); + + String json = TestUtilities.serialize(createEnrichmentModel); + + CreateEnrichment createEnrichmentModelNew = + TestUtilities.deserialize(json, CreateEnrichment.class); + assertTrue(createEnrichmentModelNew instanceof CreateEnrichment); + assertEquals(createEnrichmentModelNew.name(), "testString"); + assertEquals(createEnrichmentModelNew.description(), "testString"); + assertEquals(createEnrichmentModelNew.type(), "dictionary"); + assertEquals(createEnrichmentModelNew.options().toString(), enrichmentOptionsModel.toString()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CreateProjectOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CreateProjectOptionsTest.java new file mode 100644 index 00000000000..805cf730d8e --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CreateProjectOptionsTest.java @@ -0,0 +1,114 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateProjectOptions model. */ +public class CreateProjectOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateProjectOptions() throws Throwable { + DefaultQueryParamsPassages defaultQueryParamsPassagesModel = + new DefaultQueryParamsPassages.Builder() + .enabled(true) + .count(Long.valueOf("26")) + .fields(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .characters(Long.valueOf("26")) + .perDocument(true) + .maxPerDocument(Long.valueOf("26")) + .build(); + assertEquals(defaultQueryParamsPassagesModel.enabled(), Boolean.valueOf(true)); + assertEquals(defaultQueryParamsPassagesModel.count(), Long.valueOf("26")); + assertEquals( + defaultQueryParamsPassagesModel.fields(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals(defaultQueryParamsPassagesModel.characters(), Long.valueOf("26")); + assertEquals(defaultQueryParamsPassagesModel.perDocument(), Boolean.valueOf(true)); + assertEquals(defaultQueryParamsPassagesModel.maxPerDocument(), Long.valueOf("26")); + + DefaultQueryParamsTableResults defaultQueryParamsTableResultsModel = + new DefaultQueryParamsTableResults.Builder() + .enabled(true) + .count(Long.valueOf("26")) + .perDocument(Long.valueOf("26")) + .build(); + assertEquals(defaultQueryParamsTableResultsModel.enabled(), Boolean.valueOf(true)); + assertEquals(defaultQueryParamsTableResultsModel.count(), Long.valueOf("26")); + assertEquals(defaultQueryParamsTableResultsModel.perDocument(), Long.valueOf("26")); + + DefaultQueryParamsSuggestedRefinements defaultQueryParamsSuggestedRefinementsModel = + new DefaultQueryParamsSuggestedRefinements.Builder() + .enabled(true) + .count(Long.valueOf("26")) + .build(); + assertEquals(defaultQueryParamsSuggestedRefinementsModel.enabled(), Boolean.valueOf(true)); + assertEquals(defaultQueryParamsSuggestedRefinementsModel.count(), Long.valueOf("26")); + + DefaultQueryParams defaultQueryParamsModel = + new DefaultQueryParams.Builder() + .collectionIds(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .passages(defaultQueryParamsPassagesModel) + .tableResults(defaultQueryParamsTableResultsModel) + .aggregation("testString") + .suggestedRefinements(defaultQueryParamsSuggestedRefinementsModel) + .spellingSuggestions(true) + .highlight(true) + .count(Long.valueOf("26")) + .sort("testString") + .xReturn(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals( + defaultQueryParamsModel.collectionIds(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals(defaultQueryParamsModel.passages(), defaultQueryParamsPassagesModel); + assertEquals(defaultQueryParamsModel.tableResults(), defaultQueryParamsTableResultsModel); + assertEquals(defaultQueryParamsModel.aggregation(), "testString"); + assertEquals( + defaultQueryParamsModel.suggestedRefinements(), + defaultQueryParamsSuggestedRefinementsModel); + assertEquals(defaultQueryParamsModel.spellingSuggestions(), Boolean.valueOf(true)); + assertEquals(defaultQueryParamsModel.highlight(), Boolean.valueOf(true)); + assertEquals(defaultQueryParamsModel.count(), Long.valueOf("26")); + assertEquals(defaultQueryParamsModel.sort(), "testString"); + assertEquals( + defaultQueryParamsModel.xReturn(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + CreateProjectOptions createProjectOptionsModel = + new CreateProjectOptions.Builder() + .name("testString") + .type("document_retrieval") + .defaultQueryParameters(defaultQueryParamsModel) + .build(); + assertEquals(createProjectOptionsModel.name(), "testString"); + assertEquals(createProjectOptionsModel.type(), "document_retrieval"); + assertEquals(createProjectOptionsModel.defaultQueryParameters(), defaultQueryParamsModel); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateProjectOptionsError() throws Throwable { + new CreateProjectOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CreateTrainingQueryOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CreateTrainingQueryOptionsTest.java new file mode 100644 index 00000000000..f2de87fca48 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/CreateTrainingQueryOptionsTest.java @@ -0,0 +1,64 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateTrainingQueryOptions model. */ +public class CreateTrainingQueryOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateTrainingQueryOptions() throws Throwable { + TrainingExample trainingExampleModel = + new TrainingExample.Builder() + .documentId("testString") + .collectionId("testString") + .relevance(Long.valueOf("26")) + .build(); + assertEquals(trainingExampleModel.documentId(), "testString"); + assertEquals(trainingExampleModel.collectionId(), "testString"); + assertEquals(trainingExampleModel.relevance(), Long.valueOf("26")); + + CreateTrainingQueryOptions createTrainingQueryOptionsModel = + new CreateTrainingQueryOptions.Builder() + .projectId("testString") + .naturalLanguageQuery("testString") + .examples( + new java.util.ArrayList( + java.util.Arrays.asList(trainingExampleModel))) + .filter("testString") + .build(); + assertEquals(createTrainingQueryOptionsModel.projectId(), "testString"); + assertEquals(createTrainingQueryOptionsModel.naturalLanguageQuery(), "testString"); + assertEquals( + createTrainingQueryOptionsModel.examples(), + new java.util.ArrayList(java.util.Arrays.asList(trainingExampleModel))); + assertEquals(createTrainingQueryOptionsModel.filter(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateTrainingQueryOptionsError() throws Throwable { + new CreateTrainingQueryOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DefaultQueryParamsPassagesTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DefaultQueryParamsPassagesTest.java new file mode 100644 index 00000000000..012393dbd37 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DefaultQueryParamsPassagesTest.java @@ -0,0 +1,62 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DefaultQueryParamsPassages model. */ +public class DefaultQueryParamsPassagesTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDefaultQueryParamsPassages() throws Throwable { + DefaultQueryParamsPassages defaultQueryParamsPassagesModel = + new DefaultQueryParamsPassages.Builder() + .enabled(true) + .count(Long.valueOf("26")) + .fields(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .characters(Long.valueOf("26")) + .perDocument(true) + .maxPerDocument(Long.valueOf("26")) + .build(); + assertEquals(defaultQueryParamsPassagesModel.enabled(), Boolean.valueOf(true)); + assertEquals(defaultQueryParamsPassagesModel.count(), Long.valueOf("26")); + assertEquals( + defaultQueryParamsPassagesModel.fields(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals(defaultQueryParamsPassagesModel.characters(), Long.valueOf("26")); + assertEquals(defaultQueryParamsPassagesModel.perDocument(), Boolean.valueOf(true)); + assertEquals(defaultQueryParamsPassagesModel.maxPerDocument(), Long.valueOf("26")); + + String json = TestUtilities.serialize(defaultQueryParamsPassagesModel); + + DefaultQueryParamsPassages defaultQueryParamsPassagesModelNew = + TestUtilities.deserialize(json, DefaultQueryParamsPassages.class); + assertTrue(defaultQueryParamsPassagesModelNew instanceof DefaultQueryParamsPassages); + assertEquals(defaultQueryParamsPassagesModelNew.enabled(), Boolean.valueOf(true)); + assertEquals(defaultQueryParamsPassagesModelNew.count(), Long.valueOf("26")); + assertEquals(defaultQueryParamsPassagesModelNew.characters(), Long.valueOf("26")); + assertEquals(defaultQueryParamsPassagesModelNew.perDocument(), Boolean.valueOf(true)); + assertEquals(defaultQueryParamsPassagesModelNew.maxPerDocument(), Long.valueOf("26")); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DefaultQueryParamsSuggestedRefinementsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DefaultQueryParamsSuggestedRefinementsTest.java new file mode 100644 index 00000000000..a2e29f25abd --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DefaultQueryParamsSuggestedRefinementsTest.java @@ -0,0 +1,51 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DefaultQueryParamsSuggestedRefinements model. */ +public class DefaultQueryParamsSuggestedRefinementsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDefaultQueryParamsSuggestedRefinements() throws Throwable { + DefaultQueryParamsSuggestedRefinements defaultQueryParamsSuggestedRefinementsModel = + new DefaultQueryParamsSuggestedRefinements.Builder() + .enabled(true) + .count(Long.valueOf("26")) + .build(); + assertEquals(defaultQueryParamsSuggestedRefinementsModel.enabled(), Boolean.valueOf(true)); + assertEquals(defaultQueryParamsSuggestedRefinementsModel.count(), Long.valueOf("26")); + + String json = TestUtilities.serialize(defaultQueryParamsSuggestedRefinementsModel); + + DefaultQueryParamsSuggestedRefinements defaultQueryParamsSuggestedRefinementsModelNew = + TestUtilities.deserialize(json, DefaultQueryParamsSuggestedRefinements.class); + assertTrue( + defaultQueryParamsSuggestedRefinementsModelNew + instanceof DefaultQueryParamsSuggestedRefinements); + assertEquals(defaultQueryParamsSuggestedRefinementsModelNew.enabled(), Boolean.valueOf(true)); + assertEquals(defaultQueryParamsSuggestedRefinementsModelNew.count(), Long.valueOf("26")); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DefaultQueryParamsTableResultsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DefaultQueryParamsTableResultsTest.java new file mode 100644 index 00000000000..33cc6d3cb59 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DefaultQueryParamsTableResultsTest.java @@ -0,0 +1,52 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DefaultQueryParamsTableResults model. */ +public class DefaultQueryParamsTableResultsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDefaultQueryParamsTableResults() throws Throwable { + DefaultQueryParamsTableResults defaultQueryParamsTableResultsModel = + new DefaultQueryParamsTableResults.Builder() + .enabled(true) + .count(Long.valueOf("26")) + .perDocument(Long.valueOf("26")) + .build(); + assertEquals(defaultQueryParamsTableResultsModel.enabled(), Boolean.valueOf(true)); + assertEquals(defaultQueryParamsTableResultsModel.count(), Long.valueOf("26")); + assertEquals(defaultQueryParamsTableResultsModel.perDocument(), Long.valueOf("26")); + + String json = TestUtilities.serialize(defaultQueryParamsTableResultsModel); + + DefaultQueryParamsTableResults defaultQueryParamsTableResultsModelNew = + TestUtilities.deserialize(json, DefaultQueryParamsTableResults.class); + assertTrue(defaultQueryParamsTableResultsModelNew instanceof DefaultQueryParamsTableResults); + assertEquals(defaultQueryParamsTableResultsModelNew.enabled(), Boolean.valueOf(true)); + assertEquals(defaultQueryParamsTableResultsModelNew.count(), Long.valueOf("26")); + assertEquals(defaultQueryParamsTableResultsModelNew.perDocument(), Long.valueOf("26")); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DefaultQueryParamsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DefaultQueryParamsTest.java new file mode 100644 index 00000000000..c70d46f6138 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DefaultQueryParamsTest.java @@ -0,0 +1,119 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DefaultQueryParams model. */ +public class DefaultQueryParamsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDefaultQueryParams() throws Throwable { + DefaultQueryParamsPassages defaultQueryParamsPassagesModel = + new DefaultQueryParamsPassages.Builder() + .enabled(true) + .count(Long.valueOf("26")) + .fields(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .characters(Long.valueOf("26")) + .perDocument(true) + .maxPerDocument(Long.valueOf("26")) + .build(); + assertEquals(defaultQueryParamsPassagesModel.enabled(), Boolean.valueOf(true)); + assertEquals(defaultQueryParamsPassagesModel.count(), Long.valueOf("26")); + assertEquals( + defaultQueryParamsPassagesModel.fields(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals(defaultQueryParamsPassagesModel.characters(), Long.valueOf("26")); + assertEquals(defaultQueryParamsPassagesModel.perDocument(), Boolean.valueOf(true)); + assertEquals(defaultQueryParamsPassagesModel.maxPerDocument(), Long.valueOf("26")); + + DefaultQueryParamsTableResults defaultQueryParamsTableResultsModel = + new DefaultQueryParamsTableResults.Builder() + .enabled(true) + .count(Long.valueOf("26")) + .perDocument(Long.valueOf("26")) + .build(); + assertEquals(defaultQueryParamsTableResultsModel.enabled(), Boolean.valueOf(true)); + assertEquals(defaultQueryParamsTableResultsModel.count(), Long.valueOf("26")); + assertEquals(defaultQueryParamsTableResultsModel.perDocument(), Long.valueOf("26")); + + DefaultQueryParamsSuggestedRefinements defaultQueryParamsSuggestedRefinementsModel = + new DefaultQueryParamsSuggestedRefinements.Builder() + .enabled(true) + .count(Long.valueOf("26")) + .build(); + assertEquals(defaultQueryParamsSuggestedRefinementsModel.enabled(), Boolean.valueOf(true)); + assertEquals(defaultQueryParamsSuggestedRefinementsModel.count(), Long.valueOf("26")); + + DefaultQueryParams defaultQueryParamsModel = + new DefaultQueryParams.Builder() + .collectionIds(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .passages(defaultQueryParamsPassagesModel) + .tableResults(defaultQueryParamsTableResultsModel) + .aggregation("testString") + .suggestedRefinements(defaultQueryParamsSuggestedRefinementsModel) + .spellingSuggestions(true) + .highlight(true) + .count(Long.valueOf("26")) + .sort("testString") + .xReturn(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals( + defaultQueryParamsModel.collectionIds(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals(defaultQueryParamsModel.passages(), defaultQueryParamsPassagesModel); + assertEquals(defaultQueryParamsModel.tableResults(), defaultQueryParamsTableResultsModel); + assertEquals(defaultQueryParamsModel.aggregation(), "testString"); + assertEquals( + defaultQueryParamsModel.suggestedRefinements(), + defaultQueryParamsSuggestedRefinementsModel); + assertEquals(defaultQueryParamsModel.spellingSuggestions(), Boolean.valueOf(true)); + assertEquals(defaultQueryParamsModel.highlight(), Boolean.valueOf(true)); + assertEquals(defaultQueryParamsModel.count(), Long.valueOf("26")); + assertEquals(defaultQueryParamsModel.sort(), "testString"); + assertEquals( + defaultQueryParamsModel.xReturn(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + String json = TestUtilities.serialize(defaultQueryParamsModel); + + DefaultQueryParams defaultQueryParamsModelNew = + TestUtilities.deserialize(json, DefaultQueryParams.class); + assertTrue(defaultQueryParamsModelNew instanceof DefaultQueryParams); + assertEquals( + defaultQueryParamsModelNew.passages().toString(), + defaultQueryParamsPassagesModel.toString()); + assertEquals( + defaultQueryParamsModelNew.tableResults().toString(), + defaultQueryParamsTableResultsModel.toString()); + assertEquals(defaultQueryParamsModelNew.aggregation(), "testString"); + assertEquals( + defaultQueryParamsModelNew.suggestedRefinements().toString(), + defaultQueryParamsSuggestedRefinementsModel.toString()); + assertEquals(defaultQueryParamsModelNew.spellingSuggestions(), Boolean.valueOf(true)); + assertEquals(defaultQueryParamsModelNew.highlight(), Boolean.valueOf(true)); + assertEquals(defaultQueryParamsModelNew.count(), Long.valueOf("26")); + assertEquals(defaultQueryParamsModelNew.sort(), "testString"); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteCollectionOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteCollectionOptionsTest.java new file mode 100644 index 00000000000..ca7118f4e5c --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteCollectionOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteCollectionOptions model. */ +public class DeleteCollectionOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteCollectionOptions() throws Throwable { + DeleteCollectionOptions deleteCollectionOptionsModel = + new DeleteCollectionOptions.Builder() + .projectId("testString") + .collectionId("testString") + .build(); + assertEquals(deleteCollectionOptionsModel.projectId(), "testString"); + assertEquals(deleteCollectionOptionsModel.collectionId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteCollectionOptionsError() throws Throwable { + new DeleteCollectionOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteDocumentOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteDocumentOptionsTest.java new file mode 100644 index 00000000000..b5ec74c3d63 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteDocumentOptionsTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteDocumentOptions model. */ +public class DeleteDocumentOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteDocumentOptions() throws Throwable { + DeleteDocumentOptions deleteDocumentOptionsModel = + new DeleteDocumentOptions.Builder() + .projectId("testString") + .collectionId("testString") + .documentId("testString") + .xWatsonDiscoveryForce(true) + .build(); + assertEquals(deleteDocumentOptionsModel.projectId(), "testString"); + assertEquals(deleteDocumentOptionsModel.collectionId(), "testString"); + assertEquals(deleteDocumentOptionsModel.documentId(), "testString"); + assertEquals(deleteDocumentOptionsModel.xWatsonDiscoveryForce(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteDocumentOptionsError() throws Throwable { + new DeleteDocumentOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteDocumentResponseTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteDocumentResponseTest.java new file mode 100644 index 00000000000..36c8d72d86c --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteDocumentResponseTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteDocumentResponse model. */ +public class DeleteDocumentResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteDocumentResponse() throws Throwable { + DeleteDocumentResponse deleteDocumentResponseModel = new DeleteDocumentResponse(); + assertNull(deleteDocumentResponseModel.getDocumentId()); + assertNull(deleteDocumentResponseModel.getStatus()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteEnrichmentOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteEnrichmentOptionsTest.java new file mode 100644 index 00000000000..cb0e5863094 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteEnrichmentOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteEnrichmentOptions model. */ +public class DeleteEnrichmentOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteEnrichmentOptions() throws Throwable { + DeleteEnrichmentOptions deleteEnrichmentOptionsModel = + new DeleteEnrichmentOptions.Builder() + .projectId("testString") + .enrichmentId("testString") + .build(); + assertEquals(deleteEnrichmentOptionsModel.projectId(), "testString"); + assertEquals(deleteEnrichmentOptionsModel.enrichmentId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteEnrichmentOptionsError() throws Throwable { + new DeleteEnrichmentOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteProjectOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteProjectOptionsTest.java new file mode 100644 index 00000000000..8e3f7ab64f0 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteProjectOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteProjectOptions model. */ +public class DeleteProjectOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteProjectOptions() throws Throwable { + DeleteProjectOptions deleteProjectOptionsModel = + new DeleteProjectOptions.Builder().projectId("testString").build(); + assertEquals(deleteProjectOptionsModel.projectId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteProjectOptionsError() throws Throwable { + new DeleteProjectOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteTrainingQueriesOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteTrainingQueriesOptionsTest.java new file mode 100644 index 00000000000..305cd243ea1 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteTrainingQueriesOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteTrainingQueriesOptions model. */ +public class DeleteTrainingQueriesOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteTrainingQueriesOptions() throws Throwable { + DeleteTrainingQueriesOptions deleteTrainingQueriesOptionsModel = + new DeleteTrainingQueriesOptions.Builder().projectId("testString").build(); + assertEquals(deleteTrainingQueriesOptionsModel.projectId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteTrainingQueriesOptionsError() throws Throwable { + new DeleteTrainingQueriesOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteUserDataOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteUserDataOptionsTest.java new file mode 100644 index 00000000000..6a438e77c35 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DeleteUserDataOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteUserDataOptions model. */ +public class DeleteUserDataOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteUserDataOptions() throws Throwable { + DeleteUserDataOptions deleteUserDataOptionsModel = + new DeleteUserDataOptions.Builder().customerId("testString").build(); + assertEquals(deleteUserDataOptionsModel.customerId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteUserDataOptionsError() throws Throwable { + new DeleteUserDataOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DocumentAcceptedTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DocumentAcceptedTest.java new file mode 100644 index 00000000000..81ba8672f59 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DocumentAcceptedTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DocumentAccepted model. */ +public class DocumentAcceptedTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDocumentAccepted() throws Throwable { + DocumentAccepted documentAcceptedModel = new DocumentAccepted(); + assertNull(documentAcceptedModel.getDocumentId()); + assertNull(documentAcceptedModel.getStatus()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DocumentAttributeTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DocumentAttributeTest.java new file mode 100644 index 00000000000..407e14dfba9 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/DocumentAttributeTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DocumentAttribute model. */ +public class DocumentAttributeTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDocumentAttribute() throws Throwable { + DocumentAttribute documentAttributeModel = new DocumentAttribute(); + assertNull(documentAttributeModel.getType()); + assertNull(documentAttributeModel.getText()); + assertNull(documentAttributeModel.getLocation()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/EnrichmentOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/EnrichmentOptionsTest.java new file mode 100644 index 00000000000..cf26d311d82 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/EnrichmentOptionsTest.java @@ -0,0 +1,56 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the EnrichmentOptions model. */ +public class EnrichmentOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testEnrichmentOptions() throws Throwable { + EnrichmentOptions enrichmentOptionsModel = + new EnrichmentOptions.Builder() + .languages(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .entityType("testString") + .regularExpression("testString") + .resultField("testString") + .build(); + assertEquals( + enrichmentOptionsModel.languages(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals(enrichmentOptionsModel.entityType(), "testString"); + assertEquals(enrichmentOptionsModel.regularExpression(), "testString"); + assertEquals(enrichmentOptionsModel.resultField(), "testString"); + + String json = TestUtilities.serialize(enrichmentOptionsModel); + + EnrichmentOptions enrichmentOptionsModelNew = + TestUtilities.deserialize(json, EnrichmentOptions.class); + assertTrue(enrichmentOptionsModelNew instanceof EnrichmentOptions); + assertEquals(enrichmentOptionsModelNew.entityType(), "testString"); + assertEquals(enrichmentOptionsModelNew.regularExpression(), "testString"); + assertEquals(enrichmentOptionsModelNew.resultField(), "testString"); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/EnrichmentTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/EnrichmentTest.java new file mode 100644 index 00000000000..0917d5f64ab --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/EnrichmentTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Enrichment model. */ +public class EnrichmentTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testEnrichment() throws Throwable { + Enrichment enrichmentModel = new Enrichment(); + assertNull(enrichmentModel.getName()); + assertNull(enrichmentModel.getDescription()); + assertNull(enrichmentModel.getType()); + assertNull(enrichmentModel.getOptions()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/EnrichmentsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/EnrichmentsTest.java new file mode 100644 index 00000000000..fa30fe0a77e --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/EnrichmentsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Enrichments model. */ +public class EnrichmentsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testEnrichments() throws Throwable { + Enrichments enrichmentsModel = new Enrichments(); + assertNull(enrichmentsModel.getEnrichments()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/FieldTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/FieldTest.java new file mode 100644 index 00000000000..f03b656056b --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/FieldTest.java @@ -0,0 +1,35 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Field model. */ +public class FieldTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testField() throws Throwable { + Field fieldModel = new Field(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/GetAutocompletionOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/GetAutocompletionOptionsTest.java new file mode 100644 index 00000000000..bbb3e3a6e93 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/GetAutocompletionOptionsTest.java @@ -0,0 +1,54 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetAutocompletionOptions model. */ +public class GetAutocompletionOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetAutocompletionOptions() throws Throwable { + GetAutocompletionOptions getAutocompletionOptionsModel = + new GetAutocompletionOptions.Builder() + .projectId("testString") + .prefix("testString") + .collectionIds(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .field("testString") + .count(Long.valueOf("26")) + .build(); + assertEquals(getAutocompletionOptionsModel.projectId(), "testString"); + assertEquals(getAutocompletionOptionsModel.prefix(), "testString"); + assertEquals( + getAutocompletionOptionsModel.collectionIds(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals(getAutocompletionOptionsModel.field(), "testString"); + assertEquals(getAutocompletionOptionsModel.count(), Long.valueOf("26")); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetAutocompletionOptionsError() throws Throwable { + new GetAutocompletionOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/GetCollectionOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/GetCollectionOptionsTest.java new file mode 100644 index 00000000000..e7b928aadc4 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/GetCollectionOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetCollectionOptions model. */ +public class GetCollectionOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetCollectionOptions() throws Throwable { + GetCollectionOptions getCollectionOptionsModel = + new GetCollectionOptions.Builder() + .projectId("testString") + .collectionId("testString") + .build(); + assertEquals(getCollectionOptionsModel.projectId(), "testString"); + assertEquals(getCollectionOptionsModel.collectionId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetCollectionOptionsError() throws Throwable { + new GetCollectionOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/GetComponentSettingsOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/GetComponentSettingsOptionsTest.java new file mode 100644 index 00000000000..a79b461c38f --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/GetComponentSettingsOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetComponentSettingsOptions model. */ +public class GetComponentSettingsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetComponentSettingsOptions() throws Throwable { + GetComponentSettingsOptions getComponentSettingsOptionsModel = + new GetComponentSettingsOptions.Builder().projectId("testString").build(); + assertEquals(getComponentSettingsOptionsModel.projectId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetComponentSettingsOptionsError() throws Throwable { + new GetComponentSettingsOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/GetEnrichmentOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/GetEnrichmentOptionsTest.java new file mode 100644 index 00000000000..c6231fde743 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/GetEnrichmentOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetEnrichmentOptions model. */ +public class GetEnrichmentOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetEnrichmentOptions() throws Throwable { + GetEnrichmentOptions getEnrichmentOptionsModel = + new GetEnrichmentOptions.Builder() + .projectId("testString") + .enrichmentId("testString") + .build(); + assertEquals(getEnrichmentOptionsModel.projectId(), "testString"); + assertEquals(getEnrichmentOptionsModel.enrichmentId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetEnrichmentOptionsError() throws Throwable { + new GetEnrichmentOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/GetProjectOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/GetProjectOptionsTest.java new file mode 100644 index 00000000000..bca7bac326d --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/GetProjectOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetProjectOptions model. */ +public class GetProjectOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetProjectOptions() throws Throwable { + GetProjectOptions getProjectOptionsModel = + new GetProjectOptions.Builder().projectId("testString").build(); + assertEquals(getProjectOptionsModel.projectId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetProjectOptionsError() throws Throwable { + new GetProjectOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/GetTrainingQueryOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/GetTrainingQueryOptionsTest.java new file mode 100644 index 00000000000..49d3cf2a688 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/GetTrainingQueryOptionsTest.java @@ -0,0 +1,43 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetTrainingQueryOptions model. */ +public class GetTrainingQueryOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetTrainingQueryOptions() throws Throwable { + GetTrainingQueryOptions getTrainingQueryOptionsModel = + new GetTrainingQueryOptions.Builder().projectId("testString").queryId("testString").build(); + assertEquals(getTrainingQueryOptionsModel.projectId(), "testString"); + assertEquals(getTrainingQueryOptionsModel.queryId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetTrainingQueryOptionsError() throws Throwable { + new GetTrainingQueryOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListCollectionsOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListCollectionsOptionsTest.java new file mode 100644 index 00000000000..f8f76b0e482 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListCollectionsOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListCollectionsOptions model. */ +public class ListCollectionsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListCollectionsOptions() throws Throwable { + ListCollectionsOptions listCollectionsOptionsModel = + new ListCollectionsOptions.Builder().projectId("testString").build(); + assertEquals(listCollectionsOptionsModel.projectId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListCollectionsOptionsError() throws Throwable { + new ListCollectionsOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListCollectionsResponseTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListCollectionsResponseTest.java new file mode 100644 index 00000000000..e6c84f0e7e2 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListCollectionsResponseTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListCollectionsResponse model. */ +public class ListCollectionsResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListCollectionsResponse() throws Throwable { + ListCollectionsResponse listCollectionsResponseModel = new ListCollectionsResponse(); + assertNull(listCollectionsResponseModel.getCollections()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListEnrichmentsOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListEnrichmentsOptionsTest.java new file mode 100644 index 00000000000..1351210c48f --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListEnrichmentsOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListEnrichmentsOptions model. */ +public class ListEnrichmentsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListEnrichmentsOptions() throws Throwable { + ListEnrichmentsOptions listEnrichmentsOptionsModel = + new ListEnrichmentsOptions.Builder().projectId("testString").build(); + assertEquals(listEnrichmentsOptionsModel.projectId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListEnrichmentsOptionsError() throws Throwable { + new ListEnrichmentsOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListFieldsOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListFieldsOptionsTest.java new file mode 100644 index 00000000000..3c7ddbc78b6 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListFieldsOptionsTest.java @@ -0,0 +1,48 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListFieldsOptions model. */ +public class ListFieldsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListFieldsOptions() throws Throwable { + ListFieldsOptions listFieldsOptionsModel = + new ListFieldsOptions.Builder() + .projectId("testString") + .collectionIds(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals(listFieldsOptionsModel.projectId(), "testString"); + assertEquals( + listFieldsOptionsModel.collectionIds(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListFieldsOptionsError() throws Throwable { + new ListFieldsOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListFieldsResponseTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListFieldsResponseTest.java new file mode 100644 index 00000000000..2a806ec1beb --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListFieldsResponseTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListFieldsResponse model. */ +public class ListFieldsResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListFieldsResponse() throws Throwable { + ListFieldsResponse listFieldsResponseModel = new ListFieldsResponse(); + assertNull(listFieldsResponseModel.getFields()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListProjectsOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListProjectsOptionsTest.java new file mode 100644 index 00000000000..8714d67e7e7 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListProjectsOptionsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListProjectsOptions model. */ +public class ListProjectsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListProjectsOptions() throws Throwable { + ListProjectsOptions listProjectsOptionsModel = new ListProjectsOptions(); + assertNotNull(listProjectsOptionsModel); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListProjectsResponseTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListProjectsResponseTest.java new file mode 100644 index 00000000000..d4554029e5a --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListProjectsResponseTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListProjectsResponse model. */ +public class ListProjectsResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListProjectsResponse() throws Throwable { + ListProjectsResponse listProjectsResponseModel = new ListProjectsResponse(); + assertNull(listProjectsResponseModel.getProjects()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListTrainingQueriesOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListTrainingQueriesOptionsTest.java new file mode 100644 index 00000000000..1c7369fe48a --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ListTrainingQueriesOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListTrainingQueriesOptions model. */ +public class ListTrainingQueriesOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListTrainingQueriesOptions() throws Throwable { + ListTrainingQueriesOptions listTrainingQueriesOptionsModel = + new ListTrainingQueriesOptions.Builder().projectId("testString").build(); + assertEquals(listTrainingQueriesOptionsModel.projectId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListTrainingQueriesOptionsError() throws Throwable { + new ListTrainingQueriesOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/NoticeTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/NoticeTest.java new file mode 100644 index 00000000000..056e74902cf --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/NoticeTest.java @@ -0,0 +1,35 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Notice model. */ +public class NoticeTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testNotice() throws Throwable { + Notice noticeModel = new Notice(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ProjectDetailsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ProjectDetailsTest.java new file mode 100644 index 00000000000..8b2fb4f3832 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ProjectDetailsTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ProjectDetails model. */ +public class ProjectDetailsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testProjectDetails() throws Throwable { + ProjectDetails projectDetailsModel = new ProjectDetails(); + assertNull(projectDetailsModel.getName()); + assertNull(projectDetailsModel.getType()); + assertNull(projectDetailsModel.getRelevancyTrainingStatus()); + assertNull(projectDetailsModel.getDefaultQueryParameters()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ProjectListDetailsRelevancyTrainingStatusTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ProjectListDetailsRelevancyTrainingStatusTest.java new file mode 100644 index 00000000000..a5003e9472a --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ProjectListDetailsRelevancyTrainingStatusTest.java @@ -0,0 +1,45 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ProjectListDetailsRelevancyTrainingStatus model. */ +public class ProjectListDetailsRelevancyTrainingStatusTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testProjectListDetailsRelevancyTrainingStatus() throws Throwable { + ProjectListDetailsRelevancyTrainingStatus projectListDetailsRelevancyTrainingStatusModel = + new ProjectListDetailsRelevancyTrainingStatus(); + assertNull(projectListDetailsRelevancyTrainingStatusModel.getDataUpdated()); + assertNull(projectListDetailsRelevancyTrainingStatusModel.getTotalExamples()); + assertNull(projectListDetailsRelevancyTrainingStatusModel.isSufficientLabelDiversity()); + assertNull(projectListDetailsRelevancyTrainingStatusModel.isProcessing()); + assertNull(projectListDetailsRelevancyTrainingStatusModel.isMinimumExamplesAdded()); + assertNull(projectListDetailsRelevancyTrainingStatusModel.getSuccessfullyTrained()); + assertNull(projectListDetailsRelevancyTrainingStatusModel.isAvailable()); + assertNull(projectListDetailsRelevancyTrainingStatusModel.getNotices()); + assertNull(projectListDetailsRelevancyTrainingStatusModel.isMinimumQueriesAdded()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ProjectListDetailsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ProjectListDetailsTest.java new file mode 100644 index 00000000000..ccde68ed6de --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/ProjectListDetailsTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ProjectListDetails model. */ +public class ProjectListDetailsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testProjectListDetails() throws Throwable { + ProjectListDetails projectListDetailsModel = new ProjectListDetails(); + assertNull(projectListDetailsModel.getName()); + assertNull(projectListDetailsModel.getType()); + assertNull(projectListDetailsModel.getRelevancyTrainingStatus()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryAggregationTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryAggregationTest.java new file mode 100644 index 00000000000..f80d8082bd6 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryAggregationTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryAggregation model. */ +public class QueryAggregationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + // TODO: Add tests for models that are abstract + @Test + public void testQueryAggregation() throws Throwable { + QueryAggregation queryAggregationModel = new QueryAggregation(); + assertNotNull(queryAggregationModel); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryCalculationAggregationTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryCalculationAggregationTest.java new file mode 100644 index 00000000000..791167ae28e --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryCalculationAggregationTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryCalculationAggregation model. */ +public class QueryCalculationAggregationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryCalculationAggregation() throws Throwable { + QueryCalculationAggregation queryCalculationAggregationModel = + new QueryCalculationAggregation(); + assertNull(queryCalculationAggregationModel.getType()); + assertNull(queryCalculationAggregationModel.getField()); + assertNull(queryCalculationAggregationModel.getValue()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryFilterAggregationTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryFilterAggregationTest.java new file mode 100644 index 00000000000..9654f867f9e --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryFilterAggregationTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryFilterAggregation model. */ +public class QueryFilterAggregationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryFilterAggregation() throws Throwable { + QueryFilterAggregation queryFilterAggregationModel = new QueryFilterAggregation(); + assertNull(queryFilterAggregationModel.getType()); + assertNull(queryFilterAggregationModel.getMatch()); + assertNull(queryFilterAggregationModel.getMatchingResults()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryGroupByAggregationResultTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryGroupByAggregationResultTest.java new file mode 100644 index 00000000000..c92624481c8 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryGroupByAggregationResultTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryGroupByAggregationResult model. */ +public class QueryGroupByAggregationResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryGroupByAggregationResult() throws Throwable { + QueryGroupByAggregationResult queryGroupByAggregationResultModel = + new QueryGroupByAggregationResult(); + assertNull(queryGroupByAggregationResultModel.getKey()); + assertNull(queryGroupByAggregationResultModel.getMatchingResults()); + assertNull(queryGroupByAggregationResultModel.getRelevancy()); + assertNull(queryGroupByAggregationResultModel.getTotalMatchingDocuments()); + assertNull(queryGroupByAggregationResultModel.getEstimatedMatchingDocuments()); + assertNull(queryGroupByAggregationResultModel.getAggregations()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryGroupByAggregationTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryGroupByAggregationTest.java new file mode 100644 index 00000000000..5e36a7ddac7 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryGroupByAggregationTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryGroupByAggregation model. */ +public class QueryGroupByAggregationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryGroupByAggregation() throws Throwable { + QueryGroupByAggregation queryGroupByAggregationModel = new QueryGroupByAggregation(); + assertNull(queryGroupByAggregationModel.getType()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryHistogramAggregationResultTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryHistogramAggregationResultTest.java new file mode 100644 index 00000000000..3969522405b --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryHistogramAggregationResultTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryHistogramAggregationResult model. */ +public class QueryHistogramAggregationResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryHistogramAggregationResult() throws Throwable { + QueryHistogramAggregationResult queryHistogramAggregationResultModel = + new QueryHistogramAggregationResult(); + assertNull(queryHistogramAggregationResultModel.getKey()); + assertNull(queryHistogramAggregationResultModel.getMatchingResults()); + assertNull(queryHistogramAggregationResultModel.getAggregations()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryHistogramAggregationTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryHistogramAggregationTest.java new file mode 100644 index 00000000000..c65e1f0788f --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryHistogramAggregationTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryHistogramAggregation model. */ +public class QueryHistogramAggregationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryHistogramAggregation() throws Throwable { + QueryHistogramAggregation queryHistogramAggregationModel = new QueryHistogramAggregation(); + assertNull(queryHistogramAggregationModel.getType()); + assertNull(queryHistogramAggregationModel.getField()); + assertNull(queryHistogramAggregationModel.getInterval()); + assertNull(queryHistogramAggregationModel.getName()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryLargePassagesTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryLargePassagesTest.java new file mode 100644 index 00000000000..235e994505c --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryLargePassagesTest.java @@ -0,0 +1,62 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryLargePassages model. */ +public class QueryLargePassagesTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryLargePassages() throws Throwable { + QueryLargePassages queryLargePassagesModel = + new QueryLargePassages.Builder() + .enabled(true) + .perDocument(true) + .maxPerDocument(Long.valueOf("26")) + .fields(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .count(Long.valueOf("100")) + .characters(Long.valueOf("50")) + .build(); + assertEquals(queryLargePassagesModel.enabled(), Boolean.valueOf(true)); + assertEquals(queryLargePassagesModel.perDocument(), Boolean.valueOf(true)); + assertEquals(queryLargePassagesModel.maxPerDocument(), Long.valueOf("26")); + assertEquals( + queryLargePassagesModel.fields(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals(queryLargePassagesModel.count(), Long.valueOf("100")); + assertEquals(queryLargePassagesModel.characters(), Long.valueOf("50")); + + String json = TestUtilities.serialize(queryLargePassagesModel); + + QueryLargePassages queryLargePassagesModelNew = + TestUtilities.deserialize(json, QueryLargePassages.class); + assertTrue(queryLargePassagesModelNew instanceof QueryLargePassages); + assertEquals(queryLargePassagesModelNew.enabled(), Boolean.valueOf(true)); + assertEquals(queryLargePassagesModelNew.perDocument(), Boolean.valueOf(true)); + assertEquals(queryLargePassagesModelNew.maxPerDocument(), Long.valueOf("26")); + assertEquals(queryLargePassagesModelNew.count(), Long.valueOf("100")); + assertEquals(queryLargePassagesModelNew.characters(), Long.valueOf("50")); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryLargeSuggestedRefinementsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryLargeSuggestedRefinementsTest.java new file mode 100644 index 00000000000..09ebb92dd85 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryLargeSuggestedRefinementsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryLargeSuggestedRefinements model. */ +public class QueryLargeSuggestedRefinementsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryLargeSuggestedRefinements() throws Throwable { + QueryLargeSuggestedRefinements queryLargeSuggestedRefinementsModel = + new QueryLargeSuggestedRefinements.Builder().enabled(true).count(Long.valueOf("1")).build(); + assertEquals(queryLargeSuggestedRefinementsModel.enabled(), Boolean.valueOf(true)); + assertEquals(queryLargeSuggestedRefinementsModel.count(), Long.valueOf("1")); + + String json = TestUtilities.serialize(queryLargeSuggestedRefinementsModel); + + QueryLargeSuggestedRefinements queryLargeSuggestedRefinementsModelNew = + TestUtilities.deserialize(json, QueryLargeSuggestedRefinements.class); + assertTrue(queryLargeSuggestedRefinementsModelNew instanceof QueryLargeSuggestedRefinements); + assertEquals(queryLargeSuggestedRefinementsModelNew.enabled(), Boolean.valueOf(true)); + assertEquals(queryLargeSuggestedRefinementsModelNew.count(), Long.valueOf("1")); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryLargeTableResultsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryLargeTableResultsTest.java new file mode 100644 index 00000000000..37f037d84ec --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryLargeTableResultsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryLargeTableResults model. */ +public class QueryLargeTableResultsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryLargeTableResults() throws Throwable { + QueryLargeTableResults queryLargeTableResultsModel = + new QueryLargeTableResults.Builder().enabled(true).count(Long.valueOf("26")).build(); + assertEquals(queryLargeTableResultsModel.enabled(), Boolean.valueOf(true)); + assertEquals(queryLargeTableResultsModel.count(), Long.valueOf("26")); + + String json = TestUtilities.serialize(queryLargeTableResultsModel); + + QueryLargeTableResults queryLargeTableResultsModelNew = + TestUtilities.deserialize(json, QueryLargeTableResults.class); + assertTrue(queryLargeTableResultsModelNew instanceof QueryLargeTableResults); + assertEquals(queryLargeTableResultsModelNew.enabled(), Boolean.valueOf(true)); + assertEquals(queryLargeTableResultsModelNew.count(), Long.valueOf("26")); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryNestedAggregationTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryNestedAggregationTest.java new file mode 100644 index 00000000000..36346ecd1ce --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryNestedAggregationTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryNestedAggregation model. */ +public class QueryNestedAggregationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryNestedAggregation() throws Throwable { + QueryNestedAggregation queryNestedAggregationModel = new QueryNestedAggregation(); + assertNull(queryNestedAggregationModel.getType()); + assertNull(queryNestedAggregationModel.getPath()); + assertNull(queryNestedAggregationModel.getMatchingResults()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryNoticesOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryNoticesOptionsTest.java new file mode 100644 index 00000000000..cd6840c1400 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryNoticesOptionsTest.java @@ -0,0 +1,54 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryNoticesOptions model. */ +public class QueryNoticesOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryNoticesOptions() throws Throwable { + QueryNoticesOptions queryNoticesOptionsModel = + new QueryNoticesOptions.Builder() + .projectId("testString") + .filter("testString") + .query("testString") + .naturalLanguageQuery("testString") + .count(Long.valueOf("26")) + .offset(Long.valueOf("26")) + .build(); + assertEquals(queryNoticesOptionsModel.projectId(), "testString"); + assertEquals(queryNoticesOptionsModel.filter(), "testString"); + assertEquals(queryNoticesOptionsModel.query(), "testString"); + assertEquals(queryNoticesOptionsModel.naturalLanguageQuery(), "testString"); + assertEquals(queryNoticesOptionsModel.count(), Long.valueOf("26")); + assertEquals(queryNoticesOptionsModel.offset(), Long.valueOf("26")); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testQueryNoticesOptionsError() throws Throwable { + new QueryNoticesOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryNoticesResponseTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryNoticesResponseTest.java new file mode 100644 index 00000000000..62a8db72078 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryNoticesResponseTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryNoticesResponse model. */ +public class QueryNoticesResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryNoticesResponse() throws Throwable { + QueryNoticesResponse queryNoticesResponseModel = new QueryNoticesResponse(); + assertNull(queryNoticesResponseModel.getMatchingResults()); + assertNull(queryNoticesResponseModel.getNotices()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryOptionsTest.java new file mode 100644 index 00000000000..4093eca70aa --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryOptionsTest.java @@ -0,0 +1,104 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryOptions model. */ +public class QueryOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryOptions() throws Throwable { + QueryLargeTableResults queryLargeTableResultsModel = + new QueryLargeTableResults.Builder().enabled(true).count(Long.valueOf("26")).build(); + assertEquals(queryLargeTableResultsModel.enabled(), Boolean.valueOf(true)); + assertEquals(queryLargeTableResultsModel.count(), Long.valueOf("26")); + + QueryLargeSuggestedRefinements queryLargeSuggestedRefinementsModel = + new QueryLargeSuggestedRefinements.Builder().enabled(true).count(Long.valueOf("1")).build(); + assertEquals(queryLargeSuggestedRefinementsModel.enabled(), Boolean.valueOf(true)); + assertEquals(queryLargeSuggestedRefinementsModel.count(), Long.valueOf("1")); + + QueryLargePassages queryLargePassagesModel = + new QueryLargePassages.Builder() + .enabled(true) + .perDocument(true) + .maxPerDocument(Long.valueOf("26")) + .fields(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .count(Long.valueOf("100")) + .characters(Long.valueOf("50")) + .build(); + assertEquals(queryLargePassagesModel.enabled(), Boolean.valueOf(true)); + assertEquals(queryLargePassagesModel.perDocument(), Boolean.valueOf(true)); + assertEquals(queryLargePassagesModel.maxPerDocument(), Long.valueOf("26")); + assertEquals( + queryLargePassagesModel.fields(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals(queryLargePassagesModel.count(), Long.valueOf("100")); + assertEquals(queryLargePassagesModel.characters(), Long.valueOf("50")); + + QueryOptions queryOptionsModel = + new QueryOptions.Builder() + .projectId("testString") + .collectionIds(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .filter("testString") + .query("testString") + .naturalLanguageQuery("testString") + .aggregation("testString") + .count(Long.valueOf("26")) + .xReturn(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .offset(Long.valueOf("26")) + .sort("testString") + .highlight(true) + .spellingSuggestions(true) + .tableResults(queryLargeTableResultsModel) + .suggestedRefinements(queryLargeSuggestedRefinementsModel) + .passages(queryLargePassagesModel) + .build(); + assertEquals(queryOptionsModel.projectId(), "testString"); + assertEquals( + queryOptionsModel.collectionIds(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals(queryOptionsModel.filter(), "testString"); + assertEquals(queryOptionsModel.query(), "testString"); + assertEquals(queryOptionsModel.naturalLanguageQuery(), "testString"); + assertEquals(queryOptionsModel.aggregation(), "testString"); + assertEquals(queryOptionsModel.count(), Long.valueOf("26")); + assertEquals( + queryOptionsModel.xReturn(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals(queryOptionsModel.offset(), Long.valueOf("26")); + assertEquals(queryOptionsModel.sort(), "testString"); + assertEquals(queryOptionsModel.highlight(), Boolean.valueOf(true)); + assertEquals(queryOptionsModel.spellingSuggestions(), Boolean.valueOf(true)); + assertEquals(queryOptionsModel.tableResults(), queryLargeTableResultsModel); + assertEquals(queryOptionsModel.suggestedRefinements(), queryLargeSuggestedRefinementsModel); + assertEquals(queryOptionsModel.passages(), queryLargePassagesModel); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testQueryOptionsError() throws Throwable { + new QueryOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryResponsePassageTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryResponsePassageTest.java new file mode 100644 index 00000000000..07ceeafd3de --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryResponsePassageTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryResponsePassage model. */ +public class QueryResponsePassageTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryResponsePassage() throws Throwable { + QueryResponsePassage queryResponsePassageModel = new QueryResponsePassage(); + assertNull(queryResponsePassageModel.getPassageText()); + assertNull(queryResponsePassageModel.getPassageScore()); + assertNull(queryResponsePassageModel.getDocumentId()); + assertNull(queryResponsePassageModel.getCollectionId()); + assertNull(queryResponsePassageModel.getStartOffset()); + assertNull(queryResponsePassageModel.getEndOffset()); + assertNull(queryResponsePassageModel.getField()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryResponseTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryResponseTest.java new file mode 100644 index 00000000000..2e14fce1fe2 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryResponseTest.java @@ -0,0 +1,43 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryResponse model. */ +public class QueryResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryResponse() throws Throwable { + QueryResponse queryResponseModel = new QueryResponse(); + assertNull(queryResponseModel.getMatchingResults()); + assertNull(queryResponseModel.getResults()); + assertNull(queryResponseModel.getAggregations()); + assertNull(queryResponseModel.getRetrievalDetails()); + assertNull(queryResponseModel.getSuggestedQuery()); + assertNull(queryResponseModel.getSuggestedRefinements()); + assertNull(queryResponseModel.getTableResults()); + assertNull(queryResponseModel.getPassages()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryResultMetadataTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryResultMetadataTest.java new file mode 100644 index 00000000000..801c9922f5d --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryResultMetadataTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryResultMetadata model. */ +public class QueryResultMetadataTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryResultMetadata() throws Throwable { + QueryResultMetadata queryResultMetadataModel = new QueryResultMetadata(); + assertNull(queryResultMetadataModel.getDocumentRetrievalSource()); + assertNull(queryResultMetadataModel.getCollectionId()); + assertNull(queryResultMetadataModel.getConfidence()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryResultPassageTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryResultPassageTest.java new file mode 100644 index 00000000000..75f29223494 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryResultPassageTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryResultPassage model. */ +public class QueryResultPassageTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryResultPassage() throws Throwable { + QueryResultPassage queryResultPassageModel = new QueryResultPassage(); + assertNull(queryResultPassageModel.getPassageText()); + assertNull(queryResultPassageModel.getStartOffset()); + assertNull(queryResultPassageModel.getEndOffset()); + assertNull(queryResultPassageModel.getField()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryResultTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryResultTest.java new file mode 100644 index 00000000000..610d64845ad --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryResultTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryResult model. */ +public class QueryResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryResult() throws Throwable { + QueryResult queryResultModel = new QueryResult(); + assertNull(queryResultModel.getDocumentId()); + assertNull(queryResultModel.getMetadata()); + assertNull(queryResultModel.getResultMetadata()); + assertNull(queryResultModel.getDocumentPassages()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QuerySuggestedRefinementTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QuerySuggestedRefinementTest.java new file mode 100644 index 00000000000..77f813593b2 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QuerySuggestedRefinementTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QuerySuggestedRefinement model. */ +public class QuerySuggestedRefinementTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQuerySuggestedRefinement() throws Throwable { + QuerySuggestedRefinement querySuggestedRefinementModel = new QuerySuggestedRefinement(); + assertNull(querySuggestedRefinementModel.getText()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryTableResultTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryTableResultTest.java new file mode 100644 index 00000000000..ffa96e7bf6a --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryTableResultTest.java @@ -0,0 +1,41 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryTableResult model. */ +public class QueryTableResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryTableResult() throws Throwable { + QueryTableResult queryTableResultModel = new QueryTableResult(); + assertNull(queryTableResultModel.getTableId()); + assertNull(queryTableResultModel.getSourceDocumentId()); + assertNull(queryTableResultModel.getCollectionId()); + assertNull(queryTableResultModel.getTableHtml()); + assertNull(queryTableResultModel.getTableHtmlOffset()); + assertNull(queryTableResultModel.getTable()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryTermAggregationResultTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryTermAggregationResultTest.java new file mode 100644 index 00000000000..77d875a4cd5 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryTermAggregationResultTest.java @@ -0,0 +1,41 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryTermAggregationResult model. */ +public class QueryTermAggregationResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryTermAggregationResult() throws Throwable { + QueryTermAggregationResult queryTermAggregationResultModel = new QueryTermAggregationResult(); + assertNull(queryTermAggregationResultModel.getKey()); + assertNull(queryTermAggregationResultModel.getMatchingResults()); + assertNull(queryTermAggregationResultModel.getRelevancy()); + assertNull(queryTermAggregationResultModel.getTotalMatchingDocuments()); + assertNull(queryTermAggregationResultModel.getEstimatedMatchingDocuments()); + assertNull(queryTermAggregationResultModel.getAggregations()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryTermAggregationTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryTermAggregationTest.java new file mode 100644 index 00000000000..9d850eb4bbf --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryTermAggregationTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryTermAggregation model. */ +public class QueryTermAggregationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryTermAggregation() throws Throwable { + QueryTermAggregation queryTermAggregationModel = new QueryTermAggregation(); + assertNull(queryTermAggregationModel.getType()); + assertNull(queryTermAggregationModel.getField()); + assertNull(queryTermAggregationModel.getCount()); + assertNull(queryTermAggregationModel.getName()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryTimesliceAggregationResultTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryTimesliceAggregationResultTest.java new file mode 100644 index 00000000000..62489288624 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryTimesliceAggregationResultTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryTimesliceAggregationResult model. */ +public class QueryTimesliceAggregationResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryTimesliceAggregationResult() throws Throwable { + QueryTimesliceAggregationResult queryTimesliceAggregationResultModel = + new QueryTimesliceAggregationResult(); + assertNull(queryTimesliceAggregationResultModel.getKeyAsString()); + assertNull(queryTimesliceAggregationResultModel.getKey()); + assertNull(queryTimesliceAggregationResultModel.getMatchingResults()); + assertNull(queryTimesliceAggregationResultModel.getAggregations()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryTimesliceAggregationTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryTimesliceAggregationTest.java new file mode 100644 index 00000000000..78d5ae10013 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryTimesliceAggregationTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryTimesliceAggregation model. */ +public class QueryTimesliceAggregationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryTimesliceAggregation() throws Throwable { + QueryTimesliceAggregation queryTimesliceAggregationModel = new QueryTimesliceAggregation(); + assertNull(queryTimesliceAggregationModel.getType()); + assertNull(queryTimesliceAggregationModel.getField()); + assertNull(queryTimesliceAggregationModel.getInterval()); + assertNull(queryTimesliceAggregationModel.getName()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryTopHitsAggregationResultTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryTopHitsAggregationResultTest.java new file mode 100644 index 00000000000..a39a8e0de41 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryTopHitsAggregationResultTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryTopHitsAggregationResult model. */ +public class QueryTopHitsAggregationResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryTopHitsAggregationResult() throws Throwable { + QueryTopHitsAggregationResult queryTopHitsAggregationResultModel = + new QueryTopHitsAggregationResult(); + assertNull(queryTopHitsAggregationResultModel.getMatchingResults()); + assertNull(queryTopHitsAggregationResultModel.getHits()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryTopHitsAggregationTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryTopHitsAggregationTest.java new file mode 100644 index 00000000000..31f118322f9 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/QueryTopHitsAggregationTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the QueryTopHitsAggregation model. */ +public class QueryTopHitsAggregationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testQueryTopHitsAggregation() throws Throwable { + QueryTopHitsAggregation queryTopHitsAggregationModel = new QueryTopHitsAggregation(); + assertNull(queryTopHitsAggregationModel.getType()); + assertNull(queryTopHitsAggregationModel.getSize()); + assertNull(queryTopHitsAggregationModel.getName()); + assertNull(queryTopHitsAggregationModel.getHits()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/RetrievalDetailsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/RetrievalDetailsTest.java new file mode 100644 index 00000000000..645bb7f0759 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/RetrievalDetailsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RetrievalDetails model. */ +public class RetrievalDetailsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRetrievalDetails() throws Throwable { + RetrievalDetails retrievalDetailsModel = new RetrievalDetails(); + assertNull(retrievalDetailsModel.getDocumentRetrievalStrategy()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableBodyCellsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableBodyCellsTest.java new file mode 100644 index 00000000000..d565cb0df2c --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableBodyCellsTest.java @@ -0,0 +1,49 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TableBodyCells model. */ +public class TableBodyCellsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTableBodyCells() throws Throwable { + TableBodyCells tableBodyCellsModel = new TableBodyCells(); + assertNull(tableBodyCellsModel.getCellId()); + assertNull(tableBodyCellsModel.getLocation()); + assertNull(tableBodyCellsModel.getText()); + assertNull(tableBodyCellsModel.getRowIndexBegin()); + assertNull(tableBodyCellsModel.getRowIndexEnd()); + assertNull(tableBodyCellsModel.getColumnIndexBegin()); + assertNull(tableBodyCellsModel.getColumnIndexEnd()); + assertNull(tableBodyCellsModel.getRowHeaderIds()); + assertNull(tableBodyCellsModel.getRowHeaderTexts()); + assertNull(tableBodyCellsModel.getRowHeaderTextsNormalized()); + assertNull(tableBodyCellsModel.getColumnHeaderIds()); + assertNull(tableBodyCellsModel.getColumnHeaderTexts()); + assertNull(tableBodyCellsModel.getColumnHeaderTextsNormalized()); + assertNull(tableBodyCellsModel.getAttributes()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableCellKeyTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableCellKeyTest.java new file mode 100644 index 00000000000..00bda19b030 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableCellKeyTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TableCellKey model. */ +public class TableCellKeyTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTableCellKey() throws Throwable { + TableCellKey tableCellKeyModel = new TableCellKey(); + assertNull(tableCellKeyModel.getCellId()); + assertNull(tableCellKeyModel.getLocation()); + assertNull(tableCellKeyModel.getText()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableCellValuesTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableCellValuesTest.java new file mode 100644 index 00000000000..d2d50e39940 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableCellValuesTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TableCellValues model. */ +public class TableCellValuesTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTableCellValues() throws Throwable { + TableCellValues tableCellValuesModel = new TableCellValues(); + assertNull(tableCellValuesModel.getCellId()); + assertNull(tableCellValuesModel.getLocation()); + assertNull(tableCellValuesModel.getText()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableColumnHeaderIdsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableColumnHeaderIdsTest.java new file mode 100644 index 00000000000..9a8270c209d --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableColumnHeaderIdsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TableColumnHeaderIds model. */ +public class TableColumnHeaderIdsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTableColumnHeaderIds() throws Throwable { + TableColumnHeaderIds tableColumnHeaderIdsModel = new TableColumnHeaderIds(); + assertNull(tableColumnHeaderIdsModel.getId()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableColumnHeaderTextsNormalizedTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableColumnHeaderTextsNormalizedTest.java new file mode 100644 index 00000000000..f9cf3b1b57f --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableColumnHeaderTextsNormalizedTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TableColumnHeaderTextsNormalized model. */ +public class TableColumnHeaderTextsNormalizedTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTableColumnHeaderTextsNormalized() throws Throwable { + TableColumnHeaderTextsNormalized tableColumnHeaderTextsNormalizedModel = + new TableColumnHeaderTextsNormalized(); + assertNull(tableColumnHeaderTextsNormalizedModel.getTextNormalized()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableColumnHeaderTextsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableColumnHeaderTextsTest.java new file mode 100644 index 00000000000..4825af8ea78 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableColumnHeaderTextsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TableColumnHeaderTexts model. */ +public class TableColumnHeaderTextsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTableColumnHeaderTexts() throws Throwable { + TableColumnHeaderTexts tableColumnHeaderTextsModel = new TableColumnHeaderTexts(); + assertNull(tableColumnHeaderTextsModel.getText()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableColumnHeadersTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableColumnHeadersTest.java new file mode 100644 index 00000000000..e6c27cd0586 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableColumnHeadersTest.java @@ -0,0 +1,43 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TableColumnHeaders model. */ +public class TableColumnHeadersTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTableColumnHeaders() throws Throwable { + TableColumnHeaders tableColumnHeadersModel = new TableColumnHeaders(); + assertNull(tableColumnHeadersModel.getCellId()); + assertNull(tableColumnHeadersModel.getLocation()); + assertNull(tableColumnHeadersModel.getText()); + assertNull(tableColumnHeadersModel.getTextNormalized()); + assertNull(tableColumnHeadersModel.getRowIndexBegin()); + assertNull(tableColumnHeadersModel.getRowIndexEnd()); + assertNull(tableColumnHeadersModel.getColumnIndexBegin()); + assertNull(tableColumnHeadersModel.getColumnIndexEnd()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableElementLocationTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableElementLocationTest.java new file mode 100644 index 00000000000..1281314f7c0 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableElementLocationTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TableElementLocation model. */ +public class TableElementLocationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTableElementLocation() throws Throwable { + TableElementLocation tableElementLocationModel = new TableElementLocation(); + assertNull(tableElementLocationModel.getBegin()); + assertNull(tableElementLocationModel.getEnd()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableHeadersTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableHeadersTest.java new file mode 100644 index 00000000000..421caf3cf92 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableHeadersTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TableHeaders model. */ +public class TableHeadersTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTableHeaders() throws Throwable { + TableHeaders tableHeadersModel = new TableHeaders(); + assertNull(tableHeadersModel.getCellId()); + assertNull(tableHeadersModel.getLocation()); + assertNull(tableHeadersModel.getText()); + assertNull(tableHeadersModel.getRowIndexBegin()); + assertNull(tableHeadersModel.getRowIndexEnd()); + assertNull(tableHeadersModel.getColumnIndexBegin()); + assertNull(tableHeadersModel.getColumnIndexEnd()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableKeyValuePairsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableKeyValuePairsTest.java new file mode 100644 index 00000000000..f135fd6eee5 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableKeyValuePairsTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TableKeyValuePairs model. */ +public class TableKeyValuePairsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTableKeyValuePairs() throws Throwable { + TableKeyValuePairs tableKeyValuePairsModel = new TableKeyValuePairs(); + assertNull(tableKeyValuePairsModel.getKey()); + assertNull(tableKeyValuePairsModel.getValue()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableResultTableTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableResultTableTest.java new file mode 100644 index 00000000000..92fafcb72b3 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableResultTableTest.java @@ -0,0 +1,45 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TableResultTable model. */ +public class TableResultTableTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTableResultTable() throws Throwable { + TableResultTable tableResultTableModel = new TableResultTable(); + assertNull(tableResultTableModel.getLocation()); + assertNull(tableResultTableModel.getText()); + assertNull(tableResultTableModel.getSectionTitle()); + assertNull(tableResultTableModel.getTitle()); + assertNull(tableResultTableModel.getTableHeaders()); + assertNull(tableResultTableModel.getRowHeaders()); + assertNull(tableResultTableModel.getColumnHeaders()); + assertNull(tableResultTableModel.getKeyValuePairs()); + assertNull(tableResultTableModel.getBodyCells()); + assertNull(tableResultTableModel.getContexts()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableRowHeaderIdsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableRowHeaderIdsTest.java new file mode 100644 index 00000000000..26f26df9808 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableRowHeaderIdsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TableRowHeaderIds model. */ +public class TableRowHeaderIdsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTableRowHeaderIds() throws Throwable { + TableRowHeaderIds tableRowHeaderIdsModel = new TableRowHeaderIds(); + assertNull(tableRowHeaderIdsModel.getId()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableRowHeaderTextsNormalizedTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableRowHeaderTextsNormalizedTest.java new file mode 100644 index 00000000000..b2b88c2cc29 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableRowHeaderTextsNormalizedTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TableRowHeaderTextsNormalized model. */ +public class TableRowHeaderTextsNormalizedTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTableRowHeaderTextsNormalized() throws Throwable { + TableRowHeaderTextsNormalized tableRowHeaderTextsNormalizedModel = + new TableRowHeaderTextsNormalized(); + assertNull(tableRowHeaderTextsNormalizedModel.getTextNormalized()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableRowHeaderTextsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableRowHeaderTextsTest.java new file mode 100644 index 00000000000..bef2e76bdf4 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableRowHeaderTextsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TableRowHeaderTexts model. */ +public class TableRowHeaderTextsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTableRowHeaderTexts() throws Throwable { + TableRowHeaderTexts tableRowHeaderTextsModel = new TableRowHeaderTexts(); + assertNull(tableRowHeaderTextsModel.getText()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableRowHeadersTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableRowHeadersTest.java new file mode 100644 index 00000000000..968715bac59 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableRowHeadersTest.java @@ -0,0 +1,43 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TableRowHeaders model. */ +public class TableRowHeadersTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTableRowHeaders() throws Throwable { + TableRowHeaders tableRowHeadersModel = new TableRowHeaders(); + assertNull(tableRowHeadersModel.getCellId()); + assertNull(tableRowHeadersModel.getLocation()); + assertNull(tableRowHeadersModel.getText()); + assertNull(tableRowHeadersModel.getTextNormalized()); + assertNull(tableRowHeadersModel.getRowIndexBegin()); + assertNull(tableRowHeadersModel.getRowIndexEnd()); + assertNull(tableRowHeadersModel.getColumnIndexBegin()); + assertNull(tableRowHeadersModel.getColumnIndexEnd()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableTextLocationTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableTextLocationTest.java new file mode 100644 index 00000000000..aaa0971aba8 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TableTextLocationTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TableTextLocation model. */ +public class TableTextLocationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTableTextLocation() throws Throwable { + TableTextLocation tableTextLocationModel = new TableTextLocation(); + assertNull(tableTextLocationModel.getText()); + assertNull(tableTextLocationModel.getLocation()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TrainingExampleTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TrainingExampleTest.java new file mode 100644 index 00000000000..1e177f0baa3 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TrainingExampleTest.java @@ -0,0 +1,57 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TrainingExample model. */ +public class TrainingExampleTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTrainingExample() throws Throwable { + TrainingExample trainingExampleModel = + new TrainingExample.Builder() + .documentId("testString") + .collectionId("testString") + .relevance(Long.valueOf("26")) + .build(); + assertEquals(trainingExampleModel.documentId(), "testString"); + assertEquals(trainingExampleModel.collectionId(), "testString"); + assertEquals(trainingExampleModel.relevance(), Long.valueOf("26")); + + String json = TestUtilities.serialize(trainingExampleModel); + + TrainingExample trainingExampleModelNew = + TestUtilities.deserialize(json, TrainingExample.class); + assertTrue(trainingExampleModelNew instanceof TrainingExample); + assertEquals(trainingExampleModelNew.documentId(), "testString"); + assertEquals(trainingExampleModelNew.collectionId(), "testString"); + assertEquals(trainingExampleModelNew.relevance(), Long.valueOf("26")); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testTrainingExampleError() throws Throwable { + new TrainingExample.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TrainingQuerySetTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TrainingQuerySetTest.java new file mode 100644 index 00000000000..e7f6e3b0de6 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TrainingQuerySetTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TrainingQuerySet model. */ +public class TrainingQuerySetTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTrainingQuerySet() throws Throwable { + TrainingQuerySet trainingQuerySetModel = new TrainingQuerySet(); + assertNull(trainingQuerySetModel.getQueries()); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TrainingQueryTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TrainingQueryTest.java new file mode 100644 index 00000000000..dabb8a58b04 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/TrainingQueryTest.java @@ -0,0 +1,69 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TrainingQuery model. */ +public class TrainingQueryTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTrainingQuery() throws Throwable { + TrainingExample trainingExampleModel = + new TrainingExample.Builder() + .documentId("testString") + .collectionId("testString") + .relevance(Long.valueOf("26")) + .build(); + assertEquals(trainingExampleModel.documentId(), "testString"); + assertEquals(trainingExampleModel.collectionId(), "testString"); + assertEquals(trainingExampleModel.relevance(), Long.valueOf("26")); + + TrainingQuery trainingQueryModel = + new TrainingQuery.Builder() + .naturalLanguageQuery("testString") + .filter("testString") + .examples( + new java.util.ArrayList( + java.util.Arrays.asList(trainingExampleModel))) + .build(); + assertEquals(trainingQueryModel.naturalLanguageQuery(), "testString"); + assertEquals(trainingQueryModel.filter(), "testString"); + assertEquals( + trainingQueryModel.examples(), + new java.util.ArrayList(java.util.Arrays.asList(trainingExampleModel))); + + String json = TestUtilities.serialize(trainingQueryModel); + + TrainingQuery trainingQueryModelNew = TestUtilities.deserialize(json, TrainingQuery.class); + assertTrue(trainingQueryModelNew instanceof TrainingQuery); + assertEquals(trainingQueryModelNew.naturalLanguageQuery(), "testString"); + assertEquals(trainingQueryModelNew.filter(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testTrainingQueryError() throws Throwable { + new TrainingQuery.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/UpdateCollectionOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/UpdateCollectionOptionsTest.java new file mode 100644 index 00000000000..279de50c596 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/UpdateCollectionOptionsTest.java @@ -0,0 +1,67 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the UpdateCollectionOptions model. */ +public class UpdateCollectionOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateCollectionOptions() throws Throwable { + CollectionEnrichment collectionEnrichmentModel = + new CollectionEnrichment.Builder() + .enrichmentId("testString") + .fields(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals(collectionEnrichmentModel.enrichmentId(), "testString"); + assertEquals( + collectionEnrichmentModel.fields(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + UpdateCollectionOptions updateCollectionOptionsModel = + new UpdateCollectionOptions.Builder() + .projectId("testString") + .collectionId("testString") + .name("testString") + .description("testString") + .enrichments( + new java.util.ArrayList( + java.util.Arrays.asList(collectionEnrichmentModel))) + .build(); + assertEquals(updateCollectionOptionsModel.projectId(), "testString"); + assertEquals(updateCollectionOptionsModel.collectionId(), "testString"); + assertEquals(updateCollectionOptionsModel.name(), "testString"); + assertEquals(updateCollectionOptionsModel.description(), "testString"); + assertEquals( + updateCollectionOptionsModel.enrichments(), + new java.util.ArrayList( + java.util.Arrays.asList(collectionEnrichmentModel))); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateCollectionOptionsError() throws Throwable { + new UpdateCollectionOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/UpdateDocumentOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/UpdateDocumentOptionsTest.java new file mode 100644 index 00000000000..d3dcf0c0078 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/UpdateDocumentOptionsTest.java @@ -0,0 +1,61 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.apache.commons.io.IOUtils; +import org.testng.annotations.Test; + +/** Unit test class for the UpdateDocumentOptions model. */ +public class UpdateDocumentOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateDocumentOptions() throws Throwable { + UpdateDocumentOptions updateDocumentOptionsModel = + new UpdateDocumentOptions.Builder() + .projectId("testString") + .collectionId("testString") + .documentId("testString") + .file(TestUtilities.createMockStream("This is a mock file.")) + .filename("testString") + .fileContentType("application/json") + .metadata("testString") + .xWatsonDiscoveryForce(true) + .build(); + assertEquals(updateDocumentOptionsModel.projectId(), "testString"); + assertEquals(updateDocumentOptionsModel.collectionId(), "testString"); + assertEquals(updateDocumentOptionsModel.documentId(), "testString"); + assertEquals( + IOUtils.toString(updateDocumentOptionsModel.file()), + IOUtils.toString(TestUtilities.createMockStream("This is a mock file."))); + assertEquals(updateDocumentOptionsModel.filename(), "testString"); + assertEquals(updateDocumentOptionsModel.fileContentType(), "application/json"); + assertEquals(updateDocumentOptionsModel.metadata(), "testString"); + assertEquals(updateDocumentOptionsModel.xWatsonDiscoveryForce(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateDocumentOptionsError() throws Throwable { + new UpdateDocumentOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/UpdateEnrichmentOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/UpdateEnrichmentOptionsTest.java new file mode 100644 index 00000000000..62aac59ab78 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/UpdateEnrichmentOptionsTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the UpdateEnrichmentOptions model. */ +public class UpdateEnrichmentOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateEnrichmentOptions() throws Throwable { + UpdateEnrichmentOptions updateEnrichmentOptionsModel = + new UpdateEnrichmentOptions.Builder() + .projectId("testString") + .enrichmentId("testString") + .name("testString") + .description("testString") + .build(); + assertEquals(updateEnrichmentOptionsModel.projectId(), "testString"); + assertEquals(updateEnrichmentOptionsModel.enrichmentId(), "testString"); + assertEquals(updateEnrichmentOptionsModel.name(), "testString"); + assertEquals(updateEnrichmentOptionsModel.description(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateEnrichmentOptionsError() throws Throwable { + new UpdateEnrichmentOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/UpdateProjectOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/UpdateProjectOptionsTest.java new file mode 100644 index 00000000000..a51e52f0e33 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/UpdateProjectOptionsTest.java @@ -0,0 +1,43 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the UpdateProjectOptions model. */ +public class UpdateProjectOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateProjectOptions() throws Throwable { + UpdateProjectOptions updateProjectOptionsModel = + new UpdateProjectOptions.Builder().projectId("testString").name("testString").build(); + assertEquals(updateProjectOptionsModel.projectId(), "testString"); + assertEquals(updateProjectOptionsModel.name(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateProjectOptionsError() throws Throwable { + new UpdateProjectOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/model/UpdateTrainingQueryOptionsTest.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/UpdateTrainingQueryOptionsTest.java new file mode 100644 index 00000000000..1033568656e --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/model/UpdateTrainingQueryOptionsTest.java @@ -0,0 +1,66 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.discovery.v2.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the UpdateTrainingQueryOptions model. */ +public class UpdateTrainingQueryOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateTrainingQueryOptions() throws Throwable { + TrainingExample trainingExampleModel = + new TrainingExample.Builder() + .documentId("testString") + .collectionId("testString") + .relevance(Long.valueOf("26")) + .build(); + assertEquals(trainingExampleModel.documentId(), "testString"); + assertEquals(trainingExampleModel.collectionId(), "testString"); + assertEquals(trainingExampleModel.relevance(), Long.valueOf("26")); + + UpdateTrainingQueryOptions updateTrainingQueryOptionsModel = + new UpdateTrainingQueryOptions.Builder() + .projectId("testString") + .queryId("testString") + .naturalLanguageQuery("testString") + .examples( + new java.util.ArrayList( + java.util.Arrays.asList(trainingExampleModel))) + .filter("testString") + .build(); + assertEquals(updateTrainingQueryOptionsModel.projectId(), "testString"); + assertEquals(updateTrainingQueryOptionsModel.queryId(), "testString"); + assertEquals(updateTrainingQueryOptionsModel.naturalLanguageQuery(), "testString"); + assertEquals( + updateTrainingQueryOptionsModel.examples(), + new java.util.ArrayList(java.util.Arrays.asList(trainingExampleModel))); + assertEquals(updateTrainingQueryOptionsModel.filter(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateTrainingQueryOptionsError() throws Throwable { + new UpdateTrainingQueryOptions.Builder().build(); + } +} diff --git a/discovery/src/test/java/com/ibm/watson/discovery/v2/utils/TestUtilities.java b/discovery/src/test/java/com/ibm/watson/discovery/v2/utils/TestUtilities.java new file mode 100644 index 00000000000..600ab75893a --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/utils/TestUtilities.java @@ -0,0 +1,128 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.discovery.v2.utils; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.cloud.sdk.core.util.GsonSingleton; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import okhttp3.HttpUrl; +import okhttp3.mockwebserver.RecordedRequest; + +/** A class used by the unit tests containing utility functions. */ +public class TestUtilities { + public static Map createMockMap() { + Map mockMap = new HashMap<>(); + mockMap.put("foo", "bar"); + return mockMap; + } + + public static HashMap createMockStreamMap() { + return new HashMap() { + { + put("key1", createMockStream("This is a mock file.")); + } + }; + } + + public static Map parseQueryString(RecordedRequest req) { + Map queryMap = new HashMap<>(); + + try { + HttpUrl requestUrl = req.getRequestUrl(); + + if (requestUrl != null) { + Set queryParamsNames = requestUrl.queryParameterNames(); + // map the parameter name to its corresponding value + for (String p : queryParamsNames) { + // get the corresponding value for the parameter (p) + List val = requestUrl.queryParameterValues(p); + if (val != null && !val.isEmpty()) { + String joinedQuery = String.join(",", val); + queryMap.put(p, joinedQuery); + } + } + } + if (queryMap.isEmpty()) { + return null; + } + } catch (Exception e) { + return null; + } + + return queryMap; + } + + public static String parseReqPath(RecordedRequest req) { + String parsedPath = null; + + try { + String fullPath = req.getPath(); + if (fullPath != null && !fullPath.isEmpty()) { + // retrieve the path segment before the query parameter + parsedPath = fullPath.split("\\?", 2)[0]; + } + if (parsedPath.isEmpty() || parsedPath == null) { + return null; + } + + } catch (Exception e) { + return null; + } + + return parsedPath; + } + + public static String serialize(Object obj) { + return GsonSingleton.getGson().toJson(obj); + } + + public static T deserialize(String json, Class clazz) { + return GsonSingleton.getGson().fromJson(json, clazz); + } + + public static InputStream createMockStream(String s) { + return new ByteArrayInputStream(s.getBytes()); + } + + public static List creatMockListFileWithMetadata() { + List list = new ArrayList(); + byte[] fileBytes = {(byte) 0xde, (byte) 0xad, (byte) 0xbe, (byte) 0xef}; + InputStream inputStream = new ByteArrayInputStream(fileBytes); + FileWithMetadata.Builder builder = new FileWithMetadata.Builder(); + builder.data(inputStream); + FileWithMetadata fileWithMetadata = builder.build(); + list.add(fileWithMetadata); + + return list; + } + + public static byte[] createMockByteArray(String bytes) { + return bytes.getBytes(); + } + + public static Date createMockDate(String date) throws Exception { + return new SimpleDateFormat("yyyy-MM-dd").parse(date); + } + + public static Date createMockDateTime(String date) throws Exception { + return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").parse(date); + } +} diff --git a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/LanguageTranslator.java b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/LanguageTranslator.java index 192315824a0..0cf061bd261 100644 --- a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/LanguageTranslator.java +++ b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/LanguageTranslator.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -10,6 +10,11 @@ * 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. */ + +/* + * IBM OpenAPI SDK Code Generator Version: 99-SNAPSHOT-7cc05500-20201106-154555 + */ + package com.ibm.watson.language_translator.v3; import com.google.gson.JsonObject; @@ -45,105 +50,128 @@ import com.ibm.watson.language_translator.v3.model.TranslationModels; import com.ibm.watson.language_translator.v3.model.TranslationResult; import java.io.InputStream; +import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; import okhttp3.MultipartBody; /** - * IBM Watson™ Language Translator translates text from one language to another. The service - * offers multiple IBM-provided translation models that you can customize based on your unique - * terminology and language. Use Language Translator to take news from across the globe and present - * it in your language, communicate with your customers in their own language, and more. + * IBM Watson&trade; Language Translator translates text from one language to another. The + * service offers multiple IBM-provided translation models that you can customize based on your + * unique terminology and language. Use Language Translator to take news from across the globe and + * present it in your language, communicate with your customers in their own language, and more. * * @version v3 - * @see Language Translator + * @see Language Translator */ public class LanguageTranslator extends BaseService { - private static final String DEFAULT_SERVICE_NAME = "language_translator"; + public static final String DEFAULT_SERVICE_NAME = "language_translator"; - private static final String DEFAULT_SERVICE_URL = + public static final String DEFAULT_SERVICE_URL = "https://api.us-south.language-translator.watson.cloud.ibm.com"; - private String versionDate; + private String version; /** - * Constructs a new `LanguageTranslator` client using the DEFAULT_SERVICE_NAME. + * Constructs an instance of the `LanguageTranslator` client. The default service name is used to + * configure the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value - * will keep your API calls from failing when the service introduces breaking changes. + * @param version Release date of the version of the API you want to use. Specify dates in + * YYYY-MM-DD format. The current version is `2018-05-01`. */ - public LanguageTranslator(String versionDate) { + public LanguageTranslator(String version) { this( - versionDate, + version, DEFAULT_SERVICE_NAME, ConfigBasedAuthenticatorFactory.getAuthenticator(DEFAULT_SERVICE_NAME)); } /** - * Constructs a new `LanguageTranslator` client with the DEFAULT_SERVICE_NAME and the specified - * Authenticator. + * Constructs an instance of the `LanguageTranslator` client. The default service name and + * specified authenticator are used to configure the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value - * will keep your API calls from failing when the service introduces breaking changes. - * @param authenticator the Authenticator instance to be configured for this service + * @param version Release date of the version of the API you want to use. Specify dates in + * YYYY-MM-DD format. The current version is `2018-05-01`. + * @param authenticator the {@link Authenticator} instance to be configured for this client */ - public LanguageTranslator(String versionDate, Authenticator authenticator) { - this(versionDate, DEFAULT_SERVICE_NAME, authenticator); + public LanguageTranslator(String version, Authenticator authenticator) { + this(version, DEFAULT_SERVICE_NAME, authenticator); } /** - * Constructs a new `LanguageTranslator` client with the specified serviceName. + * Constructs an instance of the `LanguageTranslator` client. The specified service name is used + * to configure the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value - * will keep your API calls from failing when the service introduces breaking changes. - * @param serviceName The name of the service to configure. + * @param version Release date of the version of the API you want to use. Specify dates in + * YYYY-MM-DD format. The current version is `2018-05-01`. + * @param serviceName the service name to be used when configuring the client instance */ - public LanguageTranslator(String versionDate, String serviceName) { - this(versionDate, serviceName, ConfigBasedAuthenticatorFactory.getAuthenticator(serviceName)); + public LanguageTranslator(String version, String serviceName) { + this(version, serviceName, ConfigBasedAuthenticatorFactory.getAuthenticator(serviceName)); } /** - * Constructs a new `LanguageTranslator` client with the specified Authenticator and serviceName. + * Constructs an instance of the `LanguageTranslator` client. The specified service name and + * authenticator are used to configure the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value - * will keep your API calls from failing when the service introduces breaking changes. - * @param serviceName The name of the service to configure. - * @param authenticator the Authenticator instance to be configured for this service + * @param version Release date of the version of the API you want to use. Specify dates in + * YYYY-MM-DD format. The current version is `2018-05-01`. + * @param serviceName the service name to be used when configuring the client instance + * @param authenticator the {@link Authenticator} instance to be configured for this client */ - public LanguageTranslator(String versionDate, String serviceName, Authenticator authenticator) { + public LanguageTranslator(String version, String serviceName, Authenticator authenticator) { super(serviceName, authenticator); setServiceUrl(DEFAULT_SERVICE_URL); - com.ibm.cloud.sdk.core.util.Validator.isTrue( - (versionDate != null) && !versionDate.isEmpty(), "version cannot be null."); - this.versionDate = versionDate; + setVersion(version); this.configureService(serviceName); } + /** + * Gets the version. + * + *

Release date of the version of the API you want to use. Specify dates in YYYY-MM-DD format. + * The current version is `2018-05-01`. + * + * @return the version + */ + public String getVersion() { + return this.version; + } + + /** + * Sets the version. + * + * @param version the new version + */ + public void setVersion(final String version) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(version, "version cannot be empty."); + this.version = version; + } + /** * List supported languages. * - *

Lists all supported languages. The method returns an array of supported languages with - * information about each language. Languages are listed in alphabetical order by language code - * (for example, `af`, `ar`). + *

Lists all supported languages for translation. The method returns an array of supported + * languages with information about each language. Languages are listed in alphabetical order by + * language code (for example, `af`, `ar`). In addition to basic information about each language, + * the response indicates whether the language is `supported_as_source` for translation and + * `supported_as_target` for translation. It also lists whether the language is `identifiable`. * * @param listLanguagesOptions the {@link ListLanguagesOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of {@link Languages} + * @return a {@link ServiceCall} with a result of type {@link Languages} */ public ServiceCall listLanguages(ListLanguagesOptions listLanguagesOptions) { - String[] pathSegments = {"v3/languages"}; RequestBuilder builder = - RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); + RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v3/languages")); Map sdkHeaders = SdkCommon.getSdkHeaders("language_translator", "v3", "listLanguages"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - if (listLanguagesOptions != null) {} - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken() {}.getType()); @@ -153,11 +181,13 @@ public ServiceCall listLanguages(ListLanguagesOptions listLanguagesOp /** * List supported languages. * - *

Lists all supported languages. The method returns an array of supported languages with - * information about each language. Languages are listed in alphabetical order by language code - * (for example, `af`, `ar`). + *

Lists all supported languages for translation. The method returns an array of supported + * languages with information about each language. Languages are listed in alphabetical order by + * language code (for example, `af`, `ar`). In addition to basic information about each language, + * the response indicates whether the language is `supported_as_source` for translation and + * `supported_as_target` for translation. It also lists whether the language is `identifiable`. * - * @return a {@link ServiceCall} with a response type of {@link Languages} + * @return a {@link ServiceCall} with a result of type {@link Languages} */ public ServiceCall listLanguages() { return listLanguages(null); @@ -172,22 +202,24 @@ public ServiceCall listLanguages() { * language from the input text. If you omit the source language, the request must contain * sufficient input text for the service to identify the source language. * + *

You can translate a maximum of 50 KB (51,200 bytes) of text with a single request. All input + * text must be encoded in UTF-8 format. + * * @param translateOptions the {@link TranslateOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link TranslationResult} + * @return a {@link ServiceCall} with a result of type {@link TranslationResult} */ public ServiceCall translate(TranslateOptions translateOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( translateOptions, "translateOptions cannot be null"); - String[] pathSegments = {"v3/translate"}; RequestBuilder builder = - RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); + RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v3/translate")); Map sdkHeaders = SdkCommon.getSdkHeaders("language_translator", "v3", "translate"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); final JsonObject contentJson = new JsonObject(); contentJson.add( "text", @@ -216,22 +248,20 @@ public ServiceCall translate(TranslateOptions translateOption * * @param listIdentifiableLanguagesOptions the {@link ListIdentifiableLanguagesOptions} containing * the options for the call - * @return a {@link ServiceCall} with a response type of {@link IdentifiableLanguages} + * @return a {@link ServiceCall} with a result of type {@link IdentifiableLanguages} */ public ServiceCall listIdentifiableLanguages( ListIdentifiableLanguagesOptions listIdentifiableLanguagesOptions) { - String[] pathSegments = {"v3/identifiable_languages"}; RequestBuilder builder = - RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); + RequestBuilder.get( + RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v3/identifiable_languages")); Map sdkHeaders = SdkCommon.getSdkHeaders("language_translator", "v3", "listIdentifiableLanguages"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - if (listIdentifiableLanguagesOptions != null) {} - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken() {}.getType()); @@ -244,7 +274,7 @@ public ServiceCall listIdentifiableLanguages( *

Lists the languages that the service can identify. Returns the language code (for example, * `en` for English or `es` for Spanish) and name of each language. * - * @return a {@link ServiceCall} with a response type of {@link IdentifiableLanguages} + * @return a {@link ServiceCall} with a result of type {@link IdentifiableLanguages} */ public ServiceCall listIdentifiableLanguages() { return listIdentifiableLanguages(null); @@ -256,21 +286,20 @@ public ServiceCall listIdentifiableLanguages() { *

Identifies the language of the input text. * * @param identifyOptions the {@link IdentifyOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link IdentifiedLanguages} + * @return a {@link ServiceCall} with a result of type {@link IdentifiedLanguages} */ public ServiceCall identify(IdentifyOptions identifyOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( identifyOptions, "identifyOptions cannot be null"); - String[] pathSegments = {"v3/identify"}; RequestBuilder builder = - RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); + RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v3/identify")); Map sdkHeaders = SdkCommon.getSdkHeaders("language_translator", "v3", "identify"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); builder.bodyContent(identifyOptions.text(), "text/plain"); ResponseConverter responseConverter = ResponseConverterUtils.getValue( @@ -284,29 +313,29 @@ public ServiceCall identify(IdentifyOptions identifyOptions *

Lists available translation models. * * @param listModelsOptions the {@link ListModelsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link TranslationModels} + * @return a {@link ServiceCall} with a result of type {@link TranslationModels} */ public ServiceCall listModels(ListModelsOptions listModelsOptions) { - String[] pathSegments = {"v3/models"}; + if (listModelsOptions == null) { + listModelsOptions = new ListModelsOptions.Builder().build(); + } RequestBuilder builder = - RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); + RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v3/models")); Map sdkHeaders = SdkCommon.getSdkHeaders("language_translator", "v3", "listModels"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - if (listModelsOptions != null) { - if (listModelsOptions.source() != null) { - builder.query("source", listModelsOptions.source()); - } - if (listModelsOptions.target() != null) { - builder.query("target", listModelsOptions.target()); - } - if (listModelsOptions.xDefault() != null) { - builder.query("default", String.valueOf(listModelsOptions.xDefault())); - } + builder.query("version", String.valueOf(this.version)); + if (listModelsOptions.source() != null) { + builder.query("source", String.valueOf(listModelsOptions.source())); + } + if (listModelsOptions.target() != null) { + builder.query("target", String.valueOf(listModelsOptions.target())); + } + if (listModelsOptions.xDefault() != null) { + builder.query("default", String.valueOf(listModelsOptions.xDefault())); } ResponseConverter responseConverter = ResponseConverterUtils.getValue( @@ -319,7 +348,7 @@ public ServiceCall listModels(ListModelsOptions listModelsOpt * *

Lists available translation models. * - * @return a {@link ServiceCall} with a response type of {@link TranslationModels} + * @return a {@link ServiceCall} with a result of type {@link TranslationModels} */ public ServiceCall listModels() { return listModels(null); @@ -356,11 +385,13 @@ public ServiceCall listModels() { * of translation memories. * **XLIFF** (`.xliff`) - XML Localization Interchange File Format * (XLIFF) is an XML specification for the exchange of translation memories. * **CSV** (`.csv`) - * Comma-separated values (CSV) file with two columns for aligned sentences and phrases. The first - * row contains the language code. * **TSV** (`.tsv` or `.tab`) - Tab-separated values (TSV) file - * with two columns for aligned sentences and phrases. The first row contains the language code. * - * **JSON** (`.json`) - Custom JSON format for specifying aligned sentences and phrases. * - * **Microsoft Excel** (`.xls` or `.xlsx`) - Excel file with the first two columns for aligned - * sentences and phrases. The first row contains the language code. + * row must have two language codes. The first column is for the source language code, and the + * second column is for the target language code. * **TSV** (`.tsv` or `.tab`) - Tab-separated + * values (TSV) file with two columns for aligned sentences and phrases. The first row must have + * two language codes. The first column is for the source language code, and the second column is + * for the target language code. * **JSON** (`.json`) - Custom JSON format for specifying aligned + * sentences and phrases. * **Microsoft Excel** (`.xls` or `.xlsx`) - Excel file with the first + * two columns for aligned sentences and phrases. The first row contains the language code. * *

You must encode all text data in UTF-8 format. For more information, see [Supported document * formats for training @@ -383,7 +414,7 @@ public ServiceCall listModels() { *

`--form "forced_glossary=@glossary;type=text/csv"`. * * @param createModelOptions the {@link CreateModelOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link TranslationModel} + * @return a {@link ServiceCall} with a result of type {@link TranslationModel} */ public ServiceCall createModel(CreateModelOptions createModelOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( @@ -392,19 +423,18 @@ public ServiceCall createModel(CreateModelOptions createModelO (createModelOptions.forcedGlossary() != null) || (createModelOptions.parallelCorpus() != null), "At least one of forcedGlossary or parallelCorpus must be supplied."); - String[] pathSegments = {"v3/models"}; RequestBuilder builder = - RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); + RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v3/models")); Map sdkHeaders = SdkCommon.getSdkHeaders("language_translator", "v3", "createModel"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - builder.query("base_model_id", createModelOptions.baseModelId()); + builder.query("version", String.valueOf(this.version)); + builder.query("base_model_id", String.valueOf(createModelOptions.baseModelId())); if (createModelOptions.name() != null) { - builder.query("name", createModelOptions.name()); + builder.query("name", String.valueOf(createModelOptions.name())); } MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); multipartBuilder.setType(MultipartBody.FORM); @@ -433,24 +463,24 @@ public ServiceCall createModel(CreateModelOptions createModelO *

Deletes a custom translation model. * * @param deleteModelOptions the {@link DeleteModelOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link DeleteModelResult} + * @return a {@link ServiceCall} with a result of type {@link DeleteModelResult} */ public ServiceCall deleteModel(DeleteModelOptions deleteModelOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( deleteModelOptions, "deleteModelOptions cannot be null"); - String[] pathSegments = {"v3/models"}; - String[] pathParameters = {deleteModelOptions.modelId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("model_id", deleteModelOptions.modelId()); RequestBuilder builder = RequestBuilder.delete( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v3/models/{model_id}", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("language_translator", "v3", "deleteModel"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken() {}.getType()); @@ -465,24 +495,24 @@ public ServiceCall deleteModel(DeleteModelOptions deleteModel * training has a status of `available`. * * @param getModelOptions the {@link GetModelOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link TranslationModel} + * @return a {@link ServiceCall} with a result of type {@link TranslationModel} */ public ServiceCall getModel(GetModelOptions getModelOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( getModelOptions, "getModelOptions cannot be null"); - String[] pathSegments = {"v3/models"}; - String[] pathParameters = {getModelOptions.modelId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("model_id", getModelOptions.modelId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v3/models/{model_id}", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("language_translator", "v3", "getModel"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken() {}.getType()); @@ -496,21 +526,18 @@ public ServiceCall getModel(GetModelOptions getModelOptions) { * * @param listDocumentsOptions the {@link ListDocumentsOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of {@link DocumentList} + * @return a {@link ServiceCall} with a result of type {@link DocumentList} */ public ServiceCall listDocuments(ListDocumentsOptions listDocumentsOptions) { - String[] pathSegments = {"v3/documents"}; RequestBuilder builder = - RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); + RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v3/documents")); Map sdkHeaders = SdkCommon.getSdkHeaders("language_translator", "v3", "listDocuments"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - if (listDocumentsOptions != null) {} - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken() {}.getType()); @@ -522,7 +549,7 @@ public ServiceCall listDocuments(ListDocumentsOptions listDocument * *

Lists documents that have been submitted for translation. * - * @return a {@link ServiceCall} with a response type of {@link DocumentList} + * @return a {@link ServiceCall} with a result of type {@link DocumentList} */ public ServiceCall listDocuments() { return listDocuments(null); @@ -532,26 +559,27 @@ public ServiceCall listDocuments() { * Translate document. * *

Submit a document for translation. You can submit the document contents in the `file` - * parameter, or you can reference a previously submitted document by document ID. + * parameter, or you can reference a previously submitted document by document ID. The maximum + * file size for document translation is * 20 MB for service instances on the Standard, Advanced, + * and Premium plans * 2 MB for service instances on the Lite plan. * * @param translateDocumentOptions the {@link TranslateDocumentOptions} containing the options for * the call - * @return a {@link ServiceCall} with a response type of {@link DocumentStatus} + * @return a {@link ServiceCall} with a result of type {@link DocumentStatus} */ public ServiceCall translateDocument( TranslateDocumentOptions translateDocumentOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( translateDocumentOptions, "translateDocumentOptions cannot be null"); - String[] pathSegments = {"v3/documents"}; RequestBuilder builder = - RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); + RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v3/documents")); Map sdkHeaders = SdkCommon.getSdkHeaders("language_translator", "v3", "translateDocument"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); multipartBuilder.setType(MultipartBody.FORM); okhttp3.RequestBody fileBody = @@ -584,25 +612,25 @@ public ServiceCall translateDocument( * * @param getDocumentStatusOptions the {@link GetDocumentStatusOptions} containing the options for * the call - * @return a {@link ServiceCall} with a response type of {@link DocumentStatus} + * @return a {@link ServiceCall} with a result of type {@link DocumentStatus} */ public ServiceCall getDocumentStatus( GetDocumentStatusOptions getDocumentStatusOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( getDocumentStatusOptions, "getDocumentStatusOptions cannot be null"); - String[] pathSegments = {"v3/documents"}; - String[] pathParameters = {getDocumentStatusOptions.documentId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("document_id", getDocumentStatusOptions.documentId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v3/documents/{document_id}", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("language_translator", "v3", "getDocumentStatus"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken() {}.getType()); @@ -616,23 +644,23 @@ public ServiceCall getDocumentStatus( * * @param deleteDocumentOptions the {@link DeleteDocumentOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteDocument(DeleteDocumentOptions deleteDocumentOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( deleteDocumentOptions, "deleteDocumentOptions cannot be null"); - String[] pathSegments = {"v3/documents"}; - String[] pathParameters = {deleteDocumentOptions.documentId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("document_id", deleteDocumentOptions.documentId()); RequestBuilder builder = RequestBuilder.delete( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v3/documents/{document_id}", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("language_translator", "v3", "deleteDocument"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -644,18 +672,18 @@ public ServiceCall deleteDocument(DeleteDocumentOptions deleteDocumentOpti * * @param getTranslatedDocumentOptions the {@link GetTranslatedDocumentOptions} containing the * options for the call - * @return a {@link ServiceCall} with a response type of {@link InputStream} + * @return a {@link ServiceCall} with a result of type {@link InputStream} */ public ServiceCall getTranslatedDocument( GetTranslatedDocumentOptions getTranslatedDocumentOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( getTranslatedDocumentOptions, "getTranslatedDocumentOptions cannot be null"); - String[] pathSegments = {"v3/documents", "translated_document"}; - String[] pathParameters = {getTranslatedDocumentOptions.documentId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("document_id", getTranslatedDocumentOptions.documentId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v3/documents/{document_id}/translated_document", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("language_translator", "v3", "getTranslatedDocument"); for (Entry header : sdkHeaders.entrySet()) { @@ -664,6 +692,7 @@ public ServiceCall getTranslatedDocument( if (getTranslatedDocumentOptions.accept() != null) { builder.header("Accept", getTranslatedDocumentOptions.accept()); } + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getInputStream(); return createServiceCall(builder.build(), responseConverter); } diff --git a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/CreateModelOptions.java b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/CreateModelOptions.java index 1184fe5c3d2..dc433e890f5 100644 --- a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/CreateModelOptions.java +++ b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/CreateModelOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -55,7 +55,7 @@ public Builder(String baseModelId) { /** * Builds a CreateModelOptions. * - * @return the createModelOptions + * @return the new CreateModelOptions instance */ public CreateModelOptions build() { return new CreateModelOptions(this); diff --git a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/DeleteDocumentOptions.java b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/DeleteDocumentOptions.java index 4d6a920887a..f7feebd1f29 100644 --- a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/DeleteDocumentOptions.java +++ b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/DeleteDocumentOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -42,7 +42,7 @@ public Builder(String documentId) { /** * Builds a DeleteDocumentOptions. * - * @return the deleteDocumentOptions + * @return the new DeleteDocumentOptions instance */ public DeleteDocumentOptions build() { return new DeleteDocumentOptions(this); diff --git a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/DeleteModelOptions.java b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/DeleteModelOptions.java index 6aab569aec7..0b40891a43e 100644 --- a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/DeleteModelOptions.java +++ b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/DeleteModelOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -42,7 +42,7 @@ public Builder(String modelId) { /** * Builds a DeleteModelOptions. * - * @return the deleteModelOptions + * @return the new DeleteModelOptions instance */ public DeleteModelOptions build() { return new DeleteModelOptions(this); diff --git a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/DeleteModelResult.java b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/DeleteModelResult.java index e6ffa5aee21..71dec4c579f 100644 --- a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/DeleteModelResult.java +++ b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/DeleteModelResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/DocumentList.java b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/DocumentList.java index be859147788..4167108fe67 100644 --- a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/DocumentList.java +++ b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/DocumentList.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/DocumentStatus.java b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/DocumentStatus.java index 415814d0fa5..34a75ca7267 100644 --- a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/DocumentStatus.java +++ b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/DocumentStatus.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -71,8 +71,8 @@ public String getDocumentId() { /** * Gets the filename. * - *

filename from the submission (if it was missing in the multipart-form, 'noname.' is used. + *

filename from the submission (if it was missing in the multipart-form, 'noname.<ext + * matching content type>' is used. * * @return the filename */ diff --git a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/GetDocumentStatusOptions.java b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/GetDocumentStatusOptions.java index cb421616179..e9e2f904ecb 100644 --- a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/GetDocumentStatusOptions.java +++ b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/GetDocumentStatusOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -42,7 +42,7 @@ public Builder(String documentId) { /** * Builds a GetDocumentStatusOptions. * - * @return the getDocumentStatusOptions + * @return the new GetDocumentStatusOptions instance */ public GetDocumentStatusOptions build() { return new GetDocumentStatusOptions(this); diff --git a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/GetModelOptions.java b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/GetModelOptions.java index 8519287a3be..70bc7326e54 100644 --- a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/GetModelOptions.java +++ b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/GetModelOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -42,7 +42,7 @@ public Builder(String modelId) { /** * Builds a GetModelOptions. * - * @return the getModelOptions + * @return the new GetModelOptions instance */ public GetModelOptions build() { return new GetModelOptions(this); diff --git a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/GetTranslatedDocumentOptions.java b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/GetTranslatedDocumentOptions.java index 50a6f90b131..c99ab706b2d 100644 --- a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/GetTranslatedDocumentOptions.java +++ b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/GetTranslatedDocumentOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -45,7 +45,7 @@ public Builder(String documentId) { /** * Builds a GetTranslatedDocumentOptions. * - * @return the getTranslatedDocumentOptions + * @return the new GetTranslatedDocumentOptions instance */ public GetTranslatedDocumentOptions build() { return new GetTranslatedDocumentOptions(this); diff --git a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/IdentifiableLanguage.java b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/IdentifiableLanguage.java index 670aee92d79..b9b7f5d9f21 100644 --- a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/IdentifiableLanguage.java +++ b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/IdentifiableLanguage.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/IdentifiableLanguages.java b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/IdentifiableLanguages.java index d7da94793f0..8bebaa66610 100644 --- a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/IdentifiableLanguages.java +++ b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/IdentifiableLanguages.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/IdentifiedLanguage.java b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/IdentifiedLanguage.java index 3d30ace1a3e..8e0fd080b6f 100644 --- a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/IdentifiedLanguage.java +++ b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/IdentifiedLanguage.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/IdentifiedLanguages.java b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/IdentifiedLanguages.java index c1c37befad6..1e8c4bf9e4f 100644 --- a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/IdentifiedLanguages.java +++ b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/IdentifiedLanguages.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/IdentifyOptions.java b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/IdentifyOptions.java index 2af1c840d59..414e982568e 100644 --- a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/IdentifyOptions.java +++ b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/IdentifyOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -42,7 +42,7 @@ public Builder(String text) { /** * Builds a IdentifyOptions. * - * @return the identifyOptions + * @return the new IdentifyOptions instance */ public IdentifyOptions build() { return new IdentifyOptions(this); diff --git a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/ListDocumentsOptions.java b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/ListDocumentsOptions.java index 72fbe09c02c..7351da5a66a 100644 --- a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/ListDocumentsOptions.java +++ b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/ListDocumentsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -15,34 +15,4 @@ import com.ibm.cloud.sdk.core.service.model.GenericModel; /** The listDocuments options. */ -public class ListDocumentsOptions extends GenericModel { - - /** Builder. */ - public static class Builder { - - private Builder(ListDocumentsOptions listDocumentsOptions) {} - - /** Instantiates a new builder. */ - public Builder() {} - - /** - * Builds a ListDocumentsOptions. - * - * @return the listDocumentsOptions - */ - public ListDocumentsOptions build() { - return new ListDocumentsOptions(this); - } - } - - private ListDocumentsOptions(Builder builder) {} - - /** - * New builder. - * - * @return a ListDocumentsOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } -} +public class ListDocumentsOptions extends GenericModel {} diff --git a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/ListIdentifiableLanguagesOptions.java b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/ListIdentifiableLanguagesOptions.java index c748206cc00..6135492d374 100644 --- a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/ListIdentifiableLanguagesOptions.java +++ b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/ListIdentifiableLanguagesOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -15,34 +15,4 @@ import com.ibm.cloud.sdk.core.service.model.GenericModel; /** The listIdentifiableLanguages options. */ -public class ListIdentifiableLanguagesOptions extends GenericModel { - - /** Builder. */ - public static class Builder { - - private Builder(ListIdentifiableLanguagesOptions listIdentifiableLanguagesOptions) {} - - /** Instantiates a new builder. */ - public Builder() {} - - /** - * Builds a ListIdentifiableLanguagesOptions. - * - * @return the listIdentifiableLanguagesOptions - */ - public ListIdentifiableLanguagesOptions build() { - return new ListIdentifiableLanguagesOptions(this); - } - } - - private ListIdentifiableLanguagesOptions(Builder builder) {} - - /** - * New builder. - * - * @return a ListIdentifiableLanguagesOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } -} +public class ListIdentifiableLanguagesOptions extends GenericModel {} diff --git a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/ListLanguagesOptions.java b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/ListLanguagesOptions.java index 51ae9393336..0ff8689f8bb 100644 --- a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/ListLanguagesOptions.java +++ b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/ListLanguagesOptions.java @@ -15,34 +15,4 @@ import com.ibm.cloud.sdk.core.service.model.GenericModel; /** The listLanguages options. */ -public class ListLanguagesOptions extends GenericModel { - - /** Builder. */ - public static class Builder { - - private Builder(ListLanguagesOptions listDocumentsOptions) {} - - /** Instantiates a new builder. */ - public Builder() {} - - /** - * Builds a ListDocumentsOptions. - * - * @return the listDocumentsOptions - */ - public ListLanguagesOptions build() { - return new ListLanguagesOptions(this); - } - } - - private ListLanguagesOptions(Builder builder) {} - - /** - * New builder. - * - * @return a ListDocumentsOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } -} +public class ListLanguagesOptions extends GenericModel {} diff --git a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/ListModelsOptions.java b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/ListModelsOptions.java index 5a182483877..933cb3cccfc 100644 --- a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/ListModelsOptions.java +++ b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/ListModelsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -39,7 +39,7 @@ public Builder() {} /** * Builds a ListModelsOptions. * - * @return the listModelsOptions + * @return the new ListModelsOptions instance */ public ListModelsOptions build() { return new ListModelsOptions(this); diff --git a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/TranslateDocumentOptions.java b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/TranslateDocumentOptions.java index 38bb9dfcaf1..76acc18c227 100644 --- a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/TranslateDocumentOptions.java +++ b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/TranslateDocumentOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -66,7 +66,7 @@ public Builder(InputStream file, String filename) { /** * Builds a TranslateDocumentOptions. * - * @return the translateDocumentOptions + * @return the new TranslateDocumentOptions instance */ public TranslateDocumentOptions build() { return new TranslateDocumentOptions(this); @@ -187,12 +187,10 @@ public Builder newBuilder() { /** * Gets the file. * - *

The contents of the source file to translate. - * - *

[Supported file - * types](https://cloud.ibm.com/docs/language-translator?topic=language-translator-document-translator-tutorial#supported-file-formats) - * - *

Maximum file size: **20 MB**. + *

The contents of the source file to translate. The maximum file size for document translation + * is 20 MB for service instances on the Standard, Advanced, and Premium plans, and 2 MB for + * service instances on the Lite plan. For more information, see [Supported file formats + * (Beta)](https://cloud.ibm.com/docs/language-translator?topic=language-translator-document-translator-tutorial#supported-file-formats). * * @return the file */ diff --git a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/TranslateOptions.java b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/TranslateOptions.java index c72b603d985..6f07bde7efd 100644 --- a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/TranslateOptions.java +++ b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/TranslateOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -53,7 +53,7 @@ public Builder(List text) { /** * Builds a TranslateOptions. * - * @return the translateOptions + * @return the new TranslateOptions instance */ public TranslateOptions build() { return new TranslateOptions(this); @@ -139,8 +139,8 @@ public Builder newBuilder() { /** * Gets the text. * - *

Input text in UTF-8 encoding. Multiple entries result in multiple translations in the - * response. + *

Input text in UTF-8 encoding. Submit a maximum of 50 KB (51,200 bytes) of text with a single + * request. Multiple elements result in multiple translations in the response. * * @return the text */ diff --git a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/Translation.java b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/Translation.java index 9f4dd52d2c5..db1727ae8f6 100644 --- a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/Translation.java +++ b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/Translation.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/TranslationModel.java b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/TranslationModel.java index a27c8414b72..ac5b1aef5ae 100644 --- a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/TranslationModel.java +++ b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/TranslationModel.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2016, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/TranslationModels.java b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/TranslationModels.java index 82da462a5c6..f711610fd49 100644 --- a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/TranslationModels.java +++ b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/TranslationModels.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/TranslationResult.java b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/TranslationResult.java index fe7b44519c5..536d4298136 100644 --- a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/TranslationResult.java +++ b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/model/TranslationResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2016, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/package-info.java b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/package-info.java index e7520c0f03d..2e360266f73 100644 --- a/language-translator/src/main/java/com/ibm/watson/language_translator/v3/package-info.java +++ b/language-translator/src/main/java/com/ibm/watson/language_translator/v3/package-info.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/language-translator/src/test/java/com/ibm/watson/language_translator/v3/LanguageTranslatorTest.java b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/LanguageTranslatorTest.java index eb2652a947e..bc493574486 100644 --- a/language-translator/src/test/java/com/ibm/watson/language_translator/v3/LanguageTranslatorTest.java +++ b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/LanguageTranslatorTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -12,609 +12,764 @@ */ package com.ibm.watson.language_translator.v3; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; +import static org.testng.Assert.*; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.io.Files; -import com.google.gson.Gson; -import com.google.gson.reflect.TypeToken; -import com.ibm.cloud.sdk.core.http.HttpMediaType; +import com.ibm.cloud.sdk.core.http.Response; +import com.ibm.cloud.sdk.core.security.Authenticator; import com.ibm.cloud.sdk.core.security.NoAuthAuthenticator; -import com.ibm.cloud.sdk.core.service.exception.BadRequestException; -import com.ibm.cloud.sdk.core.util.GsonSingleton; -import com.ibm.watson.common.WatsonServiceUnitTest; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; import com.ibm.watson.language_translator.v3.model.CreateModelOptions; import com.ibm.watson.language_translator.v3.model.DeleteDocumentOptions; +import com.ibm.watson.language_translator.v3.model.DeleteModelOptions; +import com.ibm.watson.language_translator.v3.model.DeleteModelResult; import com.ibm.watson.language_translator.v3.model.DocumentList; import com.ibm.watson.language_translator.v3.model.DocumentStatus; import com.ibm.watson.language_translator.v3.model.GetDocumentStatusOptions; import com.ibm.watson.language_translator.v3.model.GetModelOptions; import com.ibm.watson.language_translator.v3.model.GetTranslatedDocumentOptions; -import com.ibm.watson.language_translator.v3.model.IdentifiableLanguage; -import com.ibm.watson.language_translator.v3.model.IdentifiedLanguage; +import com.ibm.watson.language_translator.v3.model.IdentifiableLanguages; import com.ibm.watson.language_translator.v3.model.IdentifiedLanguages; import com.ibm.watson.language_translator.v3.model.IdentifyOptions; +import com.ibm.watson.language_translator.v3.model.Languages; import com.ibm.watson.language_translator.v3.model.ListDocumentsOptions; +import com.ibm.watson.language_translator.v3.model.ListIdentifiableLanguagesOptions; +import com.ibm.watson.language_translator.v3.model.ListLanguagesOptions; import com.ibm.watson.language_translator.v3.model.ListModelsOptions; import com.ibm.watson.language_translator.v3.model.TranslateDocumentOptions; import com.ibm.watson.language_translator.v3.model.TranslateOptions; import com.ibm.watson.language_translator.v3.model.TranslationModel; import com.ibm.watson.language_translator.v3.model.TranslationModels; import com.ibm.watson.language_translator.v3.model.TranslationResult; -import com.ibm.watson.language_translator.v3.util.Language; -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; +import com.ibm.watson.language_translator.v3.utils.TestUtilities; import java.io.IOException; import java.io.InputStream; -import java.lang.reflect.Type; -import java.util.Collections; +import java.util.HashMap; import java.util.List; import java.util.Map; import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; import okhttp3.mockwebserver.RecordedRequest; -import okio.Buffer; -import org.junit.Before; -import org.junit.Test; - -/** Language Translator v3 Unit tests. */ -public class LanguageTranslatorTest extends WatsonServiceUnitTest { - - private static final String GET_MODELS_PATH = "/v3/models"; - private static final String IDENTIFIABLE_LANGUAGES_PATH = "/v3/identifiable_languages"; - private static final String IDENTITY_PATH = "/v3/identify"; - private static final String LANGUAGE_TRANSLATION_PATH = "/v3/translate"; - private static final String VERSION_PARAM = "?version=2018-05-01"; - private static final String RESOURCE = "src/test/resources/language_translation/"; - private static final Type TYPE_IDENTIFIED_LANGUAGES = - new TypeToken>>() {}.getType(); - private static final Gson GSON = GsonSingleton.getGsonWithoutPrettyPrinting(); - private final String modelId = "foo-bar"; - private LanguageTranslator service; - - private final Map translations = - ImmutableMap.of( - "The IBM Watson team is awesome", - "El equipo es increíble IBM Watson", - "Welcome to the cognitive era", - "Bienvenido a la era cognitiva"); - private final List texts = ImmutableList.copyOf(translations.keySet()); - - private TranslationModel model; - private TranslationModels models; - private IdentifiedLanguages identifiedLanguages; - private TranslationResult singleTranslation; - private TranslationResult multipleTranslations; - private Map identifiableLanguages; - private DocumentList documentList; - private DocumentStatus documentStatus; - private File translatedDocument; - - /** - * Sets up the tests. - * - * @throws Exception the exception - */ - /* - * (non-Javadoc) - * @see com.ibm.watson.developercloud.WatsonServiceTest#setUp() - */ - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - - service = new LanguageTranslator("2018-05-01", new NoAuthAuthenticator()); - service.setServiceUrl(getMockWebServerUrl()); - - // fixtures - String jsonString = - getStringFromInputStream(new FileInputStream(RESOURCE + "identifiable_languages.json")); - identifiableLanguages = GSON.fromJson(jsonString, TYPE_IDENTIFIED_LANGUAGES); - - model = loadFixture(RESOURCE + "model.json", TranslationModel.class); - models = loadFixture(RESOURCE + "models.json", TranslationModels.class); - identifiedLanguages = - loadFixture(RESOURCE + "identify_response.json", IdentifiedLanguages.class); - singleTranslation = loadFixture(RESOURCE + "single_translation.json", TranslationResult.class); - multipleTranslations = - loadFixture(RESOURCE + "multiple_translations.json", TranslationResult.class); - documentList = loadFixture(RESOURCE + "list_documents_response.json", DocumentList.class); - documentStatus = loadFixture(RESOURCE + "document_status.json", DocumentStatus.class); - translatedDocument = new File(RESOURCE + "translated_document.txt"); - } +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; - /** - * Test create model with base model null. - * - * @throws IOException Signals that an I/O exception has occurred. - */ - @Test(expected = IllegalArgumentException.class) - public void testcreateModelWithBaseModelNull() throws IOException { - InputStream glossary = new FileInputStream(new File(RESOURCE + "glossary.tmx")); - final CreateModelOptions options = - new CreateModelOptions.Builder().forcedGlossary(glossary).build(); - service.createModel(options).execute(); - } +/** Unit test class for the LanguageTranslator service. */ +public class LanguageTranslatorTest { + + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + protected MockWebServer server; + protected LanguageTranslator languageTranslatorService; - /** Test create model with baseModelId null. */ - @Test(expected = IllegalArgumentException.class) - public void testcreateModelWithBaseModelIdNull() { - service.createModel(new CreateModelOptions.Builder().build()).execute(); + public void constructClientService() throws Throwable { + final String serviceName = "testService"; + // set mock values for global params + String version = "testString"; + + final Authenticator authenticator = new NoAuthAuthenticator(); + + languageTranslatorService = new LanguageTranslator(version, serviceName, authenticator); + String url = server.url("/").toString(); + languageTranslatorService.setServiceUrl(url); } - /** Test create model with glossary null. */ - @Test(expected = IllegalArgumentException.class) - public void testcreateModelWithGlossaryNull() { - service.createModel(new CreateModelOptions.Builder(modelId).build()).execute(); + /** Negative Test - construct the service with a null authenticator. */ + @Test(expectedExceptions = IllegalArgumentException.class) + public void testConstructorWithNullAuthenticator() throws Throwable { + final String serviceName = "testService"; + // set mock values for global params + String version = "testString"; + + new LanguageTranslator(version, serviceName, null); } - /** Test delete with null. */ - @Test(expected = IllegalArgumentException.class) - public void testDeleteWithNull() { - service.deleteModel(null).execute(); + @Test + public void testGetVersion() throws Throwable { + constructClientService(); + assertEquals(languageTranslatorService.getVersion(), "testString"); } - /** - * Test Get Identifiable languages. - * - * @throws InterruptedException the interrupted exception - */ @Test - public void testGetIdentifiableLanguages() throws InterruptedException { - server.enqueue(jsonResponse(identifiableLanguages)); + public void testListLanguagesWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"languages\": [{\"language\": \"language\", \"language_name\": \"languageName\", \"native_language_name\": \"nativeLanguageName\", \"country_code\": \"countryCode\", \"words_separated\": true, \"direction\": \"direction\", \"supported_as_source\": false, \"supported_as_target\": false, \"identifiable\": true}]}"; + String listLanguagesPath = "/v3/languages"; - List languages = - service.listIdentifiableLanguages().execute().getResult().getLanguages(); - RecordedRequest request = server.takeRequest(); + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); - assertEquals(IDENTIFIABLE_LANGUAGES_PATH + VERSION_PARAM, request.getPath()); - assertEquals(GSON.toJson(languages), GSON.toJson(identifiableLanguages.get("languages"))); - } + constructClientService(); - /** - * Test Get Model. - * - * @throws InterruptedException the interrupted exception - */ - @Test - public void testGetModel() throws InterruptedException { - server.enqueue(jsonResponse(model)); + // Construct an instance of the ListLanguagesOptions model + ListLanguagesOptions listLanguagesOptionsModel = new ListLanguagesOptions(); - GetModelOptions getOptions = new GetModelOptions.Builder(model.getModelId()).build(); - TranslationModel returnedModel = service.getModel(getOptions).execute().getResult(); - RecordedRequest request = server.takeRequest(); + // Invoke operation with valid options model (positive test) + Response response = + languageTranslatorService.listLanguages(listLanguagesOptionsModel).execute(); + assertNotNull(response); + Languages responseObj = response.getResult(); + assertNotNull(responseObj); - assertEquals(GET_MODELS_PATH + "/" + model.getModelId() + VERSION_PARAM, request.getPath()); - assertEquals(model, returnedModel); + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listLanguagesPath); } - /** - * Test Get Models. - * - * @throws InterruptedException the interrupted exception - */ @Test - public void testListModels() throws InterruptedException { - server.enqueue(jsonResponse(models)); + public void testTranslateWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"word_count\": 9, \"character_count\": 14, \"detected_language\": \"detectedLanguage\", \"detected_language_confidence\": 0, \"translations\": [{\"translation\": \"translation\"}]}"; + String translatePath = "/v3/translate"; - ListModelsOptions options = new ListModelsOptions.Builder().build(); - List modelList = - service.listModels(options).execute().getResult().getModels(); - RecordedRequest request = server.takeRequest(); + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the TranslateOptions model + TranslateOptions translateOptionsModel = + new TranslateOptions.Builder() + .text(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .modelId("testString") + .source("testString") + .target("testString") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + languageTranslatorService.translate(translateOptionsModel).execute(); + assertNotNull(response); + TranslationResult responseObj = response.getResult(); + assertNotNull(responseObj); - assertEquals(GET_MODELS_PATH + VERSION_PARAM, request.getPath()); - assertEquals(GSON.toJson(models.getModels()), GSON.toJson(modelList)); + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, translatePath); } - /** Test get model with null. */ - @Test(expected = IllegalArgumentException.class) - public void testGetModelWithNull() { - final String modelId = null; - GetModelOptions getOptions = new GetModelOptions.Builder(modelId).build(); - service.getModel(getOptions).execute(); + // Test the translate operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testTranslateNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + languageTranslatorService.translate(null).execute(); } - /** - * Test Identify. - * - * @throws InterruptedException the interrupted exception - */ @Test - public void testIdentify() throws InterruptedException { - server.enqueue(jsonResponse(identifiedLanguages)); + public void testListIdentifiableLanguagesWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = "{\"languages\": [{\"language\": \"language\", \"name\": \"name\"}]}"; + String listIdentifiableLanguagesPath = "/v3/identifiable_languages"; - final String text = texts.get(0); - IdentifyOptions identifyOptions = new IdentifyOptions.Builder(text).build(); - List identifiedLanguages = - service.identify(identifyOptions).execute().getResult().getLanguages(); - RecordedRequest request = server.takeRequest(); + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the ListIdentifiableLanguagesOptions model + ListIdentifiableLanguagesOptions listIdentifiableLanguagesOptionsModel = + new ListIdentifiableLanguagesOptions(); + + // Invoke operation with valid options model (positive test) + Response response = + languageTranslatorService + .listIdentifiableLanguages(listIdentifiableLanguagesOptionsModel) + .execute(); + assertNotNull(response); + IdentifiableLanguages responseObj = response.getResult(); + assertNotNull(responseObj); - assertEquals(IDENTITY_PATH + VERSION_PARAM, request.getPath()); - assertEquals("POST", request.getMethod()); - assertEquals(text, request.getBody().readUtf8()); - assertNotNull(identifiedLanguages); - assertFalse(identifiedLanguages.isEmpty()); - assertEquals(identifiedLanguages.get(0).getLanguage(), Language.ENGLISH); - assertEquals(identifiedLanguages.get(0).getConfidence(), 0.877159, 0.05); - assertEquals(identifiedLanguages.get(1).getLanguage(), Language.AFRIKAANS); - assertEquals(identifiedLanguages.get(1).getConfidence(), 0.0752636, 0.05); + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listIdentifiableLanguagesPath); } - /** - * Test translate. - * - * @throws InterruptedException the interrupted exception - */ @Test - public void testTranslate() throws InterruptedException { - server.enqueue(jsonResponse(singleTranslation)); + public void testIdentifyWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = "{\"languages\": [{\"language\": \"language\", \"confidence\": 0}]}"; + String identifyPath = "/v3/identify"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); - final String text = texts.get(0); - final Map requestBody = - ImmutableMap.of("text", Collections.singleton(text), "model_id", modelId); + // Construct an instance of the IdentifyOptions model + IdentifyOptions identifyOptionsModel = new IdentifyOptions.Builder().text("testString").build(); - TranslateOptions translateOptions = - new TranslateOptions.Builder().addText(text).modelId(modelId).build(); - TranslationResult translationResult = service.translate(translateOptions).execute().getResult(); + // Invoke operation with valid options model (positive test) + Response response = + languageTranslatorService.identify(identifyOptionsModel).execute(); + assertNotNull(response); + IdentifiedLanguages responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, identifyPath); + } + + // Test the identify operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testIdentifyNoOptions() throws Throwable { + // construct the service + constructClientService(); - assertEquals(LANGUAGE_TRANSLATION_PATH + VERSION_PARAM, request.getPath()); - assertEquals("POST", request.getMethod()); - assertEquals(GSON.toJson(requestBody), request.getBody().readUtf8()); - testTranslationResult(text, translationResult); + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + languageTranslatorService.identify(null).execute(); } - /** - * Test translate multiple texts. - * - * @throws InterruptedException the interrupted exception - */ @Test - public void testTranslateMultiple() throws InterruptedException { - server.enqueue(jsonResponse(multipleTranslations)); + public void testListModelsWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"models\": [{\"model_id\": \"modelId\", \"name\": \"name\", \"source\": \"source\", \"target\": \"target\", \"base_model_id\": \"baseModelId\", \"domain\": \"domain\", \"customizable\": true, \"default_model\": true, \"owner\": \"owner\", \"status\": \"uploading\"}]}"; + String listModelsPath = "/v3/models"; - final Map requestBody = ImmutableMap.of("text", texts, "model_id", modelId); + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the ListModelsOptions model + ListModelsOptions listModelsOptionsModel = + new ListModelsOptions.Builder() + .source("testString") + .target("testString") + .xDefault(true) + .build(); - TranslateOptions translateOptions = - new TranslateOptions.Builder().text(texts).modelId(modelId).build(); - TranslationResult translationResult = service.translate(translateOptions).execute().getResult(); - RecordedRequest request = server.takeRequest(); + // Invoke operation with valid options model (positive test) + Response response = + languageTranslatorService.listModels(listModelsOptionsModel).execute(); + assertNotNull(response); + TranslationModels responseObj = response.getResult(); + assertNotNull(responseObj); - assertEquals(LANGUAGE_TRANSLATION_PATH + VERSION_PARAM, request.getPath()); - assertEquals("POST", request.getMethod()); - assertEquals(GSON.toJson(requestBody), request.getBody().readUtf8()); - assertEquals(2, translationResult.getTranslations().size()); - assertEquals( - translations.get(texts.get(0)), - translationResult.getTranslations().get(0).getTranslation()); - assertEquals( - translations.get(texts.get(1)), - translationResult.getTranslations().get(1).getTranslation()); + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(query.get("source"), "testString"); + assertEquals(query.get("target"), "testString"); + assertEquals(Boolean.valueOf(query.get("default")), Boolean.valueOf(true)); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listModelsPath); } - /** Test Translate with an invalid model. */ - @Test(expected = BadRequestException.class) - public void testTranslateNotSupported() { - Map response = ImmutableMap.of("error_code", 400, "error message", "error"); - server.enqueue(jsonResponse(response).setResponseCode(400)); - TranslateOptions translateOptions = - new TranslateOptions.Builder().addText("X").modelId("FOO-BAR-FOO").build(); - service.translate(translateOptions).execute(); - } + @Test + public void testCreateModelWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"model_id\": \"modelId\", \"name\": \"name\", \"source\": \"source\", \"target\": \"target\", \"base_model_id\": \"baseModelId\", \"domain\": \"domain\", \"customizable\": true, \"default_model\": true, \"owner\": \"owner\", \"status\": \"uploading\"}"; + String createModelPath = "/v3/models"; - /** Test translate with null. */ - @Test(expected = IllegalArgumentException.class) - public void testTranslateWithNull() { - TranslateOptions translateOptions = new TranslateOptions.Builder().build(); - service.translate(translateOptions).execute(); - } + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the CreateModelOptions model + CreateModelOptions createModelOptionsModel = + new CreateModelOptions.Builder() + .baseModelId("testString") + .forcedGlossary(TestUtilities.createMockStream("This is a mock file.")) + .parallelCorpus(TestUtilities.createMockStream("This is a mock file.")) + .name("testString") + .build(); - /** - * Test translation result. - * - * @param text the text - * @param translationResult the translation result - */ - private void testTranslationResult(String text, TranslationResult translationResult) { - assertNotNull(translationResult); - assertEquals(translationResult.getWordCount().intValue(), text.split(" ").length); - assertNotNull(translationResult.getTranslations()); - assertNotNull(translationResult.getTranslations().get(0).getTranslation()); + // Invoke operation with valid options model (positive test) + Response response = + languageTranslatorService.createModel(createModelOptionsModel).execute(); + assertNotNull(response); + TranslationModel responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(query.get("base_model_id"), "testString"); + assertEquals(query.get("name"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createModelPath); } - /** Test translate options. */ - @Test - public void testTranslateOptions() { - final String text = "Hello, Watson!"; - - TranslateOptions options1 = - new TranslateOptions.Builder().addText(text).modelId(modelId).build(); - TranslateOptions.Builder builder = options1.newBuilder(); - TranslateOptions options2 = builder.text(texts).build(); - assertEquals(options2.text(), texts); - assertEquals(options2.modelId(), modelId); + // Test the createModel operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateModelNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + languageTranslatorService.createModel(null).execute(); } - /** Test create model options. */ @Test - public void testCreateModelOptions() { - - String myParallelCorpus = "{\"field\":\"value\"}"; - InputStream parallelCorpusStream = new ByteArrayInputStream(myParallelCorpus.getBytes()); - - CreateModelOptions options1 = - new CreateModelOptions.Builder(modelId).parallelCorpus(parallelCorpusStream).build(); - CreateModelOptions.Builder builder = options1.newBuilder(); - CreateModelOptions options2 = builder.name("baz").build(); - assertEquals(options2.baseModelId(), modelId); - assertEquals(options2.parallelCorpus(), parallelCorpusStream); - assertEquals(options2.name(), "baz"); + public void testDeleteModelWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = "{\"status\": \"status\"}"; + String deleteModelPath = "/v3/models/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the DeleteModelOptions model + DeleteModelOptions deleteModelOptionsModel = + new DeleteModelOptions.Builder().modelId("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = + languageTranslatorService.deleteModel(deleteModelOptionsModel).execute(); + assertNotNull(response); + DeleteModelResult responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteModelPath); } - /** Test list documents options. */ - @Test - public void testListDocumentsOptions() { - ListDocumentsOptions options = new ListDocumentsOptions.Builder().build(); - options = options.newBuilder().build(); + // Test the deleteModel operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteModelNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + languageTranslatorService.deleteModel(null).execute(); } - /** - * Test list documents. - * - * @throws InterruptedException the interrupted exception - */ @Test - public void testListDocuments() throws InterruptedException { - server.enqueue(jsonResponse(documentList)); - ListDocumentsOptions options = new ListDocumentsOptions.Builder().build(); - DocumentList response = service.listDocuments(options).execute().getResult(); + public void testGetModelWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"model_id\": \"modelId\", \"name\": \"name\", \"source\": \"source\", \"target\": \"target\", \"base_model_id\": \"baseModelId\", \"domain\": \"domain\", \"customizable\": true, \"default_model\": true, \"owner\": \"owner\", \"status\": \"uploading\"}"; + String getModelPath = "/v3/models/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the GetModelOptions model + GetModelOptions getModelOptionsModel = + new GetModelOptions.Builder().modelId("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = + languageTranslatorService.getModel(getModelOptionsModel).execute(); + assertNotNull(response); + TranslationModel responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getModelPath); + } + + // Test the getModel operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetModelNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); - assertEquals(GET, request.getMethod()); - assertEquals( - documentList.getDocuments().get(0).getDocumentId(), - response.getDocuments().get(0).getDocumentId()); - assertEquals( - documentList.getDocuments().get(0).getBaseModelId(), - response.getDocuments().get(0).getBaseModelId()); - assertEquals( - documentList.getDocuments().get(0).getCharacterCount(), - response.getDocuments().get(0).getCharacterCount()); - assertEquals( - documentList.getDocuments().get(0).getCompleted(), - response.getDocuments().get(0).getCompleted()); - assertEquals( - documentList.getDocuments().get(0).getCreated(), - response.getDocuments().get(0).getCreated()); - assertEquals( - documentList.getDocuments().get(0).getFilename(), - response.getDocuments().get(0).getFilename()); - assertEquals( - documentList.getDocuments().get(0).getModelId(), - response.getDocuments().get(0).getModelId()); - assertEquals( - documentList.getDocuments().get(0).getSource(), response.getDocuments().get(0).getSource()); - assertEquals( - documentList.getDocuments().get(0).getStatus(), response.getDocuments().get(0).getStatus()); - assertEquals( - documentList.getDocuments().get(0).getTarget(), response.getDocuments().get(0).getTarget()); - assertEquals( - documentList.getDocuments().get(0).getWordCount(), - response.getDocuments().get(0).getWordCount()); + // Invoke operation with null options model (negative test) + languageTranslatorService.getModel(null).execute(); } - /** - * Test list documents no options. - * - * @throws InterruptedException the interrupted exception - */ @Test - public void testListDocumentsNoOptions() throws InterruptedException { - server.enqueue(jsonResponse(documentList)); - DocumentList response = service.listDocuments().execute().getResult(); - RecordedRequest request = server.takeRequest(); + public void testListDocumentsWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"documents\": [{\"document_id\": \"documentId\", \"filename\": \"filename\", \"status\": \"processing\", \"model_id\": \"modelId\", \"base_model_id\": \"baseModelId\", \"source\": \"source\", \"detected_language_confidence\": 0, \"target\": \"target\", \"created\": \"2019-01-01T12:00:00\", \"completed\": \"2019-01-01T12:00:00\", \"word_count\": 9, \"character_count\": 14}]}"; + String listDocumentsPath = "/v3/documents"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); - assertEquals(GET, request.getMethod()); - assertEquals( - documentList.getDocuments().get(0).getDocumentId(), - response.getDocuments().get(0).getDocumentId()); - assertEquals( - documentList.getDocuments().get(0).getBaseModelId(), - response.getDocuments().get(0).getBaseModelId()); - assertEquals( - documentList.getDocuments().get(0).getCharacterCount(), - response.getDocuments().get(0).getCharacterCount()); - assertEquals( - documentList.getDocuments().get(0).getCompleted(), - response.getDocuments().get(0).getCompleted()); - assertEquals( - documentList.getDocuments().get(0).getCreated(), - response.getDocuments().get(0).getCreated()); - assertEquals( - documentList.getDocuments().get(0).getFilename(), - response.getDocuments().get(0).getFilename()); - assertEquals( - documentList.getDocuments().get(0).getModelId(), - response.getDocuments().get(0).getModelId()); - assertEquals( - documentList.getDocuments().get(0).getSource(), response.getDocuments().get(0).getSource()); - assertEquals( - documentList.getDocuments().get(0).getStatus(), response.getDocuments().get(0).getStatus()); - assertEquals( - documentList.getDocuments().get(0).getTarget(), response.getDocuments().get(0).getTarget()); - assertEquals( - documentList.getDocuments().get(0).getWordCount(), - response.getDocuments().get(0).getWordCount()); + constructClientService(); + + // Construct an instance of the ListDocumentsOptions model + ListDocumentsOptions listDocumentsOptionsModel = new ListDocumentsOptions(); + + // Invoke operation with valid options model (positive test) + Response response = + languageTranslatorService.listDocuments(listDocumentsOptionsModel).execute(); + assertNotNull(response); + DocumentList responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listDocumentsPath); } - /** - * Test translate document options. - * - * @throws FileNotFoundException the file not found exception - */ @Test - public void testTranslateDocumentOptions() throws FileNotFoundException { - File file = new File(RESOURCE + "document_to_translate.txt"); - String fileContentType = HttpMediaType.TEXT_PLAIN; - String filename = "filename"; - String modelId = "modelId"; - String source = "en"; - String target = "es"; - String documentId = "documentId"; - - TranslateDocumentOptions options = + public void testTranslateDocumentWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"document_id\": \"documentId\", \"filename\": \"filename\", \"status\": \"processing\", \"model_id\": \"modelId\", \"base_model_id\": \"baseModelId\", \"source\": \"source\", \"detected_language_confidence\": 0, \"target\": \"target\", \"created\": \"2019-01-01T12:00:00\", \"completed\": \"2019-01-01T12:00:00\", \"word_count\": 9, \"character_count\": 14}"; + String translateDocumentPath = "/v3/documents"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(202) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the TranslateDocumentOptions model + TranslateDocumentOptions translateDocumentOptionsModel = new TranslateDocumentOptions.Builder() - .file(file) - .fileContentType(fileContentType) - .filename(filename) - .modelId(modelId) - .source(source) - .target(target) - .documentId(documentId) + .file(TestUtilities.createMockStream("This is a mock file.")) + .filename("testString") + .fileContentType("application/powerpoint") + .modelId("testString") + .source("testString") + .target("testString") + .documentId("testString") .build(); - options = options.newBuilder().build(); - - assertNotNull(options.file()); - assertEquals(fileContentType, options.fileContentType()); - assertEquals(filename, options.filename()); - assertEquals(modelId, options.modelId()); - assertEquals(source, options.source()); - assertEquals(target, options.target()); - assertEquals(documentId, options.documentId()); - } - /** - * Test translate document. - * - * @throws FileNotFoundException the file not found exception - * @throws InterruptedException the interrupted exception - */ - @Test - public void testTranslateDocument() throws FileNotFoundException, InterruptedException { - server.enqueue(jsonResponse(documentStatus)); - File file = new File(RESOURCE + "document_to_translate.txt"); - TranslateDocumentOptions options = new TranslateDocumentOptions.Builder().file(file).build(); - DocumentStatus response = service.translateDocument(options).execute().getResult(); - RecordedRequest request = server.takeRequest(); + // Invoke operation with valid options model (positive test) + Response response = + languageTranslatorService.translateDocument(translateDocumentOptionsModel).execute(); + assertNotNull(response); + DocumentStatus responseObj = response.getResult(); + assertNotNull(responseObj); - assertEquals(POST, request.getMethod()); - assertEquals(documentStatus.getWordCount(), response.getWordCount()); - assertEquals(documentStatus.getTarget(), response.getTarget()); - assertEquals(documentStatus.getStatus(), response.getStatus()); - assertEquals(documentStatus.getSource(), response.getSource()); - assertEquals(documentStatus.getModelId(), response.getModelId()); - assertEquals(documentStatus.getFilename(), response.getFilename()); - assertEquals(documentStatus.getCreated(), response.getCreated()); - assertEquals(documentStatus.getCompleted(), response.getCompleted()); - assertEquals(documentStatus.getCharacterCount(), response.getCharacterCount()); - assertEquals(documentStatus.getBaseModelId(), response.getBaseModelId()); - assertEquals(documentStatus.getDocumentId(), response.getDocumentId()); + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, translateDocumentPath); } - /** Test get document status options. */ - @Test - public void testGetDocumentStatusOptions() { - String documentId = "documentId"; + // Test the translateDocument operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testTranslateDocumentNoOptions() throws Throwable { + // construct the service + constructClientService(); - GetDocumentStatusOptions options = - new GetDocumentStatusOptions.Builder().documentId(documentId).build(); - options = options.newBuilder().build(); + server.enqueue(new MockResponse()); - assertEquals(documentId, options.documentId()); + // Invoke operation with null options model (negative test) + languageTranslatorService.translateDocument(null).execute(); } - /** - * Test get document status. - * - * @throws InterruptedException the interrupted exception - */ @Test - public void testGetDocumentStatus() throws InterruptedException { - server.enqueue(jsonResponse(documentStatus)); - GetDocumentStatusOptions options = - new GetDocumentStatusOptions.Builder().documentId("documentId").build(); - DocumentStatus response = service.getDocumentStatus(options).execute().getResult(); - RecordedRequest request = server.takeRequest(); + public void testGetDocumentStatusWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"document_id\": \"documentId\", \"filename\": \"filename\", \"status\": \"processing\", \"model_id\": \"modelId\", \"base_model_id\": \"baseModelId\", \"source\": \"source\", \"detected_language_confidence\": 0, \"target\": \"target\", \"created\": \"2019-01-01T12:00:00\", \"completed\": \"2019-01-01T12:00:00\", \"word_count\": 9, \"character_count\": 14}"; + String getDocumentStatusPath = "/v3/documents/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); - assertEquals(GET, request.getMethod()); - assertEquals(documentStatus.getWordCount(), response.getWordCount()); - assertEquals(documentStatus.getTarget(), response.getTarget()); - assertEquals(documentStatus.getStatus(), response.getStatus()); - assertEquals(documentStatus.getSource(), response.getSource()); - assertEquals(documentStatus.getModelId(), response.getModelId()); - assertEquals(documentStatus.getFilename(), response.getFilename()); - assertEquals(documentStatus.getCreated(), response.getCreated()); - assertEquals(documentStatus.getCompleted(), response.getCompleted()); - assertEquals(documentStatus.getCharacterCount(), response.getCharacterCount()); - assertEquals(documentStatus.getBaseModelId(), response.getBaseModelId()); - assertEquals(documentStatus.getDocumentId(), response.getDocumentId()); + // Construct an instance of the GetDocumentStatusOptions model + GetDocumentStatusOptions getDocumentStatusOptionsModel = + new GetDocumentStatusOptions.Builder().documentId("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = + languageTranslatorService.getDocumentStatus(getDocumentStatusOptionsModel).execute(); + assertNotNull(response); + DocumentStatus responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getDocumentStatusPath); } - /** Test delete document options. */ - @Test - public void testDeleteDocumentOptions() { - String documentId = "documentId"; + // Test the getDocumentStatus operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetDocumentStatusNoOptions() throws Throwable { + // construct the service + constructClientService(); - DeleteDocumentOptions options = - new DeleteDocumentOptions.Builder().documentId(documentId).build(); - options = options.newBuilder().build(); + server.enqueue(new MockResponse()); - assertEquals(documentId, options.documentId()); + // Invoke operation with null options model (negative test) + languageTranslatorService.getDocumentStatus(null).execute(); } - /** - * Test delete document. - * - * @throws InterruptedException the interrupted exception - */ @Test - public void testDeleteDocument() throws InterruptedException { - server.enqueue(new MockResponse().setResponseCode(200)); - DeleteDocumentOptions options = - new DeleteDocumentOptions.Builder().documentId("documentId").build(); - service.deleteDocument(options).execute().getResult(); - RecordedRequest request = server.takeRequest(); + public void testDeleteDocumentWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String deleteDocumentPath = "/v3/documents/testString"; + + server.enqueue(new MockResponse().setResponseCode(204).setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the DeleteDocumentOptions model + DeleteDocumentOptions deleteDocumentOptionsModel = + new DeleteDocumentOptions.Builder().documentId("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = + languageTranslatorService.deleteDocument(deleteDocumentOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); - assertEquals(DELETE, request.getMethod()); + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteDocumentPath); } - /** Test get translated document options. */ - @Test - public void testGetTranslatedDocumentOptions() { - String documentId = "documentId"; - String accept = HttpMediaType.APPLICATION_JSON; + // Test the deleteDocument operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteDocumentNoOptions() throws Throwable { + // construct the service + constructClientService(); - GetTranslatedDocumentOptions options = - new GetTranslatedDocumentOptions.Builder().accept(accept).documentId(documentId).build(); - options = options.newBuilder().build(); + server.enqueue(new MockResponse()); - assertEquals(documentId, options.documentId()); - assertEquals(accept, options.accept()); + // Invoke operation with null options model (negative test) + languageTranslatorService.deleteDocument(null).execute(); } - /** - * Test get translated document. - * - * @throws IOException Signals that an I/O exception has occurred. - * @throws InterruptedException the interrupted exception - */ @Test - public void testGetTranslatedDocument() throws IOException, InterruptedException { - Buffer buffer = new Buffer().write(Files.toByteArray(translatedDocument)); + public void testGetTranslatedDocumentWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = "This is a mock binary response."; + String getTranslatedDocumentPath = "/v3/documents/testString/translated_document"; + server.enqueue( - new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.TEXT_PLAIN).setBody(buffer)); + new MockResponse() + .setHeader("Content-type", "application/powerpoint") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the GetTranslatedDocumentOptions model + GetTranslatedDocumentOptions getTranslatedDocumentOptionsModel = + new GetTranslatedDocumentOptions.Builder() + .documentId("testString") + .accept("application/powerpoint") + .build(); - GetTranslatedDocumentOptions options = - new GetTranslatedDocumentOptions.Builder().documentId("documentId").accept("").build(); - InputStream response = service.getTranslatedDocument(options).execute().getResult(); + // Invoke operation with valid options model (positive test) + Response response = + languageTranslatorService + .getTranslatedDocument(getTranslatedDocumentOptionsModel) + .execute(); + assertNotNull(response); + InputStream responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getTranslatedDocumentPath); + } - assertEquals(GET, request.getMethod()); - assertNotNull(response); + // Test the getTranslatedDocument operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetTranslatedDocumentNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + languageTranslatorService.getTranslatedDocument(null).execute(); + } + + /** Initialize the server */ + @BeforeMethod + public void setUpMockServer() { + try { + server = new MockWebServer(); + // register handler + server.start(); + } catch (IOException err) { + fail("Failed to instantiate mock web server"); + } + } + + @AfterMethod + public void tearDownMockServer() throws IOException { + server.shutdown(); + languageTranslatorService = null; } } diff --git a/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/CreateModelOptionsTest.java b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/CreateModelOptionsTest.java new file mode 100644 index 00000000000..16e5c367466 --- /dev/null +++ b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/CreateModelOptionsTest.java @@ -0,0 +1,55 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.language_translator.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.language_translator.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.apache.commons.io.IOUtils; +import org.testng.annotations.Test; + +/** Unit test class for the CreateModelOptions model. */ +public class CreateModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateModelOptions() throws Throwable { + CreateModelOptions createModelOptionsModel = + new CreateModelOptions.Builder() + .baseModelId("testString") + .forcedGlossary(TestUtilities.createMockStream("This is a mock file.")) + .parallelCorpus(TestUtilities.createMockStream("This is a mock file.")) + .name("testString") + .build(); + assertEquals(createModelOptionsModel.baseModelId(), "testString"); + assertEquals( + IOUtils.toString(createModelOptionsModel.forcedGlossary()), + IOUtils.toString(TestUtilities.createMockStream("This is a mock file."))); + assertEquals( + IOUtils.toString(createModelOptionsModel.parallelCorpus()), + IOUtils.toString(TestUtilities.createMockStream("This is a mock file."))); + assertEquals(createModelOptionsModel.name(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateModelOptionsError() throws Throwable { + new CreateModelOptions.Builder().build(); + } +} diff --git a/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/DeleteDocumentOptionsTest.java b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/DeleteDocumentOptionsTest.java new file mode 100644 index 00000000000..c96f25e1868 --- /dev/null +++ b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/DeleteDocumentOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.language_translator.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.language_translator.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteDocumentOptions model. */ +public class DeleteDocumentOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteDocumentOptions() throws Throwable { + DeleteDocumentOptions deleteDocumentOptionsModel = + new DeleteDocumentOptions.Builder().documentId("testString").build(); + assertEquals(deleteDocumentOptionsModel.documentId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteDocumentOptionsError() throws Throwable { + new DeleteDocumentOptions.Builder().build(); + } +} diff --git a/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/DeleteModelOptionsTest.java b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/DeleteModelOptionsTest.java new file mode 100644 index 00000000000..02782fd12c4 --- /dev/null +++ b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/DeleteModelOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.language_translator.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.language_translator.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteModelOptions model. */ +public class DeleteModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteModelOptions() throws Throwable { + DeleteModelOptions deleteModelOptionsModel = + new DeleteModelOptions.Builder().modelId("testString").build(); + assertEquals(deleteModelOptionsModel.modelId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteModelOptionsError() throws Throwable { + new DeleteModelOptions.Builder().build(); + } +} diff --git a/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/DeleteModelResultTest.java b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/DeleteModelResultTest.java new file mode 100644 index 00000000000..8537d3643c5 --- /dev/null +++ b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/DeleteModelResultTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.language_translator.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.language_translator.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteModelResult model. */ +public class DeleteModelResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteModelResult() throws Throwable { + DeleteModelResult deleteModelResultModel = new DeleteModelResult(); + assertNull(deleteModelResultModel.getStatus()); + } +} diff --git a/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/DocumentListTest.java b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/DocumentListTest.java new file mode 100644 index 00000000000..1cac44e874f --- /dev/null +++ b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/DocumentListTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.language_translator.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.language_translator.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DocumentList model. */ +public class DocumentListTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDocumentList() throws Throwable { + DocumentList documentListModel = new DocumentList(); + assertNull(documentListModel.getDocuments()); + } +} diff --git a/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/DocumentStatusTest.java b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/DocumentStatusTest.java new file mode 100644 index 00000000000..a1009008c6b --- /dev/null +++ b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/DocumentStatusTest.java @@ -0,0 +1,47 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.language_translator.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.language_translator.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DocumentStatus model. */ +public class DocumentStatusTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDocumentStatus() throws Throwable { + DocumentStatus documentStatusModel = new DocumentStatus(); + assertNull(documentStatusModel.getDocumentId()); + assertNull(documentStatusModel.getFilename()); + assertNull(documentStatusModel.getStatus()); + assertNull(documentStatusModel.getModelId()); + assertNull(documentStatusModel.getBaseModelId()); + assertNull(documentStatusModel.getSource()); + assertNull(documentStatusModel.getDetectedLanguageConfidence()); + assertNull(documentStatusModel.getTarget()); + assertNull(documentStatusModel.getCreated()); + assertNull(documentStatusModel.getCompleted()); + assertNull(documentStatusModel.getWordCount()); + assertNull(documentStatusModel.getCharacterCount()); + } +} diff --git a/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/GetDocumentStatusOptionsTest.java b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/GetDocumentStatusOptionsTest.java new file mode 100644 index 00000000000..00dfee6957c --- /dev/null +++ b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/GetDocumentStatusOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.language_translator.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.language_translator.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetDocumentStatusOptions model. */ +public class GetDocumentStatusOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetDocumentStatusOptions() throws Throwable { + GetDocumentStatusOptions getDocumentStatusOptionsModel = + new GetDocumentStatusOptions.Builder().documentId("testString").build(); + assertEquals(getDocumentStatusOptionsModel.documentId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetDocumentStatusOptionsError() throws Throwable { + new GetDocumentStatusOptions.Builder().build(); + } +} diff --git a/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/GetModelOptionsTest.java b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/GetModelOptionsTest.java new file mode 100644 index 00000000000..ed26f06d892 --- /dev/null +++ b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/GetModelOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.language_translator.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.language_translator.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetModelOptions model. */ +public class GetModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetModelOptions() throws Throwable { + GetModelOptions getModelOptionsModel = + new GetModelOptions.Builder().modelId("testString").build(); + assertEquals(getModelOptionsModel.modelId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetModelOptionsError() throws Throwable { + new GetModelOptions.Builder().build(); + } +} diff --git a/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/GetTranslatedDocumentOptionsTest.java b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/GetTranslatedDocumentOptionsTest.java new file mode 100644 index 00000000000..ea72b80b9b5 --- /dev/null +++ b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/GetTranslatedDocumentOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.language_translator.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.language_translator.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetTranslatedDocumentOptions model. */ +public class GetTranslatedDocumentOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetTranslatedDocumentOptions() throws Throwable { + GetTranslatedDocumentOptions getTranslatedDocumentOptionsModel = + new GetTranslatedDocumentOptions.Builder() + .documentId("testString") + .accept("application/powerpoint") + .build(); + assertEquals(getTranslatedDocumentOptionsModel.documentId(), "testString"); + assertEquals(getTranslatedDocumentOptionsModel.accept(), "application/powerpoint"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetTranslatedDocumentOptionsError() throws Throwable { + new GetTranslatedDocumentOptions.Builder().build(); + } +} diff --git a/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/IdentifiableLanguageTest.java b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/IdentifiableLanguageTest.java new file mode 100644 index 00000000000..38d6afa381f --- /dev/null +++ b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/IdentifiableLanguageTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.language_translator.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.language_translator.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the IdentifiableLanguage model. */ +public class IdentifiableLanguageTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testIdentifiableLanguage() throws Throwable { + IdentifiableLanguage identifiableLanguageModel = new IdentifiableLanguage(); + assertNull(identifiableLanguageModel.getLanguage()); + assertNull(identifiableLanguageModel.getName()); + } +} diff --git a/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/IdentifiableLanguagesTest.java b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/IdentifiableLanguagesTest.java new file mode 100644 index 00000000000..574ccb6888d --- /dev/null +++ b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/IdentifiableLanguagesTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.language_translator.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.language_translator.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the IdentifiableLanguages model. */ +public class IdentifiableLanguagesTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testIdentifiableLanguages() throws Throwable { + IdentifiableLanguages identifiableLanguagesModel = new IdentifiableLanguages(); + assertNull(identifiableLanguagesModel.getLanguages()); + } +} diff --git a/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/IdentifiedLanguageTest.java b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/IdentifiedLanguageTest.java new file mode 100644 index 00000000000..a4d02b0c732 --- /dev/null +++ b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/IdentifiedLanguageTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.language_translator.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.language_translator.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the IdentifiedLanguage model. */ +public class IdentifiedLanguageTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testIdentifiedLanguage() throws Throwable { + IdentifiedLanguage identifiedLanguageModel = new IdentifiedLanguage(); + assertNull(identifiedLanguageModel.getLanguage()); + assertNull(identifiedLanguageModel.getConfidence()); + } +} diff --git a/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/IdentifiedLanguagesTest.java b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/IdentifiedLanguagesTest.java new file mode 100644 index 00000000000..132aec42388 --- /dev/null +++ b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/IdentifiedLanguagesTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.language_translator.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.language_translator.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the IdentifiedLanguages model. */ +public class IdentifiedLanguagesTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testIdentifiedLanguages() throws Throwable { + IdentifiedLanguages identifiedLanguagesModel = new IdentifiedLanguages(); + assertNull(identifiedLanguagesModel.getLanguages()); + } +} diff --git a/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/IdentifyOptionsTest.java b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/IdentifyOptionsTest.java new file mode 100644 index 00000000000..f85f5707dd1 --- /dev/null +++ b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/IdentifyOptionsTest.java @@ -0,0 +1,41 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.language_translator.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.language_translator.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the IdentifyOptions model. */ +public class IdentifyOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testIdentifyOptions() throws Throwable { + IdentifyOptions identifyOptionsModel = new IdentifyOptions.Builder().text("testString").build(); + assertEquals(identifyOptionsModel.text(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testIdentifyOptionsError() throws Throwable { + new IdentifyOptions.Builder().build(); + } +} diff --git a/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/LanguageTest.java b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/LanguageTest.java new file mode 100644 index 00000000000..12ee1374a5d --- /dev/null +++ b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/LanguageTest.java @@ -0,0 +1,44 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.language_translator.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.language_translator.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Language model. */ +public class LanguageTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testLanguage() throws Throwable { + Language languageModel = new Language(); + assertNull(languageModel.getLanguage()); + assertNull(languageModel.getLanguageName()); + assertNull(languageModel.getNativeLanguageName()); + assertNull(languageModel.getCountryCode()); + assertNull(languageModel.isWordsSeparated()); + assertNull(languageModel.getDirection()); + assertNull(languageModel.isSupportedAsSource()); + assertNull(languageModel.isSupportedAsTarget()); + assertNull(languageModel.isIdentifiable()); + } +} diff --git a/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/LanguagesTest.java b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/LanguagesTest.java new file mode 100644 index 00000000000..9b7b92c13fd --- /dev/null +++ b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/LanguagesTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.language_translator.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.language_translator.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Languages model. */ +public class LanguagesTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testLanguages() throws Throwable { + Languages languagesModel = new Languages(); + assertNull(languagesModel.getLanguages()); + } +} diff --git a/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/ListDocumentsOptionsTest.java b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/ListDocumentsOptionsTest.java new file mode 100644 index 00000000000..70b62c22cb7 --- /dev/null +++ b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/ListDocumentsOptionsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.language_translator.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.language_translator.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListDocumentsOptions model. */ +public class ListDocumentsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListDocumentsOptions() throws Throwable { + ListDocumentsOptions listDocumentsOptionsModel = new ListDocumentsOptions(); + assertNotNull(listDocumentsOptionsModel); + } +} diff --git a/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/ListIdentifiableLanguagesOptionsTest.java b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/ListIdentifiableLanguagesOptionsTest.java new file mode 100644 index 00000000000..e8c6a929850 --- /dev/null +++ b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/ListIdentifiableLanguagesOptionsTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.language_translator.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.language_translator.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListIdentifiableLanguagesOptions model. */ +public class ListIdentifiableLanguagesOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListIdentifiableLanguagesOptions() throws Throwable { + ListIdentifiableLanguagesOptions listIdentifiableLanguagesOptionsModel = + new ListIdentifiableLanguagesOptions(); + assertNotNull(listIdentifiableLanguagesOptionsModel); + } +} diff --git a/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/ListLanguagesOptionsTest.java b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/ListLanguagesOptionsTest.java new file mode 100644 index 00000000000..9f984801866 --- /dev/null +++ b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/ListLanguagesOptionsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.language_translator.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.language_translator.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListLanguagesOptions model. */ +public class ListLanguagesOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListLanguagesOptions() throws Throwable { + ListLanguagesOptions listLanguagesOptionsModel = new ListLanguagesOptions(); + assertNotNull(listLanguagesOptionsModel); + } +} diff --git a/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/ListModelsOptionsTest.java b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/ListModelsOptionsTest.java new file mode 100644 index 00000000000..df432681d29 --- /dev/null +++ b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/ListModelsOptionsTest.java @@ -0,0 +1,43 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.language_translator.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.language_translator.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListModelsOptions model. */ +public class ListModelsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListModelsOptions() throws Throwable { + ListModelsOptions listModelsOptionsModel = + new ListModelsOptions.Builder() + .source("testString") + .target("testString") + .xDefault(true) + .build(); + assertEquals(listModelsOptionsModel.source(), "testString"); + assertEquals(listModelsOptionsModel.target(), "testString"); + assertEquals(listModelsOptionsModel.xDefault(), Boolean.valueOf(true)); + } +} diff --git a/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/TranslateDocumentOptionsTest.java b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/TranslateDocumentOptionsTest.java new file mode 100644 index 00000000000..c90570d7e4a --- /dev/null +++ b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/TranslateDocumentOptionsTest.java @@ -0,0 +1,59 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.language_translator.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.language_translator.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.apache.commons.io.IOUtils; +import org.testng.annotations.Test; + +/** Unit test class for the TranslateDocumentOptions model. */ +public class TranslateDocumentOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTranslateDocumentOptions() throws Throwable { + TranslateDocumentOptions translateDocumentOptionsModel = + new TranslateDocumentOptions.Builder() + .file(TestUtilities.createMockStream("This is a mock file.")) + .filename("testString") + .fileContentType("application/powerpoint") + .modelId("testString") + .source("testString") + .target("testString") + .documentId("testString") + .build(); + assertEquals( + IOUtils.toString(translateDocumentOptionsModel.file()), + IOUtils.toString(TestUtilities.createMockStream("This is a mock file."))); + assertEquals(translateDocumentOptionsModel.filename(), "testString"); + assertEquals(translateDocumentOptionsModel.fileContentType(), "application/powerpoint"); + assertEquals(translateDocumentOptionsModel.modelId(), "testString"); + assertEquals(translateDocumentOptionsModel.source(), "testString"); + assertEquals(translateDocumentOptionsModel.target(), "testString"); + assertEquals(translateDocumentOptionsModel.documentId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testTranslateDocumentOptionsError() throws Throwable { + new TranslateDocumentOptions.Builder().build(); + } +} diff --git a/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/TranslateOptionsTest.java b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/TranslateOptionsTest.java new file mode 100644 index 00000000000..cefc8ced006 --- /dev/null +++ b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/TranslateOptionsTest.java @@ -0,0 +1,52 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.language_translator.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.language_translator.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TranslateOptions model. */ +public class TranslateOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTranslateOptions() throws Throwable { + TranslateOptions translateOptionsModel = + new TranslateOptions.Builder() + .text(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .modelId("testString") + .source("testString") + .target("testString") + .build(); + assertEquals( + translateOptionsModel.text(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals(translateOptionsModel.modelId(), "testString"); + assertEquals(translateOptionsModel.source(), "testString"); + assertEquals(translateOptionsModel.target(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testTranslateOptionsError() throws Throwable { + new TranslateOptions.Builder().build(); + } +} diff --git a/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/TranslationModelTest.java b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/TranslationModelTest.java new file mode 100644 index 00000000000..522411ac5b2 --- /dev/null +++ b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/TranslationModelTest.java @@ -0,0 +1,45 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.language_translator.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.language_translator.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TranslationModel model. */ +public class TranslationModelTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTranslationModel() throws Throwable { + TranslationModel translationModelModel = new TranslationModel(); + assertNull(translationModelModel.getModelId()); + assertNull(translationModelModel.getName()); + assertNull(translationModelModel.getSource()); + assertNull(translationModelModel.getTarget()); + assertNull(translationModelModel.getBaseModelId()); + assertNull(translationModelModel.getDomain()); + assertNull(translationModelModel.isCustomizable()); + assertNull(translationModelModel.isDefaultModel()); + assertNull(translationModelModel.getOwner()); + assertNull(translationModelModel.getStatus()); + } +} diff --git a/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/TranslationModelsTest.java b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/TranslationModelsTest.java new file mode 100644 index 00000000000..6f45a8af8ca --- /dev/null +++ b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/TranslationModelsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.language_translator.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.language_translator.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TranslationModels model. */ +public class TranslationModelsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTranslationModels() throws Throwable { + TranslationModels translationModelsModel = new TranslationModels(); + assertNull(translationModelsModel.getModels()); + } +} diff --git a/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/TranslationResultTest.java b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/TranslationResultTest.java new file mode 100644 index 00000000000..0637ea00c4c --- /dev/null +++ b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/TranslationResultTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.language_translator.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.language_translator.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TranslationResult model. */ +public class TranslationResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTranslationResult() throws Throwable { + TranslationResult translationResultModel = new TranslationResult(); + assertNull(translationResultModel.getWordCount()); + assertNull(translationResultModel.getCharacterCount()); + assertNull(translationResultModel.getDetectedLanguage()); + assertNull(translationResultModel.getDetectedLanguageConfidence()); + assertNull(translationResultModel.getTranslations()); + } +} diff --git a/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/TranslationTest.java b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/TranslationTest.java new file mode 100644 index 00000000000..026918e149c --- /dev/null +++ b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/model/TranslationTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.language_translator.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.language_translator.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Translation model. */ +public class TranslationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTranslation() throws Throwable { + Translation translationModel = new Translation(); + assertNull(translationModel.getTranslation()); + } +} diff --git a/language-translator/src/test/java/com/ibm/watson/language_translator/v3/utils/TestUtilities.java b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/utils/TestUtilities.java new file mode 100644 index 00000000000..7e4a2b959ff --- /dev/null +++ b/language-translator/src/test/java/com/ibm/watson/language_translator/v3/utils/TestUtilities.java @@ -0,0 +1,128 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.language_translator.v3.utils; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.cloud.sdk.core.util.GsonSingleton; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import okhttp3.HttpUrl; +import okhttp3.mockwebserver.RecordedRequest; + +/** A class used by the unit tests containing utility functions. */ +public class TestUtilities { + public static Map createMockMap() { + Map mockMap = new HashMap<>(); + mockMap.put("foo", "bar"); + return mockMap; + } + + public static HashMap createMockStreamMap() { + return new HashMap() { + { + put("key1", createMockStream("This is a mock file.")); + } + }; + } + + public static Map parseQueryString(RecordedRequest req) { + Map queryMap = new HashMap<>(); + + try { + HttpUrl requestUrl = req.getRequestUrl(); + + if (requestUrl != null) { + Set queryParamsNames = requestUrl.queryParameterNames(); + // map the parameter name to its corresponding value + for (String p : queryParamsNames) { + // get the corresponding value for the parameter (p) + List val = requestUrl.queryParameterValues(p); + if (val != null && !val.isEmpty()) { + String joinedQuery = String.join(",", val); + queryMap.put(p, joinedQuery); + } + } + } + if (queryMap.isEmpty()) { + return null; + } + } catch (Exception e) { + return null; + } + + return queryMap; + } + + public static String parseReqPath(RecordedRequest req) { + String parsedPath = null; + + try { + String fullPath = req.getPath(); + if (fullPath != null && !fullPath.isEmpty()) { + // retrieve the path segment before the query parameter + parsedPath = fullPath.split("\\?", 2)[0]; + } + if (parsedPath.isEmpty() || parsedPath == null) { + return null; + } + + } catch (Exception e) { + return null; + } + + return parsedPath; + } + + public static String serialize(Object obj) { + return GsonSingleton.getGson().toJson(obj); + } + + public static T deserialize(String json, Class clazz) { + return GsonSingleton.getGson().fromJson(json, clazz); + } + + public static InputStream createMockStream(String s) { + return new ByteArrayInputStream(s.getBytes()); + } + + public static List creatMockListFileWithMetadata() { + List list = new ArrayList(); + byte[] fileBytes = {(byte) 0xde, (byte) 0xad, (byte) 0xbe, (byte) 0xef}; + InputStream inputStream = new ByteArrayInputStream(fileBytes); + FileWithMetadata.Builder builder = new FileWithMetadata.Builder(); + builder.data(inputStream); + FileWithMetadata fileWithMetadata = builder.build(); + list.add(fileWithMetadata); + + return list; + } + + public static byte[] createMockByteArray(String bytes) { + return bytes.getBytes(); + } + + public static Date createMockDate(String date) throws Exception { + return new SimpleDateFormat("yyyy-MM-dd").parse(date); + } + + public static Date createMockDateTime(String date) throws Exception { + return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").parse(date); + } +} diff --git a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/NaturalLanguageClassifier.java b/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/NaturalLanguageClassifier.java index 3b9b779a4f9..6509f04b718 100644 --- a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/NaturalLanguageClassifier.java +++ b/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/NaturalLanguageClassifier.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -10,6 +10,11 @@ * 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. */ + +/* + * IBM OpenAPI SDK Code Generator Version: 99-SNAPSHOT-7cc05500-20201106-154555 + */ + package com.ibm.watson.natural_language_classifier.v1; import com.google.gson.JsonObject; @@ -32,27 +37,32 @@ import com.ibm.watson.natural_language_classifier.v1.model.DeleteClassifierOptions; import com.ibm.watson.natural_language_classifier.v1.model.GetClassifierOptions; import com.ibm.watson.natural_language_classifier.v1.model.ListClassifiersOptions; +import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; import okhttp3.MultipartBody; /** - * IBM Watson™ Natural Language Classifier uses machine learning algorithms to return the top - * matching predefined classes for short text input. You create and train a classifier to connect - * predefined classes to example texts so that the service can apply those classes to new inputs. + * IBM Watson&trade; Natural Language Classifier uses machine learning algorithms to return the + * top matching predefined classes for short text input. You create and train a classifier to + * connect predefined classes to example texts so that the service can apply those classes to new + * inputs. * * @version v1 - * @see Natural Language + * @see Natural Language * Classifier */ public class NaturalLanguageClassifier extends BaseService { - private static final String DEFAULT_SERVICE_NAME = "natural_language_classifier"; + public static final String DEFAULT_SERVICE_NAME = "natural_language_classifier"; - private static final String DEFAULT_SERVICE_URL = + public static final String DEFAULT_SERVICE_URL = "https://api.us-south.natural-language-classifier.watson.cloud.ibm.com"; - /** Constructs a new `NaturalLanguageClassifier` client using the DEFAULT_SERVICE_NAME. */ + /** + * Constructs an instance of the `NaturalLanguageClassifier` client. The default service name is + * used to configure the client instance. + */ public NaturalLanguageClassifier() { this( DEFAULT_SERVICE_NAME, @@ -60,30 +70,31 @@ public NaturalLanguageClassifier() { } /** - * Constructs a new `NaturalLanguageClassifier` client with the DEFAULT_SERVICE_NAME and the - * specified Authenticator. + * Constructs an instance of the `NaturalLanguageClassifier` client. The default service name and + * specified authenticator are used to configure the client instance. * - * @param authenticator the Authenticator instance to be configured for this service + * @param authenticator the {@link Authenticator} instance to be configured for this client */ public NaturalLanguageClassifier(Authenticator authenticator) { this(DEFAULT_SERVICE_NAME, authenticator); } /** - * Constructs a new `NaturalLanguageClassifier` client with the specified serviceName. + * Constructs an instance of the `NaturalLanguageClassifier` client. The specified service name is + * used to configure the client instance. * - * @param serviceName The name of the service to configure. + * @param serviceName the service name to be used when configuring the client instance */ public NaturalLanguageClassifier(String serviceName) { this(serviceName, ConfigBasedAuthenticatorFactory.getAuthenticator(serviceName)); } /** - * Constructs a new `NaturalLanguageClassifier` client with the specified Authenticator and - * serviceName. + * Constructs an instance of the `NaturalLanguageClassifier` client. The specified service name + * and authenticator are used to configure the client instance. * - * @param serviceName The name of the service to configure. - * @param authenticator the Authenticator instance to be configured for this service + * @param serviceName the service name to be used when configuring the client instance + * @param authenticator the {@link Authenticator} instance to be configured for this client */ public NaturalLanguageClassifier(String serviceName, Authenticator authenticator) { super(serviceName, authenticator); @@ -98,16 +109,17 @@ public NaturalLanguageClassifier(String serviceName, Authenticator authenticator * the classifier to classify text. * * @param classifyOptions the {@link ClassifyOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Classification} + * @return a {@link ServiceCall} with a result of type {@link Classification} */ public ServiceCall classify(ClassifyOptions classifyOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( classifyOptions, "classifyOptions cannot be null"); - String[] pathSegments = {"v1/classifiers", "classify"}; - String[] pathParameters = {classifyOptions.classifierId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("classifier_id", classifyOptions.classifierId()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/classifiers/{classifier_id}/classify", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("natural_language_classifier", "v1", "classify"); for (Entry header : sdkHeaders.entrySet()) { @@ -133,17 +145,20 @@ public ServiceCall classify(ClassifyOptions classifyOptions) { * * @param classifyCollectionOptions the {@link ClassifyCollectionOptions} containing the options * for the call - * @return a {@link ServiceCall} with a response type of {@link ClassificationCollection} + * @return a {@link ServiceCall} with a result of type {@link ClassificationCollection} */ public ServiceCall classifyCollection( ClassifyCollectionOptions classifyCollectionOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( classifyCollectionOptions, "classifyCollectionOptions cannot be null"); - String[] pathSegments = {"v1/classifiers", "classify_collection"}; - String[] pathParameters = {classifyCollectionOptions.classifierId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("classifier_id", classifyCollectionOptions.classifierId()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/classifiers/{classifier_id}/classify_collection", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("natural_language_classifier", "v1", "classifyCollection"); for (Entry header : sdkHeaders.entrySet()) { @@ -170,14 +185,13 @@ public ServiceCall classifyCollection( * * @param createClassifierOptions the {@link CreateClassifierOptions} containing the options for * the call - * @return a {@link ServiceCall} with a response type of {@link Classifier} + * @return a {@link ServiceCall} with a result of type {@link Classifier} */ public ServiceCall createClassifier(CreateClassifierOptions createClassifierOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( createClassifierOptions, "createClassifierOptions cannot be null"); - String[] pathSegments = {"v1/classifiers"}; RequestBuilder builder = - RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); + RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/classifiers")); Map sdkHeaders = SdkCommon.getSdkHeaders("natural_language_classifier", "v1", "createClassifier"); for (Entry header : sdkHeaders.entrySet()) { @@ -207,21 +221,18 @@ public ServiceCall createClassifier(CreateClassifierOptions createCl * * @param listClassifiersOptions the {@link ListClassifiersOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of {@link ClassifierList} + * @return a {@link ServiceCall} with a result of type {@link ClassifierList} */ public ServiceCall listClassifiers( ListClassifiersOptions listClassifiersOptions) { - String[] pathSegments = {"v1/classifiers"}; RequestBuilder builder = - RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); + RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/classifiers")); Map sdkHeaders = SdkCommon.getSdkHeaders("natural_language_classifier", "v1", "listClassifiers"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - if (listClassifiersOptions != null) {} - ResponseConverter responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken() {}.getType()); @@ -233,7 +244,7 @@ public ServiceCall listClassifiers( * *

Returns an empty array if no classifiers are available. * - * @return a {@link ServiceCall} with a response type of {@link ClassifierList} + * @return a {@link ServiceCall} with a result of type {@link ClassifierList} */ public ServiceCall listClassifiers() { return listClassifiers(null); @@ -246,23 +257,23 @@ public ServiceCall listClassifiers() { * * @param getClassifierOptions the {@link GetClassifierOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of {@link Classifier} + * @return a {@link ServiceCall} with a result of type {@link Classifier} */ public ServiceCall getClassifier(GetClassifierOptions getClassifierOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( getClassifierOptions, "getClassifierOptions cannot be null"); - String[] pathSegments = {"v1/classifiers"}; - String[] pathParameters = {getClassifierOptions.classifierId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("classifier_id", getClassifierOptions.classifierId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/classifiers/{classifier_id}", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("natural_language_classifier", "v1", "getClassifier"); 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()); @@ -274,23 +285,23 @@ public ServiceCall getClassifier(GetClassifierOptions getClassifierO * * @param deleteClassifierOptions the {@link DeleteClassifierOptions} containing the options for * the call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteClassifier(DeleteClassifierOptions deleteClassifierOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( deleteClassifierOptions, "deleteClassifierOptions cannot be null"); - String[] pathSegments = {"v1/classifiers"}; - String[] pathParameters = {deleteClassifierOptions.classifierId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("classifier_id", deleteClassifierOptions.classifierId()); RequestBuilder builder = RequestBuilder.delete( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/classifiers/{classifier_id}", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("natural_language_classifier", "v1", "deleteClassifier"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } diff --git a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/Classification.java b/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/Classification.java index f89e0f16e08..80370c099c6 100644 --- a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/Classification.java +++ b/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/Classification.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2016, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/ClassificationCollection.java b/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/ClassificationCollection.java index fc537d1de19..1ea6ca0b007 100644 --- a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/ClassificationCollection.java +++ b/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/ClassificationCollection.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/ClassifiedClass.java b/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/ClassifiedClass.java index 00f08ea50d0..07a1b940d13 100644 --- a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/ClassifiedClass.java +++ b/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/ClassifiedClass.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/Classifier.java b/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/Classifier.java index ff66b91477d..407b0724d65 100644 --- a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/Classifier.java +++ b/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/Classifier.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2016, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/ClassifierList.java b/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/ClassifierList.java index 6a8e7471026..8c672a5f428 100644 --- a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/ClassifierList.java +++ b/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/ClassifierList.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/ClassifyCollectionOptions.java b/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/ClassifyCollectionOptions.java index cd76350f9e1..6f0fbb03db3 100644 --- a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/ClassifyCollectionOptions.java +++ b/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/ClassifyCollectionOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -49,7 +49,7 @@ public Builder(String classifierId, List collection) { /** * Builds a ClassifyCollectionOptions. * - * @return the classifyCollectionOptions + * @return the new ClassifyCollectionOptions instance */ public ClassifyCollectionOptions build() { return new ClassifyCollectionOptions(this); diff --git a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/ClassifyInput.java b/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/ClassifyInput.java index ef5b359a5af..c238fb09276 100644 --- a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/ClassifyInput.java +++ b/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/ClassifyInput.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -42,7 +42,7 @@ public Builder(String text) { /** * Builds a ClassifyInput. * - * @return the classifyInput + * @return the new ClassifyInput instance */ public ClassifyInput build() { return new ClassifyInput(this); diff --git a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/ClassifyOptions.java b/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/ClassifyOptions.java index 7e4133ccb9c..ba4fbf8bf11 100644 --- a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/ClassifyOptions.java +++ b/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/ClassifyOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -47,7 +47,7 @@ public Builder(String classifierId, String text) { /** * Builds a ClassifyOptions. * - * @return the classifyOptions + * @return the new ClassifyOptions instance */ public ClassifyOptions build() { return new ClassifyOptions(this); diff --git a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/CollectionItem.java b/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/CollectionItem.java index 42c58053747..3d989733891 100644 --- a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/CollectionItem.java +++ b/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/CollectionItem.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/CreateClassifierOptions.java b/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/CreateClassifierOptions.java index 0986b14effd..7e5fb81e02e 100644 --- a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/CreateClassifierOptions.java +++ b/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/CreateClassifierOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -51,7 +51,7 @@ public Builder(InputStream trainingMetadata, InputStream trainingData) { /** * Builds a CreateClassifierOptions. * - * @return the createClassifierOptions + * @return the new CreateClassifierOptions instance */ public CreateClassifierOptions build() { return new CreateClassifierOptions(this); diff --git a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/DeleteClassifierOptions.java b/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/DeleteClassifierOptions.java index 313ba47b7cd..349c2ad4dc1 100644 --- a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/DeleteClassifierOptions.java +++ b/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/DeleteClassifierOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -42,7 +42,7 @@ public Builder(String classifierId) { /** * Builds a DeleteClassifierOptions. * - * @return the deleteClassifierOptions + * @return the new DeleteClassifierOptions instance */ public DeleteClassifierOptions build() { return new DeleteClassifierOptions(this); diff --git a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/GetClassifierOptions.java b/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/GetClassifierOptions.java index 118834fbacd..cd8072cc264 100644 --- a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/GetClassifierOptions.java +++ b/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/GetClassifierOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -42,7 +42,7 @@ public Builder(String classifierId) { /** * Builds a GetClassifierOptions. * - * @return the getClassifierOptions + * @return the new GetClassifierOptions instance */ public GetClassifierOptions build() { return new GetClassifierOptions(this); diff --git a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/ListClassifiersOptions.java b/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/ListClassifiersOptions.java index a24aed424d3..48327ae5557 100644 --- a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/ListClassifiersOptions.java +++ b/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/model/ListClassifiersOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -15,34 +15,4 @@ import com.ibm.cloud.sdk.core.service.model.GenericModel; /** The listClassifiers options. */ -public class ListClassifiersOptions extends GenericModel { - - /** Builder. */ - public static class Builder { - - private Builder(ListClassifiersOptions listClassifiersOptions) {} - - /** Instantiates a new builder. */ - public Builder() {} - - /** - * Builds a ListClassifiersOptions. - * - * @return the listClassifiersOptions - */ - public ListClassifiersOptions build() { - return new ListClassifiersOptions(this); - } - } - - private ListClassifiersOptions(Builder builder) {} - - /** - * New builder. - * - * @return a ListClassifiersOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } -} +public class ListClassifiersOptions extends GenericModel {} diff --git a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/package-info.java b/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/package-info.java index d93302baf41..a6bfac5cb75 100644 --- a/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/package-info.java +++ b/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/package-info.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/natural-language-classifier/src/test/java/com/ibm/watson/natural_language_classifier/v1/NaturalLanguageClassifierTest.java b/natural-language-classifier/src/test/java/com/ibm/watson/natural_language_classifier/v1/NaturalLanguageClassifierTest.java index b789c7090a1..f8911d78b49 100644 --- a/natural-language-classifier/src/test/java/com/ibm/watson/natural_language_classifier/v1/NaturalLanguageClassifierTest.java +++ b/natural-language-classifier/src/test/java/com/ibm/watson/natural_language_classifier/v1/NaturalLanguageClassifierTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -12,11 +12,12 @@ */ package com.ibm.watson.natural_language_classifier.v1; -import static org.junit.Assert.assertEquals; +import static org.testng.Assert.*; -import com.google.gson.JsonObject; +import com.ibm.cloud.sdk.core.http.Response; +import com.ibm.cloud.sdk.core.security.Authenticator; import com.ibm.cloud.sdk.core.security.NoAuthAuthenticator; -import com.ibm.watson.common.WatsonServiceUnitTest; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; import com.ibm.watson.natural_language_classifier.v1.model.Classification; import com.ibm.watson.natural_language_classifier.v1.model.ClassificationCollection; import com.ibm.watson.natural_language_classifier.v1.model.Classifier; @@ -27,215 +28,371 @@ import com.ibm.watson.natural_language_classifier.v1.model.CreateClassifierOptions; import com.ibm.watson.natural_language_classifier.v1.model.DeleteClassifierOptions; import com.ibm.watson.natural_language_classifier.v1.model.GetClassifierOptions; -import java.io.File; -import java.io.FileNotFoundException; -import java.util.Arrays; +import com.ibm.watson.natural_language_classifier.v1.model.ListClassifiersOptions; +import com.ibm.watson.natural_language_classifier.v1.utils.TestUtilities; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; import okhttp3.mockwebserver.RecordedRequest; -import org.junit.Before; -import org.junit.Test; - -/** The Class NaturalLanguageClassifierTest. */ -public class NaturalLanguageClassifierTest extends WatsonServiceUnitTest { - private static final String TEXT = "text"; - private static final String CLASSIFIERS_PATH = "/v1/classifiers"; - private static final String CLASSIFY_PATH = "/v1/classifiers/%s/classify"; - private static final String CLASSIFY_COLLECTION_PATH = "/v1/classifiers/%s/classify_collection"; - private static final String RESOURCE = "src/test/resources/natural_language_classifier/"; - - private ClassifierList classifiers; - private Classifier classifier; - private Classification classification; - private ClassificationCollection classificationCollection; - - private String classifierId; - private NaturalLanguageClassifier service; - - /** - * Sets up the tests. - * - * @throws Exception the exception - */ - /* - * (non-Javadoc) - * @see com.ibm.watson.common.WatsonServiceTest#setUp() - */ - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - service = new NaturalLanguageClassifier(new NoAuthAuthenticator()); - service.setServiceUrl(getMockWebServerUrl()); - - classifierId = "foo"; - classifiers = loadFixture(RESOURCE + "classifiers.json", ClassifierList.class); - classifier = loadFixture(RESOURCE + "classifier.json", Classifier.class); - classification = loadFixture(RESOURCE + "classification.json", Classification.class); - classificationCollection = - loadFixture(RESOURCE + "classification_collection.json", ClassificationCollection.class); +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +/** Unit test class for the NaturalLanguageClassifier service. */ +public class NaturalLanguageClassifierTest { + + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + protected MockWebServer server; + protected NaturalLanguageClassifier naturalLanguageClassifierService; + + public void constructClientService() throws Throwable { + final String serviceName = "testService"; + + final Authenticator authenticator = new NoAuthAuthenticator(); + + naturalLanguageClassifierService = new NaturalLanguageClassifier(serviceName, authenticator); + String url = server.url("/").toString(); + naturalLanguageClassifierService.setServiceUrl(url); + } + + /** Negative Test - construct the service with a null authenticator. */ + @Test(expectedExceptions = IllegalArgumentException.class) + public void testConstructorWithNullAuthenticator() throws Throwable { + final String serviceName = "testService"; + + new NaturalLanguageClassifier(serviceName, null); } - /** - * Test classify. - * - * @throws InterruptedException the interrupted exception - */ @Test - public void testClassify() throws InterruptedException { - final JsonObject contentJson = new JsonObject(); - contentJson.addProperty(TEXT, classification.getText()); + public void testClassifyWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"classifier_id\": \"classifierId\", \"url\": \"url\", \"text\": \"text\", \"top_class\": \"topClass\", \"classes\": [{\"confidence\": 10, \"class_name\": \"className\"}]}"; + String classifyPath = "/v1/classifiers/testString/classify"; - final String path = String.format(CLASSIFY_PATH, classifierId); + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); - server.enqueue(jsonResponse(classification)); - ClassifyOptions classifyOptions = - new ClassifyOptions.Builder() - .classifierId(classifierId) - .text(classification.getText()) - .build(); - final Classification result = service.classify(classifyOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); + constructClientService(); + + // Construct an instance of the ClassifyOptions model + ClassifyOptions classifyOptionsModel = + new ClassifyOptions.Builder().classifierId("testString").text("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = + naturalLanguageClassifierService.classify(classifyOptionsModel).execute(); + assertNotNull(response); + Classification responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, classifyPath); + } + + // Test the classify operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testClassifyNoOptions() throws Throwable { + // construct the service + constructClientService(); - assertEquals(path, request.getPath()); - assertEquals("POST", request.getMethod()); - assertEquals(contentJson.toString(), request.getBody().readUtf8()); - assertEquals(classification, result); + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + naturalLanguageClassifierService.classify(null).execute(); } - /** - * Test classifying a collection. - * - * @throws InterruptedException the interrupted exception - */ @Test - public void testClassifyCollection() throws InterruptedException { - final String path = String.format(CLASSIFY_COLLECTION_PATH, classifierId); + public void testClassifyCollectionWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"classifier_id\": \"classifierId\", \"url\": \"url\", \"collection\": [{\"text\": \"text\", \"top_class\": \"topClass\", \"classes\": [{\"confidence\": 10, \"class_name\": \"className\"}]}]}"; + String classifyCollectionPath = "/v1/classifiers/testString/classify_collection"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); - server.enqueue(jsonResponse(classificationCollection)); + constructClientService(); - ClassifyInput input1 = new ClassifyInput.Builder().text("How hot will it be today?").build(); - ClassifyInput input2 = new ClassifyInput.Builder().text("Is it hot outside?").build(); - List inputCollection = Arrays.asList(input1, input2); + // Construct an instance of the ClassifyInput model + ClassifyInput classifyInputModel = + new ClassifyInput.Builder().text("How hot will it be today?").build(); - ClassifyCollectionOptions classifyOptions = + // Construct an instance of the ClassifyCollectionOptions model + ClassifyCollectionOptions classifyCollectionOptionsModel = new ClassifyCollectionOptions.Builder() - .classifierId(classifierId) - .collection(inputCollection) + .classifierId("testString") + .collection( + new java.util.ArrayList(java.util.Arrays.asList(classifyInputModel))) .build(); - final ClassificationCollection result = - service.classifyCollection(classifyOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - assertEquals(path, request.getPath()); - assertEquals("POST", request.getMethod()); - assertEquals(classificationCollection, result); - } + // Invoke operation with valid options model (positive test) + Response response = + naturalLanguageClassifierService + .classifyCollection(classifyCollectionOptionsModel) + .execute(); + assertNotNull(response); + ClassificationCollection responseObj = response.getResult(); + assertNotNull(responseObj); - /** - * Test get classifier. - * - * @throws InterruptedException the interrupted exception - */ - @Test - public void testGetClassifier() throws InterruptedException { - server.enqueue(jsonResponse(classifier)); - GetClassifierOptions getOptions = - new GetClassifierOptions.Builder().classifierId(classifierId).build(); - final Classifier response = service.getClassifier(getOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - - assertEquals(CLASSIFIERS_PATH + "/" + classifierId, request.getPath()); - assertEquals(classifier, response); + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, classifyCollectionPath); } - /** - * Test get classifiers. - * - * @throws InterruptedException the interrupted exception - */ - @Test - public void testGetClassifiers() throws InterruptedException { - server.enqueue(jsonResponse(classifiers)); - final ClassifierList response = service.listClassifiers().execute().getResult(); - final RecordedRequest request = server.takeRequest(); + // Test the classifyCollection operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testClassifyCollectionNoOptions() throws Throwable { + // construct the service + constructClientService(); - assertEquals(CLASSIFIERS_PATH, request.getPath()); - assertEquals(classifiers, response); + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + naturalLanguageClassifierService.classifyCollection(null).execute(); } - /** - * Test create classifier. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ @Test - public void testCreateClassifier() throws InterruptedException, FileNotFoundException { - server.enqueue(jsonResponse(classifier)); - File metadata = new File(RESOURCE + "metadata.json"); - File trainingData = new File(RESOURCE + "weather_data_train.csv"); - CreateClassifierOptions createOptions = + public void testCreateClassifierWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"name\": \"name\", \"url\": \"url\", \"status\": \"Non Existent\", \"classifier_id\": \"classifierId\", \"created\": \"2019-01-01T12:00:00\", \"status_description\": \"statusDescription\", \"language\": \"language\"}"; + String createClassifierPath = "/v1/classifiers"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the CreateClassifierOptions model + CreateClassifierOptions createClassifierOptionsModel = new CreateClassifierOptions.Builder() - .trainingMetadata(metadata) - .trainingData(trainingData) + .trainingMetadata(TestUtilities.createMockStream("This is a mock file.")) + .trainingData(TestUtilities.createMockStream("This is a mock file.")) .build(); - final Classifier response = service.createClassifier(createOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - assertEquals(CLASSIFIERS_PATH, request.getPath()); - assertEquals(classifier, response); + // Invoke operation with valid options model (positive test) + Response response = + naturalLanguageClassifierService.createClassifier(createClassifierOptionsModel).execute(); + assertNotNull(response); + Classifier responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createClassifierPath); + } + + // Test the createClassifier operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateClassifierNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + naturalLanguageClassifierService.createClassifier(null).execute(); } - /** - * Test delete classifier. - * - * @throws InterruptedException the interrupted exception - */ @Test - public void testDeleteClassifier() throws InterruptedException { - DeleteClassifierOptions deleteOptions = - new DeleteClassifierOptions.Builder().classifierId(classifierId).build(); - service.deleteClassifier(deleteOptions); + public void testListClassifiersWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"classifiers\": [{\"name\": \"name\", \"url\": \"url\", \"status\": \"Non Existent\", \"classifier_id\": \"classifierId\", \"created\": \"2019-01-01T12:00:00\", \"status_description\": \"statusDescription\", \"language\": \"language\"}]}"; + String listClassifiersPath = "/v1/classifiers"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the ListClassifiersOptions model + ListClassifiersOptions listClassifiersOptionsModel = new ListClassifiersOptions(); + + // Invoke operation with valid options model (positive test) + Response response = + naturalLanguageClassifierService.listClassifiers(listClassifiersOptionsModel).execute(); + assertNotNull(response); + ClassifierList responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listClassifiersPath); + } + + @Test + public void testGetClassifierWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"name\": \"name\", \"url\": \"url\", \"status\": \"Non Existent\", \"classifier_id\": \"classifierId\", \"created\": \"2019-01-01T12:00:00\", \"status_description\": \"statusDescription\", \"language\": \"language\"}"; + String getClassifierPath = "/v1/classifiers/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the GetClassifierOptions model + GetClassifierOptions getClassifierOptionsModel = + new GetClassifierOptions.Builder().classifierId("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = + naturalLanguageClassifierService.getClassifier(getClassifierOptionsModel).execute(); + assertNotNull(response); + Classifier responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getClassifierPath); } - // START NEGATIVE TESTS - /** Test null classifier. */ - @Test(expected = IllegalArgumentException.class) - public void testNullClassifier() { - ClassifyOptions classifyOptions = new ClassifyOptions.Builder().text("test").build(); - service.classify(classifyOptions); + // Test the getClassifier operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetClassifierNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + naturalLanguageClassifierService.getClassifier(null).execute(); } - /** Test null text. */ - @Test(expected = IllegalArgumentException.class) - public void testNullText() { - ClassifyOptions classifyOptions = - new ClassifyOptions.Builder().classifierId(classifierId).build(); - service.classify(classifyOptions); + @Test + public void testDeleteClassifierWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String deleteClassifierPath = "/v1/classifiers/testString"; + + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the DeleteClassifierOptions model + DeleteClassifierOptions deleteClassifierOptionsModel = + new DeleteClassifierOptions.Builder().classifierId("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = + naturalLanguageClassifierService.deleteClassifier(deleteClassifierOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteClassifierPath); + } + + // Test the deleteClassifier operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteClassifierNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + naturalLanguageClassifierService.deleteClassifier(null).execute(); } - /** Test null delete classifier. */ - @Test(expected = IllegalArgumentException.class) - public void testNullDeleteClassifier() { - DeleteClassifierOptions deleteOptions = new DeleteClassifierOptions.Builder().build(); - service.deleteClassifier(deleteOptions); + /** Initialize the server */ + @BeforeMethod + public void setUpMockServer() { + try { + server = new MockWebServer(); + // register handler + server.start(); + } catch (IOException err) { + fail("Failed to instantiate mock web server"); + } } - /** - * Test null training data file. - * - * @throws FileNotFoundException the file not found exception - */ - @Test(expected = FileNotFoundException.class) - public void testNullTrainingDataFile() throws FileNotFoundException { - server.enqueue(jsonResponse(classifier)); - File metadata = new File(RESOURCE + "metadata.json"); - File trainingData = new File(RESOURCE + "notfound.txt"); - CreateClassifierOptions createOptions = - new CreateClassifierOptions.Builder() - .trainingMetadata(metadata) - .trainingData(trainingData) - .build(); - service.createClassifier(createOptions).execute(); + @AfterMethod + public void tearDownMockServer() throws IOException { + server.shutdown(); + naturalLanguageClassifierService = null; } } diff --git a/natural-language-classifier/src/test/java/com/ibm/watson/natural_language_classifier/v1/model/ClassificationCollectionTest.java b/natural-language-classifier/src/test/java/com/ibm/watson/natural_language_classifier/v1/model/ClassificationCollectionTest.java new file mode 100644 index 00000000000..52fa89c8ca7 --- /dev/null +++ b/natural-language-classifier/src/test/java/com/ibm/watson/natural_language_classifier/v1/model/ClassificationCollectionTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_classifier.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_classifier.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ClassificationCollection model. */ +public class ClassificationCollectionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testClassificationCollection() throws Throwable { + ClassificationCollection classificationCollectionModel = new ClassificationCollection(); + assertNull(classificationCollectionModel.getClassifierId()); + assertNull(classificationCollectionModel.getUrl()); + assertNull(classificationCollectionModel.getCollection()); + } +} diff --git a/natural-language-classifier/src/test/java/com/ibm/watson/natural_language_classifier/v1/model/ClassificationTest.java b/natural-language-classifier/src/test/java/com/ibm/watson/natural_language_classifier/v1/model/ClassificationTest.java new file mode 100644 index 00000000000..8574fd431b6 --- /dev/null +++ b/natural-language-classifier/src/test/java/com/ibm/watson/natural_language_classifier/v1/model/ClassificationTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_classifier.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_classifier.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Classification model. */ +public class ClassificationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testClassification() throws Throwable { + Classification classificationModel = new Classification(); + assertNull(classificationModel.getClassifierId()); + assertNull(classificationModel.getUrl()); + assertNull(classificationModel.getText()); + assertNull(classificationModel.getTopClass()); + assertNull(classificationModel.getClasses()); + } +} diff --git a/natural-language-classifier/src/test/java/com/ibm/watson/natural_language_classifier/v1/model/ClassifiedClassTest.java b/natural-language-classifier/src/test/java/com/ibm/watson/natural_language_classifier/v1/model/ClassifiedClassTest.java new file mode 100644 index 00000000000..7fb9a0be8dc --- /dev/null +++ b/natural-language-classifier/src/test/java/com/ibm/watson/natural_language_classifier/v1/model/ClassifiedClassTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_classifier.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_classifier.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ClassifiedClass model. */ +public class ClassifiedClassTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testClassifiedClass() throws Throwable { + ClassifiedClass classifiedClassModel = new ClassifiedClass(); + assertNull(classifiedClassModel.getConfidence()); + assertNull(classifiedClassModel.getClassName()); + } +} diff --git a/natural-language-classifier/src/test/java/com/ibm/watson/natural_language_classifier/v1/model/ClassifierListTest.java b/natural-language-classifier/src/test/java/com/ibm/watson/natural_language_classifier/v1/model/ClassifierListTest.java new file mode 100644 index 00000000000..dd64e5fe71b --- /dev/null +++ b/natural-language-classifier/src/test/java/com/ibm/watson/natural_language_classifier/v1/model/ClassifierListTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_classifier.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_classifier.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ClassifierList model. */ +public class ClassifierListTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testClassifierList() throws Throwable { + ClassifierList classifierListModel = new ClassifierList(); + assertNull(classifierListModel.getClassifiers()); + } +} diff --git a/natural-language-classifier/src/test/java/com/ibm/watson/natural_language_classifier/v1/model/ClassifierTest.java b/natural-language-classifier/src/test/java/com/ibm/watson/natural_language_classifier/v1/model/ClassifierTest.java new file mode 100644 index 00000000000..28b2cb25f8d --- /dev/null +++ b/natural-language-classifier/src/test/java/com/ibm/watson/natural_language_classifier/v1/model/ClassifierTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_classifier.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_classifier.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Classifier model. */ +public class ClassifierTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testClassifier() throws Throwable { + Classifier classifierModel = new Classifier(); + assertNull(classifierModel.getName()); + assertNull(classifierModel.getUrl()); + assertNull(classifierModel.getClassifierId()); + assertNull(classifierModel.getLanguage()); + } +} diff --git a/natural-language-classifier/src/test/java/com/ibm/watson/natural_language_classifier/v1/model/ClassifyCollectionOptionsTest.java b/natural-language-classifier/src/test/java/com/ibm/watson/natural_language_classifier/v1/model/ClassifyCollectionOptionsTest.java new file mode 100644 index 00000000000..cbe772b264c --- /dev/null +++ b/natural-language-classifier/src/test/java/com/ibm/watson/natural_language_classifier/v1/model/ClassifyCollectionOptionsTest.java @@ -0,0 +1,53 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_classifier.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_classifier.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ClassifyCollectionOptions model. */ +public class ClassifyCollectionOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testClassifyCollectionOptions() throws Throwable { + ClassifyInput classifyInputModel = + new ClassifyInput.Builder().text("How hot will it be today?").build(); + assertEquals(classifyInputModel.text(), "How hot will it be today?"); + + ClassifyCollectionOptions classifyCollectionOptionsModel = + new ClassifyCollectionOptions.Builder() + .classifierId("testString") + .collection( + new java.util.ArrayList(java.util.Arrays.asList(classifyInputModel))) + .build(); + assertEquals(classifyCollectionOptionsModel.classifierId(), "testString"); + assertEquals( + classifyCollectionOptionsModel.collection(), + new java.util.ArrayList(java.util.Arrays.asList(classifyInputModel))); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testClassifyCollectionOptionsError() throws Throwable { + new ClassifyCollectionOptions.Builder().build(); + } +} diff --git a/natural-language-classifier/src/test/java/com/ibm/watson/natural_language_classifier/v1/model/ClassifyInputTest.java b/natural-language-classifier/src/test/java/com/ibm/watson/natural_language_classifier/v1/model/ClassifyInputTest.java new file mode 100644 index 00000000000..1c5b9015844 --- /dev/null +++ b/natural-language-classifier/src/test/java/com/ibm/watson/natural_language_classifier/v1/model/ClassifyInputTest.java @@ -0,0 +1,47 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_classifier.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_classifier.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ClassifyInput model. */ +public class ClassifyInputTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testClassifyInput() throws Throwable { + ClassifyInput classifyInputModel = new ClassifyInput.Builder().text("testString").build(); + assertEquals(classifyInputModel.text(), "testString"); + + String json = TestUtilities.serialize(classifyInputModel); + + ClassifyInput classifyInputModelNew = TestUtilities.deserialize(json, ClassifyInput.class); + assertTrue(classifyInputModelNew instanceof ClassifyInput); + assertEquals(classifyInputModelNew.text(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testClassifyInputError() throws Throwable { + new ClassifyInput.Builder().build(); + } +} diff --git a/natural-language-classifier/src/test/java/com/ibm/watson/natural_language_classifier/v1/model/ClassifyOptionsTest.java b/natural-language-classifier/src/test/java/com/ibm/watson/natural_language_classifier/v1/model/ClassifyOptionsTest.java new file mode 100644 index 00000000000..81ee15f3877 --- /dev/null +++ b/natural-language-classifier/src/test/java/com/ibm/watson/natural_language_classifier/v1/model/ClassifyOptionsTest.java @@ -0,0 +1,43 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_classifier.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_classifier.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ClassifyOptions model. */ +public class ClassifyOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testClassifyOptions() throws Throwable { + ClassifyOptions classifyOptionsModel = + new ClassifyOptions.Builder().classifierId("testString").text("testString").build(); + assertEquals(classifyOptionsModel.classifierId(), "testString"); + assertEquals(classifyOptionsModel.text(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testClassifyOptionsError() throws Throwable { + new ClassifyOptions.Builder().build(); + } +} diff --git a/natural-language-classifier/src/test/java/com/ibm/watson/natural_language_classifier/v1/model/CollectionItemTest.java b/natural-language-classifier/src/test/java/com/ibm/watson/natural_language_classifier/v1/model/CollectionItemTest.java new file mode 100644 index 00000000000..70dd1925a5f --- /dev/null +++ b/natural-language-classifier/src/test/java/com/ibm/watson/natural_language_classifier/v1/model/CollectionItemTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_classifier.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_classifier.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CollectionItem model. */ +public class CollectionItemTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCollectionItem() throws Throwable { + CollectionItem collectionItemModel = new CollectionItem(); + assertNull(collectionItemModel.getText()); + assertNull(collectionItemModel.getTopClass()); + assertNull(collectionItemModel.getClasses()); + } +} diff --git a/natural-language-classifier/src/test/java/com/ibm/watson/natural_language_classifier/v1/model/CreateClassifierOptionsTest.java b/natural-language-classifier/src/test/java/com/ibm/watson/natural_language_classifier/v1/model/CreateClassifierOptionsTest.java new file mode 100644 index 00000000000..c0f1ea905aa --- /dev/null +++ b/natural-language-classifier/src/test/java/com/ibm/watson/natural_language_classifier/v1/model/CreateClassifierOptionsTest.java @@ -0,0 +1,51 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_classifier.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_classifier.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.apache.commons.io.IOUtils; +import org.testng.annotations.Test; + +/** Unit test class for the CreateClassifierOptions model. */ +public class CreateClassifierOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateClassifierOptions() throws Throwable { + CreateClassifierOptions createClassifierOptionsModel = + new CreateClassifierOptions.Builder() + .trainingMetadata(TestUtilities.createMockStream("This is a mock file.")) + .trainingData(TestUtilities.createMockStream("This is a mock file.")) + .build(); + assertEquals( + IOUtils.toString(createClassifierOptionsModel.trainingMetadata()), + IOUtils.toString(TestUtilities.createMockStream("This is a mock file."))); + assertEquals( + IOUtils.toString(createClassifierOptionsModel.trainingData()), + IOUtils.toString(TestUtilities.createMockStream("This is a mock file."))); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateClassifierOptionsError() throws Throwable { + new CreateClassifierOptions.Builder().build(); + } +} diff --git a/natural-language-classifier/src/test/java/com/ibm/watson/natural_language_classifier/v1/model/DeleteClassifierOptionsTest.java b/natural-language-classifier/src/test/java/com/ibm/watson/natural_language_classifier/v1/model/DeleteClassifierOptionsTest.java new file mode 100644 index 00000000000..2c0bea94f89 --- /dev/null +++ b/natural-language-classifier/src/test/java/com/ibm/watson/natural_language_classifier/v1/model/DeleteClassifierOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_classifier.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_classifier.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteClassifierOptions model. */ +public class DeleteClassifierOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteClassifierOptions() throws Throwable { + DeleteClassifierOptions deleteClassifierOptionsModel = + new DeleteClassifierOptions.Builder().classifierId("testString").build(); + assertEquals(deleteClassifierOptionsModel.classifierId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteClassifierOptionsError() throws Throwable { + new DeleteClassifierOptions.Builder().build(); + } +} diff --git a/natural-language-classifier/src/test/java/com/ibm/watson/natural_language_classifier/v1/model/GetClassifierOptionsTest.java b/natural-language-classifier/src/test/java/com/ibm/watson/natural_language_classifier/v1/model/GetClassifierOptionsTest.java new file mode 100644 index 00000000000..1a646c84901 --- /dev/null +++ b/natural-language-classifier/src/test/java/com/ibm/watson/natural_language_classifier/v1/model/GetClassifierOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_classifier.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_classifier.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetClassifierOptions model. */ +public class GetClassifierOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetClassifierOptions() throws Throwable { + GetClassifierOptions getClassifierOptionsModel = + new GetClassifierOptions.Builder().classifierId("testString").build(); + assertEquals(getClassifierOptionsModel.classifierId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetClassifierOptionsError() throws Throwable { + new GetClassifierOptions.Builder().build(); + } +} diff --git a/natural-language-classifier/src/test/java/com/ibm/watson/natural_language_classifier/v1/model/ListClassifiersOptionsTest.java b/natural-language-classifier/src/test/java/com/ibm/watson/natural_language_classifier/v1/model/ListClassifiersOptionsTest.java new file mode 100644 index 00000000000..6da9a7f5e77 --- /dev/null +++ b/natural-language-classifier/src/test/java/com/ibm/watson/natural_language_classifier/v1/model/ListClassifiersOptionsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_classifier.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_classifier.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListClassifiersOptions model. */ +public class ListClassifiersOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListClassifiersOptions() throws Throwable { + ListClassifiersOptions listClassifiersOptionsModel = new ListClassifiersOptions(); + assertNotNull(listClassifiersOptionsModel); + } +} diff --git a/natural-language-classifier/src/test/java/com/ibm/watson/natural_language_classifier/v1/utils/TestUtilities.java b/natural-language-classifier/src/test/java/com/ibm/watson/natural_language_classifier/v1/utils/TestUtilities.java new file mode 100644 index 00000000000..040a43c1a57 --- /dev/null +++ b/natural-language-classifier/src/test/java/com/ibm/watson/natural_language_classifier/v1/utils/TestUtilities.java @@ -0,0 +1,128 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_classifier.v1.utils; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.cloud.sdk.core.util.GsonSingleton; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import okhttp3.HttpUrl; +import okhttp3.mockwebserver.RecordedRequest; + +/** A class used by the unit tests containing utility functions. */ +public class TestUtilities { + public static Map createMockMap() { + Map mockMap = new HashMap<>(); + mockMap.put("foo", "bar"); + return mockMap; + } + + public static HashMap createMockStreamMap() { + return new HashMap() { + { + put("key1", createMockStream("This is a mock file.")); + } + }; + } + + public static Map parseQueryString(RecordedRequest req) { + Map queryMap = new HashMap<>(); + + try { + HttpUrl requestUrl = req.getRequestUrl(); + + if (requestUrl != null) { + Set queryParamsNames = requestUrl.queryParameterNames(); + // map the parameter name to its corresponding value + for (String p : queryParamsNames) { + // get the corresponding value for the parameter (p) + List val = requestUrl.queryParameterValues(p); + if (val != null && !val.isEmpty()) { + String joinedQuery = String.join(",", val); + queryMap.put(p, joinedQuery); + } + } + } + if (queryMap.isEmpty()) { + return null; + } + } catch (Exception e) { + return null; + } + + return queryMap; + } + + public static String parseReqPath(RecordedRequest req) { + String parsedPath = null; + + try { + String fullPath = req.getPath(); + if (fullPath != null && !fullPath.isEmpty()) { + // retrieve the path segment before the query parameter + parsedPath = fullPath.split("\\?", 2)[0]; + } + if (parsedPath.isEmpty() || parsedPath == null) { + return null; + } + + } catch (Exception e) { + return null; + } + + return parsedPath; + } + + public static String serialize(Object obj) { + return GsonSingleton.getGson().toJson(obj); + } + + public static T deserialize(String json, Class clazz) { + return GsonSingleton.getGson().fromJson(json, clazz); + } + + public static InputStream createMockStream(String s) { + return new ByteArrayInputStream(s.getBytes()); + } + + public static List creatMockListFileWithMetadata() { + List list = new ArrayList(); + byte[] fileBytes = {(byte) 0xde, (byte) 0xad, (byte) 0xbe, (byte) 0xef}; + InputStream inputStream = new ByteArrayInputStream(fileBytes); + FileWithMetadata.Builder builder = new FileWithMetadata.Builder(); + builder.data(inputStream); + FileWithMetadata fileWithMetadata = builder.build(); + list.add(fileWithMetadata); + + return list; + } + + public static byte[] createMockByteArray(String bytes) { + return bytes.getBytes(); + } + + public static Date createMockDate(String date) throws Exception { + return new SimpleDateFormat("yyyy-MM-dd").parse(date); + } + + public static Date createMockDateTime(String date) throws Exception { + return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").parse(date); + } +} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/NaturalLanguageUnderstanding.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/NaturalLanguageUnderstanding.java index 95410e1b564..7fa1ca5d8c0 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/NaturalLanguageUnderstanding.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/NaturalLanguageUnderstanding.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -10,6 +10,11 @@ * 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. */ + +/* + * IBM OpenAPI SDK Code Generator Version: 99-SNAPSHOT-7cc05500-20201106-154555 + */ + package com.ibm.watson.natural_language_understanding.v1; import com.google.gson.JsonObject; @@ -27,6 +32,7 @@ import com.ibm.watson.natural_language_understanding.v1.model.DeleteModelResults; import com.ibm.watson.natural_language_understanding.v1.model.ListModelsOptions; import com.ibm.watson.natural_language_understanding.v1.model.ListModelsResults; +import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; @@ -42,98 +48,120 @@ * Understanding. * * @version v1 - * @see Natural Language + * @see Natural Language * Understanding */ public class NaturalLanguageUnderstanding extends BaseService { - private static final String DEFAULT_SERVICE_NAME = "natural_language_understanding"; + public static final String DEFAULT_SERVICE_NAME = "natural-language-understanding"; - private static final String DEFAULT_SERVICE_URL = + public static final String DEFAULT_SERVICE_URL = "https://api.us-south.natural-language-understanding.watson.cloud.ibm.com"; - private String versionDate; + private String version; /** - * Constructs a new `NaturalLanguageUnderstanding` client using the DEFAULT_SERVICE_NAME. + * Constructs an instance of the `NaturalLanguageUnderstanding` client. The default service name + * is used to configure the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value - * will keep your API calls from failing when the service introduces breaking changes. + * @param version Release date of the API version you want to use. Specify dates in YYYY-MM-DD + * format. The current version is `2020-08-01`. */ - public NaturalLanguageUnderstanding(String versionDate) { + public NaturalLanguageUnderstanding(String version) { this( - versionDate, + version, DEFAULT_SERVICE_NAME, ConfigBasedAuthenticatorFactory.getAuthenticator(DEFAULT_SERVICE_NAME)); } /** - * Constructs a new `NaturalLanguageUnderstanding` client with the DEFAULT_SERVICE_NAME and the - * specified Authenticator. + * Constructs an instance of the `NaturalLanguageUnderstanding` client. The default service name + * and specified authenticator are used to configure the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value - * will keep your API calls from failing when the service introduces breaking changes. - * @param authenticator the Authenticator instance to be configured for this service + * @param version Release date of the API version you want to use. Specify dates in YYYY-MM-DD + * format. The current version is `2020-08-01`. + * @param authenticator the {@link Authenticator} instance to be configured for this client */ - public NaturalLanguageUnderstanding(String versionDate, Authenticator authenticator) { - this(versionDate, DEFAULT_SERVICE_NAME, authenticator); + public NaturalLanguageUnderstanding(String version, Authenticator authenticator) { + this(version, DEFAULT_SERVICE_NAME, authenticator); } /** - * Constructs a new `NaturalLanguageUnderstanding` client with the specified serviceName. + * Constructs an instance of the `NaturalLanguageUnderstanding` client. The specified service name + * is used to configure the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value - * will keep your API calls from failing when the service introduces breaking changes. - * @param serviceName The name of the service to configure. + * @param version Release date of the API version you want to use. Specify dates in YYYY-MM-DD + * format. The current version is `2020-08-01`. + * @param serviceName the service name to be used when configuring the client instance */ - public NaturalLanguageUnderstanding(String versionDate, String serviceName) { - this(versionDate, serviceName, ConfigBasedAuthenticatorFactory.getAuthenticator(serviceName)); + public NaturalLanguageUnderstanding(String version, String serviceName) { + this(version, serviceName, ConfigBasedAuthenticatorFactory.getAuthenticator(serviceName)); } /** - * Constructs a new `NaturalLanguageUnderstanding` client with the specified Authenticator and - * serviceName. + * Constructs an instance of the `NaturalLanguageUnderstanding` client. The specified service name + * and authenticator are used to configure the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value - * will keep your API calls from failing when the service introduces breaking changes. - * @param serviceName The name of the service to configure. - * @param authenticator the Authenticator instance to be configured for this service + * @param version Release date of the API version you want to use. Specify dates in YYYY-MM-DD + * format. The current version is `2020-08-01`. + * @param serviceName the service name to be used when configuring the client instance + * @param authenticator the {@link Authenticator} instance to be configured for this client */ public NaturalLanguageUnderstanding( - String versionDate, String serviceName, Authenticator authenticator) { + String version, String serviceName, Authenticator authenticator) { super(serviceName, authenticator); setServiceUrl(DEFAULT_SERVICE_URL); - com.ibm.cloud.sdk.core.util.Validator.isTrue( - (versionDate != null) && !versionDate.isEmpty(), "version cannot be null."); - this.versionDate = versionDate; + setVersion(version); this.configureService(serviceName); } + /** + * Gets the version. + * + *

Release date of the API version you want to use. Specify dates in YYYY-MM-DD format. The + * current version is `2020-08-01`. + * + * @return the version + */ + public String getVersion() { + return this.version; + } + + /** + * Sets the version. + * + * @param version the new version + */ + public void setVersion(final String version) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(version, "version cannot be empty."); + this.version = version; + } + /** * Analyze text. * *

Analyzes text, HTML, or a public webpage for the following features: - Categories - Concepts - * - Emotion - Entities - Keywords - Metadata - Relations - Semantic roles - Sentiment - Syntax. + * - Emotion - Entities - Keywords - Metadata - Relations - Semantic roles - Sentiment - Syntax - + * Summarization (Experimental) * *

If a language for the input text is not specified with the `language` parameter, the service * [automatically detects the * language](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-detectable-languages). * * @param analyzeOptions the {@link AnalyzeOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link AnalysisResults} + * @return a {@link ServiceCall} with a result of type {@link AnalysisResults} */ public ServiceCall analyze(AnalyzeOptions analyzeOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull(analyzeOptions, "analyzeOptions cannot be null"); - String[] pathSegments = {"v1/analyze"}; RequestBuilder builder = - RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); + RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/analyze")); Map sdkHeaders = SdkCommon.getSdkHeaders("natural-language-understanding", "v1", "analyze"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); final JsonObject contentJson = new JsonObject(); contentJson.add( "features", @@ -180,21 +208,18 @@ public ServiceCall analyze(AnalyzeOptions analyzeOptions) { * that are deployed to your Natural Language Understanding service. * * @param listModelsOptions the {@link ListModelsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link ListModelsResults} + * @return a {@link ServiceCall} with a result of type {@link ListModelsResults} */ public ServiceCall listModels(ListModelsOptions listModelsOptions) { - String[] pathSegments = {"v1/models"}; RequestBuilder builder = - RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); + RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/models")); Map sdkHeaders = SdkCommon.getSdkHeaders("natural-language-understanding", "v1", "listModels"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - if (listModelsOptions != null) {} - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken() {}.getType()); @@ -208,7 +233,7 @@ public ServiceCall listModels(ListModelsOptions listModelsOpt * models](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-customizing) * that are deployed to your Natural Language Understanding service. * - * @return a {@link ServiceCall} with a response type of {@link ListModelsResults} + * @return a {@link ServiceCall} with a result of type {@link ListModelsResults} */ public ServiceCall listModels() { return listModels(null); @@ -220,24 +245,24 @@ public ServiceCall listModels() { *

Deletes a custom model. * * @param deleteModelOptions the {@link DeleteModelOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link DeleteModelResults} + * @return a {@link ServiceCall} with a result of type {@link DeleteModelResults} */ public ServiceCall deleteModel(DeleteModelOptions deleteModelOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( deleteModelOptions, "deleteModelOptions cannot be null"); - String[] pathSegments = {"v1/models"}; - String[] pathParameters = {deleteModelOptions.modelId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("model_id", deleteModelOptions.modelId()); RequestBuilder builder = RequestBuilder.delete( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/models/{model_id}", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("natural-language-understanding", "v1", "deleteModel"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken() {}.getType()); diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/AnalysisResults.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/AnalysisResults.java index 228c95388db..d680e2e0f68 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/AnalysisResults.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/AnalysisResults.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -33,7 +33,7 @@ public class AnalysisResults extends GenericModel { protected List keywords; protected List categories; protected EmotionResult emotion; - protected AnalysisResultsMetadata metadata; + protected FeaturesResultsMetadata metadata; protected List relations; @SerializedName("semantic_roles") @@ -148,7 +148,7 @@ public EmotionResult getEmotion() { * * @return the metadata */ - public AnalysisResultsMetadata getMetadata() { + public FeaturesResultsMetadata getMetadata() { return metadata; } diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/AnalysisResultsUsage.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/AnalysisResultsUsage.java index c78dde7c3a6..d23e0e1c599 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/AnalysisResultsUsage.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/AnalysisResultsUsage.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/AnalyzeOptions.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/AnalyzeOptions.java index 46bf10990da..ea5e4fe0c07 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/AnalyzeOptions.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/AnalyzeOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -69,7 +69,7 @@ public Builder(Features features) { /** * Builds a AnalyzeOptions. * - * @return the analyzeOptions + * @return the new AnalyzeOptions instance */ public AnalyzeOptions build() { return new AnalyzeOptions(this); diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/Author.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/Author.java index 545c37ccea0..88245d3d2d1 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/Author.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/Author.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesOptions.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesOptions.java index 19f75c08a0b..1bbf83be15d 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesOptions.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -24,13 +24,13 @@ public class CategoriesOptions extends GenericModel { protected Boolean explanation; protected Long limit; - @Deprecated protected String model; + protected String model; /** Builder. */ public static class Builder { private Boolean explanation; private Long limit; - @Deprecated private String model; + private String model; private Builder(CategoriesOptions categoriesOptions) { this.explanation = categoriesOptions.explanation; @@ -44,7 +44,7 @@ public Builder() {} /** * Builds a CategoriesOptions. * - * @return the categoriesOptions + * @return the new CategoriesOptions instance */ public CategoriesOptions build() { return new CategoriesOptions(this); @@ -77,8 +77,6 @@ public Builder limit(long limit) { * * @param model the model * @return the CategoriesOptions builder - * @deprecated the model parameter is no longer supported by the Natural Language Understanding - * service and will be removed in the next major release */ public Builder model(String model) { this.model = model; @@ -137,8 +135,6 @@ public Long limit() { * categories models will no longer be accessible in Knowledge Studio on 17 December 2019. * * @return the model - * @deprecated the model parameter is no longer supported by the Natural Language Understanding - * service and will be removed in the next major release */ public String model() { return model; diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesRelevantText.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesRelevantText.java index d038a7243d1..3ae8bf961d5 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesRelevantText.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesRelevantText.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesResult.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesResult.java index 0efd83a5049..03dee62c9c4 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesResult.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesResultExplanation.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesResultExplanation.java index fc5fb0ac18c..eb1f563e2ee 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesResultExplanation.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesResultExplanation.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ConceptsOptions.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ConceptsOptions.java index b754ff4235a..14bacf7eaae 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ConceptsOptions.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ConceptsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -38,7 +38,7 @@ public Builder() {} /** * Builds a ConceptsOptions. * - * @return the conceptsOptions + * @return the new ConceptsOptions instance */ public ConceptsOptions build() { return new ConceptsOptions(this); diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ConceptsResult.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ConceptsResult.java index 9ef4067903b..f7ce8f146a0 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ConceptsResult.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ConceptsResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/DeleteModelOptions.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/DeleteModelOptions.java index ad726fa0dd0..860a7a777b9 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/DeleteModelOptions.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/DeleteModelOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -42,7 +42,7 @@ public Builder(String modelId) { /** * Builds a DeleteModelOptions. * - * @return the deleteModelOptions + * @return the new DeleteModelOptions instance */ public DeleteModelOptions build() { return new DeleteModelOptions(this); diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/DeleteModelResults.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/DeleteModelResults.java index 9958c2d63dd..3d6076ce18f 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/DeleteModelResults.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/DeleteModelResults.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/DisambiguationResult.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/DisambiguationResult.java index 9a57501260f..0a4d700fdb5 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/DisambiguationResult.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/DisambiguationResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/DocumentEmotionResults.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/DocumentEmotionResults.java index 9dc15f68d72..f9a072edefc 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/DocumentEmotionResults.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/DocumentEmotionResults.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/DocumentSentimentResults.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/DocumentSentimentResults.java index 8bc9f9066a0..6d095328570 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/DocumentSentimentResults.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/DocumentSentimentResults.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/EmotionOptions.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/EmotionOptions.java index ff569ed2c10..a471e7bcdfb 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/EmotionOptions.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/EmotionOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -44,7 +44,7 @@ public Builder() {} /** * Builds a EmotionOptions. * - * @return the emotionOptions + * @return the new EmotionOptions instance */ public EmotionOptions build() { return new EmotionOptions(this); diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/EmotionResult.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/EmotionResult.java index 7baeb3d8388..ab052a6c042 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/EmotionResult.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/EmotionResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/EmotionScores.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/EmotionScores.java index e8fbb45cf49..d65bc2820da 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/EmotionScores.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/EmotionScores.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/EntitiesOptions.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/EntitiesOptions.java index 6a37b33bc63..09eb633a1b1 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/EntitiesOptions.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/EntitiesOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -52,7 +52,7 @@ public Builder() {} /** * Builds a EntitiesOptions. * - * @return the entitiesOptions + * @return the new EntitiesOptions instance */ public EntitiesOptions build() { return new EntitiesOptions(this); diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/EntitiesResult.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/EntitiesResult.java index 607512ac24e..af183664a70 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/EntitiesResult.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/EntitiesResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/EntityMention.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/EntityMention.java index 25f2c7993c5..424f8c64a5e 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/EntityMention.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/EntityMention.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/FeatureSentimentResults.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/FeatureSentimentResults.java index 4a5a7a536fc..78c149c27d3 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/FeatureSentimentResults.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/FeatureSentimentResults.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/Features.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/Features.java index 02ed30a550c..de831e850f6 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/Features.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/Features.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -14,6 +14,7 @@ import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.Map; /** Analysis features and options. */ public class Features extends GenericModel { @@ -22,7 +23,7 @@ public class Features extends GenericModel { protected EmotionOptions emotion; protected EntitiesOptions entities; protected KeywordsOptions keywords; - protected MetadataOptions metadata; + protected Map metadata; protected RelationsOptions relations; @SerializedName("semantic_roles") @@ -38,7 +39,7 @@ public static class Builder { private EmotionOptions emotion; private EntitiesOptions entities; private KeywordsOptions keywords; - private MetadataOptions metadata; + private Map metadata; private RelationsOptions relations; private SemanticRolesOptions semanticRoles; private SentimentOptions sentiment; @@ -64,7 +65,7 @@ public Builder() {} /** * Builds a Features. * - * @return the features + * @return the new Features instance */ public Features build() { return new Features(this); @@ -120,7 +121,7 @@ public Builder keywords(KeywordsOptions keywords) { * @param metadata the metadata * @return the Features builder */ - public Builder metadata(MetadataOptions metadata) { + public Builder metadata(Map metadata) { this.metadata = metadata; return this; } @@ -272,7 +273,7 @@ public KeywordsOptions keywords() { * * @return the metadata */ - public MetadataOptions metadata() { + public Map metadata() { return metadata; } diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/AnalysisResultsMetadata.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/FeaturesResultsMetadata.java similarity index 95% rename from natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/AnalysisResultsMetadata.java rename to natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/FeaturesResultsMetadata.java index 217fcbf8318..db93f044820 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/AnalysisResultsMetadata.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/FeaturesResultsMetadata.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -17,7 +17,7 @@ import java.util.List; /** Webpage metadata, such as the author and the title of the page. */ -public class AnalysisResultsMetadata extends GenericModel { +public class FeaturesResultsMetadata extends GenericModel { protected List authors; diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/Feed.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/Feed.java index 98e7db5d9c4..ee0f4bda165 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/Feed.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/Feed.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/KeywordsOptions.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/KeywordsOptions.java index 89238768c85..e897e0b9803 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/KeywordsOptions.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/KeywordsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -44,7 +44,7 @@ public Builder() {} /** * Builds a KeywordsOptions. * - * @return the keywordsOptions + * @return the new KeywordsOptions instance */ public KeywordsOptions build() { return new KeywordsOptions(this); diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/KeywordsResult.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/KeywordsResult.java index 49fcbd34ee9..fdce32f127d 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/KeywordsResult.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/KeywordsResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ListModelsOptions.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ListModelsOptions.java index ff111c2f348..0b18313874c 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ListModelsOptions.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ListModelsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -15,34 +15,4 @@ import com.ibm.cloud.sdk.core.service.model.GenericModel; /** The listModels options. */ -public class ListModelsOptions extends GenericModel { - - /** Builder. */ - public static class Builder { - - private Builder(ListModelsOptions listModelsOptions) {} - - /** Instantiates a new builder. */ - public Builder() {} - - /** - * Builds a ListModelsOptions. - * - * @return the listModelsOptions - */ - public ListModelsOptions build() { - return new ListModelsOptions(this); - } - } - - private ListModelsOptions(Builder builder) {} - - /** - * New builder. - * - * @return a ListModelsOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } -} +public class ListModelsOptions extends GenericModel {} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ListModelsResults.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ListModelsResults.java index 169b8615313..b398d54d0e1 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ListModelsResults.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ListModelsResults.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/MetadataOptions.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/MetadataOptions.java deleted file mode 100644 index 2895610936b..00000000000 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/MetadataOptions.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.watson.natural_language_understanding.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; - -/** - * Returns information from the document, including author name, title, RSS/ATOM feeds, prominent - * page image, and publication date. Supports URL and HTML input types only. - */ -public class MetadataOptions extends GenericModel { - - /** Builder. */ - public static class Builder { - - private Builder(MetadataOptions metadataOptions) {} - - /** Instantiates a new builder. */ - public Builder() {} - - /** - * Builds a MetadataOptions. - * - * @return the metadataOptions - */ - public MetadataOptions build() { - return new MetadataOptions(this); - } - } - - private MetadataOptions(Builder builder) {} - - /** - * New builder. - * - * @return a MetadataOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } -} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/Model.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/Model.java index e23dce67247..b5519b9117c 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/Model.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/Model.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -126,8 +126,7 @@ public String getModelVersion() { /** * Gets the version. * - *

(Deprecated — use `model_version`) The model version, if it was manually provided in Watson - * Knowledge Studio. + *

Deprecated — use `model_version`. * * @return the version */ diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/RelationArgument.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/RelationArgument.java index 6b52e9281f8..93abef8bf73 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/RelationArgument.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/RelationArgument.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/RelationEntity.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/RelationEntity.java index a171e26eafb..f3009ad06dc 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/RelationEntity.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/RelationEntity.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/RelationsOptions.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/RelationsOptions.java index ea51e92b025..0030b13c2fe 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/RelationsOptions.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/RelationsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -41,7 +41,7 @@ public Builder() {} /** * Builds a RelationsOptions. * - * @return the relationsOptions + * @return the new RelationsOptions instance */ public RelationsOptions build() { return new RelationsOptions(this); diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/RelationsResult.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/RelationsResult.java index aa20599e647..dd5f90d3138 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/RelationsResult.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/RelationsResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesEntity.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesEntity.java index 8c1ae470865..55316fd661e 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesEntity.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesEntity.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesKeyword.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesKeyword.java index 80d56341a96..6c0b0018390 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesKeyword.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesKeyword.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesOptions.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesOptions.java index 94e21236253..b6ffaa38e72 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesOptions.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -43,7 +43,7 @@ public Builder() {} /** * Builds a SemanticRolesOptions. * - * @return the semanticRolesOptions + * @return the new SemanticRolesOptions instance */ public SemanticRolesOptions build() { return new SemanticRolesOptions(this); diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResult.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResult.java index 1703f2ef38c..6f313f6c0fb 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResult.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResultAction.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResultAction.java index 5d7386dd093..eb835c21ff2 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResultAction.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResultAction.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResultObject.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResultObject.java index 954aa0bb888..2c464aa60ff 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResultObject.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResultObject.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResultSubject.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResultSubject.java index 3e7e07ea4e7..449e454678b 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResultSubject.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResultSubject.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesVerb.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesVerb.java index db9e5a75caf..5f771a56270 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesVerb.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesVerb.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SentenceResult.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SentenceResult.java index 8c769799291..fb156960f80 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SentenceResult.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SentenceResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SentimentOptions.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SentimentOptions.java index 7602fde4751..edd563fca68 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SentimentOptions.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SentimentOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -45,7 +45,7 @@ public Builder() {} /** * Builds a SentimentOptions. * - * @return the sentimentOptions + * @return the new SentimentOptions instance */ public SentimentOptions build() { return new SentimentOptions(this); diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SentimentResult.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SentimentResult.java index 2bb4c9927e2..aedfec79764 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SentimentResult.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SentimentResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SyntaxOptions.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SyntaxOptions.java index ac570eff4ba..c5db9a92506 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SyntaxOptions.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SyntaxOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -36,7 +36,7 @@ public Builder() {} /** * Builds a SyntaxOptions. * - * @return the syntaxOptions + * @return the new SyntaxOptions instance */ public SyntaxOptions build() { return new SyntaxOptions(this); diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SyntaxOptionsTokens.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SyntaxOptionsTokens.java index 207992e6996..520b1513cf3 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SyntaxOptionsTokens.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SyntaxOptionsTokens.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -39,7 +39,7 @@ public Builder() {} /** * Builds a SyntaxOptionsTokens. * - * @return the syntaxOptionsTokens + * @return the new SyntaxOptionsTokens instance */ public SyntaxOptionsTokens build() { return new SyntaxOptionsTokens(this); diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SyntaxResult.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SyntaxResult.java index f8af94e4423..b4e2049ab75 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SyntaxResult.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SyntaxResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/TargetedEmotionResults.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/TargetedEmotionResults.java index 3802c6bbb6b..4e18d656900 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/TargetedEmotionResults.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/TargetedEmotionResults.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/TargetedSentimentResults.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/TargetedSentimentResults.java index 2e303a7f66f..e0346d3275f 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/TargetedSentimentResults.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/TargetedSentimentResults.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/TokenResult.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/TokenResult.java index 55bff3af750..5977a46f317 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/TokenResult.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/TokenResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/package-info.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/package-info.java index 7afb2ae5b5c..8969d9f4f15 100644 --- a/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/package-info.java +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/package-info.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/NaturalLanguageUnderstandingTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/NaturalLanguageUnderstandingTest.java index 896de8bacb5..43edbae56f4 100644 --- a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/NaturalLanguageUnderstandingTest.java +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/NaturalLanguageUnderstandingTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -12,326 +12,336 @@ */ package com.ibm.watson.natural_language_understanding.v1; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.testng.Assert.*; +import com.ibm.cloud.sdk.core.http.Response; +import com.ibm.cloud.sdk.core.security.Authenticator; import com.ibm.cloud.sdk.core.security.NoAuthAuthenticator; -import com.ibm.watson.common.WatsonServiceUnitTest; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; import com.ibm.watson.natural_language_understanding.v1.model.AnalysisResults; import com.ibm.watson.natural_language_understanding.v1.model.AnalyzeOptions; import com.ibm.watson.natural_language_understanding.v1.model.CategoriesOptions; import com.ibm.watson.natural_language_understanding.v1.model.ConceptsOptions; import com.ibm.watson.natural_language_understanding.v1.model.DeleteModelOptions; +import com.ibm.watson.natural_language_understanding.v1.model.DeleteModelResults; import com.ibm.watson.natural_language_understanding.v1.model.EmotionOptions; import com.ibm.watson.natural_language_understanding.v1.model.EntitiesOptions; import com.ibm.watson.natural_language_understanding.v1.model.Features; import com.ibm.watson.natural_language_understanding.v1.model.KeywordsOptions; +import com.ibm.watson.natural_language_understanding.v1.model.ListModelsOptions; import com.ibm.watson.natural_language_understanding.v1.model.ListModelsResults; -import com.ibm.watson.natural_language_understanding.v1.model.MetadataOptions; import com.ibm.watson.natural_language_understanding.v1.model.RelationsOptions; import com.ibm.watson.natural_language_understanding.v1.model.SemanticRolesOptions; import com.ibm.watson.natural_language_understanding.v1.model.SentimentOptions; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.util.ArrayList; -import java.util.Arrays; +import com.ibm.watson.natural_language_understanding.v1.model.SyntaxOptions; +import com.ibm.watson.natural_language_understanding.v1.model.SyntaxOptionsTokens; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; import okhttp3.mockwebserver.RecordedRequest; -import org.junit.Before; -import org.junit.Test; - -/** The Class NaturalLanguageunderstandingTest. */ -public class NaturalLanguageUnderstandingTest extends WatsonServiceUnitTest { - private static final String MODELS_PATH = "/v1/models?version=2019-07-12"; - private static final String DELETE_PATH = "/v1/models/foo?version=2019-07-12"; - private static final String ANALYZE_PATH = "/v1/analyze?version=2019-07-12"; - private static final String RESOURCE = "src/test/resources/natural_language_understanding/"; - - private static final String TEXT = "text"; - private static final Long LOCATION = 0L; - private static final Double CONFIDENCE = 0.5; - - private ListModelsResults models; - private AnalysisResults analyzeResults; - private String modelId; - private NaturalLanguageUnderstanding service; - - /** - * Sets up the tests. - * - * @throws Exception the exception - */ - /* - * (non-Javadoc) - * @see com.ibm.watson.common.WatsonServiceTest#setUp() - */ - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - service = new NaturalLanguageUnderstanding("2019-07-12", new NoAuthAuthenticator()); - service.setServiceUrl(getMockWebServerUrl()); - - modelId = "foo"; - models = loadFixture(RESOURCE + "models.json", ListModelsResults.class); - analyzeResults = loadFixture(RESOURCE + "analyze.json", AnalysisResults.class); +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +/** Unit test class for the NaturalLanguageUnderstanding service. */ +public class NaturalLanguageUnderstandingTest { + + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + protected MockWebServer server; + protected NaturalLanguageUnderstanding naturalLanguageUnderstandingService; + + public void constructClientService() throws Throwable { + final String serviceName = "testService"; + // set mock values for global params + String version = "testString"; + + final Authenticator authenticator = new NoAuthAuthenticator(); + + naturalLanguageUnderstandingService = + new NaturalLanguageUnderstanding(version, serviceName, authenticator); + String url = server.url("/").toString(); + naturalLanguageUnderstandingService.setServiceUrl(url); } - // --- MODELS --- + /** Negative Test - construct the service with a null authenticator. */ + @Test(expectedExceptions = IllegalArgumentException.class) + public void testConstructorWithNullAuthenticator() throws Throwable { + final String serviceName = "testService"; + // set mock values for global params + String version = "testString"; + + new NaturalLanguageUnderstanding(version, serviceName, null); + } - /** - * Test some of the model constructors. pump up the code coverage numbers - * - * @throws InterruptedException the interrupted exception - */ @Test - public void testModelOptions() throws InterruptedException { - Features features = - new Features.Builder() - .concepts(null) - .categories(null) - .emotion(null) - .entities(null) - .keywords(null) - .metadata(null) - .relations(null) - .semanticRoles(null) - .sentiment(null) - .build(); + public void testGetVersion() throws Throwable { + constructClientService(); + assertEquals(naturalLanguageUnderstandingService.getVersion(), "testString"); + } - // AnalyzeOptions - AnalyzeOptions analyzeOptions = - new AnalyzeOptions.Builder() - .text("text") - .html("html") - .url("url") - .features(features) - .clean(true) - .xpath("xpath") - .fallbackToRaw(false) - .returnAnalyzedText(true) - .language("language") - .build(); - assertEquals(analyzeOptions.text(), "text"); - assertEquals(analyzeOptions.html(), "html"); - assertEquals(analyzeOptions.url(), "url"); - assertEquals(analyzeOptions.features(), features); - assertEquals(analyzeOptions.clean(), true); - assertEquals(analyzeOptions.xpath(), "xpath"); - assertEquals(analyzeOptions.fallbackToRaw(), false); - assertEquals(analyzeOptions.returnAnalyzedText(), true); - assertEquals(analyzeOptions.language(), "language"); - analyzeOptions.newBuilder(); - - // CategoriesOptions - CategoriesOptions categoriesOptions = new CategoriesOptions.Builder().build(); - assertNotNull(categoriesOptions); - - // EmotionOptions - List emotionOptionsTargets = new ArrayList<>(Arrays.asList("target1", "target2")); - EmotionOptions emotionOptions = + @Test + public void testAnalyzeWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"language\": \"language\", \"analyzed_text\": \"analyzedText\", \"retrieved_url\": \"retrievedUrl\", \"usage\": {\"features\": 8, \"text_characters\": 14, \"text_units\": 9}, \"concepts\": [{\"text\": \"text\", \"relevance\": 9, \"dbpedia_resource\": \"dbpediaResource\"}], \"entities\": [{\"type\": \"type\", \"text\": \"text\", \"relevance\": 9, \"confidence\": 10, \"mentions\": [{\"text\": \"text\", \"location\": [8], \"confidence\": 10}], \"count\": 5, \"emotion\": {\"anger\": 5, \"disgust\": 7, \"fear\": 4, \"joy\": 3, \"sadness\": 7}, \"sentiment\": {\"score\": 5}, \"disambiguation\": {\"name\": \"name\", \"dbpedia_resource\": \"dbpediaResource\", \"subtype\": [\"subtype\"]}}], \"keywords\": [{\"count\": 5, \"relevance\": 9, \"text\": \"text\", \"emotion\": {\"anger\": 5, \"disgust\": 7, \"fear\": 4, \"joy\": 3, \"sadness\": 7}, \"sentiment\": {\"score\": 5}}], \"categories\": [{\"label\": \"label\", \"score\": 5, \"explanation\": {\"relevant_text\": [{\"text\": \"text\"}]}}], \"emotion\": {\"document\": {\"emotion\": {\"anger\": 5, \"disgust\": 7, \"fear\": 4, \"joy\": 3, \"sadness\": 7}}, \"targets\": [{\"text\": \"text\", \"emotion\": {\"anger\": 5, \"disgust\": 7, \"fear\": 4, \"joy\": 3, \"sadness\": 7}}]}, \"metadata\": {\"authors\": [{\"name\": \"name\"}], \"publication_date\": \"publicationDate\", \"title\": \"title\", \"image\": \"image\", \"feeds\": [{\"link\": \"link\"}]}, \"relations\": [{\"score\": 5, \"sentence\": \"sentence\", \"type\": \"type\", \"arguments\": [{\"entities\": [{\"text\": \"text\", \"type\": \"type\"}], \"location\": [8], \"text\": \"text\"}]}], \"semantic_roles\": [{\"sentence\": \"sentence\", \"subject\": {\"text\": \"text\", \"entities\": [{\"type\": \"type\", \"text\": \"text\"}], \"keywords\": [{\"text\": \"text\"}]}, \"action\": {\"text\": \"text\", \"normalized\": \"normalized\", \"verb\": {\"text\": \"text\", \"tense\": \"tense\"}}, \"object\": {\"text\": \"text\", \"keywords\": [{\"text\": \"text\"}]}}], \"sentiment\": {\"document\": {\"label\": \"label\", \"score\": 5}, \"targets\": [{\"text\": \"text\", \"score\": 5}]}, \"syntax\": {\"tokens\": [{\"text\": \"text\", \"part_of_speech\": \"ADJ\", \"location\": [8], \"lemma\": \"lemma\"}], \"sentences\": [{\"text\": \"text\", \"location\": [8]}]}}"; + String analyzePath = "/v1/analyze"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the ConceptsOptions model + ConceptsOptions conceptsOptionsModel = + new ConceptsOptions.Builder().limit(Long.valueOf("50")).build(); + + // Construct an instance of the EmotionOptions model + EmotionOptions emotionOptionsModel = new EmotionOptions.Builder() .document(true) - .targets(emotionOptionsTargets) - .addTargets("target3") + .targets(new java.util.ArrayList(java.util.Arrays.asList("testString"))) .build(); - emotionOptionsTargets.add("target3"); - assertEquals(emotionOptions.document(), true); - assertEquals(emotionOptions.targets(), emotionOptionsTargets); - emotionOptions.newBuilder(); - // EntitiesOptions - EntitiesOptions entitiesOptions = + // Construct an instance of the EntitiesOptions model + EntitiesOptions entitiesOptionsModel = new EntitiesOptions.Builder() + .limit(Long.valueOf("250")) + .mentions(true) + .model("testString") + .sentiment(true) .emotion(true) - .limit(10) - .model("model") - .sentiment(false) - .mentions(false) .build(); - assertEquals(entitiesOptions.emotion(), true); - assertEquals(entitiesOptions.limit(), 10, 0); - assertEquals(entitiesOptions.model(), "model"); - assertEquals(entitiesOptions.sentiment(), false); - assertEquals(entitiesOptions.mentions(), false); - entitiesOptions.newBuilder(); - - // Features - assertEquals(features.categories(), null); - assertEquals(features.concepts(), null); - assertEquals(features.emotion(), null); - assertEquals(features.entities(), null); - assertEquals(features.keywords(), null); - assertEquals(features.metadata(), null); - assertEquals(features.relations(), null); - assertEquals(features.semanticRoles(), null); - assertEquals(features.sentiment(), null); - features.newBuilder(); - - // KeywordsOptions - KeywordsOptions keywordsOptions = - new KeywordsOptions.Builder().emotion(true).limit(10).sentiment(false).build(); - assertEquals(keywordsOptions.emotion(), true); - assertEquals(keywordsOptions.limit(), 10, 0); - assertEquals(keywordsOptions.sentiment(), false); - keywordsOptions.newBuilder(); - - // MetadataOptions - MetadataOptions metadataOptions = new MetadataOptions.Builder().build(); - assertNotNull(metadataOptions); - - // RelationsOptions - RelationsOptions relationsOptions = new RelationsOptions.Builder().model("model").build(); - assertEquals(relationsOptions.model(), "model"); - relationsOptions.newBuilder(); - - // SemanticRolesOptions - SemanticRolesOptions semanticRolesOptions = - new SemanticRolesOptions.Builder().entities(true).keywords(false).limit(10).build(); - assertEquals(semanticRolesOptions.entities(), true); - assertEquals(semanticRolesOptions.keywords(), false); - assertEquals(semanticRolesOptions.limit(), 10, 0); - semanticRolesOptions.newBuilder(); - - // SentimentOptions - List optionsTargets = new ArrayList<>(Arrays.asList("target1", "target2")); - SentimentOptions sentimentOptions = + + // Construct an instance of the KeywordsOptions model + KeywordsOptions keywordsOptionsModel = + new KeywordsOptions.Builder() + .limit(Long.valueOf("250")) + .sentiment(true) + .emotion(true) + .build(); + + // Construct an instance of the RelationsOptions model + RelationsOptions relationsOptionsModel = + new RelationsOptions.Builder().model("testString").build(); + + // Construct an instance of the SemanticRolesOptions model + SemanticRolesOptions semanticRolesOptionsModel = + new SemanticRolesOptions.Builder() + .limit(Long.valueOf("26")) + .keywords(true) + .entities(true) + .build(); + + // Construct an instance of the SentimentOptions model + SentimentOptions sentimentOptionsModel = new SentimentOptions.Builder() .document(true) - .targets(optionsTargets) - .addTargets("target3") + .targets(new java.util.ArrayList(java.util.Arrays.asList("testString"))) .build(); - optionsTargets.add("target3"); - assertEquals(sentimentOptions.document(), true); - assertEquals(sentimentOptions.targets(), optionsTargets); - sentimentOptions.newBuilder(); - } - // --- METHODS --- + // Construct an instance of the CategoriesOptions model + CategoriesOptions categoriesOptionsModel = + new CategoriesOptions.Builder() + .explanation(true) + .limit(Long.valueOf("10")) + .model("testString") + .build(); - /** - * Test analyze. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ - @Test - public void testAnalyze() throws InterruptedException, FileNotFoundException { - String testHtmlFileName = RESOURCE + "testArticle.html"; - String html = getStringFromInputStream(new FileInputStream(testHtmlFileName)); - - ConceptsOptions concepts = new ConceptsOptions.Builder().limit(5).build(); - assertEquals(concepts.limit(), 5, 0); - concepts.newBuilder(); - - Features features = new Features.Builder().concepts(concepts).build(); - AnalyzeOptions parameters = new AnalyzeOptions.Builder().html(html).features(features).build(); - - server.enqueue(jsonResponse(analyzeResults)); - final AnalysisResults response = service.analyze(parameters).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - - assertEquals(ANALYZE_PATH, request.getPath()); - assertEquals("POST", request.getMethod()); - assertEquals(analyzeResults, response); - assertNotNull(analyzeResults.getAnalyzedText()); - assertNotNull(analyzeResults.getSentiment()); - assertNotNull(analyzeResults.getLanguage()); - assertNotNull(analyzeResults.getEntities()); - assertNotNull(analyzeResults.getEmotion()); - assertNotNull(analyzeResults.getConcepts()); - assertNotNull(analyzeResults.getCategories()); - assertEquals( - analyzeResults.getCategories().get(0).getExplanation().getRelevantText().get(0).getText(), - response.getCategories().get(0).getExplanation().getRelevantText().get(0).getText()); - assertNotNull(analyzeResults.getKeywords()); - assertNotNull(analyzeResults.getMetadata()); - assertNotNull(analyzeResults.getSemanticRoles()); - assertNotNull(analyzeResults.getRetrievedUrl()); - assertNotNull(analyzeResults.getRelations()); - assertNotNull(analyzeResults.getSyntax()); - assertNotNull(analyzeResults.getUsage()); - assertEquals(CONFIDENCE, analyzeResults.getEntities().get(0).getConfidence()); - assertEquals(TEXT, analyzeResults.getEntities().get(0).getMentions().get(0).getText()); - assertEquals( - LOCATION, analyzeResults.getEntities().get(0).getMentions().get(0).getLocation().get(0)); - assertEquals( - CONFIDENCE, analyzeResults.getEntities().get(0).getMentions().get(0).getConfidence()); - } + // Construct an instance of the SyntaxOptionsTokens model + SyntaxOptionsTokens syntaxOptionsTokensModel = + new SyntaxOptionsTokens.Builder().lemma(true).partOfSpeech(true).build(); - /** - * Test analyze with null parameters. Test different constructor - * - * @throws InterruptedException the interrupted exception - */ - @Test - public void testAnalyzeNullParams() throws InterruptedException { - server.enqueue(jsonResponse(analyzeResults)); - Features features = + // Construct an instance of the SyntaxOptions model + SyntaxOptions syntaxOptionsModel = + new SyntaxOptions.Builder().tokens(syntaxOptionsTokensModel).sentences(true).build(); + + // Construct an instance of the Features model + Features featuresModel = new Features.Builder() - .concepts(null) - .categories(null) - .emotion(null) - .entities(null) - .keywords(null) - .metadata(null) - .relations(null) - .semanticRoles(null) - .sentiment(null) + .concepts(conceptsOptionsModel) + .emotion(emotionOptionsModel) + .entities(entitiesOptionsModel) + .keywords(keywordsOptionsModel) + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .relations(relationsOptionsModel) + .semanticRoles(semanticRolesOptionsModel) + .sentiment(sentimentOptionsModel) + .categories(categoriesOptionsModel) + .syntax(syntaxOptionsModel) .build(); - AnalyzeOptions.Builder builder = new AnalyzeOptions.Builder().features(features); - final AnalysisResults response = service.analyze(builder.build()).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - assertEquals(ANALYZE_PATH, request.getPath()); - assertEquals("POST", request.getMethod()); - assertEquals(analyzeResults, response); + // Construct an instance of the AnalyzeOptions model + AnalyzeOptions analyzeOptionsModel = + new AnalyzeOptions.Builder() + .features(featuresModel) + .text("testString") + .html("testString") + .url("testString") + .clean(true) + .xpath("testString") + .fallbackToRaw(true) + .returnAnalyzedText(true) + .language("testString") + .limitTextCharacters(Long.valueOf("26")) + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + naturalLanguageUnderstandingService.analyze(analyzeOptionsModel).execute(); + assertNotNull(response); + AnalysisResults responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, analyzePath); + } + + // Test the analyze operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAnalyzeNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + naturalLanguageUnderstandingService.analyze(null).execute(); } - /** - * Test get models. - * - * @throws InterruptedException the interrupted exception - */ @Test - public void testListModels() throws InterruptedException { - server.enqueue(jsonResponse(models)); - final ListModelsResults response = service.listModels().execute().getResult(); - final RecordedRequest request = server.takeRequest(); - - assertEquals(MODELS_PATH, request.getPath()); - assertEquals("GET", request.getMethod()); - assertEquals(models, response); + public void testListModelsWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"models\": [{\"status\": \"starting\", \"model_id\": \"modelId\", \"language\": \"language\", \"description\": \"description\", \"workspace_id\": \"workspaceId\", \"model_version\": \"modelVersion\", \"version\": \"version\", \"version_description\": \"versionDescription\", \"created\": \"2019-01-01T12:00:00\"}]}"; + String listModelsPath = "/v1/models"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the ListModelsOptions model + ListModelsOptions listModelsOptionsModel = new ListModelsOptions(); + + // Invoke operation with valid options model (positive test) + Response response = + naturalLanguageUnderstandingService.listModels(listModelsOptionsModel).execute(); + assertNotNull(response); + ListModelsResults responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listModelsPath); } - /** - * Test delete model. - * - * @throws InterruptedException the interrupted exception - */ @Test - public void testDeleteModel() throws InterruptedException { - server.enqueue(jsonResponse(null)); - DeleteModelOptions deleteOptions = new DeleteModelOptions.Builder(modelId).build(); - service.deleteModel(deleteOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - - assertEquals(DELETE_PATH, request.getPath()); - assertEquals("DELETE", request.getMethod()); + public void testDeleteModelWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = "{\"deleted\": \"deleted\"}"; + String deleteModelPath = "/v1/models/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the DeleteModelOptions model + DeleteModelOptions deleteModelOptionsModel = + new DeleteModelOptions.Builder().modelId("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = + naturalLanguageUnderstandingService.deleteModel(deleteModelOptionsModel).execute(); + assertNotNull(response); + DeleteModelResults responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteModelPath); + } + + // Test the deleteModel operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteModelNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + naturalLanguageUnderstandingService.deleteModel(null).execute(); } - // START NEGATIVE TESTS - /** Test delete model with a null model ID. */ - @Test(expected = IllegalArgumentException.class) - public void testNullModelId() { - service.deleteModel(null).execute(); + /** Initialize the server */ + @BeforeMethod + public void setUpMockServer() { + try { + server = new MockWebServer(); + // register handler + server.start(); + } catch (IOException err) { + fail("Failed to instantiate mock web server"); + } } - /** Test constructor with null version. */ - @Test(expected = IllegalArgumentException.class) - public void testNullVersion() { - @SuppressWarnings("unused") - NaturalLanguageUnderstanding service2 = - new NaturalLanguageUnderstanding(null, new NoAuthAuthenticator()); + @AfterMethod + public void tearDownMockServer() throws IOException { + server.shutdown(); + naturalLanguageUnderstandingService = null; } } diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/AnalysisResultsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/AnalysisResultsTest.java new file mode 100644 index 00000000000..3e37d99a650 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/AnalysisResultsTest.java @@ -0,0 +1,49 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the AnalysisResults model. */ +public class AnalysisResultsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAnalysisResults() throws Throwable { + AnalysisResults analysisResultsModel = new AnalysisResults(); + assertNull(analysisResultsModel.getLanguage()); + assertNull(analysisResultsModel.getAnalyzedText()); + assertNull(analysisResultsModel.getRetrievedUrl()); + assertNull(analysisResultsModel.getUsage()); + assertNull(analysisResultsModel.getConcepts()); + assertNull(analysisResultsModel.getEntities()); + assertNull(analysisResultsModel.getKeywords()); + assertNull(analysisResultsModel.getCategories()); + assertNull(analysisResultsModel.getEmotion()); + assertNull(analysisResultsModel.getMetadata()); + assertNull(analysisResultsModel.getRelations()); + assertNull(analysisResultsModel.getSemanticRoles()); + assertNull(analysisResultsModel.getSentiment()); + assertNull(analysisResultsModel.getSyntax()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/AnalysisResultsUsageTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/AnalysisResultsUsageTest.java new file mode 100644 index 00000000000..0e34bea13da --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/AnalysisResultsUsageTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the AnalysisResultsUsage model. */ +public class AnalysisResultsUsageTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAnalysisResultsUsage() throws Throwable { + AnalysisResultsUsage analysisResultsUsageModel = new AnalysisResultsUsage(); + assertNull(analysisResultsUsageModel.getFeatures()); + assertNull(analysisResultsUsageModel.getTextCharacters()); + assertNull(analysisResultsUsageModel.getTextUnits()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/AnalyzeOptionsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/AnalyzeOptionsTest.java new file mode 100644 index 00000000000..b11ac824423 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/AnalyzeOptionsTest.java @@ -0,0 +1,179 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the AnalyzeOptions model. */ +public class AnalyzeOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAnalyzeOptions() throws Throwable { + ConceptsOptions conceptsOptionsModel = + new ConceptsOptions.Builder().limit(Long.valueOf("50")).build(); + assertEquals(conceptsOptionsModel.limit(), Long.valueOf("50")); + + EmotionOptions emotionOptionsModel = + new EmotionOptions.Builder() + .document(true) + .targets(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals(emotionOptionsModel.document(), Boolean.valueOf(true)); + assertEquals( + emotionOptionsModel.targets(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + EntitiesOptions entitiesOptionsModel = + new EntitiesOptions.Builder() + .limit(Long.valueOf("250")) + .mentions(true) + .model("testString") + .sentiment(true) + .emotion(true) + .build(); + assertEquals(entitiesOptionsModel.limit(), Long.valueOf("250")); + assertEquals(entitiesOptionsModel.mentions(), Boolean.valueOf(true)); + assertEquals(entitiesOptionsModel.model(), "testString"); + assertEquals(entitiesOptionsModel.sentiment(), Boolean.valueOf(true)); + assertEquals(entitiesOptionsModel.emotion(), Boolean.valueOf(true)); + + KeywordsOptions keywordsOptionsModel = + new KeywordsOptions.Builder() + .limit(Long.valueOf("250")) + .sentiment(true) + .emotion(true) + .build(); + assertEquals(keywordsOptionsModel.limit(), Long.valueOf("250")); + assertEquals(keywordsOptionsModel.sentiment(), Boolean.valueOf(true)); + assertEquals(keywordsOptionsModel.emotion(), Boolean.valueOf(true)); + + RelationsOptions relationsOptionsModel = + new RelationsOptions.Builder().model("testString").build(); + assertEquals(relationsOptionsModel.model(), "testString"); + + SemanticRolesOptions semanticRolesOptionsModel = + new SemanticRolesOptions.Builder() + .limit(Long.valueOf("26")) + .keywords(true) + .entities(true) + .build(); + assertEquals(semanticRolesOptionsModel.limit(), Long.valueOf("26")); + assertEquals(semanticRolesOptionsModel.keywords(), Boolean.valueOf(true)); + assertEquals(semanticRolesOptionsModel.entities(), Boolean.valueOf(true)); + + SentimentOptions sentimentOptionsModel = + new SentimentOptions.Builder() + .document(true) + .targets(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals(sentimentOptionsModel.document(), Boolean.valueOf(true)); + assertEquals( + sentimentOptionsModel.targets(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + CategoriesOptions categoriesOptionsModel = + new CategoriesOptions.Builder() + .explanation(true) + .limit(Long.valueOf("10")) + .model("testString") + .build(); + assertEquals(categoriesOptionsModel.explanation(), Boolean.valueOf(true)); + assertEquals(categoriesOptionsModel.limit(), Long.valueOf("10")); + assertEquals(categoriesOptionsModel.model(), "testString"); + + SyntaxOptionsTokens syntaxOptionsTokensModel = + new SyntaxOptionsTokens.Builder().lemma(true).partOfSpeech(true).build(); + assertEquals(syntaxOptionsTokensModel.lemma(), Boolean.valueOf(true)); + assertEquals(syntaxOptionsTokensModel.partOfSpeech(), Boolean.valueOf(true)); + + SyntaxOptions syntaxOptionsModel = + new SyntaxOptions.Builder().tokens(syntaxOptionsTokensModel).sentences(true).build(); + assertEquals(syntaxOptionsModel.tokens(), syntaxOptionsTokensModel); + assertEquals(syntaxOptionsModel.sentences(), Boolean.valueOf(true)); + + Features featuresModel = + new Features.Builder() + .concepts(conceptsOptionsModel) + .emotion(emotionOptionsModel) + .entities(entitiesOptionsModel) + .keywords(keywordsOptionsModel) + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .relations(relationsOptionsModel) + .semanticRoles(semanticRolesOptionsModel) + .sentiment(sentimentOptionsModel) + .categories(categoriesOptionsModel) + .syntax(syntaxOptionsModel) + .build(); + assertEquals(featuresModel.concepts(), conceptsOptionsModel); + assertEquals(featuresModel.emotion(), emotionOptionsModel); + assertEquals(featuresModel.entities(), entitiesOptionsModel); + assertEquals(featuresModel.keywords(), keywordsOptionsModel); + assertEquals( + featuresModel.metadata(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals(featuresModel.relations(), relationsOptionsModel); + assertEquals(featuresModel.semanticRoles(), semanticRolesOptionsModel); + assertEquals(featuresModel.sentiment(), sentimentOptionsModel); + assertEquals(featuresModel.categories(), categoriesOptionsModel); + assertEquals(featuresModel.syntax(), syntaxOptionsModel); + + AnalyzeOptions analyzeOptionsModel = + new AnalyzeOptions.Builder() + .features(featuresModel) + .text("testString") + .html("testString") + .url("testString") + .clean(true) + .xpath("testString") + .fallbackToRaw(true) + .returnAnalyzedText(true) + .language("testString") + .limitTextCharacters(Long.valueOf("26")) + .build(); + assertEquals(analyzeOptionsModel.features(), featuresModel); + assertEquals(analyzeOptionsModel.text(), "testString"); + assertEquals(analyzeOptionsModel.html(), "testString"); + assertEquals(analyzeOptionsModel.url(), "testString"); + assertEquals(analyzeOptionsModel.clean(), Boolean.valueOf(true)); + assertEquals(analyzeOptionsModel.xpath(), "testString"); + assertEquals(analyzeOptionsModel.fallbackToRaw(), Boolean.valueOf(true)); + assertEquals(analyzeOptionsModel.returnAnalyzedText(), Boolean.valueOf(true)); + assertEquals(analyzeOptionsModel.language(), "testString"); + assertEquals(analyzeOptionsModel.limitTextCharacters(), Long.valueOf("26")); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAnalyzeOptionsError() throws Throwable { + new AnalyzeOptions.Builder().build(); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/AuthorTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/AuthorTest.java new file mode 100644 index 00000000000..b0668933976 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/AuthorTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Author model. */ +public class AuthorTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAuthor() throws Throwable { + Author authorModel = new Author(); + assertNull(authorModel.getName()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesOptionsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesOptionsTest.java new file mode 100644 index 00000000000..ac68055ec44 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesOptionsTest.java @@ -0,0 +1,52 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CategoriesOptions model. */ +public class CategoriesOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCategoriesOptions() throws Throwable { + CategoriesOptions categoriesOptionsModel = + new CategoriesOptions.Builder() + .explanation(true) + .limit(Long.valueOf("10")) + .model("testString") + .build(); + assertEquals(categoriesOptionsModel.explanation(), Boolean.valueOf(true)); + assertEquals(categoriesOptionsModel.limit(), Long.valueOf("10")); + assertEquals(categoriesOptionsModel.model(), "testString"); + + String json = TestUtilities.serialize(categoriesOptionsModel); + + CategoriesOptions categoriesOptionsModelNew = + TestUtilities.deserialize(json, CategoriesOptions.class); + assertTrue(categoriesOptionsModelNew instanceof CategoriesOptions); + assertEquals(categoriesOptionsModelNew.explanation(), Boolean.valueOf(true)); + assertEquals(categoriesOptionsModelNew.limit(), Long.valueOf("10")); + assertEquals(categoriesOptionsModelNew.model(), "testString"); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesRelevantTextTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesRelevantTextTest.java new file mode 100644 index 00000000000..3e542b1d268 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesRelevantTextTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CategoriesRelevantText model. */ +public class CategoriesRelevantTextTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCategoriesRelevantText() throws Throwable { + CategoriesRelevantText categoriesRelevantTextModel = new CategoriesRelevantText(); + assertNull(categoriesRelevantTextModel.getText()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesResultExplanationTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesResultExplanationTest.java new file mode 100644 index 00000000000..d55a62512dc --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesResultExplanationTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CategoriesResultExplanation model. */ +public class CategoriesResultExplanationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCategoriesResultExplanation() throws Throwable { + CategoriesResultExplanation categoriesResultExplanationModel = + new CategoriesResultExplanation(); + assertNull(categoriesResultExplanationModel.getRelevantText()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesResultTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesResultTest.java new file mode 100644 index 00000000000..d350d6266cc --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesResultTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CategoriesResult model. */ +public class CategoriesResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCategoriesResult() throws Throwable { + CategoriesResult categoriesResultModel = new CategoriesResult(); + assertNull(categoriesResultModel.getLabel()); + assertNull(categoriesResultModel.getScore()); + assertNull(categoriesResultModel.getExplanation()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/ConceptsOptionsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/ConceptsOptionsTest.java new file mode 100644 index 00000000000..ff124f44be2 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/ConceptsOptionsTest.java @@ -0,0 +1,44 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ConceptsOptions model. */ +public class ConceptsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testConceptsOptions() throws Throwable { + ConceptsOptions conceptsOptionsModel = + new ConceptsOptions.Builder().limit(Long.valueOf("50")).build(); + assertEquals(conceptsOptionsModel.limit(), Long.valueOf("50")); + + String json = TestUtilities.serialize(conceptsOptionsModel); + + ConceptsOptions conceptsOptionsModelNew = + TestUtilities.deserialize(json, ConceptsOptions.class); + assertTrue(conceptsOptionsModelNew instanceof ConceptsOptions); + assertEquals(conceptsOptionsModelNew.limit(), Long.valueOf("50")); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/ConceptsResultTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/ConceptsResultTest.java new file mode 100644 index 00000000000..41c21212f97 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/ConceptsResultTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ConceptsResult model. */ +public class ConceptsResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testConceptsResult() throws Throwable { + ConceptsResult conceptsResultModel = new ConceptsResult(); + assertNull(conceptsResultModel.getText()); + assertNull(conceptsResultModel.getRelevance()); + assertNull(conceptsResultModel.getDbpediaResource()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/DeleteModelOptionsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/DeleteModelOptionsTest.java new file mode 100644 index 00000000000..df4e3794e78 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/DeleteModelOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteModelOptions model. */ +public class DeleteModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteModelOptions() throws Throwable { + DeleteModelOptions deleteModelOptionsModel = + new DeleteModelOptions.Builder().modelId("testString").build(); + assertEquals(deleteModelOptionsModel.modelId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteModelOptionsError() throws Throwable { + new DeleteModelOptions.Builder().build(); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/DeleteModelResultsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/DeleteModelResultsTest.java new file mode 100644 index 00000000000..3e3d435e03a --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/DeleteModelResultsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteModelResults model. */ +public class DeleteModelResultsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteModelResults() throws Throwable { + DeleteModelResults deleteModelResultsModel = new DeleteModelResults(); + assertNull(deleteModelResultsModel.getDeleted()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/DisambiguationResultTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/DisambiguationResultTest.java new file mode 100644 index 00000000000..a8a47294c27 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/DisambiguationResultTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DisambiguationResult model. */ +public class DisambiguationResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDisambiguationResult() throws Throwable { + DisambiguationResult disambiguationResultModel = new DisambiguationResult(); + assertNull(disambiguationResultModel.getName()); + assertNull(disambiguationResultModel.getDbpediaResource()); + assertNull(disambiguationResultModel.getSubtype()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/DocumentEmotionResultsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/DocumentEmotionResultsTest.java new file mode 100644 index 00000000000..32f8462b706 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/DocumentEmotionResultsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DocumentEmotionResults model. */ +public class DocumentEmotionResultsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDocumentEmotionResults() throws Throwable { + DocumentEmotionResults documentEmotionResultsModel = new DocumentEmotionResults(); + assertNull(documentEmotionResultsModel.getEmotion()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/DocumentSentimentResultsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/DocumentSentimentResultsTest.java new file mode 100644 index 00000000000..1d8b54b398a --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/DocumentSentimentResultsTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DocumentSentimentResults model. */ +public class DocumentSentimentResultsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDocumentSentimentResults() throws Throwable { + DocumentSentimentResults documentSentimentResultsModel = new DocumentSentimentResults(); + assertNull(documentSentimentResultsModel.getLabel()); + assertNull(documentSentimentResultsModel.getScore()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/EmotionOptionsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/EmotionOptionsTest.java new file mode 100644 index 00000000000..56f4f13cc19 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/EmotionOptionsTest.java @@ -0,0 +1,49 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the EmotionOptions model. */ +public class EmotionOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testEmotionOptions() throws Throwable { + EmotionOptions emotionOptionsModel = + new EmotionOptions.Builder() + .document(true) + .targets(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals(emotionOptionsModel.document(), Boolean.valueOf(true)); + assertEquals( + emotionOptionsModel.targets(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + String json = TestUtilities.serialize(emotionOptionsModel); + + EmotionOptions emotionOptionsModelNew = TestUtilities.deserialize(json, EmotionOptions.class); + assertTrue(emotionOptionsModelNew instanceof EmotionOptions); + assertEquals(emotionOptionsModelNew.document(), Boolean.valueOf(true)); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/EmotionResultTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/EmotionResultTest.java new file mode 100644 index 00000000000..4dc0db2a8ed --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/EmotionResultTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the EmotionResult model. */ +public class EmotionResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testEmotionResult() throws Throwable { + EmotionResult emotionResultModel = new EmotionResult(); + assertNull(emotionResultModel.getDocument()); + assertNull(emotionResultModel.getTargets()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/EmotionScoresTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/EmotionScoresTest.java new file mode 100644 index 00000000000..f1180be6a4a --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/EmotionScoresTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the EmotionScores model. */ +public class EmotionScoresTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testEmotionScores() throws Throwable { + EmotionScores emotionScoresModel = new EmotionScores(); + assertNull(emotionScoresModel.getAnger()); + assertNull(emotionScoresModel.getDisgust()); + assertNull(emotionScoresModel.getFear()); + assertNull(emotionScoresModel.getJoy()); + assertNull(emotionScoresModel.getSadness()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/EntitiesOptionsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/EntitiesOptionsTest.java new file mode 100644 index 00000000000..dbd2505cd2c --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/EntitiesOptionsTest.java @@ -0,0 +1,58 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the EntitiesOptions model. */ +public class EntitiesOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testEntitiesOptions() throws Throwable { + EntitiesOptions entitiesOptionsModel = + new EntitiesOptions.Builder() + .limit(Long.valueOf("250")) + .mentions(true) + .model("testString") + .sentiment(true) + .emotion(true) + .build(); + assertEquals(entitiesOptionsModel.limit(), Long.valueOf("250")); + assertEquals(entitiesOptionsModel.mentions(), Boolean.valueOf(true)); + assertEquals(entitiesOptionsModel.model(), "testString"); + assertEquals(entitiesOptionsModel.sentiment(), Boolean.valueOf(true)); + assertEquals(entitiesOptionsModel.emotion(), Boolean.valueOf(true)); + + String json = TestUtilities.serialize(entitiesOptionsModel); + + EntitiesOptions entitiesOptionsModelNew = + TestUtilities.deserialize(json, EntitiesOptions.class); + assertTrue(entitiesOptionsModelNew instanceof EntitiesOptions); + assertEquals(entitiesOptionsModelNew.limit(), Long.valueOf("250")); + assertEquals(entitiesOptionsModelNew.mentions(), Boolean.valueOf(true)); + assertEquals(entitiesOptionsModelNew.model(), "testString"); + assertEquals(entitiesOptionsModelNew.sentiment(), Boolean.valueOf(true)); + assertEquals(entitiesOptionsModelNew.emotion(), Boolean.valueOf(true)); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/EntitiesResultTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/EntitiesResultTest.java new file mode 100644 index 00000000000..d053d5287eb --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/EntitiesResultTest.java @@ -0,0 +1,44 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the EntitiesResult model. */ +public class EntitiesResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testEntitiesResult() throws Throwable { + EntitiesResult entitiesResultModel = new EntitiesResult(); + assertNull(entitiesResultModel.getType()); + assertNull(entitiesResultModel.getText()); + assertNull(entitiesResultModel.getRelevance()); + assertNull(entitiesResultModel.getConfidence()); + assertNull(entitiesResultModel.getMentions()); + assertNull(entitiesResultModel.getCount()); + assertNull(entitiesResultModel.getEmotion()); + assertNull(entitiesResultModel.getSentiment()); + assertNull(entitiesResultModel.getDisambiguation()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/EntityMentionTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/EntityMentionTest.java new file mode 100644 index 00000000000..9ad823e5198 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/EntityMentionTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the EntityMention model. */ +public class EntityMentionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testEntityMention() throws Throwable { + EntityMention entityMentionModel = new EntityMention(); + assertNull(entityMentionModel.getText()); + assertNull(entityMentionModel.getLocation()); + assertNull(entityMentionModel.getConfidence()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/FeatureSentimentResultsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/FeatureSentimentResultsTest.java new file mode 100644 index 00000000000..bf1747f6a6a --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/FeatureSentimentResultsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the FeatureSentimentResults model. */ +public class FeatureSentimentResultsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testFeatureSentimentResults() throws Throwable { + FeatureSentimentResults featureSentimentResultsModel = new FeatureSentimentResults(); + assertNull(featureSentimentResultsModel.getScore()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/FeaturesResultsMetadataTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/FeaturesResultsMetadataTest.java new file mode 100644 index 00000000000..79ba1f9d0a8 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/FeaturesResultsMetadataTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the FeaturesResultsMetadata model. */ +public class FeaturesResultsMetadataTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testFeaturesResultsMetadata() throws Throwable { + FeaturesResultsMetadata featuresResultsMetadataModel = new FeaturesResultsMetadata(); + assertNull(featuresResultsMetadataModel.getAuthors()); + assertNull(featuresResultsMetadataModel.getPublicationDate()); + assertNull(featuresResultsMetadataModel.getTitle()); + assertNull(featuresResultsMetadataModel.getImage()); + assertNull(featuresResultsMetadataModel.getFeeds()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/FeaturesTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/FeaturesTest.java new file mode 100644 index 00000000000..0c161e209f7 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/FeaturesTest.java @@ -0,0 +1,171 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Features model. */ +public class FeaturesTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testFeatures() throws Throwable { + ConceptsOptions conceptsOptionsModel = + new ConceptsOptions.Builder().limit(Long.valueOf("50")).build(); + assertEquals(conceptsOptionsModel.limit(), Long.valueOf("50")); + + EmotionOptions emotionOptionsModel = + new EmotionOptions.Builder() + .document(true) + .targets(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals(emotionOptionsModel.document(), Boolean.valueOf(true)); + assertEquals( + emotionOptionsModel.targets(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + EntitiesOptions entitiesOptionsModel = + new EntitiesOptions.Builder() + .limit(Long.valueOf("250")) + .mentions(true) + .model("testString") + .sentiment(true) + .emotion(true) + .build(); + assertEquals(entitiesOptionsModel.limit(), Long.valueOf("250")); + assertEquals(entitiesOptionsModel.mentions(), Boolean.valueOf(true)); + assertEquals(entitiesOptionsModel.model(), "testString"); + assertEquals(entitiesOptionsModel.sentiment(), Boolean.valueOf(true)); + assertEquals(entitiesOptionsModel.emotion(), Boolean.valueOf(true)); + + KeywordsOptions keywordsOptionsModel = + new KeywordsOptions.Builder() + .limit(Long.valueOf("250")) + .sentiment(true) + .emotion(true) + .build(); + assertEquals(keywordsOptionsModel.limit(), Long.valueOf("250")); + assertEquals(keywordsOptionsModel.sentiment(), Boolean.valueOf(true)); + assertEquals(keywordsOptionsModel.emotion(), Boolean.valueOf(true)); + + RelationsOptions relationsOptionsModel = + new RelationsOptions.Builder().model("testString").build(); + assertEquals(relationsOptionsModel.model(), "testString"); + + SemanticRolesOptions semanticRolesOptionsModel = + new SemanticRolesOptions.Builder() + .limit(Long.valueOf("26")) + .keywords(true) + .entities(true) + .build(); + assertEquals(semanticRolesOptionsModel.limit(), Long.valueOf("26")); + assertEquals(semanticRolesOptionsModel.keywords(), Boolean.valueOf(true)); + assertEquals(semanticRolesOptionsModel.entities(), Boolean.valueOf(true)); + + SentimentOptions sentimentOptionsModel = + new SentimentOptions.Builder() + .document(true) + .targets(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals(sentimentOptionsModel.document(), Boolean.valueOf(true)); + assertEquals( + sentimentOptionsModel.targets(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + CategoriesOptions categoriesOptionsModel = + new CategoriesOptions.Builder() + .explanation(true) + .limit(Long.valueOf("10")) + .model("testString") + .build(); + assertEquals(categoriesOptionsModel.explanation(), Boolean.valueOf(true)); + assertEquals(categoriesOptionsModel.limit(), Long.valueOf("10")); + assertEquals(categoriesOptionsModel.model(), "testString"); + + SyntaxOptionsTokens syntaxOptionsTokensModel = + new SyntaxOptionsTokens.Builder().lemma(true).partOfSpeech(true).build(); + assertEquals(syntaxOptionsTokensModel.lemma(), Boolean.valueOf(true)); + assertEquals(syntaxOptionsTokensModel.partOfSpeech(), Boolean.valueOf(true)); + + SyntaxOptions syntaxOptionsModel = + new SyntaxOptions.Builder().tokens(syntaxOptionsTokensModel).sentences(true).build(); + assertEquals(syntaxOptionsModel.tokens(), syntaxOptionsTokensModel); + assertEquals(syntaxOptionsModel.sentences(), Boolean.valueOf(true)); + + Features featuresModel = + new Features.Builder() + .concepts(conceptsOptionsModel) + .emotion(emotionOptionsModel) + .entities(entitiesOptionsModel) + .keywords(keywordsOptionsModel) + .metadata( + new java.util.HashMap() { + { + put("foo", "testString"); + } + }) + .relations(relationsOptionsModel) + .semanticRoles(semanticRolesOptionsModel) + .sentiment(sentimentOptionsModel) + .categories(categoriesOptionsModel) + .syntax(syntaxOptionsModel) + .build(); + assertEquals(featuresModel.concepts(), conceptsOptionsModel); + assertEquals(featuresModel.emotion(), emotionOptionsModel); + assertEquals(featuresModel.entities(), entitiesOptionsModel); + assertEquals(featuresModel.keywords(), keywordsOptionsModel); + assertEquals( + featuresModel.metadata(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }); + assertEquals(featuresModel.relations(), relationsOptionsModel); + assertEquals(featuresModel.semanticRoles(), semanticRolesOptionsModel); + assertEquals(featuresModel.sentiment(), sentimentOptionsModel); + assertEquals(featuresModel.categories(), categoriesOptionsModel); + assertEquals(featuresModel.syntax(), syntaxOptionsModel); + + String json = TestUtilities.serialize(featuresModel); + + Features featuresModelNew = TestUtilities.deserialize(json, Features.class); + assertTrue(featuresModelNew instanceof Features); + assertEquals(featuresModelNew.concepts().toString(), conceptsOptionsModel.toString()); + assertEquals(featuresModelNew.emotion().toString(), emotionOptionsModel.toString()); + assertEquals(featuresModelNew.entities().toString(), entitiesOptionsModel.toString()); + assertEquals(featuresModelNew.keywords().toString(), keywordsOptionsModel.toString()); + assertEquals( + featuresModelNew.metadata().toString(), + new java.util.HashMap() { + { + put("foo", "testString"); + } + }.toString()); + assertEquals(featuresModelNew.relations().toString(), relationsOptionsModel.toString()); + assertEquals(featuresModelNew.semanticRoles().toString(), semanticRolesOptionsModel.toString()); + assertEquals(featuresModelNew.sentiment().toString(), sentimentOptionsModel.toString()); + assertEquals(featuresModelNew.categories().toString(), categoriesOptionsModel.toString()); + assertEquals(featuresModelNew.syntax().toString(), syntaxOptionsModel.toString()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/FeedTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/FeedTest.java new file mode 100644 index 00000000000..ea02d2ae9fb --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/FeedTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Feed model. */ +public class FeedTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testFeed() throws Throwable { + Feed feedModel = new Feed(); + assertNull(feedModel.getLink()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/KeywordsOptionsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/KeywordsOptionsTest.java new file mode 100644 index 00000000000..4a6240f66e0 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/KeywordsOptionsTest.java @@ -0,0 +1,52 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the KeywordsOptions model. */ +public class KeywordsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testKeywordsOptions() throws Throwable { + KeywordsOptions keywordsOptionsModel = + new KeywordsOptions.Builder() + .limit(Long.valueOf("250")) + .sentiment(true) + .emotion(true) + .build(); + assertEquals(keywordsOptionsModel.limit(), Long.valueOf("250")); + assertEquals(keywordsOptionsModel.sentiment(), Boolean.valueOf(true)); + assertEquals(keywordsOptionsModel.emotion(), Boolean.valueOf(true)); + + String json = TestUtilities.serialize(keywordsOptionsModel); + + KeywordsOptions keywordsOptionsModelNew = + TestUtilities.deserialize(json, KeywordsOptions.class); + assertTrue(keywordsOptionsModelNew instanceof KeywordsOptions); + assertEquals(keywordsOptionsModelNew.limit(), Long.valueOf("250")); + assertEquals(keywordsOptionsModelNew.sentiment(), Boolean.valueOf(true)); + assertEquals(keywordsOptionsModelNew.emotion(), Boolean.valueOf(true)); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/KeywordsResultTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/KeywordsResultTest.java new file mode 100644 index 00000000000..3899b45b881 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/KeywordsResultTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the KeywordsResult model. */ +public class KeywordsResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testKeywordsResult() throws Throwable { + KeywordsResult keywordsResultModel = new KeywordsResult(); + assertNull(keywordsResultModel.getCount()); + assertNull(keywordsResultModel.getRelevance()); + assertNull(keywordsResultModel.getText()); + assertNull(keywordsResultModel.getEmotion()); + assertNull(keywordsResultModel.getSentiment()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/ListModelsOptionsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/ListModelsOptionsTest.java new file mode 100644 index 00000000000..0707152c1bb --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/ListModelsOptionsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListModelsOptions model. */ +public class ListModelsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListModelsOptions() throws Throwable { + ListModelsOptions listModelsOptionsModel = new ListModelsOptions(); + assertNotNull(listModelsOptionsModel); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/ListModelsResultsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/ListModelsResultsTest.java new file mode 100644 index 00000000000..48ccae4ed6b --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/ListModelsResultsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListModelsResults model. */ +public class ListModelsResultsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListModelsResults() throws Throwable { + ListModelsResults listModelsResultsModel = new ListModelsResults(); + assertNull(listModelsResultsModel.getModels()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/ModelTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/ModelTest.java new file mode 100644 index 00000000000..11056cba484 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/ModelTest.java @@ -0,0 +1,44 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Model model. */ +public class ModelTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testModel() throws Throwable { + Model modelModel = new Model(); + assertNull(modelModel.getStatus()); + assertNull(modelModel.getModelId()); + assertNull(modelModel.getLanguage()); + assertNull(modelModel.getDescription()); + assertNull(modelModel.getWorkspaceId()); + assertNull(modelModel.getModelVersion()); + assertNull(modelModel.getVersion()); + assertNull(modelModel.getVersionDescription()); + assertNull(modelModel.getCreated()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/RelationArgumentTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/RelationArgumentTest.java new file mode 100644 index 00000000000..82bb46bfc7f --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/RelationArgumentTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RelationArgument model. */ +public class RelationArgumentTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRelationArgument() throws Throwable { + RelationArgument relationArgumentModel = new RelationArgument(); + assertNull(relationArgumentModel.getEntities()); + assertNull(relationArgumentModel.getLocation()); + assertNull(relationArgumentModel.getText()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/RelationEntityTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/RelationEntityTest.java new file mode 100644 index 00000000000..0c18a71f2b1 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/RelationEntityTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RelationEntity model. */ +public class RelationEntityTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRelationEntity() throws Throwable { + RelationEntity relationEntityModel = new RelationEntity(); + assertNull(relationEntityModel.getText()); + assertNull(relationEntityModel.getType()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/RelationsOptionsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/RelationsOptionsTest.java new file mode 100644 index 00000000000..7c85ef01f17 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/RelationsOptionsTest.java @@ -0,0 +1,44 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RelationsOptions model. */ +public class RelationsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRelationsOptions() throws Throwable { + RelationsOptions relationsOptionsModel = + new RelationsOptions.Builder().model("testString").build(); + assertEquals(relationsOptionsModel.model(), "testString"); + + String json = TestUtilities.serialize(relationsOptionsModel); + + RelationsOptions relationsOptionsModelNew = + TestUtilities.deserialize(json, RelationsOptions.class); + assertTrue(relationsOptionsModelNew instanceof RelationsOptions); + assertEquals(relationsOptionsModelNew.model(), "testString"); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/RelationsResultTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/RelationsResultTest.java new file mode 100644 index 00000000000..a0143a69ac2 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/RelationsResultTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RelationsResult model. */ +public class RelationsResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRelationsResult() throws Throwable { + RelationsResult relationsResultModel = new RelationsResult(); + assertNull(relationsResultModel.getScore()); + assertNull(relationsResultModel.getSentence()); + assertNull(relationsResultModel.getType()); + assertNull(relationsResultModel.getArguments()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesEntityTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesEntityTest.java new file mode 100644 index 00000000000..27406bafbef --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesEntityTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SemanticRolesEntity model. */ +public class SemanticRolesEntityTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSemanticRolesEntity() throws Throwable { + SemanticRolesEntity semanticRolesEntityModel = new SemanticRolesEntity(); + assertNull(semanticRolesEntityModel.getType()); + assertNull(semanticRolesEntityModel.getText()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesKeywordTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesKeywordTest.java new file mode 100644 index 00000000000..c39e95bfaad --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesKeywordTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SemanticRolesKeyword model. */ +public class SemanticRolesKeywordTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSemanticRolesKeyword() throws Throwable { + SemanticRolesKeyword semanticRolesKeywordModel = new SemanticRolesKeyword(); + assertNull(semanticRolesKeywordModel.getText()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesOptionsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesOptionsTest.java new file mode 100644 index 00000000000..1cdda869f5a --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesOptionsTest.java @@ -0,0 +1,52 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SemanticRolesOptions model. */ +public class SemanticRolesOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSemanticRolesOptions() throws Throwable { + SemanticRolesOptions semanticRolesOptionsModel = + new SemanticRolesOptions.Builder() + .limit(Long.valueOf("26")) + .keywords(true) + .entities(true) + .build(); + assertEquals(semanticRolesOptionsModel.limit(), Long.valueOf("26")); + assertEquals(semanticRolesOptionsModel.keywords(), Boolean.valueOf(true)); + assertEquals(semanticRolesOptionsModel.entities(), Boolean.valueOf(true)); + + String json = TestUtilities.serialize(semanticRolesOptionsModel); + + SemanticRolesOptions semanticRolesOptionsModelNew = + TestUtilities.deserialize(json, SemanticRolesOptions.class); + assertTrue(semanticRolesOptionsModelNew instanceof SemanticRolesOptions); + assertEquals(semanticRolesOptionsModelNew.limit(), Long.valueOf("26")); + assertEquals(semanticRolesOptionsModelNew.keywords(), Boolean.valueOf(true)); + assertEquals(semanticRolesOptionsModelNew.entities(), Boolean.valueOf(true)); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResultActionTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResultActionTest.java new file mode 100644 index 00000000000..7251c800c75 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResultActionTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SemanticRolesResultAction model. */ +public class SemanticRolesResultActionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSemanticRolesResultAction() throws Throwable { + SemanticRolesResultAction semanticRolesResultActionModel = new SemanticRolesResultAction(); + assertNull(semanticRolesResultActionModel.getText()); + assertNull(semanticRolesResultActionModel.getNormalized()); + assertNull(semanticRolesResultActionModel.getVerb()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResultObjectTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResultObjectTest.java new file mode 100644 index 00000000000..2672ffa9ce7 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResultObjectTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SemanticRolesResultObject model. */ +public class SemanticRolesResultObjectTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSemanticRolesResultObject() throws Throwable { + SemanticRolesResultObject semanticRolesResultObjectModel = new SemanticRolesResultObject(); + assertNull(semanticRolesResultObjectModel.getText()); + assertNull(semanticRolesResultObjectModel.getKeywords()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResultSubjectTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResultSubjectTest.java new file mode 100644 index 00000000000..591935ca64b --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResultSubjectTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SemanticRolesResultSubject model. */ +public class SemanticRolesResultSubjectTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSemanticRolesResultSubject() throws Throwable { + SemanticRolesResultSubject semanticRolesResultSubjectModel = new SemanticRolesResultSubject(); + assertNull(semanticRolesResultSubjectModel.getText()); + assertNull(semanticRolesResultSubjectModel.getEntities()); + assertNull(semanticRolesResultSubjectModel.getKeywords()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResultTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResultTest.java new file mode 100644 index 00000000000..0457a495199 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResultTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SemanticRolesResult model. */ +public class SemanticRolesResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSemanticRolesResult() throws Throwable { + SemanticRolesResult semanticRolesResultModel = new SemanticRolesResult(); + assertNull(semanticRolesResultModel.getSentence()); + assertNull(semanticRolesResultModel.getSubject()); + assertNull(semanticRolesResultModel.getAction()); + assertNull(semanticRolesResultModel.getObject()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesVerbTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesVerbTest.java new file mode 100644 index 00000000000..07ba0ab35ff --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesVerbTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SemanticRolesVerb model. */ +public class SemanticRolesVerbTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSemanticRolesVerb() throws Throwable { + SemanticRolesVerb semanticRolesVerbModel = new SemanticRolesVerb(); + assertNull(semanticRolesVerbModel.getText()); + assertNull(semanticRolesVerbModel.getTense()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SentenceResultTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SentenceResultTest.java new file mode 100644 index 00000000000..41021f841ad --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SentenceResultTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SentenceResult model. */ +public class SentenceResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSentenceResult() throws Throwable { + SentenceResult sentenceResultModel = new SentenceResult(); + assertNull(sentenceResultModel.getText()); + assertNull(sentenceResultModel.getLocation()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SentimentOptionsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SentimentOptionsTest.java new file mode 100644 index 00000000000..b51bb13edf2 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SentimentOptionsTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SentimentOptions model. */ +public class SentimentOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSentimentOptions() throws Throwable { + SentimentOptions sentimentOptionsModel = + new SentimentOptions.Builder() + .document(true) + .targets(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .build(); + assertEquals(sentimentOptionsModel.document(), Boolean.valueOf(true)); + assertEquals( + sentimentOptionsModel.targets(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + + String json = TestUtilities.serialize(sentimentOptionsModel); + + SentimentOptions sentimentOptionsModelNew = + TestUtilities.deserialize(json, SentimentOptions.class); + assertTrue(sentimentOptionsModelNew instanceof SentimentOptions); + assertEquals(sentimentOptionsModelNew.document(), Boolean.valueOf(true)); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SentimentResultTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SentimentResultTest.java new file mode 100644 index 00000000000..7ef8e8a53db --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SentimentResultTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SentimentResult model. */ +public class SentimentResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSentimentResult() throws Throwable { + SentimentResult sentimentResultModel = new SentimentResult(); + assertNull(sentimentResultModel.getDocument()); + assertNull(sentimentResultModel.getTargets()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SyntaxOptionsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SyntaxOptionsTest.java new file mode 100644 index 00000000000..000c74b8f97 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SyntaxOptionsTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SyntaxOptions model. */ +public class SyntaxOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSyntaxOptions() throws Throwable { + SyntaxOptionsTokens syntaxOptionsTokensModel = + new SyntaxOptionsTokens.Builder().lemma(true).partOfSpeech(true).build(); + assertEquals(syntaxOptionsTokensModel.lemma(), Boolean.valueOf(true)); + assertEquals(syntaxOptionsTokensModel.partOfSpeech(), Boolean.valueOf(true)); + + SyntaxOptions syntaxOptionsModel = + new SyntaxOptions.Builder().tokens(syntaxOptionsTokensModel).sentences(true).build(); + assertEquals(syntaxOptionsModel.tokens(), syntaxOptionsTokensModel); + assertEquals(syntaxOptionsModel.sentences(), Boolean.valueOf(true)); + + String json = TestUtilities.serialize(syntaxOptionsModel); + + SyntaxOptions syntaxOptionsModelNew = TestUtilities.deserialize(json, SyntaxOptions.class); + assertTrue(syntaxOptionsModelNew instanceof SyntaxOptions); + assertEquals(syntaxOptionsModelNew.tokens().toString(), syntaxOptionsTokensModel.toString()); + assertEquals(syntaxOptionsModelNew.sentences(), Boolean.valueOf(true)); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SyntaxOptionsTokensTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SyntaxOptionsTokensTest.java new file mode 100644 index 00000000000..ac2d0a9e488 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SyntaxOptionsTokensTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SyntaxOptionsTokens model. */ +public class SyntaxOptionsTokensTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSyntaxOptionsTokens() throws Throwable { + SyntaxOptionsTokens syntaxOptionsTokensModel = + new SyntaxOptionsTokens.Builder().lemma(true).partOfSpeech(true).build(); + assertEquals(syntaxOptionsTokensModel.lemma(), Boolean.valueOf(true)); + assertEquals(syntaxOptionsTokensModel.partOfSpeech(), Boolean.valueOf(true)); + + String json = TestUtilities.serialize(syntaxOptionsTokensModel); + + SyntaxOptionsTokens syntaxOptionsTokensModelNew = + TestUtilities.deserialize(json, SyntaxOptionsTokens.class); + assertTrue(syntaxOptionsTokensModelNew instanceof SyntaxOptionsTokens); + assertEquals(syntaxOptionsTokensModelNew.lemma(), Boolean.valueOf(true)); + assertEquals(syntaxOptionsTokensModelNew.partOfSpeech(), Boolean.valueOf(true)); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SyntaxResultTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SyntaxResultTest.java new file mode 100644 index 00000000000..b859e19ee9b --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/SyntaxResultTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SyntaxResult model. */ +public class SyntaxResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSyntaxResult() throws Throwable { + SyntaxResult syntaxResultModel = new SyntaxResult(); + assertNull(syntaxResultModel.getTokens()); + assertNull(syntaxResultModel.getSentences()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/TargetedEmotionResultsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/TargetedEmotionResultsTest.java new file mode 100644 index 00000000000..41218d2ccab --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/TargetedEmotionResultsTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TargetedEmotionResults model. */ +public class TargetedEmotionResultsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTargetedEmotionResults() throws Throwable { + TargetedEmotionResults targetedEmotionResultsModel = new TargetedEmotionResults(); + assertNull(targetedEmotionResultsModel.getText()); + assertNull(targetedEmotionResultsModel.getEmotion()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/TargetedSentimentResultsTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/TargetedSentimentResultsTest.java new file mode 100644 index 00000000000..25da4f0be85 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/TargetedSentimentResultsTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TargetedSentimentResults model. */ +public class TargetedSentimentResultsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTargetedSentimentResults() throws Throwable { + TargetedSentimentResults targetedSentimentResultsModel = new TargetedSentimentResults(); + assertNull(targetedSentimentResultsModel.getText()); + assertNull(targetedSentimentResultsModel.getScore()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/TokenResultTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/TokenResultTest.java new file mode 100644 index 00000000000..00386b9f3a1 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/model/TokenResultTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_understanding.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.natural_language_understanding.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TokenResult model. */ +public class TokenResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTokenResult() throws Throwable { + TokenResult tokenResultModel = new TokenResult(); + assertNull(tokenResultModel.getText()); + assertNull(tokenResultModel.getPartOfSpeech()); + assertNull(tokenResultModel.getLocation()); + assertNull(tokenResultModel.getLemma()); + } +} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/utils/TestUtilities.java b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/utils/TestUtilities.java new file mode 100644 index 00000000000..e6fa31df673 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/utils/TestUtilities.java @@ -0,0 +1,128 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.natural_language_understanding.v1.utils; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.cloud.sdk.core.util.GsonSingleton; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import okhttp3.HttpUrl; +import okhttp3.mockwebserver.RecordedRequest; + +/** A class used by the unit tests containing utility functions. */ +public class TestUtilities { + public static Map createMockMap() { + Map mockMap = new HashMap<>(); + mockMap.put("foo", "bar"); + return mockMap; + } + + public static HashMap createMockStreamMap() { + return new HashMap() { + { + put("key1", createMockStream("This is a mock file.")); + } + }; + } + + public static Map parseQueryString(RecordedRequest req) { + Map queryMap = new HashMap<>(); + + try { + HttpUrl requestUrl = req.getRequestUrl(); + + if (requestUrl != null) { + Set queryParamsNames = requestUrl.queryParameterNames(); + // map the parameter name to its corresponding value + for (String p : queryParamsNames) { + // get the corresponding value for the parameter (p) + List val = requestUrl.queryParameterValues(p); + if (val != null && !val.isEmpty()) { + String joinedQuery = String.join(",", val); + queryMap.put(p, joinedQuery); + } + } + } + if (queryMap.isEmpty()) { + return null; + } + } catch (Exception e) { + return null; + } + + return queryMap; + } + + public static String parseReqPath(RecordedRequest req) { + String parsedPath = null; + + try { + String fullPath = req.getPath(); + if (fullPath != null && !fullPath.isEmpty()) { + // retrieve the path segment before the query parameter + parsedPath = fullPath.split("\\?", 2)[0]; + } + if (parsedPath.isEmpty() || parsedPath == null) { + return null; + } + + } catch (Exception e) { + return null; + } + + return parsedPath; + } + + public static String serialize(Object obj) { + return GsonSingleton.getGson().toJson(obj); + } + + public static T deserialize(String json, Class clazz) { + return GsonSingleton.getGson().fromJson(json, clazz); + } + + public static InputStream createMockStream(String s) { + return new ByteArrayInputStream(s.getBytes()); + } + + public static List creatMockListFileWithMetadata() { + List list = new ArrayList(); + byte[] fileBytes = {(byte) 0xde, (byte) 0xad, (byte) 0xbe, (byte) 0xef}; + InputStream inputStream = new ByteArrayInputStream(fileBytes); + FileWithMetadata.Builder builder = new FileWithMetadata.Builder(); + builder.data(inputStream); + FileWithMetadata fileWithMetadata = builder.build(); + list.add(fileWithMetadata); + + return list; + } + + public static byte[] createMockByteArray(String bytes) { + return bytes.getBytes(); + } + + public static Date createMockDate(String date) throws Exception { + return new SimpleDateFormat("yyyy-MM-dd").parse(date); + } + + public static Date createMockDateTime(String date) throws Exception { + return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").parse(date); + } +} diff --git a/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/PersonalityInsights.java b/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/PersonalityInsights.java index 0511cd5d108..0cab6ad9f69 100644 --- a/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/PersonalityInsights.java +++ b/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/PersonalityInsights.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2016, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -10,6 +10,11 @@ * 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. */ + +/* + * IBM OpenAPI SDK Code Generator Version: 99-SNAPSHOT-7cc05500-20201106-154555 + */ + package com.ibm.watson.personality_insights.v3; import com.ibm.cloud.sdk.core.http.RequestBuilder; @@ -27,8 +32,8 @@ import java.util.Map.Entry; /** - * The IBM Watson™ Personality Insights service enables applications to derive insights from - * social media, enterprise data, or other digital communications. The service uses linguistic + * The IBM Watson&trade; Personality Insights service enables applications to derive insights + * from social media, enterprise data, or other digital communications. The service uses linguistic * analytics to infer individuals' intrinsic personality characteristics, including Big Five, Needs, * and Values, from digital communications such as email, text messages, tweets, and forum posts. * @@ -46,70 +51,93 @@ * retain data from requests and responses. * * @version v3 - * @see Personality Insights + * @see Personality Insights */ public class PersonalityInsights extends BaseService { - private static final String DEFAULT_SERVICE_NAME = "personality_insights"; + public static final String DEFAULT_SERVICE_NAME = "personality_insights"; - private static final String DEFAULT_SERVICE_URL = + public static final String DEFAULT_SERVICE_URL = "https://api.us-south.personality-insights.watson.cloud.ibm.com"; - private String versionDate; + private String version; /** - * Constructs a new `PersonalityInsights` client using the DEFAULT_SERVICE_NAME. + * Constructs an instance of the `PersonalityInsights` client. The default service name is used to + * configure the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value - * will keep your API calls from failing when the service introduces breaking changes. + * @param version Release date of the version of the API you want to use. Specify dates in + * YYYY-MM-DD format. The current version is `2017-10-13`. */ - public PersonalityInsights(String versionDate) { + public PersonalityInsights(String version) { this( - versionDate, + version, DEFAULT_SERVICE_NAME, ConfigBasedAuthenticatorFactory.getAuthenticator(DEFAULT_SERVICE_NAME)); } /** - * Constructs a new `PersonalityInsights` client with the DEFAULT_SERVICE_NAME and the specified - * Authenticator. + * Constructs an instance of the `PersonalityInsights` client. The default service name and + * specified authenticator are used to configure the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value - * will keep your API calls from failing when the service introduces breaking changes. - * @param authenticator the Authenticator instance to be configured for this service + * @param version Release date of the version of the API you want to use. Specify dates in + * YYYY-MM-DD format. The current version is `2017-10-13`. + * @param authenticator the {@link Authenticator} instance to be configured for this client */ - public PersonalityInsights(String versionDate, Authenticator authenticator) { - this(versionDate, DEFAULT_SERVICE_NAME, authenticator); + public PersonalityInsights(String version, Authenticator authenticator) { + this(version, DEFAULT_SERVICE_NAME, authenticator); } /** - * Constructs a new `PersonalityInsights` client with the specified serviceName. + * Constructs an instance of the `PersonalityInsights` client. The specified service name is used + * to configure the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value - * will keep your API calls from failing when the service introduces breaking changes. - * @param serviceName The name of the service to configure. + * @param version Release date of the version of the API you want to use. Specify dates in + * YYYY-MM-DD format. The current version is `2017-10-13`. + * @param serviceName the service name to be used when configuring the client instance */ - public PersonalityInsights(String versionDate, String serviceName) { - this(versionDate, serviceName, ConfigBasedAuthenticatorFactory.getAuthenticator(serviceName)); + public PersonalityInsights(String version, String serviceName) { + this(version, serviceName, ConfigBasedAuthenticatorFactory.getAuthenticator(serviceName)); } /** - * Constructs a new `PersonalityInsights` client with the specified Authenticator and serviceName. + * Constructs an instance of the `PersonalityInsights` client. The specified service name and + * authenticator are used to configure the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value - * will keep your API calls from failing when the service introduces breaking changes. - * @param serviceName The name of the service to configure. - * @param authenticator the Authenticator instance to be configured for this service + * @param version Release date of the version of the API you want to use. Specify dates in + * YYYY-MM-DD format. The current version is `2017-10-13`. + * @param serviceName the service name to be used when configuring the client instance + * @param authenticator the {@link Authenticator} instance to be configured for this client */ - public PersonalityInsights(String versionDate, String serviceName, Authenticator authenticator) { + public PersonalityInsights(String version, String serviceName, Authenticator authenticator) { super(serviceName, authenticator); setServiceUrl(DEFAULT_SERVICE_URL); - com.ibm.cloud.sdk.core.util.Validator.isTrue( - (versionDate != null) && !versionDate.isEmpty(), "version cannot be null."); - this.versionDate = versionDate; + setVersion(version); this.configureService(serviceName); } + /** + * Gets the version. + * + *

Release date of the version of the API you want to use. Specify dates in YYYY-MM-DD format. + * The current version is `2017-10-13`. + * + * @return the version + */ + public String getVersion() { + return this.version; + } + + /** + * Sets the version. + * + * @param version the new version + */ + public void setVersion(final String version) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(version, "version cannot be empty."); + this.version = version; + } + /** * Get profile. * @@ -151,14 +179,12 @@ public PersonalityInsights(String versionDate, String serviceName, Authenticator * profile](https://cloud.ibm.com/docs/personality-insights?topic=personality-insights-outputCSV#outputCSV). * * @param profileOptions the {@link ProfileOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Profile} + * @return a {@link ServiceCall} with a result of type {@link Profile} */ public ServiceCall profile(ProfileOptions profileOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull(profileOptions, "profileOptions cannot be null"); - String[] pathSegments = {"v3/profile"}; RequestBuilder builder = - RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); + RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v3/profile")); Map sdkHeaders = SdkCommon.getSdkHeaders("personality_insights", "v3", "profile"); for (Entry header : sdkHeaders.entrySet()) { @@ -174,6 +200,7 @@ public ServiceCall profile(ProfileOptions profileOptions) { if (profileOptions.acceptLanguage() != null) { builder.header("Accept-Language", profileOptions.acceptLanguage()); } + builder.query("version", String.valueOf(this.version)); if (profileOptions.rawScores() != null) { builder.query("raw_scores", String.valueOf(profileOptions.rawScores())); } @@ -233,14 +260,12 @@ public ServiceCall profile(ProfileOptions profileOptions) { * profile](https://cloud.ibm.com/docs/personality-insights?topic=personality-insights-outputCSV#outputCSV). * * @param profileOptions the {@link ProfileOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link String} + * @return a {@link ServiceCall} with a result of type {@link String} */ public ServiceCall profileAsCsv(ProfileOptions profileOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull(profileOptions, "profileOptions cannot be null"); - String[] pathSegments = {"v3/profile"}; RequestBuilder builder = - RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); + RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v3/profile")); Map sdkHeaders = SdkCommon.getSdkHeaders("personality_insights", "v3", "profileAsCsv"); for (Entry header : sdkHeaders.entrySet()) { @@ -256,6 +281,7 @@ public ServiceCall profileAsCsv(ProfileOptions profileOptions) { if (profileOptions.acceptLanguage() != null) { builder.header("Accept-Language", profileOptions.acceptLanguage()); } + builder.query("version", String.valueOf(this.version)); if (profileOptions.rawScores() != null) { builder.query("raw_scores", String.valueOf(profileOptions.rawScores())); } diff --git a/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/Behavior.java b/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/Behavior.java index 3392a9fbea8..bf737ed727c 100644 --- a/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/Behavior.java +++ b/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/Behavior.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2016, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/ConsumptionPreferences.java b/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/ConsumptionPreferences.java index 1f63298e302..784566bf3aa 100644 --- a/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/ConsumptionPreferences.java +++ b/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/ConsumptionPreferences.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2016, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/ConsumptionPreferencesCategory.java b/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/ConsumptionPreferencesCategory.java index 1780127d91c..21ff488869c 100644 --- a/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/ConsumptionPreferencesCategory.java +++ b/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/ConsumptionPreferencesCategory.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/Content.java b/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/Content.java index 5e68a6ac551..e211d9950b8 100644 --- a/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/Content.java +++ b/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/Content.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2016, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -44,7 +44,7 @@ public Builder(List contentItems) { /** * Builds a Content. * - * @return the content + * @return the new Content instance */ public Content build() { return new Content(this); diff --git a/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/ContentItem.java b/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/ContentItem.java index 86548b6200f..8073b0c7314 100644 --- a/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/ContentItem.java +++ b/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/ContentItem.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2016, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -100,7 +100,7 @@ public Builder(String content) { /** * Builds a ContentItem. * - * @return the contentItem + * @return the new ContentItem instance */ public ContentItem build() { return new ContentItem(this); diff --git a/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/Profile.java b/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/Profile.java index 3ff6c919502..9f6a3b3035b 100644 --- a/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/Profile.java +++ b/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/Profile.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2016, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/ProfileOptions.java b/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/ProfileOptions.java index 8f91ba4a403..f70cb20f751 100644 --- a/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/ProfileOptions.java +++ b/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/ProfileOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2016, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -110,7 +110,7 @@ public Builder() {} /** * Builds a ProfileOptions. * - * @return the profileOptions + * @return the new ProfileOptions instance */ public ProfileOptions build() { return new ProfileOptions(this); diff --git a/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/Trait.java b/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/Trait.java index bfb44f57b64..ce889d84d78 100644 --- a/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/Trait.java +++ b/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/Trait.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2016, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/Warning.java b/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/Warning.java index d5faba6a9c9..5b2eb0fe463 100644 --- a/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/Warning.java +++ b/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/model/Warning.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/package-info.java b/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/package-info.java index e8e2e01e8e7..46874a8acad 100644 --- a/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/package-info.java +++ b/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/package-info.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/personality-insights/src/test/java/com/ibm/watson/personality_insights/v3/PersonalityInsightsTest.java b/personality-insights/src/test/java/com/ibm/watson/personality_insights/v3/PersonalityInsightsTest.java index 8bca6ade825..4fca9a6f28e 100644 --- a/personality-insights/src/test/java/com/ibm/watson/personality_insights/v3/PersonalityInsightsTest.java +++ b/personality-insights/src/test/java/com/ibm/watson/personality_insights/v3/PersonalityInsightsTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2016, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -12,208 +12,248 @@ */ package com.ibm.watson.personality_insights.v3; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; +import static org.testng.Assert.*; -import com.ibm.cloud.sdk.core.http.HttpHeaders; -import com.ibm.cloud.sdk.core.http.HttpMediaType; +import com.ibm.cloud.sdk.core.http.Response; +import com.ibm.cloud.sdk.core.security.Authenticator; import com.ibm.cloud.sdk.core.security.NoAuthAuthenticator; -import com.ibm.watson.common.WatsonServiceUnitTest; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; import com.ibm.watson.personality_insights.v3.model.Content; import com.ibm.watson.personality_insights.v3.model.ContentItem; import com.ibm.watson.personality_insights.v3.model.Profile; import com.ibm.watson.personality_insights.v3.model.ProfileOptions; -import java.io.FileNotFoundException; -import java.util.Date; -import java.util.UUID; +import com.ibm.watson.personality_insights.v3.utils.TestUtilities; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; import okhttp3.mockwebserver.RecordedRequest; -import org.junit.Before; -import org.junit.Test; - -/** PersonalityInsights Unit Test v3. */ -public class PersonalityInsightsTest extends WatsonServiceUnitTest { - - private static final String RESOURCE = "src/test/resources/personality_insights/"; - private static final String PROFILE_PATH = "/v3/profile"; - private static final String VERSION_DATE_2016_10_19 = "2017-10-13"; - private String text; - private PersonalityInsights service; - private Profile profile; - private ContentItem contentItem; - - /** - * Instantiates a new personality insights test. - * - * @throws FileNotFoundException the file not found exception - */ - public PersonalityInsightsTest() throws FileNotFoundException { - profile = loadFixture(RESOURCE + "profile.json", Profile.class); - text = "foo-bar-text"; - contentItem = new ContentItem.Builder().content(text).build(); - } +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; - /** - * Sets up the tests. - * - * @throws Exception the exception - */ - /* - * (non-Javadoc) - * @see com.ibm.watson.common.WatsonServiceUnitTest#setUp() - */ - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - service = new PersonalityInsights(VERSION_DATE_2016_10_19, new NoAuthAuthenticator()); - service.setServiceUrl(getMockWebServerUrl()); - } +/** Unit test class for the PersonalityInsights service. */ +public class PersonalityInsightsTest { - /** Negative - Test constructor with null version date. */ - @Test(expected = IllegalArgumentException.class) - public void testConstructorWithNullVersionDate() { - new PersonalityInsights(null, new NoAuthAuthenticator()); - } + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + protected MockWebServer server; + protected PersonalityInsights personalityInsightsService; + + public void constructClientService() throws Throwable { + final String serviceName = "testService"; + // set mock values for global params + String version = "testString"; + + final Authenticator authenticator = new NoAuthAuthenticator(); - /** Negative - Test constructor with empty version date. */ - @Test(expected = IllegalArgumentException.class) - public void testConstructorWithEmptyVersionDate() { - new PersonalityInsights("", new NoAuthAuthenticator()); + personalityInsightsService = new PersonalityInsights(version, serviceName, authenticator); + String url = server.url("/").toString(); + personalityInsightsService.setServiceUrl(url); } - /** - * Test get profile with content. - * - * @throws InterruptedException the interrupted exception - */ - @Test - public void testGetProfileWithContent() throws InterruptedException { - final Content content = new Content.Builder().addContentItem(contentItem).build(); - final ProfileOptions options = new ProfileOptions.Builder().content(content).build(); - - server.enqueue(jsonResponse(profile)); - final Profile profile = service.profile(options).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - - assertEquals(PROFILE_PATH + "?version=2017-10-13", request.getPath()); - assertEquals("POST", request.getMethod()); - assertNotNull(profile); - assertEquals(this.profile, profile); + /** Negative Test - construct the service with a null authenticator. */ + @Test(expectedExceptions = IllegalArgumentException.class) + public void testConstructorWithNullAuthenticator() throws Throwable { + final String serviceName = "testService"; + // set mock values for global params + String version = "testString"; + + new PersonalityInsights(version, serviceName, null); } - /** - * Test load a content from a file. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ @Test - public void testLoadAContentFromAFile() throws InterruptedException, FileNotFoundException { - final Content content = loadFixture(RESOURCE + "v3-contentItems.json", Content.class); - assertNotNull(content); + public void testGetVersion() throws Throwable { + constructClientService(); + assertEquals(personalityInsightsService.getVersion(), "testString"); } - /** Test content builders. */ @Test - public void testContentBuilders() { - final String content1 = - "Wow, I liked @TheRock before , now I really SEE how special he is. " - + "The daughter story was IT for me. So great! #MasterClass"; - final String content2 = "Wow aren't you loving @TheRock and his candor? #Masterclass"; - Long now = new Date().getTime(); - final ContentItem cItem1 = - new ContentItem.Builder(content1) - .language(ContentItem.Language.EN) + public void testProfileWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"processed_language\": \"ar\", \"word_count\": 9, \"word_count_message\": \"wordCountMessage\", \"personality\": [{\"trait_id\": \"traitId\", \"name\": \"name\", \"category\": \"personality\", \"percentile\": 10, \"raw_score\": 8, \"significant\": false}], \"needs\": [{\"trait_id\": \"traitId\", \"name\": \"name\", \"category\": \"personality\", \"percentile\": 10, \"raw_score\": 8, \"significant\": false}], \"values\": [{\"trait_id\": \"traitId\", \"name\": \"name\", \"category\": \"personality\", \"percentile\": 10, \"raw_score\": 8, \"significant\": false}], \"behavior\": [{\"trait_id\": \"traitId\", \"name\": \"name\", \"category\": \"category\", \"percentage\": 10}], \"consumption_preferences\": [{\"consumption_preference_category_id\": \"consumptionPreferenceCategoryId\", \"name\": \"name\", \"consumption_preferences\": [{\"consumption_preference_id\": \"consumptionPreferenceId\", \"name\": \"name\", \"score\": 0.0}]}], \"warnings\": [{\"warning_id\": \"WORD_COUNT_MESSAGE\", \"message\": \"message\"}]}"; + String profilePath = "/v3/profile"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the ContentItem model + ContentItem contentItemModel = + new ContentItem.Builder() + .content("testString") + .id("testString") + .created(Long.valueOf("26")) + .updated(Long.valueOf("26")) .contenttype("text/plain") - .created(now) - .updated(now) - .id(UUID.randomUUID().toString()) - .forward(false) - .reply(false) - .parentid(null) + .language("ar") + .parentid("testString") + .reply(true) + .forward(true) .build(); - ContentItem cItem2 = - cItem1.newBuilder().content(content2).id(UUID.randomUUID().toString()).build(); - assertEquals(cItem2.contenttype(), "text/plain"); - assertEquals(cItem2.created(), now); - assertEquals(cItem2.updated(), now); - assertNotEquals(cItem1.id(), cItem2.id()); - final Content content = - new Content.Builder().addContentItem(cItem1).addContentItem(cItem2).build(); - assertEquals(content.contentItems().size(), 2); - final Content newContent = content.newBuilder().build(); - assertEquals(newContent.contentItems().size(), 2); - } - /** - * Test get profile with English text. - * - * @throws InterruptedException the interrupted exception - */ - @Test - public void testGetProfileWithEnglishText() throws InterruptedException { - final ProfileOptions options = + // Construct an instance of the Content model + Content contentModel = + new Content.Builder() + .contentItems( + new java.util.ArrayList(java.util.Arrays.asList(contentItemModel))) + .build(); + + // Construct an instance of the ProfileOptions model + ProfileOptions profileOptionsModel = new ProfileOptions.Builder() - .text(text) - .contentLanguage(ProfileOptions.ContentLanguage.EN) + .content(contentModel) + .contentLanguage("ar") + .acceptLanguage("ar") + .rawScores(true) + .csvHeaders(true) + .consumptionPreferences(true) .build(); - server.enqueue(jsonResponse(profile)); - final Profile profile = service.profile(options).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - - assertEquals(PROFILE_PATH + "?version=2017-10-13", request.getPath()); - assertEquals("POST", request.getMethod()); - assertEquals("en", request.getHeader(HttpHeaders.CONTENT_LANGUAGE)); - assertEquals(HttpMediaType.TEXT_PLAIN, request.getHeader(HttpHeaders.CONTENT_TYPE)); - assertEquals(text, request.getBody().readUtf8()); - assertNotNull(profile); - assertEquals(this.profile, profile); + // Invoke operation with valid options model (positive test) + Response response = personalityInsightsService.profile(profileOptionsModel).execute(); + assertNotNull(response); + Profile responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("raw_scores")), Boolean.valueOf(true)); + assertEquals(Boolean.valueOf(query.get("csv_headers")), Boolean.valueOf(true)); + assertEquals(Boolean.valueOf(query.get("consumption_preferences")), Boolean.valueOf(true)); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, profilePath); + } + + // Test the profile operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testProfileNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + personalityInsightsService.profile(null).execute(); } - /** - * Test get profile with spanish text. - * - * @throws InterruptedException the interrupted exception - */ @Test - public void testGetProfileWithSpanishText() throws InterruptedException { - final ProfileOptions options = + public void testProfileAsCsvWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = "\"operationResponse\""; + String profileAsCsvPath = "/v3/profile"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "text/csv") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the ContentItem model + ContentItem contentItemModel = + new ContentItem.Builder() + .content("testString") + .id("testString") + .created(Long.valueOf("26")) + .updated(Long.valueOf("26")) + .contenttype("text/plain") + .language("ar") + .parentid("testString") + .reply(true) + .forward(true) + .build(); + + // Construct an instance of the Content model + Content contentModel = + new Content.Builder() + .contentItems( + new java.util.ArrayList(java.util.Arrays.asList(contentItemModel))) + .build(); + + // Construct an instance of the ProfileOptions model + ProfileOptions profileOptionsModel = new ProfileOptions.Builder() - .text(text) - .contentLanguage(ProfileOptions.ContentLanguage.ES) - .consumptionPreferences(true) + .content(contentModel) + .contentLanguage("ar") + .acceptLanguage("ar") .rawScores(true) + .csvHeaders(true) + .consumptionPreferences(true) .build(); - server.enqueue(jsonResponse(profile)); - final Profile profile = service.profile(options).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - - assertEquals( - PROFILE_PATH + "?version=2017-10-13&raw_scores=true&consumption_preferences=true", - request.getPath()); - assertEquals("POST", request.getMethod()); - assertEquals("es", request.getHeader(HttpHeaders.CONTENT_LANGUAGE)); - assertEquals(HttpMediaType.TEXT_PLAIN, request.getHeader(HttpHeaders.CONTENT_TYPE)); - assertEquals(text, request.getBody().readUtf8()); - assertNotNull(profile); - assertEquals(profile, this.profile); + // Invoke operation with valid options model (positive test) + Response response = + personalityInsightsService.profileAsCsv(profileOptionsModel).execute(); + assertNotNull(response); + InputStream responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("raw_scores")), Boolean.valueOf(true)); + assertEquals(Boolean.valueOf(query.get("csv_headers")), Boolean.valueOf(true)); + assertEquals(Boolean.valueOf(query.get("consumption_preferences")), Boolean.valueOf(true)); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, profileAsCsvPath); } - /** Test profile options builders. */ - @Test - public void testProfileBuilders() { - final ProfileOptions options = - new ProfileOptions.Builder() - .html(text) - .contentLanguage(ProfileOptions.ContentLanguage.ES) - .acceptLanguage(ProfileOptions.AcceptLanguage.EN) - .build(); - final ProfileOptions newOptions = options.newBuilder().build(); - assertEquals(newOptions.body(), text); - assertEquals(newOptions.contentLanguage(), ProfileOptions.ContentLanguage.ES); - assertEquals(newOptions.acceptLanguage(), ProfileOptions.AcceptLanguage.EN); + // Test the profileAsCsv operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testProfileAsCsvNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + personalityInsightsService.profileAsCsv(null).execute(); + } + + /** Initialize the server */ + @BeforeMethod + public void setUpMockServer() { + try { + server = new MockWebServer(); + // register handler + server.start(); + } catch (IOException err) { + fail("Failed to instantiate mock web server"); + } + } + + @AfterMethod + public void tearDownMockServer() throws IOException { + server.shutdown(); + personalityInsightsService = null; } } diff --git a/personality-insights/src/test/java/com/ibm/watson/personality_insights/v3/model/BehaviorTest.java b/personality-insights/src/test/java/com/ibm/watson/personality_insights/v3/model/BehaviorTest.java new file mode 100644 index 00000000000..1495904a9b9 --- /dev/null +++ b/personality-insights/src/test/java/com/ibm/watson/personality_insights/v3/model/BehaviorTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.personality_insights.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.personality_insights.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Behavior model. */ +public class BehaviorTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testBehavior() throws Throwable { + Behavior behaviorModel = new Behavior(); + assertNull(behaviorModel.getTraitId()); + assertNull(behaviorModel.getName()); + assertNull(behaviorModel.getCategory()); + assertNull(behaviorModel.getPercentage()); + } +} diff --git a/personality-insights/src/test/java/com/ibm/watson/personality_insights/v3/model/ConsumptionPreferencesCategoryTest.java b/personality-insights/src/test/java/com/ibm/watson/personality_insights/v3/model/ConsumptionPreferencesCategoryTest.java new file mode 100644 index 00000000000..37f7dafd21e --- /dev/null +++ b/personality-insights/src/test/java/com/ibm/watson/personality_insights/v3/model/ConsumptionPreferencesCategoryTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.personality_insights.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.personality_insights.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ConsumptionPreferencesCategory model. */ +public class ConsumptionPreferencesCategoryTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testConsumptionPreferencesCategory() throws Throwable { + ConsumptionPreferencesCategory consumptionPreferencesCategoryModel = + new ConsumptionPreferencesCategory(); + assertNull(consumptionPreferencesCategoryModel.getConsumptionPreferenceCategoryId()); + assertNull(consumptionPreferencesCategoryModel.getName()); + assertNull(consumptionPreferencesCategoryModel.getConsumptionPreferences()); + } +} diff --git a/personality-insights/src/test/java/com/ibm/watson/personality_insights/v3/model/ConsumptionPreferencesTest.java b/personality-insights/src/test/java/com/ibm/watson/personality_insights/v3/model/ConsumptionPreferencesTest.java new file mode 100644 index 00000000000..d2d6de4ef7a --- /dev/null +++ b/personality-insights/src/test/java/com/ibm/watson/personality_insights/v3/model/ConsumptionPreferencesTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.personality_insights.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.personality_insights.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ConsumptionPreferences model. */ +public class ConsumptionPreferencesTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testConsumptionPreferences() throws Throwable { + ConsumptionPreferences consumptionPreferencesModel = new ConsumptionPreferences(); + assertNull(consumptionPreferencesModel.getConsumptionPreferenceId()); + assertNull(consumptionPreferencesModel.getName()); + assertNull(consumptionPreferencesModel.getScore()); + } +} diff --git a/personality-insights/src/test/java/com/ibm/watson/personality_insights/v3/model/ContentItemTest.java b/personality-insights/src/test/java/com/ibm/watson/personality_insights/v3/model/ContentItemTest.java new file mode 100644 index 00000000000..26ceae10094 --- /dev/null +++ b/personality-insights/src/test/java/com/ibm/watson/personality_insights/v3/model/ContentItemTest.java @@ -0,0 +1,74 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.personality_insights.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.personality_insights.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ContentItem model. */ +public class ContentItemTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testContentItem() throws Throwable { + ContentItem contentItemModel = + new ContentItem.Builder() + .content("testString") + .id("testString") + .created(Long.valueOf("26")) + .updated(Long.valueOf("26")) + .contenttype("text/plain") + .language("ar") + .parentid("testString") + .reply(true) + .forward(true) + .build(); + assertEquals(contentItemModel.content(), "testString"); + assertEquals(contentItemModel.id(), "testString"); + assertEquals(contentItemModel.created(), Long.valueOf("26")); + assertEquals(contentItemModel.updated(), Long.valueOf("26")); + assertEquals(contentItemModel.contenttype(), "text/plain"); + assertEquals(contentItemModel.language(), "ar"); + assertEquals(contentItemModel.parentid(), "testString"); + assertEquals(contentItemModel.reply(), Boolean.valueOf(true)); + assertEquals(contentItemModel.forward(), Boolean.valueOf(true)); + + String json = TestUtilities.serialize(contentItemModel); + + ContentItem contentItemModelNew = TestUtilities.deserialize(json, ContentItem.class); + assertTrue(contentItemModelNew instanceof ContentItem); + assertEquals(contentItemModelNew.content(), "testString"); + assertEquals(contentItemModelNew.id(), "testString"); + assertEquals(contentItemModelNew.created(), Long.valueOf("26")); + assertEquals(contentItemModelNew.updated(), Long.valueOf("26")); + assertEquals(contentItemModelNew.contenttype(), "text/plain"); + assertEquals(contentItemModelNew.language(), "ar"); + assertEquals(contentItemModelNew.parentid(), "testString"); + assertEquals(contentItemModelNew.reply(), Boolean.valueOf(true)); + assertEquals(contentItemModelNew.forward(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testContentItemError() throws Throwable { + new ContentItem.Builder().build(); + } +} diff --git a/personality-insights/src/test/java/com/ibm/watson/personality_insights/v3/model/ContentTest.java b/personality-insights/src/test/java/com/ibm/watson/personality_insights/v3/model/ContentTest.java new file mode 100644 index 00000000000..e1f581e1409 --- /dev/null +++ b/personality-insights/src/test/java/com/ibm/watson/personality_insights/v3/model/ContentTest.java @@ -0,0 +1,74 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.personality_insights.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.personality_insights.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Content model. */ +public class ContentTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testContent() throws Throwable { + ContentItem contentItemModel = + new ContentItem.Builder() + .content("testString") + .id("testString") + .created(Long.valueOf("26")) + .updated(Long.valueOf("26")) + .contenttype("text/plain") + .language("ar") + .parentid("testString") + .reply(true) + .forward(true) + .build(); + assertEquals(contentItemModel.content(), "testString"); + assertEquals(contentItemModel.id(), "testString"); + assertEquals(contentItemModel.created(), Long.valueOf("26")); + assertEquals(contentItemModel.updated(), Long.valueOf("26")); + assertEquals(contentItemModel.contenttype(), "text/plain"); + assertEquals(contentItemModel.language(), "ar"); + assertEquals(contentItemModel.parentid(), "testString"); + assertEquals(contentItemModel.reply(), Boolean.valueOf(true)); + assertEquals(contentItemModel.forward(), Boolean.valueOf(true)); + + Content contentModel = + new Content.Builder() + .contentItems( + new java.util.ArrayList(java.util.Arrays.asList(contentItemModel))) + .build(); + assertEquals( + contentModel.contentItems(), + new java.util.ArrayList(java.util.Arrays.asList(contentItemModel))); + + String json = TestUtilities.serialize(contentModel); + + Content contentModelNew = TestUtilities.deserialize(json, Content.class); + assertTrue(contentModelNew instanceof Content); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testContentError() throws Throwable { + new Content.Builder().build(); + } +} diff --git a/personality-insights/src/test/java/com/ibm/watson/personality_insights/v3/model/ProfileOptionsTest.java b/personality-insights/src/test/java/com/ibm/watson/personality_insights/v3/model/ProfileOptionsTest.java new file mode 100644 index 00000000000..449af10e21c --- /dev/null +++ b/personality-insights/src/test/java/com/ibm/watson/personality_insights/v3/model/ProfileOptionsTest.java @@ -0,0 +1,80 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.personality_insights.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.personality_insights.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ProfileOptions model. */ +public class ProfileOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testProfileOptions() throws Throwable { + ContentItem contentItemModel = + new ContentItem.Builder() + .content("testString") + .id("testString") + .created(Long.valueOf("26")) + .updated(Long.valueOf("26")) + .contenttype("text/plain") + .language("ar") + .parentid("testString") + .reply(true) + .forward(true) + .build(); + assertEquals(contentItemModel.content(), "testString"); + assertEquals(contentItemModel.id(), "testString"); + assertEquals(contentItemModel.created(), Long.valueOf("26")); + assertEquals(contentItemModel.updated(), Long.valueOf("26")); + assertEquals(contentItemModel.contenttype(), "text/plain"); + assertEquals(contentItemModel.language(), "ar"); + assertEquals(contentItemModel.parentid(), "testString"); + assertEquals(contentItemModel.reply(), Boolean.valueOf(true)); + assertEquals(contentItemModel.forward(), Boolean.valueOf(true)); + + Content contentModel = + new Content.Builder() + .contentItems( + new java.util.ArrayList(java.util.Arrays.asList(contentItemModel))) + .build(); + assertEquals( + contentModel.contentItems(), + new java.util.ArrayList(java.util.Arrays.asList(contentItemModel))); + + ProfileOptions profileOptionsModel = + new ProfileOptions.Builder() + .content(contentModel) + .contentLanguage("ar") + .acceptLanguage("ar") + .rawScores(true) + .csvHeaders(true) + .consumptionPreferences(true) + .build(); + assertEquals(profileOptionsModel.content(), contentModel); + assertEquals(profileOptionsModel.contentLanguage(), "ar"); + assertEquals(profileOptionsModel.acceptLanguage(), "ar"); + assertEquals(profileOptionsModel.rawScores(), Boolean.valueOf(true)); + assertEquals(profileOptionsModel.csvHeaders(), Boolean.valueOf(true)); + assertEquals(profileOptionsModel.consumptionPreferences(), Boolean.valueOf(true)); + } +} diff --git a/personality-insights/src/test/java/com/ibm/watson/personality_insights/v3/model/ProfileTest.java b/personality-insights/src/test/java/com/ibm/watson/personality_insights/v3/model/ProfileTest.java new file mode 100644 index 00000000000..b7c47a960b1 --- /dev/null +++ b/personality-insights/src/test/java/com/ibm/watson/personality_insights/v3/model/ProfileTest.java @@ -0,0 +1,44 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.personality_insights.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.personality_insights.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Profile model. */ +public class ProfileTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testProfile() throws Throwable { + Profile profileModel = new Profile(); + assertNull(profileModel.getProcessedLanguage()); + assertNull(profileModel.getWordCount()); + assertNull(profileModel.getWordCountMessage()); + assertNull(profileModel.getPersonality()); + assertNull(profileModel.getNeeds()); + assertNull(profileModel.getValues()); + assertNull(profileModel.getBehavior()); + assertNull(profileModel.getConsumptionPreferences()); + assertNull(profileModel.getWarnings()); + } +} diff --git a/personality-insights/src/test/java/com/ibm/watson/personality_insights/v3/model/TraitTest.java b/personality-insights/src/test/java/com/ibm/watson/personality_insights/v3/model/TraitTest.java new file mode 100644 index 00000000000..cf31bcd3ad7 --- /dev/null +++ b/personality-insights/src/test/java/com/ibm/watson/personality_insights/v3/model/TraitTest.java @@ -0,0 +1,41 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.personality_insights.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.personality_insights.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Trait model. */ +public class TraitTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTrait() throws Throwable { + Trait traitModel = new Trait(); + assertNull(traitModel.getTraitId()); + assertNull(traitModel.getName()); + assertNull(traitModel.getCategory()); + assertNull(traitModel.getPercentile()); + assertNull(traitModel.getRawScore()); + assertNull(traitModel.isSignificant()); + } +} diff --git a/personality-insights/src/test/java/com/ibm/watson/personality_insights/v3/model/WarningTest.java b/personality-insights/src/test/java/com/ibm/watson/personality_insights/v3/model/WarningTest.java new file mode 100644 index 00000000000..778c156e0d9 --- /dev/null +++ b/personality-insights/src/test/java/com/ibm/watson/personality_insights/v3/model/WarningTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.personality_insights.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.personality_insights.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Warning model. */ +public class WarningTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testWarning() throws Throwable { + Warning warningModel = new Warning(); + assertNull(warningModel.getWarningId()); + assertNull(warningModel.getMessage()); + } +} diff --git a/personality-insights/src/test/java/com/ibm/watson/personality_insights/v3/utils/TestUtilities.java b/personality-insights/src/test/java/com/ibm/watson/personality_insights/v3/utils/TestUtilities.java new file mode 100644 index 00000000000..11f74b2adf3 --- /dev/null +++ b/personality-insights/src/test/java/com/ibm/watson/personality_insights/v3/utils/TestUtilities.java @@ -0,0 +1,128 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.personality_insights.v3.utils; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.cloud.sdk.core.util.GsonSingleton; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import okhttp3.HttpUrl; +import okhttp3.mockwebserver.RecordedRequest; + +/** A class used by the unit tests containing utility functions. */ +public class TestUtilities { + public static Map createMockMap() { + Map mockMap = new HashMap<>(); + mockMap.put("foo", "bar"); + return mockMap; + } + + public static HashMap createMockStreamMap() { + return new HashMap() { + { + put("key1", createMockStream("This is a mock file.")); + } + }; + } + + public static Map parseQueryString(RecordedRequest req) { + Map queryMap = new HashMap<>(); + + try { + HttpUrl requestUrl = req.getRequestUrl(); + + if (requestUrl != null) { + Set queryParamsNames = requestUrl.queryParameterNames(); + // map the parameter name to its corresponding value + for (String p : queryParamsNames) { + // get the corresponding value for the parameter (p) + List val = requestUrl.queryParameterValues(p); + if (val != null && !val.isEmpty()) { + String joinedQuery = String.join(",", val); + queryMap.put(p, joinedQuery); + } + } + } + if (queryMap.isEmpty()) { + return null; + } + } catch (Exception e) { + return null; + } + + return queryMap; + } + + public static String parseReqPath(RecordedRequest req) { + String parsedPath = null; + + try { + String fullPath = req.getPath(); + if (fullPath != null && !fullPath.isEmpty()) { + // retrieve the path segment before the query parameter + parsedPath = fullPath.split("\\?", 2)[0]; + } + if (parsedPath.isEmpty() || parsedPath == null) { + return null; + } + + } catch (Exception e) { + return null; + } + + return parsedPath; + } + + public static String serialize(Object obj) { + return GsonSingleton.getGson().toJson(obj); + } + + public static T deserialize(String json, Class clazz) { + return GsonSingleton.getGson().fromJson(json, clazz); + } + + public static InputStream createMockStream(String s) { + return new ByteArrayInputStream(s.getBytes()); + } + + public static List creatMockListFileWithMetadata() { + List list = new ArrayList(); + byte[] fileBytes = {(byte) 0xde, (byte) 0xad, (byte) 0xbe, (byte) 0xef}; + InputStream inputStream = new ByteArrayInputStream(fileBytes); + FileWithMetadata.Builder builder = new FileWithMetadata.Builder(); + builder.data(inputStream); + FileWithMetadata fileWithMetadata = builder.build(); + list.add(fileWithMetadata); + + return list; + } + + public static byte[] createMockByteArray(String bytes) { + return bytes.getBytes(); + } + + public static Date createMockDate(String date) throws Exception { + return new SimpleDateFormat("yyyy-MM-dd").parse(date); + } + + public static Date createMockDateTime(String date) throws Exception { + return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").parse(date); + } +} diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/SpeechToText.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/SpeechToText.java index 9c8c9f52788..d7778f9d1ad 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/SpeechToText.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/SpeechToText.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2016, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -10,6 +10,11 @@ * 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. */ + +/* + * IBM OpenAPI SDK Code Generator Version: 99-SNAPSHOT-7cc05500-20201106-154555 + */ + package com.ibm.watson.speech_to_text.v1; import com.google.gson.JsonObject; @@ -82,14 +87,13 @@ import com.ibm.watson.speech_to_text.v1.model.UpgradeLanguageModelOptions; import com.ibm.watson.speech_to_text.v1.model.Word; import com.ibm.watson.speech_to_text.v1.model.Words; -import com.ibm.watson.speech_to_text.v1.websocket.RecognizeCallback; -import com.ibm.watson.speech_to_text.v1.websocket.SpeechToTextWebSocketListener; +import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; -import okhttp3.*; +import okhttp3.MultipartBody; /** - * The IBM Watson™ Speech to Text service provides APIs that use IBM's speech-recognition + * The IBM Watson&trade; Speech to Text service provides APIs that use IBM's speech-recognition * capabilities to produce transcripts of spoken audio. The service can transcribe speech from * various languages and audio formats. In addition to basic transcription, the service can produce * detailed information about many different aspects of the audio. For most languages, the service @@ -112,16 +116,19 @@ * functionality for all language models that support language model customization. * * @version v1 - * @see Speech to Text + * @see Speech to Text */ public class SpeechToText extends BaseService { - private static final String DEFAULT_SERVICE_NAME = "speech_to_text"; + public static final String DEFAULT_SERVICE_NAME = "speech_to_text"; - private static final String DEFAULT_SERVICE_URL = + public static final String DEFAULT_SERVICE_URL = "https://api.us-south.speech-to-text.watson.cloud.ibm.com"; - /** Constructs a new `SpeechToText` client using the DEFAULT_SERVICE_NAME. */ + /** + * Constructs an instance of the `SpeechToText` client. The default service name is used to + * configure the client instance. + */ public SpeechToText() { this( DEFAULT_SERVICE_NAME, @@ -129,29 +136,31 @@ public SpeechToText() { } /** - * Constructs a new `SpeechToText` client with the DEFAULT_SERVICE_NAME and the specified - * Authenticator. + * Constructs an instance of the `SpeechToText` client. The default service name and specified + * authenticator are used to configure the client instance. * - * @param authenticator the Authenticator instance to be configured for this service + * @param authenticator the {@link Authenticator} instance to be configured for this client */ public SpeechToText(Authenticator authenticator) { this(DEFAULT_SERVICE_NAME, authenticator); } /** - * Constructs a new `SpeechToText` client with the specified serviceName. + * Constructs an instance of the `SpeechToText` client. The specified service name is used to + * configure the client instance. * - * @param serviceName The name of the service to configure. + * @param serviceName the service name to be used when configuring the client instance */ public SpeechToText(String serviceName) { this(serviceName, ConfigBasedAuthenticatorFactory.getAuthenticator(serviceName)); } /** - * Constructs a new `SpeechToText` client with the specified Authenticator and serviceName. + * Constructs an instance of the `SpeechToText` client. The specified service name and + * authenticator are used to configure the client instance. * - * @param serviceName The name of the service to configure. - * @param authenticator the Authenticator instance to be configured for this service + * @param serviceName the service name to be used when configuring the client instance + * @param authenticator the {@link Authenticator} instance to be configured for this client */ public SpeechToText(String serviceName, Authenticator authenticator) { super(serviceName, authenticator); @@ -171,19 +180,16 @@ public SpeechToText(String serviceName, Authenticator authenticator) { * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models#models). * * @param listModelsOptions the {@link ListModelsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link SpeechModels} + * @return a {@link ServiceCall} with a result of type {@link SpeechModels} */ public ServiceCall listModels(ListModelsOptions listModelsOptions) { - String[] pathSegments = {"v1/models"}; RequestBuilder builder = - RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); + RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/models")); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "listModels"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - if (listModelsOptions != null) {} - ResponseConverter responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken() {}.getType()); @@ -201,7 +207,7 @@ public ServiceCall listModels(ListModelsOptions listModelsOptions) *

**See also:** [Languages and * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models#models). * - * @return a {@link ServiceCall} with a response type of {@link SpeechModels} + * @return a {@link ServiceCall} with a result of type {@link SpeechModels} */ public ServiceCall listModels() { return listModels(null); @@ -218,22 +224,22 @@ public ServiceCall listModels() { * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-models#models). * * @param getModelOptions the {@link GetModelOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link SpeechModel} + * @return a {@link ServiceCall} with a result of type {@link SpeechModel} */ public ServiceCall getModel(GetModelOptions getModelOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( getModelOptions, "getModelOptions cannot be null"); - String[] pathSegments = {"v1/models"}; - String[] pathParameters = {getModelOptions.modelId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("model_id", getModelOptions.modelId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/models/{model_id}", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "getModel"); 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()); @@ -315,14 +321,13 @@ public ServiceCall getModel(GetModelOptions getModelOptions) { * request](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-http#HTTP-multi). * * @param recognizeOptions the {@link RecognizeOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link SpeechRecognitionResults} + * @return a {@link ServiceCall} with a result of type {@link SpeechRecognitionResults} */ public ServiceCall recognize(RecognizeOptions recognizeOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( recognizeOptions, "recognizeOptions cannot be null"); - String[] pathSegments = {"v1/recognize"}; RequestBuilder builder = - RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); + RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/recognize")); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "recognize"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); @@ -332,16 +337,18 @@ public ServiceCall recognize(RecognizeOptions recogniz builder.header("Content-Type", recognizeOptions.contentType()); } if (recognizeOptions.model() != null) { - builder.query("model", recognizeOptions.model()); + builder.query("model", String.valueOf(recognizeOptions.model())); } if (recognizeOptions.languageCustomizationId() != null) { - builder.query("language_customization_id", recognizeOptions.languageCustomizationId()); + builder.query( + "language_customization_id", String.valueOf(recognizeOptions.languageCustomizationId())); } if (recognizeOptions.acousticCustomizationId() != null) { - builder.query("acoustic_customization_id", recognizeOptions.acousticCustomizationId()); + builder.query( + "acoustic_customization_id", String.valueOf(recognizeOptions.acousticCustomizationId())); } if (recognizeOptions.baseModelVersion() != null) { - builder.query("base_model_version", recognizeOptions.baseModelVersion()); + builder.query("base_model_version", String.valueOf(recognizeOptions.baseModelVersion())); } if (recognizeOptions.customizationWeight() != null) { builder.query("customization_weight", String.valueOf(recognizeOptions.customizationWeight())); @@ -379,10 +386,10 @@ public ServiceCall recognize(RecognizeOptions recogniz builder.query("speaker_labels", String.valueOf(recognizeOptions.speakerLabels())); } if (recognizeOptions.customizationId() != null) { - builder.query("customization_id", recognizeOptions.customizationId()); + builder.query("customization_id", String.valueOf(recognizeOptions.customizationId())); } if (recognizeOptions.grammarName() != null) { - builder.query("grammar_name", recognizeOptions.grammarName()); + builder.query("grammar_name", String.valueOf(recognizeOptions.grammarName())); } if (recognizeOptions.redaction() != null) { builder.query("redaction", String.valueOf(recognizeOptions.redaction())); @@ -416,61 +423,6 @@ public ServiceCall recognize(RecognizeOptions recogniz return createServiceCall(builder.build(), responseConverter); } - /** - * Sends audio and returns transcription results for recognition requests over a WebSocket - * connection. Requests and responses are enabled over a single TCP connection that abstracts much - * of the complexity of the request to offer efficient implementation, low latency, high - * throughput, and an asynchronous response. By default, only final results are returned for any - * request; to enable interim results, set the interimResults parameter to true. - * - *

The service imposes a data size limit of 100 MB per utterance (per recognition request). You - * can send multiple utterances over a single WebSocket connection. The service automatically - * detects the endianness of the incoming audio and, for audio that includes multiple channels, - * downmixes the audio to one-channel mono during transcoding. (For the audio/l16 format, you can - * specify the endianness.) - * - * @param recognizeOptions the recognize options - * @param callback the {@link RecognizeCallback} instance where results will be sent - * @return the {@link WebSocket} - */ - public WebSocket recognizeUsingWebSocket( - RecognizeOptions recognizeOptions, RecognizeCallback callback) { - com.ibm.cloud.sdk.core.util.Validator.notNull( - recognizeOptions, "recognizeOptions cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(recognizeOptions.audio(), "audio cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(callback, "callback cannot be null"); - - HttpUrl.Builder urlBuilder = HttpUrl.parse(getServiceUrl() + "/v1/recognize").newBuilder(); - - if (recognizeOptions.model() != null) { - urlBuilder.addQueryParameter("model", recognizeOptions.model()); - } - if (recognizeOptions.customizationId() != null) { - urlBuilder.addQueryParameter("customization_id", recognizeOptions.customizationId()); - } - if (recognizeOptions.languageCustomizationId() != null) { - urlBuilder.addQueryParameter( - "language_customization_id", recognizeOptions.languageCustomizationId()); - } - if (recognizeOptions.acousticCustomizationId() != null) { - urlBuilder.addQueryParameter( - "acoustic_customization_id", recognizeOptions.acousticCustomizationId()); - } - if (recognizeOptions.baseModelVersion() != null) { - urlBuilder.addQueryParameter("base_model_version", recognizeOptions.baseModelVersion()); - } - - String url = urlBuilder.toString().replace("https://", "wss://"); - Request.Builder builder = new Request.Builder().url(url); - - setAuthentication(builder); - setDefaultHeaders(builder); - - OkHttpClient client = configureHttpClient(); - return client.newWebSocket( - builder.build(), new SpeechToTextWebSocketListener(recognizeOptions, callback)); - } - /** * Register a callback. * @@ -508,24 +460,24 @@ public WebSocket recognizeUsingWebSocket( * * @param registerCallbackOptions the {@link RegisterCallbackOptions} containing the options for * the call - * @return a {@link ServiceCall} with a response type of {@link RegisterStatus} + * @return a {@link ServiceCall} with a result of type {@link RegisterStatus} */ public ServiceCall registerCallback( RegisterCallbackOptions registerCallbackOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( registerCallbackOptions, "registerCallbackOptions cannot be null"); - String[] pathSegments = {"v1/register_callback"}; RequestBuilder builder = - RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); + RequestBuilder.post( + RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/register_callback")); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "registerCallback"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - builder.query("callback_url", registerCallbackOptions.callbackUrl()); + builder.query("callback_url", String.valueOf(registerCallbackOptions.callbackUrl())); if (registerCallbackOptions.userSecret() != null) { - builder.query("user_secret", registerCallbackOptions.userSecret()); + builder.query("user_secret", String.valueOf(registerCallbackOptions.userSecret())); } ResponseConverter responseConverter = ResponseConverterUtils.getValue( @@ -545,20 +497,20 @@ public ServiceCall registerCallback( * * @param unregisterCallbackOptions the {@link UnregisterCallbackOptions} containing the options * for the call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall unregisterCallback(UnregisterCallbackOptions unregisterCallbackOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( unregisterCallbackOptions, "unregisterCallbackOptions cannot be null"); - String[] pathSegments = {"v1/unregister_callback"}; RequestBuilder builder = - RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); + RequestBuilder.post( + RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/unregister_callback")); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "unregisterCallback"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } - builder.query("callback_url", unregisterCallbackOptions.callbackUrl()); + builder.query("callback_url", String.valueOf(unregisterCallbackOptions.callbackUrl())); ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -641,14 +593,13 @@ public ServiceCall unregisterCallback(UnregisterCallbackOptions unregister * formats](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-audio-formats#audio-formats). * * @param createJobOptions the {@link CreateJobOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link RecognitionJob} + * @return a {@link ServiceCall} with a result of type {@link RecognitionJob} */ public ServiceCall createJob(CreateJobOptions createJobOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( createJobOptions, "createJobOptions cannot be null"); - String[] pathSegments = {"v1/recognitions"}; RequestBuilder builder = - RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); + RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/recognitions")); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "createJob"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); @@ -658,28 +609,30 @@ public ServiceCall createJob(CreateJobOptions createJobOptions) builder.header("Content-Type", createJobOptions.contentType()); } if (createJobOptions.model() != null) { - builder.query("model", createJobOptions.model()); + builder.query("model", String.valueOf(createJobOptions.model())); } if (createJobOptions.callbackUrl() != null) { - builder.query("callback_url", createJobOptions.callbackUrl()); + builder.query("callback_url", String.valueOf(createJobOptions.callbackUrl())); } if (createJobOptions.events() != null) { - builder.query("events", createJobOptions.events()); + builder.query("events", String.valueOf(createJobOptions.events())); } if (createJobOptions.userToken() != null) { - builder.query("user_token", createJobOptions.userToken()); + builder.query("user_token", String.valueOf(createJobOptions.userToken())); } if (createJobOptions.resultsTtl() != null) { builder.query("results_ttl", String.valueOf(createJobOptions.resultsTtl())); } if (createJobOptions.languageCustomizationId() != null) { - builder.query("language_customization_id", createJobOptions.languageCustomizationId()); + builder.query( + "language_customization_id", String.valueOf(createJobOptions.languageCustomizationId())); } if (createJobOptions.acousticCustomizationId() != null) { - builder.query("acoustic_customization_id", createJobOptions.acousticCustomizationId()); + builder.query( + "acoustic_customization_id", String.valueOf(createJobOptions.acousticCustomizationId())); } if (createJobOptions.baseModelVersion() != null) { - builder.query("base_model_version", createJobOptions.baseModelVersion()); + builder.query("base_model_version", String.valueOf(createJobOptions.baseModelVersion())); } if (createJobOptions.customizationWeight() != null) { builder.query("customization_weight", String.valueOf(createJobOptions.customizationWeight())); @@ -717,10 +670,10 @@ public ServiceCall createJob(CreateJobOptions createJobOptions) builder.query("speaker_labels", String.valueOf(createJobOptions.speakerLabels())); } if (createJobOptions.customizationId() != null) { - builder.query("customization_id", createJobOptions.customizationId()); + builder.query("customization_id", String.valueOf(createJobOptions.customizationId())); } if (createJobOptions.grammarName() != null) { - builder.query("grammar_name", createJobOptions.grammarName()); + builder.query("grammar_name", String.valueOf(createJobOptions.grammarName())); } if (createJobOptions.redaction() != null) { builder.query("redaction", String.valueOf(createJobOptions.redaction())); @@ -777,19 +730,16 @@ public ServiceCall createJob(CreateJobOptions createJobOptions) * jobs](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-async#jobs). * * @param checkJobsOptions the {@link CheckJobsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link RecognitionJobs} + * @return a {@link ServiceCall} with a result of type {@link RecognitionJobs} */ public ServiceCall checkJobs(CheckJobsOptions checkJobsOptions) { - String[] pathSegments = {"v1/recognitions"}; RequestBuilder builder = - RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); + RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/recognitions")); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "checkJobs"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - if (checkJobsOptions != null) {} - ResponseConverter responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken() {}.getType()); @@ -810,7 +760,7 @@ public ServiceCall checkJobs(CheckJobsOptions checkJobsOptions) *

**See also:** [Checking the status of the latest * jobs](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-async#jobs). * - * @return a {@link ServiceCall} with a response type of {@link RecognitionJobs} + * @return a {@link ServiceCall} with a result of type {@link RecognitionJobs} */ public ServiceCall checkJobs() { return checkJobs(null); @@ -834,22 +784,22 @@ public ServiceCall checkJobs() { * job](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-async#job). * * @param checkJobOptions the {@link CheckJobOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link RecognitionJob} + * @return a {@link ServiceCall} with a result of type {@link RecognitionJob} */ public ServiceCall checkJob(CheckJobOptions checkJobOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( checkJobOptions, "checkJobOptions cannot be null"); - String[] pathSegments = {"v1/recognitions"}; - String[] pathParameters = {checkJobOptions.id()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("id", checkJobOptions.id()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/recognitions/{id}", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "checkJob"); 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()); @@ -868,21 +818,21 @@ public ServiceCall checkJob(CheckJobOptions checkJobOptions) { * job](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-async#delete-async). * * @param deleteJobOptions the {@link DeleteJobOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteJob(DeleteJobOptions deleteJobOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( deleteJobOptions, "deleteJobOptions cannot be null"); - String[] pathSegments = {"v1/recognitions"}; - String[] pathParameters = {deleteJobOptions.id()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("id", deleteJobOptions.id()); RequestBuilder builder = RequestBuilder.delete( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/recognitions/{id}", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "deleteJob"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } - ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -903,15 +853,15 @@ public ServiceCall deleteJob(DeleteJobOptions deleteJobOptions) { * * @param createLanguageModelOptions the {@link CreateLanguageModelOptions} containing the options * for the call - * @return a {@link ServiceCall} with a response type of {@link LanguageModel} + * @return a {@link ServiceCall} with a result of type {@link LanguageModel} */ public ServiceCall createLanguageModel( CreateLanguageModelOptions createLanguageModelOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( createLanguageModelOptions, "createLanguageModelOptions cannot be null"); - String[] pathSegments = {"v1/customizations"}; RequestBuilder builder = - RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); + RequestBuilder.post( + RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/customizations")); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "createLanguageModel"); for (Entry header : sdkHeaders.entrySet()) { @@ -947,23 +897,23 @@ public ServiceCall createLanguageModel( * * @param listLanguageModelsOptions the {@link ListLanguageModelsOptions} containing the options * for the call - * @return a {@link ServiceCall} with a response type of {@link LanguageModels} + * @return a {@link ServiceCall} with a result of type {@link LanguageModels} */ public ServiceCall listLanguageModels( ListLanguageModelsOptions listLanguageModelsOptions) { - String[] pathSegments = {"v1/customizations"}; + if (listLanguageModelsOptions == null) { + listLanguageModelsOptions = new ListLanguageModelsOptions.Builder().build(); + } RequestBuilder builder = - RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); + RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/customizations")); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "listLanguageModels"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - if (listLanguageModelsOptions != null) { - if (listLanguageModelsOptions.language() != null) { - builder.query("language", listLanguageModelsOptions.language()); - } + if (listLanguageModelsOptions.language() != null) { + builder.query("language", String.valueOf(listLanguageModelsOptions.language())); } ResponseConverter responseConverter = ResponseConverterUtils.getValue( @@ -982,7 +932,7 @@ public ServiceCall listLanguageModels( *

**See also:** [Listing custom language * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-manageLanguageModels#listModels-language). * - * @return a {@link ServiceCall} with a response type of {@link LanguageModels} + * @return a {@link ServiceCall} with a result of type {@link LanguageModels} */ public ServiceCall listLanguageModels() { return listLanguageModels(null); @@ -999,24 +949,24 @@ public ServiceCall listLanguageModels() { * * @param getLanguageModelOptions the {@link GetLanguageModelOptions} containing the options for * the call - * @return a {@link ServiceCall} with a response type of {@link LanguageModel} + * @return a {@link ServiceCall} with a result of type {@link LanguageModel} */ public ServiceCall getLanguageModel( GetLanguageModelOptions getLanguageModelOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( getLanguageModelOptions, "getLanguageModelOptions cannot be null"); - String[] pathSegments = {"v1/customizations"}; - String[] pathParameters = {getLanguageModelOptions.customizationId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", getLanguageModelOptions.customizationId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/customizations/{customization_id}", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "getLanguageModel"); 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()); @@ -1035,24 +985,24 @@ public ServiceCall getLanguageModel( * * @param deleteLanguageModelOptions the {@link DeleteLanguageModelOptions} containing the options * for the call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteLanguageModel( DeleteLanguageModelOptions deleteLanguageModelOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( deleteLanguageModelOptions, "deleteLanguageModelOptions cannot be null"); - String[] pathSegments = {"v1/customizations"}; - String[] pathParameters = {deleteLanguageModelOptions.customizationId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", deleteLanguageModelOptions.customizationId()); RequestBuilder builder = RequestBuilder.delete( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/customizations/{customization_id}", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "deleteLanguageModel"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -1094,17 +1044,18 @@ public ServiceCall deleteLanguageModel( * * @param trainLanguageModelOptions the {@link TrainLanguageModelOptions} containing the options * for the call - * @return a {@link ServiceCall} with a response type of {@link TrainingResponse} + * @return a {@link ServiceCall} with a result of type {@link TrainingResponse} */ public ServiceCall trainLanguageModel( TrainLanguageModelOptions trainLanguageModelOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( trainLanguageModelOptions, "trainLanguageModelOptions cannot be null"); - String[] pathSegments = {"v1/customizations", "train"}; - String[] pathParameters = {trainLanguageModelOptions.customizationId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", trainLanguageModelOptions.customizationId()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/customizations/{customization_id}/train", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "trainLanguageModel"); for (Entry header : sdkHeaders.entrySet()) { @@ -1112,7 +1063,7 @@ public ServiceCall trainLanguageModel( } builder.header("Accept", "application/json"); if (trainLanguageModelOptions.wordTypeToAdd() != null) { - builder.query("word_type_to_add", trainLanguageModelOptions.wordTypeToAdd()); + builder.query("word_type_to_add", String.valueOf(trainLanguageModelOptions.wordTypeToAdd())); } if (trainLanguageModelOptions.customizationWeight() != null) { builder.query( @@ -1138,23 +1089,23 @@ public ServiceCall trainLanguageModel( * * @param resetLanguageModelOptions the {@link ResetLanguageModelOptions} containing the options * for the call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall resetLanguageModel(ResetLanguageModelOptions resetLanguageModelOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( resetLanguageModelOptions, "resetLanguageModelOptions cannot be null"); - String[] pathSegments = {"v1/customizations", "reset"}; - String[] pathParameters = {resetLanguageModelOptions.customizationId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", resetLanguageModelOptions.customizationId()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/customizations/{customization_id}/reset", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "resetLanguageModel"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -1181,24 +1132,26 @@ public ServiceCall resetLanguageModel(ResetLanguageModelOptions resetLangu * * @param upgradeLanguageModelOptions the {@link UpgradeLanguageModelOptions} containing the * options for the call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall upgradeLanguageModel( UpgradeLanguageModelOptions upgradeLanguageModelOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( upgradeLanguageModelOptions, "upgradeLanguageModelOptions cannot be null"); - String[] pathSegments = {"v1/customizations", "upgrade_model"}; - String[] pathParameters = {upgradeLanguageModelOptions.customizationId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", upgradeLanguageModelOptions.customizationId()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/customizations/{customization_id}/upgrade_model", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "upgradeLanguageModel"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -1214,22 +1167,22 @@ public ServiceCall upgradeLanguageModel( * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-manageCorpora#listCorpora). * * @param listCorporaOptions the {@link ListCorporaOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Corpora} + * @return a {@link ServiceCall} with a result of type {@link Corpora} */ public ServiceCall listCorpora(ListCorporaOptions listCorporaOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( listCorporaOptions, "listCorporaOptions cannot be null"); - String[] pathSegments = {"v1/customizations", "corpora"}; - String[] pathParameters = {listCorporaOptions.customizationId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", listCorporaOptions.customizationId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/customizations/{customization_id}/corpora", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "listCorpora"); 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()); @@ -1285,16 +1238,20 @@ public ServiceCall listCorpora(ListCorporaOptions listCorporaOptions) { * resource](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-corporaWords#validateModel). * * @param addCorpusOptions the {@link AddCorpusOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall addCorpus(AddCorpusOptions addCorpusOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( addCorpusOptions, "addCorpusOptions cannot be null"); - String[] pathSegments = {"v1/customizations", "corpora"}; - String[] pathParameters = {addCorpusOptions.customizationId(), addCorpusOptions.corpusName()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", addCorpusOptions.customizationId()); + pathParamsMap.put("corpus_name", addCorpusOptions.corpusName()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/customizations/{customization_id}/corpora/{corpus_name}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "addCorpus"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); @@ -1303,8 +1260,12 @@ public ServiceCall addCorpus(AddCorpusOptions addCorpusOptions) { if (addCorpusOptions.allowOverwrite() != null) { builder.query("allow_overwrite", String.valueOf(addCorpusOptions.allowOverwrite())); } - builder.body(RequestUtils.inputStreamBody(addCorpusOptions.corpusFile(), "text/plain")); - + MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); + multipartBuilder.setType(MultipartBody.FORM); + okhttp3.RequestBody corpusFileBody = + RequestUtils.inputStreamBody(addCorpusOptions.corpusFile(), "text/plain"); + multipartBuilder.addFormDataPart("corpus_file", "filename", corpusFileBody); + builder.body(multipartBuilder.build()); ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -1320,22 +1281,25 @@ public ServiceCall addCorpus(AddCorpusOptions addCorpusOptions) { * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-manageCorpora#listCorpora). * * @param getCorpusOptions the {@link GetCorpusOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Corpus} + * @return a {@link ServiceCall} with a result of type {@link Corpus} */ public ServiceCall getCorpus(GetCorpusOptions getCorpusOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( getCorpusOptions, "getCorpusOptions cannot be null"); - String[] pathSegments = {"v1/customizations", "corpora"}; - String[] pathParameters = {getCorpusOptions.customizationId(), getCorpusOptions.corpusName()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", getCorpusOptions.customizationId()); + pathParamsMap.put("corpus_name", getCorpusOptions.corpusName()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/customizations/{customization_id}/corpora/{corpus_name}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "getCorpus"); 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()); @@ -1357,25 +1321,26 @@ public ServiceCall getCorpus(GetCorpusOptions getCorpusOptions) { * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-manageCorpora#deleteCorpus). * * @param deleteCorpusOptions the {@link DeleteCorpusOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteCorpus(DeleteCorpusOptions deleteCorpusOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( deleteCorpusOptions, "deleteCorpusOptions cannot be null"); - String[] pathSegments = {"v1/customizations", "corpora"}; - String[] pathParameters = { - deleteCorpusOptions.customizationId(), deleteCorpusOptions.corpusName() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", deleteCorpusOptions.customizationId()); + pathParamsMap.put("corpus_name", deleteCorpusOptions.corpusName()); RequestBuilder builder = RequestBuilder.delete( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/customizations/{customization_id}/corpora/{corpus_name}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "deleteCorpus"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -1394,26 +1359,27 @@ public ServiceCall deleteCorpus(DeleteCorpusOptions deleteCorpusOptions) { * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-manageWords#listWords). * * @param listWordsOptions the {@link ListWordsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Words} + * @return a {@link ServiceCall} with a result of type {@link Words} */ public ServiceCall listWords(ListWordsOptions listWordsOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( listWordsOptions, "listWordsOptions cannot be null"); - String[] pathSegments = {"v1/customizations", "words"}; - String[] pathParameters = {listWordsOptions.customizationId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", listWordsOptions.customizationId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/customizations/{customization_id}/words", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "listWords"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); if (listWordsOptions.wordType() != null) { - builder.query("word_type", listWordsOptions.wordType()); + builder.query("word_type", String.valueOf(listWordsOptions.wordType())); } if (listWordsOptions.sort() != null) { - builder.query("sort", listWordsOptions.sort()); + builder.query("sort", String.valueOf(listWordsOptions.sort())); } ResponseConverter responseConverter = ResponseConverterUtils.getValue( @@ -1449,7 +1415,7 @@ public ServiceCall listWords(ListWordsOptions listWordsOptions) { * complete and valid. * The `display_as` field provides a different way of spelling the word in a * transcript. Use the parameter when you want the word to appear different from its usual * representation or from its spelling in training data. For example, you might indicate that the - * word `IBM(trademark)` is to be displayed as `IBM™`. + * word `IBM(trademark)` is to be displayed as `IBM&trade;`. * *

If you add a custom word that already exists in the words resource for the custom model, the * new definition overwrites the existing data for the word. If the service encounters an error @@ -1480,16 +1446,17 @@ public ServiceCall listWords(ListWordsOptions listWordsOptions) { * resource](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-corporaWords#validateModel). * * @param addWordsOptions the {@link AddWordsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall addWords(AddWordsOptions addWordsOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( addWordsOptions, "addWordsOptions cannot be null"); - String[] pathSegments = {"v1/customizations", "words"}; - String[] pathParameters = {addWordsOptions.customizationId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", addWordsOptions.customizationId()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/customizations/{customization_id}/words", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "addWords"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); @@ -1531,7 +1498,7 @@ public ServiceCall addWords(AddWordsOptions addWordsOptions) { * ensure that it is complete and valid. * The `display_as` field provides a different way of * spelling the word in a transcript. Use the parameter when you want the word to appear different * from its usual representation or from its spelling in training data. For example, you might - * indicate that the word `IBM(trademark)` is to be displayed as `IBM™`. + * indicate that the word `IBM(trademark)` is to be displayed as `IBM&trade;`. * *

If you add a custom word that already exists in the words resource for the custom model, the * new definition overwrites the existing data for the word. If the service encounters an error, @@ -1546,15 +1513,19 @@ public ServiceCall addWords(AddWordsOptions addWordsOptions) { * resource](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-corporaWords#validateModel). * * @param addWordOptions the {@link AddWordOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall addWord(AddWordOptions addWordOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull(addWordOptions, "addWordOptions cannot be null"); - String[] pathSegments = {"v1/customizations", "words"}; - String[] pathParameters = {addWordOptions.customizationId(), addWordOptions.wordName()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", addWordOptions.customizationId()); + pathParamsMap.put("word_name", addWordOptions.wordName()); RequestBuilder builder = RequestBuilder.put( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/customizations/{customization_id}/words/{word_name}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "addWord"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); @@ -1588,21 +1559,24 @@ public ServiceCall addWord(AddWordOptions addWordOptions) { * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-manageWords#listWords). * * @param getWordOptions the {@link GetWordOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Word} + * @return a {@link ServiceCall} with a result of type {@link Word} */ public ServiceCall getWord(GetWordOptions getWordOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull(getWordOptions, "getWordOptions cannot be null"); - String[] pathSegments = {"v1/customizations", "words"}; - String[] pathParameters = {getWordOptions.customizationId(), getWordOptions.wordName()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", getWordOptions.customizationId()); + pathParamsMap.put("word_name", getWordOptions.wordName()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/customizations/{customization_id}/words/{word_name}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "getWord"); 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); @@ -1622,22 +1596,25 @@ public ServiceCall getWord(GetWordOptions getWordOptions) { * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-manageWords#deleteWord). * * @param deleteWordOptions the {@link DeleteWordOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteWord(DeleteWordOptions deleteWordOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( deleteWordOptions, "deleteWordOptions cannot be null"); - String[] pathSegments = {"v1/customizations", "words"}; - String[] pathParameters = {deleteWordOptions.customizationId(), deleteWordOptions.wordName()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", deleteWordOptions.customizationId()); + pathParamsMap.put("word_name", deleteWordOptions.wordName()); RequestBuilder builder = RequestBuilder.delete( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/customizations/{customization_id}/words/{word_name}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "deleteWord"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -1653,23 +1630,23 @@ public ServiceCall deleteWord(DeleteWordOptions deleteWordOptions) { * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-manageGrammars#listGrammars). * * @param listGrammarsOptions the {@link ListGrammarsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Grammars} + * @return a {@link ServiceCall} with a result of type {@link Grammars} */ public ServiceCall listGrammars(ListGrammarsOptions listGrammarsOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( listGrammarsOptions, "listGrammarsOptions cannot be null"); - String[] pathSegments = {"v1/customizations", "grammars"}; - String[] pathParameters = {listGrammarsOptions.customizationId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", listGrammarsOptions.customizationId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/customizations/{customization_id}/grammars", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "listGrammars"); 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()); @@ -1717,18 +1694,20 @@ public ServiceCall listGrammars(ListGrammarsOptions listGrammarsOption * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-grammarAdd#addGrammar). * * @param addGrammarOptions the {@link AddGrammarOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall addGrammar(AddGrammarOptions addGrammarOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( addGrammarOptions, "addGrammarOptions cannot be null"); - String[] pathSegments = {"v1/customizations", "grammars"}; - String[] pathParameters = { - addGrammarOptions.customizationId(), addGrammarOptions.grammarName() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", addGrammarOptions.customizationId()); + pathParamsMap.put("grammar_name", addGrammarOptions.grammarName()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/customizations/{customization_id}/grammars/{grammar_name}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "addGrammar"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); @@ -1755,24 +1734,25 @@ public ServiceCall addGrammar(AddGrammarOptions addGrammarOptions) { * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-manageGrammars#listGrammars). * * @param getGrammarOptions the {@link GetGrammarOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Grammar} + * @return a {@link ServiceCall} with a result of type {@link Grammar} */ public ServiceCall getGrammar(GetGrammarOptions getGrammarOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( getGrammarOptions, "getGrammarOptions cannot be null"); - String[] pathSegments = {"v1/customizations", "grammars"}; - String[] pathParameters = { - getGrammarOptions.customizationId(), getGrammarOptions.grammarName() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", getGrammarOptions.customizationId()); + pathParamsMap.put("grammar_name", getGrammarOptions.grammarName()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/customizations/{customization_id}/grammars/{grammar_name}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "getGrammar"); 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()); @@ -1795,25 +1775,26 @@ public ServiceCall getGrammar(GetGrammarOptions getGrammarOptions) { * * @param deleteGrammarOptions the {@link DeleteGrammarOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteGrammar(DeleteGrammarOptions deleteGrammarOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( deleteGrammarOptions, "deleteGrammarOptions cannot be null"); - String[] pathSegments = {"v1/customizations", "grammars"}; - String[] pathParameters = { - deleteGrammarOptions.customizationId(), deleteGrammarOptions.grammarName() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", deleteGrammarOptions.customizationId()); + pathParamsMap.put("grammar_name", deleteGrammarOptions.grammarName()); RequestBuilder builder = RequestBuilder.delete( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/customizations/{customization_id}/grammars/{grammar_name}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "deleteGrammar"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -1834,15 +1815,15 @@ public ServiceCall deleteGrammar(DeleteGrammarOptions deleteGrammarOptions * * @param createAcousticModelOptions the {@link CreateAcousticModelOptions} containing the options * for the call - * @return a {@link ServiceCall} with a response type of {@link AcousticModel} + * @return a {@link ServiceCall} with a result of type {@link AcousticModel} */ public ServiceCall createAcousticModel( CreateAcousticModelOptions createAcousticModelOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( createAcousticModelOptions, "createAcousticModelOptions cannot be null"); - String[] pathSegments = {"v1/acoustic_customizations"}; RequestBuilder builder = - RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); + RequestBuilder.post( + RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/acoustic_customizations")); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "createAcousticModel"); for (Entry header : sdkHeaders.entrySet()) { @@ -1875,23 +1856,24 @@ public ServiceCall createAcousticModel( * * @param listAcousticModelsOptions the {@link ListAcousticModelsOptions} containing the options * for the call - * @return a {@link ServiceCall} with a response type of {@link AcousticModels} + * @return a {@link ServiceCall} with a result of type {@link AcousticModels} */ public ServiceCall listAcousticModels( ListAcousticModelsOptions listAcousticModelsOptions) { - String[] pathSegments = {"v1/acoustic_customizations"}; + if (listAcousticModelsOptions == null) { + listAcousticModelsOptions = new ListAcousticModelsOptions.Builder().build(); + } RequestBuilder builder = - RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); + RequestBuilder.get( + RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/acoustic_customizations")); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "listAcousticModels"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - if (listAcousticModelsOptions != null) { - if (listAcousticModelsOptions.language() != null) { - builder.query("language", listAcousticModelsOptions.language()); - } + if (listAcousticModelsOptions.language() != null) { + builder.query("language", String.valueOf(listAcousticModelsOptions.language())); } ResponseConverter responseConverter = ResponseConverterUtils.getValue( @@ -1910,7 +1892,7 @@ public ServiceCall listAcousticModels( *

**See also:** [Listing custom acoustic * models](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-manageAcousticModels#listModels-acoustic). * - * @return a {@link ServiceCall} with a response type of {@link AcousticModels} + * @return a {@link ServiceCall} with a result of type {@link AcousticModels} */ public ServiceCall listAcousticModels() { return listAcousticModels(null); @@ -1927,24 +1909,24 @@ public ServiceCall listAcousticModels() { * * @param getAcousticModelOptions the {@link GetAcousticModelOptions} containing the options for * the call - * @return a {@link ServiceCall} with a response type of {@link AcousticModel} + * @return a {@link ServiceCall} with a result of type {@link AcousticModel} */ public ServiceCall getAcousticModel( GetAcousticModelOptions getAcousticModelOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( getAcousticModelOptions, "getAcousticModelOptions cannot be null"); - String[] pathSegments = {"v1/acoustic_customizations"}; - String[] pathParameters = {getAcousticModelOptions.customizationId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", getAcousticModelOptions.customizationId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/acoustic_customizations/{customization_id}", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "getAcousticModel"); 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()); @@ -1963,24 +1945,24 @@ public ServiceCall getAcousticModel( * * @param deleteAcousticModelOptions the {@link DeleteAcousticModelOptions} containing the options * for the call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteAcousticModel( DeleteAcousticModelOptions deleteAcousticModelOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( deleteAcousticModelOptions, "deleteAcousticModelOptions cannot be null"); - String[] pathSegments = {"v1/acoustic_customizations"}; - String[] pathParameters = {deleteAcousticModelOptions.customizationId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", deleteAcousticModelOptions.customizationId()); RequestBuilder builder = RequestBuilder.delete( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/acoustic_customizations/{customization_id}", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "deleteAcousticModel"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -1994,13 +1976,13 @@ public ServiceCall deleteAcousticModel( * reflect its changed data until you train it. You must use credentials for the instance of the * service that owns a model to train it. * - *

The training method is asynchronous. It can take on the order of minutes or hours to - * complete depending on the total amount of audio data on which the custom acoustic model is - * being trained and the current load on the service. Typically, training a custom acoustic model - * takes approximately two to four times the length of its audio data. The actual time depends on - * the model being trained and the nature of the audio, such as whether the audio is clean or - * noisy. The method returns an HTTP 200 response code to indicate that the training process has - * begun. + *

The training method is asynchronous. Training time depends on the cumulative amount of audio + * data that the custom acoustic model contains and the current load on the service. When you + * train or retrain a model, the service uses all of the model's audio data in the training. + * Training a custom acoustic model takes approximately as long as the length of its cumulative + * audio data. For example, it takes approximately 2 hours to train a model that contains a total + * of 2 hours of audio. The method returns an HTTP 200 response code to indicate that the training + * process has begun. * *

You can monitor the status of the training by using the **Get a custom acoustic model** * method to poll the model's status. Use a loop to check the status once a minute. The method @@ -2039,17 +2021,20 @@ public ServiceCall deleteAcousticModel( * * @param trainAcousticModelOptions the {@link TrainAcousticModelOptions} containing the options * for the call - * @return a {@link ServiceCall} with a response type of {@link TrainingResponse} + * @return a {@link ServiceCall} with a result of type {@link TrainingResponse} */ public ServiceCall trainAcousticModel( TrainAcousticModelOptions trainAcousticModelOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( trainAcousticModelOptions, "trainAcousticModelOptions cannot be null"); - String[] pathSegments = {"v1/acoustic_customizations", "train"}; - String[] pathParameters = {trainAcousticModelOptions.customizationId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", trainAcousticModelOptions.customizationId()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/acoustic_customizations/{customization_id}/train", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "trainAcousticModel"); for (Entry header : sdkHeaders.entrySet()) { @@ -2057,7 +2042,9 @@ public ServiceCall trainAcousticModel( } builder.header("Accept", "application/json"); if (trainAcousticModelOptions.customLanguageModelId() != null) { - builder.query("custom_language_model_id", trainAcousticModelOptions.customLanguageModelId()); + builder.query( + "custom_language_model_id", + String.valueOf(trainAcousticModelOptions.customLanguageModelId())); } ResponseConverter responseConverter = ResponseConverterUtils.getValue( @@ -2081,23 +2068,25 @@ public ServiceCall trainAcousticModel( * * @param resetAcousticModelOptions the {@link ResetAcousticModelOptions} containing the options * for the call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall resetAcousticModel(ResetAcousticModelOptions resetAcousticModelOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( resetAcousticModelOptions, "resetAcousticModelOptions cannot be null"); - String[] pathSegments = {"v1/acoustic_customizations", "reset"}; - String[] pathParameters = {resetAcousticModelOptions.customizationId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", resetAcousticModelOptions.customizationId()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/acoustic_customizations/{customization_id}/reset", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "resetAcousticModel"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -2132,17 +2121,20 @@ public ServiceCall resetAcousticModel(ResetAcousticModelOptions resetAcous * * @param upgradeAcousticModelOptions the {@link UpgradeAcousticModelOptions} containing the * options for the call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall upgradeAcousticModel( UpgradeAcousticModelOptions upgradeAcousticModelOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( upgradeAcousticModelOptions, "upgradeAcousticModelOptions cannot be null"); - String[] pathSegments = {"v1/acoustic_customizations", "upgrade_model"}; - String[] pathParameters = {upgradeAcousticModelOptions.customizationId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", upgradeAcousticModelOptions.customizationId()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/acoustic_customizations/{customization_id}/upgrade_model", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "upgradeAcousticModel"); for (Entry header : sdkHeaders.entrySet()) { @@ -2151,7 +2143,8 @@ public ServiceCall upgradeAcousticModel( builder.header("Accept", "application/json"); if (upgradeAcousticModelOptions.customLanguageModelId() != null) { builder.query( - "custom_language_model_id", upgradeAcousticModelOptions.customLanguageModelId()); + "custom_language_model_id", + String.valueOf(upgradeAcousticModelOptions.customLanguageModelId())); } if (upgradeAcousticModelOptions.force() != null) { builder.query("force", String.valueOf(upgradeAcousticModelOptions.force())); @@ -2174,22 +2167,24 @@ public ServiceCall upgradeAcousticModel( * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-manageAudio#listAudio). * * @param listAudioOptions the {@link ListAudioOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link AudioResources} + * @return a {@link ServiceCall} with a result of type {@link AudioResources} */ public ServiceCall listAudio(ListAudioOptions listAudioOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( listAudioOptions, "listAudioOptions cannot be null"); - String[] pathSegments = {"v1/acoustic_customizations", "audio"}; - String[] pathParameters = {listAudioOptions.customizationId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", listAudioOptions.customizationId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/acoustic_customizations/{customization_id}/audio", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "listAudio"); 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()); @@ -2284,16 +2279,20 @@ public ServiceCall listAudio(ListAudioOptions listAudioOptions) * example, slashes). * * @param addAudioOptions the {@link AddAudioOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall addAudio(AddAudioOptions addAudioOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( addAudioOptions, "addAudioOptions cannot be null"); - String[] pathSegments = {"v1/acoustic_customizations", "audio"}; - String[] pathParameters = {addAudioOptions.customizationId(), addAudioOptions.audioName()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", addAudioOptions.customizationId()); + pathParamsMap.put("audio_name", addAudioOptions.audioName()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/acoustic_customizations/{customization_id}/audio/{audio_name}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "addAudio"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); @@ -2338,22 +2337,25 @@ public ServiceCall addAudio(AddAudioOptions addAudioOptions) { * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-manageAudio#listAudio). * * @param getAudioOptions the {@link GetAudioOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link AudioListing} + * @return a {@link ServiceCall} with a result of type {@link AudioListing} */ public ServiceCall getAudio(GetAudioOptions getAudioOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( getAudioOptions, "getAudioOptions cannot be null"); - String[] pathSegments = {"v1/acoustic_customizations", "audio"}; - String[] pathParameters = {getAudioOptions.customizationId(), getAudioOptions.audioName()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", getAudioOptions.customizationId()); + pathParamsMap.put("audio_name", getAudioOptions.audioName()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/acoustic_customizations/{customization_id}/audio/{audio_name}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "getAudio"); 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()); @@ -2377,24 +2379,25 @@ public ServiceCall getAudio(GetAudioOptions getAudioOptions) { * model](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-manageAudio#deleteAudio). * * @param deleteAudioOptions the {@link DeleteAudioOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteAudio(DeleteAudioOptions deleteAudioOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( deleteAudioOptions, "deleteAudioOptions cannot be null"); - String[] pathSegments = {"v1/acoustic_customizations", "audio"}; - String[] pathParameters = { - deleteAudioOptions.customizationId(), deleteAudioOptions.audioName() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", deleteAudioOptions.customizationId()); + pathParamsMap.put("audio_name", deleteAudioOptions.audioName()); RequestBuilder builder = RequestBuilder.delete( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/acoustic_customizations/{customization_id}/audio/{audio_name}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "deleteAudio"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -2420,20 +2423,19 @@ public ServiceCall deleteAudio(DeleteAudioOptions deleteAudioOptions) { * * @param deleteUserDataOptions the {@link DeleteUserDataOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteUserData(DeleteUserDataOptions deleteUserDataOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( deleteUserDataOptions, "deleteUserDataOptions cannot be null"); - String[] pathSegments = {"v1/user_data"}; RequestBuilder builder = - RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); + RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/user_data")); Map sdkHeaders = SdkCommon.getSdkHeaders("speech_to_text", "v1", "deleteUserData"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } - builder.query("customer_id", deleteUserDataOptions.customerId()); + builder.query("customer_id", String.valueOf(deleteUserDataOptions.customerId())); ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AcousticModel.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AcousticModel.java index a1406c78901..9e94a8fa559 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AcousticModel.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AcousticModel.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AcousticModels.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AcousticModels.java index a270d1220d0..a363b636cba 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AcousticModels.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AcousticModels.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AddAudioOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AddAudioOptions.java index 38de1fbf6b6..7e9eefa35f0 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AddAudioOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AddAudioOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -114,7 +114,7 @@ public Builder(String customizationId, String audioName, InputStream audioResour /** * Builds a AddAudioOptions. * - * @return the addAudioOptions + * @return the new AddAudioOptions instance */ public AddAudioOptions build() { return new AddAudioOptions(this); diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AddCorpusOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AddCorpusOptions.java index f40905c3cf0..4ed844c16c9 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AddCorpusOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AddCorpusOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -59,7 +59,7 @@ public Builder(String customizationId, String corpusName, InputStream corpusFile /** * Builds a AddCorpusOptions. * - * @return the addCorpusOptions + * @return the new AddCorpusOptions instance */ public AddCorpusOptions build() { return new AddCorpusOptions(this); diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AddGrammarOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AddGrammarOptions.java index 132c0e76de9..f6d81d05000 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AddGrammarOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AddGrammarOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -65,7 +65,7 @@ public Builder( /** * Builds a AddGrammarOptions. * - * @return the addGrammarOptions + * @return the new AddGrammarOptions instance */ public AddGrammarOptions build() { return new AddGrammarOptions(this); diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AddWordOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AddWordOptions.java index cce2fb03963..1bb5154db4b 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AddWordOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AddWordOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -58,7 +58,7 @@ public Builder(String customizationId, String wordName) { /** * Builds a AddWordOptions. * - * @return the addWordOptions + * @return the new AddWordOptions instance */ public AddWordOptions build() { return new AddWordOptions(this); diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AddWordsOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AddWordsOptions.java index 73abf2a7a9c..75eec89a54b 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AddWordsOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AddWordsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -49,7 +49,7 @@ public Builder(String customizationId, List words) { /** * Builds a AddWordsOptions. * - * @return the addWordsOptions + * @return the new AddWordsOptions instance */ public AddWordsOptions build() { return new AddWordsOptions(this); diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioDetails.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioDetails.java index 4ee2b16a7b5..bc2640880cd 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioDetails.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioDetails.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioListing.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioListing.java index 9eb21ce1968..be2e8eaf6cd 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioListing.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioListing.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioMetrics.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioMetrics.java index c7c0db7a643..cdb7a546632 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioMetrics.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioMetrics.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioMetricsDetails.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioMetricsDetails.java index d73e9ee0e24..a4754e6724d 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioMetricsDetails.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioMetricsDetails.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioMetricsHistogramBin.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioMetricsHistogramBin.java index 041f7edf3aa..7a13f0f6e4c 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioMetricsHistogramBin.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioMetricsHistogramBin.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioResource.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioResource.java index 88b4b943c17..60e4a5151a8 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioResource.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioResource.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioResources.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioResources.java index b0f6852328a..1c37b2a2f8c 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioResources.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioResources.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CheckJobOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CheckJobOptions.java index f76388016d1..0269eb2c02b 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CheckJobOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CheckJobOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -42,7 +42,7 @@ public Builder(String id) { /** * Builds a CheckJobOptions. * - * @return the checkJobOptions + * @return the new CheckJobOptions instance */ public CheckJobOptions build() { return new CheckJobOptions(this); diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CheckJobsOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CheckJobsOptions.java index 98d61bce423..b5cc8c58088 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CheckJobsOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CheckJobsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -15,34 +15,4 @@ import com.ibm.cloud.sdk.core.service.model.GenericModel; /** The checkJobs options. */ -public class CheckJobsOptions extends GenericModel { - - /** Builder. */ - public static class Builder { - - private Builder(CheckJobsOptions checkJobsOptions) {} - - /** Instantiates a new builder. */ - public Builder() {} - - /** - * Builds a CheckJobsOptions. - * - * @return the checkJobsOptions - */ - public CheckJobsOptions build() { - return new CheckJobsOptions(this); - } - } - - private CheckJobsOptions(Builder builder) {} - - /** - * New builder. - * - * @return a CheckJobsOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } -} +public class CheckJobsOptions extends GenericModel {} diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/Corpora.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/Corpora.java index 5c4eb45f736..192ba4c83ed 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/Corpora.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/Corpora.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/Corpus.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/Corpus.java index 41fcb8acb65..04bb2487b8f 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/Corpus.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/Corpus.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2016, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CreateAcousticModelOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CreateAcousticModelOptions.java index c79ebc9d5ff..a95f4189d63 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CreateAcousticModelOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CreateAcousticModelOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -32,6 +32,10 @@ public interface BaseModelName { String DE_DE_BROADBANDMODEL = "de-DE_BroadbandModel"; /** de-DE_NarrowbandModel. */ String DE_DE_NARROWBANDMODEL = "de-DE_NarrowbandModel"; + /** en-AU_BroadbandModel. */ + String EN_AU_BROADBANDMODEL = "en-AU_BroadbandModel"; + /** en-AU_NarrowbandModel. */ + String EN_AU_NARROWBANDMODEL = "en-AU_NarrowbandModel"; /** en-GB_BroadbandModel. */ String EN_GB_BROADBANDMODEL = "en-GB_BroadbandModel"; /** en-GB_NarrowbandModel. */ @@ -129,7 +133,7 @@ public Builder(String name, String baseModelName) { /** * Builds a CreateAcousticModelOptions. * - * @return the createAcousticModelOptions + * @return the new CreateAcousticModelOptions instance */ public CreateAcousticModelOptions build() { return new CreateAcousticModelOptions(this); diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CreateJobOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CreateJobOptions.java index f0c594d1fab..5a50ae6c2aa 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CreateJobOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CreateJobOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -72,6 +72,10 @@ public interface Model { String ES_PE_BROADBANDMODEL = "es-PE_BroadbandModel"; /** es-PE_NarrowbandModel. */ String ES_PE_NARROWBANDMODEL = "es-PE_NarrowbandModel"; + /** fr-CA_BroadbandModel. */ + String FR_CA_BROADBANDMODEL = "fr-CA_BroadbandModel"; + /** fr-CA_NarrowbandModel. */ + String FR_CA_NARROWBANDMODEL = "fr-CA_NarrowbandModel"; /** fr-FR_BroadbandModel. */ String FR_FR_BROADBANDMODEL = "fr-FR_BroadbandModel"; /** fr-FR_NarrowbandModel. */ @@ -245,7 +249,7 @@ public Builder(InputStream audio) { /** * Builds a CreateJobOptions. * - * @return the createJobOptions + * @return the new CreateJobOptions instance */ public CreateJobOptions build() { return new CreateJobOptions(this); diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CreateLanguageModelOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CreateLanguageModelOptions.java index 9dc2f0166d6..6eeb840cd3c 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CreateLanguageModelOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CreateLanguageModelOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -31,6 +31,10 @@ public interface BaseModelName { String DE_DE_BROADBANDMODEL = "de-DE_BroadbandModel"; /** de-DE_NarrowbandModel. */ String DE_DE_NARROWBANDMODEL = "de-DE_NarrowbandModel"; + /** en-AU_BroadbandModel. */ + String EN_AU_BROADBANDMODEL = "en-AU_BroadbandModel"; + /** en-AU_NarrowbandModel. */ + String EN_AU_NARROWBANDMODEL = "en-AU_NarrowbandModel"; /** en-GB_BroadbandModel. */ String EN_GB_BROADBANDMODEL = "en-GB_BroadbandModel"; /** en-GB_NarrowbandModel. */ @@ -127,7 +131,7 @@ public Builder(String name, String baseModelName) { /** * Builds a CreateLanguageModelOptions. * - * @return the createLanguageModelOptions + * @return the new CreateLanguageModelOptions instance */ public CreateLanguageModelOptions build() { return new CreateLanguageModelOptions(this); diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CustomWord.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CustomWord.java index 844140af1d3..9f8b752ff49 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CustomWord.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CustomWord.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -46,7 +46,7 @@ public Builder() {} /** * Builds a CustomWord. * - * @return the customWord + * @return the new CustomWord instance */ public CustomWord build() { return new CustomWord(this); diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteAcousticModelOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteAcousticModelOptions.java index e4a6c62eadf..5ecc1130a67 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteAcousticModelOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteAcousticModelOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -42,7 +42,7 @@ public Builder(String customizationId) { /** * Builds a DeleteAcousticModelOptions. * - * @return the deleteAcousticModelOptions + * @return the new DeleteAcousticModelOptions instance */ public DeleteAcousticModelOptions build() { return new DeleteAcousticModelOptions(this); diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteAudioOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteAudioOptions.java index 265bc3e13fa..596bfa19363 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteAudioOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteAudioOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -47,7 +47,7 @@ public Builder(String customizationId, String audioName) { /** * Builds a DeleteAudioOptions. * - * @return the deleteAudioOptions + * @return the new DeleteAudioOptions instance */ public DeleteAudioOptions build() { return new DeleteAudioOptions(this); diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteCorpusOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteCorpusOptions.java index cd43563bd3e..f1711388977 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteCorpusOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteCorpusOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -47,7 +47,7 @@ public Builder(String customizationId, String corpusName) { /** * Builds a DeleteCorpusOptions. * - * @return the deleteCorpusOptions + * @return the new DeleteCorpusOptions instance */ public DeleteCorpusOptions build() { return new DeleteCorpusOptions(this); diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteGrammarOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteGrammarOptions.java index 6d7a6e20f92..bb940a89b40 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteGrammarOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteGrammarOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -47,7 +47,7 @@ public Builder(String customizationId, String grammarName) { /** * Builds a DeleteGrammarOptions. * - * @return the deleteGrammarOptions + * @return the new DeleteGrammarOptions instance */ public DeleteGrammarOptions build() { return new DeleteGrammarOptions(this); diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteJobOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteJobOptions.java index 44617b42d7f..096b41e78fa 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteJobOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteJobOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -42,7 +42,7 @@ public Builder(String id) { /** * Builds a DeleteJobOptions. * - * @return the deleteJobOptions + * @return the new DeleteJobOptions instance */ public DeleteJobOptions build() { return new DeleteJobOptions(this); diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteLanguageModelOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteLanguageModelOptions.java index 648daf102d1..e83a2ec9e76 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteLanguageModelOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteLanguageModelOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -42,7 +42,7 @@ public Builder(String customizationId) { /** * Builds a DeleteLanguageModelOptions. * - * @return the deleteLanguageModelOptions + * @return the new DeleteLanguageModelOptions instance */ public DeleteLanguageModelOptions build() { return new DeleteLanguageModelOptions(this); diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteUserDataOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteUserDataOptions.java index a252403dbdd..58eb8d92d1f 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteUserDataOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteUserDataOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -42,7 +42,7 @@ public Builder(String customerId) { /** * Builds a DeleteUserDataOptions. * - * @return the deleteUserDataOptions + * @return the new DeleteUserDataOptions instance */ public DeleteUserDataOptions build() { return new DeleteUserDataOptions(this); diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteWordOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteWordOptions.java index 6915343c4b8..46586e9b604 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteWordOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteWordOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -47,7 +47,7 @@ public Builder(String customizationId, String wordName) { /** * Builds a DeleteWordOptions. * - * @return the deleteWordOptions + * @return the new DeleteWordOptions instance */ public DeleteWordOptions build() { return new DeleteWordOptions(this); diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetAcousticModelOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetAcousticModelOptions.java index 9bc7bd4d7bd..ffdf2c4acac 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetAcousticModelOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetAcousticModelOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -42,7 +42,7 @@ public Builder(String customizationId) { /** * Builds a GetAcousticModelOptions. * - * @return the getAcousticModelOptions + * @return the new GetAcousticModelOptions instance */ public GetAcousticModelOptions build() { return new GetAcousticModelOptions(this); diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetAudioOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetAudioOptions.java index 2cc0bc3f46b..a7cb4b3c634 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetAudioOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetAudioOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -47,7 +47,7 @@ public Builder(String customizationId, String audioName) { /** * Builds a GetAudioOptions. * - * @return the getAudioOptions + * @return the new GetAudioOptions instance */ public GetAudioOptions build() { return new GetAudioOptions(this); diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetCorpusOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetCorpusOptions.java index ce00d2e1678..f4282234d04 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetCorpusOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetCorpusOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -47,7 +47,7 @@ public Builder(String customizationId, String corpusName) { /** * Builds a GetCorpusOptions. * - * @return the getCorpusOptions + * @return the new GetCorpusOptions instance */ public GetCorpusOptions build() { return new GetCorpusOptions(this); diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetGrammarOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetGrammarOptions.java index 77e2aa2267b..4108162ecfa 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetGrammarOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetGrammarOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -47,7 +47,7 @@ public Builder(String customizationId, String grammarName) { /** * Builds a GetGrammarOptions. * - * @return the getGrammarOptions + * @return the new GetGrammarOptions instance */ public GetGrammarOptions build() { return new GetGrammarOptions(this); diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetLanguageModelOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetLanguageModelOptions.java index 1f793e34b5a..183b57823f7 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetLanguageModelOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetLanguageModelOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -42,7 +42,7 @@ public Builder(String customizationId) { /** * Builds a GetLanguageModelOptions. * - * @return the getLanguageModelOptions + * @return the new GetLanguageModelOptions instance */ public GetLanguageModelOptions build() { return new GetLanguageModelOptions(this); diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetModelOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetModelOptions.java index 937807466f6..3535238d9e7 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetModelOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetModelOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -66,6 +66,10 @@ public interface ModelId { String ES_PE_BROADBANDMODEL = "es-PE_BroadbandModel"; /** es-PE_NarrowbandModel. */ String ES_PE_NARROWBANDMODEL = "es-PE_NarrowbandModel"; + /** fr-CA_BroadbandModel. */ + String FR_CA_BROADBANDMODEL = "fr-CA_BroadbandModel"; + /** fr-CA_NarrowbandModel. */ + String FR_CA_NARROWBANDMODEL = "fr-CA_NarrowbandModel"; /** fr-FR_BroadbandModel. */ String FR_FR_BROADBANDMODEL = "fr-FR_BroadbandModel"; /** fr-FR_NarrowbandModel. */ @@ -121,7 +125,7 @@ public Builder(String modelId) { /** * Builds a GetModelOptions. * - * @return the getModelOptions + * @return the new GetModelOptions instance */ public GetModelOptions build() { return new GetModelOptions(this); diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetWordOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetWordOptions.java index e475c37bc96..52f8f2ec288 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetWordOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetWordOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -47,7 +47,7 @@ public Builder(String customizationId, String wordName) { /** * Builds a GetWordOptions. * - * @return the getWordOptions + * @return the new GetWordOptions instance */ public GetWordOptions build() { return new GetWordOptions(this); diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/Grammar.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/Grammar.java index 2a50e27a29a..0bf546add65 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/Grammar.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/Grammar.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/Grammars.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/Grammars.java index 70add9efbb7..bc1bf3c2460 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/Grammars.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/Grammars.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/KeywordResult.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/KeywordResult.java index 095f5739116..839efbc2b64 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/KeywordResult.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/KeywordResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/LanguageModel.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/LanguageModel.java index b5f3f35134a..467bf1b1dd2 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/LanguageModel.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/LanguageModel.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/LanguageModels.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/LanguageModels.java index 0c67d8791fc..cfb5b25fb5b 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/LanguageModels.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/LanguageModels.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListAcousticModelsOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListAcousticModelsOptions.java index 676baff60d9..d9e28ce3652 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListAcousticModelsOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListAcousticModelsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -20,14 +20,18 @@ public class ListAcousticModelsOptions extends GenericModel { /** * The identifier of the language for which custom language or custom acoustic models are to be * returned. Omit the parameter to see all custom language or custom acoustic models that are - * owned by the requesting credentials. **Note:** The `ar-AR` (Modern Standard Arabic) and `zh-CN` - * (Mandarin Chinese) languages are not available for language model customization. + * owned by the requesting credentials. + * + *

To determine the languages for which customization is available, see [Language support for + * customization](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-customization#languageSupport). */ public interface Language { /** ar-AR. */ String AR_AR = "ar-AR"; /** de-DE. */ String DE_DE = "de-DE"; + /** en-AU. */ + String EN_AU = "en-AU"; /** en-GB. */ String EN_GB = "en-GB"; /** en-US. */ @@ -76,7 +80,7 @@ public Builder() {} /** * Builds a ListAcousticModelsOptions. * - * @return the listAcousticModelsOptions + * @return the new ListAcousticModelsOptions instance */ public ListAcousticModelsOptions build() { return new ListAcousticModelsOptions(this); @@ -112,8 +116,10 @@ public Builder newBuilder() { * *

The identifier of the language for which custom language or custom acoustic models are to be * returned. Omit the parameter to see all custom language or custom acoustic models that are - * owned by the requesting credentials. **Note:** The `ar-AR` (Modern Standard Arabic) and `zh-CN` - * (Mandarin Chinese) languages are not available for language model customization. + * owned by the requesting credentials. + * + *

To determine the languages for which customization is available, see [Language support for + * customization](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-customization#languageSupport). * * @return the language */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListAudioOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListAudioOptions.java index cdf858821ce..477f2f0da94 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListAudioOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListAudioOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -42,7 +42,7 @@ public Builder(String customizationId) { /** * Builds a ListAudioOptions. * - * @return the listAudioOptions + * @return the new ListAudioOptions instance */ public ListAudioOptions build() { return new ListAudioOptions(this); diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListCorporaOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListCorporaOptions.java index 34d2e689e3a..db5a7d26e87 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListCorporaOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListCorporaOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -42,7 +42,7 @@ public Builder(String customizationId) { /** * Builds a ListCorporaOptions. * - * @return the listCorporaOptions + * @return the new ListCorporaOptions instance */ public ListCorporaOptions build() { return new ListCorporaOptions(this); diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListGrammarsOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListGrammarsOptions.java index 2208a2826f2..241047f935e 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListGrammarsOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListGrammarsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -42,7 +42,7 @@ public Builder(String customizationId) { /** * Builds a ListGrammarsOptions. * - * @return the listGrammarsOptions + * @return the new ListGrammarsOptions instance */ public ListGrammarsOptions build() { return new ListGrammarsOptions(this); diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListLanguageModelsOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListLanguageModelsOptions.java index 33796721a96..740f0bbe0a1 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListLanguageModelsOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListLanguageModelsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -20,14 +20,18 @@ public class ListLanguageModelsOptions extends GenericModel { /** * The identifier of the language for which custom language or custom acoustic models are to be * returned. Omit the parameter to see all custom language or custom acoustic models that are - * owned by the requesting credentials. **Note:** The `ar-AR` (Modern Standard Arabic) and `zh-CN` - * (Mandarin Chinese) languages are not available for language model customization. + * owned by the requesting credentials. + * + *

To determine the languages for which customization is available, see [Language support for + * customization](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-customization#languageSupport). */ public interface Language { /** ar-AR. */ String AR_AR = "ar-AR"; /** de-DE. */ String DE_DE = "de-DE"; + /** en-AU. */ + String EN_AU = "en-AU"; /** en-GB. */ String EN_GB = "en-GB"; /** en-US. */ @@ -76,7 +80,7 @@ public Builder() {} /** * Builds a ListLanguageModelsOptions. * - * @return the listLanguageModelsOptions + * @return the new ListLanguageModelsOptions instance */ public ListLanguageModelsOptions build() { return new ListLanguageModelsOptions(this); @@ -112,8 +116,10 @@ public Builder newBuilder() { * *

The identifier of the language for which custom language or custom acoustic models are to be * returned. Omit the parameter to see all custom language or custom acoustic models that are - * owned by the requesting credentials. **Note:** The `ar-AR` (Modern Standard Arabic) and `zh-CN` - * (Mandarin Chinese) languages are not available for language model customization. + * owned by the requesting credentials. + * + *

To determine the languages for which customization is available, see [Language support for + * customization](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-customization#languageSupport). * * @return the language */ diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListModelsOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListModelsOptions.java index bc8e43bf79d..386903130ba 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListModelsOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListModelsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -15,34 +15,4 @@ import com.ibm.cloud.sdk.core.service.model.GenericModel; /** The listModels options. */ -public class ListModelsOptions extends GenericModel { - - /** Builder. */ - public static class Builder { - - private Builder(ListModelsOptions listModelsOptions) {} - - /** Instantiates a new builder. */ - public Builder() {} - - /** - * Builds a ListModelsOptions. - * - * @return the listModelsOptions - */ - public ListModelsOptions build() { - return new ListModelsOptions(this); - } - } - - private ListModelsOptions(Builder builder) {} - - /** - * New builder. - * - * @return a ListModelsOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } -} +public class ListModelsOptions extends GenericModel {} diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListWordsOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListWordsOptions.java index 947c9e47017..d85119ff574 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListWordsOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListWordsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -80,7 +80,7 @@ public Builder(String customizationId) { /** * Builds a ListWordsOptions. * - * @return the listWordsOptions + * @return the new ListWordsOptions instance */ public ListWordsOptions build() { return new ListWordsOptions(this); diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ProcessedAudio.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ProcessedAudio.java index 0247350879e..5faad4a432a 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ProcessedAudio.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ProcessedAudio.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ProcessingMetrics.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ProcessingMetrics.java index 6b35920ec23..4181530a92c 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ProcessingMetrics.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ProcessingMetrics.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/RecognitionJob.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/RecognitionJob.java index 7763d61480f..6773b18abb0 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/RecognitionJob.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/RecognitionJob.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2016, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/RecognitionJobs.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/RecognitionJobs.java index 39a0c0d73e5..7890b6f403a 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/RecognitionJobs.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/RecognitionJobs.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/RecognizeOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/RecognizeOptions.java index 8215efce8b8..bb9fa9087dc 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/RecognizeOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/RecognizeOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2016, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -12,7 +12,6 @@ */ package com.ibm.watson.speech_to_text.v1.model; -import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; import java.io.File; import java.io.FileInputStream; @@ -73,6 +72,10 @@ public interface Model { String ES_PE_BROADBANDMODEL = "es-PE_BroadbandModel"; /** es-PE_NarrowbandModel. */ String ES_PE_NARROWBANDMODEL = "es-PE_NarrowbandModel"; + /** fr-CA_BroadbandModel. */ + String FR_CA_BROADBANDMODEL = "fr-CA_BroadbandModel"; + /** fr-CA_NarrowbandModel. */ + String FR_CA_NARROWBANDMODEL = "fr-CA_NarrowbandModel"; /** fr-FR_BroadbandModel. */ String FR_FR_BROADBANDMODEL = "fr-FR_BroadbandModel"; /** fr-FR_NarrowbandModel. */ @@ -103,11 +106,8 @@ public interface Model { String ZH_CN_NARROWBANDMODEL = "zh-CN_NarrowbandModel"; } - protected transient InputStream audio; - - @SerializedName("content-type") + protected InputStream audio; protected String contentType; - protected String model; protected String languageCustomizationId; protected String acousticCustomizationId; @@ -131,9 +131,6 @@ public interface Model { protected Boolean splitTranscriptAtPhraseEnd; protected Float speechDetectorSensitivity; protected Float backgroundAudioSuppression; - private Boolean interimResults; - private Boolean processingMetrics; - private Float processingMetricsInterval; /** Builder. */ public static class Builder { @@ -162,9 +159,6 @@ public static class Builder { private Boolean splitTranscriptAtPhraseEnd; private Float speechDetectorSensitivity; private Float backgroundAudioSuppression; - private Boolean interimResults; - private Boolean processingMetrics; - private Float processingMetricsInterval; private Builder(RecognizeOptions recognizeOptions) { this.audio = recognizeOptions.audio; @@ -192,9 +186,6 @@ private Builder(RecognizeOptions recognizeOptions) { this.splitTranscriptAtPhraseEnd = recognizeOptions.splitTranscriptAtPhraseEnd; this.speechDetectorSensitivity = recognizeOptions.speechDetectorSensitivity; this.backgroundAudioSuppression = recognizeOptions.backgroundAudioSuppression; - this.interimResults = recognizeOptions.interimResults; - this.processingMetrics = recognizeOptions.processingMetrics; - this.processingMetricsInterval = recognizeOptions.processingMetricsInterval; } /** Instantiates a new builder. */ @@ -212,7 +203,7 @@ public Builder(InputStream audio) { /** * Builds a RecognizeOptions. * - * @return the recognizeOptions + * @return the new RecognizeOptions instance */ public RecognizeOptions build() { return new RecognizeOptions(this); @@ -233,100 +224,6 @@ public Builder addKeyword(String keyword) { return this; } - /** - * Gets the interimResults. - * - *

If `true`, the service returns interim results as a stream of `SpeechRecognitionResults` - * objects. By default, the service returns a single `SpeechRecognitionResults` object with - * final results only. - * - *

NOTE: This parameter only works for the `recognizeUsingWebSocket` method. - * - * @return the interimResults - */ - public Boolean interimResults() { - return interimResults; - } - - /** - * Gets the processingMetrics. - * - *

If `true`, requests processing metrics about the service's transcription of the input - * audio. The service returns processing metrics at the interval specified by the - * `processing_metrics_interval` parameter. It also returns processing metrics for transcription - * events, for example, for final and interim results. By default, the service returns no - * processing metrics. - * - *

NOTE: This parameter only works for the `recognizeUsingWebSocket` method. - * - * @return the processingMetrics - */ - public Boolean processingMetrics() { - return processingMetrics; - } - - /** - * Gets the processingMetricsInterval. - * - *

Specifies the interval in real wall-clock seconds at which the service is to return - * processing metrics. The parameter is ignored unless the `processing_metrics` parameter is set - * to `true`. - * - *

The parameter accepts a minimum value of 0.1 seconds. The level of precision is not - * restricted, so you can specify values such as 0.25 and 0.125. - * - *

The service does not impose a maximum value. If you want to receive processing metrics - * only for transcription events instead of at periodic intervals, set the value to a large - * number. If the value is larger than the duration of the audio, the service returns processing - * metrics only for transcription events. - * - *

NOTE: This parameter only works for the `recognizeUsingWebSocket` method. - * - * @return the processingMetricsInterval - */ - public Float processingMetricsInterval() { - return processingMetricsInterval; - } - - /** - * Set the interimResults. - * - *

NOTE: This parameter only works for the `recognizeUsingWebSocket` method. - * - * @param interimResults the interimResults - * @return the interimResults - */ - public Builder interimResults(Boolean interimResults) { - this.interimResults = interimResults; - return this; - } - - /** - * Set the processingMetrics. - * - *

NOTE: This parameter only works for the `recognizeUsingWebSocket` method. - * - * @param processingMetrics the processingMetrics - * @return the processingMetrics - */ - public Builder processingMetrics(Boolean processingMetrics) { - this.processingMetrics = processingMetrics; - return this; - } - - /** - * Set the processingMetricsInterval. - * - *

NOTE: This parameter only works for the `recognizeUsingWebSocket` method. - * - * @param processingMetricsInterval the processingMetricsInterval - * @return the processingMetricsInterval - */ - public Builder processingMetricsInterval(Float processingMetricsInterval) { - this.processingMetricsInterval = processingMetricsInterval; - return this; - } - /** * Set the audio. * @@ -642,9 +539,6 @@ protected RecognizeOptions(Builder builder) { splitTranscriptAtPhraseEnd = builder.splitTranscriptAtPhraseEnd; speechDetectorSensitivity = builder.speechDetectorSensitivity; backgroundAudioSuppression = builder.backgroundAudioSuppression; - interimResults = builder.interimResults; - processingMetrics = builder.processingMetrics; - processingMetricsInterval = builder.processingMetricsInterval; } /** diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/RegisterCallbackOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/RegisterCallbackOptions.java index 5f050becb18..8a9a18a269b 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/RegisterCallbackOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/RegisterCallbackOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -45,7 +45,7 @@ public Builder(String callbackUrl) { /** * Builds a RegisterCallbackOptions. * - * @return the registerCallbackOptions + * @return the new RegisterCallbackOptions instance */ public RegisterCallbackOptions build() { return new RegisterCallbackOptions(this); diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/RegisterStatus.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/RegisterStatus.java index 3760722214d..b8875963227 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/RegisterStatus.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/RegisterStatus.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ResetAcousticModelOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ResetAcousticModelOptions.java index f1385662a30..ad93c93ecf0 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ResetAcousticModelOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ResetAcousticModelOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -42,7 +42,7 @@ public Builder(String customizationId) { /** * Builds a ResetAcousticModelOptions. * - * @return the resetAcousticModelOptions + * @return the new ResetAcousticModelOptions instance */ public ResetAcousticModelOptions build() { return new ResetAcousticModelOptions(this); diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ResetLanguageModelOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ResetLanguageModelOptions.java index 4cb7511be1c..2976de872e9 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ResetLanguageModelOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ResetLanguageModelOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -42,7 +42,7 @@ public Builder(String customizationId) { /** * Builds a ResetLanguageModelOptions. * - * @return the resetLanguageModelOptions + * @return the new ResetLanguageModelOptions instance */ public ResetLanguageModelOptions build() { return new ResetLanguageModelOptions(this); diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeakerLabelsResult.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeakerLabelsResult.java index 67897fbf349..9b6e21e91e0 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeakerLabelsResult.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeakerLabelsResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechModel.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechModel.java index 7dcdc8d3611..2408ceac665 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechModel.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechModel.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2016, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechModels.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechModels.java index 73fa92b4543..68130d3ac50 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechModels.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechModels.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionAlternative.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionAlternative.java index da4516574c9..5ee36370d52 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionAlternative.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionAlternative.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -21,10 +21,10 @@ public class SpeechRecognitionAlternative extends GenericModel { protected String transcript; protected Double confidence; - protected List timestamps; + protected List timestamps; @SerializedName("word_confidence") - protected List wordConfidence; + protected List wordConfidence; /** * Gets the transcript. @@ -60,7 +60,7 @@ public Double getConfidence() { * * @return the timestamps */ - public List getTimestamps() { + public List getTimestamps() { return timestamps; } @@ -74,7 +74,7 @@ public List getTimestamps() { * * @return the wordConfidence */ - public List getWordConfidence() { + public List getWordConfidence() { return wordConfidence; } } diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionResult.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionResult.java index 8bb28bdafd3..3d0b49fd48e 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionResult.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionResults.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionResults.java index ce1dbd47564..a66cf1e65ae 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionResults.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionResults.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechTimestamp.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechTimestamp.java deleted file mode 100644 index 903e78d5f30..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechTimestamp.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.watson.speech_to_text.v1.model; - -import com.google.gson.annotations.JsonAdapter; -import com.ibm.cloud.sdk.core.service.model.GenericModel; -import com.ibm.watson.speech_to_text.v1.util.SpeechTimestampTypeAdapter; - -/** Transcription timestamp. */ -@JsonAdapter(SpeechTimestampTypeAdapter.class) -public class SpeechTimestamp extends GenericModel { - private Double endTime; - private Double startTime; - private String word; - - /** - * Gets the end time. - * - * @return The end time - */ - public Double getEndTime() { - return endTime; - } - - /** - * Gets the start time. - * - * @return The start time - */ - public Double getStartTime() { - return startTime; - } - - /** - * Gets the word. - * - * @return The word - */ - public String getWord() { - return word; - } - - /** - * Sets the end time. - * - * @param endTime The end time - */ - public void setEndTime(final Double endTime) { - this.endTime = endTime; - } - - /** - * Sets the start time. - * - * @param startTime The start time - */ - public void setStartTime(final Double startTime) { - this.startTime = startTime; - } - - /** - * Sets the word. - * - * @param word The word - */ - public void setWord(final String word) { - this.word = word; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechWordConfidence.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechWordConfidence.java deleted file mode 100644 index 67fdd84838b..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechWordConfidence.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019, 2020. - * - * 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.watson.speech_to_text.v1.model; - -import com.google.gson.annotations.JsonAdapter; -import com.ibm.cloud.sdk.core.service.model.GenericModel; -import com.ibm.watson.speech_to_text.v1.util.SpeechWordConfidenceTypeAdapter; - -/** Transcription word confidence. */ -@JsonAdapter(SpeechWordConfidenceTypeAdapter.class) -public class SpeechWordConfidence extends GenericModel { - private Double confidence; - private String word; - - /** - * Gets the confidence. - * - * @return The confidence - */ - public Double getConfidence() { - return confidence; - } - - /** - * Gets the word. - * - * @return The word - */ - public String getWord() { - return word; - } - - /** - * Sets the confidence. - * - * @param confidence The confidence - */ - public void setConfidence(final Double confidence) { - this.confidence = confidence; - } - - /** - * Sets the word. - * - * @param word The word - */ - public void setWord(final String word) { - this.word = word; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SupportedFeatures.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SupportedFeatures.java index f3f2b53f231..bcf14ba1ada 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SupportedFeatures.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SupportedFeatures.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/TrainAcousticModelOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/TrainAcousticModelOptions.java index 2023b08443f..c88ce8299b3 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/TrainAcousticModelOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/TrainAcousticModelOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -45,7 +45,7 @@ public Builder(String customizationId) { /** * Builds a TrainAcousticModelOptions. * - * @return the trainAcousticModelOptions + * @return the new TrainAcousticModelOptions instance */ public TrainAcousticModelOptions build() { return new TrainAcousticModelOptions(this); diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/TrainLanguageModelOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/TrainLanguageModelOptions.java index ae170f65df2..f108093bd1b 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/TrainLanguageModelOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/TrainLanguageModelOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -62,7 +62,7 @@ public Builder(String customizationId) { /** * Builds a TrainLanguageModelOptions. * - * @return the trainLanguageModelOptions + * @return the new TrainLanguageModelOptions instance */ public TrainLanguageModelOptions build() { return new TrainLanguageModelOptions(this); diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/TrainingResponse.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/TrainingResponse.java index 9209f2dd476..de2d23bfdc5 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/TrainingResponse.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/TrainingResponse.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/TrainingWarning.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/TrainingWarning.java index e264bc61a6d..b6689c07ca0 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/TrainingWarning.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/TrainingWarning.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/UnregisterCallbackOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/UnregisterCallbackOptions.java index 8c4e0932749..3a90a1b5e4d 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/UnregisterCallbackOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/UnregisterCallbackOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -42,7 +42,7 @@ public Builder(String callbackUrl) { /** * Builds a UnregisterCallbackOptions. * - * @return the unregisterCallbackOptions + * @return the new UnregisterCallbackOptions instance */ public UnregisterCallbackOptions build() { return new UnregisterCallbackOptions(this); diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/UpgradeAcousticModelOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/UpgradeAcousticModelOptions.java index 5508b02fef8..44bfad6fd17 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/UpgradeAcousticModelOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/UpgradeAcousticModelOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -48,7 +48,7 @@ public Builder(String customizationId) { /** * Builds a UpgradeAcousticModelOptions. * - * @return the upgradeAcousticModelOptions + * @return the new UpgradeAcousticModelOptions instance */ public UpgradeAcousticModelOptions build() { return new UpgradeAcousticModelOptions(this); diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/UpgradeLanguageModelOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/UpgradeLanguageModelOptions.java index b42db698b6e..3def95b954a 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/UpgradeLanguageModelOptions.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/UpgradeLanguageModelOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -42,7 +42,7 @@ public Builder(String customizationId) { /** * Builds a UpgradeLanguageModelOptions. * - * @return the upgradeLanguageModelOptions + * @return the new UpgradeLanguageModelOptions instance */ public UpgradeLanguageModelOptions build() { return new UpgradeLanguageModelOptions(this); diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/Word.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/Word.java index 5dc4aa4cdf6..01b885189bf 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/Word.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/Word.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2016, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/WordAlternativeResult.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/WordAlternativeResult.java index 59ad4ec2503..022ce2f4297 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/WordAlternativeResult.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/WordAlternativeResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/WordAlternativeResults.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/WordAlternativeResults.java index 4107f5865bc..d6d30528ead 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/WordAlternativeResults.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/WordAlternativeResults.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/WordError.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/WordError.java index 9c710ce4609..2f036656d5b 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/WordError.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/WordError.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/Words.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/Words.java index b7e8b7a2cd4..2e38fc08cf9 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/Words.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/Words.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/package-info.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/package-info.java index 30434f58d3e..cf231a8cb34 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/package-info.java +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/package-info.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/SpeechToTextTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/SpeechToTextTest.java index 36c7edc3b7b..0e179d42b4b 100755 --- a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/SpeechToTextTest.java +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/SpeechToTextTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -12,21 +12,13 @@ */ package com.ibm.watson.speech_to_text.v1; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.testng.Assert.*; -import com.google.gson.Gson; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import com.ibm.cloud.sdk.core.http.HttpMediaType; +import com.ibm.cloud.sdk.core.http.Response; +import com.ibm.cloud.sdk.core.security.Authenticator; import com.ibm.cloud.sdk.core.security.NoAuthAuthenticator; -import com.ibm.cloud.sdk.core.util.GsonSingleton; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; import com.ibm.cloud.sdk.core.util.RequestUtils; -import com.ibm.watson.common.TestUtils; -import com.ibm.watson.common.WatsonServiceUnitTest; import com.ibm.watson.speech_to_text.v1.model.AcousticModel; import com.ibm.watson.speech_to_text.v1.model.AcousticModels; import com.ibm.watson.speech_to_text.v1.model.AddAudioOptions; @@ -35,10 +27,11 @@ import com.ibm.watson.speech_to_text.v1.model.AddWordOptions; import com.ibm.watson.speech_to_text.v1.model.AddWordsOptions; import com.ibm.watson.speech_to_text.v1.model.AudioListing; -import com.ibm.watson.speech_to_text.v1.model.AudioResource; import com.ibm.watson.speech_to_text.v1.model.AudioResources; import com.ibm.watson.speech_to_text.v1.model.CheckJobOptions; +import com.ibm.watson.speech_to_text.v1.model.CheckJobsOptions; import com.ibm.watson.speech_to_text.v1.model.Corpora; +import com.ibm.watson.speech_to_text.v1.model.Corpus; import com.ibm.watson.speech_to_text.v1.model.CreateAcousticModelOptions; import com.ibm.watson.speech_to_text.v1.model.CreateJobOptions; import com.ibm.watson.speech_to_text.v1.model.CreateLanguageModelOptions; @@ -67,6 +60,7 @@ import com.ibm.watson.speech_to_text.v1.model.ListCorporaOptions; import com.ibm.watson.speech_to_text.v1.model.ListGrammarsOptions; import com.ibm.watson.speech_to_text.v1.model.ListLanguageModelsOptions; +import com.ibm.watson.speech_to_text.v1.model.ListModelsOptions; import com.ibm.watson.speech_to_text.v1.model.ListWordsOptions; import com.ibm.watson.speech_to_text.v1.model.RecognitionJob; import com.ibm.watson.speech_to_text.v1.model.RecognitionJobs; @@ -77,1855 +71,2278 @@ import com.ibm.watson.speech_to_text.v1.model.ResetLanguageModelOptions; import com.ibm.watson.speech_to_text.v1.model.SpeechModel; import com.ibm.watson.speech_to_text.v1.model.SpeechModels; -import com.ibm.watson.speech_to_text.v1.model.SpeechRecognitionResult; import com.ibm.watson.speech_to_text.v1.model.SpeechRecognitionResults; import com.ibm.watson.speech_to_text.v1.model.TrainAcousticModelOptions; import com.ibm.watson.speech_to_text.v1.model.TrainLanguageModelOptions; +import com.ibm.watson.speech_to_text.v1.model.TrainingResponse; import com.ibm.watson.speech_to_text.v1.model.UnregisterCallbackOptions; import com.ibm.watson.speech_to_text.v1.model.UpgradeAcousticModelOptions; import com.ibm.watson.speech_to_text.v1.model.UpgradeLanguageModelOptions; import com.ibm.watson.speech_to_text.v1.model.Word; import com.ibm.watson.speech_to_text.v1.model.Words; -import com.ibm.watson.speech_to_text.v1.util.MediaTypeUtils; -import com.ibm.watson.speech_to_text.v1.websocket.RecognizeCallback; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; import java.io.IOException; import java.io.InputStream; -import java.io.PipedInputStream; -import java.io.PipedOutputStream; -import java.net.URISyntaxException; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.TimeUnit; -import okhttp3.WebSocket; -import okhttp3.internal.ws.WebSocketRecorder; import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; import okhttp3.mockwebserver.RecordedRequest; -import okio.ByteString; -import org.apache.commons.lang3.StringUtils; -import org.junit.Before; -import org.junit.FixMethodOrder; -import org.junit.Test; -import org.junit.runners.MethodSorters; - -/** The Class SpeechToTextTest. */ -@FixMethodOrder(MethodSorters.JVM) -public class SpeechToTextTest extends WatsonServiceUnitTest { - - private static final Gson GSON = GsonSingleton.getGsonWithoutPrettyPrinting(); - - private static final String PATH_CORPORA = "/v1/customizations/%s/corpora"; - private static final String PATH_CORPUS = "/v1/customizations/%s/corpora/%s"; - private static final String PATH_CUSTOMIZATION = "/v1/customizations/%s"; - private static final String PATH_CUSTOMIZATIONS = "/v1/customizations"; - private static final String PATH_ACOUSTIC_CUSTOMIZATION = "/v1/acoustic_customizations/%s"; - private static final String PATH_ACOUSTIC_CUSTOMIZATIONS = "/v1/acoustic_customizations"; - private static final String PATH_MODELS = "/v1/models"; - private static final String PATH_RECOGNITION = "/v1/recognitions/%s"; - private static final String PATH_RECOGNITIONS = "/v1/recognitions"; - private static final String PATH_RECOGNIZE = "/v1/recognize"; - private static final String PATH_ACOUSTIC_RESET = "/v1/acoustic_customizations/%s/reset"; - private static final String PATH_RESET = "/v1/customizations/%s/reset"; - private static final String PATH_ACOUSTIC_TRAIN = "/v1/acoustic_customizations/%s/train"; - private static final String PATH_TRAIN = "/v1/customizations/%s/train"; - private static final String PATH_WORDS = "/v1/customizations/%s/words"; - private static final String PATH_WORD = "/v1/customizations/%s/words/%s"; - private static final String PATH_ACOUSTIC_UPGRADE = - "/v1/acoustic_customizations/%s/upgrade_model"; - private static final String PATH_UPGRADE = "/v1/customizations/%s/upgrade_model"; - private static final String PATH_ALL_AUDIO = "/v1/acoustic_customizations/%s/audio"; - private static final String PATH_SPECIFIC_AUDIO = "/v1/acoustic_customizations/%s/audio/%s"; - private static final String REGISTER_CALLBACK = - "/v1/register_callback?callback_url=%s&user_secret=%s"; - private static final String UNREGISTER_CALLBACK = "/v1/unregister_callback?callback_url=%s"; - - private static final File SAMPLE_WAV = new File("src/test/resources/speech_to_text/sample1.wav"); - private static final File SAMPLE_WEBM = - new File("src/test/resources/speech_to_text/sample1.webm"); - - private static final String UPDATED = "2019-10-11T19:16:58.547Z"; - - private SpeechModel speechModel; - private SpeechModels speechModels; - private SpeechRecognitionResults recognitionResults; - private Grammars grammars; - private Grammar grammar; - - private SpeechToText service; - - /** - * Sets up the tests. - * - * @throws Exception the exception - */ - /* - * (non-Javadoc) - * @see com.ibm.watson.common.WatsonServiceTest#setUp() - */ - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - - service = new SpeechToText(new NoAuthAuthenticator()); - service.setServiceUrl(getMockWebServerUrl()); - - speechModel = - loadFixture("src/test/resources/speech_to_text/speech-model.json", SpeechModel.class); - speechModels = - loadFixture("src/test/resources/speech_to_text/speech-models.json", SpeechModels.class); - recognitionResults = - loadFixture( - "src/test/resources/speech_to_text/recognition-results.json", - SpeechRecognitionResults.class); - grammars = loadFixture("src/test/resources/speech_to_text/grammar_list.json", Grammars.class); - grammar = loadFixture("src/test/resources/speech_to_text/grammar.json", Grammar.class); - } - - // --- MODELS --- - - /** Test delete user data options builder. */ - @Test - public void testDeleteUserDataOptionsBuilder() { - String customerId = "customerId"; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; - DeleteUserDataOptions deleteOptions = - new DeleteUserDataOptions.Builder().customerId(customerId).build(); +/** Unit test class for the SpeechToText service. */ +public class SpeechToTextTest { - assertEquals(deleteOptions.customerId(), customerId); - } + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); - /** - * Test add grammar options. - * - * @throws FileNotFoundException the file not found exception - */ - @Test - public void testAddGrammarOptions() throws FileNotFoundException { - String customizationId = "id"; - String grammarName = "grammar_name"; - InputStream grammarFile = new FileInputStream(SAMPLE_WAV); + protected MockWebServer server; + protected SpeechToText speechToTextService; - AddGrammarOptions addGrammarOptions = - new AddGrammarOptions.Builder() - .customizationId(customizationId) - .grammarName(grammarName) - .grammarFile(grammarFile) - .contentType("application/srgs") - .allowOverwrite(true) - .build(); + public void constructClientService() throws Throwable { + final String serviceName = "testService"; - assertEquals(customizationId, addGrammarOptions.customizationId()); - assertEquals(grammarName, addGrammarOptions.grammarName()); - assertEquals(grammarFile, addGrammarOptions.grammarFile()); - assertEquals("application/srgs", addGrammarOptions.contentType()); - assertTrue(addGrammarOptions.allowOverwrite()); - } + final Authenticator authenticator = new NoAuthAuthenticator(); - /** Test list grammars options. */ - @Test - public void testListGrammarsOptions() { - String customizationId = "id"; - - ListGrammarsOptions listGrammarsOptions = - new ListGrammarsOptions.Builder().customizationId(customizationId).build(); - - assertEquals(customizationId, listGrammarsOptions.customizationId()); + speechToTextService = new SpeechToText(serviceName, authenticator); + String url = server.url("/").toString(); + speechToTextService.setServiceUrl(url); } - /** Test get grammar options. */ - @Test - public void testGetGrammarOptions() { - String customizationId = "id"; - String grammarName = "grammar_name"; - - GetGrammarOptions getGrammarOptions = - new GetGrammarOptions.Builder() - .customizationId(customizationId) - .grammarName(grammarName) - .build(); + /** Negative Test - construct the service with a null authenticator. */ + @Test(expectedExceptions = IllegalArgumentException.class) + public void testConstructorWithNullAuthenticator() throws Throwable { + final String serviceName = "testService"; - assertEquals(customizationId, getGrammarOptions.customizationId()); - assertEquals(grammarName, getGrammarOptions.grammarName()); + new SpeechToText(serviceName, null); } - /** Test delete grammar options. */ @Test - public void testDeleteGrammarOptions() { - String customizationId = "id"; - String grammarName = "grammar_name"; + public void testListModelsWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"models\": [{\"name\": \"name\", \"language\": \"language\", \"rate\": 4, \"url\": \"url\", \"supported_features\": {\"custom_language_model\": false, \"speaker_labels\": false}, \"description\": \"description\"}]}"; + String listModelsPath = "/v1/models"; - DeleteGrammarOptions deleteGrammarOptions = - new DeleteGrammarOptions.Builder() - .customizationId(customizationId) - .grammarName(grammarName) - .build(); + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); - assertEquals(customizationId, deleteGrammarOptions.customizationId()); - assertEquals(grammarName, deleteGrammarOptions.grammarName()); - } + constructClientService(); - // --- METHODS --- + // Construct an instance of the ListModelsOptions model + ListModelsOptions listModelsOptionsModel = new ListModelsOptions(); - /** - * Test get model. - * - * @throws Exception the exception - */ - @Test - public void testGetModel() throws Exception { - final MockResponse mockResponse = - new MockResponse() - .addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON) - .setBody(GSON.toJson(speechModel)); + // Invoke operation with valid options model (positive test) + Response response = + speechToTextService.listModels(listModelsOptionsModel).execute(); + assertNotNull(response); + SpeechModels responseObj = response.getResult(); + assertNotNull(responseObj); - server.enqueue(mockResponse); - GetModelOptions getOptionsString = - new GetModelOptions.Builder().modelId("not-a-real-Model").build(); - SpeechModel model = service.getModel(getOptionsString).execute().getResult(); + // Verify the contents of the request RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); - assertNotNull(model); - assertEquals(model, speechModel); - assertEquals(GET, request.getMethod()); - - server.enqueue(mockResponse); - GetModelOptions getOptionsGetter = - new GetModelOptions.Builder().modelId("not-a-real-Model").build(); - model = service.getModel(getOptionsGetter).execute().getResult(); - request = server.takeRequest(); + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNull(query); - assertNotNull(model); - assertEquals(model, speechModel); - assertEquals(GET, request.getMethod()); - - TestUtils.assertNoExceptionsOnGetters(model); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listModelsPath); } - /** - * Test get models. - * - * @throws InterruptedException the interrupted exception - */ @Test - public void testGetModels() throws InterruptedException { + public void testGetModelWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"name\": \"name\", \"language\": \"language\", \"rate\": 4, \"url\": \"url\", \"supported_features\": {\"custom_language_model\": false, \"speaker_labels\": false}, \"description\": \"description\"}"; + String getModelPath = "/v1/models/ar-AR_BroadbandModel"; + server.enqueue( new MockResponse() - .addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON) - .setBody(GSON.toJson(speechModels))); + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the GetModelOptions model + GetModelOptions getModelOptionsModel = + new GetModelOptions.Builder().modelId("ar-AR_BroadbandModel").build(); + + // Invoke operation with valid options model (positive test) + Response response = speechToTextService.getModel(getModelOptionsModel).execute(); + assertNotNull(response); + SpeechModel responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); - final SpeechModels models = service.listModels().execute().getResult(); - final RecordedRequest request = server.takeRequest(); + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNull(query); - assertNotNull(models); - assertFalse(models.getModels().isEmpty()); - assertEquals(models.getModels(), speechModels.getModels()); - assertEquals(PATH_MODELS, request.getPath()); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getModelPath); } - /** Test get model with null. */ - @Test(expected = IllegalArgumentException.class) - public void testGetModelWithNull() { - service.getModel(null).execute().getResult(); + // Test the getModel operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetModelNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + speechToTextService.getModel(null).execute(); } - /** - * Test recognize. - * - * @throws URISyntaxException the URI syntax exception - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ @Test - public void testRecognize() - throws URISyntaxException, InterruptedException, FileNotFoundException { + public void testRecognizeWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"results\": [{\"final\": true, \"alternatives\": [{\"transcript\": \"transcript\", \"confidence\": 0, \"timestamps\": [\"timestamps\"], \"word_confidence\": [\"wordConfidence\"]}], \"keywords_result\": {\"mapKey\": [{\"normalized_text\": \"normalizedText\", \"start_time\": 9, \"end_time\": 7, \"confidence\": 0}]}, \"word_alternatives\": [{\"start_time\": 9, \"end_time\": 7, \"alternatives\": [{\"confidence\": 0, \"word\": \"word\"}]}], \"end_of_utterance\": \"end_of_data\"}], \"result_index\": 11, \"speaker_labels\": [{\"from\": 4, \"to\": 2, \"speaker\": 7, \"confidence\": 10, \"final\": true}], \"processing_metrics\": {\"processed_audio\": {\"received\": 8, \"seen_by_engine\": 12, \"transcription\": 13, \"speaker_labels\": 13}, \"wall_clock_since_first_byte_received\": 31, \"periodic\": true}, \"audio_metrics\": {\"sampling_interval\": 16, \"accumulated\": {\"final\": true, \"end_time\": 7, \"signal_to_noise_ratio\": 18, \"speech_ratio\": 11, \"high_frequency_loss\": 17, \"direct_current_offset\": [{\"begin\": 5, \"end\": 3, \"count\": 5}], \"clipping_rate\": [{\"begin\": 5, \"end\": 3, \"count\": 5}], \"speech_level\": [{\"begin\": 5, \"end\": 3, \"count\": 5}], \"non_speech_level\": [{\"begin\": 5, \"end\": 3, \"count\": 5}]}}, \"warnings\": [\"warnings\"]}"; + String recognizePath = "/v1/recognize"; + server.enqueue( new MockResponse() - .addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON) - .setBody(GSON.toJson(recognitionResults))); + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); - RecognizeOptions recognizeOptions = + // Construct an instance of the RecognizeOptions model + RecognizeOptions recognizeOptionsModel = new RecognizeOptions.Builder() - .audio(SAMPLE_WAV) - .contentType(HttpMediaType.AUDIO_WAV) + .audio(TestUtilities.createMockStream("This is a mock file.")) + .contentType("application/octet-stream") + .model("ar-AR_BroadbandModel") + .languageCustomizationId("testString") + .acousticCustomizationId("testString") + .baseModelVersion("testString") + .customizationWeight(Double.valueOf("72.5")) + .inactivityTimeout(Long.valueOf("26")) + .keywords(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .keywordsThreshold(Float.valueOf("36.0")) + .maxAlternatives(Long.valueOf("26")) + .wordAlternativesThreshold(Float.valueOf("36.0")) + .wordConfidence(true) + .timestamps(true) + .profanityFilter(true) + .smartFormatting(true) + .speakerLabels(true) + .customizationId("testString") + .grammarName("testString") + .redaction(true) .audioMetrics(true) - .endOfPhraseSilenceTime(2.0) + .endOfPhraseSilenceTime(Double.valueOf("72.5")) .splitTranscriptAtPhraseEnd(true) + .speechDetectorSensitivity(Float.valueOf("36.0")) + .backgroundAudioSuppression(Float.valueOf("36.0")) .build(); - assertEquals((Double) 2.0, recognizeOptions.endOfPhraseSilenceTime()); - assertTrue(recognizeOptions.splitTranscriptAtPhraseEnd()); - - final SpeechRecognitionResults result = - service.recognize(recognizeOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); + // Invoke operation with valid options model (positive test) + Response response = + speechToTextService.recognize(recognizeOptionsModel).execute(); + assertNotNull(response); + SpeechRecognitionResults responseObj = response.getResult(); + assertNotNull(responseObj); - assertNotNull(result); - assertEquals(result, recognitionResults); - assertEquals("POST", request.getMethod()); - assertEquals( - PATH_RECOGNIZE - + "?audio_metrics=true&end_of_phrase_silence_time=2.0&split_transcript_at_phrase_end=true", - request.getPath()); - assertEquals(HttpMediaType.AUDIO_WAV, request.getHeader(CONTENT_TYPE)); - assertEquals( - recognitionResults.getAudioMetrics().getSamplingInterval(), - result.getAudioMetrics().getSamplingInterval()); - assertEquals( - recognitionResults.getAudioMetrics().getAccumulated().isXFinal(), - result.getAudioMetrics().getAccumulated().isXFinal()); - assertEquals( - recognitionResults.getAudioMetrics().getAccumulated().getEndTime(), - result.getAudioMetrics().getAccumulated().getEndTime()); - assertEquals( - recognitionResults.getAudioMetrics().getAccumulated().getSpeechRatio(), - result.getAudioMetrics().getAccumulated().getSpeechRatio()); - assertEquals( - recognitionResults.getAudioMetrics().getAccumulated().getHighFrequencyLoss(), - result.getAudioMetrics().getAccumulated().getHighFrequencyLoss()); - assertEquals( - recognitionResults.getAudioMetrics().getAccumulated().getSignalToNoiseRatio(), - result.getAudioMetrics().getAccumulated().getSignalToNoiseRatio()); - assertEquals( - recognitionResults - .getAudioMetrics() - .getAccumulated() - .getDirectCurrentOffset() - .get(0) - .getBegin(), - result.getAudioMetrics().getAccumulated().getDirectCurrentOffset().get(0).getBegin()); - assertEquals( - recognitionResults - .getAudioMetrics() - .getAccumulated() - .getDirectCurrentOffset() - .get(0) - .getEnd(), - result.getAudioMetrics().getAccumulated().getDirectCurrentOffset().get(0).getEnd()); - assertEquals( - recognitionResults - .getAudioMetrics() - .getAccumulated() - .getDirectCurrentOffset() - .get(0) - .getCount(), - result.getAudioMetrics().getAccumulated().getDirectCurrentOffset().get(0).getCount()); - assertEquals( - recognitionResults.getAudioMetrics().getAccumulated().getClippingRate().get(0).getBegin(), - result.getAudioMetrics().getAccumulated().getClippingRate().get(0).getBegin()); - assertEquals( - recognitionResults.getAudioMetrics().getAccumulated().getClippingRate().get(0).getEnd(), - result.getAudioMetrics().getAccumulated().getClippingRate().get(0).getEnd()); - assertEquals( - recognitionResults.getAudioMetrics().getAccumulated().getClippingRate().get(0).getCount(), - result.getAudioMetrics().getAccumulated().getClippingRate().get(0).getCount()); - assertEquals( - recognitionResults.getAudioMetrics().getAccumulated().getSpeechLevel().get(0).getBegin(), - result.getAudioMetrics().getAccumulated().getSpeechLevel().get(0).getBegin()); - assertEquals( - recognitionResults.getAudioMetrics().getAccumulated().getSpeechLevel().get(0).getEnd(), - result.getAudioMetrics().getAccumulated().getSpeechLevel().get(0).getEnd()); - assertEquals( - recognitionResults.getAudioMetrics().getAccumulated().getSpeechLevel().get(0).getCount(), - result.getAudioMetrics().getAccumulated().getSpeechLevel().get(0).getCount()); - assertEquals( - recognitionResults.getAudioMetrics().getAccumulated().getNonSpeechLevel().get(0).getBegin(), - result.getAudioMetrics().getAccumulated().getNonSpeechLevel().get(0).getBegin()); - assertEquals( - recognitionResults.getAudioMetrics().getAccumulated().getNonSpeechLevel().get(0).getEnd(), - result.getAudioMetrics().getAccumulated().getNonSpeechLevel().get(0).getEnd()); + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("model"), "ar-AR_BroadbandModel"); + assertEquals(query.get("language_customization_id"), "testString"); + assertEquals(query.get("acoustic_customization_id"), "testString"); + assertEquals(query.get("base_model_version"), "testString"); + assertEquals(Double.valueOf(query.get("customization_weight")), Double.valueOf("72.5")); + assertEquals(Long.valueOf(query.get("inactivity_timeout")), Long.valueOf("26")); assertEquals( - recognitionResults.getAudioMetrics().getAccumulated().getNonSpeechLevel().get(0).getCount(), - result.getAudioMetrics().getAccumulated().getNonSpeechLevel().get(0).getCount()); + query.get("keywords"), + RequestUtils.join( + new java.util.ArrayList(java.util.Arrays.asList("testString")), ",")); + assertEquals(Float.valueOf(query.get("keywords_threshold")), Float.valueOf("36.0")); + assertEquals(Long.valueOf(query.get("max_alternatives")), Long.valueOf("26")); + assertEquals(Float.valueOf(query.get("word_alternatives_threshold")), Float.valueOf("36.0")); + assertEquals(Boolean.valueOf(query.get("word_confidence")), Boolean.valueOf(true)); + assertEquals(Boolean.valueOf(query.get("timestamps")), Boolean.valueOf(true)); + assertEquals(Boolean.valueOf(query.get("profanity_filter")), Boolean.valueOf(true)); + assertEquals(Boolean.valueOf(query.get("smart_formatting")), Boolean.valueOf(true)); + assertEquals(Boolean.valueOf(query.get("speaker_labels")), Boolean.valueOf(true)); + assertEquals(query.get("customization_id"), "testString"); + assertEquals(query.get("grammar_name"), "testString"); + assertEquals(Boolean.valueOf(query.get("redaction")), Boolean.valueOf(true)); + assertEquals(Boolean.valueOf(query.get("audio_metrics")), Boolean.valueOf(true)); + assertEquals(Double.valueOf(query.get("end_of_phrase_silence_time")), Double.valueOf("72.5")); assertEquals( - SpeechRecognitionResult.EndOfUtterance.END_OF_DATA, - recognitionResults.getResults().get(0).getEndOfUtterance()); + Boolean.valueOf(query.get("split_transcript_at_phrase_end")), Boolean.valueOf(true)); + assertEquals(Float.valueOf(query.get("speech_detector_sensitivity")), Float.valueOf("36.0")); + assertEquals(Float.valueOf(query.get("background_audio_suppression")), Float.valueOf("36.0")); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, recognizePath); + } + + // Test the recognize operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testRecognizeNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + speechToTextService.recognize(null).execute(); } - /** - * Test recognize WebM for WebM audio format. - * - * @throws URISyntaxException the URI syntax exception - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ @Test - public void testRecognizeWebM() - throws URISyntaxException, InterruptedException, FileNotFoundException { + public void testRegisterCallbackWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = "{\"status\": \"created\", \"url\": \"url\"}"; + String registerCallbackPath = "/v1/register_callback"; + server.enqueue( new MockResponse() - .addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON) - .setBody(GSON.toJson(recognitionResults))); + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); - RecognizeOptions recognizeOptions = - new RecognizeOptions.Builder() - .audio(SAMPLE_WEBM) - .contentType(HttpMediaType.AUDIO_WEBM) + constructClientService(); + + // Construct an instance of the RegisterCallbackOptions model + RegisterCallbackOptions registerCallbackOptionsModel = + new RegisterCallbackOptions.Builder() + .callbackUrl("testString") + .userSecret("testString") .build(); - final SpeechRecognitionResults result = - service.recognize(recognizeOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - - assertNotNull(result); - assertEquals(result, recognitionResults); - assertEquals("POST", request.getMethod()); - assertEquals(PATH_RECOGNIZE, request.getPath()); - assertEquals(HttpMediaType.AUDIO_WEBM, request.getHeader(CONTENT_TYPE)); - } - - /** - * Test diarization. - * - * @throws URISyntaxException the URI syntax exception - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ + + // Invoke operation with valid options model (positive test) + Response response = + speechToTextService.registerCallback(registerCallbackOptionsModel).execute(); + assertNotNull(response); + RegisterStatus responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("callback_url"), "testString"); + assertEquals(query.get("user_secret"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, registerCallbackPath); + } + + // Test the registerCallback operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testRegisterCallbackNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + speechToTextService.registerCallback(null).execute(); + } + @Test - public void testRecognizeWithSpeakerLabels() - throws URISyntaxException, InterruptedException, FileNotFoundException { - FileInputStream jsonFile = - new FileInputStream("src/test/resources/speech_to_text/diarization.json"); - String diarizationStr = getStringFromInputStream(jsonFile); - JsonObject diarization = new JsonParser().parse(diarizationStr).getAsJsonObject(); + public void testUnregisterCallbackWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String unregisterCallbackPath = "/v1/unregister_callback"; - server.enqueue( - new MockResponse() - .addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON) - .setBody(diarizationStr)); + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); - RecognizeOptions recognizeOptions = - new RecognizeOptions.Builder() - .audio(SAMPLE_WAV) - .contentType(HttpMediaType.AUDIO_WAV) - .speakerLabels(true) - .build(); - SpeechRecognitionResults result = service.recognize(recognizeOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); + constructClientService(); + + // Construct an instance of the UnregisterCallbackOptions model + UnregisterCallbackOptions unregisterCallbackOptionsModel = + new UnregisterCallbackOptions.Builder().callbackUrl("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = + speechToTextService.unregisterCallback(unregisterCallbackOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("callback_url"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, unregisterCallbackPath); + } - assertEquals("POST", request.getMethod()); - assertEquals(PATH_RECOGNIZE + "?speaker_labels=true", request.getPath()); - assertEquals(diarization.toString(), GSON.toJsonTree(result).toString()); + // Test the unregisterCallback operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUnregisterCallbackNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + speechToTextService.unregisterCallback(null).execute(); } - /** - * Test recognize with customization. - * - * @throws FileNotFoundException the file not found exception - * @throws InterruptedException the interrupted exception - */ @Test - public void testRecognizeWithCustomization() throws FileNotFoundException, InterruptedException { - String id = "foo"; - String version = "version"; - String recString = - getStringFromInputStream( - new FileInputStream("src/test/resources/speech_to_text/recognition.json")); - JsonObject recognition = new JsonParser().parse(recString).getAsJsonObject(); + public void testCreateJobWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"id\": \"id\", \"status\": \"waiting\", \"created\": \"created\", \"updated\": \"updated\", \"url\": \"url\", \"user_token\": \"userToken\", \"results\": [{\"results\": [{\"final\": true, \"alternatives\": [{\"transcript\": \"transcript\", \"confidence\": 0, \"timestamps\": [\"timestamps\"], \"word_confidence\": [\"wordConfidence\"]}], \"keywords_result\": {\"mapKey\": [{\"normalized_text\": \"normalizedText\", \"start_time\": 9, \"end_time\": 7, \"confidence\": 0}]}, \"word_alternatives\": [{\"start_time\": 9, \"end_time\": 7, \"alternatives\": [{\"confidence\": 0, \"word\": \"word\"}]}], \"end_of_utterance\": \"end_of_data\"}], \"result_index\": 11, \"speaker_labels\": [{\"from\": 4, \"to\": 2, \"speaker\": 7, \"confidence\": 10, \"final\": true}], \"processing_metrics\": {\"processed_audio\": {\"received\": 8, \"seen_by_engine\": 12, \"transcription\": 13, \"speaker_labels\": 13}, \"wall_clock_since_first_byte_received\": 31, \"periodic\": true}, \"audio_metrics\": {\"sampling_interval\": 16, \"accumulated\": {\"final\": true, \"end_time\": 7, \"signal_to_noise_ratio\": 18, \"speech_ratio\": 11, \"high_frequency_loss\": 17, \"direct_current_offset\": [{\"begin\": 5, \"end\": 3, \"count\": 5}], \"clipping_rate\": [{\"begin\": 5, \"end\": 3, \"count\": 5}], \"speech_level\": [{\"begin\": 5, \"end\": 3, \"count\": 5}], \"non_speech_level\": [{\"begin\": 5, \"end\": 3, \"count\": 5}]}}, \"warnings\": [\"warnings\"]}], \"warnings\": [\"warnings\"]}"; + String createJobPath = "/v1/recognitions"; server.enqueue( new MockResponse() - .addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON) - .setBody(recString)); + .setHeader("Content-type", "application/json") + .setResponseCode(201) + .setBody(mockResponseBody)); - RecognizeOptions recognizeOptions = - new RecognizeOptions.Builder() - .audio(SAMPLE_WAV) - .contentType(HttpMediaType.AUDIO_WAV) - .languageCustomizationId(id) - .baseModelVersion(version) + constructClientService(); + + // Construct an instance of the CreateJobOptions model + CreateJobOptions createJobOptionsModel = + new CreateJobOptions.Builder() + .audio(TestUtilities.createMockStream("This is a mock file.")) + .contentType("application/octet-stream") + .model("ar-AR_BroadbandModel") + .callbackUrl("testString") + .events("recognitions.started") + .userToken("testString") + .resultsTtl(Long.valueOf("26")) + .languageCustomizationId("testString") + .acousticCustomizationId("testString") + .baseModelVersion("testString") + .customizationWeight(Double.valueOf("72.5")) + .inactivityTimeout(Long.valueOf("26")) + .keywords(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .keywordsThreshold(Float.valueOf("36.0")) + .maxAlternatives(Long.valueOf("26")) + .wordAlternativesThreshold(Float.valueOf("36.0")) + .wordConfidence(true) + .timestamps(true) + .profanityFilter(true) + .smartFormatting(true) + .speakerLabels(true) + .customizationId("testString") + .grammarName("testString") + .redaction(true) + .processingMetrics(true) + .processingMetricsInterval(Float.valueOf("36.0")) + .audioMetrics(true) + .endOfPhraseSilenceTime(Double.valueOf("72.5")) + .splitTranscriptAtPhraseEnd(true) + .speechDetectorSensitivity(Float.valueOf("36.0")) + .backgroundAudioSuppression(Float.valueOf("36.0")) .build(); - SpeechRecognitionResults result = service.recognize(recognizeOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - assertEquals("POST", request.getMethod()); + // Invoke operation with valid options model (positive test) + Response response = + speechToTextService.createJob(createJobOptionsModel).execute(); + assertNotNull(response); + RecognitionJob responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("model"), "ar-AR_BroadbandModel"); + assertEquals(query.get("callback_url"), "testString"); + assertEquals(query.get("events"), "recognitions.started"); + assertEquals(query.get("user_token"), "testString"); + assertEquals(Long.valueOf(query.get("results_ttl")), Long.valueOf("26")); + assertEquals(query.get("language_customization_id"), "testString"); + assertEquals(query.get("acoustic_customization_id"), "testString"); + assertEquals(query.get("base_model_version"), "testString"); + assertEquals(Double.valueOf(query.get("customization_weight")), Double.valueOf("72.5")); + assertEquals(Long.valueOf(query.get("inactivity_timeout")), Long.valueOf("26")); + assertEquals( + query.get("keywords"), + RequestUtils.join( + new java.util.ArrayList(java.util.Arrays.asList("testString")), ",")); + assertEquals(Float.valueOf(query.get("keywords_threshold")), Float.valueOf("36.0")); + assertEquals(Long.valueOf(query.get("max_alternatives")), Long.valueOf("26")); + assertEquals(Float.valueOf(query.get("word_alternatives_threshold")), Float.valueOf("36.0")); + assertEquals(Boolean.valueOf(query.get("word_confidence")), Boolean.valueOf(true)); + assertEquals(Boolean.valueOf(query.get("timestamps")), Boolean.valueOf(true)); + assertEquals(Boolean.valueOf(query.get("profanity_filter")), Boolean.valueOf(true)); + assertEquals(Boolean.valueOf(query.get("smart_formatting")), Boolean.valueOf(true)); + assertEquals(Boolean.valueOf(query.get("speaker_labels")), Boolean.valueOf(true)); + assertEquals(query.get("customization_id"), "testString"); + assertEquals(query.get("grammar_name"), "testString"); + assertEquals(Boolean.valueOf(query.get("redaction")), Boolean.valueOf(true)); + assertEquals(Boolean.valueOf(query.get("processing_metrics")), Boolean.valueOf(true)); + assertEquals(Float.valueOf(query.get("processing_metrics_interval")), Float.valueOf("36.0")); + assertEquals(Boolean.valueOf(query.get("audio_metrics")), Boolean.valueOf(true)); + assertEquals(Double.valueOf(query.get("end_of_phrase_silence_time")), Double.valueOf("72.5")); assertEquals( - PATH_RECOGNIZE + "?language_customization_id=" + id + "&base_model_version=" + version, - request.getPath()); - assertEquals(recognition, GSON.toJsonTree(result)); + Boolean.valueOf(query.get("split_transcript_at_phrase_end")), Boolean.valueOf(true)); + assertEquals(Float.valueOf(query.get("speech_detector_sensitivity")), Float.valueOf("36.0")); + assertEquals(Float.valueOf(query.get("background_audio_suppression")), Float.valueOf("36.0")); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createJobPath); + } + + // Test the createJob operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateJobNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + speechToTextService.createJob(null).execute(); } - /** - * Test recognize with acoustic customization. - * - * @throws FileNotFoundException the file not found exception - * @throws InterruptedException the interrupted exception - */ @Test - public void testRecognizeWithAcousticCustomization() - throws FileNotFoundException, InterruptedException { - String id = "foo"; - String version = "version"; - String recString = - getStringFromInputStream( - new FileInputStream("src/test/resources/speech_to_text/recognition.json")); - JsonObject recognition = new JsonParser().parse(recString).getAsJsonObject(); + public void testCheckJobsWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"recognitions\": [{\"id\": \"id\", \"status\": \"waiting\", \"created\": \"created\", \"updated\": \"updated\", \"url\": \"url\", \"user_token\": \"userToken\", \"results\": [{\"results\": [{\"final\": true, \"alternatives\": [{\"transcript\": \"transcript\", \"confidence\": 0, \"timestamps\": [\"timestamps\"], \"word_confidence\": [\"wordConfidence\"]}], \"keywords_result\": {\"mapKey\": [{\"normalized_text\": \"normalizedText\", \"start_time\": 9, \"end_time\": 7, \"confidence\": 0}]}, \"word_alternatives\": [{\"start_time\": 9, \"end_time\": 7, \"alternatives\": [{\"confidence\": 0, \"word\": \"word\"}]}], \"end_of_utterance\": \"end_of_data\"}], \"result_index\": 11, \"speaker_labels\": [{\"from\": 4, \"to\": 2, \"speaker\": 7, \"confidence\": 10, \"final\": true}], \"processing_metrics\": {\"processed_audio\": {\"received\": 8, \"seen_by_engine\": 12, \"transcription\": 13, \"speaker_labels\": 13}, \"wall_clock_since_first_byte_received\": 31, \"periodic\": true}, \"audio_metrics\": {\"sampling_interval\": 16, \"accumulated\": {\"final\": true, \"end_time\": 7, \"signal_to_noise_ratio\": 18, \"speech_ratio\": 11, \"high_frequency_loss\": 17, \"direct_current_offset\": [{\"begin\": 5, \"end\": 3, \"count\": 5}], \"clipping_rate\": [{\"begin\": 5, \"end\": 3, \"count\": 5}], \"speech_level\": [{\"begin\": 5, \"end\": 3, \"count\": 5}], \"non_speech_level\": [{\"begin\": 5, \"end\": 3, \"count\": 5}]}}, \"warnings\": [\"warnings\"]}], \"warnings\": [\"warnings\"]}]}"; + String checkJobsPath = "/v1/recognitions"; server.enqueue( new MockResponse() - .addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON) - .setBody(recString)); + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); - RecognizeOptions recognizeOptions = - new RecognizeOptions.Builder() - .audio(SAMPLE_WAV) - .contentType(HttpMediaType.AUDIO_WAV) - .acousticCustomizationId(id) - .baseModelVersion(version) - .build(); - SpeechRecognitionResults result = service.recognize(recognizeOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); + constructClientService(); - assertEquals("POST", request.getMethod()); - assertEquals( - PATH_RECOGNIZE + "?acoustic_customization_id=" + id + "&base_model_version=" + version, - request.getPath()); - assertEquals(recognition, GSON.toJsonTree(result)); + // Construct an instance of the CheckJobsOptions model + CheckJobsOptions checkJobsOptionsModel = new CheckJobsOptions(); + + // Invoke operation with valid options model (positive test) + Response response = + speechToTextService.checkJobs(checkJobsOptionsModel).execute(); + assertNotNull(response); + RecognitionJobs responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, checkJobsPath); } - /** - * Test recognize with customization weight. - * - * @throws FileNotFoundException the file not found exception - * @throws InterruptedException the interrupted exception - */ @Test - public void testRecognizeWithCustomizationWeight() - throws FileNotFoundException, InterruptedException { - String id = "foo"; - String recString = - getStringFromInputStream( - new FileInputStream("src/test/resources/speech_to_text/recognition.json")); - JsonObject recognition = new JsonParser().parse(recString).getAsJsonObject(); + public void testCheckJobWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"id\": \"id\", \"status\": \"waiting\", \"created\": \"created\", \"updated\": \"updated\", \"url\": \"url\", \"user_token\": \"userToken\", \"results\": [{\"results\": [{\"final\": true, \"alternatives\": [{\"transcript\": \"transcript\", \"confidence\": 0, \"timestamps\": [\"timestamps\"], \"word_confidence\": [\"wordConfidence\"]}], \"keywords_result\": {\"mapKey\": [{\"normalized_text\": \"normalizedText\", \"start_time\": 9, \"end_time\": 7, \"confidence\": 0}]}, \"word_alternatives\": [{\"start_time\": 9, \"end_time\": 7, \"alternatives\": [{\"confidence\": 0, \"word\": \"word\"}]}], \"end_of_utterance\": \"end_of_data\"}], \"result_index\": 11, \"speaker_labels\": [{\"from\": 4, \"to\": 2, \"speaker\": 7, \"confidence\": 10, \"final\": true}], \"processing_metrics\": {\"processed_audio\": {\"received\": 8, \"seen_by_engine\": 12, \"transcription\": 13, \"speaker_labels\": 13}, \"wall_clock_since_first_byte_received\": 31, \"periodic\": true}, \"audio_metrics\": {\"sampling_interval\": 16, \"accumulated\": {\"final\": true, \"end_time\": 7, \"signal_to_noise_ratio\": 18, \"speech_ratio\": 11, \"high_frequency_loss\": 17, \"direct_current_offset\": [{\"begin\": 5, \"end\": 3, \"count\": 5}], \"clipping_rate\": [{\"begin\": 5, \"end\": 3, \"count\": 5}], \"speech_level\": [{\"begin\": 5, \"end\": 3, \"count\": 5}], \"non_speech_level\": [{\"begin\": 5, \"end\": 3, \"count\": 5}]}}, \"warnings\": [\"warnings\"]}], \"warnings\": [\"warnings\"]}"; + String checkJobPath = "/v1/recognitions/testString"; server.enqueue( new MockResponse() - .addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON) - .setBody(recString)); + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); - RecognizeOptions recognizeOptions = - new RecognizeOptions.Builder() - .audio(SAMPLE_WAV) - .contentType(HttpMediaType.AUDIO_WAV) - .languageCustomizationId(id) - .customizationWeight(0.5) - .build(); - SpeechRecognitionResults result = service.recognize(recognizeOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); + constructClientService(); - assertEquals( - PATH_RECOGNIZE + "?language_customization_id=" + id + "&customization_weight=0.5", - request.getPath()); - assertEquals(recognition, GSON.toJsonTree(result)); + // Construct an instance of the CheckJobOptions model + CheckJobOptions checkJobOptionsModel = new CheckJobOptions.Builder().id("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = + speechToTextService.checkJob(checkJobOptionsModel).execute(); + assertNotNull(response); + RecognitionJob responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, checkJobPath); + } + + // Test the checkJob operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCheckJobNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + speechToTextService.checkJob(null).execute(); } - /** Test MediaTypeUtils class. */ @Test - public void testMediaTypeUtils() { - assertEquals( - HttpMediaType.AUDIO_WAV, MediaTypeUtils.getMediaTypeFromFile(new File("test.wav"))); - assertEquals( - HttpMediaType.AUDIO_OGG, MediaTypeUtils.getMediaTypeFromFile(new File("test.OGG"))); - assertNull(MediaTypeUtils.getMediaTypeFromFile(new File("invalid.png"))); - assertNull(MediaTypeUtils.getMediaTypeFromFile(new File("invalidwav"))); - assertNull(MediaTypeUtils.getMediaTypeFromFile(null)); - - assertTrue(MediaTypeUtils.isValidMediaType("audio/wav")); - assertFalse(MediaTypeUtils.isValidMediaType("image/png")); - assertFalse(MediaTypeUtils.isValidMediaType(null)); - } - - /** - * Test create job. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ + public void testDeleteJobWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String deleteJobPath = "/v1/recognitions/testString"; + + server.enqueue(new MockResponse().setResponseCode(204).setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the DeleteJobOptions model + DeleteJobOptions deleteJobOptionsModel = + new DeleteJobOptions.Builder().id("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = speechToTextService.deleteJob(deleteJobOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteJobPath); + } + + // Test the deleteJob operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteJobNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + speechToTextService.deleteJob(null).execute(); + } + @Test - public void testCreateJob() throws InterruptedException, FileNotFoundException { - String callbackUrl = "callback"; - String events = CreateJobOptions.Events.RECOGNITIONS_STARTED; - String userToken = "token"; - Long resultsTtl = 5L; - File audio = SAMPLE_WAV; - String contentType = HttpMediaType.AUDIO_WAV; - String model = CreateJobOptions.Model.EN_US_BROADBANDMODEL; - String customizationId = "customizationId"; - Double customizationWeight = 5d; - String version = "version"; - Long inactivityTimeout = 20L; - List keywords = Arrays.asList("keyword1", "keyword2"); - Float keywordsThreshold = 5f; - Boolean wordConfidence = true; - Boolean timestamps = true; - Boolean profanityFilter = true; - Boolean smartFormatting = true; - Boolean speakerLabels = true; - Double endOfPhraseSilenceTime = 2.0; - Boolean splitTranscriptAtPhraseEnd = true; - - RecognitionJob job = - loadFixture("src/test/resources/speech_to_text/job.json", RecognitionJob.class); + public void testCreateLanguageModelWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"customization_id\": \"customizationId\", \"created\": \"created\", \"updated\": \"updated\", \"language\": \"language\", \"dialect\": \"dialect\", \"versions\": [\"versions\"], \"owner\": \"owner\", \"name\": \"name\", \"description\": \"description\", \"base_model_name\": \"baseModelName\", \"status\": \"pending\", \"progress\": 8, \"error\": \"error\", \"warnings\": \"warnings\"}"; + String createLanguageModelPath = "/v1/customizations"; + server.enqueue( new MockResponse() - .addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON) - .setBody(GSON.toJson(job))); + .setHeader("Content-type", "application/json") + .setResponseCode(201) + .setBody(mockResponseBody)); - CreateJobOptions createOptions = - new CreateJobOptions.Builder() - .callbackUrl(callbackUrl) - .events(events) - .userToken(userToken) - .resultsTtl(resultsTtl) - .audio(audio) - .contentType(contentType) - .model(model) - .languageCustomizationId(customizationId) - .customizationWeight(customizationWeight) - .baseModelVersion(version) - .inactivityTimeout(inactivityTimeout) - .keywords(keywords) - .keywordsThreshold(keywordsThreshold) - .wordConfidence(wordConfidence) - .timestamps(timestamps) - .profanityFilter(profanityFilter) - .smartFormatting(smartFormatting) - .speakerLabels(speakerLabels) - .endOfPhraseSilenceTime(endOfPhraseSilenceTime) - .splitTranscriptAtPhraseEnd(splitTranscriptAtPhraseEnd) + constructClientService(); + + // Construct an instance of the CreateLanguageModelOptions model + CreateLanguageModelOptions createLanguageModelOptionsModel = + new CreateLanguageModelOptions.Builder() + .name("testString") + .baseModelName("de-DE_BroadbandModel") + .dialect("testString") + .description("testString") .build(); - assertEquals((Double) 2.0, createOptions.endOfPhraseSilenceTime()); - assertTrue(createOptions.splitTranscriptAtPhraseEnd()); + // Invoke operation with valid options model (positive test) + Response response = + speechToTextService.createLanguageModel(createLanguageModelOptionsModel).execute(); + assertNotNull(response); + LanguageModel responseObj = response.getResult(); + assertNotNull(responseObj); - service.createJob(createOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); - assertEquals("POST", request.getMethod()); - assertEquals( - PATH_RECOGNITIONS - + "?model=" - + model - + "&callback_url=" - + callbackUrl - + "&events=" - + events - + "&user_token=" - + userToken - + "&results_ttl=" - + resultsTtl - + "&language_customization_id=" - + customizationId - + "&base_model_version=" - + version - + "&customization_weight=" - + customizationWeight - + "&inactivity_timeout=" - + inactivityTimeout - + "&keywords=" - + RequestUtils.encode(StringUtils.join(keywords, ',')) - + "&keywords_threshold=" - + keywordsThreshold - + "&word_confidence=" - + wordConfidence - + "×tamps=" - + timestamps - + "&profanity_filter=" - + profanityFilter - + "&smart_formatting=" - + smartFormatting - + "&speaker_labels=" - + speakerLabels - + "&end_of_phrase_silence_time=" - + endOfPhraseSilenceTime - + "&split_transcript_at_phrase_end=" - + splitTranscriptAtPhraseEnd, - request.getPath()); - } - - /** - * Test delete job. - * - * @throws InterruptedException the interrupted exception - */ - @Test - public void testDeleteJob() throws InterruptedException { - String id = "foo"; + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNull(query); - server.enqueue( - new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody("{}")); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createLanguageModelPath); + } - DeleteJobOptions deleteOptions = new DeleteJobOptions.Builder().id(id).build(); - service.deleteJob(deleteOptions).execute(); - final RecordedRequest request = server.takeRequest(); + // Test the createLanguageModel operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateLanguageModelNoOptions() throws Throwable { + // construct the service + constructClientService(); - assertEquals("DELETE", request.getMethod()); - assertEquals(String.format(PATH_RECOGNITION, id), request.getPath()); + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + speechToTextService.createLanguageModel(null).execute(); } - /** - * Test check job. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ @Test - public void testCheckJob() throws InterruptedException, FileNotFoundException { - String id = "foo"; - RecognitionJob job = - loadFixture("src/test/resources/speech_to_text/job.json", RecognitionJob.class); + public void testListLanguageModelsWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"customizations\": [{\"customization_id\": \"customizationId\", \"created\": \"created\", \"updated\": \"updated\", \"language\": \"language\", \"dialect\": \"dialect\", \"versions\": [\"versions\"], \"owner\": \"owner\", \"name\": \"name\", \"description\": \"description\", \"base_model_name\": \"baseModelName\", \"status\": \"pending\", \"progress\": 8, \"error\": \"error\", \"warnings\": \"warnings\"}]}"; + String listLanguageModelsPath = "/v1/customizations"; server.enqueue( new MockResponse() - .addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON) - .setBody(GSON.toJson(job))); + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); - CheckJobOptions checkOptions = new CheckJobOptions.Builder().id(id).build(); - RecognitionJob result = service.checkJob(checkOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); + // Construct an instance of the ListLanguageModelsOptions model + ListLanguageModelsOptions listLanguageModelsOptionsModel = + new ListLanguageModelsOptions.Builder().language("ar-AR").build(); - assertEquals("GET", request.getMethod()); - assertEquals(String.format(PATH_RECOGNITION, id), request.getPath()); - assertEquals(result.toString(), job.toString()); + // Invoke operation with valid options model (positive test) + Response response = + speechToTextService.listLanguageModels(listLanguageModelsOptionsModel).execute(); + assertNotNull(response); + LanguageModels responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("language"), "ar-AR"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listLanguageModelsPath); } - /** - * Test check jobs. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ @Test - public void testCheckJobs() throws InterruptedException, FileNotFoundException { - String jobsAsString = - getStringFromInputStream( - new FileInputStream("src/test/resources/speech_to_text/jobs.json")); - JsonObject jobsAsJson = new JsonParser().parse(jobsAsString).getAsJsonObject(); + public void testGetLanguageModelWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"customization_id\": \"customizationId\", \"created\": \"created\", \"updated\": \"updated\", \"language\": \"language\", \"dialect\": \"dialect\", \"versions\": [\"versions\"], \"owner\": \"owner\", \"name\": \"name\", \"description\": \"description\", \"base_model_name\": \"baseModelName\", \"status\": \"pending\", \"progress\": 8, \"error\": \"error\", \"warnings\": \"warnings\"}"; + String getLanguageModelPath = "/v1/customizations/testString"; server.enqueue( new MockResponse() - .addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON) - .setBody(jobsAsString)); + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); - RecognitionJobs result = service.checkJobs().execute().getResult(); - final RecordedRequest request = server.takeRequest(); + // Construct an instance of the GetLanguageModelOptions model + GetLanguageModelOptions getLanguageModelOptionsModel = + new GetLanguageModelOptions.Builder().customizationId("testString").build(); - assertEquals("GET", request.getMethod()); - assertEquals(PATH_RECOGNITIONS, request.getPath()); - assertEquals(jobsAsJson.get("recognitions"), GSON.toJsonTree(result.getRecognitions())); + // Invoke operation with valid options model (positive test) + Response response = + speechToTextService.getLanguageModel(getLanguageModelOptionsModel).execute(); + assertNotNull(response); + LanguageModel responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getLanguageModelPath); + } + + // Test the getLanguageModel operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetLanguageModelNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + speechToTextService.getLanguageModel(null).execute(); } - /** - * Test list language models. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ @Test - public void testListLanguageModels() throws InterruptedException, FileNotFoundException { - String customizationsAsString = - getStringFromInputStream( - new FileInputStream("src/test/resources/speech_to_text/customizations.json")); - JsonObject customizations = new JsonParser().parse(customizationsAsString).getAsJsonObject(); + public void testDeleteLanguageModelWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String deleteLanguageModelPath = "/v1/customizations/testString"; - server.enqueue( - new MockResponse() - .addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON) - .setBody(customizationsAsString)); + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); - ListLanguageModelsOptions listOptions = - new ListLanguageModelsOptions.Builder().language("en-us").build(); - LanguageModels result = service.listLanguageModels(listOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); + constructClientService(); - assertEquals("GET", request.getMethod()); - assertEquals(PATH_CUSTOMIZATIONS + "?language=en-us", request.getPath()); - assertEquals( - customizations.get("customizations").getAsJsonArray().size(), - result.getCustomizations().size()); - assertEquals(customizations.get("customizations"), GSON.toJsonTree(result.getCustomizations())); + // Construct an instance of the DeleteLanguageModelOptions model + DeleteLanguageModelOptions deleteLanguageModelOptionsModel = + new DeleteLanguageModelOptions.Builder().customizationId("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = + speechToTextService.deleteLanguageModel(deleteLanguageModelOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteLanguageModelPath); } - /** - * Test get language model. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ - @Test - public void testGetLanguageModel() throws InterruptedException, FileNotFoundException { - String id = "foo"; - LanguageModel model = - loadFixture("src/test/resources/speech_to_text/customization.json", LanguageModel.class); + // Test the deleteLanguageModel operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteLanguageModelNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + speechToTextService.deleteLanguageModel(null).execute(); + } - server.enqueue( - new MockResponse() - .addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON) - .setBody(GSON.toJson(model))); - - GetLanguageModelOptions getOptions = - new GetLanguageModelOptions.Builder().customizationId(id).build(); - LanguageModel result = service.getLanguageModel(getOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - - assertEquals("GET", request.getMethod()); - assertEquals(String.format(PATH_CUSTOMIZATION, id), request.getPath()); - assertEquals(result.toString(), model.toString()); - assertEquals(UPDATED, result.getUpdated()); - } - - /** - * Test create language model. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ @Test - public void testCreateLanguageModel() throws InterruptedException, FileNotFoundException { - LanguageModel model = - loadFixture("src/test/resources/speech_to_text/customization.json", LanguageModel.class); + public void testTrainLanguageModelWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"warnings\": [{\"code\": \"invalid_audio_files\", \"message\": \"message\"}]}"; + String trainLanguageModelPath = "/v1/customizations/testString/train"; server.enqueue( new MockResponse() - .addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON) - .setBody(GSON.toJson(model))); + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); - CreateLanguageModelOptions createOptions = - new CreateLanguageModelOptions.Builder() - .name(model.getName()) - .baseModelName("en-GB_BroadbandModel") - .description(model.getDescription()) + constructClientService(); + + // Construct an instance of the TrainLanguageModelOptions model + TrainLanguageModelOptions trainLanguageModelOptionsModel = + new TrainLanguageModelOptions.Builder() + .customizationId("testString") + .wordTypeToAdd("all") + .customizationWeight(Double.valueOf("72.5")) .build(); - LanguageModel result = service.createLanguageModel(createOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - assertEquals("POST", request.getMethod()); - assertEquals(PATH_CUSTOMIZATIONS, request.getPath()); - assertEquals(result.toString(), model.toString()); + // Invoke operation with valid options model (positive test) + Response response = + speechToTextService.trainLanguageModel(trainLanguageModelOptionsModel).execute(); + assertNotNull(response); + TrainingResponse responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("word_type_to_add"), "all"); + assertEquals(Double.valueOf(query.get("customization_weight")), Double.valueOf("72.5")); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, trainLanguageModelPath); + } + + // Test the trainLanguageModel operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testTrainLanguageModelNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + speechToTextService.trainLanguageModel(null).execute(); } - /** - * Test delete language model. - * - * @throws InterruptedException the interrupted exception - */ @Test - public void testDeleteLanguageModel() throws InterruptedException { - String id = "foo"; + public void testResetLanguageModelWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String resetLanguageModelPath = "/v1/customizations/testString/reset"; - server.enqueue( - new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody("{}")); + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the ResetLanguageModelOptions model + ResetLanguageModelOptions resetLanguageModelOptionsModel = + new ResetLanguageModelOptions.Builder().customizationId("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = + speechToTextService.resetLanguageModel(resetLanguageModelOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); - DeleteLanguageModelOptions deleteOptions = - new DeleteLanguageModelOptions.Builder().customizationId(id).build(); - service.deleteLanguageModel(deleteOptions).execute(); - final RecordedRequest request = server.takeRequest(); + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNull(query); - assertEquals("DELETE", request.getMethod()); - assertEquals(String.format(PATH_CUSTOMIZATION, id), request.getPath()); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, resetLanguageModelPath); } - /** - * Test train language model. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ - @Test - public void testTrainLanguageModel() throws InterruptedException, FileNotFoundException { - server.enqueue( - new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody("{}")); - String id = "foo"; + // Test the resetLanguageModel operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testResetLanguageModelNoOptions() throws Throwable { + // construct the service + constructClientService(); - TrainLanguageModelOptions trainOptions = - new TrainLanguageModelOptions.Builder() - .customizationId(id) - .wordTypeToAdd(TrainLanguageModelOptions.WordTypeToAdd.ALL) - .customizationWeight(0.5) - .build(); - service.trainLanguageModel(trainOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); + server.enqueue(new MockResponse()); - assertEquals("POST", request.getMethod()); - assertEquals( - String.format(PATH_TRAIN, id) + "?word_type_to_add=all&customization_weight=" + 0.5, - request.getPath()); + // Invoke operation with null options model (negative test) + speechToTextService.resetLanguageModel(null).execute(); } - /** - * Test reset language model. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ @Test - public void testResetLanguageModel() throws InterruptedException, FileNotFoundException { - server.enqueue( - new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody("{}")); - String id = "foo"; + public void testUpgradeLanguageModelWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String upgradeLanguageModelPath = "/v1/customizations/testString/upgrade_model"; + + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); - ResetLanguageModelOptions resetOptions = - new ResetLanguageModelOptions.Builder().customizationId(id).build(); - service.resetLanguageModel(resetOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); + constructClientService(); - assertEquals("POST", request.getMethod()); - assertEquals(String.format(PATH_RESET, id), request.getPath()); + // Construct an instance of the UpgradeLanguageModelOptions model + UpgradeLanguageModelOptions upgradeLanguageModelOptionsModel = + new UpgradeLanguageModelOptions.Builder().customizationId("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = + speechToTextService.upgradeLanguageModel(upgradeLanguageModelOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, upgradeLanguageModelPath); } - /** - * Test upgrade language model. - * - * @throws InterruptedException the interrupted exception - */ - @Test - public void testUpgradeLanguageModel() throws InterruptedException { - server.enqueue( - new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody("{}")); - String id = "foo"; + // Test the upgradeLanguageModel operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpgradeLanguageModelNoOptions() throws Throwable { + // construct the service + constructClientService(); - UpgradeLanguageModelOptions upgradeOptions = - new UpgradeLanguageModelOptions.Builder().customizationId(id).build(); - service.upgradeLanguageModel(upgradeOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); + server.enqueue(new MockResponse()); - assertEquals("POST", request.getMethod()); - assertEquals(String.format(PATH_UPGRADE, id), request.getPath()); + // Invoke operation with null options model (negative test) + speechToTextService.upgradeLanguageModel(null).execute(); } - /** - * Test list corpora. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ @Test - public void testListCorpora() throws InterruptedException, FileNotFoundException { - String id = "foo"; - String corporaAsString = - getStringFromInputStream( - new FileInputStream("src/test/resources/speech_to_text/corpora.json")); - JsonObject corpora = new JsonParser().parse(corporaAsString).getAsJsonObject(); + public void testListCorporaWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"corpora\": [{\"name\": \"name\", \"total_words\": 10, \"out_of_vocabulary_words\": 20, \"status\": \"analyzed\", \"error\": \"error\"}]}"; + String listCorporaPath = "/v1/customizations/testString/corpora"; server.enqueue( new MockResponse() - .addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON) - .setBody(corporaAsString)); + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); - ListCorporaOptions listOptions = new ListCorporaOptions.Builder().customizationId(id).build(); - Corpora result = service.listCorpora(listOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); + constructClientService(); - assertEquals("GET", request.getMethod()); - assertEquals(String.format(PATH_CORPORA, id), request.getPath()); - assertEquals(corpora.get("corpora"), GSON.toJsonTree(result.getCorpora())); - } + // Construct an instance of the ListCorporaOptions model + ListCorporaOptions listCorporaOptionsModel = + new ListCorporaOptions.Builder().customizationId("testString").build(); - /** - * Test get corpus. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ - @Test - public void testGetCorpus() throws InterruptedException, FileNotFoundException { - String id = "foo"; - String corpus = "cName"; + // Invoke operation with valid options model (positive test) + Response response = speechToTextService.listCorpora(listCorporaOptionsModel).execute(); + assertNotNull(response); + Corpora responseObj = response.getResult(); + assertNotNull(responseObj); - server.enqueue( - new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody("{}")); + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); - GetCorpusOptions getOptions = - new GetCorpusOptions.Builder().customizationId(id).corpusName(corpus).build(); - service.getCorpus(getOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNull(query); - assertEquals("GET", request.getMethod()); - assertEquals(String.format(PATH_CORPUS, id, corpus), request.getPath()); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listCorporaPath); } - /** - * Test delete corpus. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ - @Test - public void testDeleteCorpus() throws InterruptedException, FileNotFoundException { - String id = "foo"; - String corpus = "cName"; - - server.enqueue( - new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody("{}")); + // Test the listCorpora operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListCorporaNoOptions() throws Throwable { + // construct the service + constructClientService(); - DeleteCorpusOptions deleteOptions = - new DeleteCorpusOptions.Builder().customizationId(id).corpusName(corpus).build(); - service.deleteCorpus(deleteOptions).execute(); - final RecordedRequest request = server.takeRequest(); + server.enqueue(new MockResponse()); - assertEquals("DELETE", request.getMethod()); - assertEquals(String.format(PATH_CORPUS, id, corpus), request.getPath()); + // Invoke operation with null options model (negative test) + speechToTextService.listCorpora(null).execute(); } - /** - * Test add corpus. - * - * @throws InterruptedException the interrupted exception - * @throws IOException the IO exception - */ @Test - public void testAddCorpus() throws InterruptedException, IOException { - String id = "foo"; - String corpusName = "cName"; - File corpusFile = new File("src/test/resources/speech_to_text/corpus-text.txt"); - String corpusFileText = new String(Files.readAllBytes(Paths.get(corpusFile.toURI()))); + public void testAddCorpusWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String addCorpusPath = "/v1/customizations/testString/corpora/testString"; - server.enqueue( - new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody("{}")); + server.enqueue(new MockResponse().setResponseCode(201).setBody(mockResponseBody)); + + constructClientService(); - AddCorpusOptions addOptions = + // Construct an instance of the AddCorpusOptions model + AddCorpusOptions addCorpusOptionsModel = new AddCorpusOptions.Builder() - .customizationId(id) - .corpusName(corpusName) - .corpusFile(corpusFile) + .customizationId("testString") + .corpusName("testString") + .corpusFile(TestUtilities.createMockStream("This is a mock file.")) .allowOverwrite(true) .build(); - service.addCorpus(addOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - assertEquals("POST", request.getMethod()); - assertEquals( - String.format(PATH_CORPUS, id, corpusName) + "?allow_overwrite=true", request.getPath()); - assertTrue(request.getBody().readUtf8().contains(corpusFileText)); + // Invoke operation with valid options model (positive test) + Response response = speechToTextService.addCorpus(addCorpusOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(Boolean.valueOf(query.get("allow_overwrite")), Boolean.valueOf(true)); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, addCorpusPath); } - /** - * Test list words. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ - @Test - public void testListWords() throws InterruptedException, FileNotFoundException { - String id = "foo"; - String wordsAsStr = - getStringFromInputStream( - new FileInputStream("src/test/resources/speech_to_text/words.json")); - JsonObject words = new JsonParser().parse(wordsAsStr).getAsJsonObject(); + // Test the addCorpus operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAddCorpusNoOptions() throws Throwable { + // construct the service + constructClientService(); - server.enqueue( - new MockResponse() - .addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON) - .setBody(wordsAsStr)); + server.enqueue(new MockResponse()); - ListWordsOptions listOptions = new ListWordsOptions.Builder().customizationId(id).build(); - Words result = service.listWords(listOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - - assertEquals("GET", request.getMethod()); - assertEquals(String.format(PATH_WORDS, id), request.getPath()); - assertEquals(words.get("words"), GSON.toJsonTree(result.getWords())); + // Invoke operation with null options model (negative test) + speechToTextService.addCorpus(null).execute(); } - /** - * Test list words with word type all. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ @Test - public void testListWordsType() throws InterruptedException, FileNotFoundException { - String id = "foo"; - String wordsAsStr = - getStringFromInputStream( - new FileInputStream("src/test/resources/speech_to_text/words.json")); - JsonObject words = new JsonParser().parse(wordsAsStr).getAsJsonObject(); + public void testGetCorpusWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"name\": \"name\", \"total_words\": 10, \"out_of_vocabulary_words\": 20, \"status\": \"analyzed\", \"error\": \"error\"}"; + String getCorpusPath = "/v1/customizations/testString/corpora/testString"; server.enqueue( new MockResponse() - .addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON) - .setBody(wordsAsStr)); + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); - ListWordsOptions listOptions = - new ListWordsOptions.Builder() - .customizationId(id) - .wordType(ListWordsOptions.WordType.ALL) + constructClientService(); + + // Construct an instance of the GetCorpusOptions model + GetCorpusOptions getCorpusOptionsModel = + new GetCorpusOptions.Builder() + .customizationId("testString") + .corpusName("testString") .build(); - Words result = service.listWords(listOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - assertEquals("GET", request.getMethod()); - assertEquals(String.format(PATH_WORDS, id) + "?word_type=all", request.getPath()); - assertEquals(words.get("words"), GSON.toJsonTree(result.getWords())); + // Invoke operation with valid options model (positive test) + Response response = speechToTextService.getCorpus(getCorpusOptionsModel).execute(); + assertNotNull(response); + Corpus responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getCorpusPath); + } + + // Test the getCorpus operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetCorpusNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + speechToTextService.getCorpus(null).execute(); } - /** - * Test list words with sort order alphabetical. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ @Test - public void testListWordsSort() throws InterruptedException, FileNotFoundException { - String id = "foo"; - String wordsAsStr = - getStringFromInputStream( - new FileInputStream("src/test/resources/speech_to_text/words.json")); - JsonObject words = new JsonParser().parse(wordsAsStr).getAsJsonObject(); + public void testDeleteCorpusWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String deleteCorpusPath = "/v1/customizations/testString/corpora/testString"; - server.enqueue( - new MockResponse() - .addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON) - .setBody(wordsAsStr)); + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); - ListWordsOptions listOptions = - new ListWordsOptions.Builder() - .customizationId(id) - .sort(ListWordsOptions.Sort.ALPHABETICAL) + constructClientService(); + + // Construct an instance of the DeleteCorpusOptions model + DeleteCorpusOptions deleteCorpusOptionsModel = + new DeleteCorpusOptions.Builder() + .customizationId("testString") + .corpusName("testString") .build(); - Words result = service.listWords(listOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - assertEquals("GET", request.getMethod()); - assertEquals(String.format(PATH_WORDS, id) + "?sort=alphabetical", request.getPath()); - assertEquals(words.get("words"), GSON.toJsonTree(result.getWords())); + // Invoke operation with valid options model (positive test) + Response response = speechToTextService.deleteCorpus(deleteCorpusOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteCorpusPath); + } + + // Test the deleteCorpus operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteCorpusNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + speechToTextService.deleteCorpus(null).execute(); } - /** - * Test list words with word type all and sort order alphabetical. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ @Test - public void testListWordsTypeSort() throws InterruptedException, FileNotFoundException { - String id = "foo"; - String wordsAsStr = - getStringFromInputStream( - new FileInputStream("src/test/resources/speech_to_text/words.json")); - JsonObject words = new JsonParser().parse(wordsAsStr).getAsJsonObject(); + public void testListWordsWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"words\": [{\"word\": \"word\", \"sounds_like\": [\"soundsLike\"], \"display_as\": \"displayAs\", \"count\": 5, \"source\": [\"source\"], \"error\": [{\"element\": \"element\"}]}]}"; + String listWordsPath = "/v1/customizations/testString/words"; server.enqueue( new MockResponse() - .addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON) - .setBody(wordsAsStr)); + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); - ListWordsOptions listOptions = + constructClientService(); + + // Construct an instance of the ListWordsOptions model + ListWordsOptions listWordsOptionsModel = new ListWordsOptions.Builder() - .customizationId(id) - .sort(ListWordsOptions.Sort.ALPHABETICAL) - .wordType(ListWordsOptions.WordType.ALL) + .customizationId("testString") + .wordType("all") + .sort("alphabetical") .build(); - Words result = service.listWords(listOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - assertEquals("GET", request.getMethod()); - assertEquals( - String.format(PATH_WORDS, id) + "?word_type=all&sort=alphabetical", request.getPath()); - assertEquals(words.get("words"), GSON.toJsonTree(result.getWords())); + // Invoke operation with valid options model (positive test) + Response response = speechToTextService.listWords(listWordsOptionsModel).execute(); + assertNotNull(response); + Words responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("word_type"), "all"); + assertEquals(query.get("sort"), "alphabetical"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listWordsPath); + } + + // Test the listWords operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListWordsNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + speechToTextService.listWords(null).execute(); } - /** - * Test get word. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ @Test - public void testGetWord() throws InterruptedException, FileNotFoundException { - String id = "foo"; - String wordName = "bar"; + public void testAddWordsWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String addWordsPath = "/v1/customizations/testString/words"; - String wordAsStr = - getStringFromInputStream( - new FileInputStream("src/test/resources/speech_to_text/word.json")); - JsonObject word = new JsonParser().parse(wordAsStr).getAsJsonObject(); + server.enqueue(new MockResponse().setResponseCode(201).setBody(mockResponseBody)); - server.enqueue( - new MockResponse() - .addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON) - .setBody(wordAsStr)); + constructClientService(); - GetWordOptions getOptions = - new GetWordOptions.Builder().customizationId(id).wordName(wordName).build(); - Word result = service.getWord(getOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); + // Construct an instance of the CustomWord model + CustomWord customWordModel = + new CustomWord.Builder() + .word("testString") + .soundsLike(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .displayAs("testString") + .build(); - assertEquals("GET", request.getMethod()); - assertEquals(String.format(PATH_WORD, id, wordName), request.getPath()); - assertEquals(word, GSON.toJsonTree(result)); - } + // Construct an instance of the AddWordsOptions model + AddWordsOptions addWordsOptionsModel = + new AddWordsOptions.Builder() + .customizationId("testString") + .words(new java.util.ArrayList(java.util.Arrays.asList(customWordModel))) + .build(); - /** - * Test delete word. - * - * @throws InterruptedException the interrupted exception - */ - @Test - public void testDeleteWord() throws InterruptedException { - String id = "foo"; - String wordName = "bar"; + // Invoke operation with valid options model (positive test) + Response response = speechToTextService.addWords(addWordsOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); - server.enqueue( - new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody("{}")); + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); - DeleteWordOptions deleteOptions = - new DeleteWordOptions.Builder().customizationId(id).wordName(wordName).build(); - service.deleteWord(deleteOptions).execute(); - final RecordedRequest request = server.takeRequest(); + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNull(query); - assertEquals("DELETE", request.getMethod()); - assertEquals(String.format(PATH_WORD, id, wordName), request.getPath()); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, addWordsPath); } - /** - * Test add words. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ - @Test - public void testAddWords() throws InterruptedException, FileNotFoundException { - String id = "foo"; - Word newWord = loadFixture("src/test/resources/speech_to_text/word.json", Word.class); - Map wordsAsMap = new HashMap(); - wordsAsMap.put("words", new Word[] {newWord}); - server.enqueue( - new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody("{}")); + // Test the addWords operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAddWordsNoOptions() throws Throwable { + // construct the service + constructClientService(); - CustomWord word = - new CustomWord.Builder() - .word(newWord.getWord()) - .displayAs(newWord.getDisplayAs()) - .soundsLike(newWord.getSoundsLike()) - .build(); + server.enqueue(new MockResponse()); - AddWordsOptions addOptions = - new AddWordsOptions.Builder().customizationId(id).addWords(word).build(); - service.addWords(addOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - - assertEquals("POST", request.getMethod()); - assertEquals(String.format(PATH_WORDS, id), request.getPath()); - Gson testGsonNoNulls = new Gson(); - assertEquals(testGsonNoNulls.toJson(wordsAsMap), request.getBody().readUtf8()); + // Invoke operation with null options model (negative test) + speechToTextService.addWords(null).execute(); } - /** - * Test add word. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ @Test - public void testAddWord() throws InterruptedException, FileNotFoundException { - String id = "foo"; - Word newWord = loadFixture("src/test/resources/speech_to_text/word.json", Word.class); - server.enqueue( - new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody("{}")); + public void testAddWordWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String addWordPath = "/v1/customizations/testString/words/testString"; + + server.enqueue(new MockResponse().setResponseCode(201).setBody(mockResponseBody)); + + constructClientService(); - AddWordOptions addOptions = + // Construct an instance of the AddWordOptions model + AddWordOptions addWordOptionsModel = new AddWordOptions.Builder() - .wordName(newWord.getWord()) - .customizationId(id) - .word(newWord.getWord()) - .displayAs(newWord.getDisplayAs()) - .soundsLike(newWord.getSoundsLike()) + .customizationId("testString") + .wordName("testString") + .word("testString") + .soundsLike(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .displayAs("testString") .build(); - service.addWord(addOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - assertEquals("PUT", request.getMethod()); - assertEquals(String.format(PATH_WORD, id, newWord.getWord()), request.getPath()); - Gson testGsonNoNulls = new Gson(); - assertEquals(testGsonNoNulls.toJson(newWord), request.getBody().readUtf8()); + // Invoke operation with valid options model (positive test) + Response response = speechToTextService.addWord(addWordOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "PUT"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, addWordPath); + } + + // Test the addWord operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAddWordNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + speechToTextService.addWord(null).execute(); } - /** - * Test create acoustic model. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ @Test - public void testCreateAcousticModel() throws InterruptedException, FileNotFoundException { - AcousticModel model = - loadFixture("src/test/resources/speech_to_text/acoustic-model.json", AcousticModel.class); + public void testGetWordWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"word\": \"word\", \"sounds_like\": [\"soundsLike\"], \"display_as\": \"displayAs\", \"count\": 5, \"source\": [\"source\"], \"error\": [{\"element\": \"element\"}]}"; + String getWordPath = "/v1/customizations/testString/words/testString"; server.enqueue( new MockResponse() - .addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON) - .setBody(GSON.toJson(model))); + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); - CreateAcousticModelOptions createOptions = - new CreateAcousticModelOptions.Builder() - .name(model.getName()) - .baseModelName(model.getBaseModelName()) - .description(model.getDescription()) - .build(); - AcousticModel result = service.createAcousticModel(createOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); + constructClientService(); + + // Construct an instance of the GetWordOptions model + GetWordOptions getWordOptionsModel = + new GetWordOptions.Builder().customizationId("testString").wordName("testString").build(); - assertEquals("POST", request.getMethod()); - assertEquals(PATH_ACOUSTIC_CUSTOMIZATIONS, request.getPath()); - assertEquals(result.toString(), model.toString()); + // Invoke operation with valid options model (positive test) + Response response = speechToTextService.getWord(getWordOptionsModel).execute(); + assertNotNull(response); + Word responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getWordPath); + } + + // Test the getWord operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetWordNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + speechToTextService.getWord(null).execute(); } - /** - * Test list acoustic models. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ @Test - public void testListAcousticModels() throws InterruptedException, FileNotFoundException { - String acousticModelsAsString = - getStringFromInputStream( - new FileInputStream("src/test/resources/speech_to_text/acoustic-models.json")); - JsonObject acousticModels = new JsonParser().parse(acousticModelsAsString).getAsJsonObject(); + public void testDeleteWordWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String deleteWordPath = "/v1/customizations/testString/words/testString"; - server.enqueue( - new MockResponse() - .addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON) - .setBody(acousticModelsAsString)); + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); - ListAcousticModelsOptions listOptions = - new ListAcousticModelsOptions.Builder().language("en-us").build(); - AcousticModels result = service.listAcousticModels(listOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); + constructClientService(); - assertEquals("GET", request.getMethod()); - assertEquals(PATH_ACOUSTIC_CUSTOMIZATIONS + "?language=en-us", request.getPath()); - assertEquals( - acousticModels.get("customizations").getAsJsonArray().size(), - result.getCustomizations().size()); - assertEquals(acousticModels.get("customizations"), GSON.toJsonTree(result.getCustomizations())); + // Construct an instance of the DeleteWordOptions model + DeleteWordOptions deleteWordOptionsModel = + new DeleteWordOptions.Builder() + .customizationId("testString") + .wordName("testString") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = speechToTextService.deleteWord(deleteWordOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteWordPath); + } + + // Test the deleteWord operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteWordNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + speechToTextService.deleteWord(null).execute(); } - /** - * Test get acoustic model. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ @Test - public void testGetAcousticModel() throws InterruptedException, FileNotFoundException { - String id = "foo"; - AcousticModel model = - loadFixture("src/test/resources/speech_to_text/acoustic-model.json", AcousticModel.class); + public void testListGrammarsWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"grammars\": [{\"name\": \"name\", \"out_of_vocabulary_words\": 20, \"status\": \"analyzed\", \"error\": \"error\"}]}"; + String listGrammarsPath = "/v1/customizations/testString/grammars"; server.enqueue( new MockResponse() - .addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON) - .setBody(GSON.toJson(model))); + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); - GetAcousticModelOptions getOptions = - new GetAcousticModelOptions.Builder().customizationId(id).build(); - AcousticModel result = service.getAcousticModel(getOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); + constructClientService(); - assertEquals("GET", request.getMethod()); - assertEquals(String.format(PATH_ACOUSTIC_CUSTOMIZATION, id), request.getPath()); - assertEquals(result.toString(), model.toString()); - assertEquals(UPDATED, result.getUpdated()); + // Construct an instance of the ListGrammarsOptions model + ListGrammarsOptions listGrammarsOptionsModel = + new ListGrammarsOptions.Builder().customizationId("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = + speechToTextService.listGrammars(listGrammarsOptionsModel).execute(); + assertNotNull(response); + Grammars responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listGrammarsPath); + } + + // Test the listGrammars operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListGrammarsNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + speechToTextService.listGrammars(null).execute(); } - /** - * Test delete acoustic model. - * - * @throws InterruptedException the interrupted exception - */ @Test - public void testDeleteAcousticModel() throws InterruptedException { - String id = "foo"; + public void testAddGrammarWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String addGrammarPath = "/v1/customizations/testString/grammars/testString"; - server.enqueue( - new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody("{}")); + server.enqueue(new MockResponse().setResponseCode(201).setBody(mockResponseBody)); - DeleteAcousticModelOptions deleteOptions = - new DeleteAcousticModelOptions.Builder().customizationId(id).build(); - service.deleteAcousticModel(deleteOptions).execute(); - final RecordedRequest request = server.takeRequest(); + constructClientService(); + + // Construct an instance of the AddGrammarOptions model + AddGrammarOptions addGrammarOptionsModel = + new AddGrammarOptions.Builder() + .customizationId("testString") + .grammarName("testString") + .grammarFile(TestUtilities.createMockStream("This is a mock file.")) + .contentType("application/srgs") + .allowOverwrite(true) + .build(); - assertEquals("DELETE", request.getMethod()); - assertEquals(String.format(PATH_ACOUSTIC_CUSTOMIZATION, id), request.getPath()); + // Invoke operation with valid options model (positive test) + Response response = speechToTextService.addGrammar(addGrammarOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + assertEquals(request.getHeader("Content-Type"), "application/srgs"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(Boolean.valueOf(query.get("allow_overwrite")), Boolean.valueOf(true)); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, addGrammarPath); + } + + // Test the addGrammar operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAddGrammarNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + speechToTextService.addGrammar(null).execute(); } - /** - * Test train acoustic model. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ @Test - public void testTrainAcousticModel() throws InterruptedException, FileNotFoundException { + public void testGetGrammarWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"name\": \"name\", \"out_of_vocabulary_words\": 20, \"status\": \"analyzed\", \"error\": \"error\"}"; + String getGrammarPath = "/v1/customizations/testString/grammars/testString"; + server.enqueue( - new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody("{}")); - String id = "foo"; - String languageModelId = "bar"; + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); - TrainAcousticModelOptions trainOptions = - new TrainAcousticModelOptions.Builder() - .customizationId(id) - .customLanguageModelId(languageModelId) + constructClientService(); + + // Construct an instance of the GetGrammarOptions model + GetGrammarOptions getGrammarOptionsModel = + new GetGrammarOptions.Builder() + .customizationId("testString") + .grammarName("testString") .build(); - service.trainAcousticModel(trainOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - assertEquals("POST", request.getMethod()); - assertEquals( - String.format(PATH_ACOUSTIC_TRAIN, id) + "?custom_language_model_id=bar", - request.getPath()); + // Invoke operation with valid options model (positive test) + Response response = speechToTextService.getGrammar(getGrammarOptionsModel).execute(); + assertNotNull(response); + Grammar responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getGrammarPath); } - /** - * Test reset acoustic model. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ - @Test - public void testResetAcousticModel() throws InterruptedException, FileNotFoundException { - server.enqueue( - new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody("{}")); - String id = "foo"; + // Test the getGrammar operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetGrammarNoOptions() throws Throwable { + // construct the service + constructClientService(); - ResetAcousticModelOptions resetOptions = - new ResetAcousticModelOptions.Builder().customizationId(id).build(); - service.resetAcousticModel(resetOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); + server.enqueue(new MockResponse()); - assertEquals("POST", request.getMethod()); - assertEquals(String.format(PATH_ACOUSTIC_RESET, id), request.getPath()); + // Invoke operation with null options model (negative test) + speechToTextService.getGrammar(null).execute(); } - /** - * Test upgrade acoustic model. - * - * @throws InterruptedException the interrupted exception - */ @Test - public void testUpgradeAcousticModel() throws InterruptedException { - server.enqueue( - new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody("{}")); - String id = "foo"; - String languageModelId = "modelId"; + public void testDeleteGrammarWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String deleteGrammarPath = "/v1/customizations/testString/grammars/testString"; - UpgradeAcousticModelOptions upgradeOptions = - new UpgradeAcousticModelOptions.Builder() - .customizationId(id) - .customLanguageModelId(languageModelId) - .force(true) + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the DeleteGrammarOptions model + DeleteGrammarOptions deleteGrammarOptionsModel = + new DeleteGrammarOptions.Builder() + .customizationId("testString") + .grammarName("testString") .build(); - upgradeOptions = upgradeOptions.newBuilder().build(); - service.upgradeAcousticModel(upgradeOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - assertEquals("POST", request.getMethod()); - assertEquals( - String.format(PATH_ACOUSTIC_UPGRADE, id) - + "?custom_language_model_id=" - + languageModelId - + "&force=true", - request.getPath()); - } - - /** - * Test add audio. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ + // Invoke operation with valid options model (positive test) + Response response = + speechToTextService.deleteGrammar(deleteGrammarOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteGrammarPath); + } + + // Test the deleteGrammar operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteGrammarNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + speechToTextService.deleteGrammar(null).execute(); + } + @Test - public void testAddAudio() throws InterruptedException, FileNotFoundException { + public void testCreateAcousticModelWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"customization_id\": \"customizationId\", \"created\": \"created\", \"updated\": \"updated\", \"language\": \"language\", \"versions\": [\"versions\"], \"owner\": \"owner\", \"name\": \"name\", \"description\": \"description\", \"base_model_name\": \"baseModelName\", \"status\": \"pending\", \"progress\": 8, \"warnings\": \"warnings\"}"; + String createAcousticModelPath = "/v1/acoustic_customizations"; + server.enqueue( - new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody("{}")); - String id = "foo"; - String audioName = "test_file"; + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(201) + .setBody(mockResponseBody)); - AddAudioOptions addOptions = - new AddAudioOptions.Builder() - .customizationId(id) - .audioResource(SAMPLE_WAV) - .contentType(HttpMediaType.AUDIO_WAV) - .audioName(audioName) - .allowOverwrite(true) + constructClientService(); + + // Construct an instance of the CreateAcousticModelOptions model + CreateAcousticModelOptions createAcousticModelOptionsModel = + new CreateAcousticModelOptions.Builder() + .name("testString") + .baseModelName("ar-AR_BroadbandModel") + .description("testString") .build(); - service.addAudio(addOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - assertEquals("POST", request.getMethod()); - assertEquals( - String.format(PATH_SPECIFIC_AUDIO, id, audioName) + "?allow_overwrite=true", - request.getPath()); + // Invoke operation with valid options model (positive test) + Response response = + speechToTextService.createAcousticModel(createAcousticModelOptionsModel).execute(); + assertNotNull(response); + AcousticModel responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createAcousticModelPath); + } + + // Test the createAcousticModel operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateAcousticModelNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + speechToTextService.createAcousticModel(null).execute(); } - /** - * Test list audio. - * - * @throws FileNotFoundException the file not found exception - * @throws InterruptedException the interrupted exception - */ @Test - public void testListAudio() throws FileNotFoundException, InterruptedException { - String resourcesAsString = - getStringFromInputStream( - new FileInputStream("src/test/resources/speech_to_text/audio-resources.json")); - JsonObject audioResources = new JsonParser().parse(resourcesAsString).getAsJsonObject(); - String id = "foo"; + public void testListAcousticModelsWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"customizations\": [{\"customization_id\": \"customizationId\", \"created\": \"created\", \"updated\": \"updated\", \"language\": \"language\", \"versions\": [\"versions\"], \"owner\": \"owner\", \"name\": \"name\", \"description\": \"description\", \"base_model_name\": \"baseModelName\", \"status\": \"pending\", \"progress\": 8, \"warnings\": \"warnings\"}]}"; + String listAcousticModelsPath = "/v1/acoustic_customizations"; server.enqueue( new MockResponse() - .addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON) - .setBody(resourcesAsString)); + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); - ListAudioOptions listOptions = new ListAudioOptions.Builder().customizationId(id).build(); - AudioResources result = service.listAudio(listOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); + // Construct an instance of the ListAcousticModelsOptions model + ListAcousticModelsOptions listAcousticModelsOptionsModel = + new ListAcousticModelsOptions.Builder().language("ar-AR").build(); - assertEquals("GET", request.getMethod()); - assertEquals(String.format(PATH_ALL_AUDIO, id), request.getPath()); - assertEquals(audioResources.get("audio").getAsJsonArray().size(), result.getAudio().size()); - assertEquals(audioResources.get("audio"), GSON.toJsonTree(result.getAudio())); + // Invoke operation with valid options model (positive test) + Response response = + speechToTextService.listAcousticModels(listAcousticModelsOptionsModel).execute(); + assertNotNull(response); + AcousticModels responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("language"), "ar-AR"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listAcousticModelsPath); } - /** - * Test get audio. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ @Test - public void testGetAudio() throws InterruptedException, FileNotFoundException { - String id = "foo"; - String audioName = "audio1"; - AudioResource audio = - loadFixture("src/test/resources/speech_to_text/audio-resource.json", AudioResource.class); + public void testGetAcousticModelWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"customization_id\": \"customizationId\", \"created\": \"created\", \"updated\": \"updated\", \"language\": \"language\", \"versions\": [\"versions\"], \"owner\": \"owner\", \"name\": \"name\", \"description\": \"description\", \"base_model_name\": \"baseModelName\", \"status\": \"pending\", \"progress\": 8, \"warnings\": \"warnings\"}"; + String getAcousticModelPath = "/v1/acoustic_customizations/testString"; server.enqueue( new MockResponse() - .addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON) - .setBody(GSON.toJson(audio))); - - GetAudioOptions getOptions = - new GetAudioOptions.Builder().customizationId(id).audioName(audioName).build(); - AudioListing result = service.getAudio(getOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - - assertEquals("GET", request.getMethod()); - assertEquals(String.format(PATH_SPECIFIC_AUDIO, id, audioName), request.getPath()); - assertEquals(audio.getDetails(), result.getDetails()); - assertEquals(audio.getDuration(), result.getDuration()); - assertEquals(audio.getName(), result.getName()); - assertEquals(audio.getStatus(), result.getStatus()); - } - - /** - * Test delete audio. - * - * @throws InterruptedException the interrupted exception - */ + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the GetAcousticModelOptions model + GetAcousticModelOptions getAcousticModelOptionsModel = + new GetAcousticModelOptions.Builder().customizationId("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = + speechToTextService.getAcousticModel(getAcousticModelOptionsModel).execute(); + assertNotNull(response); + AcousticModel responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getAcousticModelPath); + } + + // Test the getAcousticModel operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetAcousticModelNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + speechToTextService.getAcousticModel(null).execute(); + } + @Test - public void testDeleteAudio() throws InterruptedException { - String id = "foo"; - String audioName = "audio1"; + public void testDeleteAcousticModelWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String deleteAcousticModelPath = "/v1/acoustic_customizations/testString"; - server.enqueue( - new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody("{}")); + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the DeleteAcousticModelOptions model + DeleteAcousticModelOptions deleteAcousticModelOptionsModel = + new DeleteAcousticModelOptions.Builder().customizationId("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = + speechToTextService.deleteAcousticModel(deleteAcousticModelOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); - DeleteAudioOptions deleteOptions = - new DeleteAudioOptions.Builder().customizationId(id).audioName(audioName).build(); - service.deleteAudio(deleteOptions).execute(); - final RecordedRequest request = server.takeRequest(); + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNull(query); - assertEquals("DELETE", request.getMethod()); - assertEquals(String.format(PATH_SPECIFIC_AUDIO, id, audioName), request.getPath()); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteAcousticModelPath); + } + + // Test the deleteAcousticModel operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteAcousticModelNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + speechToTextService.deleteAcousticModel(null).execute(); } - /** - * Test register callback. - * - * @throws FileNotFoundException the file not found exception - * @throws InterruptedException the interrupted exception - */ @Test - public void testRegisterCallback() throws FileNotFoundException, InterruptedException { - String callbackUrl = "http://testurl.com"; - String secret = "secret"; - RegisterStatus registerStatus = - loadFixture("src/test/resources/speech_to_text/register-status.json", RegisterStatus.class); + public void testTrainAcousticModelWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"warnings\": [{\"code\": \"invalid_audio_files\", \"message\": \"message\"}]}"; + String trainAcousticModelPath = "/v1/acoustic_customizations/testString/train"; server.enqueue( new MockResponse() - .addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON) - .setBody(GSON.toJson(registerStatus))); + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); - RegisterCallbackOptions registerOptions = - new RegisterCallbackOptions.Builder().callbackUrl(callbackUrl).userSecret(secret).build(); - RegisterStatus result = service.registerCallback(registerOptions).execute().getResult(); - final RecordedRequest registerRequest = server.takeRequest(); + constructClientService(); - assertEquals("POST", registerRequest.getMethod()); - assertEquals( - String.format( - REGISTER_CALLBACK, RequestUtils.encode(callbackUrl), RequestUtils.encode(secret)), - registerRequest.getPath()); - assertEquals(RegisterStatus.Status.CREATED, result.getStatus()); - assertEquals(callbackUrl, result.getUrl()); - } - - /** - * Test unregister callback. - * - * @throws InterruptedException the interrupted exception - */ - @Test - public void testUnregisterCallback() throws InterruptedException { - String callbackUrl = "http://testurl.com"; - server.enqueue( - new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody("{}")); + // Construct an instance of the TrainAcousticModelOptions model + TrainAcousticModelOptions trainAcousticModelOptionsModel = + new TrainAcousticModelOptions.Builder() + .customizationId("testString") + .customLanguageModelId("testString") + .build(); - UnregisterCallbackOptions unregisterOptions = - new UnregisterCallbackOptions.Builder().callbackUrl(callbackUrl).build(); - service.unregisterCallback(unregisterOptions).execute().getResult(); - final RecordedRequest unregisterRequest = server.takeRequest(); + // Invoke operation with valid options model (positive test) + Response response = + speechToTextService.trainAcousticModel(trainAcousticModelOptionsModel).execute(); + assertNotNull(response); + TrainingResponse responseObj = response.getResult(); + assertNotNull(responseObj); - assertEquals("POST", unregisterRequest.getMethod()); - assertEquals( - String.format(UNREGISTER_CALLBACK, RequestUtils.encode(callbackUrl)), - unregisterRequest.getPath()); + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("custom_language_model_id"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, trainAcousticModelPath); + } + + // Test the trainAcousticModel operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testTrainAcousticModelNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + speechToTextService.trainAcousticModel(null).execute(); } - /** - * Test closing input stream closes web socket. - * - * @throws Exception the exception - */ @Test - public void testClosingInputStreamClosesWebSocket() throws Exception { - TestRecognizeCallback callback = new TestRecognizeCallback(); - WebSocketRecorder webSocketRecorder = new WebSocketRecorder("server"); - PipedOutputStream outputStream = new PipedOutputStream(); - InputStream inputStream = new PipedInputStream(outputStream); - - server.enqueue(new MockResponse().withWebSocketUpgrade(webSocketRecorder)); - - String customizationId = "id"; - String version = "version"; - Double customizationWeight = 0.1; - RecognizeOptions options = - new RecognizeOptions.Builder() - .audio(inputStream) - .contentType(HttpMediaType.createAudioRaw(44000)) - .customizationId(customizationId) - .baseModelVersion(version) - .customizationWeight(customizationWeight) - .build(); - service.recognizeUsingWebSocket(options, callback); + public void testResetAcousticModelWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String resetAcousticModelPath = "/v1/acoustic_customizations/testString/reset"; + + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the ResetAcousticModelOptions model + ResetAcousticModelOptions resetAcousticModelOptionsModel = + new ResetAcousticModelOptions.Builder().customizationId("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = + speechToTextService.resetAcousticModel(resetAcousticModelOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); - WebSocket serverSocket = webSocketRecorder.assertOpen(); - serverSocket.send("{\"state\": {}}"); + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNull(query); - outputStream.write(ByteString.encodeUtf8("test").toByteArray()); - outputStream.close(); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, resetAcousticModelPath); + } - webSocketRecorder.assertTextMessage( - "{\"content-type\":\"audio/l16; rate=44000\"," - + "\"customization_weight\":0.1,\"action\":\"start\"}"); - webSocketRecorder.assertBinaryMessage(ByteString.encodeUtf8("test")); - webSocketRecorder.assertTextMessage("{\"action\":\"stop\"}"); - webSocketRecorder.assertExhausted(); + // Test the resetAcousticModel operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testResetAcousticModelNoOptions() throws Throwable { + // construct the service + constructClientService(); - serverSocket.close(1000, null); + server.enqueue(new MockResponse()); - callback.assertConnected(); - callback.assertDisconnected(); - callback.assertNoErrors(); - callback.assertOnTranscriptionComplete(); + // Invoke operation with null options model (negative test) + speechToTextService.resetAcousticModel(null).execute(); } - /** - * Test add grammar. - * - * @throws FileNotFoundException the file not found exception - * @throws InterruptedException the interrupted exception - */ @Test - public void testAddGrammar() throws FileNotFoundException, InterruptedException { - MockResponse desiredResponse = new MockResponse().setResponseCode(200); - server.enqueue(desiredResponse); + public void testUpgradeAcousticModelWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String upgradeAcousticModelPath = "/v1/acoustic_customizations/testString/upgrade_model"; - String customizationId = "id"; - String grammarName = "grammar_name"; - InputStream grammarFile = new FileInputStream(SAMPLE_WAV); + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); - AddGrammarOptions addGrammarOptions = - new AddGrammarOptions.Builder() - .customizationId(customizationId) - .grammarName(grammarName) - .grammarFile(grammarFile) - .contentType("application/srgs") + constructClientService(); + + // Construct an instance of the UpgradeAcousticModelOptions model + UpgradeAcousticModelOptions upgradeAcousticModelOptionsModel = + new UpgradeAcousticModelOptions.Builder() + .customizationId("testString") + .customLanguageModelId("testString") + .force(true) .build(); - service.addGrammar(addGrammarOptions).execute().getResult(); + + // Invoke operation with valid options model (positive test) + Response response = + speechToTextService.upgradeAcousticModel(upgradeAcousticModelOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); + + // Verify the contents of the request RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("custom_language_model_id"), "testString"); + assertEquals(Boolean.valueOf(query.get("force")), Boolean.valueOf(true)); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, upgradeAcousticModelPath); + } + + // Test the upgradeAcousticModel operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpgradeAcousticModelNoOptions() throws Throwable { + // construct the service + constructClientService(); - assertEquals(POST, request.getMethod()); + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + speechToTextService.upgradeAcousticModel(null).execute(); } - /** - * Test list grammars. - * - * @throws InterruptedException the interrupted exception - */ @Test - public void testListGrammars() throws InterruptedException { - server.enqueue(jsonResponse(grammars)); + public void testListAudioWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"total_minutes_of_audio\": 19, \"audio\": [{\"duration\": 8, \"name\": \"name\", \"details\": {\"type\": \"audio\", \"codec\": \"codec\", \"frequency\": 9, \"compression\": \"zip\"}, \"status\": \"ok\"}]}"; + String listAudioPath = "/v1/acoustic_customizations/testString/audio"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); - String customizationId = "id"; + constructClientService(); - ListGrammarsOptions listGrammarsOptions = - new ListGrammarsOptions.Builder().customizationId(customizationId).build(); - Grammars response = service.listGrammars(listGrammarsOptions).execute().getResult(); + // Construct an instance of the ListAudioOptions model + ListAudioOptions listAudioOptionsModel = + new ListAudioOptions.Builder().customizationId("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = + speechToTextService.listAudio(listAudioOptionsModel).execute(); + assertNotNull(response); + AudioResources responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listAudioPath); + } + + // Test the listAudio operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListAudioNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); - assertEquals(GET, request.getMethod()); - assertEquals(grammars, response); + // Invoke operation with null options model (negative test) + speechToTextService.listAudio(null).execute(); } - /** - * Test get grammar. - * - * @throws InterruptedException the interrupted exception - */ @Test - public void testGetGrammar() throws InterruptedException { - server.enqueue(jsonResponse(grammar)); + public void testAddAudioWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String addAudioPath = "/v1/acoustic_customizations/testString/audio/testString"; - String customizationId = "id"; - String grammarName = "grammar_name"; + server.enqueue(new MockResponse().setResponseCode(201).setBody(mockResponseBody)); - GetGrammarOptions getGrammarOptions = - new GetGrammarOptions.Builder() - .customizationId(customizationId) - .grammarName(grammarName) + constructClientService(); + + // Construct an instance of the AddAudioOptions model + AddAudioOptions addAudioOptionsModel = + new AddAudioOptions.Builder() + .customizationId("testString") + .audioName("testString") + .audioResource(TestUtilities.createMockStream("This is a mock file.")) + .contentType("application/zip") + .containedContentType("audio/alaw") + .allowOverwrite(true) .build(); - Grammar response = service.getGrammar(getGrammarOptions).execute().getResult(); + + // Invoke operation with valid options model (positive test) + Response response = speechToTextService.addAudio(addAudioOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); + + // Verify the contents of the request RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(Boolean.valueOf(query.get("allow_overwrite")), Boolean.valueOf(true)); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, addAudioPath); + } - assertEquals(GET, request.getMethod()); - assertEquals(grammar, response); + // Test the addAudio operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAddAudioNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + speechToTextService.addAudio(null).execute(); } - /** - * Test delete grammar. - * - * @throws InterruptedException the interrupted exception - */ @Test - public void testDeleteGrammar() throws InterruptedException { - MockResponse desiredResponse = new MockResponse().setResponseCode(200); - server.enqueue(desiredResponse); + public void testGetAudioWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"duration\": 8, \"name\": \"name\", \"details\": {\"type\": \"audio\", \"codec\": \"codec\", \"frequency\": 9, \"compression\": \"zip\"}, \"status\": \"ok\", \"container\": {\"duration\": 8, \"name\": \"name\", \"details\": {\"type\": \"audio\", \"codec\": \"codec\", \"frequency\": 9, \"compression\": \"zip\"}, \"status\": \"ok\"}, \"audio\": [{\"duration\": 8, \"name\": \"name\", \"details\": {\"type\": \"audio\", \"codec\": \"codec\", \"frequency\": 9, \"compression\": \"zip\"}, \"status\": \"ok\"}]}"; + String getAudioPath = "/v1/acoustic_customizations/testString/audio/testString"; - String customizationId = "id"; - String grammarName = "grammar_name"; + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); - DeleteGrammarOptions deleteGrammarOptions = - new DeleteGrammarOptions.Builder() - .customizationId(customizationId) - .grammarName(grammarName) - .build(); - service.deleteGrammar(deleteGrammarOptions).execute(); + constructClientService(); + + // Construct an instance of the GetAudioOptions model + GetAudioOptions getAudioOptionsModel = + new GetAudioOptions.Builder().customizationId("testString").audioName("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = speechToTextService.getAudio(getAudioOptionsModel).execute(); + assertNotNull(response); + AudioListing responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); - assertEquals(DELETE, request.getMethod()); + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getAudioPath); } - // --- HELPERS --- + // Test the getAudio operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetAudioNoOptions() throws Throwable { + // construct the service + constructClientService(); - private static class TestRecognizeCallback implements RecognizeCallback { + server.enqueue(new MockResponse()); - private final BlockingQueue speechResults = - new LinkedBlockingQueue<>(); + // Invoke operation with null options model (negative test) + speechToTextService.getAudio(null).execute(); + } - private final BlockingQueue errors = new LinkedBlockingQueue<>(); + @Test + public void testDeleteAudioWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String deleteAudioPath = "/v1/acoustic_customizations/testString/audio/testString"; - private final BlockingQueue onDisconnectedCalls = new LinkedBlockingQueue<>(); + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); - private final BlockingQueue onConnectedCalls = new LinkedBlockingQueue<>(); + constructClientService(); - private final BlockingQueue onTranscriptionCompleteCalls = new LinkedBlockingQueue<>(); + // Construct an instance of the DeleteAudioOptions model + DeleteAudioOptions deleteAudioOptionsModel = + new DeleteAudioOptions.Builder() + .customizationId("testString") + .audioName("testString") + .build(); - @Override - public void onTranscription(SpeechRecognitionResults speechResults) { - this.speechResults.add(speechResults); - } + // Invoke operation with valid options model (positive test) + Response response = speechToTextService.deleteAudio(deleteAudioOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); - @Override - public void onConnected() { - this.onConnectedCalls.add(new Object()); - } + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); - @Override - public void onError(Exception e) { - this.errors.add(e); - } + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNull(query); - @Override - public void onDisconnected() { - this.onDisconnectedCalls.add(new Object()); - } + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteAudioPath); + } - private void assertOnTranscriptionComplete() { - if (this.onTranscriptionCompleteCalls.size() == 1) { - throw new AssertionError( - "There were " + this.errors.size() + " calls to onTranscriptionComplete"); - } - } + // Test the deleteAudio operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteAudioNoOptions() throws Throwable { + // construct the service + constructClientService(); - private void assertConnected() { - try { - Object connectedEvent = this.onConnectedCalls.poll(10, TimeUnit.SECONDS); - if (connectedEvent == null) { - throw new AssertionError("Timed out waiting for connect."); - } - } catch (InterruptedException e) { - throw new AssertionError(e); - } - } + server.enqueue(new MockResponse()); - private void assertDisconnected() { - try { - Object disconnectedEvent = this.onDisconnectedCalls.poll(10, TimeUnit.SECONDS); - if (disconnectedEvent == null) { - throw new AssertionError("Timed out waiting for disconnect."); - } - } catch (InterruptedException e) { - throw new AssertionError(e); - } - } + // Invoke operation with null options model (negative test) + speechToTextService.deleteAudio(null).execute(); + } - private void assertNoErrors() { - if (this.errors.size() > 0) { - throw new AssertionError("There were " + this.errors.size() + " errors"); - } - } + @Test + public void testDeleteUserDataWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String deleteUserDataPath = "/v1/user_data"; + + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the DeleteUserDataOptions model + DeleteUserDataOptions deleteUserDataOptionsModel = + new DeleteUserDataOptions.Builder().customerId("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = + speechToTextService.deleteUserData(deleteUserDataOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); - @Override - public void onInactivityTimeout(RuntimeException runtimeException) {} + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("customer_id"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteUserDataPath); + } - @Override - public void onListening() {} + // Test the deleteUserData operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteUserDataNoOptions() throws Throwable { + // construct the service + constructClientService(); - @Override - public void onTranscriptionComplete() { - this.onTranscriptionCompleteCalls.add(new Object()); + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + speechToTextService.deleteUserData(null).execute(); + } + + /** Initialize the server */ + @BeforeMethod + public void setUpMockServer() { + try { + server = new MockWebServer(); + // register handler + server.start(); + } catch (IOException err) { + fail("Failed to instantiate mock web server"); } } + + @AfterMethod + public void tearDownMockServer() throws IOException { + server.shutdown(); + speechToTextService = null; + } } diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AcousticModelTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AcousticModelTest.java new file mode 100644 index 00000000000..9180df7ad58 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AcousticModelTest.java @@ -0,0 +1,47 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the AcousticModel model. */ +public class AcousticModelTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAcousticModel() throws Throwable { + AcousticModel acousticModelModel = new AcousticModel(); + assertNull(acousticModelModel.getCustomizationId()); + assertNull(acousticModelModel.getCreated()); + assertNull(acousticModelModel.getUpdated()); + assertNull(acousticModelModel.getLanguage()); + assertNull(acousticModelModel.getVersions()); + assertNull(acousticModelModel.getOwner()); + assertNull(acousticModelModel.getName()); + assertNull(acousticModelModel.getDescription()); + assertNull(acousticModelModel.getBaseModelName()); + assertNull(acousticModelModel.getStatus()); + assertNull(acousticModelModel.getProgress()); + assertNull(acousticModelModel.getWarnings()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AcousticModelsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AcousticModelsTest.java new file mode 100644 index 00000000000..1fc1e642ecb --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AcousticModelsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the AcousticModels model. */ +public class AcousticModelsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAcousticModels() throws Throwable { + AcousticModels acousticModelsModel = new AcousticModels(); + assertNull(acousticModelsModel.getCustomizations()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AddAudioOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AddAudioOptionsTest.java new file mode 100644 index 00000000000..2c78288cb26 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AddAudioOptionsTest.java @@ -0,0 +1,57 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.apache.commons.io.IOUtils; +import org.testng.annotations.Test; + +/** Unit test class for the AddAudioOptions model. */ +public class AddAudioOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAddAudioOptions() throws Throwable { + AddAudioOptions addAudioOptionsModel = + new AddAudioOptions.Builder() + .customizationId("testString") + .audioName("testString") + .audioResource(TestUtilities.createMockStream("This is a mock file.")) + .contentType("application/zip") + .containedContentType("audio/alaw") + .allowOverwrite(true) + .build(); + assertEquals(addAudioOptionsModel.customizationId(), "testString"); + assertEquals(addAudioOptionsModel.audioName(), "testString"); + assertEquals( + IOUtils.toString(addAudioOptionsModel.audioResource()), + IOUtils.toString(TestUtilities.createMockStream("This is a mock file."))); + assertEquals(addAudioOptionsModel.contentType(), "application/zip"); + assertEquals(addAudioOptionsModel.containedContentType(), "audio/alaw"); + assertEquals(addAudioOptionsModel.allowOverwrite(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAddAudioOptionsError() throws Throwable { + new AddAudioOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AddCorpusOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AddCorpusOptionsTest.java new file mode 100644 index 00000000000..382d2a825a7 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AddCorpusOptionsTest.java @@ -0,0 +1,53 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.apache.commons.io.IOUtils; +import org.testng.annotations.Test; + +/** Unit test class for the AddCorpusOptions model. */ +public class AddCorpusOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAddCorpusOptions() throws Throwable { + AddCorpusOptions addCorpusOptionsModel = + new AddCorpusOptions.Builder() + .customizationId("testString") + .corpusName("testString") + .corpusFile(TestUtilities.createMockStream("This is a mock file.")) + .allowOverwrite(true) + .build(); + assertEquals(addCorpusOptionsModel.customizationId(), "testString"); + assertEquals(addCorpusOptionsModel.corpusName(), "testString"); + assertEquals( + IOUtils.toString(addCorpusOptionsModel.corpusFile()), + IOUtils.toString(TestUtilities.createMockStream("This is a mock file."))); + assertEquals(addCorpusOptionsModel.allowOverwrite(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAddCorpusOptionsError() throws Throwable { + new AddCorpusOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AddGrammarOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AddGrammarOptionsTest.java new file mode 100644 index 00000000000..5d1653beeb9 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AddGrammarOptionsTest.java @@ -0,0 +1,55 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.apache.commons.io.IOUtils; +import org.testng.annotations.Test; + +/** Unit test class for the AddGrammarOptions model. */ +public class AddGrammarOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAddGrammarOptions() throws Throwable { + AddGrammarOptions addGrammarOptionsModel = + new AddGrammarOptions.Builder() + .customizationId("testString") + .grammarName("testString") + .grammarFile(TestUtilities.createMockStream("This is a mock file.")) + .contentType("application/srgs") + .allowOverwrite(true) + .build(); + assertEquals(addGrammarOptionsModel.customizationId(), "testString"); + assertEquals(addGrammarOptionsModel.grammarName(), "testString"); + assertEquals( + IOUtils.toString(addGrammarOptionsModel.grammarFile()), + IOUtils.toString(TestUtilities.createMockStream("This is a mock file."))); + assertEquals(addGrammarOptionsModel.contentType(), "application/srgs"); + assertEquals(addGrammarOptionsModel.allowOverwrite(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAddGrammarOptionsError() throws Throwable { + new AddGrammarOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AddWordOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AddWordOptionsTest.java new file mode 100644 index 00000000000..7e0fbeb1170 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AddWordOptionsTest.java @@ -0,0 +1,54 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the AddWordOptions model. */ +public class AddWordOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAddWordOptions() throws Throwable { + AddWordOptions addWordOptionsModel = + new AddWordOptions.Builder() + .customizationId("testString") + .wordName("testString") + .word("testString") + .soundsLike(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .displayAs("testString") + .build(); + assertEquals(addWordOptionsModel.customizationId(), "testString"); + assertEquals(addWordOptionsModel.wordName(), "testString"); + assertEquals(addWordOptionsModel.word(), "testString"); + assertEquals( + addWordOptionsModel.soundsLike(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals(addWordOptionsModel.displayAs(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAddWordOptionsError() throws Throwable { + new AddWordOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AddWordsOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AddWordsOptionsTest.java new file mode 100644 index 00000000000..a773744d3e6 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AddWordsOptionsTest.java @@ -0,0 +1,60 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the AddWordsOptions model. */ +public class AddWordsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAddWordsOptions() throws Throwable { + CustomWord customWordModel = + new CustomWord.Builder() + .word("testString") + .soundsLike(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .displayAs("testString") + .build(); + assertEquals(customWordModel.word(), "testString"); + assertEquals( + customWordModel.soundsLike(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals(customWordModel.displayAs(), "testString"); + + AddWordsOptions addWordsOptionsModel = + new AddWordsOptions.Builder() + .customizationId("testString") + .words(new java.util.ArrayList(java.util.Arrays.asList(customWordModel))) + .build(); + assertEquals(addWordsOptionsModel.customizationId(), "testString"); + assertEquals( + addWordsOptionsModel.words(), + new java.util.ArrayList(java.util.Arrays.asList(customWordModel))); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAddWordsOptionsError() throws Throwable { + new AddWordsOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AudioDetailsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AudioDetailsTest.java new file mode 100644 index 00000000000..38728466449 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AudioDetailsTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the AudioDetails model. */ +public class AudioDetailsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAudioDetails() throws Throwable { + AudioDetails audioDetailsModel = new AudioDetails(); + assertNull(audioDetailsModel.getType()); + assertNull(audioDetailsModel.getCodec()); + assertNull(audioDetailsModel.getFrequency()); + assertNull(audioDetailsModel.getCompression()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AudioListingTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AudioListingTest.java new file mode 100644 index 00000000000..7e1aa576348 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AudioListingTest.java @@ -0,0 +1,41 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the AudioListing model. */ +public class AudioListingTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAudioListing() throws Throwable { + AudioListing audioListingModel = new AudioListing(); + assertNull(audioListingModel.getDuration()); + assertNull(audioListingModel.getName()); + assertNull(audioListingModel.getDetails()); + assertNull(audioListingModel.getStatus()); + assertNull(audioListingModel.getContainer()); + assertNull(audioListingModel.getAudio()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AudioMetricsDetailsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AudioMetricsDetailsTest.java new file mode 100644 index 00000000000..7cb5329561f --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AudioMetricsDetailsTest.java @@ -0,0 +1,44 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the AudioMetricsDetails model. */ +public class AudioMetricsDetailsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAudioMetricsDetails() throws Throwable { + AudioMetricsDetails audioMetricsDetailsModel = new AudioMetricsDetails(); + assertNull(audioMetricsDetailsModel.isXFinal()); + assertNull(audioMetricsDetailsModel.getEndTime()); + assertNull(audioMetricsDetailsModel.getSignalToNoiseRatio()); + assertNull(audioMetricsDetailsModel.getSpeechRatio()); + assertNull(audioMetricsDetailsModel.getHighFrequencyLoss()); + assertNull(audioMetricsDetailsModel.getDirectCurrentOffset()); + assertNull(audioMetricsDetailsModel.getClippingRate()); + assertNull(audioMetricsDetailsModel.getSpeechLevel()); + assertNull(audioMetricsDetailsModel.getNonSpeechLevel()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AudioMetricsHistogramBinTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AudioMetricsHistogramBinTest.java new file mode 100644 index 00000000000..08fd0da60d0 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AudioMetricsHistogramBinTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the AudioMetricsHistogramBin model. */ +public class AudioMetricsHistogramBinTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAudioMetricsHistogramBin() throws Throwable { + AudioMetricsHistogramBin audioMetricsHistogramBinModel = new AudioMetricsHistogramBin(); + assertNull(audioMetricsHistogramBinModel.getBegin()); + assertNull(audioMetricsHistogramBinModel.getEnd()); + assertNull(audioMetricsHistogramBinModel.getCount()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AudioMetricsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AudioMetricsTest.java new file mode 100644 index 00000000000..424bbf06d45 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AudioMetricsTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the AudioMetrics model. */ +public class AudioMetricsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAudioMetrics() throws Throwable { + AudioMetrics audioMetricsModel = new AudioMetrics(); + assertNull(audioMetricsModel.getSamplingInterval()); + assertNull(audioMetricsModel.getAccumulated()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AudioResourceTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AudioResourceTest.java new file mode 100644 index 00000000000..12834c7260b --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AudioResourceTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the AudioResource model. */ +public class AudioResourceTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAudioResource() throws Throwable { + AudioResource audioResourceModel = new AudioResource(); + assertNull(audioResourceModel.getDuration()); + assertNull(audioResourceModel.getName()); + assertNull(audioResourceModel.getDetails()); + assertNull(audioResourceModel.getStatus()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AudioResourcesTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AudioResourcesTest.java new file mode 100644 index 00000000000..d24afe32521 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/AudioResourcesTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the AudioResources model. */ +public class AudioResourcesTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAudioResources() throws Throwable { + AudioResources audioResourcesModel = new AudioResources(); + assertNull(audioResourcesModel.getTotalMinutesOfAudio()); + assertNull(audioResourcesModel.getAudio()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/CheckJobOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/CheckJobOptionsTest.java new file mode 100644 index 00000000000..e19a826742d --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/CheckJobOptionsTest.java @@ -0,0 +1,41 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CheckJobOptions model. */ +public class CheckJobOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCheckJobOptions() throws Throwable { + CheckJobOptions checkJobOptionsModel = new CheckJobOptions.Builder().id("testString").build(); + assertEquals(checkJobOptionsModel.id(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCheckJobOptionsError() throws Throwable { + new CheckJobOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/CheckJobsOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/CheckJobsOptionsTest.java new file mode 100644 index 00000000000..36063074f5c --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/CheckJobsOptionsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CheckJobsOptions model. */ +public class CheckJobsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCheckJobsOptions() throws Throwable { + CheckJobsOptions checkJobsOptionsModel = new CheckJobsOptions(); + assertNotNull(checkJobsOptionsModel); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/CorporaTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/CorporaTest.java new file mode 100644 index 00000000000..1ca388222a5 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/CorporaTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Corpora model. */ +public class CorporaTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCorpora() throws Throwable { + Corpora corporaModel = new Corpora(); + assertNull(corporaModel.getCorpora()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/CorpusTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/CorpusTest.java new file mode 100644 index 00000000000..5ad24853e7d --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/CorpusTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Corpus model. */ +public class CorpusTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCorpus() throws Throwable { + Corpus corpusModel = new Corpus(); + assertNull(corpusModel.getName()); + assertNull(corpusModel.getTotalWords()); + assertNull(corpusModel.getOutOfVocabularyWords()); + assertNull(corpusModel.getStatus()); + assertNull(corpusModel.getError()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/CreateAcousticModelOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/CreateAcousticModelOptionsTest.java new file mode 100644 index 00000000000..6ae680686b2 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/CreateAcousticModelOptionsTest.java @@ -0,0 +1,48 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateAcousticModelOptions model. */ +public class CreateAcousticModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateAcousticModelOptions() throws Throwable { + CreateAcousticModelOptions createAcousticModelOptionsModel = + new CreateAcousticModelOptions.Builder() + .name("testString") + .baseModelName("ar-AR_BroadbandModel") + .description("testString") + .build(); + assertEquals(createAcousticModelOptionsModel.name(), "testString"); + assertEquals(createAcousticModelOptionsModel.baseModelName(), "ar-AR_BroadbandModel"); + assertEquals(createAcousticModelOptionsModel.description(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateAcousticModelOptionsError() throws Throwable { + new CreateAcousticModelOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/CreateJobOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/CreateJobOptionsTest.java new file mode 100644 index 00000000000..0019a6e5761 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/CreateJobOptionsTest.java @@ -0,0 +1,109 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.apache.commons.io.IOUtils; +import org.testng.annotations.Test; + +/** Unit test class for the CreateJobOptions model. */ +public class CreateJobOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateJobOptions() throws Throwable { + CreateJobOptions createJobOptionsModel = + new CreateJobOptions.Builder() + .audio(TestUtilities.createMockStream("This is a mock file.")) + .contentType("application/octet-stream") + .model("ar-AR_BroadbandModel") + .callbackUrl("testString") + .events("recognitions.started") + .userToken("testString") + .resultsTtl(Long.valueOf("26")) + .languageCustomizationId("testString") + .acousticCustomizationId("testString") + .baseModelVersion("testString") + .customizationWeight(Double.valueOf("72.5")) + .inactivityTimeout(Long.valueOf("26")) + .keywords(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .keywordsThreshold(Float.valueOf("36.0")) + .maxAlternatives(Long.valueOf("26")) + .wordAlternativesThreshold(Float.valueOf("36.0")) + .wordConfidence(true) + .timestamps(true) + .profanityFilter(true) + .smartFormatting(true) + .speakerLabels(true) + .customizationId("testString") + .grammarName("testString") + .redaction(true) + .processingMetrics(true) + .processingMetricsInterval(Float.valueOf("36.0")) + .audioMetrics(true) + .endOfPhraseSilenceTime(Double.valueOf("72.5")) + .splitTranscriptAtPhraseEnd(true) + .speechDetectorSensitivity(Float.valueOf("36.0")) + .backgroundAudioSuppression(Float.valueOf("36.0")) + .build(); + assertEquals( + IOUtils.toString(createJobOptionsModel.audio()), + IOUtils.toString(TestUtilities.createMockStream("This is a mock file."))); + assertEquals(createJobOptionsModel.contentType(), "application/octet-stream"); + assertEquals(createJobOptionsModel.model(), "ar-AR_BroadbandModel"); + assertEquals(createJobOptionsModel.callbackUrl(), "testString"); + assertEquals(createJobOptionsModel.events(), "recognitions.started"); + assertEquals(createJobOptionsModel.userToken(), "testString"); + assertEquals(createJobOptionsModel.resultsTtl(), Long.valueOf("26")); + assertEquals(createJobOptionsModel.languageCustomizationId(), "testString"); + assertEquals(createJobOptionsModel.acousticCustomizationId(), "testString"); + assertEquals(createJobOptionsModel.baseModelVersion(), "testString"); + assertEquals(createJobOptionsModel.customizationWeight(), Double.valueOf("72.5")); + assertEquals(createJobOptionsModel.inactivityTimeout(), Long.valueOf("26")); + assertEquals( + createJobOptionsModel.keywords(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals(createJobOptionsModel.keywordsThreshold(), Float.valueOf("36.0")); + assertEquals(createJobOptionsModel.maxAlternatives(), Long.valueOf("26")); + assertEquals(createJobOptionsModel.wordAlternativesThreshold(), Float.valueOf("36.0")); + assertEquals(createJobOptionsModel.wordConfidence(), Boolean.valueOf(true)); + assertEquals(createJobOptionsModel.timestamps(), Boolean.valueOf(true)); + assertEquals(createJobOptionsModel.profanityFilter(), Boolean.valueOf(true)); + assertEquals(createJobOptionsModel.smartFormatting(), Boolean.valueOf(true)); + assertEquals(createJobOptionsModel.speakerLabels(), Boolean.valueOf(true)); + assertEquals(createJobOptionsModel.customizationId(), "testString"); + assertEquals(createJobOptionsModel.grammarName(), "testString"); + assertEquals(createJobOptionsModel.redaction(), Boolean.valueOf(true)); + assertEquals(createJobOptionsModel.processingMetrics(), Boolean.valueOf(true)); + assertEquals(createJobOptionsModel.processingMetricsInterval(), Float.valueOf("36.0")); + assertEquals(createJobOptionsModel.audioMetrics(), Boolean.valueOf(true)); + assertEquals(createJobOptionsModel.endOfPhraseSilenceTime(), Double.valueOf("72.5")); + assertEquals(createJobOptionsModel.splitTranscriptAtPhraseEnd(), Boolean.valueOf(true)); + assertEquals(createJobOptionsModel.speechDetectorSensitivity(), Float.valueOf("36.0")); + assertEquals(createJobOptionsModel.backgroundAudioSuppression(), Float.valueOf("36.0")); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateJobOptionsError() throws Throwable { + new CreateJobOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/CreateLanguageModelOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/CreateLanguageModelOptionsTest.java new file mode 100644 index 00000000000..51a644b9676 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/CreateLanguageModelOptionsTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateLanguageModelOptions model. */ +public class CreateLanguageModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateLanguageModelOptions() throws Throwable { + CreateLanguageModelOptions createLanguageModelOptionsModel = + new CreateLanguageModelOptions.Builder() + .name("testString") + .baseModelName("de-DE_BroadbandModel") + .dialect("testString") + .description("testString") + .build(); + assertEquals(createLanguageModelOptionsModel.name(), "testString"); + assertEquals(createLanguageModelOptionsModel.baseModelName(), "de-DE_BroadbandModel"); + assertEquals(createLanguageModelOptionsModel.dialect(), "testString"); + assertEquals(createLanguageModelOptionsModel.description(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateLanguageModelOptionsError() throws Throwable { + new CreateLanguageModelOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/CustomWordTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/CustomWordTest.java new file mode 100644 index 00000000000..2374e701549 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/CustomWordTest.java @@ -0,0 +1,52 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CustomWord model. */ +public class CustomWordTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCustomWord() throws Throwable { + CustomWord customWordModel = + new CustomWord.Builder() + .word("testString") + .soundsLike(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .displayAs("testString") + .build(); + assertEquals(customWordModel.word(), "testString"); + assertEquals( + customWordModel.soundsLike(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals(customWordModel.displayAs(), "testString"); + + String json = TestUtilities.serialize(customWordModel); + + CustomWord customWordModelNew = TestUtilities.deserialize(json, CustomWord.class); + assertTrue(customWordModelNew instanceof CustomWord); + assertEquals(customWordModelNew.word(), "testString"); + assertEquals(customWordModelNew.displayAs(), "testString"); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/DeleteAcousticModelOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/DeleteAcousticModelOptionsTest.java new file mode 100644 index 00000000000..da37e0aff2c --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/DeleteAcousticModelOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteAcousticModelOptions model. */ +public class DeleteAcousticModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteAcousticModelOptions() throws Throwable { + DeleteAcousticModelOptions deleteAcousticModelOptionsModel = + new DeleteAcousticModelOptions.Builder().customizationId("testString").build(); + assertEquals(deleteAcousticModelOptionsModel.customizationId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteAcousticModelOptionsError() throws Throwable { + new DeleteAcousticModelOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/DeleteAudioOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/DeleteAudioOptionsTest.java new file mode 100644 index 00000000000..1f819c3cac1 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/DeleteAudioOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteAudioOptions model. */ +public class DeleteAudioOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteAudioOptions() throws Throwable { + DeleteAudioOptions deleteAudioOptionsModel = + new DeleteAudioOptions.Builder() + .customizationId("testString") + .audioName("testString") + .build(); + assertEquals(deleteAudioOptionsModel.customizationId(), "testString"); + assertEquals(deleteAudioOptionsModel.audioName(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteAudioOptionsError() throws Throwable { + new DeleteAudioOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/DeleteCorpusOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/DeleteCorpusOptionsTest.java new file mode 100644 index 00000000000..fac8f8acf39 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/DeleteCorpusOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteCorpusOptions model. */ +public class DeleteCorpusOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteCorpusOptions() throws Throwable { + DeleteCorpusOptions deleteCorpusOptionsModel = + new DeleteCorpusOptions.Builder() + .customizationId("testString") + .corpusName("testString") + .build(); + assertEquals(deleteCorpusOptionsModel.customizationId(), "testString"); + assertEquals(deleteCorpusOptionsModel.corpusName(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteCorpusOptionsError() throws Throwable { + new DeleteCorpusOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/DeleteGrammarOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/DeleteGrammarOptionsTest.java new file mode 100644 index 00000000000..ec4c32d20f8 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/DeleteGrammarOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteGrammarOptions model. */ +public class DeleteGrammarOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteGrammarOptions() throws Throwable { + DeleteGrammarOptions deleteGrammarOptionsModel = + new DeleteGrammarOptions.Builder() + .customizationId("testString") + .grammarName("testString") + .build(); + assertEquals(deleteGrammarOptionsModel.customizationId(), "testString"); + assertEquals(deleteGrammarOptionsModel.grammarName(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteGrammarOptionsError() throws Throwable { + new DeleteGrammarOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/DeleteJobOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/DeleteJobOptionsTest.java new file mode 100644 index 00000000000..6e60a6c131e --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/DeleteJobOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteJobOptions model. */ +public class DeleteJobOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteJobOptions() throws Throwable { + DeleteJobOptions deleteJobOptionsModel = + new DeleteJobOptions.Builder().id("testString").build(); + assertEquals(deleteJobOptionsModel.id(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteJobOptionsError() throws Throwable { + new DeleteJobOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/DeleteLanguageModelOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/DeleteLanguageModelOptionsTest.java new file mode 100644 index 00000000000..3d6196b5c09 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/DeleteLanguageModelOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteLanguageModelOptions model. */ +public class DeleteLanguageModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteLanguageModelOptions() throws Throwable { + DeleteLanguageModelOptions deleteLanguageModelOptionsModel = + new DeleteLanguageModelOptions.Builder().customizationId("testString").build(); + assertEquals(deleteLanguageModelOptionsModel.customizationId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteLanguageModelOptionsError() throws Throwable { + new DeleteLanguageModelOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/DeleteUserDataOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/DeleteUserDataOptionsTest.java new file mode 100644 index 00000000000..0ceb8f6b6ec --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/DeleteUserDataOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteUserDataOptions model. */ +public class DeleteUserDataOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteUserDataOptions() throws Throwable { + DeleteUserDataOptions deleteUserDataOptionsModel = + new DeleteUserDataOptions.Builder().customerId("testString").build(); + assertEquals(deleteUserDataOptionsModel.customerId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteUserDataOptionsError() throws Throwable { + new DeleteUserDataOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/DeleteWordOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/DeleteWordOptionsTest.java new file mode 100644 index 00000000000..236c8409cef --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/DeleteWordOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteWordOptions model. */ +public class DeleteWordOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteWordOptions() throws Throwable { + DeleteWordOptions deleteWordOptionsModel = + new DeleteWordOptions.Builder() + .customizationId("testString") + .wordName("testString") + .build(); + assertEquals(deleteWordOptionsModel.customizationId(), "testString"); + assertEquals(deleteWordOptionsModel.wordName(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteWordOptionsError() throws Throwable { + new DeleteWordOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/GetAcousticModelOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/GetAcousticModelOptionsTest.java new file mode 100644 index 00000000000..5418cf925af --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/GetAcousticModelOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetAcousticModelOptions model. */ +public class GetAcousticModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetAcousticModelOptions() throws Throwable { + GetAcousticModelOptions getAcousticModelOptionsModel = + new GetAcousticModelOptions.Builder().customizationId("testString").build(); + assertEquals(getAcousticModelOptionsModel.customizationId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetAcousticModelOptionsError() throws Throwable { + new GetAcousticModelOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/GetAudioOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/GetAudioOptionsTest.java new file mode 100644 index 00000000000..87e2f57865b --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/GetAudioOptionsTest.java @@ -0,0 +1,43 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetAudioOptions model. */ +public class GetAudioOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetAudioOptions() throws Throwable { + GetAudioOptions getAudioOptionsModel = + new GetAudioOptions.Builder().customizationId("testString").audioName("testString").build(); + assertEquals(getAudioOptionsModel.customizationId(), "testString"); + assertEquals(getAudioOptionsModel.audioName(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetAudioOptionsError() throws Throwable { + new GetAudioOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/GetCorpusOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/GetCorpusOptionsTest.java new file mode 100644 index 00000000000..9a1898b75f0 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/GetCorpusOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetCorpusOptions model. */ +public class GetCorpusOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetCorpusOptions() throws Throwable { + GetCorpusOptions getCorpusOptionsModel = + new GetCorpusOptions.Builder() + .customizationId("testString") + .corpusName("testString") + .build(); + assertEquals(getCorpusOptionsModel.customizationId(), "testString"); + assertEquals(getCorpusOptionsModel.corpusName(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetCorpusOptionsError() throws Throwable { + new GetCorpusOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/GetGrammarOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/GetGrammarOptionsTest.java new file mode 100644 index 00000000000..26ed1a93bba --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/GetGrammarOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetGrammarOptions model. */ +public class GetGrammarOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetGrammarOptions() throws Throwable { + GetGrammarOptions getGrammarOptionsModel = + new GetGrammarOptions.Builder() + .customizationId("testString") + .grammarName("testString") + .build(); + assertEquals(getGrammarOptionsModel.customizationId(), "testString"); + assertEquals(getGrammarOptionsModel.grammarName(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetGrammarOptionsError() throws Throwable { + new GetGrammarOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/GetLanguageModelOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/GetLanguageModelOptionsTest.java new file mode 100644 index 00000000000..6b70ac6b27f --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/GetLanguageModelOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetLanguageModelOptions model. */ +public class GetLanguageModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetLanguageModelOptions() throws Throwable { + GetLanguageModelOptions getLanguageModelOptionsModel = + new GetLanguageModelOptions.Builder().customizationId("testString").build(); + assertEquals(getLanguageModelOptionsModel.customizationId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetLanguageModelOptionsError() throws Throwable { + new GetLanguageModelOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/GetModelOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/GetModelOptionsTest.java new file mode 100644 index 00000000000..f7f4a77b173 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/GetModelOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetModelOptions model. */ +public class GetModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetModelOptions() throws Throwable { + GetModelOptions getModelOptionsModel = + new GetModelOptions.Builder().modelId("ar-AR_BroadbandModel").build(); + assertEquals(getModelOptionsModel.modelId(), "ar-AR_BroadbandModel"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetModelOptionsError() throws Throwable { + new GetModelOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/GetWordOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/GetWordOptionsTest.java new file mode 100644 index 00000000000..db9392665a8 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/GetWordOptionsTest.java @@ -0,0 +1,43 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetWordOptions model. */ +public class GetWordOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetWordOptions() throws Throwable { + GetWordOptions getWordOptionsModel = + new GetWordOptions.Builder().customizationId("testString").wordName("testString").build(); + assertEquals(getWordOptionsModel.customizationId(), "testString"); + assertEquals(getWordOptionsModel.wordName(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetWordOptionsError() throws Throwable { + new GetWordOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/GrammarTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/GrammarTest.java new file mode 100644 index 00000000000..1d084a76ded --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/GrammarTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Grammar model. */ +public class GrammarTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGrammar() throws Throwable { + Grammar grammarModel = new Grammar(); + assertNull(grammarModel.getName()); + assertNull(grammarModel.getOutOfVocabularyWords()); + assertNull(grammarModel.getStatus()); + assertNull(grammarModel.getError()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/GrammarsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/GrammarsTest.java new file mode 100644 index 00000000000..a5238a3321c --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/GrammarsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Grammars model. */ +public class GrammarsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGrammars() throws Throwable { + Grammars grammarsModel = new Grammars(); + assertNull(grammarsModel.getGrammars()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/KeywordResultTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/KeywordResultTest.java new file mode 100644 index 00000000000..9053fe5fc20 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/KeywordResultTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the KeywordResult model. */ +public class KeywordResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testKeywordResult() throws Throwable { + KeywordResult keywordResultModel = new KeywordResult(); + assertNull(keywordResultModel.getNormalizedText()); + assertNull(keywordResultModel.getStartTime()); + assertNull(keywordResultModel.getEndTime()); + assertNull(keywordResultModel.getConfidence()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/LanguageModelTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/LanguageModelTest.java new file mode 100644 index 00000000000..e2a180806d2 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/LanguageModelTest.java @@ -0,0 +1,49 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the LanguageModel model. */ +public class LanguageModelTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testLanguageModel() throws Throwable { + LanguageModel languageModelModel = new LanguageModel(); + assertNull(languageModelModel.getCustomizationId()); + assertNull(languageModelModel.getCreated()); + assertNull(languageModelModel.getUpdated()); + assertNull(languageModelModel.getLanguage()); + assertNull(languageModelModel.getDialect()); + assertNull(languageModelModel.getVersions()); + assertNull(languageModelModel.getOwner()); + assertNull(languageModelModel.getName()); + assertNull(languageModelModel.getDescription()); + assertNull(languageModelModel.getBaseModelName()); + assertNull(languageModelModel.getStatus()); + assertNull(languageModelModel.getProgress()); + assertNull(languageModelModel.getError()); + assertNull(languageModelModel.getWarnings()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/LanguageModelsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/LanguageModelsTest.java new file mode 100644 index 00000000000..547701416ac --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/LanguageModelsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the LanguageModels model. */ +public class LanguageModelsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testLanguageModels() throws Throwable { + LanguageModels languageModelsModel = new LanguageModels(); + assertNull(languageModelsModel.getCustomizations()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ListAcousticModelsOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ListAcousticModelsOptionsTest.java new file mode 100644 index 00000000000..68b26898039 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ListAcousticModelsOptionsTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListAcousticModelsOptions model. */ +public class ListAcousticModelsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListAcousticModelsOptions() throws Throwable { + ListAcousticModelsOptions listAcousticModelsOptionsModel = + new ListAcousticModelsOptions.Builder().language("ar-AR").build(); + assertEquals(listAcousticModelsOptionsModel.language(), "ar-AR"); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ListAudioOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ListAudioOptionsTest.java new file mode 100644 index 00000000000..c70d1017ab2 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ListAudioOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListAudioOptions model. */ +public class ListAudioOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListAudioOptions() throws Throwable { + ListAudioOptions listAudioOptionsModel = + new ListAudioOptions.Builder().customizationId("testString").build(); + assertEquals(listAudioOptionsModel.customizationId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListAudioOptionsError() throws Throwable { + new ListAudioOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ListCorporaOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ListCorporaOptionsTest.java new file mode 100644 index 00000000000..898b817220f --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ListCorporaOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListCorporaOptions model. */ +public class ListCorporaOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListCorporaOptions() throws Throwable { + ListCorporaOptions listCorporaOptionsModel = + new ListCorporaOptions.Builder().customizationId("testString").build(); + assertEquals(listCorporaOptionsModel.customizationId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListCorporaOptionsError() throws Throwable { + new ListCorporaOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ListGrammarsOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ListGrammarsOptionsTest.java new file mode 100644 index 00000000000..c025a37c687 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ListGrammarsOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListGrammarsOptions model. */ +public class ListGrammarsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListGrammarsOptions() throws Throwable { + ListGrammarsOptions listGrammarsOptionsModel = + new ListGrammarsOptions.Builder().customizationId("testString").build(); + assertEquals(listGrammarsOptionsModel.customizationId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListGrammarsOptionsError() throws Throwable { + new ListGrammarsOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ListLanguageModelsOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ListLanguageModelsOptionsTest.java new file mode 100644 index 00000000000..c7c2fa509ec --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ListLanguageModelsOptionsTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListLanguageModelsOptions model. */ +public class ListLanguageModelsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListLanguageModelsOptions() throws Throwable { + ListLanguageModelsOptions listLanguageModelsOptionsModel = + new ListLanguageModelsOptions.Builder().language("ar-AR").build(); + assertEquals(listLanguageModelsOptionsModel.language(), "ar-AR"); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ListModelsOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ListModelsOptionsTest.java new file mode 100644 index 00000000000..549435f8771 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ListModelsOptionsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListModelsOptions model. */ +public class ListModelsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListModelsOptions() throws Throwable { + ListModelsOptions listModelsOptionsModel = new ListModelsOptions(); + assertNotNull(listModelsOptionsModel); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ListWordsOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ListWordsOptionsTest.java new file mode 100644 index 00000000000..ff5b2b015f3 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ListWordsOptionsTest.java @@ -0,0 +1,48 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListWordsOptions model. */ +public class ListWordsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListWordsOptions() throws Throwable { + ListWordsOptions listWordsOptionsModel = + new ListWordsOptions.Builder() + .customizationId("testString") + .wordType("all") + .sort("alphabetical") + .build(); + assertEquals(listWordsOptionsModel.customizationId(), "testString"); + assertEquals(listWordsOptionsModel.wordType(), "all"); + assertEquals(listWordsOptionsModel.sort(), "alphabetical"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListWordsOptionsError() throws Throwable { + new ListWordsOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ProcessedAudioTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ProcessedAudioTest.java new file mode 100644 index 00000000000..df6eeb7f0a3 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ProcessedAudioTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ProcessedAudio model. */ +public class ProcessedAudioTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testProcessedAudio() throws Throwable { + ProcessedAudio processedAudioModel = new ProcessedAudio(); + assertNull(processedAudioModel.getReceived()); + assertNull(processedAudioModel.getSeenByEngine()); + assertNull(processedAudioModel.getTranscription()); + assertNull(processedAudioModel.getSpeakerLabels()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ProcessingMetricsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ProcessingMetricsTest.java new file mode 100644 index 00000000000..86285ffdc89 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ProcessingMetricsTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ProcessingMetrics model. */ +public class ProcessingMetricsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testProcessingMetrics() throws Throwable { + ProcessingMetrics processingMetricsModel = new ProcessingMetrics(); + assertNull(processingMetricsModel.getProcessedAudio()); + assertNull(processingMetricsModel.getWallClockSinceFirstByteReceived()); + assertNull(processingMetricsModel.isPeriodic()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/RecognitionJobTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/RecognitionJobTest.java new file mode 100644 index 00000000000..2fda4143572 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/RecognitionJobTest.java @@ -0,0 +1,43 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RecognitionJob model. */ +public class RecognitionJobTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRecognitionJob() throws Throwable { + RecognitionJob recognitionJobModel = new RecognitionJob(); + assertNull(recognitionJobModel.getId()); + assertNull(recognitionJobModel.getStatus()); + assertNull(recognitionJobModel.getCreated()); + assertNull(recognitionJobModel.getUpdated()); + assertNull(recognitionJobModel.getUrl()); + assertNull(recognitionJobModel.getUserToken()); + assertNull(recognitionJobModel.getResults()); + assertNull(recognitionJobModel.getWarnings()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/RecognitionJobsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/RecognitionJobsTest.java new file mode 100644 index 00000000000..24486f3a3c8 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/RecognitionJobsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RecognitionJobs model. */ +public class RecognitionJobsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRecognitionJobs() throws Throwable { + RecognitionJobs recognitionJobsModel = new RecognitionJobs(); + assertNull(recognitionJobsModel.getRecognitions()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/RecognizeOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/RecognizeOptionsTest.java new file mode 100644 index 00000000000..021ffc36190 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/RecognizeOptionsTest.java @@ -0,0 +1,97 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.apache.commons.io.IOUtils; +import org.testng.annotations.Test; + +/** Unit test class for the RecognizeOptions model. */ +public class RecognizeOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRecognizeOptions() throws Throwable { + RecognizeOptions recognizeOptionsModel = + new RecognizeOptions.Builder() + .audio(TestUtilities.createMockStream("This is a mock file.")) + .contentType("application/octet-stream") + .model("ar-AR_BroadbandModel") + .languageCustomizationId("testString") + .acousticCustomizationId("testString") + .baseModelVersion("testString") + .customizationWeight(Double.valueOf("72.5")) + .inactivityTimeout(Long.valueOf("26")) + .keywords(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .keywordsThreshold(Float.valueOf("36.0")) + .maxAlternatives(Long.valueOf("26")) + .wordAlternativesThreshold(Float.valueOf("36.0")) + .wordConfidence(true) + .timestamps(true) + .profanityFilter(true) + .smartFormatting(true) + .speakerLabels(true) + .customizationId("testString") + .grammarName("testString") + .redaction(true) + .audioMetrics(true) + .endOfPhraseSilenceTime(Double.valueOf("72.5")) + .splitTranscriptAtPhraseEnd(true) + .speechDetectorSensitivity(Float.valueOf("36.0")) + .backgroundAudioSuppression(Float.valueOf("36.0")) + .build(); + assertEquals( + IOUtils.toString(recognizeOptionsModel.audio()), + IOUtils.toString(TestUtilities.createMockStream("This is a mock file."))); + assertEquals(recognizeOptionsModel.contentType(), "application/octet-stream"); + assertEquals(recognizeOptionsModel.model(), "ar-AR_BroadbandModel"); + assertEquals(recognizeOptionsModel.languageCustomizationId(), "testString"); + assertEquals(recognizeOptionsModel.acousticCustomizationId(), "testString"); + assertEquals(recognizeOptionsModel.baseModelVersion(), "testString"); + assertEquals(recognizeOptionsModel.customizationWeight(), Double.valueOf("72.5")); + assertEquals(recognizeOptionsModel.inactivityTimeout(), Long.valueOf("26")); + assertEquals( + recognizeOptionsModel.keywords(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals(recognizeOptionsModel.keywordsThreshold(), Float.valueOf("36.0")); + assertEquals(recognizeOptionsModel.maxAlternatives(), Long.valueOf("26")); + assertEquals(recognizeOptionsModel.wordAlternativesThreshold(), Float.valueOf("36.0")); + assertEquals(recognizeOptionsModel.wordConfidence(), Boolean.valueOf(true)); + assertEquals(recognizeOptionsModel.timestamps(), Boolean.valueOf(true)); + assertEquals(recognizeOptionsModel.profanityFilter(), Boolean.valueOf(true)); + assertEquals(recognizeOptionsModel.smartFormatting(), Boolean.valueOf(true)); + assertEquals(recognizeOptionsModel.speakerLabels(), Boolean.valueOf(true)); + assertEquals(recognizeOptionsModel.customizationId(), "testString"); + assertEquals(recognizeOptionsModel.grammarName(), "testString"); + assertEquals(recognizeOptionsModel.redaction(), Boolean.valueOf(true)); + assertEquals(recognizeOptionsModel.audioMetrics(), Boolean.valueOf(true)); + assertEquals(recognizeOptionsModel.endOfPhraseSilenceTime(), Double.valueOf("72.5")); + assertEquals(recognizeOptionsModel.splitTranscriptAtPhraseEnd(), Boolean.valueOf(true)); + assertEquals(recognizeOptionsModel.speechDetectorSensitivity(), Float.valueOf("36.0")); + assertEquals(recognizeOptionsModel.backgroundAudioSuppression(), Float.valueOf("36.0")); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testRecognizeOptionsError() throws Throwable { + new RecognizeOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/RegisterCallbackOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/RegisterCallbackOptionsTest.java new file mode 100644 index 00000000000..672abc52443 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/RegisterCallbackOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RegisterCallbackOptions model. */ +public class RegisterCallbackOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRegisterCallbackOptions() throws Throwable { + RegisterCallbackOptions registerCallbackOptionsModel = + new RegisterCallbackOptions.Builder() + .callbackUrl("testString") + .userSecret("testString") + .build(); + assertEquals(registerCallbackOptionsModel.callbackUrl(), "testString"); + assertEquals(registerCallbackOptionsModel.userSecret(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testRegisterCallbackOptionsError() throws Throwable { + new RegisterCallbackOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/RegisterStatusTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/RegisterStatusTest.java new file mode 100644 index 00000000000..11d6ab141a3 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/RegisterStatusTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the RegisterStatus model. */ +public class RegisterStatusTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testRegisterStatus() throws Throwable { + RegisterStatus registerStatusModel = new RegisterStatus(); + assertNull(registerStatusModel.getStatus()); + assertNull(registerStatusModel.getUrl()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ResetAcousticModelOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ResetAcousticModelOptionsTest.java new file mode 100644 index 00000000000..cde7f724775 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ResetAcousticModelOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ResetAcousticModelOptions model. */ +public class ResetAcousticModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testResetAcousticModelOptions() throws Throwable { + ResetAcousticModelOptions resetAcousticModelOptionsModel = + new ResetAcousticModelOptions.Builder().customizationId("testString").build(); + assertEquals(resetAcousticModelOptionsModel.customizationId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testResetAcousticModelOptionsError() throws Throwable { + new ResetAcousticModelOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ResetLanguageModelOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ResetLanguageModelOptionsTest.java new file mode 100644 index 00000000000..4b0598cc1d6 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/ResetLanguageModelOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ResetLanguageModelOptions model. */ +public class ResetLanguageModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testResetLanguageModelOptions() throws Throwable { + ResetLanguageModelOptions resetLanguageModelOptionsModel = + new ResetLanguageModelOptions.Builder().customizationId("testString").build(); + assertEquals(resetLanguageModelOptionsModel.customizationId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testResetLanguageModelOptionsError() throws Throwable { + new ResetLanguageModelOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/SpeakerLabelsResultTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/SpeakerLabelsResultTest.java new file mode 100644 index 00000000000..5d68864e930 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/SpeakerLabelsResultTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SpeakerLabelsResult model. */ +public class SpeakerLabelsResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSpeakerLabelsResult() throws Throwable { + SpeakerLabelsResult speakerLabelsResultModel = new SpeakerLabelsResult(); + assertNull(speakerLabelsResultModel.getFrom()); + assertNull(speakerLabelsResultModel.getTo()); + assertNull(speakerLabelsResultModel.getSpeaker()); + assertNull(speakerLabelsResultModel.getConfidence()); + assertNull(speakerLabelsResultModel.isXFinal()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/SpeechModelTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/SpeechModelTest.java new file mode 100644 index 00000000000..6f43e748cc4 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/SpeechModelTest.java @@ -0,0 +1,41 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SpeechModel model. */ +public class SpeechModelTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSpeechModel() throws Throwable { + SpeechModel speechModelModel = new SpeechModel(); + assertNull(speechModelModel.getName()); + assertNull(speechModelModel.getLanguage()); + assertNull(speechModelModel.getRate()); + assertNull(speechModelModel.getUrl()); + assertNull(speechModelModel.getSupportedFeatures()); + assertNull(speechModelModel.getDescription()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/SpeechModelsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/SpeechModelsTest.java new file mode 100644 index 00000000000..2b7e47e653d --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/SpeechModelsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SpeechModels model. */ +public class SpeechModelsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSpeechModels() throws Throwable { + SpeechModels speechModelsModel = new SpeechModels(); + assertNull(speechModelsModel.getModels()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionAlternativeTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionAlternativeTest.java new file mode 100644 index 00000000000..4708977f0ad --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionAlternativeTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SpeechRecognitionAlternative model. */ +public class SpeechRecognitionAlternativeTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSpeechRecognitionAlternative() throws Throwable { + SpeechRecognitionAlternative speechRecognitionAlternativeModel = + new SpeechRecognitionAlternative(); + assertNull(speechRecognitionAlternativeModel.getTranscript()); + assertNull(speechRecognitionAlternativeModel.getConfidence()); + assertNull(speechRecognitionAlternativeModel.getTimestamps()); + assertNull(speechRecognitionAlternativeModel.getWordConfidence()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionResultTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionResultTest.java new file mode 100644 index 00000000000..863e20ac75c --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionResultTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SpeechRecognitionResult model. */ +public class SpeechRecognitionResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSpeechRecognitionResult() throws Throwable { + SpeechRecognitionResult speechRecognitionResultModel = new SpeechRecognitionResult(); + assertNull(speechRecognitionResultModel.isXFinal()); + assertNull(speechRecognitionResultModel.getAlternatives()); + assertNull(speechRecognitionResultModel.getKeywordsResult()); + assertNull(speechRecognitionResultModel.getWordAlternatives()); + assertNull(speechRecognitionResultModel.getEndOfUtterance()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionResultsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionResultsTest.java new file mode 100644 index 00000000000..d981cf87986 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionResultsTest.java @@ -0,0 +1,41 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SpeechRecognitionResults model. */ +public class SpeechRecognitionResultsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSpeechRecognitionResults() throws Throwable { + SpeechRecognitionResults speechRecognitionResultsModel = new SpeechRecognitionResults(); + assertNull(speechRecognitionResultsModel.getResults()); + assertNull(speechRecognitionResultsModel.getResultIndex()); + assertNull(speechRecognitionResultsModel.getSpeakerLabels()); + assertNull(speechRecognitionResultsModel.getProcessingMetrics()); + assertNull(speechRecognitionResultsModel.getAudioMetrics()); + assertNull(speechRecognitionResultsModel.getWarnings()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/SupportedFeaturesTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/SupportedFeaturesTest.java new file mode 100644 index 00000000000..a9f930ac569 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/SupportedFeaturesTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SupportedFeatures model. */ +public class SupportedFeaturesTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSupportedFeatures() throws Throwable { + SupportedFeatures supportedFeaturesModel = new SupportedFeatures(); + assertNull(supportedFeaturesModel.isCustomLanguageModel()); + assertNull(supportedFeaturesModel.isSpeakerLabels()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/TrainAcousticModelOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/TrainAcousticModelOptionsTest.java new file mode 100644 index 00000000000..9d9b30bd1ba --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/TrainAcousticModelOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TrainAcousticModelOptions model. */ +public class TrainAcousticModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTrainAcousticModelOptions() throws Throwable { + TrainAcousticModelOptions trainAcousticModelOptionsModel = + new TrainAcousticModelOptions.Builder() + .customizationId("testString") + .customLanguageModelId("testString") + .build(); + assertEquals(trainAcousticModelOptionsModel.customizationId(), "testString"); + assertEquals(trainAcousticModelOptionsModel.customLanguageModelId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testTrainAcousticModelOptionsError() throws Throwable { + new TrainAcousticModelOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/TrainLanguageModelOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/TrainLanguageModelOptionsTest.java new file mode 100644 index 00000000000..715c6be01f7 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/TrainLanguageModelOptionsTest.java @@ -0,0 +1,48 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TrainLanguageModelOptions model. */ +public class TrainLanguageModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTrainLanguageModelOptions() throws Throwable { + TrainLanguageModelOptions trainLanguageModelOptionsModel = + new TrainLanguageModelOptions.Builder() + .customizationId("testString") + .wordTypeToAdd("all") + .customizationWeight(Double.valueOf("72.5")) + .build(); + assertEquals(trainLanguageModelOptionsModel.customizationId(), "testString"); + assertEquals(trainLanguageModelOptionsModel.wordTypeToAdd(), "all"); + assertEquals(trainLanguageModelOptionsModel.customizationWeight(), Double.valueOf("72.5")); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testTrainLanguageModelOptionsError() throws Throwable { + new TrainLanguageModelOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/TrainingResponseTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/TrainingResponseTest.java new file mode 100644 index 00000000000..cd153c69c19 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/TrainingResponseTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TrainingResponse model. */ +public class TrainingResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTrainingResponse() throws Throwable { + TrainingResponse trainingResponseModel = new TrainingResponse(); + assertNull(trainingResponseModel.getWarnings()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/TrainingWarningTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/TrainingWarningTest.java new file mode 100644 index 00000000000..76f943c68f8 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/TrainingWarningTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TrainingWarning model. */ +public class TrainingWarningTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTrainingWarning() throws Throwable { + TrainingWarning trainingWarningModel = new TrainingWarning(); + assertNull(trainingWarningModel.getCode()); + assertNull(trainingWarningModel.getMessage()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/UnregisterCallbackOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/UnregisterCallbackOptionsTest.java new file mode 100644 index 00000000000..0615a419ee9 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/UnregisterCallbackOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the UnregisterCallbackOptions model. */ +public class UnregisterCallbackOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUnregisterCallbackOptions() throws Throwable { + UnregisterCallbackOptions unregisterCallbackOptionsModel = + new UnregisterCallbackOptions.Builder().callbackUrl("testString").build(); + assertEquals(unregisterCallbackOptionsModel.callbackUrl(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUnregisterCallbackOptionsError() throws Throwable { + new UnregisterCallbackOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/UpgradeAcousticModelOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/UpgradeAcousticModelOptionsTest.java new file mode 100644 index 00000000000..aff74bae998 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/UpgradeAcousticModelOptionsTest.java @@ -0,0 +1,48 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the UpgradeAcousticModelOptions model. */ +public class UpgradeAcousticModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpgradeAcousticModelOptions() throws Throwable { + UpgradeAcousticModelOptions upgradeAcousticModelOptionsModel = + new UpgradeAcousticModelOptions.Builder() + .customizationId("testString") + .customLanguageModelId("testString") + .force(true) + .build(); + assertEquals(upgradeAcousticModelOptionsModel.customizationId(), "testString"); + assertEquals(upgradeAcousticModelOptionsModel.customLanguageModelId(), "testString"); + assertEquals(upgradeAcousticModelOptionsModel.force(), Boolean.valueOf(true)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpgradeAcousticModelOptionsError() throws Throwable { + new UpgradeAcousticModelOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/UpgradeLanguageModelOptionsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/UpgradeLanguageModelOptionsTest.java new file mode 100644 index 00000000000..9dd57cb11af --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/UpgradeLanguageModelOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the UpgradeLanguageModelOptions model. */ +public class UpgradeLanguageModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpgradeLanguageModelOptions() throws Throwable { + UpgradeLanguageModelOptions upgradeLanguageModelOptionsModel = + new UpgradeLanguageModelOptions.Builder().customizationId("testString").build(); + assertEquals(upgradeLanguageModelOptionsModel.customizationId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpgradeLanguageModelOptionsError() throws Throwable { + new UpgradeLanguageModelOptions.Builder().build(); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/WordAlternativeResultTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/WordAlternativeResultTest.java new file mode 100644 index 00000000000..81c03b6a49f --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/WordAlternativeResultTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the WordAlternativeResult model. */ +public class WordAlternativeResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testWordAlternativeResult() throws Throwable { + WordAlternativeResult wordAlternativeResultModel = new WordAlternativeResult(); + assertNull(wordAlternativeResultModel.getConfidence()); + assertNull(wordAlternativeResultModel.getWord()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/WordAlternativeResultsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/WordAlternativeResultsTest.java new file mode 100644 index 00000000000..f73eee2d049 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/WordAlternativeResultsTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the WordAlternativeResults model. */ +public class WordAlternativeResultsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testWordAlternativeResults() throws Throwable { + WordAlternativeResults wordAlternativeResultsModel = new WordAlternativeResults(); + assertNull(wordAlternativeResultsModel.getStartTime()); + assertNull(wordAlternativeResultsModel.getEndTime()); + assertNull(wordAlternativeResultsModel.getAlternatives()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/WordErrorTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/WordErrorTest.java new file mode 100644 index 00000000000..c85e3ad150a --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/WordErrorTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the WordError model. */ +public class WordErrorTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testWordError() throws Throwable { + WordError wordErrorModel = new WordError(); + assertNull(wordErrorModel.getElement()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/WordTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/WordTest.java new file mode 100644 index 00000000000..3f931922b80 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/WordTest.java @@ -0,0 +1,41 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Word model. */ +public class WordTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testWord() throws Throwable { + Word wordModel = new Word(); + assertNull(wordModel.getWord()); + assertNull(wordModel.getSoundsLike()); + assertNull(wordModel.getDisplayAs()); + assertNull(wordModel.getCount()); + assertNull(wordModel.getSource()); + assertNull(wordModel.getError()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/WordsTest.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/WordsTest.java new file mode 100644 index 00000000000..535f405d9fd --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/WordsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.speech_to_text.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Words model. */ +public class WordsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testWords() throws Throwable { + Words wordsModel = new Words(); + assertNull(wordsModel.getWords()); + } +} diff --git a/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/utils/TestUtilities.java b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/utils/TestUtilities.java new file mode 100644 index 00000000000..b89353cf1b2 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/utils/TestUtilities.java @@ -0,0 +1,128 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.speech_to_text.v1.utils; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.cloud.sdk.core.util.GsonSingleton; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import okhttp3.HttpUrl; +import okhttp3.mockwebserver.RecordedRequest; + +/** A class used by the unit tests containing utility functions. */ +public class TestUtilities { + public static Map createMockMap() { + Map mockMap = new HashMap<>(); + mockMap.put("foo", "bar"); + return mockMap; + } + + public static HashMap createMockStreamMap() { + return new HashMap() { + { + put("key1", createMockStream("This is a mock file.")); + } + }; + } + + public static Map parseQueryString(RecordedRequest req) { + Map queryMap = new HashMap<>(); + + try { + HttpUrl requestUrl = req.getRequestUrl(); + + if (requestUrl != null) { + Set queryParamsNames = requestUrl.queryParameterNames(); + // map the parameter name to its corresponding value + for (String p : queryParamsNames) { + // get the corresponding value for the parameter (p) + List val = requestUrl.queryParameterValues(p); + if (val != null && !val.isEmpty()) { + String joinedQuery = String.join(",", val); + queryMap.put(p, joinedQuery); + } + } + } + if (queryMap.isEmpty()) { + return null; + } + } catch (Exception e) { + return null; + } + + return queryMap; + } + + public static String parseReqPath(RecordedRequest req) { + String parsedPath = null; + + try { + String fullPath = req.getPath(); + if (fullPath != null && !fullPath.isEmpty()) { + // retrieve the path segment before the query parameter + parsedPath = fullPath.split("\\?", 2)[0]; + } + if (parsedPath.isEmpty() || parsedPath == null) { + return null; + } + + } catch (Exception e) { + return null; + } + + return parsedPath; + } + + public static String serialize(Object obj) { + return GsonSingleton.getGson().toJson(obj); + } + + public static T deserialize(String json, Class clazz) { + return GsonSingleton.getGson().fromJson(json, clazz); + } + + public static InputStream createMockStream(String s) { + return new ByteArrayInputStream(s.getBytes()); + } + + public static List creatMockListFileWithMetadata() { + List list = new ArrayList(); + byte[] fileBytes = {(byte) 0xde, (byte) 0xad, (byte) 0xbe, (byte) 0xef}; + InputStream inputStream = new ByteArrayInputStream(fileBytes); + FileWithMetadata.Builder builder = new FileWithMetadata.Builder(); + builder.data(inputStream); + FileWithMetadata fileWithMetadata = builder.build(); + list.add(fileWithMetadata); + + return list; + } + + public static byte[] createMockByteArray(String bytes) { + return bytes.getBytes(); + } + + public static Date createMockDate(String date) throws Exception { + return new SimpleDateFormat("yyyy-MM-dd").parse(date); + } + + public static Date createMockDateTime(String date) throws Exception { + return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").parse(date); + } +} diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/TextToSpeech.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/TextToSpeech.java index 5de00f1fd7e..8afaf19152b 100644 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/TextToSpeech.java +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/TextToSpeech.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -10,6 +10,11 @@ * 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. */ + +/* + * IBM OpenAPI SDK Code Generator Version: 99-SNAPSHOT-7cc05500-20201106-154555 + */ + package com.ibm.watson.text_to_speech.v1; import com.google.gson.JsonObject; @@ -23,38 +28,33 @@ import com.ibm.watson.common.SdkCommon; import com.ibm.watson.text_to_speech.v1.model.AddWordOptions; import com.ibm.watson.text_to_speech.v1.model.AddWordsOptions; -import com.ibm.watson.text_to_speech.v1.model.CreateVoiceModelOptions; +import com.ibm.watson.text_to_speech.v1.model.CreateCustomModelOptions; +import com.ibm.watson.text_to_speech.v1.model.CustomModel; +import com.ibm.watson.text_to_speech.v1.model.CustomModels; +import com.ibm.watson.text_to_speech.v1.model.DeleteCustomModelOptions; import com.ibm.watson.text_to_speech.v1.model.DeleteUserDataOptions; -import com.ibm.watson.text_to_speech.v1.model.DeleteVoiceModelOptions; import com.ibm.watson.text_to_speech.v1.model.DeleteWordOptions; +import com.ibm.watson.text_to_speech.v1.model.GetCustomModelOptions; import com.ibm.watson.text_to_speech.v1.model.GetPronunciationOptions; -import com.ibm.watson.text_to_speech.v1.model.GetVoiceModelOptions; import com.ibm.watson.text_to_speech.v1.model.GetVoiceOptions; import com.ibm.watson.text_to_speech.v1.model.GetWordOptions; -import com.ibm.watson.text_to_speech.v1.model.ListVoiceModelsOptions; +import com.ibm.watson.text_to_speech.v1.model.ListCustomModelsOptions; import com.ibm.watson.text_to_speech.v1.model.ListVoicesOptions; import com.ibm.watson.text_to_speech.v1.model.ListWordsOptions; import com.ibm.watson.text_to_speech.v1.model.Pronunciation; import com.ibm.watson.text_to_speech.v1.model.SynthesizeOptions; import com.ibm.watson.text_to_speech.v1.model.Translation; -import com.ibm.watson.text_to_speech.v1.model.UpdateVoiceModelOptions; +import com.ibm.watson.text_to_speech.v1.model.UpdateCustomModelOptions; import com.ibm.watson.text_to_speech.v1.model.Voice; -import com.ibm.watson.text_to_speech.v1.model.VoiceModel; -import com.ibm.watson.text_to_speech.v1.model.VoiceModels; import com.ibm.watson.text_to_speech.v1.model.Voices; import com.ibm.watson.text_to_speech.v1.model.Words; -import com.ibm.watson.text_to_speech.v1.websocket.SynthesizeCallback; -import com.ibm.watson.text_to_speech.v1.websocket.TextToSpeechWebSocketListener; import java.io.InputStream; +import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.WebSocket; /** - * The IBM Watson™ Text to Speech service provides APIs that use IBM's speech-synthesis + * The IBM Watson&trade; Text to Speech service provides APIs that use IBM's speech-synthesis * capabilities to synthesize text into natural-sounding speech in a variety of languages, dialects, * and voices. The service supports at least one male or female voice, sometimes both, for each * language. The audio is streamed back to the client with minimal delay. @@ -62,8 +62,8 @@ *

For speech synthesis, the service supports a synchronous HTTP Representational State Transfer * (REST) interface and a WebSocket interface. Both interfaces support plain text and SSML input. * SSML is an XML-based markup language that provides text annotation for speech-synthesis - * applications. The WebSocket interface also supports the SSML <mark> element - * and word timings. + * applications. The WebSocket interface also supports the SSML + * <code>&lt;mark&gt;</code> element and word timings. * *

The service offers a customization interface that you can use to define sounds-like or * phonetic translations for words. A sounds-like translation consists of one or more words that, @@ -73,16 +73,19 @@ * (SPR). The Arabic, Chinese, Dutch, and Korean languages support only IPA. * * @version v1 - * @see Text to Speech + * @see Text to Speech */ public class TextToSpeech extends BaseService { - private static final String DEFAULT_SERVICE_NAME = "text_to_speech"; + public static final String DEFAULT_SERVICE_NAME = "text_to_speech"; - private static final String DEFAULT_SERVICE_URL = + public static final String DEFAULT_SERVICE_URL = "https://api.us-south.text-to-speech.watson.cloud.ibm.com"; - /** Constructs a new `TextToSpeech` client using the DEFAULT_SERVICE_NAME. */ + /** + * Constructs an instance of the `TextToSpeech` client. The default service name is used to + * configure the client instance. + */ public TextToSpeech() { this( DEFAULT_SERVICE_NAME, @@ -90,29 +93,31 @@ public TextToSpeech() { } /** - * Constructs a new `TextToSpeech` client with the DEFAULT_SERVICE_NAME and the specified - * Authenticator. + * Constructs an instance of the `TextToSpeech` client. The default service name and specified + * authenticator are used to configure the client instance. * - * @param authenticator the Authenticator instance to be configured for this service + * @param authenticator the {@link Authenticator} instance to be configured for this client */ public TextToSpeech(Authenticator authenticator) { this(DEFAULT_SERVICE_NAME, authenticator); } /** - * Constructs a new `TextToSpeech` client with the specified serviceName. + * Constructs an instance of the `TextToSpeech` client. The specified service name is used to + * configure the client instance. * - * @param serviceName The name of the service to configure. + * @param serviceName the service name to be used when configuring the client instance */ public TextToSpeech(String serviceName) { this(serviceName, ConfigBasedAuthenticatorFactory.getAuthenticator(serviceName)); } /** - * Constructs a new `TextToSpeech` client with the specified Authenticator and serviceName. + * Constructs an instance of the `TextToSpeech` client. The specified service name and + * authenticator are used to configure the client instance. * - * @param serviceName The name of the service to configure. - * @param authenticator the Authenticator instance to be configured for this service + * @param serviceName the service name to be used when configuring the client instance + * @param authenticator the {@link Authenticator} instance to be configured for this client */ public TextToSpeech(String serviceName, Authenticator authenticator) { super(serviceName, authenticator); @@ -132,19 +137,16 @@ public TextToSpeech(String serviceName, Authenticator authenticator) { * voices](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-voices#listVoices). * * @param listVoicesOptions the {@link ListVoicesOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Voices} + * @return a {@link ServiceCall} with a result of type {@link Voices} */ public ServiceCall listVoices(ListVoicesOptions listVoicesOptions) { - String[] pathSegments = {"v1/voices"}; RequestBuilder builder = - RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); + RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/voices")); Map sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "listVoices"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - if (listVoicesOptions != null) {} - ResponseConverter responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken() {}.getType()); @@ -162,7 +164,7 @@ public ServiceCall listVoices(ListVoicesOptions listVoicesOptions) { *

**See also:** [Listing all available * voices](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-voices#listVoices). * - * @return a {@link ServiceCall} with a response type of {@link Voices} + * @return a {@link ServiceCall} with a result of type {@link Voices} */ public ServiceCall listVoices() { return listVoices(null); @@ -173,30 +175,30 @@ public ServiceCall listVoices() { * *

Gets information about the specified voice. The information includes the name, language, * gender, and other details about the voice. Specify a customization ID to obtain information for - * a custom voice model that is defined for the language of the specified voice. To list - * information about all available voices, use the **List voices** method. + * a custom model that is defined for the language of the specified voice. To list information + * about all available voices, use the **List voices** method. * *

**See also:** [Listing a specific * voice](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-voices#listVoice). * * @param getVoiceOptions the {@link GetVoiceOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Voice} + * @return a {@link ServiceCall} with a result of type {@link Voice} */ public ServiceCall getVoice(GetVoiceOptions getVoiceOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( getVoiceOptions, "getVoiceOptions cannot be null"); - String[] pathSegments = {"v1/voices"}; - String[] pathParameters = {getVoiceOptions.voice()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("voice", getVoiceOptions.voice()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); + RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/voices/{voice}", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "getVoice"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); if (getVoiceOptions.customizationId() != null) { - builder.query("customization_id", getVoiceOptions.customizationId()); + builder.query("customization_id", String.valueOf(getVoiceOptions.customizationId())); } ResponseConverter responseConverter = ResponseConverterUtils.getValue( @@ -262,14 +264,13 @@ public ServiceCall getVoice(GetVoiceOptions getVoiceOptions) { * `"{invalid_arg_1}, {invalid_arg_2}."` The request succeeds despite the warnings. * * @param synthesizeOptions the {@link SynthesizeOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link InputStream} + * @return a {@link ServiceCall} with a result of type {@link InputStream} */ public ServiceCall synthesize(SynthesizeOptions synthesizeOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( synthesizeOptions, "synthesizeOptions cannot be null"); - String[] pathSegments = {"v1/synthesize"}; RequestBuilder builder = - RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); + RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/synthesize")); Map sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "synthesize"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); @@ -278,10 +279,10 @@ public ServiceCall synthesize(SynthesizeOptions synthesizeOptions) builder.header("Accept", synthesizeOptions.accept()); } if (synthesizeOptions.voice() != null) { - builder.query("voice", synthesizeOptions.voice()); + builder.query("voice", String.valueOf(synthesizeOptions.voice())); } if (synthesizeOptions.customizationId() != null) { - builder.query("customization_id", synthesizeOptions.customizationId()); + builder.query("customization_id", String.valueOf(synthesizeOptions.customizationId())); } final JsonObject contentJson = new JsonObject(); contentJson.addProperty("text", synthesizeOptions.text()); @@ -290,92 +291,42 @@ public ServiceCall synthesize(SynthesizeOptions synthesizeOptions) return createServiceCall(builder.build(), responseConverter); } - /** - * Synthesize audio. - * - *

Synthesizes text to audio that is spoken in the specified voice. The service bases its - * understanding of the language for the input text on the specified voice. Use a voice that - * matches the language of the input text. - * - *

The method accepts a maximum of 5 KB of input text in the body of the request, and 8 KB for - * the URL and headers. The 5 KB limit includes any SSML tags that you specify. The service - * returns the synthesized audio stream as an array of bytes. - * - *

### Audio formats (accept types) - * - *

For more information about specifying an audio format, including additional details about - * some of the formats, see [Audio - * formats](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-audioFormats#audioFormats). - * - * @param synthesizeOptions the {@link SynthesizeOptions} containing the options for the call - * @param callback the {@link SynthesizeCallback} callback - * @return a {@link WebSocket} instance - */ - public WebSocket synthesizeUsingWebSocket( - SynthesizeOptions synthesizeOptions, SynthesizeCallback callback) { - com.ibm.cloud.sdk.core.util.Validator.notNull( - synthesizeOptions, "synthesizeOptions cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(callback, "callback cannot be null"); - - HttpUrl.Builder urlBuilder = HttpUrl.parse(getServiceUrl() + "/v1/synthesize").newBuilder(); - - if (synthesizeOptions.voice() != null) { - urlBuilder.addQueryParameter("voice", synthesizeOptions.voice()); - } - if (synthesizeOptions.customizationId() != null) { - urlBuilder.addQueryParameter("customization_id", synthesizeOptions.customizationId()); - } - - String url = urlBuilder.toString().replace("https://", "wss://"); - Request.Builder builder = new Request.Builder().url(url); - - setAuthentication(builder); - setDefaultHeaders(builder); - - OkHttpClient client = configureHttpClient(); - return client.newWebSocket( - builder.build(), new TextToSpeechWebSocketListener(synthesizeOptions, callback)); - } - /** * Get pronunciation. * *

Gets the phonetic pronunciation for the specified word. You can request the pronunciation * for a specific format. You can also request the pronunciation for a specific voice to see the - * default translation for the language of that voice or for a specific custom voice model to see - * the translation for that voice model. - * - *

**Note:** This method is currently a beta release. + * default translation for the language of that voice or for a specific custom model to see the + * translation for that model. * *

**See also:** [Querying a word from a * language](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customWords#cuWordsQueryLanguage). * * @param getPronunciationOptions the {@link GetPronunciationOptions} containing the options for * the call - * @return a {@link ServiceCall} with a response type of {@link Pronunciation} + * @return a {@link ServiceCall} with a result of type {@link Pronunciation} */ public ServiceCall getPronunciation( GetPronunciationOptions getPronunciationOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( getPronunciationOptions, "getPronunciationOptions cannot be null"); - String[] pathSegments = {"v1/pronunciation"}; RequestBuilder builder = - RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); + RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/pronunciation")); Map sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "getPronunciation"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - builder.query("text", getPronunciationOptions.text()); + builder.query("text", String.valueOf(getPronunciationOptions.text())); if (getPronunciationOptions.voice() != null) { - builder.query("voice", getPronunciationOptions.voice()); + builder.query("voice", String.valueOf(getPronunciationOptions.voice())); } if (getPronunciationOptions.format() != null) { - builder.query("format", getPronunciationOptions.format()); + builder.query("format", String.valueOf(getPronunciationOptions.format())); } if (getPronunciationOptions.customizationId() != null) { - builder.query("customization_id", getPronunciationOptions.customizationId()); + builder.query("customization_id", String.valueOf(getPronunciationOptions.customizationId())); } ResponseConverter responseConverter = ResponseConverterUtils.getValue( @@ -386,111 +337,107 @@ public ServiceCall getPronunciation( /** * Create a custom model. * - *

Creates a new empty custom voice model. You must specify a name for the new custom model. - * You can optionally specify the language and a description for the new model. The model is owned - * by the instance of the service whose credentials are used to create it. - * - *

**Note:** This method is currently a beta release. + *

Creates a new empty custom model. You must specify a name for the new custom model. You can + * optionally specify the language and a description for the new model. The model is owned by the + * instance of the service whose credentials are used to create it. * *

**See also:** [Creating a custom * model](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customModels#cuModelsCreate). * - * @param createVoiceModelOptions the {@link CreateVoiceModelOptions} containing the options for + * @param createCustomModelOptions the {@link CreateCustomModelOptions} containing the options for * the call - * @return a {@link ServiceCall} with a response type of {@link VoiceModel} + * @return a {@link ServiceCall} with a result of type {@link CustomModel} */ - public ServiceCall createVoiceModel(CreateVoiceModelOptions createVoiceModelOptions) { + public ServiceCall createCustomModel( + CreateCustomModelOptions createCustomModelOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( - createVoiceModelOptions, "createVoiceModelOptions cannot be null"); - String[] pathSegments = {"v1/customizations"}; + createCustomModelOptions, "createCustomModelOptions cannot be null"); RequestBuilder builder = - RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); + RequestBuilder.post( + RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/customizations")); Map sdkHeaders = - SdkCommon.getSdkHeaders("text_to_speech", "v1", "createVoiceModel"); + SdkCommon.getSdkHeaders("text_to_speech", "v1", "createCustomModel"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); final JsonObject contentJson = new JsonObject(); - contentJson.addProperty("name", createVoiceModelOptions.name()); - if (createVoiceModelOptions.language() != null) { - contentJson.addProperty("language", createVoiceModelOptions.language()); + contentJson.addProperty("name", createCustomModelOptions.name()); + if (createCustomModelOptions.language() != null) { + contentJson.addProperty("language", createCustomModelOptions.language()); } - if (createVoiceModelOptions.description() != null) { - contentJson.addProperty("description", createVoiceModelOptions.description()); + if (createCustomModelOptions.description() != null) { + contentJson.addProperty("description", createCustomModelOptions.description()); } builder.bodyJson(contentJson); - ResponseConverter responseConverter = + ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() {}.getType()); + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * List custom models. * - *

Lists metadata such as the name and description for all custom voice models that are owned - * by an instance of the service. Specify a language to list the voice models for that language - * only. To see the words in addition to the metadata for a specific voice model, use the **List a + *

Lists metadata such as the name and description for all custom models that are owned by an + * instance of the service. Specify a language to list the custom models for that language only. + * To see the words in addition to the metadata for a specific custom model, use the **List a * custom model** method. You must use credentials for the instance of the service that owns a * model to list information about it. * - *

**Note:** This method is currently a beta release. - * *

**See also:** [Querying all custom * models](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customModels#cuModelsQueryAll). * - * @param listVoiceModelsOptions the {@link ListVoiceModelsOptions} containing the options for the - * call - * @return a {@link ServiceCall} with a response type of {@link VoiceModels} + * @param listCustomModelsOptions the {@link ListCustomModelsOptions} containing the options for + * the call + * @return a {@link ServiceCall} with a result of type {@link CustomModels} */ - public ServiceCall listVoiceModels(ListVoiceModelsOptions listVoiceModelsOptions) { - String[] pathSegments = {"v1/customizations"}; + public ServiceCall listCustomModels( + ListCustomModelsOptions listCustomModelsOptions) { + if (listCustomModelsOptions == null) { + listCustomModelsOptions = new ListCustomModelsOptions.Builder().build(); + } RequestBuilder builder = - RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); + RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/customizations")); Map sdkHeaders = - SdkCommon.getSdkHeaders("text_to_speech", "v1", "listVoiceModels"); + SdkCommon.getSdkHeaders("text_to_speech", "v1", "listCustomModels"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - if (listVoiceModelsOptions != null) { - if (listVoiceModelsOptions.language() != null) { - builder.query("language", listVoiceModelsOptions.language()); - } + if (listCustomModelsOptions.language() != null) { + builder.query("language", String.valueOf(listCustomModelsOptions.language())); } - ResponseConverter responseConverter = + ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() {}.getType()); + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * List custom models. * - *

Lists metadata such as the name and description for all custom voice models that are owned - * by an instance of the service. Specify a language to list the voice models for that language - * only. To see the words in addition to the metadata for a specific voice model, use the **List a + *

Lists metadata such as the name and description for all custom models that are owned by an + * instance of the service. Specify a language to list the custom models for that language only. + * To see the words in addition to the metadata for a specific custom model, use the **List a * custom model** method. You must use credentials for the instance of the service that owns a * model to list information about it. * - *

**Note:** This method is currently a beta release. - * *

**See also:** [Querying all custom * models](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customModels#cuModelsQueryAll). * - * @return a {@link ServiceCall} with a response type of {@link VoiceModels} + * @return a {@link ServiceCall} with a result of type {@link CustomModels} */ - public ServiceCall listVoiceModels() { - return listVoiceModels(null); + public ServiceCall listCustomModels() { + return listCustomModels(null); } /** * Update a custom model. * - *

Updates information for the specified custom voice model. You can update metadata such as - * the name and description of the voice model. You can also update the words in the model and - * their translations. Adding a new translation for a word that already exists in a custom model + *

Updates information for the specified custom model. You can update metadata such as the name + * and description of the model. You can also update the words in the model and their + * translations. Adding a new translation for a word that already exists in a custom model * overwrites the word's existing translation. A custom model can contain no more than 20,000 * entries. You must use credentials for the instance of the service that owns a model to update * it. @@ -498,11 +445,15 @@ public ServiceCall listVoiceModels() { *

You can define sounds-like or phonetic translations for words. A sounds-like translation * consists of one or more words that, when combined, sound like the word. Phonetic translations * are based on the SSML phoneme format for representing a word. You can specify them in standard - * International Phonetic Alphabet (IPA) representation - * <phoneme alphabet="ipa" ph="təmˈɑto"></phoneme> or in the - * proprietary IBM Symbolic Phonetic Representation (SPR) - * <phoneme alphabet="ibm" ph="1gAstroEntxrYFXs"></phoneme> **Note:** This - * method is currently a beta release. + * International Phonetic Alphabet (IPA) representation + * + *

<code>&lt;phoneme alphabet="ipa" + * ph="t&#601;m&#712;&#593;to"&gt;&lt;/phoneme&gt;</code> + * + *

or in the proprietary IBM Symbolic Phonetic Representation (SPR) + * + *

<code>&lt;phoneme alphabet="ibm" + * ph="1gAstroEntxrYFXs"&gt;&lt;/phoneme&gt;</code> * *

**See also:** * [Updating a custom * model](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customModels#cuModelsUpdate) @@ -511,36 +462,37 @@ public ServiceCall listVoiceModels() { * * [Understanding * customization](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customIntro#customIntro). * - * @param updateVoiceModelOptions the {@link UpdateVoiceModelOptions} containing the options for + * @param updateCustomModelOptions the {@link UpdateCustomModelOptions} containing the options for * the call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ - public ServiceCall updateVoiceModel(UpdateVoiceModelOptions updateVoiceModelOptions) { + public ServiceCall updateCustomModel(UpdateCustomModelOptions updateCustomModelOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( - updateVoiceModelOptions, "updateVoiceModelOptions cannot be null"); - String[] pathSegments = {"v1/customizations"}; - String[] pathParameters = {updateVoiceModelOptions.customizationId()}; + updateCustomModelOptions, "updateCustomModelOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", updateCustomModelOptions.customizationId()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/customizations/{customization_id}", pathParamsMap)); Map sdkHeaders = - SdkCommon.getSdkHeaders("text_to_speech", "v1", "updateVoiceModel"); + SdkCommon.getSdkHeaders("text_to_speech", "v1", "updateCustomModel"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); final JsonObject contentJson = new JsonObject(); - if (updateVoiceModelOptions.name() != null) { - contentJson.addProperty("name", updateVoiceModelOptions.name()); + if (updateCustomModelOptions.name() != null) { + contentJson.addProperty("name", updateCustomModelOptions.name()); } - if (updateVoiceModelOptions.description() != null) { - contentJson.addProperty("description", updateVoiceModelOptions.description()); + if (updateCustomModelOptions.description() != null) { + contentJson.addProperty("description", updateCustomModelOptions.description()); } - if (updateVoiceModelOptions.words() != null) { + if (updateCustomModelOptions.words() != null) { contentJson.add( "words", com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() - .toJsonTree(updateVoiceModelOptions.words())); + .toJsonTree(updateCustomModelOptions.words())); } builder.bodyJson(contentJson); ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); @@ -550,70 +502,66 @@ public ServiceCall updateVoiceModel(UpdateVoiceModelOptions updateVoiceMod /** * Get a custom model. * - *

Gets all information about a specified custom voice model. In addition to metadata such as - * the name and description of the voice model, the output includes the words and their - * translations as defined in the model. To see just the metadata for a voice model, use the - * **List custom models** method. - * - *

**Note:** This method is currently a beta release. + *

Gets all information about a specified custom model. In addition to metadata such as the + * name and description of the custom model, the output includes the words and their translations + * as defined in the model. To see just the metadata for a model, use the **List custom models** + * method. * *

**See also:** [Querying a custom * model](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customModels#cuModelsQuery). * - * @param getVoiceModelOptions the {@link GetVoiceModelOptions} containing the options for the + * @param getCustomModelOptions the {@link GetCustomModelOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of {@link VoiceModel} + * @return a {@link ServiceCall} with a result of type {@link CustomModel} */ - public ServiceCall getVoiceModel(GetVoiceModelOptions getVoiceModelOptions) { + public ServiceCall getCustomModel(GetCustomModelOptions getCustomModelOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( - getVoiceModelOptions, "getVoiceModelOptions cannot be null"); - String[] pathSegments = {"v1/customizations"}; - String[] pathParameters = {getVoiceModelOptions.customizationId()}; + getCustomModelOptions, "getCustomModelOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", getCustomModelOptions.customizationId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/customizations/{customization_id}", pathParamsMap)); Map sdkHeaders = - SdkCommon.getSdkHeaders("text_to_speech", "v1", "getVoiceModel"); + SdkCommon.getSdkHeaders("text_to_speech", "v1", "getCustomModel"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - - ResponseConverter responseConverter = + ResponseConverter responseConverter = ResponseConverterUtils.getValue( - new com.google.gson.reflect.TypeToken() {}.getType()); + new com.google.gson.reflect.TypeToken() {}.getType()); return createServiceCall(builder.build(), responseConverter); } /** * Delete a custom model. * - *

Deletes the specified custom voice model. You must use credentials for the instance of the - * service that owns a model to delete it. - * - *

**Note:** This method is currently a beta release. + *

Deletes the specified custom model. You must use credentials for the instance of the service + * that owns a model to delete it. * *

**See also:** [Deleting a custom * model](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customModels#cuModelsDelete). * - * @param deleteVoiceModelOptions the {@link DeleteVoiceModelOptions} containing the options for + * @param deleteCustomModelOptions the {@link DeleteCustomModelOptions} containing the options for * the call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ - public ServiceCall deleteVoiceModel(DeleteVoiceModelOptions deleteVoiceModelOptions) { + public ServiceCall deleteCustomModel(DeleteCustomModelOptions deleteCustomModelOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( - deleteVoiceModelOptions, "deleteVoiceModelOptions cannot be null"); - String[] pathSegments = {"v1/customizations"}; - String[] pathParameters = {deleteVoiceModelOptions.customizationId()}; + deleteCustomModelOptions, "deleteCustomModelOptions cannot be null"); + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", deleteCustomModelOptions.customizationId()); RequestBuilder builder = RequestBuilder.delete( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/customizations/{customization_id}", pathParamsMap)); Map sdkHeaders = - SdkCommon.getSdkHeaders("text_to_speech", "v1", "deleteVoiceModel"); + SdkCommon.getSdkHeaders("text_to_speech", "v1", "deleteCustomModel"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } - ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -621,19 +569,23 @@ public ServiceCall deleteVoiceModel(DeleteVoiceModelOptions deleteVoiceMod /** * Add custom words. * - *

Adds one or more words and their translations to the specified custom voice model. Adding a - * new translation for a word that already exists in a custom model overwrites the word's existing + *

Adds one or more words and their translations to the specified custom model. Adding a new + * translation for a word that already exists in a custom model overwrites the word's existing * translation. A custom model can contain no more than 20,000 entries. You must use credentials * for the instance of the service that owns a model to add words to it. * *

You can define sounds-like or phonetic translations for words. A sounds-like translation * consists of one or more words that, when combined, sound like the word. Phonetic translations * are based on the SSML phoneme format for representing a word. You can specify them in standard - * International Phonetic Alphabet (IPA) representation - * <phoneme alphabet="ipa" ph="təmˈɑto"></phoneme> or in the - * proprietary IBM Symbolic Phonetic Representation (SPR) - * <phoneme alphabet="ibm" ph="1gAstroEntxrYFXs"></phoneme> **Note:** This - * method is currently a beta release. + * International Phonetic Alphabet (IPA) representation + * + *

<code>&lt;phoneme alphabet="ipa" + * ph="t&#601;m&#712;&#593;to"&gt;&lt;/phoneme&gt;</code> + * + *

or in the proprietary IBM Symbolic Phonetic Representation (SPR) + * + *

<code>&lt;phoneme alphabet="ibm" + * ph="1gAstroEntxrYFXs"&gt;&lt;/phoneme&gt;</code> * *

**See also:** * [Adding multiple words to a custom * model](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customWords#cuWordsAdd) * @@ -643,16 +595,17 @@ public ServiceCall deleteVoiceModel(DeleteVoiceModelOptions deleteVoiceMod * customization](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customIntro#customIntro). * * @param addWordsOptions the {@link AddWordsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall addWords(AddWordsOptions addWordsOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( addWordsOptions, "addWordsOptions cannot be null"); - String[] pathSegments = {"v1/customizations", "words"}; - String[] pathParameters = {addWordsOptions.customizationId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", addWordsOptions.customizationId()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/customizations/{customization_id}/words", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "addWords"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); @@ -670,32 +623,30 @@ public ServiceCall addWords(AddWordsOptions addWordsOptions) { /** * List custom words. * - *

Lists all of the words and their translations for the specified custom voice model. The - * output shows the translations as they are defined in the model. You must use credentials for - * the instance of the service that owns a model to list its words. - * - *

**Note:** This method is currently a beta release. + *

Lists all of the words and their translations for the specified custom model. The output + * shows the translations as they are defined in the model. You must use credentials for the + * instance of the service that owns a model to list its words. * *

**See also:** [Querying all words from a custom * model](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customWords#cuWordsQueryModel). * * @param listWordsOptions the {@link ListWordsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Words} + * @return a {@link ServiceCall} with a result of type {@link Words} */ public ServiceCall listWords(ListWordsOptions listWordsOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( listWordsOptions, "listWordsOptions cannot be null"); - String[] pathSegments = {"v1/customizations", "words"}; - String[] pathParameters = {listWordsOptions.customizationId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", listWordsOptions.customizationId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v1/customizations/{customization_id}/words", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "listWords"); 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()); @@ -705,7 +656,7 @@ public ServiceCall listWords(ListWordsOptions listWordsOptions) { /** * Add a custom word. * - *

Adds a single word and its translation to the specified custom voice model. Adding a new + *

Adds a single word and its translation to the specified custom model. Adding a new * translation for a word that already exists in a custom model overwrites the word's existing * translation. A custom model can contain no more than 20,000 entries. You must use credentials * for the instance of the service that owns a model to add a word to it. @@ -713,11 +664,15 @@ public ServiceCall listWords(ListWordsOptions listWordsOptions) { *

You can define sounds-like or phonetic translations for words. A sounds-like translation * consists of one or more words that, when combined, sound like the word. Phonetic translations * are based on the SSML phoneme format for representing a word. You can specify them in standard - * International Phonetic Alphabet (IPA) representation - * <phoneme alphabet="ipa" ph="təmˈɑto"></phoneme> or in the - * proprietary IBM Symbolic Phonetic Representation (SPR) - * <phoneme alphabet="ibm" ph="1gAstroEntxrYFXs"></phoneme> **Note:** This - * method is currently a beta release. + * International Phonetic Alphabet (IPA) representation + * + *

<code>&lt;phoneme alphabet="ipa" + * ph="t&#601;m&#712;&#593;to"&gt;&lt;/phoneme&gt;</code> + * + *

or in the proprietary IBM Symbolic Phonetic Representation (SPR) + * + *

<code>&lt;phoneme alphabet="ibm" + * ph="1gAstroEntxrYFXs"&gt;&lt;/phoneme&gt;</code> * *

**See also:** * [Adding a single word to a custom * model](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customWords#cuWordAdd) * @@ -727,15 +682,19 @@ public ServiceCall listWords(ListWordsOptions listWordsOptions) { * customization](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customIntro#customIntro). * * @param addWordOptions the {@link AddWordOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall addWord(AddWordOptions addWordOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull(addWordOptions, "addWordOptions cannot be null"); - String[] pathSegments = {"v1/customizations", "words"}; - String[] pathParameters = {addWordOptions.customizationId(), addWordOptions.word()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", addWordOptions.customizationId()); + pathParamsMap.put("word", addWordOptions.word()); RequestBuilder builder = RequestBuilder.put( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/customizations/{customization_id}/words/{word}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "addWord"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); @@ -757,27 +716,28 @@ public ServiceCall addWord(AddWordOptions addWordOptions) { * translation as it is defined in the model. You must use credentials for the instance of the * service that owns a model to list its words. * - *

**Note:** This method is currently a beta release. - * *

**See also:** [Querying a single word from a custom * model](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customWords#cuWordQueryModel). * * @param getWordOptions the {@link GetWordOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Translation} + * @return a {@link ServiceCall} with a result of type {@link Translation} */ public ServiceCall getWord(GetWordOptions getWordOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull(getWordOptions, "getWordOptions cannot be null"); - String[] pathSegments = {"v1/customizations", "words"}; - String[] pathParameters = {getWordOptions.customizationId(), getWordOptions.word()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", getWordOptions.customizationId()); + pathParamsMap.put("word", getWordOptions.word()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/customizations/{customization_id}/words/{word}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "getWord"); 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()); @@ -787,30 +747,31 @@ public ServiceCall getWord(GetWordOptions getWordOptions) { /** * Delete a custom word. * - *

Deletes a single word from the specified custom voice model. You must use credentials for - * the instance of the service that owns a model to delete its words. - * - *

**Note:** This method is currently a beta release. + *

Deletes a single word from the specified custom model. You must use credentials for the + * instance of the service that owns a model to delete its words. * *

**See also:** [Deleting a word from a custom * model](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customWords#cuWordDelete). * * @param deleteWordOptions the {@link DeleteWordOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteWord(DeleteWordOptions deleteWordOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( deleteWordOptions, "deleteWordOptions cannot be null"); - String[] pathSegments = {"v1/customizations", "words"}; - String[] pathParameters = {deleteWordOptions.customizationId(), deleteWordOptions.word()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("customization_id", deleteWordOptions.customizationId()); + pathParamsMap.put("word", deleteWordOptions.word()); RequestBuilder builder = RequestBuilder.delete( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v1/customizations/{customization_id}/words/{word}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "deleteWord"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } - ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -826,28 +787,27 @@ public ServiceCall deleteWord(DeleteWordOptions deleteWordOptions) { * header with a request that passes the data. * *

**Note:** If you delete an instance of the service from the service console, all data - * associated with that service instance is automatically deleted. This includes all custom voice - * models and word/translation pairs, and all data related to speech synthesis requests. + * associated with that service instance is automatically deleted. This includes all custom models + * and word/translation pairs, and all data related to speech synthesis requests. * *

**See also:** [Information * security](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-information-security#information-security). * * @param deleteUserDataOptions the {@link DeleteUserDataOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteUserData(DeleteUserDataOptions deleteUserDataOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( deleteUserDataOptions, "deleteUserDataOptions cannot be null"); - String[] pathSegments = {"v1/user_data"}; RequestBuilder builder = - RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); + RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/user_data")); Map sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "deleteUserData"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } - builder.query("customer_id", deleteUserDataOptions.customerId()); + builder.query("customer_id", String.valueOf(deleteUserDataOptions.customerId())); ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/AddWordOptions.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/AddWordOptions.java index 5cbda04243c..285e449b760 100644 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/AddWordOptions.java +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/AddWordOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -99,7 +99,7 @@ public Builder(String customizationId, String word, String translation) { /** * Builds a AddWordOptions. * - * @return the addWordOptions + * @return the new AddWordOptions instance */ public AddWordOptions build() { return new AddWordOptions(this); @@ -186,8 +186,8 @@ public Builder newBuilder() { /** * Gets the customizationId. * - *

The customization ID (GUID) of the custom voice model. You must make the request with - * credentials for the instance of the service that owns the custom model. + *

The customization ID (GUID) of the custom model. You must make the request with credentials + * for the instance of the service that owns the custom model. * * @return the customizationId */ @@ -198,7 +198,7 @@ public String customizationId() { /** * Gets the word. * - *

The word that is to be added or updated for the custom voice model. + *

The word that is to be added or updated for the custom model. * * @return the word */ diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/AddWordsOptions.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/AddWordsOptions.java index 5fe0f85b151..6493cfa877d 100644 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/AddWordsOptions.java +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/AddWordsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -49,7 +49,7 @@ public Builder(String customizationId, List words) { /** * Builds a AddWordsOptions. * - * @return the addWordsOptions + * @return the new AddWordsOptions instance */ public AddWordsOptions build() { return new AddWordsOptions(this); @@ -124,8 +124,8 @@ public Builder newBuilder() { /** * Gets the customizationId. * - *

The customization ID (GUID) of the custom voice model. You must make the request with - * credentials for the instance of the service that owns the custom model. + *

The customization ID (GUID) of the custom model. You must make the request with credentials + * for the instance of the service that owns the custom model. * * @return the customizationId */ @@ -137,12 +137,12 @@ public String customizationId() { * Gets the words. * *

The **Add custom words** method accepts an array of `Word` objects. Each object provides a - * word that is to be added or updated for the custom voice model and the word's translation. + * word that is to be added or updated for the custom model and the word's translation. * *

The **List custom words** method returns an array of `Word` objects. Each object shows a - * word and its translation from the custom voice model. The words are listed in alphabetical - * order, with uppercase letters listed before lowercase letters. The array is empty if the custom - * model contains no words. + * word and its translation from the custom model. The words are listed in alphabetical order, + * with uppercase letters listed before lowercase letters. The array is empty if the custom model + * contains no words. * * @return the words */ diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/CreateVoiceModelOptions.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/CreateCustomModelOptions.java similarity index 66% rename from text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/CreateVoiceModelOptions.java rename to text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/CreateCustomModelOptions.java index 6fbb3ea535e..d5449770491 100644 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/CreateVoiceModelOptions.java +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/CreateCustomModelOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -14,14 +14,13 @@ import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** The createVoiceModel options. */ -public class CreateVoiceModelOptions extends GenericModel { +/** The createCustomModel options. */ +public class CreateCustomModelOptions extends GenericModel { /** - * The language of the new custom voice model. You create a custom voice model for a specific - * language, not for a specific voice. A custom model can be used with any voice, standard or - * neural, for its specified language. Omit the parameter to use the the default language, - * `en-US`. + * The language of the new custom model. You create a custom model for a specific language, not + * for a specific voice. A custom model can be used with any voice, standard or neural, for its + * specified language. Omit the parameter to use the the default language, `en-US`. */ public interface Language { /** ar-AR. */ @@ -64,10 +63,10 @@ public static class Builder { private String language; private String description; - private Builder(CreateVoiceModelOptions createVoiceModelOptions) { - this.name = createVoiceModelOptions.name; - this.language = createVoiceModelOptions.language; - this.description = createVoiceModelOptions.description; + private Builder(CreateCustomModelOptions createCustomModelOptions) { + this.name = createCustomModelOptions.name; + this.language = createCustomModelOptions.language; + this.description = createCustomModelOptions.description; } /** Instantiates a new builder. */ @@ -83,19 +82,19 @@ public Builder(String name) { } /** - * Builds a CreateVoiceModelOptions. + * Builds a CreateCustomModelOptions. * - * @return the createVoiceModelOptions + * @return the new CreateCustomModelOptions instance */ - public CreateVoiceModelOptions build() { - return new CreateVoiceModelOptions(this); + public CreateCustomModelOptions build() { + return new CreateCustomModelOptions(this); } /** * Set the name. * * @param name the name - * @return the CreateVoiceModelOptions builder + * @return the CreateCustomModelOptions builder */ public Builder name(String name) { this.name = name; @@ -106,7 +105,7 @@ public Builder name(String name) { * Set the language. * * @param language the language - * @return the CreateVoiceModelOptions builder + * @return the CreateCustomModelOptions builder */ public Builder language(String language) { this.language = language; @@ -117,7 +116,7 @@ public Builder language(String language) { * Set the description. * * @param description the description - * @return the CreateVoiceModelOptions builder + * @return the CreateCustomModelOptions builder */ public Builder description(String description) { this.description = description; @@ -125,7 +124,7 @@ public Builder description(String description) { } } - protected CreateVoiceModelOptions(Builder builder) { + protected CreateCustomModelOptions(Builder builder) { com.ibm.cloud.sdk.core.util.Validator.notNull(builder.name, "name cannot be null"); name = builder.name; language = builder.language; @@ -135,7 +134,7 @@ protected CreateVoiceModelOptions(Builder builder) { /** * New builder. * - * @return a CreateVoiceModelOptions builder + * @return a CreateCustomModelOptions builder */ public Builder newBuilder() { return new Builder(this); @@ -144,7 +143,7 @@ public Builder newBuilder() { /** * Gets the name. * - *

The name of the new custom voice model. + *

The name of the new custom model. * * @return the name */ @@ -155,10 +154,9 @@ public String name() { /** * Gets the language. * - *

The language of the new custom voice model. You create a custom voice model for a specific - * language, not for a specific voice. A custom model can be used with any voice, standard or - * neural, for its specified language. Omit the parameter to use the the default language, - * `en-US`. + *

The language of the new custom model. You create a custom model for a specific language, not + * for a specific voice. A custom model can be used with any voice, standard or neural, for its + * specified language. Omit the parameter to use the the default language, `en-US`. * * @return the language */ @@ -169,7 +167,7 @@ public String language() { /** * Gets the description. * - *

A description of the new custom voice model. Specifying a description is recommended. + *

A description of the new custom model. Specifying a description is recommended. * * @return the description */ diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/VoiceModel.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/CustomModel.java similarity index 75% rename from text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/VoiceModel.java rename to text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/CustomModel.java index 74e1c56d8f1..50bd4f60456 100644 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/VoiceModel.java +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/CustomModel.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -16,8 +16,8 @@ import com.ibm.cloud.sdk.core.service.model.GenericModel; import java.util.List; -/** Information about an existing custom voice model. */ -public class VoiceModel extends GenericModel { +/** Information about an existing custom model. */ +public class CustomModel extends GenericModel { @SerializedName("customization_id") protected String customizationId; @@ -36,7 +36,7 @@ public class VoiceModel extends GenericModel { /** * Gets the customizationId. * - *

The customization ID (GUID) of the custom voice model. The **Create a custom model** method + *

The customization ID (GUID) of the custom model. The **Create a custom model** method * returns only this field. It does not not return the other fields of this object. * * @return the customizationId @@ -48,7 +48,7 @@ public String getCustomizationId() { /** * Gets the name. * - *

The name of the custom voice model. + *

The name of the custom model. * * @return the name */ @@ -59,7 +59,7 @@ public String getName() { /** * Gets the language. * - *

The language identifier of the custom voice model (for example, `en-US`). + *

The language identifier of the custom model (for example, `en-US`). * * @return the language */ @@ -70,8 +70,7 @@ public String getLanguage() { /** * Gets the owner. * - *

The GUID of the credentials for the instance of the service that owns the custom voice - * model. + *

The GUID of the credentials for the instance of the service that owns the custom model. * * @return the owner */ @@ -82,8 +81,8 @@ public String getOwner() { /** * Gets the created. * - *

The date and time in Coordinated Universal Time (UTC) at which the custom voice model was - * created. The value is provided in full ISO 8601 format (`YYYY-MM-DDThh:mm:ss.sTZD`). + *

The date and time in Coordinated Universal Time (UTC) at which the custom model was created. + * The value is provided in full ISO 8601 format (`YYYY-MM-DDThh:mm:ss.sTZD`). * * @return the created */ @@ -94,10 +93,9 @@ public String getCreated() { /** * Gets the lastModified. * - *

The date and time in Coordinated Universal Time (UTC) at which the custom voice model was - * last modified. The `created` and `updated` fields are equal when a voice model is first added - * but has yet to be updated. The value is provided in full ISO 8601 format - * (`YYYY-MM-DDThh:mm:ss.sTZD`). + *

The date and time in Coordinated Universal Time (UTC) at which the custom model was last + * modified. The `created` and `updated` fields are equal when a model is first added but has yet + * to be updated. The value is provided in full ISO 8601 format (`YYYY-MM-DDThh:mm:ss.sTZD`). * * @return the lastModified */ @@ -108,7 +106,7 @@ public String getLastModified() { /** * Gets the description. * - *

The description of the custom voice model. + *

The description of the custom model. * * @return the description */ @@ -119,11 +117,11 @@ public String getDescription() { /** * Gets the words. * - *

An array of `Word` objects that lists the words and their translations from the custom voice + *

An array of `Word` objects that lists the words and their translations from the custom * model. The words are listed in alphabetical order, with uppercase letters listed before * lowercase letters. The array is empty if the custom model contains no words. This field is * returned only by the **Get a voice** method and only when you specify the customization ID of a - * custom voice model. + * custom model. * * @return the words */ diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/VoiceModels.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/CustomModels.java similarity index 65% rename from text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/VoiceModels.java rename to text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/CustomModels.java index 13f033f2ea1..010b66e5f60 100644 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/VoiceModels.java +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/CustomModels.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -15,21 +15,21 @@ import com.ibm.cloud.sdk.core.service.model.GenericModel; import java.util.List; -/** Information about existing custom voice models. */ -public class VoiceModels extends GenericModel { +/** Information about existing custom models. */ +public class CustomModels extends GenericModel { - protected List customizations; + protected List customizations; /** * Gets the customizations. * - *

An array of `VoiceModel` objects that provides information about each available custom voice - * model. The array is empty if the requesting credentials own no custom voice models (if no - * language is specified) or own no custom voice models for the specified language. + *

An array of `CustomModel` objects that provides information about each available custom + * model. The array is empty if the requesting credentials own no custom models (if no language is + * specified) or own no custom models for the specified language. * * @return the customizations */ - public List getCustomizations() { + public List getCustomizations() { return customizations; } } diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/DeleteVoiceModelOptions.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/DeleteCustomModelOptions.java similarity index 69% rename from text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/DeleteVoiceModelOptions.java rename to text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/DeleteCustomModelOptions.java index 4784797b7ad..dbb17e6bcf4 100644 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/DeleteVoiceModelOptions.java +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/DeleteCustomModelOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -14,8 +14,8 @@ import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** The deleteVoiceModel options. */ -public class DeleteVoiceModelOptions extends GenericModel { +/** The deleteCustomModel options. */ +public class DeleteCustomModelOptions extends GenericModel { protected String customizationId; @@ -23,8 +23,8 @@ public class DeleteVoiceModelOptions extends GenericModel { public static class Builder { private String customizationId; - private Builder(DeleteVoiceModelOptions deleteVoiceModelOptions) { - this.customizationId = deleteVoiceModelOptions.customizationId; + private Builder(DeleteCustomModelOptions deleteCustomModelOptions) { + this.customizationId = deleteCustomModelOptions.customizationId; } /** Instantiates a new builder. */ @@ -40,19 +40,19 @@ public Builder(String customizationId) { } /** - * Builds a DeleteVoiceModelOptions. + * Builds a DeleteCustomModelOptions. * - * @return the deleteVoiceModelOptions + * @return the new DeleteCustomModelOptions instance */ - public DeleteVoiceModelOptions build() { - return new DeleteVoiceModelOptions(this); + public DeleteCustomModelOptions build() { + return new DeleteCustomModelOptions(this); } /** * Set the customizationId. * * @param customizationId the customizationId - * @return the DeleteVoiceModelOptions builder + * @return the DeleteCustomModelOptions builder */ public Builder customizationId(String customizationId) { this.customizationId = customizationId; @@ -60,7 +60,7 @@ public Builder customizationId(String customizationId) { } } - protected DeleteVoiceModelOptions(Builder builder) { + protected DeleteCustomModelOptions(Builder builder) { com.ibm.cloud.sdk.core.util.Validator.notEmpty( builder.customizationId, "customizationId cannot be empty"); customizationId = builder.customizationId; @@ -69,7 +69,7 @@ protected DeleteVoiceModelOptions(Builder builder) { /** * New builder. * - * @return a DeleteVoiceModelOptions builder + * @return a DeleteCustomModelOptions builder */ public Builder newBuilder() { return new Builder(this); @@ -78,8 +78,8 @@ public Builder newBuilder() { /** * Gets the customizationId. * - *

The customization ID (GUID) of the custom voice model. You must make the request with - * credentials for the instance of the service that owns the custom model. + *

The customization ID (GUID) of the custom model. You must make the request with credentials + * for the instance of the service that owns the custom model. * * @return the customizationId */ diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/DeleteUserDataOptions.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/DeleteUserDataOptions.java index 9dda253ab64..bab48896144 100644 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/DeleteUserDataOptions.java +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/DeleteUserDataOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -42,7 +42,7 @@ public Builder(String customerId) { /** * Builds a DeleteUserDataOptions. * - * @return the deleteUserDataOptions + * @return the new DeleteUserDataOptions instance */ public DeleteUserDataOptions build() { return new DeleteUserDataOptions(this); diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/DeleteWordOptions.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/DeleteWordOptions.java index 9a9be04d74d..ad9d0523ea9 100644 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/DeleteWordOptions.java +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/DeleteWordOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -47,7 +47,7 @@ public Builder(String customizationId, String word) { /** * Builds a DeleteWordOptions. * - * @return the deleteWordOptions + * @return the new DeleteWordOptions instance */ public DeleteWordOptions build() { return new DeleteWordOptions(this); @@ -96,8 +96,8 @@ public Builder newBuilder() { /** * Gets the customizationId. * - *

The customization ID (GUID) of the custom voice model. You must make the request with - * credentials for the instance of the service that owns the custom model. + *

The customization ID (GUID) of the custom model. You must make the request with credentials + * for the instance of the service that owns the custom model. * * @return the customizationId */ @@ -108,7 +108,7 @@ public String customizationId() { /** * Gets the word. * - *

The word that is to be deleted from the custom voice model. + *

The word that is to be deleted from the custom model. * * @return the word */ diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/GetVoiceModelOptions.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/GetCustomModelOptions.java similarity index 70% rename from text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/GetVoiceModelOptions.java rename to text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/GetCustomModelOptions.java index 5e020b96d0b..334449a27cd 100644 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/GetVoiceModelOptions.java +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/GetCustomModelOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -14,8 +14,8 @@ import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** The getVoiceModel options. */ -public class GetVoiceModelOptions extends GenericModel { +/** The getCustomModel options. */ +public class GetCustomModelOptions extends GenericModel { protected String customizationId; @@ -23,8 +23,8 @@ public class GetVoiceModelOptions extends GenericModel { public static class Builder { private String customizationId; - private Builder(GetVoiceModelOptions getVoiceModelOptions) { - this.customizationId = getVoiceModelOptions.customizationId; + private Builder(GetCustomModelOptions getCustomModelOptions) { + this.customizationId = getCustomModelOptions.customizationId; } /** Instantiates a new builder. */ @@ -40,19 +40,19 @@ public Builder(String customizationId) { } /** - * Builds a GetVoiceModelOptions. + * Builds a GetCustomModelOptions. * - * @return the getVoiceModelOptions + * @return the new GetCustomModelOptions instance */ - public GetVoiceModelOptions build() { - return new GetVoiceModelOptions(this); + public GetCustomModelOptions build() { + return new GetCustomModelOptions(this); } /** * Set the customizationId. * * @param customizationId the customizationId - * @return the GetVoiceModelOptions builder + * @return the GetCustomModelOptions builder */ public Builder customizationId(String customizationId) { this.customizationId = customizationId; @@ -60,7 +60,7 @@ public Builder customizationId(String customizationId) { } } - protected GetVoiceModelOptions(Builder builder) { + protected GetCustomModelOptions(Builder builder) { com.ibm.cloud.sdk.core.util.Validator.notEmpty( builder.customizationId, "customizationId cannot be empty"); customizationId = builder.customizationId; @@ -69,7 +69,7 @@ protected GetVoiceModelOptions(Builder builder) { /** * New builder. * - * @return a GetVoiceModelOptions builder + * @return a GetCustomModelOptions builder */ public Builder newBuilder() { return new Builder(this); @@ -78,8 +78,8 @@ public Builder newBuilder() { /** * Gets the customizationId. * - *

The customization ID (GUID) of the custom voice model. You must make the request with - * credentials for the instance of the service that owns the custom model. + *

The customization ID (GUID) of the custom model. You must make the request with credentials + * for the instance of the service that owns the custom model. * * @return the customizationId */ diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/GetPronunciationOptions.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/GetPronunciationOptions.java index 56fc6b35ff4..64301822143 100644 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/GetPronunciationOptions.java +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/GetPronunciationOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -158,7 +158,7 @@ public Builder(String text) { /** * Builds a GetPronunciationOptions. * - * @return the getPronunciationOptions + * @return the new GetPronunciationOptions instance */ public GetPronunciationOptions build() { return new GetPronunciationOptions(this); @@ -265,12 +265,12 @@ public String format() { /** * Gets the customizationId. * - *

The customization ID (GUID) of a custom voice model for which the pronunciation is to be - * returned. The language of a specified custom model must match the language of the specified - * voice. If the word is not defined in the specified custom model, the service returns the - * default translation for the custom model's language. You must make the request with credentials - * for the instance of the service that owns the custom model. Omit the parameter to see the - * translation for the specified voice with no customization. + *

The customization ID (GUID) of a custom model for which the pronunciation is to be returned. + * The language of a specified custom model must match the language of the specified voice. If the + * word is not defined in the specified custom model, the service returns the default translation + * for the custom model's language. You must make the request with credentials for the instance of + * the service that owns the custom model. Omit the parameter to see the translation for the + * specified voice with no customization. * * @return the customizationId */ diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/GetVoiceOptions.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/GetVoiceOptions.java index 071caf73407..c2b34a53d62 100644 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/GetVoiceOptions.java +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/GetVoiceOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -137,7 +137,7 @@ public Builder(String voice) { /** * Builds a GetVoiceOptions. * - * @return the getVoiceOptions + * @return the new GetVoiceOptions instance */ public GetVoiceOptions build() { return new GetVoiceOptions(this); @@ -195,8 +195,8 @@ public String voice() { /** * Gets the customizationId. * - *

The customization ID (GUID) of a custom voice model for which information is to be returned. - * You must make the request with credentials for the instance of the service that owns the custom + *

The customization ID (GUID) of a custom model for which information is to be returned. You + * must make the request with credentials for the instance of the service that owns the custom * model. Omit the parameter to see information about the specified voice with no customization. * * @return the customizationId diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/GetWordOptions.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/GetWordOptions.java index 29106e407f3..5a74268617b 100644 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/GetWordOptions.java +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/GetWordOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -47,7 +47,7 @@ public Builder(String customizationId, String word) { /** * Builds a GetWordOptions. * - * @return the getWordOptions + * @return the new GetWordOptions instance */ public GetWordOptions build() { return new GetWordOptions(this); @@ -96,8 +96,8 @@ public Builder newBuilder() { /** * Gets the customizationId. * - *

The customization ID (GUID) of the custom voice model. You must make the request with - * credentials for the instance of the service that owns the custom model. + *

The customization ID (GUID) of the custom model. You must make the request with credentials + * for the instance of the service that owns the custom model. * * @return the customizationId */ @@ -108,7 +108,7 @@ public String customizationId() { /** * Gets the word. * - *

The word that is to be queried from the custom voice model. + *

The word that is to be queried from the custom model. * * @return the word */ diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/ListVoiceModelsOptions.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/ListCustomModelsOptions.java similarity index 67% rename from text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/ListVoiceModelsOptions.java rename to text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/ListCustomModelsOptions.java index 892d41a9713..691abca354d 100644 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/ListVoiceModelsOptions.java +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/ListCustomModelsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -14,12 +14,12 @@ import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** The listVoiceModels options. */ -public class ListVoiceModelsOptions extends GenericModel { +/** The listCustomModels options. */ +public class ListCustomModelsOptions extends GenericModel { /** - * The language for which custom voice models that are owned by the requesting credentials are to - * be returned. Omit the parameter to see all custom voice models that are owned by the requester. + * The language for which custom models that are owned by the requesting credentials are to be + * returned. Omit the parameter to see all custom models that are owned by the requester. */ public interface Language { /** ar-AR. */ @@ -58,27 +58,27 @@ public interface Language { public static class Builder { private String language; - private Builder(ListVoiceModelsOptions listVoiceModelsOptions) { - this.language = listVoiceModelsOptions.language; + private Builder(ListCustomModelsOptions listCustomModelsOptions) { + this.language = listCustomModelsOptions.language; } /** Instantiates a new builder. */ public Builder() {} /** - * Builds a ListVoiceModelsOptions. + * Builds a ListCustomModelsOptions. * - * @return the listVoiceModelsOptions + * @return the new ListCustomModelsOptions instance */ - public ListVoiceModelsOptions build() { - return new ListVoiceModelsOptions(this); + public ListCustomModelsOptions build() { + return new ListCustomModelsOptions(this); } /** * Set the language. * * @param language the language - * @return the ListVoiceModelsOptions builder + * @return the ListCustomModelsOptions builder */ public Builder language(String language) { this.language = language; @@ -86,14 +86,14 @@ public Builder language(String language) { } } - protected ListVoiceModelsOptions(Builder builder) { + protected ListCustomModelsOptions(Builder builder) { language = builder.language; } /** * New builder. * - * @return a ListVoiceModelsOptions builder + * @return a ListCustomModelsOptions builder */ public Builder newBuilder() { return new Builder(this); @@ -102,9 +102,8 @@ public Builder newBuilder() { /** * Gets the language. * - *

The language for which custom voice models that are owned by the requesting credentials are - * to be returned. Omit the parameter to see all custom voice models that are owned by the - * requester. + *

The language for which custom models that are owned by the requesting credentials are to be + * returned. Omit the parameter to see all custom models that are owned by the requester. * * @return the language */ diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/ListVoicesOptions.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/ListVoicesOptions.java index 27518578077..d9a7628c706 100644 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/ListVoicesOptions.java +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/ListVoicesOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -15,34 +15,4 @@ import com.ibm.cloud.sdk.core.service.model.GenericModel; /** The listVoices options. */ -public class ListVoicesOptions extends GenericModel { - - /** Builder. */ - public static class Builder { - - private Builder(ListVoicesOptions listVoicesOptions) {} - - /** Instantiates a new builder. */ - public Builder() {} - - /** - * Builds a ListVoicesOptions. - * - * @return the listVoicesOptions - */ - public ListVoicesOptions build() { - return new ListVoicesOptions(this); - } - } - - private ListVoicesOptions(Builder builder) {} - - /** - * New builder. - * - * @return a ListVoicesOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } -} +public class ListVoicesOptions extends GenericModel {} diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/ListWordsOptions.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/ListWordsOptions.java index cf9b3960d72..8d58cbe5c0a 100644 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/ListWordsOptions.java +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/ListWordsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -42,7 +42,7 @@ public Builder(String customizationId) { /** * Builds a ListWordsOptions. * - * @return the listWordsOptions + * @return the new ListWordsOptions instance */ public ListWordsOptions build() { return new ListWordsOptions(this); @@ -78,8 +78,8 @@ public Builder newBuilder() { /** * Gets the customizationId. * - *

The customization ID (GUID) of the custom voice model. You must make the request with - * credentials for the instance of the service that owns the custom model. + *

The customization ID (GUID) of the custom model. You must make the request with credentials + * for the instance of the service that owns the custom model. * * @return the customizationId */ diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/MarkTiming.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/MarkTiming.java deleted file mode 100644 index 5640464629a..00000000000 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/MarkTiming.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.ibm.watson.text_to_speech.v1.model; - -import com.google.gson.annotations.JsonAdapter; -import com.ibm.cloud.sdk.core.service.model.GenericModel; -import com.ibm.watson.text_to_speech.v1.util.MarkTimingTypeAdapter; - -@JsonAdapter(MarkTimingTypeAdapter.class) -public class MarkTiming extends GenericModel { - private String mark; - private Double time; - - public String getMark() { - return mark; - } - - public Double getTime() { - return time; - } - - public void setMark(String mark) { - this.mark = mark; - } - - public void setTime(Double time) { - this.time = time; - } -} diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Marks.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Marks.java deleted file mode 100644 index 23fe18ec6fb..00000000000 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Marks.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.ibm.watson.text_to_speech.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; -import java.util.List; - -public class Marks extends GenericModel { - private List marks; - - public List getMarks() { - return marks; - } -} diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Pronunciation.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Pronunciation.java index 48cdea20b56..f7a5d5028f7 100644 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Pronunciation.java +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Pronunciation.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -22,8 +22,8 @@ public class Pronunciation extends GenericModel { /** * Gets the pronunciation. * - *

The pronunciation of the specified text in the requested voice and format. If a custom voice - * model is specified, the pronunciation also reflects that custom voice. + *

The pronunciation of the specified text in the requested voice and format. If a custom model + * is specified, the pronunciation also reflects that custom model. * * @return the pronunciation */ diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/SupportedFeatures.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/SupportedFeatures.java index 02046670bc7..067182ac3d4 100644 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/SupportedFeatures.java +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/SupportedFeatures.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -39,8 +39,8 @@ public Boolean isCustomPronunciation() { /** * Gets the voiceTransformation. * - *

If `true`, the voice can be transformed by using the SSML <voice-transformation> - * element; if `false`, the voice cannot be transformed. + *

If `true`, the voice can be transformed by using the SSML + * &lt;voice-transformation&gt; element; if `false`, the voice cannot be transformed. * * @return the voiceTransformation */ diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/SynthesizeOptions.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/SynthesizeOptions.java index 2ab6e55da74..0dcb8490253 100644 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/SynthesizeOptions.java +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/SynthesizeOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -13,7 +13,6 @@ package com.ibm.watson.text_to_speech.v1.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; -import java.util.List; /** The synthesize options. */ public class SynthesizeOptions extends GenericModel { @@ -114,7 +113,6 @@ public interface Voice { protected String accept; protected String voice; protected String customizationId; - protected List timings; /** Builder. */ public static class Builder { @@ -122,14 +120,12 @@ public static class Builder { private String accept; private String voice; private String customizationId; - protected List timings; private Builder(SynthesizeOptions synthesizeOptions) { this.text = synthesizeOptions.text; this.accept = synthesizeOptions.accept; this.voice = synthesizeOptions.voice; this.customizationId = synthesizeOptions.customizationId; - this.timings = synthesizeOptions.timings; } /** Instantiates a new builder. */ @@ -147,7 +143,7 @@ public Builder(String text) { /** * Builds a SynthesizeOptions. * - * @return the synthesizeOptions + * @return the new SynthesizeOptions instance */ public SynthesizeOptions build() { return new SynthesizeOptions(this); @@ -196,17 +192,6 @@ public Builder customizationId(String customizationId) { this.customizationId = customizationId; return this; } - - /** - * Set the timings. - * - * @param timings the timings - * @return the SynthesizeOptions builder - */ - public Builder timings(List timings) { - this.timings = timings; - return this; - } } protected SynthesizeOptions(Builder builder) { @@ -215,7 +200,6 @@ protected SynthesizeOptions(Builder builder) { accept = builder.accept; voice = builder.voice; customizationId = builder.customizationId; - timings = builder.timings; } /** @@ -265,31 +249,14 @@ public String voice() { /** * Gets the customizationId. * - *

The customization ID (GUID) of a custom voice model to use for the synthesis. If a custom - * voice model is specified, it works only if it matches the language of the indicated voice. You - * must make the request with credentials for the instance of the service that owns the custom - * model. Omit the parameter to use the specified voice with no customization. + *

The customization ID (GUID) of a custom model to use for the synthesis. If a custom model is + * specified, it works only if it matches the language of the indicated voice. You must make the + * request with credentials for the instance of the service that owns the custom model. Omit the + * parameter to use the specified voice with no customization. * * @return the customizationId */ public String customizationId() { return customizationId; } - - /** - * Gets the timings. - * - *

An array that specifies whether the service is to return word timing information for all - * strings of the input text. Specify `words` as the element of the array to request word timing - * information. The service returns the start and end time of each word of the input. Specify an - * empty array or omit the parameter to receive no word timing information. Not supported for - * Japanese input text. - * - *

NOTE: This parameter only works for the `synthesizeUsingWebSocket` method. - * - * @return the timings - */ - public List getTimings() { - return timings; - } } diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Timings.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Timings.java deleted file mode 100644 index 5985a4932c8..00000000000 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Timings.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.ibm.watson.text_to_speech.v1.model; - -import com.ibm.cloud.sdk.core.service.model.GenericModel; -import java.util.List; - -public class Timings extends GenericModel { - private List words; - - public List getWords() { - return words; - } -} diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Translation.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Translation.java index 652c03d5a3c..cd334619bb0 100644 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Translation.java +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Translation.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -92,7 +92,7 @@ public Builder(String translation) { /** * Builds a Translation. * - * @return the translation + * @return the new Translation instance */ public Translation build() { return new Translation(this); diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/UpdateVoiceModelOptions.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/UpdateCustomModelOptions.java similarity index 72% rename from text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/UpdateVoiceModelOptions.java rename to text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/UpdateCustomModelOptions.java index 578aae89ef5..959b9ad90a5 100644 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/UpdateVoiceModelOptions.java +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/UpdateCustomModelOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -16,8 +16,8 @@ import java.util.ArrayList; import java.util.List; -/** The updateVoiceModel options. */ -public class UpdateVoiceModelOptions extends GenericModel { +/** The updateCustomModel options. */ +public class UpdateCustomModelOptions extends GenericModel { protected String customizationId; protected String name; @@ -31,11 +31,11 @@ public static class Builder { private String description; private List words; - private Builder(UpdateVoiceModelOptions updateVoiceModelOptions) { - this.customizationId = updateVoiceModelOptions.customizationId; - this.name = updateVoiceModelOptions.name; - this.description = updateVoiceModelOptions.description; - this.words = updateVoiceModelOptions.words; + private Builder(UpdateCustomModelOptions updateCustomModelOptions) { + this.customizationId = updateCustomModelOptions.customizationId; + this.name = updateCustomModelOptions.name; + this.description = updateCustomModelOptions.description; + this.words = updateCustomModelOptions.words; } /** Instantiates a new builder. */ @@ -51,19 +51,19 @@ public Builder(String customizationId) { } /** - * Builds a UpdateVoiceModelOptions. + * Builds a UpdateCustomModelOptions. * - * @return the updateVoiceModelOptions + * @return the new UpdateCustomModelOptions instance */ - public UpdateVoiceModelOptions build() { - return new UpdateVoiceModelOptions(this); + public UpdateCustomModelOptions build() { + return new UpdateCustomModelOptions(this); } /** * Adds an word to words. * * @param word the new word - * @return the UpdateVoiceModelOptions builder + * @return the UpdateCustomModelOptions builder */ public Builder addWord(Word word) { com.ibm.cloud.sdk.core.util.Validator.notNull(word, "word cannot be null"); @@ -78,7 +78,7 @@ public Builder addWord(Word word) { * Set the customizationId. * * @param customizationId the customizationId - * @return the UpdateVoiceModelOptions builder + * @return the UpdateCustomModelOptions builder */ public Builder customizationId(String customizationId) { this.customizationId = customizationId; @@ -89,7 +89,7 @@ public Builder customizationId(String customizationId) { * Set the name. * * @param name the name - * @return the UpdateVoiceModelOptions builder + * @return the UpdateCustomModelOptions builder */ public Builder name(String name) { this.name = name; @@ -100,7 +100,7 @@ public Builder name(String name) { * Set the description. * * @param description the description - * @return the UpdateVoiceModelOptions builder + * @return the UpdateCustomModelOptions builder */ public Builder description(String description) { this.description = description; @@ -111,7 +111,7 @@ public Builder description(String description) { * Set the words. Existing words will be replaced. * * @param words the words - * @return the UpdateVoiceModelOptions builder + * @return the UpdateCustomModelOptions builder */ public Builder words(List words) { this.words = words; @@ -119,7 +119,7 @@ public Builder words(List words) { } } - protected UpdateVoiceModelOptions(Builder builder) { + protected UpdateCustomModelOptions(Builder builder) { com.ibm.cloud.sdk.core.util.Validator.notEmpty( builder.customizationId, "customizationId cannot be empty"); customizationId = builder.customizationId; @@ -131,7 +131,7 @@ protected UpdateVoiceModelOptions(Builder builder) { /** * New builder. * - * @return a UpdateVoiceModelOptions builder + * @return a UpdateCustomModelOptions builder */ public Builder newBuilder() { return new Builder(this); @@ -140,8 +140,8 @@ public Builder newBuilder() { /** * Gets the customizationId. * - *

The customization ID (GUID) of the custom voice model. You must make the request with - * credentials for the instance of the service that owns the custom model. + *

The customization ID (GUID) of the custom model. You must make the request with credentials + * for the instance of the service that owns the custom model. * * @return the customizationId */ @@ -152,7 +152,7 @@ public String customizationId() { /** * Gets the name. * - *

A new name for the custom voice model. + *

A new name for the custom model. * * @return the name */ @@ -163,7 +163,7 @@ public String name() { /** * Gets the description. * - *

A new description for the custom voice model. + *

A new description for the custom model. * * @return the description */ @@ -175,8 +175,7 @@ public String description() { * Gets the words. * *

An array of `Word` objects that provides the words and their translations that are to be - * added or updated for the custom voice model. Pass an empty array to make no additions or - * updates. + * added or updated for the custom model. Pass an empty array to make no additions or updates. * * @return the words */ diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Voice.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Voice.java index dd5d2186ade..11bf0229f86 100644 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Voice.java +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Voice.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2016, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -15,7 +15,7 @@ import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** Information about an available voice model. */ +/** Information about an available voice. */ public class Voice extends GenericModel { protected String url; @@ -28,7 +28,7 @@ public class Voice extends GenericModel { @SerializedName("supported_features") protected SupportedFeatures supportedFeatures; - protected VoiceModel customization; + protected CustomModel customization; /** * Gets the url. @@ -111,12 +111,12 @@ public SupportedFeatures getSupportedFeatures() { /** * Gets the customization. * - *

Returns information about a specified custom voice model. This field is returned only by the - * **Get a voice** method and only when you specify the customization ID of a custom voice model. + *

Returns information about a specified custom model. This field is returned only by the **Get + * a voice** method and only when you specify the customization ID of a custom model. * * @return the customization */ - public VoiceModel getCustomization() { + public CustomModel getCustomization() { return customization; } } diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Voices.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Voices.java index a7f430d792f..a8cf69f71fb 100644 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Voices.java +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Voices.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -15,7 +15,7 @@ import com.ibm.cloud.sdk.core.service.model.GenericModel; import java.util.List; -/** Information about all available voice models. */ +/** Information about all available voices. */ public class Voices extends GenericModel { protected List voices; diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Word.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Word.java index f7267f6f33a..9b996d3836d 100644 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Word.java +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Word.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -15,7 +15,7 @@ import com.google.gson.annotations.SerializedName; import com.ibm.cloud.sdk.core.service.model.GenericModel; -/** Information about a word for the custom voice model. */ +/** Information about a word for the custom model. */ public class Word extends GenericModel { /** @@ -97,7 +97,7 @@ public Builder(String word, String translation) { /** * Builds a Word. * - * @return the word + * @return the new Word instance */ public Word build() { return new Word(this); @@ -158,7 +158,7 @@ public Builder newBuilder() { /** * Gets the word. * - *

The word for the custom voice model. The maximum length of a word is 49 characters. + *

The word for the custom model. The maximum length of a word is 49 characters. * * @return the word */ diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/WordTiming.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/WordTiming.java deleted file mode 100644 index ff0329d6e25..00000000000 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/WordTiming.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.ibm.watson.text_to_speech.v1.model; - -import com.google.gson.annotations.JsonAdapter; -import com.ibm.cloud.sdk.core.service.model.GenericModel; -import com.ibm.watson.text_to_speech.v1.util.WordTimingTypeAdapter; - -@JsonAdapter(WordTimingTypeAdapter.class) -public class WordTiming extends GenericModel { - private String word; - private Double startTime; - private Double endTime; - - public String getWord() { - return word; - } - - public Double getStartTime() { - return startTime; - } - - public Double getEndTime() { - return endTime; - } - - public void setWord(String word) { - this.word = word; - } - - public void setStartTime(Double startTime) { - this.startTime = startTime; - } - - public void setEndTime(Double endTime) { - this.endTime = endTime; - } -} diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Words.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Words.java index d15220f3000..23e16b859c2 100644 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Words.java +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Words.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -18,10 +18,9 @@ /** * For the **Add custom words** method, one or more words that are to be added or updated for the - * custom voice model and the translation for each specified word. + * custom model and the translation for each specified word. * - *

For the **List custom words** method, the words and their translations from the custom voice - * model. + *

For the **List custom words** method, the words and their translations from the custom model. */ public class Words extends GenericModel { @@ -50,7 +49,7 @@ public Builder(List words) { /** * Builds a Words. * - * @return the words + * @return the new Words instance */ public Words build() { return new Words(this); @@ -101,12 +100,12 @@ public Builder newBuilder() { * Gets the words. * *

The **Add custom words** method accepts an array of `Word` objects. Each object provides a - * word that is to be added or updated for the custom voice model and the word's translation. + * word that is to be added or updated for the custom model and the word's translation. * *

The **List custom words** method returns an array of `Word` objects. Each object shows a - * word and its translation from the custom voice model. The words are listed in alphabetical - * order, with uppercase letters listed before lowercase letters. The array is empty if the custom - * model contains no words. + * word and its translation from the custom model. The words are listed in alphabetical order, + * with uppercase letters listed before lowercase letters. The array is empty if the custom model + * contains no words. * * @return the words */ diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/package-info.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/package-info.java index 341d1963131..d285f88cac2 100644 --- a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/package-info.java +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/package-info.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/TextToSpeechTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/TextToSpeechTest.java index 2f368f88e4b..07be94f693c 100644 --- a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/TextToSpeechTest.java +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/TextToSpeechTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -12,264 +12,867 @@ */ package com.ibm.watson.text_to_speech.v1; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; +import static org.testng.Assert.*; -import com.google.common.io.Files; -import com.google.gson.Gson; -import com.ibm.cloud.sdk.core.http.HttpMediaType; +import com.ibm.cloud.sdk.core.http.Response; +import com.ibm.cloud.sdk.core.security.Authenticator; import com.ibm.cloud.sdk.core.security.NoAuthAuthenticator; -import com.ibm.cloud.sdk.core.util.GsonSingleton; -import com.ibm.watson.common.TestUtils; -import com.ibm.watson.common.WatsonServiceUnitTest; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.model.AddWordOptions; +import com.ibm.watson.text_to_speech.v1.model.AddWordsOptions; +import com.ibm.watson.text_to_speech.v1.model.CreateCustomModelOptions; +import com.ibm.watson.text_to_speech.v1.model.CustomModel; +import com.ibm.watson.text_to_speech.v1.model.CustomModels; +import com.ibm.watson.text_to_speech.v1.model.DeleteCustomModelOptions; import com.ibm.watson.text_to_speech.v1.model.DeleteUserDataOptions; +import com.ibm.watson.text_to_speech.v1.model.DeleteWordOptions; +import com.ibm.watson.text_to_speech.v1.model.GetCustomModelOptions; +import com.ibm.watson.text_to_speech.v1.model.GetPronunciationOptions; import com.ibm.watson.text_to_speech.v1.model.GetVoiceOptions; +import com.ibm.watson.text_to_speech.v1.model.GetWordOptions; +import com.ibm.watson.text_to_speech.v1.model.ListCustomModelsOptions; +import com.ibm.watson.text_to_speech.v1.model.ListVoicesOptions; +import com.ibm.watson.text_to_speech.v1.model.ListWordsOptions; +import com.ibm.watson.text_to_speech.v1.model.Pronunciation; import com.ibm.watson.text_to_speech.v1.model.SynthesizeOptions; +import com.ibm.watson.text_to_speech.v1.model.Translation; +import com.ibm.watson.text_to_speech.v1.model.UpdateCustomModelOptions; import com.ibm.watson.text_to_speech.v1.model.Voice; import com.ibm.watson.text_to_speech.v1.model.Voices; -import com.ibm.watson.text_to_speech.v1.util.WaveUtils; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; +import com.ibm.watson.text_to_speech.v1.model.Word; +import com.ibm.watson.text_to_speech.v1.model.Words; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; import java.io.IOException; import java.io.InputStream; -import java.io.OutputStream; -import javax.sound.sampled.AudioSystem; -import javax.sound.sampled.UnsupportedAudioFileException; -import okhttp3.HttpUrl; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; import okhttp3.mockwebserver.RecordedRequest; -import okio.Buffer; -import org.junit.Assert; -import org.junit.Before; -import org.junit.FixMethodOrder; -import org.junit.Test; -import org.junit.runners.MethodSorters; - -/** The Class TextToSpeechTest. */ -@FixMethodOrder(MethodSorters.JVM) -public class TextToSpeechTest extends WatsonServiceUnitTest { - - private static final Gson GSON = GsonSingleton.getGsonWithoutPrettyPrinting(); - private static final String GET_VOICES_PATH = "/v1/voices"; - private static final String SYNTHESIZE_PATH = "/v1/synthesize"; - - private Voice getVoiceResponse; - private Voices listVoicesResponse; - - /** - * Write input stream to output stream. - * - * @param inputStream the input stream - * @param outputStream the output stream - */ - private static void writeInputStreamToOutputStream( - InputStream inputStream, OutputStream outputStream) { - try { - try { - final byte[] buffer = new byte[1024]; - int read; - - while ((read = inputStream.read(buffer)) != -1) { - outputStream.write(buffer, 0, read); - } - - outputStream.flush(); - } catch (final Exception e) { - e.printStackTrace(); - } finally { - outputStream.close(); - inputStream.close(); - } - } catch (final Exception e) { - e.printStackTrace(); - } +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +/** Unit test class for the TextToSpeech service. */ +public class TextToSpeechTest { + + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + protected MockWebServer server; + protected TextToSpeech textToSpeechService; + + public void constructClientService() throws Throwable { + final String serviceName = "testService"; + + final Authenticator authenticator = new NoAuthAuthenticator(); + + textToSpeechService = new TextToSpeech(serviceName, authenticator); + String url = server.url("/").toString(); + textToSpeechService.setServiceUrl(url); + } + + /** Negative Test - construct the service with a null authenticator. */ + @Test(expectedExceptions = IllegalArgumentException.class) + public void testConstructorWithNullAuthenticator() throws Throwable { + final String serviceName = "testService"; + + new TextToSpeech(serviceName, null); } - /** The service. */ - private TextToSpeech service; - - /** The text. */ - private final String text = "IBM Watson Developer Cloud"; - - /** - * Sets up the tests. - * - * @throws Exception the exception - */ - /* - * (non-Javadoc) - * @see com.ibm.watson.common.WatsonServiceTest#setUp() - */ - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - - service = new TextToSpeech(new NoAuthAuthenticator()); - service.setServiceUrl(getMockWebServerUrl()); - - getVoiceResponse = - loadFixture("src/test/resources/text_to_speech/get_voice_response.json", Voice.class); - listVoicesResponse = - loadFixture("src/test/resources/text_to_speech/list_voices_response.json", Voices.class); - } - - /** - * Test list voices. - * - * @throws InterruptedException the interrupted exception - */ @Test - public void testListVoices() throws InterruptedException { + public void testListVoicesWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"voices\": [{\"url\": \"url\", \"gender\": \"gender\", \"name\": \"name\", \"language\": \"language\", \"description\": \"description\", \"customizable\": true, \"supported_features\": {\"custom_pronunciation\": false, \"voice_transformation\": false}, \"customization\": {\"customization_id\": \"customizationId\", \"name\": \"name\", \"language\": \"language\", \"owner\": \"owner\", \"created\": \"created\", \"last_modified\": \"lastModified\", \"description\": \"description\", \"words\": [{\"word\": \"word\", \"translation\": \"translation\", \"part_of_speech\": \"Dosi\"}]}}]}"; + String listVoicesPath = "/v1/voices"; + server.enqueue( new MockResponse() - .addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON) - .setBody(GSON.toJson(listVoicesResponse))); + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the ListVoicesOptions model + ListVoicesOptions listVoicesOptionsModel = new ListVoicesOptions(); - final Voices result = service.listVoices().execute().getResult(); - final RecordedRequest request = server.takeRequest(); + // Invoke operation with valid options model (positive test) + Response response = textToSpeechService.listVoices(listVoicesOptionsModel).execute(); + assertNotNull(response); + Voices responseObj = response.getResult(); + assertNotNull(responseObj); - assertEquals(GET_VOICES_PATH, request.getPath()); - assertNotNull(result); - assertFalse(result.getVoices().isEmpty()); - assertEquals(listVoicesResponse.getVoices(), result.getVoices()); + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listVoicesPath); } - /** Test get voice. */ @Test - public void testGetVoice() { + public void testGetVoiceWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"url\": \"url\", \"gender\": \"gender\", \"name\": \"name\", \"language\": \"language\", \"description\": \"description\", \"customizable\": true, \"supported_features\": {\"custom_pronunciation\": false, \"voice_transformation\": false}, \"customization\": {\"customization_id\": \"customizationId\", \"name\": \"name\", \"language\": \"language\", \"owner\": \"owner\", \"created\": \"created\", \"last_modified\": \"lastModified\", \"description\": \"description\", \"words\": [{\"word\": \"word\", \"translation\": \"translation\", \"part_of_speech\": \"Dosi\"}]}}"; + String getVoicePath = "/v1/voices/ar-AR_OmarVoice"; + server.enqueue( new MockResponse() - .addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON) - .setBody(GSON.toJson(getVoiceResponse))); + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); - GetVoiceOptions getOptions = new GetVoiceOptions.Builder().voice("en-US_TestMaleVoice").build(); - Voice result = service.getVoice(getOptions).execute().getResult(); - assertNotNull(result); - assertEquals(result, getVoiceResponse); + constructClientService(); - try { - TestUtils.assertNoExceptionsOnGetters(result); - } catch (final Exception e) { - Assert.fail(e.getMessage()); - } + // Construct an instance of the GetVoiceOptions model + GetVoiceOptions getVoiceOptionsModel = + new GetVoiceOptions.Builder() + .voice("ar-AR_OmarVoice") + .customizationId("testString") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = textToSpeechService.getVoice(getVoiceOptionsModel).execute(); + assertNotNull(response); + Voice responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("customization_id"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getVoicePath); + } + + // Test the getVoice operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetVoiceNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + textToSpeechService.getVoice(null).execute(); } - /** - * Test synthesize. - * - * @throws IOException Signals that an I/O exception has occurred. - * @throws InterruptedException the interrupted exception - */ - @SuppressWarnings("resource") @Test - public void testSynthesize() throws IOException, InterruptedException { - final File audio = new File("src/test/resources/text_to_speech/sample1.wav"); - final Buffer buffer = new Buffer().write(Files.toByteArray(audio)); + public void testSynthesizeWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = "This is a mock binary response."; + String synthesizePath = "/v1/synthesize"; server.enqueue( - new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.AUDIO_WAV).setBody(buffer)); + new MockResponse() + .setHeader("Content-type", "audio/basic") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); - SynthesizeOptions synthesizeOptions = + // Construct an instance of the SynthesizeOptions model + SynthesizeOptions synthesizeOptionsModel = new SynthesizeOptions.Builder() - .text(text) - .voice(SynthesizeOptions.Voice.EN_US_LISAVOICE) - .accept(HttpMediaType.AUDIO_PCM + "; rate=16000") + .text("testString") + .accept("audio/basic") + .voice("ar-AR_OmarVoice") + .customizationId("testString") .build(); - final InputStream in = service.synthesize(synthesizeOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - final HttpUrl requestUrl = HttpUrl.parse("http://www.example.com" + request.getPath()); - - assertEquals(request.getBody().readUtf8(), "{\"text\":\"" + text + "\"}"); - assertEquals(SYNTHESIZE_PATH, requestUrl.encodedPath()); - assertEquals(SynthesizeOptions.Voice.EN_US_LISAVOICE, requestUrl.queryParameter("voice")); - assertEquals(HttpMediaType.AUDIO_PCM + "; rate=16000", request.getHeader("Accept")); - assertNotNull(in); - - writeInputStreamToOutputStream(in, new FileOutputStream("build/output.wav")); - } - - /** - * Test synthesize for WebM. - * - * @throws IOException Signals that an I/O exception has occurred. - * @throws InterruptedException the interrupted exception - */ - @SuppressWarnings("resource") + + // Invoke operation with valid options model (positive test) + Response response = + textToSpeechService.synthesize(synthesizeOptionsModel).execute(); + assertNotNull(response); + InputStream responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("voice"), "ar-AR_OmarVoice"); + assertEquals(query.get("customization_id"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, synthesizePath); + } + + // Test the synthesize operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testSynthesizeNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + textToSpeechService.synthesize(null).execute(); + } + @Test - public void testSynthesizeWebM() throws IOException, InterruptedException { - final File audio = new File("src/test/resources/text_to_speech/sample1.webm"); - final Buffer buffer = new Buffer().write(Files.toByteArray(audio)); + public void testGetPronunciationWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = "{\"pronunciation\": \"pronunciation\"}"; + String getPronunciationPath = "/v1/pronunciation"; server.enqueue( - new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.AUDIO_WEBM).setBody(buffer)); + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the GetPronunciationOptions model + GetPronunciationOptions getPronunciationOptionsModel = + new GetPronunciationOptions.Builder() + .text("testString") + .voice("ar-AR_OmarVoice") + .format("ibm") + .customizationId("testString") + .build(); - SynthesizeOptions synthesizeOptions = - new SynthesizeOptions.Builder() - .text(text) - .voice(SynthesizeOptions.Voice.EN_US_LISAVOICE) - .accept(HttpMediaType.AUDIO_WEBM) + // Invoke operation with valid options model (positive test) + Response response = + textToSpeechService.getPronunciation(getPronunciationOptionsModel).execute(); + assertNotNull(response); + Pronunciation responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("text"), "testString"); + assertEquals(query.get("voice"), "ar-AR_OmarVoice"); + assertEquals(query.get("format"), "ibm"); + assertEquals(query.get("customization_id"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getPronunciationPath); + } + + // Test the getPronunciation operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetPronunciationNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + textToSpeechService.getPronunciation(null).execute(); + } + + @Test + public void testCreateCustomModelWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"customization_id\": \"customizationId\", \"name\": \"name\", \"language\": \"language\", \"owner\": \"owner\", \"created\": \"created\", \"last_modified\": \"lastModified\", \"description\": \"description\", \"words\": [{\"word\": \"word\", \"translation\": \"translation\", \"part_of_speech\": \"Dosi\"}]}"; + String createCustomModelPath = "/v1/customizations"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(201) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the CreateCustomModelOptions model + CreateCustomModelOptions createCustomModelOptionsModel = + new CreateCustomModelOptions.Builder() + .name("testString") + .language("ar-AR") + .description("testString") .build(); - final InputStream in = service.synthesize(synthesizeOptions).execute().getResult(); - final RecordedRequest request = server.takeRequest(); - final HttpUrl requestUrl = HttpUrl.parse("http://www.example.com" + request.getPath()); - assertEquals(request.getBody().readUtf8(), "{\"text\":\"" + text + "\"}"); - assertEquals(SYNTHESIZE_PATH, requestUrl.encodedPath()); - assertEquals(SynthesizeOptions.Voice.EN_US_LISAVOICE, requestUrl.queryParameter("voice")); - assertEquals(HttpMediaType.AUDIO_WEBM, request.getHeader("Accept")); - assertNotNull(in); + // Invoke operation with valid options model (positive test) + Response response = + textToSpeechService.createCustomModel(createCustomModelOptionsModel).execute(); + assertNotNull(response); + CustomModel responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createCustomModelPath); + } + + // Test the createCustomModel operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateCustomModelNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); - writeInputStreamToOutputStream(in, new FileOutputStream("build/output.webm")); + // Invoke operation with null options model (negative test) + textToSpeechService.createCustomModel(null).execute(); } - /** Test with voice as AudioFormat.WAV. */ - // @Test - public void testWithVoiceAsWav() { - SynthesizeOptions synthesizeOptions = - new SynthesizeOptions.Builder() - .text(text) - .voice(SynthesizeOptions.Voice.EN_US_LISAVOICE) - .accept(HttpMediaType.AUDIO_WAV) + @Test + public void testListCustomModelsWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"customizations\": [{\"customization_id\": \"customizationId\", \"name\": \"name\", \"language\": \"language\", \"owner\": \"owner\", \"created\": \"created\", \"last_modified\": \"lastModified\", \"description\": \"description\", \"words\": [{\"word\": \"word\", \"translation\": \"translation\", \"part_of_speech\": \"Dosi\"}]}]}"; + String listCustomModelsPath = "/v1/customizations"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the ListCustomModelsOptions model + ListCustomModelsOptions listCustomModelsOptionsModel = + new ListCustomModelsOptions.Builder().language("ar-AR").build(); + + // Invoke operation with valid options model (positive test) + Response response = + textToSpeechService.listCustomModels(listCustomModelsOptionsModel).execute(); + assertNotNull(response); + CustomModels responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("language"), "ar-AR"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listCustomModelsPath); + } + + @Test + public void testUpdateCustomModelWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String updateCustomModelPath = "/v1/customizations/testString"; + + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the Word model + Word wordModel = + new Word.Builder() + .word("testString") + .translation("testString") + .partOfSpeech("Dosi") .build(); - final InputStream is = service.synthesize(synthesizeOptions).execute().getResult(); - assertNotNull(is); - try { - writeInputStreamToOutputStream(is, new FileOutputStream("target/output.wav")); - } catch (final FileNotFoundException e) { - Assert.fail(e.getMessage()); - } + // Construct an instance of the UpdateCustomModelOptions model + UpdateCustomModelOptions updateCustomModelOptionsModel = + new UpdateCustomModelOptions.Builder() + .customizationId("testString") + .name("testString") + .description("testString") + .words(new java.util.ArrayList(java.util.Arrays.asList(wordModel))) + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + textToSpeechService.updateCustomModel(updateCustomModelOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateCustomModelPath); + } + + // Test the updateCustomModel operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateCustomModelNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + textToSpeechService.updateCustomModel(null).execute(); } - /** - * Test the fix wave header not having the size due to be streamed. - * - * @throws IOException Signals that an I/O exception has occurred. - * @throws UnsupportedAudioFileException the unsupported audio file exception - */ @Test - public void testSynthesizeAndFixHeader() throws IOException, UnsupportedAudioFileException { - File audio = new File("src/test/resources/text_to_speech/numbers.wav"); - InputStream stream = new FileInputStream(audio); - assertNotNull(stream); - stream = WaveUtils.reWriteWaveHeader(stream); - File tempFile = File.createTempFile("output", ".wav"); - writeInputStreamToFile(stream, tempFile); - assertNotNull(AudioSystem.getAudioFileFormat(tempFile)); + public void testGetCustomModelWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"customization_id\": \"customizationId\", \"name\": \"name\", \"language\": \"language\", \"owner\": \"owner\", \"created\": \"created\", \"last_modified\": \"lastModified\", \"description\": \"description\", \"words\": [{\"word\": \"word\", \"translation\": \"translation\", \"part_of_speech\": \"Dosi\"}]}"; + String getCustomModelPath = "/v1/customizations/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the GetCustomModelOptions model + GetCustomModelOptions getCustomModelOptionsModel = + new GetCustomModelOptions.Builder().customizationId("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = + textToSpeechService.getCustomModel(getCustomModelOptionsModel).execute(); + assertNotNull(response); + CustomModel responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getCustomModelPath); + } + + // Test the getCustomModel operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetCustomModelNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + textToSpeechService.getCustomModel(null).execute(); + } + + @Test + public void testDeleteCustomModelWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String deleteCustomModelPath = "/v1/customizations/testString"; + + server.enqueue(new MockResponse().setResponseCode(204).setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the DeleteCustomModelOptions model + DeleteCustomModelOptions deleteCustomModelOptionsModel = + new DeleteCustomModelOptions.Builder().customizationId("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = + textToSpeechService.deleteCustomModel(deleteCustomModelOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteCustomModelPath); + } + + // Test the deleteCustomModel operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteCustomModelNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + textToSpeechService.deleteCustomModel(null).execute(); + } + + @Test + public void testAddWordsWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String addWordsPath = "/v1/customizations/testString/words"; + + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the Word model + Word wordModel = + new Word.Builder() + .word("testString") + .translation("testString") + .partOfSpeech("Dosi") + .build(); + + // Construct an instance of the AddWordsOptions model + AddWordsOptions addWordsOptionsModel = + new AddWordsOptions.Builder() + .customizationId("testString") + .words(new java.util.ArrayList(java.util.Arrays.asList(wordModel))) + .build(); + + // Invoke operation with valid options model (positive test) + Response response = textToSpeechService.addWords(addWordsOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, addWordsPath); + } + + // Test the addWords operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAddWordsNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + textToSpeechService.addWords(null).execute(); + } + + @Test + public void testListWordsWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"words\": [{\"word\": \"word\", \"translation\": \"translation\", \"part_of_speech\": \"Dosi\"}]}"; + String listWordsPath = "/v1/customizations/testString/words"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the ListWordsOptions model + ListWordsOptions listWordsOptionsModel = + new ListWordsOptions.Builder().customizationId("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = textToSpeechService.listWords(listWordsOptionsModel).execute(); + assertNotNull(response); + Words responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listWordsPath); + } + + // Test the listWords operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListWordsNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + textToSpeechService.listWords(null).execute(); + } + + @Test + public void testAddWordWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String addWordPath = "/v1/customizations/testString/words/testString"; + + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the AddWordOptions model + AddWordOptions addWordOptionsModel = + new AddWordOptions.Builder() + .customizationId("testString") + .word("testString") + .translation("testString") + .partOfSpeech("Dosi") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = textToSpeechService.addWord(addWordOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "PUT"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, addWordPath); + } + + // Test the addWord operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAddWordNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + textToSpeechService.addWord(null).execute(); } - /** Test delete user data options builder. */ @Test - public void testDeleteUserDataOptionsBuilder() { - String customerId = "java_sdk_test_id"; + public void testGetWordWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = "{\"translation\": \"translation\", \"part_of_speech\": \"Dosi\"}"; + String getWordPath = "/v1/customizations/testString/words/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the GetWordOptions model + GetWordOptions getWordOptionsModel = + new GetWordOptions.Builder().customizationId("testString").word("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = textToSpeechService.getWord(getWordOptionsModel).execute(); + assertNotNull(response); + Translation responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getWordPath); + } + + // Test the getWord operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetWordNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + textToSpeechService.getWord(null).execute(); + } - DeleteUserDataOptions deleteOptions = - new DeleteUserDataOptions.Builder().customerId(customerId).build(); + @Test + public void testDeleteWordWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String deleteWordPath = "/v1/customizations/testString/words/testString"; + + server.enqueue(new MockResponse().setResponseCode(204).setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the DeleteWordOptions model + DeleteWordOptions deleteWordOptionsModel = + new DeleteWordOptions.Builder().customizationId("testString").word("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = textToSpeechService.deleteWord(deleteWordOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNull(query); + + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteWordPath); + } + + // Test the deleteWord operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteWordNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + textToSpeechService.deleteWord(null).execute(); + } + + @Test + public void testDeleteUserDataWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String deleteUserDataPath = "/v1/user_data"; + + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the DeleteUserDataOptions model + DeleteUserDataOptions deleteUserDataOptionsModel = + new DeleteUserDataOptions.Builder().customerId("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = + textToSpeechService.deleteUserData(deleteUserDataOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("customer_id"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteUserDataPath); + } + + // Test the deleteUserData operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteUserDataNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + textToSpeechService.deleteUserData(null).execute(); + } + + /** Initialize the server */ + @BeforeMethod + public void setUpMockServer() { + try { + server = new MockWebServer(); + // register handler + server.start(); + } catch (IOException err) { + fail("Failed to instantiate mock web server"); + } + } - assertEquals(deleteOptions.customerId(), customerId); + @AfterMethod + public void tearDownMockServer() throws IOException { + server.shutdown(); + textToSpeechService = null; } } diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/AddWordOptionsTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/AddWordOptionsTest.java new file mode 100644 index 00000000000..01d5f2e87e7 --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/AddWordOptionsTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the AddWordOptions model. */ +public class AddWordOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAddWordOptions() throws Throwable { + AddWordOptions addWordOptionsModel = + new AddWordOptions.Builder() + .customizationId("testString") + .word("testString") + .translation("testString") + .partOfSpeech("Dosi") + .build(); + assertEquals(addWordOptionsModel.customizationId(), "testString"); + assertEquals(addWordOptionsModel.word(), "testString"); + assertEquals(addWordOptionsModel.translation(), "testString"); + assertEquals(addWordOptionsModel.partOfSpeech(), "Dosi"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAddWordOptionsError() throws Throwable { + new AddWordOptions.Builder().build(); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/AddWordsOptionsTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/AddWordsOptionsTest.java new file mode 100644 index 00000000000..13160059d85 --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/AddWordsOptionsTest.java @@ -0,0 +1,58 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the AddWordsOptions model. */ +public class AddWordsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAddWordsOptions() throws Throwable { + Word wordModel = + new Word.Builder() + .word("testString") + .translation("testString") + .partOfSpeech("Dosi") + .build(); + assertEquals(wordModel.word(), "testString"); + assertEquals(wordModel.translation(), "testString"); + assertEquals(wordModel.partOfSpeech(), "Dosi"); + + AddWordsOptions addWordsOptionsModel = + new AddWordsOptions.Builder() + .customizationId("testString") + .words(new java.util.ArrayList(java.util.Arrays.asList(wordModel))) + .build(); + assertEquals(addWordsOptionsModel.customizationId(), "testString"); + assertEquals( + addWordsOptionsModel.words(), + new java.util.ArrayList(java.util.Arrays.asList(wordModel))); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAddWordsOptionsError() throws Throwable { + new AddWordsOptions.Builder().build(); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/CreateCustomModelOptionsTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/CreateCustomModelOptionsTest.java new file mode 100644 index 00000000000..2dde8269943 --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/CreateCustomModelOptionsTest.java @@ -0,0 +1,48 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateCustomModelOptions model. */ +public class CreateCustomModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateCustomModelOptions() throws Throwable { + CreateCustomModelOptions createCustomModelOptionsModel = + new CreateCustomModelOptions.Builder() + .name("testString") + .language("ar-AR") + .description("testString") + .build(); + assertEquals(createCustomModelOptionsModel.name(), "testString"); + assertEquals(createCustomModelOptionsModel.language(), "ar-AR"); + assertEquals(createCustomModelOptionsModel.description(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateCustomModelOptionsError() throws Throwable { + new CreateCustomModelOptions.Builder().build(); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/CustomModelTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/CustomModelTest.java new file mode 100644 index 00000000000..a6cf3980265 --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/CustomModelTest.java @@ -0,0 +1,43 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CustomModel model. */ +public class CustomModelTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCustomModel() throws Throwable { + CustomModel customModelModel = new CustomModel(); + assertNull(customModelModel.getCustomizationId()); + assertNull(customModelModel.getName()); + assertNull(customModelModel.getLanguage()); + assertNull(customModelModel.getOwner()); + assertNull(customModelModel.getCreated()); + assertNull(customModelModel.getLastModified()); + assertNull(customModelModel.getDescription()); + assertNull(customModelModel.getWords()); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/CustomModelsTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/CustomModelsTest.java new file mode 100644 index 00000000000..ebab4cb8c35 --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/CustomModelsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CustomModels model. */ +public class CustomModelsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCustomModels() throws Throwable { + CustomModels customModelsModel = new CustomModels(); + assertNull(customModelsModel.getCustomizations()); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/DeleteCustomModelOptionsTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/DeleteCustomModelOptionsTest.java new file mode 100644 index 00000000000..8221daf6f1b --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/DeleteCustomModelOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteCustomModelOptions model. */ +public class DeleteCustomModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteCustomModelOptions() throws Throwable { + DeleteCustomModelOptions deleteCustomModelOptionsModel = + new DeleteCustomModelOptions.Builder().customizationId("testString").build(); + assertEquals(deleteCustomModelOptionsModel.customizationId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteCustomModelOptionsError() throws Throwable { + new DeleteCustomModelOptions.Builder().build(); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/DeleteUserDataOptionsTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/DeleteUserDataOptionsTest.java new file mode 100644 index 00000000000..68120530071 --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/DeleteUserDataOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteUserDataOptions model. */ +public class DeleteUserDataOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteUserDataOptions() throws Throwable { + DeleteUserDataOptions deleteUserDataOptionsModel = + new DeleteUserDataOptions.Builder().customerId("testString").build(); + assertEquals(deleteUserDataOptionsModel.customerId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteUserDataOptionsError() throws Throwable { + new DeleteUserDataOptions.Builder().build(); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/DeleteWordOptionsTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/DeleteWordOptionsTest.java new file mode 100644 index 00000000000..caf757eb8a9 --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/DeleteWordOptionsTest.java @@ -0,0 +1,43 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteWordOptions model. */ +public class DeleteWordOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteWordOptions() throws Throwable { + DeleteWordOptions deleteWordOptionsModel = + new DeleteWordOptions.Builder().customizationId("testString").word("testString").build(); + assertEquals(deleteWordOptionsModel.customizationId(), "testString"); + assertEquals(deleteWordOptionsModel.word(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteWordOptionsError() throws Throwable { + new DeleteWordOptions.Builder().build(); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/GetCustomModelOptionsTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/GetCustomModelOptionsTest.java new file mode 100644 index 00000000000..4897230e53d --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/GetCustomModelOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetCustomModelOptions model. */ +public class GetCustomModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetCustomModelOptions() throws Throwable { + GetCustomModelOptions getCustomModelOptionsModel = + new GetCustomModelOptions.Builder().customizationId("testString").build(); + assertEquals(getCustomModelOptionsModel.customizationId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetCustomModelOptionsError() throws Throwable { + new GetCustomModelOptions.Builder().build(); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/GetPronunciationOptionsTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/GetPronunciationOptionsTest.java new file mode 100644 index 00000000000..d4908a90f6d --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/GetPronunciationOptionsTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetPronunciationOptions model. */ +public class GetPronunciationOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetPronunciationOptions() throws Throwable { + GetPronunciationOptions getPronunciationOptionsModel = + new GetPronunciationOptions.Builder() + .text("testString") + .voice("ar-AR_OmarVoice") + .format("ibm") + .customizationId("testString") + .build(); + assertEquals(getPronunciationOptionsModel.text(), "testString"); + assertEquals(getPronunciationOptionsModel.voice(), "ar-AR_OmarVoice"); + assertEquals(getPronunciationOptionsModel.format(), "ibm"); + assertEquals(getPronunciationOptionsModel.customizationId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetPronunciationOptionsError() throws Throwable { + new GetPronunciationOptions.Builder().build(); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/GetVoiceOptionsTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/GetVoiceOptionsTest.java new file mode 100644 index 00000000000..6ddb0d150c8 --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/GetVoiceOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetVoiceOptions model. */ +public class GetVoiceOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetVoiceOptions() throws Throwable { + GetVoiceOptions getVoiceOptionsModel = + new GetVoiceOptions.Builder() + .voice("ar-AR_OmarVoice") + .customizationId("testString") + .build(); + assertEquals(getVoiceOptionsModel.voice(), "ar-AR_OmarVoice"); + assertEquals(getVoiceOptionsModel.customizationId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetVoiceOptionsError() throws Throwable { + new GetVoiceOptions.Builder().build(); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/GetWordOptionsTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/GetWordOptionsTest.java new file mode 100644 index 00000000000..bb9c7f06276 --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/GetWordOptionsTest.java @@ -0,0 +1,43 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetWordOptions model. */ +public class GetWordOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetWordOptions() throws Throwable { + GetWordOptions getWordOptionsModel = + new GetWordOptions.Builder().customizationId("testString").word("testString").build(); + assertEquals(getWordOptionsModel.customizationId(), "testString"); + assertEquals(getWordOptionsModel.word(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetWordOptionsError() throws Throwable { + new GetWordOptions.Builder().build(); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/ListCustomModelsOptionsTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/ListCustomModelsOptionsTest.java new file mode 100644 index 00000000000..86cb4c74df6 --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/ListCustomModelsOptionsTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListCustomModelsOptions model. */ +public class ListCustomModelsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListCustomModelsOptions() throws Throwable { + ListCustomModelsOptions listCustomModelsOptionsModel = + new ListCustomModelsOptions.Builder().language("ar-AR").build(); + assertEquals(listCustomModelsOptionsModel.language(), "ar-AR"); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/ListVoicesOptionsTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/ListVoicesOptionsTest.java new file mode 100644 index 00000000000..d0fbb5d9d30 --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/ListVoicesOptionsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListVoicesOptions model. */ +public class ListVoicesOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListVoicesOptions() throws Throwable { + ListVoicesOptions listVoicesOptionsModel = new ListVoicesOptions(); + assertNotNull(listVoicesOptionsModel); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/ListWordsOptionsTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/ListWordsOptionsTest.java new file mode 100644 index 00000000000..968173ff392 --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/ListWordsOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListWordsOptions model. */ +public class ListWordsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListWordsOptions() throws Throwable { + ListWordsOptions listWordsOptionsModel = + new ListWordsOptions.Builder().customizationId("testString").build(); + assertEquals(listWordsOptionsModel.customizationId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListWordsOptionsError() throws Throwable { + new ListWordsOptions.Builder().build(); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/PronunciationTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/PronunciationTest.java new file mode 100644 index 00000000000..e514d0f5ac0 --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/PronunciationTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Pronunciation model. */ +public class PronunciationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testPronunciation() throws Throwable { + Pronunciation pronunciationModel = new Pronunciation(); + assertNull(pronunciationModel.getPronunciation()); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/SupportedFeaturesTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/SupportedFeaturesTest.java new file mode 100644 index 00000000000..8b52449d6b8 --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/SupportedFeaturesTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SupportedFeatures model. */ +public class SupportedFeaturesTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSupportedFeatures() throws Throwable { + SupportedFeatures supportedFeaturesModel = new SupportedFeatures(); + assertNull(supportedFeaturesModel.isCustomPronunciation()); + assertNull(supportedFeaturesModel.isVoiceTransformation()); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/SynthesizeOptionsTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/SynthesizeOptionsTest.java new file mode 100644 index 00000000000..ce3aa1ef0cb --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/SynthesizeOptionsTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SynthesizeOptions model. */ +public class SynthesizeOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSynthesizeOptions() throws Throwable { + SynthesizeOptions synthesizeOptionsModel = + new SynthesizeOptions.Builder() + .text("testString") + .accept("audio/basic") + .voice("ar-AR_OmarVoice") + .customizationId("testString") + .build(); + assertEquals(synthesizeOptionsModel.text(), "testString"); + assertEquals(synthesizeOptionsModel.accept(), "audio/basic"); + assertEquals(synthesizeOptionsModel.voice(), "ar-AR_OmarVoice"); + assertEquals(synthesizeOptionsModel.customizationId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testSynthesizeOptionsError() throws Throwable { + new SynthesizeOptions.Builder().build(); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/TranslationTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/TranslationTest.java new file mode 100644 index 00000000000..daa2712b124 --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/TranslationTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Translation model. */ +public class TranslationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTranslation() throws Throwable { + Translation translationModel = + new Translation.Builder().translation("testString").partOfSpeech("Dosi").build(); + assertEquals(translationModel.translation(), "testString"); + assertEquals(translationModel.partOfSpeech(), "Dosi"); + + String json = TestUtilities.serialize(translationModel); + + Translation translationModelNew = TestUtilities.deserialize(json, Translation.class); + assertTrue(translationModelNew instanceof Translation); + assertEquals(translationModelNew.translation(), "testString"); + assertEquals(translationModelNew.partOfSpeech(), "Dosi"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testTranslationError() throws Throwable { + new Translation.Builder().build(); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/UpdateCustomModelOptionsTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/UpdateCustomModelOptionsTest.java new file mode 100644 index 00000000000..21ff6cb4635 --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/UpdateCustomModelOptionsTest.java @@ -0,0 +1,62 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the UpdateCustomModelOptions model. */ +public class UpdateCustomModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateCustomModelOptions() throws Throwable { + Word wordModel = + new Word.Builder() + .word("testString") + .translation("testString") + .partOfSpeech("Dosi") + .build(); + assertEquals(wordModel.word(), "testString"); + assertEquals(wordModel.translation(), "testString"); + assertEquals(wordModel.partOfSpeech(), "Dosi"); + + UpdateCustomModelOptions updateCustomModelOptionsModel = + new UpdateCustomModelOptions.Builder() + .customizationId("testString") + .name("testString") + .description("testString") + .words(new java.util.ArrayList(java.util.Arrays.asList(wordModel))) + .build(); + assertEquals(updateCustomModelOptionsModel.customizationId(), "testString"); + assertEquals(updateCustomModelOptionsModel.name(), "testString"); + assertEquals(updateCustomModelOptionsModel.description(), "testString"); + assertEquals( + updateCustomModelOptionsModel.words(), + new java.util.ArrayList(java.util.Arrays.asList(wordModel))); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateCustomModelOptionsError() throws Throwable { + new UpdateCustomModelOptions.Builder().build(); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/VoiceTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/VoiceTest.java new file mode 100644 index 00000000000..cfb8f59b5cf --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/VoiceTest.java @@ -0,0 +1,43 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Voice model. */ +public class VoiceTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testVoice() throws Throwable { + Voice voiceModel = new Voice(); + assertNull(voiceModel.getUrl()); + assertNull(voiceModel.getGender()); + assertNull(voiceModel.getName()); + assertNull(voiceModel.getLanguage()); + assertNull(voiceModel.getDescription()); + assertNull(voiceModel.isCustomizable()); + assertNull(voiceModel.getSupportedFeatures()); + assertNull(voiceModel.getCustomization()); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/VoicesTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/VoicesTest.java new file mode 100644 index 00000000000..57645bb3d3f --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/VoicesTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Voices model. */ +public class VoicesTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testVoices() throws Throwable { + Voices voicesModel = new Voices(); + assertNull(voicesModel.getVoices()); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/WordTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/WordTest.java new file mode 100644 index 00000000000..98fc7bba43c --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/WordTest.java @@ -0,0 +1,56 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Word model. */ +public class WordTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testWord() throws Throwable { + Word wordModel = + new Word.Builder() + .word("testString") + .translation("testString") + .partOfSpeech("Dosi") + .build(); + assertEquals(wordModel.word(), "testString"); + assertEquals(wordModel.translation(), "testString"); + assertEquals(wordModel.partOfSpeech(), "Dosi"); + + String json = TestUtilities.serialize(wordModel); + + Word wordModelNew = TestUtilities.deserialize(json, Word.class); + assertTrue(wordModelNew instanceof Word); + assertEquals(wordModelNew.word(), "testString"); + assertEquals(wordModelNew.translation(), "testString"); + assertEquals(wordModelNew.partOfSpeech(), "Dosi"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testWordError() throws Throwable { + new Word.Builder().build(); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/WordsTest.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/WordsTest.java new file mode 100644 index 00000000000..d599e7ba1fd --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/model/WordsTest.java @@ -0,0 +1,60 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.text_to_speech.v1.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.text_to_speech.v1.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Words model. */ +public class WordsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testWords() throws Throwable { + Word wordModel = + new Word.Builder() + .word("testString") + .translation("testString") + .partOfSpeech("Dosi") + .build(); + assertEquals(wordModel.word(), "testString"); + assertEquals(wordModel.translation(), "testString"); + assertEquals(wordModel.partOfSpeech(), "Dosi"); + + Words wordsModel = + new Words.Builder() + .words(new java.util.ArrayList(java.util.Arrays.asList(wordModel))) + .build(); + assertEquals( + wordsModel.words(), new java.util.ArrayList(java.util.Arrays.asList(wordModel))); + + String json = TestUtilities.serialize(wordsModel); + + Words wordsModelNew = TestUtilities.deserialize(json, Words.class); + assertTrue(wordsModelNew instanceof Words); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testWordsError() throws Throwable { + new Words.Builder().build(); + } +} diff --git a/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/utils/TestUtilities.java b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/utils/TestUtilities.java new file mode 100644 index 00000000000..af82875e077 --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/utils/TestUtilities.java @@ -0,0 +1,128 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.text_to_speech.v1.utils; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.cloud.sdk.core.util.GsonSingleton; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import okhttp3.HttpUrl; +import okhttp3.mockwebserver.RecordedRequest; + +/** A class used by the unit tests containing utility functions. */ +public class TestUtilities { + public static Map createMockMap() { + Map mockMap = new HashMap<>(); + mockMap.put("foo", "bar"); + return mockMap; + } + + public static HashMap createMockStreamMap() { + return new HashMap() { + { + put("key1", createMockStream("This is a mock file.")); + } + }; + } + + public static Map parseQueryString(RecordedRequest req) { + Map queryMap = new HashMap<>(); + + try { + HttpUrl requestUrl = req.getRequestUrl(); + + if (requestUrl != null) { + Set queryParamsNames = requestUrl.queryParameterNames(); + // map the parameter name to its corresponding value + for (String p : queryParamsNames) { + // get the corresponding value for the parameter (p) + List val = requestUrl.queryParameterValues(p); + if (val != null && !val.isEmpty()) { + String joinedQuery = String.join(",", val); + queryMap.put(p, joinedQuery); + } + } + } + if (queryMap.isEmpty()) { + return null; + } + } catch (Exception e) { + return null; + } + + return queryMap; + } + + public static String parseReqPath(RecordedRequest req) { + String parsedPath = null; + + try { + String fullPath = req.getPath(); + if (fullPath != null && !fullPath.isEmpty()) { + // retrieve the path segment before the query parameter + parsedPath = fullPath.split("\\?", 2)[0]; + } + if (parsedPath.isEmpty() || parsedPath == null) { + return null; + } + + } catch (Exception e) { + return null; + } + + return parsedPath; + } + + public static String serialize(Object obj) { + return GsonSingleton.getGson().toJson(obj); + } + + public static T deserialize(String json, Class clazz) { + return GsonSingleton.getGson().fromJson(json, clazz); + } + + public static InputStream createMockStream(String s) { + return new ByteArrayInputStream(s.getBytes()); + } + + public static List creatMockListFileWithMetadata() { + List list = new ArrayList(); + byte[] fileBytes = {(byte) 0xde, (byte) 0xad, (byte) 0xbe, (byte) 0xef}; + InputStream inputStream = new ByteArrayInputStream(fileBytes); + FileWithMetadata.Builder builder = new FileWithMetadata.Builder(); + builder.data(inputStream); + FileWithMetadata fileWithMetadata = builder.build(); + list.add(fileWithMetadata); + + return list; + } + + public static byte[] createMockByteArray(String bytes) { + return bytes.getBytes(); + } + + public static Date createMockDate(String date) throws Exception { + return new SimpleDateFormat("yyyy-MM-dd").parse(date); + } + + public static Date createMockDateTime(String date) throws Exception { + return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").parse(date); + } +} diff --git a/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/ToneAnalyzer.java b/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/ToneAnalyzer.java index d4d9f2200d4..cffde160e9c 100644 --- a/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/ToneAnalyzer.java +++ b/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/ToneAnalyzer.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2016, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -10,6 +10,11 @@ * 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. */ + +/* + * IBM OpenAPI SDK Code Generator Version: 99-SNAPSHOT-7cc05500-20201106-154555 + */ + package com.ibm.watson.tone_analyzer.v3; import com.google.gson.JsonObject; @@ -30,7 +35,7 @@ import java.util.Map.Entry; /** - * The IBM Watson™ Tone Analyzer service uses linguistic analysis to detect emotional and + * The IBM Watson&trade; Tone Analyzer service uses linguistic analysis to detect emotional and * language tones in written text. The service can analyze tone at both the document and sentence * levels. You can use the service to understand how your written communications are perceived and * then to improve the tone of your communications. Businesses can use the service to learn the tone @@ -42,70 +47,93 @@ * requests and responses. * * @version v3 - * @see Tone Analyzer + * @see Tone Analyzer */ public class ToneAnalyzer extends BaseService { - private static final String DEFAULT_SERVICE_NAME = "tone_analyzer"; + public static final String DEFAULT_SERVICE_NAME = "tone_analyzer"; - private static final String DEFAULT_SERVICE_URL = + public static final String DEFAULT_SERVICE_URL = "https://api.us-south.tone-analyzer.watson.cloud.ibm.com"; - private String versionDate; + private String version; /** - * Constructs a new `ToneAnalyzer` client using the DEFAULT_SERVICE_NAME. + * Constructs an instance of the `ToneAnalyzer` client. The default service name is used to + * configure the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value - * will keep your API calls from failing when the service introduces breaking changes. + * @param version Release date of the version of the API you want to use. Specify dates in + * YYYY-MM-DD format. The current version is `2017-09-21`. */ - public ToneAnalyzer(String versionDate) { + public ToneAnalyzer(String version) { this( - versionDate, + version, DEFAULT_SERVICE_NAME, ConfigBasedAuthenticatorFactory.getAuthenticator(DEFAULT_SERVICE_NAME)); } /** - * Constructs a new `ToneAnalyzer` client with the DEFAULT_SERVICE_NAME and the specified - * Authenticator. + * Constructs an instance of the `ToneAnalyzer` client. The default service name and specified + * authenticator are used to configure the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value - * will keep your API calls from failing when the service introduces breaking changes. - * @param authenticator the Authenticator instance to be configured for this service + * @param version Release date of the version of the API you want to use. Specify dates in + * YYYY-MM-DD format. The current version is `2017-09-21`. + * @param authenticator the {@link Authenticator} instance to be configured for this client */ - public ToneAnalyzer(String versionDate, Authenticator authenticator) { - this(versionDate, DEFAULT_SERVICE_NAME, authenticator); + public ToneAnalyzer(String version, Authenticator authenticator) { + this(version, DEFAULT_SERVICE_NAME, authenticator); } /** - * Constructs a new `ToneAnalyzer` client with the specified serviceName. + * Constructs an instance of the `ToneAnalyzer` client. The specified service name is used to + * configure the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value - * will keep your API calls from failing when the service introduces breaking changes. - * @param serviceName The name of the service to configure. + * @param version Release date of the version of the API you want to use. Specify dates in + * YYYY-MM-DD format. The current version is `2017-09-21`. + * @param serviceName the service name to be used when configuring the client instance */ - public ToneAnalyzer(String versionDate, String serviceName) { - this(versionDate, serviceName, ConfigBasedAuthenticatorFactory.getAuthenticator(serviceName)); + public ToneAnalyzer(String version, String serviceName) { + this(version, serviceName, ConfigBasedAuthenticatorFactory.getAuthenticator(serviceName)); } /** - * Constructs a new `ToneAnalyzer` client with the specified Authenticator and serviceName. + * Constructs an instance of the `ToneAnalyzer` client. The specified service name and + * authenticator are used to configure the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value - * will keep your API calls from failing when the service introduces breaking changes. - * @param serviceName The name of the service to configure. - * @param authenticator the Authenticator instance to be configured for this service + * @param version Release date of the version of the API you want to use. Specify dates in + * YYYY-MM-DD format. The current version is `2017-09-21`. + * @param serviceName the service name to be used when configuring the client instance + * @param authenticator the {@link Authenticator} instance to be configured for this client */ - public ToneAnalyzer(String versionDate, String serviceName, Authenticator authenticator) { + public ToneAnalyzer(String version, String serviceName, Authenticator authenticator) { super(serviceName, authenticator); setServiceUrl(DEFAULT_SERVICE_URL); - com.ibm.cloud.sdk.core.util.Validator.isTrue( - (versionDate != null) && !versionDate.isEmpty(), "version cannot be null."); - this.versionDate = versionDate; + setVersion(version); this.configureService(serviceName); } + /** + * Gets the version. + * + *

Release date of the version of the API you want to use. Specify dates in YYYY-MM-DD format. + * The current version is `2017-09-21`. + * + * @return the version + */ + public String getVersion() { + return this.version; + } + + /** + * Sets the version. + * + * @param version the new version + */ + public void setVersion(final String version) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(version, "version cannot be empty."); + this.version = version; + } + /** * Analyze general tone. * @@ -129,14 +157,12 @@ public ToneAnalyzer(String versionDate, String serviceName, Authenticator authen * endpoint](https://cloud.ibm.com/docs/tone-analyzer?topic=tone-analyzer-utgpe#utgpe). * * @param toneOptions the {@link ToneOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link ToneAnalysis} + * @return a {@link ServiceCall} with a result of type {@link ToneAnalysis} */ public ServiceCall tone(ToneOptions toneOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull(toneOptions, "toneOptions cannot be null"); - String[] pathSegments = {"v3/tone"}; RequestBuilder builder = - RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); + RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v3/tone")); Map sdkHeaders = SdkCommon.getSdkHeaders("tone_analyzer", "v3", "tone"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); @@ -151,6 +177,7 @@ public ServiceCall tone(ToneOptions toneOptions) { if (toneOptions.acceptLanguage() != null) { builder.header("Accept-Language", toneOptions.acceptLanguage()); } + builder.query("version", String.valueOf(this.version)); if (toneOptions.sentences() != null) { builder.query("sentences", String.valueOf(toneOptions.sentences())); } @@ -183,15 +210,13 @@ public ServiceCall tone(ToneOptions toneOptions) { * endpoint](https://cloud.ibm.com/docs/tone-analyzer?topic=tone-analyzer-utco#utco). * * @param toneChatOptions the {@link ToneChatOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link UtteranceAnalyses} + * @return a {@link ServiceCall} with a result of type {@link UtteranceAnalyses} */ public ServiceCall toneChat(ToneChatOptions toneChatOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( toneChatOptions, "toneChatOptions cannot be null"); - String[] pathSegments = {"v3/tone_chat"}; RequestBuilder builder = - RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); + RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v3/tone_chat")); Map sdkHeaders = SdkCommon.getSdkHeaders("tone_analyzer", "v3", "toneChat"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); @@ -203,6 +228,7 @@ public ServiceCall toneChat(ToneChatOptions toneChatOptions) if (toneChatOptions.acceptLanguage() != null) { builder.header("Accept-Language", toneChatOptions.acceptLanguage()); } + builder.query("version", String.valueOf(this.version)); final JsonObject contentJson = new JsonObject(); contentJson.add( "utterances", diff --git a/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/DocumentAnalysis.java b/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/DocumentAnalysis.java index 33695e820c5..7ab3cb97de6 100644 --- a/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/DocumentAnalysis.java +++ b/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/DocumentAnalysis.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/SentenceAnalysis.java b/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/SentenceAnalysis.java index 9e20dd8685b..03d7374db7b 100644 --- a/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/SentenceAnalysis.java +++ b/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/SentenceAnalysis.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/ToneAnalysis.java b/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/ToneAnalysis.java index 5751cbec334..ad19f3c3d7d 100644 --- a/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/ToneAnalysis.java +++ b/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/ToneAnalysis.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2016, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/ToneCategory.java b/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/ToneCategory.java index 2054fa2192a..b887d06acdf 100644 --- a/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/ToneCategory.java +++ b/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/ToneCategory.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2016, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/ToneChatOptions.java b/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/ToneChatOptions.java index c01946d4ae8..2ba52328c73 100644 --- a/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/ToneChatOptions.java +++ b/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/ToneChatOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -94,7 +94,7 @@ public Builder(List utterances) { /** * Builds a ToneChatOptions. * - * @return the toneChatOptions + * @return the new ToneChatOptions instance */ public ToneChatOptions build() { return new ToneChatOptions(this); diff --git a/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/ToneChatScore.java b/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/ToneChatScore.java index 7cccafa832f..d55d025e7d8 100644 --- a/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/ToneChatScore.java +++ b/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/ToneChatScore.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/ToneInput.java b/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/ToneInput.java index a94c2acce8b..55fc4dd4bff 100644 --- a/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/ToneInput.java +++ b/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/ToneInput.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -42,7 +42,7 @@ public Builder(String text) { /** * Builds a ToneInput. * - * @return the toneInput + * @return the new ToneInput instance */ public ToneInput build() { return new ToneInput(this); diff --git a/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/ToneOptions.java b/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/ToneOptions.java index cbd401633c3..f97abd59536 100644 --- a/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/ToneOptions.java +++ b/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/ToneOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2016, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -106,7 +106,7 @@ public Builder() {} /** * Builds a ToneOptions. * - * @return the toneOptions + * @return the new ToneOptions instance */ public ToneOptions build() { return new ToneOptions(this); diff --git a/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/ToneScore.java b/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/ToneScore.java index f27e75080de..e45faa6623c 100644 --- a/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/ToneScore.java +++ b/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/ToneScore.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2016, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/Utterance.java b/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/Utterance.java index 7ea0584e81a..d189ec60665 100644 --- a/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/Utterance.java +++ b/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/Utterance.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -45,7 +45,7 @@ public Builder(String text) { /** * Builds a Utterance. * - * @return the utterance + * @return the new Utterance instance */ public Utterance build() { return new Utterance(this); diff --git a/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/UtteranceAnalyses.java b/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/UtteranceAnalyses.java index 5be0684c327..062ae11d40c 100644 --- a/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/UtteranceAnalyses.java +++ b/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/UtteranceAnalyses.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/UtteranceAnalysis.java b/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/UtteranceAnalysis.java index 9efb21b4bd9..278a99f943b 100644 --- a/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/UtteranceAnalysis.java +++ b/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/model/UtteranceAnalysis.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/package-info.java b/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/package-info.java index 3d4ebd4021d..5a7a9bc816a 100644 --- a/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/package-info.java +++ b/tone-analyzer/src/main/java/com/ibm/watson/tone_analyzer/v3/package-info.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/tone-analyzer/src/test/java/com/ibm/watson/tone_analyzer/v3/ToneAnalyzerTest.java b/tone-analyzer/src/test/java/com/ibm/watson/tone_analyzer/v3/ToneAnalyzerTest.java index 14c4a430484..3616567f33b 100644 --- a/tone-analyzer/src/test/java/com/ibm/watson/tone_analyzer/v3/ToneAnalyzerTest.java +++ b/tone-analyzer/src/test/java/com/ibm/watson/tone_analyzer/v3/ToneAnalyzerTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -12,191 +12,212 @@ */ package com.ibm.watson.tone_analyzer.v3; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.testng.Assert.*; -import com.ibm.cloud.sdk.core.http.HttpHeaders; -import com.ibm.cloud.sdk.core.http.HttpMediaType; +import com.ibm.cloud.sdk.core.http.Response; +import com.ibm.cloud.sdk.core.security.Authenticator; import com.ibm.cloud.sdk.core.security.NoAuthAuthenticator; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; import com.ibm.cloud.sdk.core.util.RequestUtils; -import com.ibm.watson.common.WatsonServiceUnitTest; import com.ibm.watson.tone_analyzer.v3.model.ToneAnalysis; import com.ibm.watson.tone_analyzer.v3.model.ToneChatOptions; +import com.ibm.watson.tone_analyzer.v3.model.ToneInput; import com.ibm.watson.tone_analyzer.v3.model.ToneOptions; import com.ibm.watson.tone_analyzer.v3.model.Utterance; import com.ibm.watson.tone_analyzer.v3.model.UtteranceAnalyses; +import com.ibm.watson.tone_analyzer.v3.utils.TestUtilities; import java.io.IOException; -import java.util.ArrayList; +import java.io.InputStream; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; import okhttp3.mockwebserver.RecordedRequest; -import org.apache.commons.lang3.StringUtils; -import org.junit.Before; -import org.junit.Test; - -/** Tone Analyzer unit test. */ -public class ToneAnalyzerTest extends WatsonServiceUnitTest { - - private static final String VERSION_DATE = "version"; - private static final String FIXTURE = "src/test/resources/tone_analyzer/tone.json"; - private static final String CHAT_FIXTURE = "src/test/resources/tone_analyzer/tone_chat.json"; - private static final String TONE_PATH = "/v3/tone"; - private static final String CHAT_TONE_PATH = "/v3/tone_chat"; - - /** The service. */ - private ToneAnalyzer service; - - private static final String VERSION_DATE_VALUE = "2017-09-21"; - - /** - * Sets up the tests. - * - * @throws Exception the exception - */ - /* - * (non-Javadoc) - * @see com.ibm.watson.common.WatsonServiceTest#setUp() - */ - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - service = new ToneAnalyzer(VERSION_DATE_VALUE, new NoAuthAuthenticator()); - service.setServiceUrl(getMockWebServerUrl()); +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +/** Unit test class for the ToneAnalyzer service. */ +public class ToneAnalyzerTest { + + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + protected MockWebServer server; + protected ToneAnalyzer toneAnalyzerService; + + public void constructClientService() throws Throwable { + final String serviceName = "testService"; + // set mock values for global params + String version = "testString"; + + final Authenticator authenticator = new NoAuthAuthenticator(); + + toneAnalyzerService = new ToneAnalyzer(version, serviceName, authenticator); + String url = server.url("/").toString(); + toneAnalyzerService.setServiceUrl(url); } - /** - * Test README. - * - * @throws InterruptedException the interrupted exception - * @throws IOException Signals that an I/O exception has occurred. - */ - @Test - public void testReadme() throws InterruptedException, IOException { - - ToneAnalyzer service = new ToneAnalyzer(VERSION_DATE, new NoAuthAuthenticator()); - - service.setServiceUrl(getMockWebServerUrl()); // exclude - ToneAnalysis mockResponse = loadFixture(FIXTURE, ToneAnalysis.class); // exclude - server.enqueue(jsonResponse(mockResponse)); // exclude - - String text = - "I know the times are difficult! Our sales have been " - + "disappointing for the past three quarters for our data analytics " - + "product suite. We have a competitive data analytics product " - + "suite in the industry. But we need to do our job selling it! " - + "We need to acknowledge and fix our sales challenges. " - + "We can’t blame the economy for our lack of execution! " - + "We are missing critical sales opportunities. " - + "Our product is in no way inferior to the competitor products. " - + "Our clients are hungry for analytical tools to improve their " - + "business outcomes. Economy has nothing to do with it."; - - // Call the service and get the tone - ToneOptions toneOptions = new ToneOptions.Builder().html(text).build(); - ToneAnalysis tone = service.tone(toneOptions).execute().getResult(); - System.out.println(tone); + /** Negative Test - construct the service with a null authenticator. */ + @Test(expectedExceptions = IllegalArgumentException.class) + public void testConstructorWithNullAuthenticator() throws Throwable { + final String serviceName = "testService"; + // set mock values for global params + String version = "testString"; + + new ToneAnalyzer(version, serviceName, null); } - /** Test tone with null. */ - @Test(expected = IllegalArgumentException.class) - public void testtoneWithNull() { - service.tone(null); + @Test + public void testGetVersion() throws Throwable { + constructClientService(); + assertEquals(toneAnalyzerService.getVersion(), "testString"); } - /** - * Test get tones. - * - * @throws InterruptedException the interrupted exception - * @throws IOException Signals that an I/O exception has occurred. - */ @Test - public void testtones() throws InterruptedException, IOException { - String text = - "I know the times are difficult! Our sales have been " - + "disappointing for the past three quarters for our data analytics " - + "product suite. We have a competitive data analytics product " - + "suite in the industry. But we need to do our job selling it! "; - - ToneAnalysis mockResponse = loadFixture(FIXTURE, ToneAnalysis.class); - server.enqueue(jsonResponse(mockResponse)); - server.enqueue(jsonResponse(mockResponse)); - server.enqueue(jsonResponse(mockResponse)); - - // execute request - ToneOptions toneOptions = new ToneOptions.Builder().html(text).build(); - ToneAnalysis serviceResponse = service.tone(toneOptions).execute().getResult(); - - // first request - RecordedRequest request = server.takeRequest(); + public void testToneWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"document_tone\": {\"tones\": [{\"score\": 5, \"tone_id\": \"toneId\", \"tone_name\": \"toneName\"}], \"tone_categories\": [{\"tones\": [{\"score\": 5, \"tone_id\": \"toneId\", \"tone_name\": \"toneName\"}], \"category_id\": \"categoryId\", \"category_name\": \"categoryName\"}], \"warning\": \"warning\"}, \"sentences_tone\": [{\"sentence_id\": 10, \"text\": \"text\", \"tones\": [{\"score\": 5, \"tone_id\": \"toneId\", \"tone_name\": \"toneName\"}], \"tone_categories\": [{\"tones\": [{\"score\": 5, \"tone_id\": \"toneId\", \"tone_name\": \"toneName\"}], \"category_id\": \"categoryId\", \"category_name\": \"categoryName\"}], \"input_from\": 9, \"input_to\": 7}]}"; + String tonePath = "/v3/tone"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); - String path = StringUtils.join(TONE_PATH, "?", VERSION_DATE, "=", VERSION_DATE_VALUE); - assertEquals(path, request.getPath()); - assertEquals(serviceResponse, mockResponse); - assertEquals(HttpMediaType.APPLICATION_JSON, request.getHeader(HttpHeaders.ACCEPT)); + constructClientService(); - // second request - serviceResponse = - service.tone(new ToneOptions.Builder().html(text).build()).execute().getResult(); - request = server.takeRequest(); - assertEquals(path, request.getPath()); - assertTrue(request.getHeader(HttpHeaders.CONTENT_TYPE).startsWith(HttpMediaType.TEXT_HTML)); + // Construct an instance of the ToneInput model + ToneInput toneInputModel = new ToneInput.Builder().text("testString").build(); - // third request - ToneOptions toneOptions1 = + // Construct an instance of the ToneOptions model + ToneOptions toneOptionsModel = new ToneOptions.Builder() - .html(text) - .addTone(ToneOptions.Tone.EMOTION) - .addTone(ToneOptions.Tone.LANGUAGE) - .addTone(ToneOptions.Tone.SOCIAL) + .toneInput(toneInputModel) + .sentences(true) + .tones(new java.util.ArrayList(java.util.Arrays.asList("emotion"))) + .contentLanguage("en") + .acceptLanguage("ar") .build(); - serviceResponse = service.tone(toneOptions1).execute().getResult(); - request = server.takeRequest(); - path = path + "&tones=" + RequestUtils.encode("emotion,language,social"); - assertEquals(path, request.getPath()); + + // Invoke operation with valid options model (positive test) + Response response = toneAnalyzerService.tone(toneOptionsModel).execute(); + assertNotNull(response); + ToneAnalysis responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("sentences")), Boolean.valueOf(true)); + assertEquals( + query.get("tones"), + RequestUtils.join( + new java.util.ArrayList(java.util.Arrays.asList("emotion")), ",")); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, tonePath); } - /** - * Test to get Chat tones. - * - * @throws IOException Signals that an I/O exception has occurred. - * @throws InterruptedException the interrupted exception - */ - @Test - public void testGetChatTones() throws IOException, InterruptedException { - - String[] users = {"customer", "agent", "customer", "agent"}; - - String[] texts = { - "My charger isn't working.", - "Thanks for reaching out. Can you give me some more detail about the issue?", - "I put my charger in my tablet to charge it up last night and it keeps saying it isn't" - + " charging. The charging icon comes on, but it stays on even when I take the charger out. " - + "Which is ridiculous, it's brand new.", - "I'm sorry you're having issues with charging. What kind of charger are you using?" - }; - - List utterances = new ArrayList<>(); - for (int i = 0; i < texts.length; i++) { - Utterance utterance = new Utterance.Builder().text(texts[i]).user(users[i]).build(); - utterances.add(utterance); - } + // Test the tone operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testToneNoOptions() throws Throwable { + // construct the service + constructClientService(); - ToneChatOptions toneChatOptions = new ToneChatOptions.Builder().utterances(utterances).build(); + server.enqueue(new MockResponse()); - UtteranceAnalyses mockResponse = loadFixture(CHAT_FIXTURE, UtteranceAnalyses.class); - server.enqueue(jsonResponse(mockResponse)); - server.enqueue(jsonResponse(mockResponse)); - server.enqueue(jsonResponse(mockResponse)); + // Invoke operation with null options model (negative test) + toneAnalyzerService.tone(null).execute(); + } - // execute request - UtteranceAnalyses serviceResponse = service.toneChat(toneChatOptions).execute().getResult(); + @Test + public void testToneChatWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"utterances_tone\": [{\"utterance_id\": 11, \"utterance_text\": \"utteranceText\", \"tones\": [{\"score\": 5, \"tone_id\": \"excited\", \"tone_name\": \"toneName\"}], \"error\": \"error\"}], \"warning\": \"warning\"}"; + String toneChatPath = "/v3/tone_chat"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the Utterance model + Utterance utteranceModel = + new Utterance.Builder().text("testString").user("testString").build(); + + // Construct an instance of the ToneChatOptions model + ToneChatOptions toneChatOptionsModel = + new ToneChatOptions.Builder() + .utterances(new java.util.ArrayList(java.util.Arrays.asList(utteranceModel))) + .contentLanguage("en") + .acceptLanguage("ar") + .build(); + + // Invoke operation with valid options model (positive test) + Response response = + toneAnalyzerService.toneChat(toneChatOptionsModel).execute(); + assertNotNull(response); + UtteranceAnalyses responseObj = response.getResult(); + assertNotNull(responseObj); - // first request + // Verify the contents of the request RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, toneChatPath); + } + + // Test the toneChat operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testToneChatNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + toneAnalyzerService.toneChat(null).execute(); + } + + /** Initialize the server */ + @BeforeMethod + public void setUpMockServer() { + try { + server = new MockWebServer(); + // register handler + server.start(); + } catch (IOException err) { + fail("Failed to instantiate mock web server"); + } + } - String path = StringUtils.join(CHAT_TONE_PATH, "?", VERSION_DATE, "=", VERSION_DATE_VALUE); - assertEquals(path, request.getPath()); - assertEquals(serviceResponse, mockResponse); - assertEquals(HttpMediaType.APPLICATION_JSON, request.getHeader(HttpHeaders.ACCEPT)); + @AfterMethod + public void tearDownMockServer() throws IOException { + server.shutdown(); + toneAnalyzerService = null; } } diff --git a/tone-analyzer/src/test/java/com/ibm/watson/tone_analyzer/v3/model/DocumentAnalysisTest.java b/tone-analyzer/src/test/java/com/ibm/watson/tone_analyzer/v3/model/DocumentAnalysisTest.java new file mode 100644 index 00000000000..f815d9ef728 --- /dev/null +++ b/tone-analyzer/src/test/java/com/ibm/watson/tone_analyzer/v3/model/DocumentAnalysisTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.tone_analyzer.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.tone_analyzer.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DocumentAnalysis model. */ +public class DocumentAnalysisTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDocumentAnalysis() throws Throwable { + DocumentAnalysis documentAnalysisModel = new DocumentAnalysis(); + assertNull(documentAnalysisModel.getTones()); + assertNull(documentAnalysisModel.getToneCategories()); + assertNull(documentAnalysisModel.getWarning()); + } +} diff --git a/tone-analyzer/src/test/java/com/ibm/watson/tone_analyzer/v3/model/SentenceAnalysisTest.java b/tone-analyzer/src/test/java/com/ibm/watson/tone_analyzer/v3/model/SentenceAnalysisTest.java new file mode 100644 index 00000000000..275f9621d5a --- /dev/null +++ b/tone-analyzer/src/test/java/com/ibm/watson/tone_analyzer/v3/model/SentenceAnalysisTest.java @@ -0,0 +1,41 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.tone_analyzer.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.tone_analyzer.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the SentenceAnalysis model. */ +public class SentenceAnalysisTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testSentenceAnalysis() throws Throwable { + SentenceAnalysis sentenceAnalysisModel = new SentenceAnalysis(); + assertNull(sentenceAnalysisModel.getSentenceId()); + assertNull(sentenceAnalysisModel.getText()); + assertNull(sentenceAnalysisModel.getTones()); + assertNull(sentenceAnalysisModel.getToneCategories()); + assertNull(sentenceAnalysisModel.getInputFrom()); + assertNull(sentenceAnalysisModel.getInputTo()); + } +} diff --git a/tone-analyzer/src/test/java/com/ibm/watson/tone_analyzer/v3/model/ToneAnalysisTest.java b/tone-analyzer/src/test/java/com/ibm/watson/tone_analyzer/v3/model/ToneAnalysisTest.java new file mode 100644 index 00000000000..087b5b60de4 --- /dev/null +++ b/tone-analyzer/src/test/java/com/ibm/watson/tone_analyzer/v3/model/ToneAnalysisTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.tone_analyzer.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.tone_analyzer.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ToneAnalysis model. */ +public class ToneAnalysisTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testToneAnalysis() throws Throwable { + ToneAnalysis toneAnalysisModel = new ToneAnalysis(); + assertNull(toneAnalysisModel.getDocumentTone()); + assertNull(toneAnalysisModel.getSentencesTone()); + } +} diff --git a/tone-analyzer/src/test/java/com/ibm/watson/tone_analyzer/v3/model/ToneCategoryTest.java b/tone-analyzer/src/test/java/com/ibm/watson/tone_analyzer/v3/model/ToneCategoryTest.java new file mode 100644 index 00000000000..fe9363f403b --- /dev/null +++ b/tone-analyzer/src/test/java/com/ibm/watson/tone_analyzer/v3/model/ToneCategoryTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.tone_analyzer.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.tone_analyzer.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ToneCategory model. */ +public class ToneCategoryTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testToneCategory() throws Throwable { + ToneCategory toneCategoryModel = new ToneCategory(); + assertNull(toneCategoryModel.getTones()); + assertNull(toneCategoryModel.getCategoryId()); + assertNull(toneCategoryModel.getCategoryName()); + } +} diff --git a/tone-analyzer/src/test/java/com/ibm/watson/tone_analyzer/v3/model/ToneChatOptionsTest.java b/tone-analyzer/src/test/java/com/ibm/watson/tone_analyzer/v3/model/ToneChatOptionsTest.java new file mode 100644 index 00000000000..6ee3eb264ba --- /dev/null +++ b/tone-analyzer/src/test/java/com/ibm/watson/tone_analyzer/v3/model/ToneChatOptionsTest.java @@ -0,0 +1,55 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.tone_analyzer.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.tone_analyzer.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ToneChatOptions model. */ +public class ToneChatOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testToneChatOptions() throws Throwable { + Utterance utteranceModel = + new Utterance.Builder().text("testString").user("testString").build(); + assertEquals(utteranceModel.text(), "testString"); + assertEquals(utteranceModel.user(), "testString"); + + ToneChatOptions toneChatOptionsModel = + new ToneChatOptions.Builder() + .utterances(new java.util.ArrayList(java.util.Arrays.asList(utteranceModel))) + .contentLanguage("en") + .acceptLanguage("ar") + .build(); + assertEquals( + toneChatOptionsModel.utterances(), + new java.util.ArrayList(java.util.Arrays.asList(utteranceModel))); + assertEquals(toneChatOptionsModel.contentLanguage(), "en"); + assertEquals(toneChatOptionsModel.acceptLanguage(), "ar"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testToneChatOptionsError() throws Throwable { + new ToneChatOptions.Builder().build(); + } +} diff --git a/tone-analyzer/src/test/java/com/ibm/watson/tone_analyzer/v3/model/ToneChatScoreTest.java b/tone-analyzer/src/test/java/com/ibm/watson/tone_analyzer/v3/model/ToneChatScoreTest.java new file mode 100644 index 00000000000..1f6a7f37c98 --- /dev/null +++ b/tone-analyzer/src/test/java/com/ibm/watson/tone_analyzer/v3/model/ToneChatScoreTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.tone_analyzer.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.tone_analyzer.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ToneChatScore model. */ +public class ToneChatScoreTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testToneChatScore() throws Throwable { + ToneChatScore toneChatScoreModel = new ToneChatScore(); + assertNull(toneChatScoreModel.getScore()); + assertNull(toneChatScoreModel.getToneId()); + assertNull(toneChatScoreModel.getToneName()); + } +} diff --git a/tone-analyzer/src/test/java/com/ibm/watson/tone_analyzer/v3/model/ToneInputTest.java b/tone-analyzer/src/test/java/com/ibm/watson/tone_analyzer/v3/model/ToneInputTest.java new file mode 100644 index 00000000000..9ad4b58596a --- /dev/null +++ b/tone-analyzer/src/test/java/com/ibm/watson/tone_analyzer/v3/model/ToneInputTest.java @@ -0,0 +1,47 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.tone_analyzer.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.tone_analyzer.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ToneInput model. */ +public class ToneInputTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testToneInput() throws Throwable { + ToneInput toneInputModel = new ToneInput.Builder().text("testString").build(); + assertEquals(toneInputModel.text(), "testString"); + + String json = TestUtilities.serialize(toneInputModel); + + ToneInput toneInputModelNew = TestUtilities.deserialize(json, ToneInput.class); + assertTrue(toneInputModelNew instanceof ToneInput); + assertEquals(toneInputModelNew.text(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testToneInputError() throws Throwable { + new ToneInput.Builder().build(); + } +} diff --git a/tone-analyzer/src/test/java/com/ibm/watson/tone_analyzer/v3/model/ToneOptionsTest.java b/tone-analyzer/src/test/java/com/ibm/watson/tone_analyzer/v3/model/ToneOptionsTest.java new file mode 100644 index 00000000000..0b0df3f2778 --- /dev/null +++ b/tone-analyzer/src/test/java/com/ibm/watson/tone_analyzer/v3/model/ToneOptionsTest.java @@ -0,0 +1,52 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.tone_analyzer.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.tone_analyzer.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ToneOptions model. */ +public class ToneOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testToneOptions() throws Throwable { + ToneInput toneInputModel = new ToneInput.Builder().text("testString").build(); + assertEquals(toneInputModel.text(), "testString"); + + ToneOptions toneOptionsModel = + new ToneOptions.Builder() + .toneInput(toneInputModel) + .sentences(true) + .tones(new java.util.ArrayList(java.util.Arrays.asList("emotion"))) + .contentLanguage("en") + .acceptLanguage("ar") + .build(); + assertEquals(toneOptionsModel.toneInput(), toneInputModel); + assertEquals(toneOptionsModel.sentences(), Boolean.valueOf(true)); + assertEquals( + toneOptionsModel.tones(), + new java.util.ArrayList(java.util.Arrays.asList("emotion"))); + assertEquals(toneOptionsModel.contentLanguage(), "en"); + assertEquals(toneOptionsModel.acceptLanguage(), "ar"); + } +} diff --git a/tone-analyzer/src/test/java/com/ibm/watson/tone_analyzer/v3/model/ToneScoreTest.java b/tone-analyzer/src/test/java/com/ibm/watson/tone_analyzer/v3/model/ToneScoreTest.java new file mode 100644 index 00000000000..c972ce48895 --- /dev/null +++ b/tone-analyzer/src/test/java/com/ibm/watson/tone_analyzer/v3/model/ToneScoreTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.tone_analyzer.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.tone_analyzer.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ToneScore model. */ +public class ToneScoreTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testToneScore() throws Throwable { + ToneScore toneScoreModel = new ToneScore(); + assertNull(toneScoreModel.getScore()); + assertNull(toneScoreModel.getToneId()); + assertNull(toneScoreModel.getToneName()); + } +} diff --git a/tone-analyzer/src/test/java/com/ibm/watson/tone_analyzer/v3/model/UtteranceAnalysesTest.java b/tone-analyzer/src/test/java/com/ibm/watson/tone_analyzer/v3/model/UtteranceAnalysesTest.java new file mode 100644 index 00000000000..69bcd895417 --- /dev/null +++ b/tone-analyzer/src/test/java/com/ibm/watson/tone_analyzer/v3/model/UtteranceAnalysesTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.tone_analyzer.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.tone_analyzer.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the UtteranceAnalyses model. */ +public class UtteranceAnalysesTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUtteranceAnalyses() throws Throwable { + UtteranceAnalyses utteranceAnalysesModel = new UtteranceAnalyses(); + assertNull(utteranceAnalysesModel.getUtterancesTone()); + assertNull(utteranceAnalysesModel.getWarning()); + } +} diff --git a/tone-analyzer/src/test/java/com/ibm/watson/tone_analyzer/v3/model/UtteranceAnalysisTest.java b/tone-analyzer/src/test/java/com/ibm/watson/tone_analyzer/v3/model/UtteranceAnalysisTest.java new file mode 100644 index 00000000000..9d749e3688c --- /dev/null +++ b/tone-analyzer/src/test/java/com/ibm/watson/tone_analyzer/v3/model/UtteranceAnalysisTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.tone_analyzer.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.tone_analyzer.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the UtteranceAnalysis model. */ +public class UtteranceAnalysisTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUtteranceAnalysis() throws Throwable { + UtteranceAnalysis utteranceAnalysisModel = new UtteranceAnalysis(); + assertNull(utteranceAnalysisModel.getUtteranceId()); + assertNull(utteranceAnalysisModel.getUtteranceText()); + assertNull(utteranceAnalysisModel.getTones()); + assertNull(utteranceAnalysisModel.getError()); + } +} diff --git a/tone-analyzer/src/test/java/com/ibm/watson/tone_analyzer/v3/model/UtteranceTest.java b/tone-analyzer/src/test/java/com/ibm/watson/tone_analyzer/v3/model/UtteranceTest.java new file mode 100644 index 00000000000..7bad242e16e --- /dev/null +++ b/tone-analyzer/src/test/java/com/ibm/watson/tone_analyzer/v3/model/UtteranceTest.java @@ -0,0 +1,50 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.tone_analyzer.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.tone_analyzer.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Utterance model. */ +public class UtteranceTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUtterance() throws Throwable { + Utterance utteranceModel = + new Utterance.Builder().text("testString").user("testString").build(); + assertEquals(utteranceModel.text(), "testString"); + assertEquals(utteranceModel.user(), "testString"); + + String json = TestUtilities.serialize(utteranceModel); + + Utterance utteranceModelNew = TestUtilities.deserialize(json, Utterance.class); + assertTrue(utteranceModelNew instanceof Utterance); + assertEquals(utteranceModelNew.text(), "testString"); + assertEquals(utteranceModelNew.user(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUtteranceError() throws Throwable { + new Utterance.Builder().build(); + } +} diff --git a/tone-analyzer/src/test/java/com/ibm/watson/tone_analyzer/v3/utils/TestUtilities.java b/tone-analyzer/src/test/java/com/ibm/watson/tone_analyzer/v3/utils/TestUtilities.java new file mode 100644 index 00000000000..13f7cd83c51 --- /dev/null +++ b/tone-analyzer/src/test/java/com/ibm/watson/tone_analyzer/v3/utils/TestUtilities.java @@ -0,0 +1,128 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.tone_analyzer.v3.utils; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.cloud.sdk.core.util.GsonSingleton; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import okhttp3.HttpUrl; +import okhttp3.mockwebserver.RecordedRequest; + +/** A class used by the unit tests containing utility functions. */ +public class TestUtilities { + public static Map createMockMap() { + Map mockMap = new HashMap<>(); + mockMap.put("foo", "bar"); + return mockMap; + } + + public static HashMap createMockStreamMap() { + return new HashMap() { + { + put("key1", createMockStream("This is a mock file.")); + } + }; + } + + public static Map parseQueryString(RecordedRequest req) { + Map queryMap = new HashMap<>(); + + try { + HttpUrl requestUrl = req.getRequestUrl(); + + if (requestUrl != null) { + Set queryParamsNames = requestUrl.queryParameterNames(); + // map the parameter name to its corresponding value + for (String p : queryParamsNames) { + // get the corresponding value for the parameter (p) + List val = requestUrl.queryParameterValues(p); + if (val != null && !val.isEmpty()) { + String joinedQuery = String.join(",", val); + queryMap.put(p, joinedQuery); + } + } + } + if (queryMap.isEmpty()) { + return null; + } + } catch (Exception e) { + return null; + } + + return queryMap; + } + + public static String parseReqPath(RecordedRequest req) { + String parsedPath = null; + + try { + String fullPath = req.getPath(); + if (fullPath != null && !fullPath.isEmpty()) { + // retrieve the path segment before the query parameter + parsedPath = fullPath.split("\\?", 2)[0]; + } + if (parsedPath.isEmpty() || parsedPath == null) { + return null; + } + + } catch (Exception e) { + return null; + } + + return parsedPath; + } + + public static String serialize(Object obj) { + return GsonSingleton.getGson().toJson(obj); + } + + public static T deserialize(String json, Class clazz) { + return GsonSingleton.getGson().fromJson(json, clazz); + } + + public static InputStream createMockStream(String s) { + return new ByteArrayInputStream(s.getBytes()); + } + + public static List creatMockListFileWithMetadata() { + List list = new ArrayList(); + byte[] fileBytes = {(byte) 0xde, (byte) 0xad, (byte) 0xbe, (byte) 0xef}; + InputStream inputStream = new ByteArrayInputStream(fileBytes); + FileWithMetadata.Builder builder = new FileWithMetadata.Builder(); + builder.data(inputStream); + FileWithMetadata fileWithMetadata = builder.build(); + list.add(fileWithMetadata); + + return list; + } + + public static byte[] createMockByteArray(String bytes) { + return bytes.getBytes(); + } + + public static Date createMockDate(String date) throws Exception { + return new SimpleDateFormat("yyyy-MM-dd").parse(date); + } + + public static Date createMockDateTime(String date) throws Exception { + return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").parse(date); + } +} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/VisualRecognition.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/VisualRecognition.java index 1b1834969c7..c025d3a1150 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/VisualRecognition.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/VisualRecognition.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2016, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -10,6 +10,11 @@ * 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. */ + +/* + * IBM OpenAPI SDK Code Generator Version: 99-SNAPSHOT-7cc05500-20201106-154555 + */ + package com.ibm.watson.visual_recognition.v3; import com.ibm.cloud.sdk.core.http.RequestBuilder; @@ -33,87 +38,111 @@ import com.ibm.watson.visual_recognition.v3.model.ListClassifiersOptions; import com.ibm.watson.visual_recognition.v3.model.UpdateClassifierOptions; import java.io.InputStream; +import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; import okhttp3.MultipartBody; /** - * The IBM Watson™ Visual Recognition service uses deep learning algorithms to identify scenes - * and objects in images that you upload to the service. You can create and train a custom + * The IBM Watson&trade; Visual Recognition service uses deep learning algorithms to identify + * scenes and objects in images that you upload to the service. You can create and train a custom * classifier to identify subjects that suit your needs. * * @version v3 - * @see Visual Recognition + * @see Visual Recognition */ public class VisualRecognition extends BaseService { - private static final String DEFAULT_SERVICE_NAME = "visual_recognition"; + public static final String DEFAULT_SERVICE_NAME = "watson_vision_combined"; - private static final String DEFAULT_SERVICE_URL = + public static final String DEFAULT_SERVICE_URL = "https://api.us-south.visual-recognition.watson.cloud.ibm.com"; - private String versionDate; + private String version; /** - * Constructs a new `VisualRecognition` client using the DEFAULT_SERVICE_NAME. + * Constructs an instance of the `VisualRecognition` client. The default service name is used to + * configure the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value - * will keep your API calls from failing when the service introduces breaking changes. + * @param version Release date of the API version you want to use. Specify dates in YYYY-MM-DD + * format. The current version is `2018-03-19`. */ - public VisualRecognition(String versionDate) { + public VisualRecognition(String version) { this( - versionDate, + version, DEFAULT_SERVICE_NAME, ConfigBasedAuthenticatorFactory.getAuthenticator(DEFAULT_SERVICE_NAME)); } /** - * Constructs a new `VisualRecognition` client with the DEFAULT_SERVICE_NAME and the specified - * Authenticator. + * Constructs an instance of the `VisualRecognition` client. The default service name and + * specified authenticator are used to configure the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value - * will keep your API calls from failing when the service introduces breaking changes. - * @param authenticator the Authenticator instance to be configured for this service + * @param version Release date of the API version you want to use. Specify dates in YYYY-MM-DD + * format. The current version is `2018-03-19`. + * @param authenticator the {@link Authenticator} instance to be configured for this client */ - public VisualRecognition(String versionDate, Authenticator authenticator) { - this(versionDate, DEFAULT_SERVICE_NAME, authenticator); + public VisualRecognition(String version, Authenticator authenticator) { + this(version, DEFAULT_SERVICE_NAME, authenticator); } /** - * Constructs a new `VisualRecognition` client with the specified serviceName. + * Constructs an instance of the `VisualRecognition` client. The specified service name is used to + * configure the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value - * will keep your API calls from failing when the service introduces breaking changes. - * @param serviceName The name of the service to configure. + * @param version Release date of the API version you want to use. Specify dates in YYYY-MM-DD + * format. The current version is `2018-03-19`. + * @param serviceName the service name to be used when configuring the client instance */ - public VisualRecognition(String versionDate, String serviceName) { - this(versionDate, serviceName, ConfigBasedAuthenticatorFactory.getAuthenticator(serviceName)); + public VisualRecognition(String version, String serviceName) { + this(version, serviceName, ConfigBasedAuthenticatorFactory.getAuthenticator(serviceName)); } /** - * Constructs a new `VisualRecognition` client with the specified Authenticator and serviceName. + * Constructs an instance of the `VisualRecognition` client. The specified service name and + * authenticator are used to configure the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value - * will keep your API calls from failing when the service introduces breaking changes. - * @param serviceName The name of the service to configure. - * @param authenticator the Authenticator instance to be configured for this service + * @param version Release date of the API version you want to use. Specify dates in YYYY-MM-DD + * format. The current version is `2018-03-19`. + * @param serviceName the service name to be used when configuring the client instance + * @param authenticator the {@link Authenticator} instance to be configured for this client */ - public VisualRecognition(String versionDate, String serviceName, Authenticator authenticator) { + public VisualRecognition(String version, String serviceName, Authenticator authenticator) { super(serviceName, authenticator); setServiceUrl(DEFAULT_SERVICE_URL); - com.ibm.cloud.sdk.core.util.Validator.isTrue( - (versionDate != null) && !versionDate.isEmpty(), "version cannot be null."); - this.versionDate = versionDate; + setVersion(version); this.configureService(serviceName); } + /** + * Gets the version. + * + *

Release date of the API version you want to use. Specify dates in YYYY-MM-DD format. The + * current version is `2018-03-19`. + * + * @return the version + */ + public String getVersion() { + return this.version; + } + + /** + * Sets the version. + * + * @param version the new version + */ + public void setVersion(final String version) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(version, "version cannot be empty."); + this.version = version; + } + /** * Classify images. * *

Classify images with built-in or custom classifiers. * * @param classifyOptions the {@link ClassifyOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link ClassifiedImages} + * @return a {@link ServiceCall} with a result of type {@link ClassifiedImages} */ public ServiceCall classify(ClassifyOptions classifyOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( @@ -125,10 +154,8 @@ public ServiceCall classify(ClassifyOptions classifyOptions) { || (classifyOptions.owners() != null) || (classifyOptions.classifierIds() != null), "At least one of imagesFile, url, threshold, owners, or classifierIds must be supplied."); - String[] pathSegments = {"v3/classify"}; RequestBuilder builder = - RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); + RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v3/classify")); Map sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v3", "classify"); for (Entry header : sdkHeaders.entrySet()) { @@ -138,6 +165,7 @@ public ServiceCall classify(ClassifyOptions classifyOptions) { if (classifyOptions.acceptLanguage() != null) { builder.header("Accept-Language", classifyOptions.acceptLanguage()); } + builder.query("version", String.valueOf(this.version)); MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); multipartBuilder.setType(MultipartBody.FORM); if (classifyOptions.imagesFile() != null) { @@ -154,11 +182,14 @@ public ServiceCall classify(ClassifyOptions classifyOptions) { multipartBuilder.addFormDataPart("threshold", String.valueOf(classifyOptions.threshold())); } if (classifyOptions.owners() != null) { - multipartBuilder.addFormDataPart("owners", RequestUtils.join(classifyOptions.owners(), ",")); + for (String item : classifyOptions.owners()) { + multipartBuilder.addFormDataPart("owners", item); + } } if (classifyOptions.classifierIds() != null) { - multipartBuilder.addFormDataPart( - "classifier_ids", RequestUtils.join(classifyOptions.classifierIds(), ",")); + for (String item : classifyOptions.classifierIds()) { + multipartBuilder.addFormDataPart("classifier_ids", item); + } } builder.body(multipartBuilder.build()); ResponseConverter responseConverter = @@ -172,7 +203,7 @@ public ServiceCall classify(ClassifyOptions classifyOptions) { * *

Classify images with built-in or custom classifiers. * - * @return a {@link ServiceCall} with a response type of {@link ClassifiedImages} + * @return a {@link ServiceCall} with a result of type {@link ClassifiedImages} */ public ServiceCall classify() { return classify(null); @@ -198,21 +229,20 @@ public ServiceCall classify() { * * @param createClassifierOptions the {@link CreateClassifierOptions} containing the options for * the call - * @return a {@link ServiceCall} with a response type of {@link Classifier} + * @return a {@link ServiceCall} with a result of type {@link Classifier} */ public ServiceCall createClassifier(CreateClassifierOptions createClassifierOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( createClassifierOptions, "createClassifierOptions cannot be null"); - String[] pathSegments = {"v3/classifiers"}; RequestBuilder builder = - RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); + RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v3/classifiers")); Map sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v3", "createClassifier"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); multipartBuilder.setType(MultipartBody.FORM); multipartBuilder.addFormDataPart("name", createClassifierOptions.name()); @@ -221,18 +251,16 @@ public ServiceCall createClassifier(CreateClassifierOptions createCl String partName = String.format("%s_positive_examples", entry.getKey()); okhttp3.RequestBody part = RequestUtils.inputStreamBody(entry.getValue(), "application/octet-stream"); - multipartBuilder.addFormDataPart(partName, entry.getKey() + ".zip", part); + multipartBuilder.addFormDataPart(partName, entry.getKey(), part); } if (createClassifierOptions.negativeExamples() != null) { okhttp3.RequestBody negativeExamplesBody = RequestUtils.inputStreamBody( createClassifierOptions.negativeExamples(), "application/octet-stream"); - String negativeExamplesFilename = createClassifierOptions.negativeExamplesFilename(); - if (!negativeExamplesFilename.contains(".")) { - negativeExamplesFilename += ".zip"; - } multipartBuilder.addFormDataPart( - "negative_examples", negativeExamplesFilename, negativeExamplesBody); + "negative_examples", + createClassifierOptions.negativeExamplesFilename(), + negativeExamplesBody); } builder.body(multipartBuilder.build()); ResponseConverter responseConverter = @@ -246,23 +274,23 @@ public ServiceCall createClassifier(CreateClassifierOptions createCl * * @param listClassifiersOptions the {@link ListClassifiersOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of {@link Classifiers} + * @return a {@link ServiceCall} with a result of type {@link Classifiers} */ public ServiceCall listClassifiers(ListClassifiersOptions listClassifiersOptions) { - String[] pathSegments = {"v3/classifiers"}; + if (listClassifiersOptions == null) { + listClassifiersOptions = new ListClassifiersOptions.Builder().build(); + } RequestBuilder builder = - RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); + RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v3/classifiers")); Map sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v3", "listClassifiers"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - if (listClassifiersOptions != null) { - if (listClassifiersOptions.verbose() != null) { - builder.query("verbose", String.valueOf(listClassifiersOptions.verbose())); - } + builder.query("version", String.valueOf(this.version)); + if (listClassifiersOptions.verbose() != null) { + builder.query("verbose", String.valueOf(listClassifiersOptions.verbose())); } ResponseConverter responseConverter = ResponseConverterUtils.getValue( @@ -273,7 +301,7 @@ public ServiceCall listClassifiers(ListClassifiersOptions listClass /** * Retrieve a list of classifiers. * - * @return a {@link ServiceCall} with a response type of {@link Classifiers} + * @return a {@link ServiceCall} with a result of type {@link Classifiers} */ public ServiceCall listClassifiers() { return listClassifiers(null); @@ -286,24 +314,24 @@ public ServiceCall listClassifiers() { * * @param getClassifierOptions the {@link GetClassifierOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of {@link Classifier} + * @return a {@link ServiceCall} with a result of type {@link Classifier} */ public ServiceCall getClassifier(GetClassifierOptions getClassifierOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( getClassifierOptions, "getClassifierOptions cannot be null"); - String[] pathSegments = {"v3/classifiers"}; - String[] pathParameters = {getClassifierOptions.classifierId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("classifier_id", getClassifierOptions.classifierId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v3/classifiers/{classifier_id}", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v3", "getClassifier"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken() {}.getType()); @@ -335,7 +363,7 @@ public ServiceCall getClassifier(GetClassifierOptions getClassifierO * * @param updateClassifierOptions the {@link UpdateClassifierOptions} containing the options for * the call - * @return a {@link ServiceCall} with a response type of {@link Classifier} + * @return a {@link ServiceCall} with a result of type {@link Classifier} */ public ServiceCall updateClassifier(UpdateClassifierOptions updateClassifierOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( @@ -344,18 +372,19 @@ public ServiceCall updateClassifier(UpdateClassifierOptions updateCl (updateClassifierOptions.positiveExamples() != null) || (updateClassifierOptions.negativeExamples() != null), "At least one of positiveExamples or negativeExamples must be supplied."); - String[] pathSegments = {"v3/classifiers"}; - String[] pathParameters = {updateClassifierOptions.classifierId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("classifier_id", updateClassifierOptions.classifierId()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v3/classifiers/{classifier_id}", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v3", "updateClassifier"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); multipartBuilder.setType(MultipartBody.FORM); if (updateClassifierOptions.positiveExamples() != null) { @@ -388,24 +417,24 @@ public ServiceCall updateClassifier(UpdateClassifierOptions updateCl * * @param deleteClassifierOptions the {@link DeleteClassifierOptions} containing the options for * the call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteClassifier(DeleteClassifierOptions deleteClassifierOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( deleteClassifierOptions, "deleteClassifierOptions cannot be null"); - String[] pathSegments = {"v3/classifiers"}; - String[] pathParameters = {deleteClassifierOptions.classifierId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("classifier_id", deleteClassifierOptions.classifierId()); RequestBuilder builder = RequestBuilder.delete( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v3/classifiers/{classifier_id}", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v3", "deleteClassifier"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -414,28 +443,28 @@ public ServiceCall deleteClassifier(DeleteClassifierOptions deleteClassifi * Retrieve a Core ML model of a classifier. * *

Download a Core ML model file (.mlmodel) of a custom classifier that returns - * "core_ml_enabled": true in the classifier details. + * <tt>"core_ml_enabled": true</tt> in the classifier details. * * @param getCoreMlModelOptions the {@link GetCoreMlModelOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of {@link InputStream} + * @return a {@link ServiceCall} with a result of type {@link InputStream} */ public ServiceCall getCoreMlModel(GetCoreMlModelOptions getCoreMlModelOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( getCoreMlModelOptions, "getCoreMlModelOptions cannot be null"); - String[] pathSegments = {"v3/classifiers", "core_ml_model"}; - String[] pathParameters = {getCoreMlModelOptions.classifierId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("classifier_id", getCoreMlModelOptions.classifierId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v3/classifiers/{classifier_id}/core_ml_model", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v3", "getCoreMlModel"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/octet-stream"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getInputStream(); return createServiceCall(builder.build(), responseConverter); } @@ -453,22 +482,21 @@ public ServiceCall getCoreMlModel(GetCoreMlModelOptions getCoreMlMo * * @param deleteUserDataOptions the {@link DeleteUserDataOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteUserData(DeleteUserDataOptions deleteUserDataOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( deleteUserDataOptions, "deleteUserDataOptions cannot be null"); - String[] pathSegments = {"v3/user_data"}; RequestBuilder builder = - RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); + RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v3/user_data")); Map sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v3", "deleteUserData"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - builder.query("customer_id", deleteUserDataOptions.customerId()); + builder.query("version", String.valueOf(this.version)); + builder.query("customer_id", String.valueOf(deleteUserDataOptions.customerId())); ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/Class.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/Class.java index 954688b8f56..c3b8663fffb 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/Class.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/Class.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/ClassResult.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/ClassResult.java index a4d75318e17..e6f64d13da0 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/ClassResult.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/ClassResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/ClassifiedImage.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/ClassifiedImage.java index b35bab8ed81..82ba97aa18d 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/ClassifiedImage.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/ClassifiedImage.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/ClassifiedImages.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/ClassifiedImages.java index 2aec0b63d43..84af6b0e08d 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/ClassifiedImages.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/ClassifiedImages.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/Classifier.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/Classifier.java index 270c75a67af..4c3c6250492 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/Classifier.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/Classifier.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/ClassifierResult.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/ClassifierResult.java index 1c5594d809f..b16590523c5 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/ClassifierResult.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/ClassifierResult.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/Classifiers.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/Classifiers.java index 6eb5a5b476b..e7eca2298f1 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/Classifiers.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/Classifiers.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/ClassifyOptions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/ClassifyOptions.java index 350060f8d24..5413b7f4eb3 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/ClassifyOptions.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/ClassifyOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -86,7 +86,7 @@ public Builder() {} /** * Builds a ClassifyOptions. * - * @return the classifyOptions + * @return the new ClassifyOptions instance */ public ClassifyOptions build() { return new ClassifyOptions(this); diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/CreateClassifierOptions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/CreateClassifierOptions.java index e37416f1176..a67c76fbc8e 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/CreateClassifierOptions.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/CreateClassifierOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -57,7 +57,7 @@ public Builder(String name) { /** * Builds a CreateClassifierOptions. * - * @return the createClassifierOptions + * @return the new CreateClassifierOptions instance */ public CreateClassifierOptions build() { return new CreateClassifierOptions(this); diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/DeleteClassifierOptions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/DeleteClassifierOptions.java index 0b4620e59c2..654f35dd83a 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/DeleteClassifierOptions.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/DeleteClassifierOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -42,7 +42,7 @@ public Builder(String classifierId) { /** * Builds a DeleteClassifierOptions. * - * @return the deleteClassifierOptions + * @return the new DeleteClassifierOptions instance */ public DeleteClassifierOptions build() { return new DeleteClassifierOptions(this); diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/DeleteUserDataOptions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/DeleteUserDataOptions.java index c413ea02eb7..9be7cbe33cc 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/DeleteUserDataOptions.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/DeleteUserDataOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -42,7 +42,7 @@ public Builder(String customerId) { /** * Builds a DeleteUserDataOptions. * - * @return the deleteUserDataOptions + * @return the new DeleteUserDataOptions instance */ public DeleteUserDataOptions build() { return new DeleteUserDataOptions(this); diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/ErrorInfo.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/ErrorInfo.java index 07437dbb468..cfad0fa0b5d 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/ErrorInfo.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/ErrorInfo.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/GetClassifierOptions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/GetClassifierOptions.java index 816395d4ce4..44c97e3ba34 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/GetClassifierOptions.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/GetClassifierOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -42,7 +42,7 @@ public Builder(String classifierId) { /** * Builds a GetClassifierOptions. * - * @return the getClassifierOptions + * @return the new GetClassifierOptions instance */ public GetClassifierOptions build() { return new GetClassifierOptions(this); diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/GetCoreMlModelOptions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/GetCoreMlModelOptions.java index ea80529e7d1..775161e7aca 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/GetCoreMlModelOptions.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/GetCoreMlModelOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -42,7 +42,7 @@ public Builder(String classifierId) { /** * Builds a GetCoreMlModelOptions. * - * @return the getCoreMlModelOptions + * @return the new GetCoreMlModelOptions instance */ public GetCoreMlModelOptions build() { return new GetCoreMlModelOptions(this); diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/ListClassifiersOptions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/ListClassifiersOptions.java index 2461a001e8e..5d354568dd2 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/ListClassifiersOptions.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/ListClassifiersOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -33,7 +33,7 @@ public Builder() {} /** * Builds a ListClassifiersOptions. * - * @return the listClassifiersOptions + * @return the new ListClassifiersOptions instance */ public ListClassifiersOptions build() { return new ListClassifiersOptions(this); diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/UpdateClassifierOptions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/UpdateClassifierOptions.java index 2417ff3849d..86fc78aab2b 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/UpdateClassifierOptions.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/UpdateClassifierOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2017, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -57,7 +57,7 @@ public Builder(String classifierId) { /** * Builds a UpdateClassifierOptions. * - * @return the updateClassifierOptions + * @return the new UpdateClassifierOptions instance */ public UpdateClassifierOptions build() { return new UpdateClassifierOptions(this); diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/WarningInfo.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/WarningInfo.java index bd904104db4..e11935d974d 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/WarningInfo.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/model/WarningInfo.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/package-info.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/package-info.java index bd5d83e51f0..379ca125e88 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/package-info.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/package-info.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/VisualRecognition.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/VisualRecognition.java index 976a2063aa7..d7261561656 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/VisualRecognition.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/VisualRecognition.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -10,6 +10,11 @@ * 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. */ + +/* + * IBM OpenAPI SDK Code Generator Version: 99-SNAPSHOT-7cc05500-20201106-154555 + */ + package com.ibm.watson.visual_recognition.v4; import com.google.gson.JsonObject; @@ -20,6 +25,7 @@ import com.ibm.cloud.sdk.core.security.ConfigBasedAuthenticatorFactory; import com.ibm.cloud.sdk.core.service.BaseService; import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.cloud.sdk.core.util.DateUtils; import com.ibm.cloud.sdk.core.util.RequestUtils; import com.ibm.cloud.sdk.core.util.ResponseConverterUtils; import com.ibm.watson.common.SdkCommon; @@ -55,12 +61,13 @@ import com.ibm.watson.visual_recognition.v4.model.UpdateObjectMetadata; import com.ibm.watson.visual_recognition.v4.model.UpdateObjectMetadataOptions; import java.io.InputStream; +import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; import okhttp3.MultipartBody; /** - * Provide images to the IBM Watson™ Visual Recognition service for analysis. The service + * Provide images to the IBM Watson&trade; Visual Recognition service for analysis. The service * detects objects based on a set of images with training data. * * @version v4 @@ -70,66 +77,89 @@ */ public class VisualRecognition extends BaseService { - private static final String DEFAULT_SERVICE_NAME = "visual_recognition"; + public static final String DEFAULT_SERVICE_NAME = "watson_vision_combined"; - private static final String DEFAULT_SERVICE_URL = + public static final String DEFAULT_SERVICE_URL = "https://api.us-south.visual-recognition.watson.cloud.ibm.com"; - private String versionDate; + private String version; /** - * Constructs a new `VisualRecognition` client using the DEFAULT_SERVICE_NAME. + * Constructs an instance of the `VisualRecognition` client. The default service name is used to + * configure the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value - * will keep your API calls from failing when the service introduces breaking changes. + * @param version Release date of the API version you want to use. Specify dates in YYYY-MM-DD + * format. The current version is `2019-02-11`. */ - public VisualRecognition(String versionDate) { + public VisualRecognition(String version) { this( - versionDate, + version, DEFAULT_SERVICE_NAME, ConfigBasedAuthenticatorFactory.getAuthenticator(DEFAULT_SERVICE_NAME)); } /** - * Constructs a new `VisualRecognition` client with the DEFAULT_SERVICE_NAME and the specified - * Authenticator. + * Constructs an instance of the `VisualRecognition` client. The default service name and + * specified authenticator are used to configure the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value - * will keep your API calls from failing when the service introduces breaking changes. - * @param authenticator the Authenticator instance to be configured for this service + * @param version Release date of the API version you want to use. Specify dates in YYYY-MM-DD + * format. The current version is `2019-02-11`. + * @param authenticator the {@link Authenticator} instance to be configured for this client */ - public VisualRecognition(String versionDate, Authenticator authenticator) { - this(versionDate, DEFAULT_SERVICE_NAME, authenticator); + public VisualRecognition(String version, Authenticator authenticator) { + this(version, DEFAULT_SERVICE_NAME, authenticator); } /** - * Constructs a new `VisualRecognition` client with the specified serviceName. + * Constructs an instance of the `VisualRecognition` client. The specified service name is used to + * configure the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value - * will keep your API calls from failing when the service introduces breaking changes. - * @param serviceName The name of the service to configure. + * @param version Release date of the API version you want to use. Specify dates in YYYY-MM-DD + * format. The current version is `2019-02-11`. + * @param serviceName the service name to be used when configuring the client instance */ - public VisualRecognition(String versionDate, String serviceName) { - this(versionDate, serviceName, ConfigBasedAuthenticatorFactory.getAuthenticator(serviceName)); + public VisualRecognition(String version, String serviceName) { + this(version, serviceName, ConfigBasedAuthenticatorFactory.getAuthenticator(serviceName)); } /** - * Constructs a new `VisualRecognition` client with the specified Authenticator and serviceName. + * Constructs an instance of the `VisualRecognition` client. The specified service name and + * authenticator are used to configure the client instance. * - * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value - * will keep your API calls from failing when the service introduces breaking changes. - * @param serviceName The name of the service to configure. - * @param authenticator the Authenticator instance to be configured for this service + * @param version Release date of the API version you want to use. Specify dates in YYYY-MM-DD + * format. The current version is `2019-02-11`. + * @param serviceName the service name to be used when configuring the client instance + * @param authenticator the {@link Authenticator} instance to be configured for this client */ - public VisualRecognition(String versionDate, String serviceName, Authenticator authenticator) { + public VisualRecognition(String version, String serviceName, Authenticator authenticator) { super(serviceName, authenticator); setServiceUrl(DEFAULT_SERVICE_URL); - com.ibm.cloud.sdk.core.util.Validator.isTrue( - (versionDate != null) && !versionDate.isEmpty(), "version cannot be null."); - this.versionDate = versionDate; + setVersion(version); this.configureService(serviceName); } + /** + * Gets the version. + * + *

Release date of the API version you want to use. Specify dates in YYYY-MM-DD format. The + * current version is `2019-02-11`. + * + * @return the version + */ + public String getVersion() { + return this.version; + } + + /** + * Sets the version. + * + * @param version the new version + */ + public void setVersion(final String version) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(version, "version cannot be empty."); + this.version = version; + } + /** * Analyze images. * @@ -141,25 +171,27 @@ public VisualRecognition(String versionDate, String serviceName, Authenticator a * service assumes UTF-8 encoding if it encounters non-ASCII characters. * * @param analyzeOptions the {@link AnalyzeOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link AnalyzeResponse} + * @return a {@link ServiceCall} with a result of type {@link AnalyzeResponse} */ public ServiceCall analyze(AnalyzeOptions analyzeOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull(analyzeOptions, "analyzeOptions cannot be null"); - String[] pathSegments = {"v4/analyze"}; RequestBuilder builder = - RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); + RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v4/analyze")); Map sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v4", "analyze"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); multipartBuilder.setType(MultipartBody.FORM); - multipartBuilder.addFormDataPart( - "collection_ids", RequestUtils.join(analyzeOptions.collectionIds(), ",")); - multipartBuilder.addFormDataPart("features", RequestUtils.join(analyzeOptions.features(), ",")); + for (String item : analyzeOptions.collectionIds()) { + multipartBuilder.addFormDataPart("collection_ids", item); + } + for (String item : analyzeOptions.features()) { + multipartBuilder.addFormDataPart("features", item); + } if (analyzeOptions.imagesFile() != null) { for (FileWithMetadata item : analyzeOptions.imagesFile()) { okhttp3.RequestBody itemBody = @@ -195,29 +227,32 @@ public ServiceCall analyze(AnalyzeOptions analyzeOptions) { * * @param createCollectionOptions the {@link CreateCollectionOptions} containing the options for * the call - * @return a {@link ServiceCall} with a response type of {@link Collection} + * @return a {@link ServiceCall} with a result of type {@link Collection} */ public ServiceCall createCollection(CreateCollectionOptions createCollectionOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( createCollectionOptions, "createCollectionOptions cannot be null"); - String[] pathSegments = {"v4/collections"}; RequestBuilder builder = - RequestBuilder.post(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); + RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v4/collections")); Map sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v4", "createCollection"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); final JsonObject contentJson = new JsonObject(); - if (createCollectionOptions != null) { - if (createCollectionOptions.name() != null) { - contentJson.addProperty("name", createCollectionOptions.name()); - } - if (createCollectionOptions.description() != null) { - contentJson.addProperty("description", createCollectionOptions.description()); - } + if (createCollectionOptions.name() != null) { + contentJson.addProperty("name", createCollectionOptions.name()); + } + if (createCollectionOptions.description() != null) { + contentJson.addProperty("description", createCollectionOptions.description()); + } + if (createCollectionOptions.trainingStatus() != null) { + contentJson.add( + "training_status", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(createCollectionOptions.trainingStatus())); } builder.bodyJson(contentJson); ResponseConverter responseConverter = @@ -237,7 +272,7 @@ public ServiceCall createCollection(CreateCollectionOptions createCo *

Encode the name and description in UTF-8 if they contain non-ASCII characters. The service * assumes UTF-8 encoding if it encounters non-ASCII characters. * - * @return a {@link ServiceCall} with a response type of {@link Collection} + * @return a {@link ServiceCall} with a result of type {@link Collection} */ public ServiceCall createCollection() { return createCollection(null); @@ -250,22 +285,19 @@ public ServiceCall createCollection() { * * @param listCollectionsOptions the {@link ListCollectionsOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of {@link CollectionsList} + * @return a {@link ServiceCall} with a result of type {@link CollectionsList} */ public ServiceCall listCollections( ListCollectionsOptions listCollectionsOptions) { - String[] pathSegments = {"v4/collections"}; RequestBuilder builder = - RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); + RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v4/collections")); Map sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v4", "listCollections"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - if (listCollectionsOptions != null) {} - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken() {}.getType()); @@ -277,7 +309,7 @@ public ServiceCall listCollections( * *

Retrieves a list of collections for the service instance. * - * @return a {@link ServiceCall} with a response type of {@link CollectionsList} + * @return a {@link ServiceCall} with a result of type {@link CollectionsList} */ public ServiceCall listCollections() { return listCollections(null); @@ -290,24 +322,24 @@ public ServiceCall listCollections() { * * @param getCollectionOptions the {@link GetCollectionOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of {@link Collection} + * @return a {@link ServiceCall} with a result of type {@link Collection} */ public ServiceCall getCollection(GetCollectionOptions getCollectionOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( getCollectionOptions, "getCollectionOptions cannot be null"); - String[] pathSegments = {"v4/collections"}; - String[] pathParameters = {getCollectionOptions.collectionId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("collection_id", getCollectionOptions.collectionId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v4/collections/{collection_id}", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v4", "getCollection"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken() {}.getType()); @@ -324,23 +356,24 @@ public ServiceCall getCollection(GetCollectionOptions getCollectionO * * @param updateCollectionOptions the {@link UpdateCollectionOptions} containing the options for * the call - * @return a {@link ServiceCall} with a response type of {@link Collection} + * @return a {@link ServiceCall} with a result of type {@link Collection} */ public ServiceCall updateCollection(UpdateCollectionOptions updateCollectionOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( updateCollectionOptions, "updateCollectionOptions cannot be null"); - String[] pathSegments = {"v4/collections"}; - String[] pathParameters = {updateCollectionOptions.collectionId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("collection_id", updateCollectionOptions.collectionId()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v4/collections/{collection_id}", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v4", "updateCollection"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); final JsonObject contentJson = new JsonObject(); if (updateCollectionOptions.name() != null) { contentJson.addProperty("name", updateCollectionOptions.name()); @@ -348,6 +381,12 @@ public ServiceCall updateCollection(UpdateCollectionOptions updateCo if (updateCollectionOptions.description() != null) { contentJson.addProperty("description", updateCollectionOptions.description()); } + if (updateCollectionOptions.trainingStatus() != null) { + contentJson.add( + "training_status", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(updateCollectionOptions.trainingStatus())); + } builder.bodyJson(contentJson); ResponseConverter responseConverter = ResponseConverterUtils.getValue( @@ -362,24 +401,24 @@ public ServiceCall updateCollection(UpdateCollectionOptions updateCo * * @param deleteCollectionOptions the {@link DeleteCollectionOptions} containing the options for * the call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteCollection(DeleteCollectionOptions deleteCollectionOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( deleteCollectionOptions, "deleteCollectionOptions cannot be null"); - String[] pathSegments = {"v4/collections"}; - String[] pathParameters = {deleteCollectionOptions.collectionId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("collection_id", deleteCollectionOptions.collectionId()); RequestBuilder builder = RequestBuilder.delete( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v4/collections/{collection_id}", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v4", "deleteCollection"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -397,25 +436,26 @@ public ServiceCall deleteCollection(DeleteCollectionOptions deleteCollecti * Android](https://github.com/matt-ny/rscnn) project in GitHub. * * @param getModelFileOptions the {@link GetModelFileOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link InputStream} + * @return a {@link ServiceCall} with a result of type {@link InputStream} */ public ServiceCall getModelFile(GetModelFileOptions getModelFileOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( getModelFileOptions, "getModelFileOptions cannot be null"); - String[] pathSegments = {"v4/collections", "model"}; - String[] pathParameters = {getModelFileOptions.collectionId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("collection_id", getModelFileOptions.collectionId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v4/collections/{collection_id}/model", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v4", "getModelFile"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/octet-stream"); - builder.query("feature", getModelFileOptions.feature()); - builder.query("model_format", getModelFileOptions.modelFormat()); + builder.query("version", String.valueOf(this.version)); + builder.query("feature", String.valueOf(getModelFileOptions.feature())); + builder.query("model_format", String.valueOf(getModelFileOptions.modelFormat())); ResponseConverter responseConverter = ResponseConverterUtils.getInputStream(); return createServiceCall(builder.build(), responseConverter); } @@ -429,7 +469,7 @@ public ServiceCall getModelFile(GetModelFileOptions getModelFileOpt * service assumes UTF-8 encoding if it encounters non-ASCII characters. * * @param addImagesOptions the {@link AddImagesOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link ImageDetailsList} + * @return a {@link ServiceCall} with a result of type {@link ImageDetailsList} */ public ServiceCall addImages(AddImagesOptions addImagesOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( @@ -439,18 +479,19 @@ public ServiceCall addImages(AddImagesOptions addImagesOptions || (addImagesOptions.imageUrl() != null) || (addImagesOptions.trainingData() != null), "At least one of imagesFile, imageUrl, or trainingData must be supplied."); - String[] pathSegments = {"v4/collections", "images"}; - String[] pathParameters = {addImagesOptions.collectionId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("collection_id", addImagesOptions.collectionId()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v4/collections/{collection_id}/images", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v4", "addImages"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); multipartBuilder.setType(MultipartBody.FORM); if (addImagesOptions.imagesFile() != null) { @@ -481,24 +522,24 @@ public ServiceCall addImages(AddImagesOptions addImagesOptions *

Retrieves a list of images in a collection. * * @param listImagesOptions the {@link ListImagesOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link ImageSummaryList} + * @return a {@link ServiceCall} with a result of type {@link ImageSummaryList} */ public ServiceCall listImages(ListImagesOptions listImagesOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( listImagesOptions, "listImagesOptions cannot be null"); - String[] pathSegments = {"v4/collections", "images"}; - String[] pathParameters = {listImagesOptions.collectionId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("collection_id", listImagesOptions.collectionId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v4/collections/{collection_id}/images", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v4", "listImages"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken() {}.getType()); @@ -512,26 +553,27 @@ public ServiceCall listImages(ListImagesOptions listImagesOpti * * @param getImageDetailsOptions the {@link GetImageDetailsOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of {@link ImageDetails} + * @return a {@link ServiceCall} with a result of type {@link ImageDetails} */ public ServiceCall getImageDetails(GetImageDetailsOptions getImageDetailsOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( getImageDetailsOptions, "getImageDetailsOptions cannot be null"); - String[] pathSegments = {"v4/collections", "images"}; - String[] pathParameters = { - getImageDetailsOptions.collectionId(), getImageDetailsOptions.imageId() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("collection_id", getImageDetailsOptions.collectionId()); + pathParamsMap.put("image_id", getImageDetailsOptions.imageId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v4/collections/{collection_id}/images/{image_id}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v4", "getImageDetails"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken() {}.getType()); @@ -544,24 +586,27 @@ public ServiceCall getImageDetails(GetImageDetailsOptions getImage *

Delete one image from a collection. * * @param deleteImageOptions the {@link DeleteImageOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteImage(DeleteImageOptions deleteImageOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( deleteImageOptions, "deleteImageOptions cannot be null"); - String[] pathSegments = {"v4/collections", "images"}; - String[] pathParameters = {deleteImageOptions.collectionId(), deleteImageOptions.imageId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("collection_id", deleteImageOptions.collectionId()); + pathParamsMap.put("image_id", deleteImageOptions.imageId()); RequestBuilder builder = RequestBuilder.delete( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v4/collections/{collection_id}/images/{image_id}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v4", "deleteImage"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -572,25 +617,29 @@ public ServiceCall deleteImage(DeleteImageOptions deleteImageOptions) { *

Download a JPEG representation of an image. * * @param getJpegImageOptions the {@link GetJpegImageOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link InputStream} + * @return a {@link ServiceCall} with a result of type {@link InputStream} */ public ServiceCall getJpegImage(GetJpegImageOptions getJpegImageOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( getJpegImageOptions, "getJpegImageOptions cannot be null"); - String[] pathSegments = {"v4/collections", "images", "jpeg"}; - String[] pathParameters = {getJpegImageOptions.collectionId(), getJpegImageOptions.imageId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("collection_id", getJpegImageOptions.collectionId()); + pathParamsMap.put("image_id", getJpegImageOptions.imageId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v4/collections/{collection_id}/images/{image_id}/jpeg", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v4", "getJpegImage"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "image/jpeg"); + builder.query("version", String.valueOf(this.version)); if (getJpegImageOptions.size() != null) { - builder.query("size", getJpegImageOptions.size()); + builder.query("size", String.valueOf(getJpegImageOptions.size())); } ResponseConverter responseConverter = ResponseConverterUtils.getInputStream(); return createServiceCall(builder.build(), responseConverter); @@ -603,25 +652,25 @@ public ServiceCall getJpegImage(GetJpegImageOptions getJpegImageOpt * * @param listObjectMetadataOptions the {@link ListObjectMetadataOptions} containing the options * for the call - * @return a {@link ServiceCall} with a response type of {@link ObjectMetadataList} + * @return a {@link ServiceCall} with a result of type {@link ObjectMetadataList} */ public ServiceCall listObjectMetadata( ListObjectMetadataOptions listObjectMetadataOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( listObjectMetadataOptions, "listObjectMetadataOptions cannot be null"); - String[] pathSegments = {"v4/collections", "objects"}; - String[] pathParameters = {listObjectMetadataOptions.collectionId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("collection_id", listObjectMetadataOptions.collectionId()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v4/collections/{collection_id}/objects", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v4", "listObjectMetadata"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken() {}.getType()); @@ -636,26 +685,28 @@ public ServiceCall listObjectMetadata( * * @param updateObjectMetadataOptions the {@link UpdateObjectMetadataOptions} containing the * options for the call - * @return a {@link ServiceCall} with a response type of {@link UpdateObjectMetadata} + * @return a {@link ServiceCall} with a result of type {@link UpdateObjectMetadata} */ public ServiceCall updateObjectMetadata( UpdateObjectMetadataOptions updateObjectMetadataOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( updateObjectMetadataOptions, "updateObjectMetadataOptions cannot be null"); - String[] pathSegments = {"v4/collections", "objects"}; - String[] pathParameters = { - updateObjectMetadataOptions.collectionId(), updateObjectMetadataOptions.object() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("collection_id", updateObjectMetadataOptions.collectionId()); + pathParamsMap.put("object", updateObjectMetadataOptions.object()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v4/collections/{collection_id}/objects/{object}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v4", "updateObjectMetadata"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); final JsonObject contentJson = new JsonObject(); contentJson.addProperty("object", updateObjectMetadataOptions.newObject()); builder.bodyJson(contentJson); @@ -672,27 +723,28 @@ public ServiceCall updateObjectMetadata( * * @param getObjectMetadataOptions the {@link GetObjectMetadataOptions} containing the options for * the call - * @return a {@link ServiceCall} with a response type of {@link ObjectMetadata} + * @return a {@link ServiceCall} with a result of type {@link ObjectMetadata} */ public ServiceCall getObjectMetadata( GetObjectMetadataOptions getObjectMetadataOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( getObjectMetadataOptions, "getObjectMetadataOptions cannot be null"); - String[] pathSegments = {"v4/collections", "objects"}; - String[] pathParameters = { - getObjectMetadataOptions.collectionId(), getObjectMetadataOptions.object() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("collection_id", getObjectMetadataOptions.collectionId()); + pathParamsMap.put("object", getObjectMetadataOptions.object()); RequestBuilder builder = RequestBuilder.get( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v4/collections/{collection_id}/objects/{object}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v4", "getObjectMetadata"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken() {}.getType()); @@ -706,24 +758,27 @@ public ServiceCall getObjectMetadata( * images that use the object. * * @param deleteObjectOptions the {@link DeleteObjectOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteObject(DeleteObjectOptions deleteObjectOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( deleteObjectOptions, "deleteObjectOptions cannot be null"); - String[] pathSegments = {"v4/collections", "objects"}; - String[] pathParameters = {deleteObjectOptions.collectionId(), deleteObjectOptions.object()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("collection_id", deleteObjectOptions.collectionId()); + pathParamsMap.put("object", deleteObjectOptions.object()); RequestBuilder builder = RequestBuilder.delete( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v4/collections/{collection_id}/objects/{object}", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v4", "deleteObject"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } @@ -736,23 +791,23 @@ public ServiceCall deleteObject(DeleteObjectOptions deleteObjectOptions) { * progress, the request queues the next training job. * * @param trainOptions the {@link TrainOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Collection} + * @return a {@link ServiceCall} with a result of type {@link Collection} */ public ServiceCall train(TrainOptions trainOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull(trainOptions, "trainOptions cannot be null"); - String[] pathSegments = {"v4/collections", "train"}; - String[] pathParameters = {trainOptions.collectionId()}; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("collection_id", trainOptions.collectionId()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), "/v4/collections/{collection_id}/train", pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v4", "train"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - + builder.query("version", String.valueOf(this.version)); ResponseConverter responseConverter = ResponseConverterUtils.getValue( new com.google.gson.reflect.TypeToken() {}.getType()); @@ -774,26 +829,28 @@ public ServiceCall train(TrainOptions trainOptions) { * * @param addImageTrainingDataOptions the {@link AddImageTrainingDataOptions} containing the * options for the call - * @return a {@link ServiceCall} with a response type of {@link TrainingDataObjects} + * @return a {@link ServiceCall} with a result of type {@link TrainingDataObjects} */ public ServiceCall addImageTrainingData( AddImageTrainingDataOptions addImageTrainingDataOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( addImageTrainingDataOptions, "addImageTrainingDataOptions cannot be null"); - String[] pathSegments = {"v4/collections", "images", "training_data"}; - String[] pathParameters = { - addImageTrainingDataOptions.collectionId(), addImageTrainingDataOptions.imageId() - }; + Map pathParamsMap = new HashMap(); + pathParamsMap.put("collection_id", addImageTrainingDataOptions.collectionId()); + pathParamsMap.put("image_id", addImageTrainingDataOptions.imageId()); RequestBuilder builder = RequestBuilder.post( - RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments, pathParameters)); - builder.query("version", versionDate); + RequestBuilder.resolveRequestUrl( + getServiceUrl(), + "/v4/collections/{collection_id}/images/{image_id}/training_data", + pathParamsMap)); Map sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v4", "addImageTrainingData"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); final JsonObject contentJson = new JsonObject(); if (addImageTrainingDataOptions.objects() != null) { contentJson.add( @@ -816,27 +873,27 @@ public ServiceCall addImageTrainingData( * * @param getTrainingUsageOptions the {@link GetTrainingUsageOptions} containing the options for * the call - * @return a {@link ServiceCall} with a response type of {@link TrainingEvents} + * @return a {@link ServiceCall} with a result of type {@link TrainingEvents} */ public ServiceCall getTrainingUsage( GetTrainingUsageOptions getTrainingUsageOptions) { - String[] pathSegments = {"v4/training_usage"}; + if (getTrainingUsageOptions == null) { + getTrainingUsageOptions = new GetTrainingUsageOptions.Builder().build(); + } RequestBuilder builder = - RequestBuilder.get(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); + RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v4/training_usage")); Map sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v4", "getTrainingUsage"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - if (getTrainingUsageOptions != null) { - if (getTrainingUsageOptions.startTime() != null) { - builder.query("start_time", getTrainingUsageOptions.startTime()); - } - if (getTrainingUsageOptions.endTime() != null) { - builder.query("end_time", getTrainingUsageOptions.endTime()); - } + builder.query("version", String.valueOf(this.version)); + if (getTrainingUsageOptions.startTime() != null) { + builder.query("start_time", DateUtils.formatAsDate(getTrainingUsageOptions.startTime())); + } + if (getTrainingUsageOptions.endTime() != null) { + builder.query("end_time", DateUtils.formatAsDate(getTrainingUsageOptions.endTime())); } ResponseConverter responseConverter = ResponseConverterUtils.getValue( @@ -850,7 +907,7 @@ public ServiceCall getTrainingUsage( *

Information about the completed training events. You can use this information to determine * how close you are to the training limits for the month. * - * @return a {@link ServiceCall} with a response type of {@link TrainingEvents} + * @return a {@link ServiceCall} with a result of type {@link TrainingEvents} */ public ServiceCall getTrainingUsage() { return getTrainingUsage(null); @@ -869,22 +926,21 @@ public ServiceCall getTrainingUsage() { * * @param deleteUserDataOptions the {@link DeleteUserDataOptions} containing the options for the * call - * @return a {@link ServiceCall} with a response type of Void + * @return a {@link ServiceCall} with a void result */ public ServiceCall deleteUserData(DeleteUserDataOptions deleteUserDataOptions) { com.ibm.cloud.sdk.core.util.Validator.notNull( deleteUserDataOptions, "deleteUserDataOptions cannot be null"); - String[] pathSegments = {"v4/user_data"}; RequestBuilder builder = - RequestBuilder.delete(RequestBuilder.constructHttpUrl(getServiceUrl(), pathSegments)); - builder.query("version", versionDate); + RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v4/user_data")); Map sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v4", "deleteUserData"); for (Entry header : sdkHeaders.entrySet()) { builder.header(header.getKey(), header.getValue()); } builder.header("Accept", "application/json"); - builder.query("customer_id", deleteUserDataOptions.customerId()); + builder.query("version", String.valueOf(this.version)); + builder.query("customer_id", String.valueOf(deleteUserDataOptions.customerId())); ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); return createServiceCall(builder.build(), responseConverter); } diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/AddImageTrainingDataOptions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/AddImageTrainingDataOptions.java index 5b596a5e9ff..5e6b90c953e 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/AddImageTrainingDataOptions.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/AddImageTrainingDataOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -52,7 +52,7 @@ public Builder(String collectionId, String imageId) { /** * Builds a AddImageTrainingDataOptions. * - * @return the addImageTrainingDataOptions + * @return the new AddImageTrainingDataOptions instance */ public AddImageTrainingDataOptions build() { return new AddImageTrainingDataOptions(this); diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/AddImagesOptions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/AddImagesOptions.java index 1b47c6f5d26..a2b732b357f 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/AddImagesOptions.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/AddImagesOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -54,7 +54,7 @@ public Builder(String collectionId) { /** * Builds a AddImagesOptions. * - * @return the addImagesOptions + * @return the new AddImagesOptions instance */ public AddImagesOptions build() { return new AddImagesOptions(this); diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/AnalyzeOptions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/AnalyzeOptions.java index 75b6b1a8387..2907957d0a5 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/AnalyzeOptions.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/AnalyzeOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -64,7 +64,7 @@ public Builder(List collectionIds, List features) { /** * Builds a AnalyzeOptions. * - * @return the analyzeOptions + * @return the new AnalyzeOptions instance */ public AnalyzeOptions build() { return new AnalyzeOptions(this); diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/AnalyzeResponse.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/AnalyzeResponse.java index 44d59f2912d..a5a3c5201a3 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/AnalyzeResponse.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/AnalyzeResponse.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/Collection.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/Collection.java index 5f7bded69d7..9ce7b56cd55 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/Collection.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/Collection.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -31,7 +31,7 @@ public class Collection extends GenericModel { protected Long imageCount; @SerializedName("training_status") - protected TrainingStatus trainingStatus; + protected CollectionTrainingStatus trainingStatus; /** * Gets the collectionId. @@ -107,7 +107,7 @@ public Long getImageCount() { * * @return the trainingStatus */ - public TrainingStatus getTrainingStatus() { + public CollectionTrainingStatus getTrainingStatus() { return trainingStatus; } } diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/CollectionObjects.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/CollectionObjects.java index 1a6f829a3f1..ad5a92a2c6b 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/CollectionObjects.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/CollectionObjects.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/CollectionTrainingStatus.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/CollectionTrainingStatus.java new file mode 100644 index 00000000000..55380c8ca57 --- /dev/null +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/CollectionTrainingStatus.java @@ -0,0 +1,32 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v4.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** Training status information for the collection. */ +public class CollectionTrainingStatus extends GenericModel { + + protected ObjectTrainingStatus objects; + + /** + * Gets the objects. + * + *

Training status for the objects in the collection. + * + * @return the objects + */ + public ObjectTrainingStatus getObjects() { + return objects; + } +} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/CollectionsList.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/CollectionsList.java index 71c60b41ecf..3320d658fa1 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/CollectionsList.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/CollectionsList.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/CreateCollectionOptions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/CreateCollectionOptions.java index 6f9f8a9c393..dd93c64a946 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/CreateCollectionOptions.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/CreateCollectionOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -19,15 +19,18 @@ public class CreateCollectionOptions extends GenericModel { protected String name; protected String description; + protected TrainingStatus trainingStatus; /** Builder. */ public static class Builder { private String name; private String description; + private TrainingStatus trainingStatus; private Builder(CreateCollectionOptions createCollectionOptions) { this.name = createCollectionOptions.name; this.description = createCollectionOptions.description; + this.trainingStatus = createCollectionOptions.trainingStatus; } /** Instantiates a new builder. */ @@ -36,7 +39,7 @@ public Builder() {} /** * Builds a CreateCollectionOptions. * - * @return the createCollectionOptions + * @return the new CreateCollectionOptions instance */ public CreateCollectionOptions build() { return new CreateCollectionOptions(this); @@ -63,11 +66,23 @@ public Builder description(String description) { this.description = description; return this; } + + /** + * Set the trainingStatus. + * + * @param trainingStatus the trainingStatus + * @return the CreateCollectionOptions builder + */ + public Builder trainingStatus(TrainingStatus trainingStatus) { + this.trainingStatus = trainingStatus; + return this; + } } protected CreateCollectionOptions(Builder builder) { name = builder.name; description = builder.description; + trainingStatus = builder.trainingStatus; } /** @@ -101,4 +116,15 @@ public String name() { public String description() { return description; } + + /** + * Gets the trainingStatus. + * + *

Training status information for the collection. + * + * @return the trainingStatus + */ + public TrainingStatus trainingStatus() { + return trainingStatus; + } } diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/DeleteCollectionOptions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/DeleteCollectionOptions.java index 7a0a4f84cbd..f05bab03c25 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/DeleteCollectionOptions.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/DeleteCollectionOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -42,7 +42,7 @@ public Builder(String collectionId) { /** * Builds a DeleteCollectionOptions. * - * @return the deleteCollectionOptions + * @return the new DeleteCollectionOptions instance */ public DeleteCollectionOptions build() { return new DeleteCollectionOptions(this); diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/DeleteImageOptions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/DeleteImageOptions.java index e2c3f822025..e6b183aab73 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/DeleteImageOptions.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/DeleteImageOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -47,7 +47,7 @@ public Builder(String collectionId, String imageId) { /** * Builds a DeleteImageOptions. * - * @return the deleteImageOptions + * @return the new DeleteImageOptions instance */ public DeleteImageOptions build() { return new DeleteImageOptions(this); diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/DeleteObjectOptions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/DeleteObjectOptions.java index b62363aef03..866c9382c33 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/DeleteObjectOptions.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/DeleteObjectOptions.java @@ -47,7 +47,7 @@ public Builder(String collectionId, String object) { /** * Builds a DeleteObjectOptions. * - * @return the deleteObjectOptions + * @return the new DeleteObjectOptions instance */ public DeleteObjectOptions build() { return new DeleteObjectOptions(this); diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/DeleteUserDataOptions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/DeleteUserDataOptions.java index 0f778f33490..3b358799033 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/DeleteUserDataOptions.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/DeleteUserDataOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2018, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -42,7 +42,7 @@ public Builder(String customerId) { /** * Builds a DeleteUserDataOptions. * - * @return the deleteUserDataOptions + * @return the new DeleteUserDataOptions instance */ public DeleteUserDataOptions build() { return new DeleteUserDataOptions(this); diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/DetectedObjects.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/DetectedObjects.java index 7689f5cd425..431c33c8d63 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/DetectedObjects.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/DetectedObjects.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/Error.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/Error.java index 5e870776b5a..ee503ed4420 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/Error.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/Error.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ErrorTarget.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ErrorTarget.java index a3a9dc83c82..99be2d0ca0d 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ErrorTarget.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ErrorTarget.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/GetCollectionOptions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/GetCollectionOptions.java index ab14fadab87..fb2bc2fe759 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/GetCollectionOptions.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/GetCollectionOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -42,7 +42,7 @@ public Builder(String collectionId) { /** * Builds a GetCollectionOptions. * - * @return the getCollectionOptions + * @return the new GetCollectionOptions instance */ public GetCollectionOptions build() { return new GetCollectionOptions(this); diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/GetImageDetailsOptions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/GetImageDetailsOptions.java index 031cef5f97f..e20e0f03e72 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/GetImageDetailsOptions.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/GetImageDetailsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -47,7 +47,7 @@ public Builder(String collectionId, String imageId) { /** * Builds a GetImageDetailsOptions. * - * @return the getImageDetailsOptions + * @return the new GetImageDetailsOptions instance */ public GetImageDetailsOptions build() { return new GetImageDetailsOptions(this); diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/GetJpegImageOptions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/GetJpegImageOptions.java index 8425248aecf..975386929d5 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/GetJpegImageOptions.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/GetJpegImageOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -62,7 +62,7 @@ public Builder(String collectionId, String imageId) { /** * Builds a GetJpegImageOptions. * - * @return the getJpegImageOptions + * @return the new GetJpegImageOptions instance */ public GetJpegImageOptions build() { return new GetJpegImageOptions(this); diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/GetModelFileOptions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/GetModelFileOptions.java index e968fe85063..3a3415005f6 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/GetModelFileOptions.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/GetModelFileOptions.java @@ -64,7 +64,7 @@ public Builder(String collectionId, String feature, String modelFormat) { /** * Builds a GetModelFileOptions. * - * @return the getModelFileOptions + * @return the new GetModelFileOptions instance */ public GetModelFileOptions build() { return new GetModelFileOptions(this); diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/GetObjectMetadataOptions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/GetObjectMetadataOptions.java index 17fcb37fe96..a5a97ebb7bd 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/GetObjectMetadataOptions.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/GetObjectMetadataOptions.java @@ -47,7 +47,7 @@ public Builder(String collectionId, String object) { /** * Builds a GetObjectMetadataOptions. * - * @return the getObjectMetadataOptions + * @return the new GetObjectMetadataOptions instance */ public GetObjectMetadataOptions build() { return new GetObjectMetadataOptions(this); diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/GetTrainingUsageOptions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/GetTrainingUsageOptions.java index 93c1588e7d2..76ee6d28754 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/GetTrainingUsageOptions.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/GetTrainingUsageOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -13,17 +13,18 @@ package com.ibm.watson.visual_recognition.v4.model; import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.Date; /** The getTrainingUsage options. */ public class GetTrainingUsageOptions extends GenericModel { - protected String startTime; - protected String endTime; + protected Date startTime; + protected Date endTime; /** Builder. */ public static class Builder { - private String startTime; - private String endTime; + private Date startTime; + private Date endTime; private Builder(GetTrainingUsageOptions getTrainingUsageOptions) { this.startTime = getTrainingUsageOptions.startTime; @@ -36,7 +37,7 @@ public Builder() {} /** * Builds a GetTrainingUsageOptions. * - * @return the getTrainingUsageOptions + * @return the new GetTrainingUsageOptions instance */ public GetTrainingUsageOptions build() { return new GetTrainingUsageOptions(this); @@ -48,7 +49,7 @@ public GetTrainingUsageOptions build() { * @param startTime the startTime * @return the GetTrainingUsageOptions builder */ - public Builder startTime(String startTime) { + public Builder startTime(Date startTime) { this.startTime = startTime; return this; } @@ -59,7 +60,7 @@ public Builder startTime(String startTime) { * @param endTime the endTime * @return the GetTrainingUsageOptions builder */ - public Builder endTime(String endTime) { + public Builder endTime(Date endTime) { this.endTime = endTime; return this; } @@ -87,7 +88,7 @@ public Builder newBuilder() { * * @return the startTime */ - public String startTime() { + public Date startTime() { return startTime; } @@ -100,7 +101,7 @@ public String startTime() { * * @return the endTime */ - public String endTime() { + public Date endTime() { return endTime; } } diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/Image.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/Image.java index b2448d9701b..c8ff48160d2 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/Image.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/Image.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ImageDetails.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ImageDetails.java index 5d4efb239cf..a4659812e98 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ImageDetails.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ImageDetails.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ImageDetailsList.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ImageDetailsList.java index a523d6c3a53..8885b85ec65 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ImageDetailsList.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ImageDetailsList.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ImageDimensions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ImageDimensions.java index 61628c78af8..a29ca0f29e9 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ImageDimensions.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ImageDimensions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ImageSource.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ImageSource.java index 91741321448..421de271c70 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ImageSource.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ImageSource.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ImageSummary.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ImageSummary.java index e436958ef74..b697b1b9b57 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ImageSummary.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ImageSummary.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ImageSummaryList.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ImageSummaryList.java index 249fa1da4c0..5cc6519e359 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ImageSummaryList.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ImageSummaryList.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ListCollectionsOptions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ListCollectionsOptions.java index bd1c284500c..5026a11d24f 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ListCollectionsOptions.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ListCollectionsOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -15,34 +15,4 @@ import com.ibm.cloud.sdk.core.service.model.GenericModel; /** The listCollections options. */ -public class ListCollectionsOptions extends GenericModel { - - /** Builder. */ - public static class Builder { - - private Builder(ListCollectionsOptions listCollectionsOptions) {} - - /** Instantiates a new builder. */ - public Builder() {} - - /** - * Builds a ListCollectionsOptions. - * - * @return the listCollectionsOptions - */ - public ListCollectionsOptions build() { - return new ListCollectionsOptions(this); - } - } - - private ListCollectionsOptions(Builder builder) {} - - /** - * New builder. - * - * @return a ListCollectionsOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } -} +public class ListCollectionsOptions extends GenericModel {} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ListImagesOptions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ListImagesOptions.java index ca53a02d098..26529e189d2 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ListImagesOptions.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ListImagesOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -42,7 +42,7 @@ public Builder(String collectionId) { /** * Builds a ListImagesOptions. * - * @return the listImagesOptions + * @return the new ListImagesOptions instance */ public ListImagesOptions build() { return new ListImagesOptions(this); diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ListObjectMetadataOptions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ListObjectMetadataOptions.java index 4fea9d566d5..5813abd5264 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ListObjectMetadataOptions.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ListObjectMetadataOptions.java @@ -42,7 +42,7 @@ public Builder(String collectionId) { /** * Builds a ListObjectMetadataOptions. * - * @return the listObjectMetadataOptions + * @return the new ListObjectMetadataOptions instance */ public ListObjectMetadataOptions build() { return new ListObjectMetadataOptions(this); diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/Location.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/Location.java index 98771df57c0..5fbbb4867c0 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/Location.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/Location.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -57,7 +57,7 @@ public Builder(Long top, Long left, Long width, Long height) { /** * Builds a Location. * - * @return the location + * @return the new Location instance */ public Location build() { return new Location(this); diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ObjectDetail.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ObjectDetail.java index 961a87fe6ef..2b1f33215c4 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ObjectDetail.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ObjectDetail.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -18,7 +18,7 @@ public class ObjectDetail extends GenericModel { protected String object; - protected Location location; + protected ObjectDetailLocation location; protected Float score; /** @@ -39,7 +39,7 @@ public String getObject() { * * @return the location */ - public Location getLocation() { + public ObjectDetailLocation getLocation() { return location; } diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ObjectDetailLocation.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ObjectDetailLocation.java new file mode 100644 index 00000000000..1910de795f7 --- /dev/null +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ObjectDetailLocation.java @@ -0,0 +1,68 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v4.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** Defines the location of the bounding box around the object. */ +public class ObjectDetailLocation extends GenericModel { + + protected Long top; + protected Long left; + protected Long width; + protected Long height; + + /** + * Gets the top. + * + *

Y-position of top-left pixel of the bounding box. + * + * @return the top + */ + public Long getTop() { + return top; + } + + /** + * Gets the left. + * + *

X-position of top-left pixel of the bounding box. + * + * @return the left + */ + public Long getLeft() { + return left; + } + + /** + * Gets the width. + * + *

Width in pixels of of the bounding box. + * + * @return the width + */ + public Long getWidth() { + return width; + } + + /** + * Gets the height. + * + *

Height in pixels of the bounding box. + * + * @return the height + */ + public Long getHeight() { + return height; + } +} diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ObjectTrainingStatus.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ObjectTrainingStatus.java index f11ed205321..65ec169c6fe 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ObjectTrainingStatus.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/ObjectTrainingStatus.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -83,7 +83,7 @@ public Builder( /** * Builds a ObjectTrainingStatus. * - * @return the objectTrainingStatus + * @return the new ObjectTrainingStatus instance */ public ObjectTrainingStatus build() { return new ObjectTrainingStatus(this); diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/TrainOptions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/TrainOptions.java index 4e1da6ccdb2..091e20c3059 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/TrainOptions.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/TrainOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -42,7 +42,7 @@ public Builder(String collectionId) { /** * Builds a TrainOptions. * - * @return the trainOptions + * @return the new TrainOptions instance */ public TrainOptions build() { return new TrainOptions(this); diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/TrainingDataObject.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/TrainingDataObject.java index 5b33f93015c..d328554ce79 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/TrainingDataObject.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/TrainingDataObject.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -36,7 +36,7 @@ public Builder() {} /** * Builds a TrainingDataObject. * - * @return the trainingDataObject + * @return the new TrainingDataObject instance */ public TrainingDataObject build() { return new TrainingDataObject(this); diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/TrainingDataObjects.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/TrainingDataObjects.java index 51a82e6bddb..33d4aa69c39 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/TrainingDataObjects.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/TrainingDataObjects.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/TrainingEvent.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/TrainingEvent.java index 28613862961..02ac9a6f9f5 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/TrainingEvent.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/TrainingEvent.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/TrainingEvents.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/TrainingEvents.java index ab827a13c2b..72f99f26d4c 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/TrainingEvents.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/TrainingEvents.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/TrainingStatus.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/TrainingStatus.java index 4b64b84c6b9..f138707bded 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/TrainingStatus.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/TrainingStatus.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -42,7 +42,7 @@ public Builder(ObjectTrainingStatus objects) { /** * Builds a TrainingStatus. * - * @return the trainingStatus + * @return the new TrainingStatus instance */ public TrainingStatus build() { return new TrainingStatus(this); diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/UpdateCollectionOptions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/UpdateCollectionOptions.java index 644eaeefa40..0d6d1ffa819 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/UpdateCollectionOptions.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/UpdateCollectionOptions.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -20,17 +20,20 @@ public class UpdateCollectionOptions extends GenericModel { protected String collectionId; protected String name; protected String description; + protected TrainingStatus trainingStatus; /** Builder. */ public static class Builder { private String collectionId; private String name; private String description; + private TrainingStatus trainingStatus; private Builder(UpdateCollectionOptions updateCollectionOptions) { this.collectionId = updateCollectionOptions.collectionId; this.name = updateCollectionOptions.name; this.description = updateCollectionOptions.description; + this.trainingStatus = updateCollectionOptions.trainingStatus; } /** Instantiates a new builder. */ @@ -48,7 +51,7 @@ public Builder(String collectionId) { /** * Builds a UpdateCollectionOptions. * - * @return the updateCollectionOptions + * @return the new UpdateCollectionOptions instance */ public UpdateCollectionOptions build() { return new UpdateCollectionOptions(this); @@ -86,6 +89,17 @@ public Builder description(String description) { this.description = description; return this; } + + /** + * Set the trainingStatus. + * + * @param trainingStatus the trainingStatus + * @return the UpdateCollectionOptions builder + */ + public Builder trainingStatus(TrainingStatus trainingStatus) { + this.trainingStatus = trainingStatus; + return this; + } } protected UpdateCollectionOptions(Builder builder) { @@ -94,6 +108,7 @@ protected UpdateCollectionOptions(Builder builder) { collectionId = builder.collectionId; name = builder.name; description = builder.description; + trainingStatus = builder.trainingStatus; } /** @@ -138,4 +153,15 @@ public String name() { public String description() { return description; } + + /** + * Gets the trainingStatus. + * + *

Training status information for the collection. + * + * @return the trainingStatus + */ + public TrainingStatus trainingStatus() { + return trainingStatus; + } } diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/UpdateObjectMetadata.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/UpdateObjectMetadata.java index ef2ec2f19c5..eb66c3f3339 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/UpdateObjectMetadata.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/UpdateObjectMetadata.java @@ -23,11 +23,9 @@ public class UpdateObjectMetadata extends GenericModel { /** Builder. */ public static class Builder { private String object; - private Long count; private Builder(UpdateObjectMetadata updateObjectMetadata) { this.object = updateObjectMetadata.object; - this.count = updateObjectMetadata.count; } /** Instantiates a new builder. */ @@ -37,17 +35,15 @@ public Builder() {} * Instantiates a new builder with required properties. * * @param object the object - * @param count the count */ - public Builder(String object, Long count) { + public Builder(String object) { this.object = object; - this.count = count; } /** * Builds a UpdateObjectMetadata. * - * @return the updateObjectMetadata + * @return the new UpdateObjectMetadata instance */ public UpdateObjectMetadata build() { return new UpdateObjectMetadata(this); @@ -63,24 +59,11 @@ public Builder object(String object) { this.object = object; return this; } - - /** - * Set the count. - * - * @param count the count - * @return the UpdateObjectMetadata builder - */ - public Builder count(long count) { - this.count = count; - return this; - } } protected UpdateObjectMetadata(Builder builder) { com.ibm.cloud.sdk.core.util.Validator.notNull(builder.object, "object cannot be null"); - com.ibm.cloud.sdk.core.util.Validator.notNull(builder.count, "count cannot be null"); object = builder.object; - count = builder.count; } /** diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/UpdateObjectMetadataOptions.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/UpdateObjectMetadataOptions.java index ee23b81145d..022068c32cb 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/UpdateObjectMetadataOptions.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/UpdateObjectMetadataOptions.java @@ -52,7 +52,7 @@ public Builder(String collectionId, String object, String newObject) { /** * Builds a UpdateObjectMetadataOptions. * - * @return the updateObjectMetadataOptions + * @return the new UpdateObjectMetadataOptions instance */ public UpdateObjectMetadataOptions build() { return new UpdateObjectMetadataOptions(this); @@ -98,6 +98,7 @@ public Builder newObject(String newObject) { * @return the UpdateObjectMetadataOptions builder */ public Builder updateObjectMetadata(UpdateObjectMetadata updateObjectMetadata) { + this.newObject = updateObjectMetadata.object(); return this; } } diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/Warning.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/Warning.java index 12b404469c1..30b6eb0c515 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/Warning.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/model/Warning.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/package-info.java b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/package-info.java index a2ba8abc9db..5e8e9540ee3 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/package-info.java +++ b/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v4/package-info.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/VisualRecognitionTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/VisualRecognitionTest.java index ffb56eb5483..9ad6a44b92a 100644 --- a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/VisualRecognitionTest.java +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/VisualRecognitionTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -12,17 +12,15 @@ */ package com.ibm.watson.visual_recognition.v3; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.testng.Assert.*; -import com.google.common.io.Files; -import com.google.gson.Gson; -import com.google.gson.JsonObject; -import com.ibm.cloud.sdk.core.http.HttpMediaType; +import com.ibm.cloud.sdk.core.http.Response; +import com.ibm.cloud.sdk.core.security.Authenticator; import com.ibm.cloud.sdk.core.security.NoAuthAuthenticator; -import com.ibm.watson.common.WatsonServiceUnitTest; +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; import com.ibm.watson.visual_recognition.v3.model.ClassifiedImages; import com.ibm.watson.visual_recognition.v3.model.Classifier; +import com.ibm.watson.visual_recognition.v3.model.Classifiers; import com.ibm.watson.visual_recognition.v3.model.ClassifyOptions; import com.ibm.watson.visual_recognition.v3.model.CreateClassifierOptions; import com.ibm.watson.visual_recognition.v3.model.DeleteClassifierOptions; @@ -31,323 +29,484 @@ import com.ibm.watson.visual_recognition.v3.model.GetCoreMlModelOptions; import com.ibm.watson.visual_recognition.v3.model.ListClassifiersOptions; import com.ibm.watson.visual_recognition.v3.model.UpdateClassifierOptions; -import java.io.File; -import java.io.FileInputStream; +import com.ibm.watson.visual_recognition.v3.utils.TestUtilities; import java.io.IOException; import java.io.InputStream; -import java.util.ArrayList; -import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; import okhttp3.mockwebserver.RecordedRequest; -import okio.Buffer; -import org.junit.Before; -import org.junit.Test; - -/** Unit tests for the {@link VisualRecognition} service. */ -public class VisualRecognitionTest extends WatsonServiceUnitTest { - private static final String FIXTURE_CLASSIFICATION = - "src/test/resources/visual_recognition/v3/visual_classification.json"; - private static final String FIXTURE_CLASSIFIER = - "src/test/resources/visual_recognition/v3/visual_classifier.json"; - private static final String IMAGE_FILE = "src/test/resources/visual_recognition/v3/test.zip"; - private static final String SINGLE_IMAGE_FILE = - "src/test/resources/visual_recognition/v3/car.png"; - private static final String PATH_CLASSIFY = "/v3/classify"; - private static final String VERSION_KEY = "version"; - private static final String VERSION = "2018-03-19"; - private static final String PATH_CLASSIFIERS = "/v3/classifiers"; - private static final String PATH_CLASSIFIER = "/v3/classifiers/%s"; - private static final String PATH_CORE_ML = "/v3/classifiers/%s/core_ml_model"; - private static final String FILENAME = "test_file"; - - private VisualRecognition service; - - /** - * Sets up the tests. - * - * @throws Exception the exception - */ - /* - * (non-Javadoc) - * @see com.ibm.watson.common.WatsonServiceUnitTest#setUp() - */ - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - - service = new VisualRecognition(VERSION, new NoAuthAuthenticator()); - service.setServiceUrl(getMockWebServerUrl()); - } +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; - /** - * Test classify with file. - * - * @throws IOException Signals that an I/O exception has occurred. - * @throws InterruptedException the interrupted exception - */ - @Test - public void testClassifyWithFile() throws IOException, InterruptedException { - ClassifiedImages mockResponse = loadFixture(FIXTURE_CLASSIFICATION, ClassifiedImages.class); - server.enqueue(new MockResponse().setBody(mockResponse.toString())); +/** Unit test class for the VisualRecognition service. */ +public class VisualRecognitionTest { - // execute request - File images = new File(IMAGE_FILE); - ClassifyOptions options = - new ClassifyOptions.Builder() - .imagesFile(images) - .classifierIds(Collections.singletonList("car")) - .build(); - ClassifiedImages serviceResponse = service.classify(options).execute().getResult(); + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); - // first request - RecordedRequest request = server.takeRequest(); + protected MockWebServer server; + protected VisualRecognition visualRecognitionService; - String path = PATH_CLASSIFY + "?" + VERSION_KEY + "=" + VERSION; - assertEquals(path, request.getPath()); - assertEquals("POST", request.getMethod()); - assertEquals(serviceResponse, mockResponse); + public void constructClientService() throws Throwable { + final String serviceName = "testService"; + // set mock values for global params + String version = "testString"; + + final Authenticator authenticator = new NoAuthAuthenticator(); + + visualRecognitionService = new VisualRecognition(version, serviceName, authenticator); + String url = server.url("/").toString(); + visualRecognitionService.setServiceUrl(url); + } + + /** Negative Test - construct the service with a null authenticator. */ + @Test(expectedExceptions = IllegalArgumentException.class) + public void testConstructorWithNullAuthenticator() throws Throwable { + final String serviceName = "testService"; + // set mock values for global params + String version = "testString"; + + new VisualRecognition(version, serviceName, null); + } + + @Test + public void testGetVersion() throws Throwable { + constructClientService(); + assertEquals(visualRecognitionService.getVersion(), "testString"); } - /** - * Test classify with bytes or stream. - * - * @throws IOException Signals that an I/O exception has occurred. - * @throws InterruptedException the interrupted exception - */ @Test - public void testClassifyWithBytes() throws IOException, InterruptedException { - ClassifiedImages mockResponse = loadFixture(FIXTURE_CLASSIFICATION, ClassifiedImages.class); - server.enqueue(new MockResponse().setBody(mockResponse.toString())); + public void testClassifyWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"custom_classes\": 13, \"images_processed\": 15, \"images\": [{\"source_url\": \"sourceUrl\", \"resolved_url\": \"resolvedUrl\", \"image\": \"image\", \"error\": {\"code\": 4, \"description\": \"description\", \"error_id\": \"errorId\"}, \"classifiers\": [{\"name\": \"name\", \"classifier_id\": \"classifierId\", \"classes\": [{\"class\": \"xClass\", \"score\": 0, \"type_hierarchy\": \"typeHierarchy\"}]}]}], \"warnings\": [{\"warning_id\": \"warningId\", \"description\": \"description\"}]}"; + String classifyPath = "/v3/classify"; - // execute request - File images = new File(SINGLE_IMAGE_FILE); + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); - InputStream fileStream = new FileInputStream(images); + constructClientService(); - ClassifyOptions options = + // Construct an instance of the ClassifyOptions model + ClassifyOptions classifyOptionsModel = new ClassifyOptions.Builder() - .imagesFile(fileStream) - .imagesFilename(FILENAME) - .classifierIds(Collections.singletonList("car")) + .imagesFile(TestUtilities.createMockStream("This is a mock file.")) + .imagesFilename("testString") + .imagesFileContentType("testString") + .url("testString") + .threshold(Float.valueOf("36.0")) + .owners(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .classifierIds(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .acceptLanguage("en") .build(); - ClassifiedImages serviceResponse = service.classify(options).execute().getResult(); - // first request - RecordedRequest request = server.takeRequest(); + // Invoke operation with valid options model (positive test) + Response response = + visualRecognitionService.classify(classifyOptionsModel).execute(); + assertNotNull(response); + ClassifiedImages responseObj = response.getResult(); + assertNotNull(responseObj); - String path = PATH_CLASSIFY + "?" + VERSION_KEY + "=" + VERSION; - assertEquals(path, request.getPath()); - assertEquals("POST", request.getMethod()); - assertEquals(serviceResponse, mockResponse); + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, classifyPath); } - /** - * Test update classifier. - * - * @throws IOException Signals that an I/O exception has occurred. - * @throws InterruptedException the interrupted exception - */ @Test - public void testUpdateClassifier() throws IOException, InterruptedException { - Classifier mockResponse = loadFixture(FIXTURE_CLASSIFIER, Classifier.class); + public void testCreateClassifierWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"classifier_id\": \"classifierId\", \"name\": \"name\", \"owner\": \"owner\", \"status\": \"ready\", \"core_ml_enabled\": false, \"explanation\": \"explanation\", \"created\": \"2019-01-01T12:00:00\", \"classes\": [{\"class\": \"xClass\"}], \"retrained\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}"; + String createClassifierPath = "/v3/classifiers"; - server.enqueue(new MockResponse().setBody(mockResponse.toString())); + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); - // execute request - File images = new File(IMAGE_FILE); - String class1 = "class1"; - String classifierId = "foo123"; + constructClientService(); - UpdateClassifierOptions options = - new UpdateClassifierOptions.Builder(classifierId) - .addPositiveExamples(class1, images) + // Construct an instance of the CreateClassifierOptions model + CreateClassifierOptions createClassifierOptionsModel = + new CreateClassifierOptions.Builder() + .name("testString") + .positiveExamples(mockStreamMap) + .negativeExamples(TestUtilities.createMockStream("This is a mock file.")) + .negativeExamplesFilename("testString") .build(); - Classifier serviceResponse = service.updateClassifier(options).execute().getResult(); + // Invoke operation with valid options model (positive test) + Response response = + visualRecognitionService.createClassifier(createClassifierOptionsModel).execute(); + assertNotNull(response); + Classifier responseObj = response.getResult(); + assertNotNull(responseObj); - // first request - String path = String.format(PATH_CLASSIFIER, classifierId); + // Verify the contents of the request RecordedRequest request = server.takeRequest(); - path += "?" + VERSION_KEY + "=" + VERSION; + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createClassifierPath); + } + + // Test the createClassifier operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateClassifierNoOptions() throws Throwable { + // construct the service + constructClientService(); - assertEquals(path, request.getPath()); - assertEquals("POST", request.getMethod()); - String body = request.getBody().readUtf8(); + server.enqueue(new MockResponse()); - String contentDisposition = - "Content-Disposition: form-data; name=\"class1_positive_examples\";"; - assertTrue(body.contains(contentDisposition)); - assertTrue(!body.contains("Content-Disposition: form-data; name=\"name\"")); - assertEquals(serviceResponse, mockResponse); + // Invoke operation with null options model (negative test) + visualRecognitionService.createClassifier(null).execute(); } - /** - * Test create classifier. - * - * @throws IOException Signals that an I/O exception has occurred. - * @throws InterruptedException the interrupted exception - */ @Test - public void testCreateClassifier() throws IOException, InterruptedException { - Classifier mockResponse = loadFixture(FIXTURE_CLASSIFIER, Classifier.class); + public void testListClassifiersWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"classifiers\": [{\"classifier_id\": \"classifierId\", \"name\": \"name\", \"owner\": \"owner\", \"status\": \"ready\", \"core_ml_enabled\": false, \"explanation\": \"explanation\", \"created\": \"2019-01-01T12:00:00\", \"classes\": [{\"class\": \"xClass\"}], \"retrained\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}]}"; + String listClassifiersPath = "/v3/classifiers"; - server.enqueue(new MockResponse().setBody(mockResponse.toString())); - - // execute request - File positiveImages = new File(IMAGE_FILE); - File negativeImages = new File(IMAGE_FILE); - String class1 = "class1"; - CreateClassifierOptions options = - new CreateClassifierOptions.Builder() - .name(class1) - .addPositiveExamples(class1, positiveImages) - .negativeExamples(negativeImages) - .build(); + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); - Classifier serviceResponse = service.createClassifier(options).execute().getResult(); + constructClientService(); - // first request - RecordedRequest request = server.takeRequest(); - String path = PATH_CLASSIFIERS + "?" + VERSION_KEY + "=" + VERSION; + // Construct an instance of the ListClassifiersOptions model + ListClassifiersOptions listClassifiersOptionsModel = + new ListClassifiersOptions.Builder().verbose(true).build(); - assertEquals(path, request.getPath()); - assertEquals("POST", request.getMethod()); - String body = request.getBody().readUtf8(); + // Invoke operation with valid options model (positive test) + Response response = + visualRecognitionService.listClassifiers(listClassifiersOptionsModel).execute(); + assertNotNull(response); + Classifiers responseObj = response.getResult(); + assertNotNull(responseObj); - String contentDisposition = - "Content-Disposition: form-data; name=\"class1_positive_examples\";"; - assertTrue(body.contains(contentDisposition)); - assertTrue(body.contains("Content-Disposition: form-data; name=\"name\"")); - assertEquals(serviceResponse, mockResponse); + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(Boolean.valueOf(query.get("verbose")), Boolean.valueOf(true)); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listClassifiersPath); } - /** - * Test delete classifier. - * - * @throws IOException Signals that an I/O exception has occurred. - * @throws InterruptedException the interrupted exception - */ @Test - public void testDeleteClassifier() throws IOException, InterruptedException { - server.enqueue(new MockResponse().setBody("")); + public void testGetClassifierWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"classifier_id\": \"classifierId\", \"name\": \"name\", \"owner\": \"owner\", \"status\": \"ready\", \"core_ml_enabled\": false, \"explanation\": \"explanation\", \"created\": \"2019-01-01T12:00:00\", \"classes\": [{\"class\": \"xClass\"}], \"retrained\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}"; + String getClassifierPath = "/v3/classifiers/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the GetClassifierOptions model + GetClassifierOptions getClassifierOptionsModel = + new GetClassifierOptions.Builder().classifierId("testString").build(); - String class1 = "class1"; - DeleteClassifierOptions options = new DeleteClassifierOptions.Builder(class1).build(); - service.deleteClassifier(options).execute(); + // Invoke operation with valid options model (positive test) + Response response = + visualRecognitionService.getClassifier(getClassifierOptionsModel).execute(); + assertNotNull(response); + Classifier responseObj = response.getResult(); + assertNotNull(responseObj); - // first request + // Verify the contents of the request RecordedRequest request = server.takeRequest(); - String path = String.format(PATH_CLASSIFIER + "?" + VERSION_KEY + "=" + VERSION, class1); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getClassifierPath); + } + + // Test the getClassifier operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetClassifierNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); - assertEquals(path, request.getPath()); - assertEquals("DELETE", request.getMethod()); + // Invoke operation with null options model (negative test) + visualRecognitionService.getClassifier(null).execute(); } - /** - * Test get classifier. - * - * @throws InterruptedException the interrupted exception - * @throws IOException Signals that an I/O exception has occurred. - */ @Test - public void testGetClassifier() throws InterruptedException, IOException { - try { - Classifier mockResponse = loadFixture(FIXTURE_CLASSIFIER, Classifier.class); + public void testUpdateClassifierWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"classifier_id\": \"classifierId\", \"name\": \"name\", \"owner\": \"owner\", \"status\": \"ready\", \"core_ml_enabled\": false, \"explanation\": \"explanation\", \"created\": \"2019-01-01T12:00:00\", \"classes\": [{\"class\": \"xClass\"}], \"retrained\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\"}"; + String updateClassifierPath = "/v3/classifiers/testString"; - server.enqueue(new MockResponse().setBody(mockResponse.toString())); + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the UpdateClassifierOptions model + UpdateClassifierOptions updateClassifierOptionsModel = + new UpdateClassifierOptions.Builder() + .classifierId("testString") + .positiveExamples(mockStreamMap) + .negativeExamples(TestUtilities.createMockStream("This is a mock file.")) + .negativeExamplesFilename("testString") + .build(); - // execute request - String class1 = "class1"; - GetClassifierOptions getOptions = new GetClassifierOptions.Builder(class1).build(); - Classifier serviceResponse = service.getClassifier(getOptions).execute().getResult(); + // Invoke operation with valid options model (positive test) + Response response = + visualRecognitionService.updateClassifier(updateClassifierOptionsModel).execute(); + assertNotNull(response); + Classifier responseObj = response.getResult(); + assertNotNull(responseObj); - // first request - RecordedRequest request = server.takeRequest(); - String path = String.format(PATH_CLASSIFIER + "?" + VERSION_KEY + "=" + VERSION, class1); + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateClassifierPath); + } - assertEquals(path, request.getPath()); - assertEquals("GET", request.getMethod()); - assertEquals(serviceResponse, mockResponse); - } catch (Exception e) { - e.printStackTrace(); - } + // Test the updateClassifier operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateClassifierNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + visualRecognitionService.updateClassifier(null).execute(); } - /** - * Test get classifiers. - * - * @throws InterruptedException the interrupted exception - * @throws IOException Signals that an I/O exception has occurred. - */ @Test - public void testGetClassifiers() throws InterruptedException, IOException { - Classifier mockClassifier = loadFixture(FIXTURE_CLASSIFIER, Classifier.class); - List classifiers = new ArrayList<>(); - classifiers.add(mockClassifier); - classifiers.add(mockClassifier); - classifiers.add(mockClassifier); + public void testDeleteClassifierWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String deleteClassifierPath = "/v3/classifiers/testString"; + + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); - JsonObject mockResponse = new JsonObject(); - mockResponse.add("classifiers", new Gson().toJsonTree(classifiers)); + constructClientService(); - server.enqueue(new MockResponse().setBody(mockResponse.toString())); + // Construct an instance of the DeleteClassifierOptions model + DeleteClassifierOptions deleteClassifierOptionsModel = + new DeleteClassifierOptions.Builder().classifierId("testString").build(); - ListClassifiersOptions options = new ListClassifiersOptions.Builder().verbose(true).build(); - List serviceResponse = - service.listClassifiers(options).execute().getResult().getClassifiers(); + // Invoke operation with valid options model (positive test) + Response response = + visualRecognitionService.deleteClassifier(deleteClassifierOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); - // first request + // Verify the contents of the request RecordedRequest request = server.takeRequest(); - String path = PATH_CLASSIFIERS + "?" + VERSION_KEY + "=" + VERSION + "&verbose=true"; + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteClassifierPath); + } + + // Test the deleteClassifier operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteClassifierNoOptions() throws Throwable { + // construct the service + constructClientService(); - assertEquals(path, request.getPath()); - assertEquals("GET", request.getMethod()); - assertEquals(serviceResponse, classifiers); + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + visualRecognitionService.deleteClassifier(null).execute(); } - /** - * Test get core ml model. - * - * @throws IOException Signals that an I/O exception has occurred. - * @throws InterruptedException the interrupted exception - */ @Test - public void testGetCoreMlModel() throws IOException, InterruptedException { - final File model = new File("src/test/resources/visual_recognition/v3/custom_model.mlmodel"); - @SuppressWarnings("resource") - final Buffer buffer = new Buffer().write(Files.toByteArray(model)); + public void testGetCoreMlModelWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = "This is a mock binary response."; + String getCoreMlModelPath = "/v3/classifiers/testString/core_ml_model"; server.enqueue( new MockResponse() - .addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_OCTET_STREAM) - .setBody(buffer)); + .setHeader("Content-type", "application/octet-stream") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); - String classifierId = "classifier_id"; - GetCoreMlModelOptions options = - new GetCoreMlModelOptions.Builder().classifierId(classifierId).build(); + // Construct an instance of the GetCoreMlModelOptions model + GetCoreMlModelOptions getCoreMlModelOptionsModel = + new GetCoreMlModelOptions.Builder().classifierId("testString").build(); - InputStream modelFile = service.getCoreMlModel(options).execute().getResult(); + // Invoke operation with valid options model (positive test) + Response response = + visualRecognitionService.getCoreMlModel(getCoreMlModelOptionsModel).execute(); + assertNotNull(response); + InputStream responseObj = response.getResult(); + assertNotNull(responseObj); + // Verify the contents of the request RecordedRequest request = server.takeRequest(); - String path = String.format(PATH_CORE_ML, classifierId) + "?" + VERSION_KEY + "=" + VERSION; + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getCoreMlModelPath); + } + + // Test the getCoreMlModel operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetCoreMlModelNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); - assertEquals(path, request.getPath()); - assertEquals("GET", request.getMethod()); - File outputFile = new File("src/test/resources/visual_recognition/v3/model_result.mlmodel"); - outputFile.createNewFile(); - writeInputStreamToFile(modelFile, outputFile); + // Invoke operation with null options model (negative test) + visualRecognitionService.getCoreMlModel(null).execute(); } - /** Test delete user data options builder. */ @Test - public void testDeleteUserDataOptionsBuilder() { - String customerId = "java_sdk_test_id"; + public void testDeleteUserDataWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String deleteUserDataPath = "/v3/user_data"; + + server.enqueue(new MockResponse().setResponseCode(202).setBody(mockResponseBody)); + + constructClientService(); - DeleteUserDataOptions deleteOptions = - new DeleteUserDataOptions.Builder().customerId(customerId).build(); + // Construct an instance of the DeleteUserDataOptions model + DeleteUserDataOptions deleteUserDataOptionsModel = + new DeleteUserDataOptions.Builder().customerId("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = + visualRecognitionService.deleteUserData(deleteUserDataOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(query.get("customer_id"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteUserDataPath); + } + + // Test the deleteUserData operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteUserDataNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + visualRecognitionService.deleteUserData(null).execute(); + } + + /** Initialize the server */ + @BeforeMethod + public void setUpMockServer() { + try { + server = new MockWebServer(); + // register handler + server.start(); + } catch (IOException err) { + fail("Failed to instantiate mock web server"); + } + } - assertEquals(deleteOptions.customerId(), customerId); + @AfterMethod + public void tearDownMockServer() throws IOException { + server.shutdown(); + visualRecognitionService = null; } } diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/model/ClassResultTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/model/ClassResultTest.java new file mode 100644 index 00000000000..6853290cedc --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/model/ClassResultTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ClassResult model. */ +public class ClassResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testClassResult() throws Throwable { + ClassResult classResultModel = new ClassResult(); + assertNull(classResultModel.getXClass()); + assertNull(classResultModel.getScore()); + assertNull(classResultModel.getTypeHierarchy()); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/model/ClassTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/model/ClassTest.java new file mode 100644 index 00000000000..90608b8d528 --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/model/ClassTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Class model. */ +public class ClassTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testClass() throws Throwable { + Class classModel = new Class(); + assertNull(classModel.getXClass()); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/model/ClassifiedImageTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/model/ClassifiedImageTest.java new file mode 100644 index 00000000000..df282bc17c7 --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/model/ClassifiedImageTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ClassifiedImage model. */ +public class ClassifiedImageTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testClassifiedImage() throws Throwable { + ClassifiedImage classifiedImageModel = new ClassifiedImage(); + assertNull(classifiedImageModel.getSourceUrl()); + assertNull(classifiedImageModel.getResolvedUrl()); + assertNull(classifiedImageModel.getImage()); + assertNull(classifiedImageModel.getError()); + assertNull(classifiedImageModel.getClassifiers()); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/model/ClassifiedImagesTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/model/ClassifiedImagesTest.java new file mode 100644 index 00000000000..cc06546b73d --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/model/ClassifiedImagesTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ClassifiedImages model. */ +public class ClassifiedImagesTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testClassifiedImages() throws Throwable { + ClassifiedImages classifiedImagesModel = new ClassifiedImages(); + assertNull(classifiedImagesModel.getCustomClasses()); + assertNull(classifiedImagesModel.getImagesProcessed()); + assertNull(classifiedImagesModel.getImages()); + assertNull(classifiedImagesModel.getWarnings()); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/model/ClassifierResultTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/model/ClassifierResultTest.java new file mode 100644 index 00000000000..4697226b390 --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/model/ClassifierResultTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ClassifierResult model. */ +public class ClassifierResultTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testClassifierResult() throws Throwable { + ClassifierResult classifierResultModel = new ClassifierResult(); + assertNull(classifierResultModel.getName()); + assertNull(classifierResultModel.getClassifierId()); + assertNull(classifierResultModel.getClasses()); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/model/ClassifierTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/model/ClassifierTest.java new file mode 100644 index 00000000000..a7032c84373 --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/model/ClassifierTest.java @@ -0,0 +1,45 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Classifier model. */ +public class ClassifierTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testClassifier() throws Throwable { + Classifier classifierModel = new Classifier(); + assertNull(classifierModel.getClassifierId()); + assertNull(classifierModel.getName()); + assertNull(classifierModel.getOwner()); + assertNull(classifierModel.getStatus()); + assertNull(classifierModel.isCoreMlEnabled()); + assertNull(classifierModel.getExplanation()); + assertNull(classifierModel.getCreated()); + assertNull(classifierModel.getClasses()); + assertNull(classifierModel.getRetrained()); + assertNull(classifierModel.getUpdated()); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/model/ClassifiersTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/model/ClassifiersTest.java new file mode 100644 index 00000000000..568cc205591 --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/model/ClassifiersTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Classifiers model. */ +public class ClassifiersTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testClassifiers() throws Throwable { + Classifiers classifiersModel = new Classifiers(); + assertNull(classifiersModel.getClassifiers()); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/model/ClassifyOptionsTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/model/ClassifyOptionsTest.java new file mode 100644 index 00000000000..a3304494444 --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/model/ClassifyOptionsTest.java @@ -0,0 +1,60 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.apache.commons.io.IOUtils; +import org.testng.annotations.Test; + +/** Unit test class for the ClassifyOptions model. */ +public class ClassifyOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testClassifyOptions() throws Throwable { + ClassifyOptions classifyOptionsModel = + new ClassifyOptions.Builder() + .imagesFile(TestUtilities.createMockStream("This is a mock file.")) + .imagesFilename("testString") + .imagesFileContentType("testString") + .url("testString") + .threshold(Float.valueOf("36.0")) + .owners(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .classifierIds(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .acceptLanguage("en") + .build(); + assertEquals( + IOUtils.toString(classifyOptionsModel.imagesFile()), + IOUtils.toString(TestUtilities.createMockStream("This is a mock file."))); + assertEquals(classifyOptionsModel.imagesFilename(), "testString"); + assertEquals(classifyOptionsModel.imagesFileContentType(), "testString"); + assertEquals(classifyOptionsModel.url(), "testString"); + assertEquals(classifyOptionsModel.threshold(), Float.valueOf("36.0")); + assertEquals( + classifyOptionsModel.owners(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals( + classifyOptionsModel.classifierIds(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals(classifyOptionsModel.acceptLanguage(), "en"); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/model/CreateClassifierOptionsTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/model/CreateClassifierOptionsTest.java new file mode 100644 index 00000000000..41567c7c40a --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/model/CreateClassifierOptionsTest.java @@ -0,0 +1,53 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.apache.commons.io.IOUtils; +import org.testng.annotations.Test; + +/** Unit test class for the CreateClassifierOptions model. */ +public class CreateClassifierOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateClassifierOptions() throws Throwable { + CreateClassifierOptions createClassifierOptionsModel = + new CreateClassifierOptions.Builder() + .name("testString") + .positiveExamples(mockStreamMap) + .negativeExamples(TestUtilities.createMockStream("This is a mock file.")) + .negativeExamplesFilename("testString") + .build(); + assertEquals(createClassifierOptionsModel.name(), "testString"); + assertEquals(createClassifierOptionsModel.positiveExamples(), mockStreamMap); + assertEquals( + IOUtils.toString(createClassifierOptionsModel.negativeExamples()), + IOUtils.toString(TestUtilities.createMockStream("This is a mock file."))); + assertEquals(createClassifierOptionsModel.negativeExamplesFilename(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCreateClassifierOptionsError() throws Throwable { + new CreateClassifierOptions.Builder().build(); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/model/DeleteClassifierOptionsTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/model/DeleteClassifierOptionsTest.java new file mode 100644 index 00000000000..df104df20e6 --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/model/DeleteClassifierOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteClassifierOptions model. */ +public class DeleteClassifierOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteClassifierOptions() throws Throwable { + DeleteClassifierOptions deleteClassifierOptionsModel = + new DeleteClassifierOptions.Builder().classifierId("testString").build(); + assertEquals(deleteClassifierOptionsModel.classifierId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteClassifierOptionsError() throws Throwable { + new DeleteClassifierOptions.Builder().build(); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/model/DeleteUserDataOptionsTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/model/DeleteUserDataOptionsTest.java new file mode 100644 index 00000000000..982d98e9036 --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/model/DeleteUserDataOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteUserDataOptions model. */ +public class DeleteUserDataOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteUserDataOptions() throws Throwable { + DeleteUserDataOptions deleteUserDataOptionsModel = + new DeleteUserDataOptions.Builder().customerId("testString").build(); + assertEquals(deleteUserDataOptionsModel.customerId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteUserDataOptionsError() throws Throwable { + new DeleteUserDataOptions.Builder().build(); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/model/ErrorInfoTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/model/ErrorInfoTest.java new file mode 100644 index 00000000000..772b5225161 --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/model/ErrorInfoTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ErrorInfo model. */ +public class ErrorInfoTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testErrorInfo() throws Throwable { + ErrorInfo errorInfoModel = new ErrorInfo(); + assertNull(errorInfoModel.getCode()); + assertNull(errorInfoModel.getDescription()); + assertNull(errorInfoModel.getErrorId()); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/model/GetClassifierOptionsTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/model/GetClassifierOptionsTest.java new file mode 100644 index 00000000000..bc0b36c1122 --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/model/GetClassifierOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetClassifierOptions model. */ +public class GetClassifierOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetClassifierOptions() throws Throwable { + GetClassifierOptions getClassifierOptionsModel = + new GetClassifierOptions.Builder().classifierId("testString").build(); + assertEquals(getClassifierOptionsModel.classifierId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetClassifierOptionsError() throws Throwable { + new GetClassifierOptions.Builder().build(); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/model/GetCoreMlModelOptionsTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/model/GetCoreMlModelOptionsTest.java new file mode 100644 index 00000000000..bd8fbf9904d --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/model/GetCoreMlModelOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetCoreMlModelOptions model. */ +public class GetCoreMlModelOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetCoreMlModelOptions() throws Throwable { + GetCoreMlModelOptions getCoreMlModelOptionsModel = + new GetCoreMlModelOptions.Builder().classifierId("testString").build(); + assertEquals(getCoreMlModelOptionsModel.classifierId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetCoreMlModelOptionsError() throws Throwable { + new GetCoreMlModelOptions.Builder().build(); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/model/ListClassifiersOptionsTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/model/ListClassifiersOptionsTest.java new file mode 100644 index 00000000000..706bd3adaed --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/model/ListClassifiersOptionsTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListClassifiersOptions model. */ +public class ListClassifiersOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListClassifiersOptions() throws Throwable { + ListClassifiersOptions listClassifiersOptionsModel = + new ListClassifiersOptions.Builder().verbose(true).build(); + assertEquals(listClassifiersOptionsModel.verbose(), Boolean.valueOf(true)); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/model/UpdateClassifierOptionsTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/model/UpdateClassifierOptionsTest.java new file mode 100644 index 00000000000..a2ea2146573 --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/model/UpdateClassifierOptionsTest.java @@ -0,0 +1,53 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.apache.commons.io.IOUtils; +import org.testng.annotations.Test; + +/** Unit test class for the UpdateClassifierOptions model. */ +public class UpdateClassifierOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateClassifierOptions() throws Throwable { + UpdateClassifierOptions updateClassifierOptionsModel = + new UpdateClassifierOptions.Builder() + .classifierId("testString") + .positiveExamples(mockStreamMap) + .negativeExamples(TestUtilities.createMockStream("This is a mock file.")) + .negativeExamplesFilename("testString") + .build(); + assertEquals(updateClassifierOptionsModel.classifierId(), "testString"); + assertEquals(updateClassifierOptionsModel.positiveExamples(), mockStreamMap); + assertEquals( + IOUtils.toString(updateClassifierOptionsModel.negativeExamples()), + IOUtils.toString(TestUtilities.createMockStream("This is a mock file."))); + assertEquals(updateClassifierOptionsModel.negativeExamplesFilename(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateClassifierOptionsError() throws Throwable { + new UpdateClassifierOptions.Builder().build(); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/model/WarningInfoTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/model/WarningInfoTest.java new file mode 100644 index 00000000000..7245f6bfd94 --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/model/WarningInfoTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v3.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v3.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the WarningInfo model. */ +public class WarningInfoTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testWarningInfo() throws Throwable { + WarningInfo warningInfoModel = new WarningInfo(); + assertNull(warningInfoModel.getWarningId()); + assertNull(warningInfoModel.getDescription()); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/utils/TestUtilities.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/utils/TestUtilities.java new file mode 100644 index 00000000000..bf33eb9be8e --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v3/utils/TestUtilities.java @@ -0,0 +1,128 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v3.utils; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.cloud.sdk.core.util.GsonSingleton; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import okhttp3.HttpUrl; +import okhttp3.mockwebserver.RecordedRequest; + +/** A class used by the unit tests containing utility functions. */ +public class TestUtilities { + public static Map createMockMap() { + Map mockMap = new HashMap<>(); + mockMap.put("foo", "bar"); + return mockMap; + } + + public static HashMap createMockStreamMap() { + return new HashMap() { + { + put("key1", createMockStream("This is a mock file.")); + } + }; + } + + public static Map parseQueryString(RecordedRequest req) { + Map queryMap = new HashMap<>(); + + try { + HttpUrl requestUrl = req.getRequestUrl(); + + if (requestUrl != null) { + Set queryParamsNames = requestUrl.queryParameterNames(); + // map the parameter name to its corresponding value + for (String p : queryParamsNames) { + // get the corresponding value for the parameter (p) + List val = requestUrl.queryParameterValues(p); + if (val != null && !val.isEmpty()) { + String joinedQuery = String.join(",", val); + queryMap.put(p, joinedQuery); + } + } + } + if (queryMap.isEmpty()) { + return null; + } + } catch (Exception e) { + return null; + } + + return queryMap; + } + + public static String parseReqPath(RecordedRequest req) { + String parsedPath = null; + + try { + String fullPath = req.getPath(); + if (fullPath != null && !fullPath.isEmpty()) { + // retrieve the path segment before the query parameter + parsedPath = fullPath.split("\\?", 2)[0]; + } + if (parsedPath.isEmpty() || parsedPath == null) { + return null; + } + + } catch (Exception e) { + return null; + } + + return parsedPath; + } + + public static String serialize(Object obj) { + return GsonSingleton.getGson().toJson(obj); + } + + public static T deserialize(String json, Class clazz) { + return GsonSingleton.getGson().fromJson(json, clazz); + } + + public static InputStream createMockStream(String s) { + return new ByteArrayInputStream(s.getBytes()); + } + + public static List creatMockListFileWithMetadata() { + List list = new ArrayList(); + byte[] fileBytes = {(byte) 0xde, (byte) 0xad, (byte) 0xbe, (byte) 0xef}; + InputStream inputStream = new ByteArrayInputStream(fileBytes); + FileWithMetadata.Builder builder = new FileWithMetadata.Builder(); + builder.data(inputStream); + FileWithMetadata fileWithMetadata = builder.build(); + list.add(fileWithMetadata); + + return list; + } + + public static byte[] createMockByteArray(String bytes) { + return bytes.getBytes(); + } + + public static Date createMockDate(String date) throws Exception { + return new SimpleDateFormat("yyyy-MM-dd").parse(date); + } + + public static Date createMockDateTime(String date) throws Exception { + return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").parse(date); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/VisualRecognitionTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/VisualRecognitionTest.java index d80851ae3f4..09e9d1f1ab2 100644 --- a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/VisualRecognitionTest.java +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/VisualRecognitionTest.java @@ -1,5 +1,5 @@ /* - * (C) Copyright IBM Corp. 2019, 2020. + * (C) Copyright IBM Corp. 2020. * * 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 @@ -12,15 +12,12 @@ */ package com.ibm.watson.visual_recognition.v4; -import static junit.framework.TestCase.assertNotNull; -import static junit.framework.TestCase.assertTrue; -import static org.junit.Assert.assertEquals; +import static org.testng.Assert.*; -import com.google.common.io.Files; +import com.ibm.cloud.sdk.core.http.Response; import com.ibm.cloud.sdk.core.security.Authenticator; import com.ibm.cloud.sdk.core.security.NoAuthAuthenticator; import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; -import com.ibm.watson.common.WatsonServiceUnitTest; import com.ibm.watson.visual_recognition.v4.model.AddImageTrainingDataOptions; import com.ibm.watson.visual_recognition.v4.model.AddImagesOptions; import com.ibm.watson.visual_recognition.v4.model.AnalyzeOptions; @@ -35,6 +32,7 @@ import com.ibm.watson.visual_recognition.v4.model.GetCollectionOptions; import com.ibm.watson.visual_recognition.v4.model.GetImageDetailsOptions; import com.ibm.watson.visual_recognition.v4.model.GetJpegImageOptions; +import com.ibm.watson.visual_recognition.v4.model.GetModelFileOptions; import com.ibm.watson.visual_recognition.v4.model.GetObjectMetadataOptions; import com.ibm.watson.visual_recognition.v4.model.GetTrainingUsageOptions; import com.ibm.watson.visual_recognition.v4.model.ImageDetails; @@ -55,874 +53,1168 @@ import com.ibm.watson.visual_recognition.v4.model.UpdateCollectionOptions; import com.ibm.watson.visual_recognition.v4.model.UpdateObjectMetadata; import com.ibm.watson.visual_recognition.v4.model.UpdateObjectMetadataOptions; -import java.io.File; +import com.ibm.watson.visual_recognition.v4.utils.TestUtilities; import java.io.IOException; import java.io.InputStream; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; +import java.util.HashMap; import java.util.List; -import java.util.Locale; +import java.util.Map; import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; import okhttp3.mockwebserver.RecordedRequest; -import okio.Buffer; -import org.junit.Before; -import org.junit.Test; - -/** Unit tests for the {@link VisualRecognition} service. */ -public class VisualRecognitionTest extends WatsonServiceUnitTest { - private static final String VERSION = "2019-02-11"; - private static final String RESOURCE = "src/test/resources/visual_recognition/v4/"; - - private static final String COLLECTION_ID = "123456789"; - private static final String IMAGE_URL = "www.image.jpg"; - private static final String TRAINING_DATA = "training_data"; - private static final String OBJECT = "object"; - private static final Long TOP = 0L; - private static final Long LEFT = 10L; - private static final Long WIDTH = 100L; - private static final Long HEIGHT = 200L; - private static final String IMAGE_ID = "image_id"; - private static final Float THRESHOLD = 12f; - private static final String NAME = "name"; - private static final String DESCRIPTION = "description"; - private static final Long IMAGE_COUNT = 50L; - private static final String CUSTOMER_ID = "customer_id"; - private static final String IMAGE_TYPE = "file"; - private static final String FILENAME = "filename"; - private static final String ARCHIVE_FILENAME = "archive_filename"; - private static final String SOURCE_URL = "source_url"; - private static final String RESOLVED_URL = "resolved_url"; - private static final Float SCORE = 5.0f; - private static final String CODE = "code"; - private static final String MESSAGE = "message"; - private static final String MORE_INFO = "more_info"; - private static final String ERROR_TYPE = "field"; - private static final String TRACE = "trace"; - private static final Long COMPLETED_EVENTS = 7L; - private static final Long TRAINED_IMAGES = 15L; - private static final String TYPE = "objects"; - private static final String STATUS = "succeeded"; - private static final String START_TIME = "1995-06-12"; - private static final String END_TIME = "2019-11-19"; - - private FileWithMetadata fileWithMetadata; - private TrainingDataObject trainingDataObject; - private ObjectTrainingStatus objectTrainingStatus; - private Date testDate; - - private AnalyzeResponse analyzeResponse; - private Collection collection; - private CollectionsList collectionsList; - private ImageDetailsList imageDetailsList; - private ImageSummaryList imageSummaryList; - private ImageDetails imageDetails; - private File imageFile; - private TrainingDataObjects trainingDataObjects; - private TrainingEvents trainingEvents; - private ObjectMetadataList objectMetadataList; - private ObjectMetadata objectName; - - private VisualRecognition service; - - /** - * Sets up the tests. - * - * @throws Exception the exception - */ - /* - * (non-Javadoc) - * - * @see com.ibm.watson.common.WatsonServiceUnitTest#setUp() - */ - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - - service = new VisualRecognition(VERSION, new NoAuthAuthenticator()); - service.setServiceUrl(getMockWebServerUrl()); - - // create test models - fileWithMetadata = - new FileWithMetadata.Builder() - .data(new File("src/test/resources/visual_recognition/v4/giraffe_to_classify.jpg")) - .build(); - new Location.Builder().top(TOP).left(LEFT).height(HEIGHT).width(WIDTH).build(); - trainingDataObject = new TrainingDataObject.Builder().build(); - objectTrainingStatus = - new ObjectTrainingStatus.Builder() - .ready(true) - .inProgress(true) - .dataChanged(true) - .rscnnReady(true) - .latestFailed(true) - .description(DESCRIPTION) - .build(); - new TrainingStatus.Builder().objects(objectTrainingStatus).build(); - String dateString = "1995-06-12T01:11:11.111+0000"; - DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ", Locale.ENGLISH); - testDate = dateFormat.parse(dateString); - - // load mock responses - analyzeResponse = loadFixture(RESOURCE + "analyze-response.json", AnalyzeResponse.class); - collection = loadFixture(RESOURCE + "collection.json", Collection.class); - collectionsList = loadFixture(RESOURCE + "collections-list.json", CollectionsList.class); - imageDetailsList = loadFixture(RESOURCE + "image-details-list.json", ImageDetailsList.class); - imageSummaryList = loadFixture(RESOURCE + "image-summary-list.json", ImageSummaryList.class); - imageDetails = loadFixture(RESOURCE + "image-details.json", ImageDetails.class); - imageFile = new File(RESOURCE + "giraffe_to_classify.jpg"); - trainingDataObjects = - loadFixture(RESOURCE + "training-data-objects.json", TrainingDataObjects.class); - trainingEvents = loadFixture(RESOURCE + "training-events.json", TrainingEvents.class); - objectMetadataList = - loadFixture(RESOURCE + "object-metadata-list.json", ObjectMetadataList.class); - objectName = loadFixture(RESOURCE + "object-name.json", ObjectMetadata.class); - } - - /** Test config based constructor. */ - @Test - public void testConfigBasedConstructor() { - VisualRecognition service = new VisualRecognition(VERSION); - assertEquals(Authenticator.AUTHTYPE_BASIC, service.getAuthenticator().authenticationType()); - } +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; - /** Test add images options. */ - @Test - public void testAddImagesOptions() { - List imageList = new ArrayList<>(); - imageList.add(fileWithMetadata); - List imageUrlList = new ArrayList<>(); - imageUrlList.add(IMAGE_URL); +/** Unit test class for the VisualRecognition service. */ +public class VisualRecognitionTest { - AddImagesOptions options = - new AddImagesOptions.Builder() - .imagesFile(imageList) - .addImagesFile(fileWithMetadata) - .imageUrl(imageUrlList) - .addImageUrl(IMAGE_URL) - .collectionId(COLLECTION_ID) - .trainingData(TRAINING_DATA) - .build(); - options = options.newBuilder().build(); + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); - assertEquals(2, options.imagesFile().size()); - assertEquals(fileWithMetadata, options.imagesFile().get(0)); - assertEquals(2, options.imageUrl().size()); - assertEquals(IMAGE_URL, options.imageUrl().get(0)); - assertEquals(COLLECTION_ID, options.collectionId()); - assertEquals(TRAINING_DATA, options.trainingData()); - } + protected MockWebServer server; + protected VisualRecognition visualRecognitionService; - /** Test add image training data options. */ - @Test - public void testAddImageTrainingDataOptions() { - List objectList = new ArrayList<>(); - objectList.add(trainingDataObject); + public void constructClientService() throws Throwable { + final String serviceName = "testService"; + // set mock values for global params + String version = "testString"; - AddImageTrainingDataOptions options = - new AddImageTrainingDataOptions.Builder() - .collectionId(COLLECTION_ID) - .imageId(IMAGE_ID) - .objects(objectList) - .addObjects(trainingDataObject) - .build(); - options = options.newBuilder().build(); + final Authenticator authenticator = new NoAuthAuthenticator(); - assertEquals(COLLECTION_ID, options.collectionId()); - assertEquals(IMAGE_ID, options.imageId()); - assertEquals(2, options.objects().size()); - assertEquals(trainingDataObject, options.objects().get(0)); + visualRecognitionService = new VisualRecognition(version, serviceName, authenticator); + String url = server.url("/").toString(); + visualRecognitionService.setServiceUrl(url); } - /** Test analyze options. */ - @Test - public void testAnalyzeOptions() { - List collectionIdList = new ArrayList<>(); - collectionIdList.add(COLLECTION_ID); - List featureList = new ArrayList<>(); - featureList.add(AnalyzeOptions.Features.OBJECTS); - List imageList = new ArrayList<>(); - imageList.add(fileWithMetadata); - List imageUrlList = new ArrayList<>(); - imageUrlList.add(IMAGE_URL); - - AnalyzeOptions options = - new AnalyzeOptions.Builder() - .collectionIds(collectionIdList) - .addCollectionIds(COLLECTION_ID) - .features(featureList) - .addFeatures(AnalyzeOptions.Features.OBJECTS) - .imagesFile(imageList) - .addImagesFile(fileWithMetadata) - .imageUrl(imageUrlList) - .addImageUrl(IMAGE_URL) - .threshold(THRESHOLD) - .build(); - options = options.newBuilder().build(); + /** Negative Test - construct the service with a null authenticator. */ + @Test(expectedExceptions = IllegalArgumentException.class) + public void testConstructorWithNullAuthenticator() throws Throwable { + final String serviceName = "testService"; + // set mock values for global params + String version = "testString"; - assertEquals(2, options.collectionIds().size()); - assertEquals(COLLECTION_ID, options.collectionIds().get(0)); - assertEquals(2, options.features().size()); - assertEquals(AnalyzeOptions.Features.OBJECTS, options.features().get(0)); - assertEquals(2, options.imagesFile().size()); - assertEquals(fileWithMetadata, options.imagesFile().get(0)); - assertEquals(2, options.imageUrl().size()); - assertEquals(IMAGE_URL, options.imageUrl().get(0)); - assertEquals(THRESHOLD, options.threshold()); + new VisualRecognition(version, serviceName, null); } - /** Test create collection options. */ @Test - public void testCreateCollectionOptions() { - CreateCollectionOptions options = - new CreateCollectionOptions.Builder().name(NAME).description(DESCRIPTION).build(); - options = options.newBuilder().build(); - - assertEquals(NAME, options.name()); - assertEquals(DESCRIPTION, options.description()); + public void testGetVersion() throws Throwable { + constructClientService(); + assertEquals(visualRecognitionService.getVersion(), "testString"); } - /** Test delete collection options. */ @Test - public void testDeleteCollectionOptions() { - DeleteCollectionOptions options = - new DeleteCollectionOptions.Builder().collectionId(COLLECTION_ID).build(); - options = options.newBuilder().build(); - - assertEquals(COLLECTION_ID, options.collectionId()); - } + public void testAnalyzeWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"images\": [{\"source\": {\"type\": \"file\", \"filename\": \"filename\", \"archive_filename\": \"archiveFilename\", \"source_url\": \"sourceUrl\", \"resolved_url\": \"resolvedUrl\"}, \"dimensions\": {\"height\": 6, \"width\": 5}, \"objects\": {\"collections\": [{\"collection_id\": \"collectionId\", \"objects\": [{\"object\": \"object\", \"location\": {\"top\": 3, \"left\": 4, \"width\": 5, \"height\": 6}, \"score\": 5}]}]}, \"errors\": [{\"code\": \"invalid_field\", \"message\": \"message\", \"more_info\": \"moreInfo\", \"target\": {\"type\": \"field\", \"name\": \"name\"}}]}], \"warnings\": [{\"code\": \"invalid_field\", \"message\": \"message\", \"more_info\": \"moreInfo\"}], \"trace\": \"trace\"}"; + String analyzePath = "/v4/analyze"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the AnalyzeOptions model + AnalyzeOptions analyzeOptionsModel = + new AnalyzeOptions.Builder() + .collectionIds(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .features(new java.util.ArrayList(java.util.Arrays.asList("objects"))) + .imagesFile(mockListFileWithMetadata) + .imageUrl(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .threshold(Float.valueOf("0.15")) + .build(); - /** Test delete image options. */ - @Test - public void testDeleteImageOptions() { - DeleteImageOptions options = - new DeleteImageOptions.Builder().collectionId(COLLECTION_ID).imageId(IMAGE_ID).build(); - options = options.newBuilder().build(); + // Invoke operation with valid options model (positive test) + Response response = + visualRecognitionService.analyze(analyzeOptionsModel).execute(); + assertNotNull(response); + AnalyzeResponse responseObj = response.getResult(); + assertNotNull(responseObj); - assertEquals(COLLECTION_ID, options.collectionId()); - assertEquals(IMAGE_ID, options.imageId()); + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, analyzePath); } - /** Test delete user data options. */ - @Test - public void testDeleteUserDataOptions() { - DeleteUserDataOptions options = - new DeleteUserDataOptions.Builder().customerId(CUSTOMER_ID).build(); - options = options.newBuilder().build(); - - assertEquals(CUSTOMER_ID, options.customerId()); - } + // Test the analyze operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAnalyzeNoOptions() throws Throwable { + // construct the service + constructClientService(); - /** Test get collection options. */ - @Test - public void testGetCollectionOptions() { - GetCollectionOptions options = - new GetCollectionOptions.Builder().collectionId(COLLECTION_ID).build(); - options = options.newBuilder().build(); + server.enqueue(new MockResponse()); - assertEquals(COLLECTION_ID, options.collectionId()); + // Invoke operation with null options model (negative test) + visualRecognitionService.analyze(null).execute(); } - /** Test get image details options. */ @Test - public void testGetImageDetailsOptions() { - GetImageDetailsOptions options = - new GetImageDetailsOptions.Builder().collectionId(COLLECTION_ID).imageId(IMAGE_ID).build(); - options = options.newBuilder().build(); + public void testCreateCollectionWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"collection_id\": \"collectionId\", \"name\": \"name\", \"description\": \"description\", \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\", \"image_count\": 10, \"training_status\": {\"objects\": {\"ready\": false, \"in_progress\": true, \"data_changed\": false, \"latest_failed\": true, \"rscnn_ready\": true, \"description\": \"description\"}}}"; + String createCollectionPath = "/v4/collections"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the ObjectTrainingStatus model + ObjectTrainingStatus objectTrainingStatusModel = + new ObjectTrainingStatus.Builder() + .ready(true) + .inProgress(true) + .dataChanged(true) + .latestFailed(true) + .rscnnReady(true) + .description("testString") + .build(); - assertEquals(COLLECTION_ID, options.collectionId()); - assertEquals(IMAGE_ID, options.imageId()); - } + // Construct an instance of the TrainingStatus model + TrainingStatus trainingStatusModel = + new TrainingStatus.Builder().objects(objectTrainingStatusModel).build(); - /** Test get jpeg image options. */ - @Test - public void testGetJpegImageOptions() { - GetJpegImageOptions options = - new GetJpegImageOptions.Builder() - .collectionId(COLLECTION_ID) - .imageId(IMAGE_ID) - .size(GetJpegImageOptions.Size.FULL) + // Construct an instance of the CreateCollectionOptions model + CreateCollectionOptions createCollectionOptionsModel = + new CreateCollectionOptions.Builder() + .name("testString") + .description("testString") + .trainingStatus(trainingStatusModel) .build(); - options = options.newBuilder().build(); - assertEquals(COLLECTION_ID, options.collectionId()); - assertEquals(IMAGE_ID, options.imageId()); - assertEquals(GetJpegImageOptions.Size.FULL, options.size()); + // Invoke operation with valid options model (positive test) + Response response = + visualRecognitionService.createCollection(createCollectionOptionsModel).execute(); + assertNotNull(response); + Collection responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, createCollectionPath); } - /** Test list collections options. */ @Test - public void testListCollectionsOptions() { - ListCollectionsOptions options = new ListCollectionsOptions.Builder().build(); - options = options.newBuilder().build(); + public void testListCollectionsWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"collections\": [{\"collection_id\": \"collectionId\", \"name\": \"name\", \"description\": \"description\", \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\", \"image_count\": 10, \"training_status\": {\"objects\": {\"ready\": false, \"in_progress\": true, \"data_changed\": false, \"latest_failed\": true, \"rscnn_ready\": true, \"description\": \"description\"}}}]}"; + String listCollectionsPath = "/v4/collections"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the ListCollectionsOptions model + ListCollectionsOptions listCollectionsOptionsModel = new ListCollectionsOptions(); + + // Invoke operation with valid options model (positive test) + Response response = + visualRecognitionService.listCollections(listCollectionsOptionsModel).execute(); + assertNotNull(response); + CollectionsList responseObj = response.getResult(); + assertNotNull(responseObj); - assertNotNull(options); + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listCollectionsPath); } - /** Test list images options. */ @Test - public void testListImagesOptions() { - ListImagesOptions options = new ListImagesOptions.Builder().collectionId(COLLECTION_ID).build(); - options = options.newBuilder().build(); + public void testGetCollectionWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"collection_id\": \"collectionId\", \"name\": \"name\", \"description\": \"description\", \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\", \"image_count\": 10, \"training_status\": {\"objects\": {\"ready\": false, \"in_progress\": true, \"data_changed\": false, \"latest_failed\": true, \"rscnn_ready\": true, \"description\": \"description\"}}}"; + String getCollectionPath = "/v4/collections/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the GetCollectionOptions model + GetCollectionOptions getCollectionOptionsModel = + new GetCollectionOptions.Builder().collectionId("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = + visualRecognitionService.getCollection(getCollectionOptionsModel).execute(); + assertNotNull(response); + Collection responseObj = response.getResult(); + assertNotNull(responseObj); - assertEquals(COLLECTION_ID, options.collectionId()); + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getCollectionPath); } - /** Test location. */ - @Test - public void testLocation() { - Location location = - new Location.Builder().top(TOP).left(LEFT).width(WIDTH).height(HEIGHT).build(); - location = location.newBuilder().build(); + // Test the getCollection operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetCollectionNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); - assertEquals(TOP, location.top()); - assertEquals(LEFT, location.left()); - assertEquals(WIDTH, location.width()); - assertEquals(HEIGHT, location.height()); + // Invoke operation with null options model (negative test) + visualRecognitionService.getCollection(null).execute(); } - /** Test object training status. */ @Test - public void testObjectTrainingStatus() { - ObjectTrainingStatus trainingStatus = + public void testUpdateCollectionWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"collection_id\": \"collectionId\", \"name\": \"name\", \"description\": \"description\", \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\", \"image_count\": 10, \"training_status\": {\"objects\": {\"ready\": false, \"in_progress\": true, \"data_changed\": false, \"latest_failed\": true, \"rscnn_ready\": true, \"description\": \"description\"}}}"; + String updateCollectionPath = "/v4/collections/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the ObjectTrainingStatus model + ObjectTrainingStatus objectTrainingStatusModel = new ObjectTrainingStatus.Builder() .ready(true) .inProgress(true) .dataChanged(true) .latestFailed(true) .rscnnReady(true) - .description(DESCRIPTION) + .description("testString") + .build(); + + // Construct an instance of the TrainingStatus model + TrainingStatus trainingStatusModel = + new TrainingStatus.Builder().objects(objectTrainingStatusModel).build(); + + // Construct an instance of the UpdateCollectionOptions model + UpdateCollectionOptions updateCollectionOptionsModel = + new UpdateCollectionOptions.Builder() + .collectionId("testString") + .name("testString") + .description("testString") + .trainingStatus(trainingStatusModel) .build(); - trainingStatus = trainingStatus.newBuilder().build(); - assertTrue(trainingStatus.ready()); - assertTrue(trainingStatus.inProgress()); - assertTrue(trainingStatus.dataChanged()); - assertTrue(trainingStatus.latestFailed()); - assertEquals(DESCRIPTION, trainingStatus.description()); + // Invoke operation with valid options model (positive test) + Response response = + visualRecognitionService.updateCollection(updateCollectionOptionsModel).execute(); + assertNotNull(response); + Collection responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateCollectionPath); } - /** Test training status. */ - @Test - public void testTrainingStatus() { - TrainingStatus trainingStatus = - new TrainingStatus.Builder().objects(objectTrainingStatus).build(); - trainingStatus = trainingStatus.newBuilder().build(); + // Test the updateCollection operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateCollectionNoOptions() throws Throwable { + // construct the service + constructClientService(); - assertEquals(objectTrainingStatus, trainingStatus.objects()); + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + visualRecognitionService.updateCollection(null).execute(); } - /** Test train options. */ @Test - public void testTrainOptions() { - TrainOptions options = new TrainOptions.Builder().collectionId(COLLECTION_ID).build(); - options = options.newBuilder().build(); + public void testDeleteCollectionWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String deleteCollectionPath = "/v4/collections/testString"; + + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the DeleteCollectionOptions model + DeleteCollectionOptions deleteCollectionOptionsModel = + new DeleteCollectionOptions.Builder().collectionId("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = + visualRecognitionService.deleteCollection(deleteCollectionOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteCollectionPath); + } + + // Test the deleteCollection operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteCollectionNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); - assertEquals(COLLECTION_ID, options.collectionId()); + // Invoke operation with null options model (negative test) + visualRecognitionService.deleteCollection(null).execute(); } - /** Test update collection options. */ @Test - public void testUpdateCollectionOptions() { - UpdateCollectionOptions options = - new UpdateCollectionOptions.Builder() - .collectionId(COLLECTION_ID) - .name(NAME) - .description(DESCRIPTION) + public void testGetModelFileWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = "This is a mock binary response."; + String getModelFilePath = "/v4/collections/testString/model"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/octet-stream") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the GetModelFileOptions model + GetModelFileOptions getModelFileOptionsModel = + new GetModelFileOptions.Builder() + .collectionId("testString") + .feature("objects") + .modelFormat("rscnn") .build(); - options = options.newBuilder().build(); - assertEquals(COLLECTION_ID, options.collectionId()); - assertEquals(NAME, options.name()); - assertEquals(DESCRIPTION, options.description()); + // Invoke operation with valid options model (positive test) + Response response = + visualRecognitionService.getModelFile(getModelFileOptionsModel).execute(); + assertNotNull(response); + InputStream responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(query.get("feature"), "objects"); + assertEquals(query.get("model_format"), "rscnn"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getModelFilePath); } - /** Test get training usage options. */ - @Test - public void testGetTrainingUsageOptions() { - GetTrainingUsageOptions options = - new GetTrainingUsageOptions.Builder().startTime(START_TIME).endTime(END_TIME).build(); - options = options.newBuilder().build(); + // Test the getModelFile operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetModelFileNoOptions() throws Throwable { + // construct the service + constructClientService(); - assertEquals(START_TIME, options.startTime()); - assertEquals(END_TIME, options.endTime()); + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + visualRecognitionService.getModelFile(null).execute(); } - /** Test analyze. */ @Test - public void testAnalyze() { - server.enqueue(jsonResponse(analyzeResponse)); - - AnalyzeOptions options = - new AnalyzeOptions.Builder() - .addCollectionIds(COLLECTION_ID) - .addFeatures(AnalyzeOptions.Features.OBJECTS) - .addImagesFile(fileWithMetadata) - .addImageUrl(IMAGE_URL) - .threshold(THRESHOLD) + public void testAddImagesWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"images\": [{\"image_id\": \"imageId\", \"updated\": \"2019-01-01T12:00:00\", \"created\": \"2019-01-01T12:00:00\", \"source\": {\"type\": \"file\", \"filename\": \"filename\", \"archive_filename\": \"archiveFilename\", \"source_url\": \"sourceUrl\", \"resolved_url\": \"resolvedUrl\"}, \"dimensions\": {\"height\": 6, \"width\": 5}, \"errors\": [{\"code\": \"invalid_field\", \"message\": \"message\", \"more_info\": \"moreInfo\", \"target\": {\"type\": \"field\", \"name\": \"name\"}}], \"training_data\": {\"objects\": [{\"object\": \"object\", \"location\": {\"top\": 3, \"left\": 4, \"width\": 5, \"height\": 6}}]}}], \"warnings\": [{\"code\": \"invalid_field\", \"message\": \"message\", \"more_info\": \"moreInfo\"}], \"trace\": \"trace\"}"; + String addImagesPath = "/v4/collections/testString/images"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the AddImagesOptions model + AddImagesOptions addImagesOptionsModel = + new AddImagesOptions.Builder() + .collectionId("testString") + .imagesFile(mockListFileWithMetadata) + .imageUrl(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .trainingData( + "\"{\"objects\":[{\"object\":\"2018-Fit\",\"location\":{\"left\":33,\"top\":8,\"width\":760,\"height\":419}}]}\"") .build(); - AnalyzeResponse response = service.analyze(options).execute().getResult(); - - assertEquals(IMAGE_TYPE, response.getImages().get(0).getSource().getType()); - assertEquals(FILENAME, response.getImages().get(0).getSource().getFilename()); - assertEquals(ARCHIVE_FILENAME, response.getImages().get(0).getSource().getArchiveFilename()); - assertEquals(SOURCE_URL, response.getImages().get(0).getSource().getSourceUrl()); - assertEquals(RESOLVED_URL, response.getImages().get(0).getSource().getResolvedUrl()); - assertEquals(HEIGHT, response.getImages().get(0).getDimensions().getHeight()); - assertEquals(WIDTH, response.getImages().get(0).getDimensions().getWidth()); - assertEquals( - COLLECTION_ID, - response.getImages().get(0).getObjects().getCollections().get(0).getCollectionId()); - assertEquals( - OBJECT, - response - .getImages() - .get(0) - .getObjects() - .getCollections() - .get(0) - .getObjects() - .get(0) - .getObject()); - assertEquals( - TOP, - response - .getImages() - .get(0) - .getObjects() - .getCollections() - .get(0) - .getObjects() - .get(0) - .getLocation() - .top()); - assertEquals( - LEFT, - response - .getImages() - .get(0) - .getObjects() - .getCollections() - .get(0) - .getObjects() - .get(0) - .getLocation() - .left()); - assertEquals( - WIDTH, - response - .getImages() - .get(0) - .getObjects() - .getCollections() - .get(0) - .getObjects() - .get(0) - .getLocation() - .width()); - assertEquals( - HEIGHT, - response - .getImages() - .get(0) - .getObjects() - .getCollections() - .get(0) - .getObjects() - .get(0) - .getLocation() - .height()); - assertEquals( - SCORE, - response - .getImages() - .get(0) - .getObjects() - .getCollections() - .get(0) - .getObjects() - .get(0) - .getScore()); - assertEquals(CODE, response.getImages().get(0).getErrors().get(0).getCode()); - assertEquals(MESSAGE, response.getImages().get(0).getErrors().get(0).getMessage()); - assertEquals(MORE_INFO, response.getImages().get(0).getErrors().get(0).getMoreInfo()); - assertEquals(ERROR_TYPE, response.getImages().get(0).getErrors().get(0).getTarget().getType()); - assertEquals(NAME, response.getImages().get(0).getErrors().get(0).getTarget().getName()); - assertEquals(CODE, response.getWarnings().get(0).getCode()); - assertEquals(MESSAGE, response.getWarnings().get(0).getMessage()); - assertEquals(MORE_INFO, response.getWarnings().get(0).getMoreInfo()); - assertEquals(TRACE, response.getTrace()); - } - - private void assertCollection(Collection response) { - assertEquals(COLLECTION_ID, response.getCollectionId()); - assertEquals(NAME, response.getName()); - assertEquals(DESCRIPTION, response.getDescription()); - assertEquals(testDate, response.getCreated()); - assertEquals(testDate, response.getUpdated()); - assertEquals(IMAGE_COUNT, response.getImageCount()); - assertTrue(response.getTrainingStatus().objects().ready()); - assertTrue(response.getTrainingStatus().objects().inProgress()); - assertTrue(response.getTrainingStatus().objects().dataChanged()); - assertTrue(response.getTrainingStatus().objects().latestFailed()); - assertEquals(DESCRIPTION, response.getTrainingStatus().objects().description()); - } - - /** Test create collection. */ - @Test - public void testCreateCollection() { - server.enqueue(jsonResponse(collection)); - CreateCollectionOptions options = - new CreateCollectionOptions.Builder().name(NAME).description(DESCRIPTION).build(); - Collection response = service.createCollection(options).execute().getResult(); + // Invoke operation with valid options model (positive test) + Response response = + visualRecognitionService.addImages(addImagesOptionsModel).execute(); + assertNotNull(response); + ImageDetailsList responseObj = response.getResult(); + assertNotNull(responseObj); - assertCollection(response); + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, addImagesPath); } - private void assertCollectionsList(CollectionsList response) { - assertEquals(COLLECTION_ID, response.getCollections().get(0).getCollectionId()); - assertEquals(NAME, response.getCollections().get(0).getName()); - assertEquals(DESCRIPTION, response.getCollections().get(0).getDescription()); - assertEquals(testDate, response.getCollections().get(0).getCreated()); - assertEquals(testDate, response.getCollections().get(0).getUpdated()); - assertEquals(IMAGE_COUNT, response.getCollections().get(0).getImageCount()); - assertTrue(response.getCollections().get(0).getTrainingStatus().objects().ready()); - assertTrue(response.getCollections().get(0).getTrainingStatus().objects().inProgress()); - assertTrue(response.getCollections().get(0).getTrainingStatus().objects().dataChanged()); - assertTrue(response.getCollections().get(0).getTrainingStatus().objects().latestFailed()); - assertEquals( - DESCRIPTION, response.getCollections().get(0).getTrainingStatus().objects().description()); + // Test the addImages operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAddImagesNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + visualRecognitionService.addImages(null).execute(); } - /** Test list collections. */ @Test - public void testListCollections() { - server.enqueue(jsonResponse(collectionsList)); - - ListCollectionsOptions options = new ListCollectionsOptions.Builder().build(); - CollectionsList response = service.listCollections(options).execute().getResult(); + public void testListImagesWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"images\": [{\"image_id\": \"imageId\", \"updated\": \"2019-01-01T12:00:00\"}]}"; + String listImagesPath = "/v4/collections/testString/images"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the ListImagesOptions model + ListImagesOptions listImagesOptionsModel = + new ListImagesOptions.Builder().collectionId("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = + visualRecognitionService.listImages(listImagesOptionsModel).execute(); + assertNotNull(response); + ImageSummaryList responseObj = response.getResult(); + assertNotNull(responseObj); - assertCollectionsList(response); + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listImagesPath); } - /** Test list collections no options. */ - @Test - public void testListCollectionsNoOptions() { - server.enqueue(jsonResponse(collectionsList)); + // Test the listImages operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListImagesNoOptions() throws Throwable { + // construct the service + constructClientService(); - CollectionsList response = service.listCollections().execute().getResult(); + server.enqueue(new MockResponse()); - assertCollectionsList(response); + // Invoke operation with null options model (negative test) + visualRecognitionService.listImages(null).execute(); } - /** Test get collection. */ @Test - public void testGetCollection() { - server.enqueue(jsonResponse(collection)); + public void testGetImageDetailsWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"image_id\": \"imageId\", \"updated\": \"2019-01-01T12:00:00\", \"created\": \"2019-01-01T12:00:00\", \"source\": {\"type\": \"file\", \"filename\": \"filename\", \"archive_filename\": \"archiveFilename\", \"source_url\": \"sourceUrl\", \"resolved_url\": \"resolvedUrl\"}, \"dimensions\": {\"height\": 6, \"width\": 5}, \"errors\": [{\"code\": \"invalid_field\", \"message\": \"message\", \"more_info\": \"moreInfo\", \"target\": {\"type\": \"field\", \"name\": \"name\"}}], \"training_data\": {\"objects\": [{\"object\": \"object\", \"location\": {\"top\": 3, \"left\": 4, \"width\": 5, \"height\": 6}}]}}"; + String getImageDetailsPath = "/v4/collections/testString/images/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the GetImageDetailsOptions model + GetImageDetailsOptions getImageDetailsOptionsModel = + new GetImageDetailsOptions.Builder() + .collectionId("testString") + .imageId("testString") + .build(); - GetCollectionOptions options = - new GetCollectionOptions.Builder().collectionId(COLLECTION_ID).build(); - Collection response = service.getCollection(options).execute().getResult(); + // Invoke operation with valid options model (positive test) + Response response = + visualRecognitionService.getImageDetails(getImageDetailsOptionsModel).execute(); + assertNotNull(response); + ImageDetails responseObj = response.getResult(); + assertNotNull(responseObj); - assertCollection(response); + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getImageDetailsPath); } - /** Test update collection. */ - @Test - public void testUpdateCollection() { - server.enqueue(jsonResponse(collection)); + // Test the getImageDetails operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetImageDetailsNoOptions() throws Throwable { + // construct the service + constructClientService(); - UpdateCollectionOptions options = - new UpdateCollectionOptions.Builder() - .collectionId(COLLECTION_ID) - .name(NAME) - .description(DESCRIPTION) - .build(); - Collection response = service.updateCollection(options).execute().getResult(); + server.enqueue(new MockResponse()); - assertCollection(response); + // Invoke operation with null options model (negative test) + visualRecognitionService.getImageDetails(null).execute(); } - /** - * Test delete collection. - * - * @throws InterruptedException the interrupted exception - */ @Test - public void testDeleteCollection() throws InterruptedException { - server.enqueue(new MockResponse()); + public void testDeleteImageWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String deleteImagePath = "/v4/collections/testString/images/testString"; + + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); - DeleteCollectionOptions options = - new DeleteCollectionOptions.Builder().collectionId(COLLECTION_ID).build(); - service.deleteCollection(options).execute(); + constructClientService(); + + // Construct an instance of the DeleteImageOptions model + DeleteImageOptions deleteImageOptionsModel = + new DeleteImageOptions.Builder().collectionId("testString").imageId("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = + visualRecognitionService.deleteImage(deleteImageOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); + + // Verify the contents of the request RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteImagePath); + } - assertEquals("DELETE", request.getMethod()); - } - - private void assertImageDetails(ImageDetails response) { - assertEquals(IMAGE_ID, response.getImageId()); - assertEquals(testDate, response.getCreated()); - assertEquals(testDate, response.getUpdated()); - assertEquals(IMAGE_TYPE, response.getSource().getType()); - assertEquals(FILENAME, response.getSource().getFilename()); - assertEquals(ARCHIVE_FILENAME, response.getSource().getArchiveFilename()); - assertEquals(SOURCE_URL, response.getSource().getSourceUrl()); - assertEquals(RESOLVED_URL, response.getSource().getResolvedUrl()); - assertEquals(HEIGHT, response.getDimensions().getHeight()); - assertEquals(WIDTH, response.getDimensions().getWidth()); - assertEquals(CODE, response.getErrors().get(0).getCode()); - assertEquals(MESSAGE, response.getErrors().get(0).getMessage()); - assertEquals(MORE_INFO, response.getErrors().get(0).getMoreInfo()); - assertEquals(ERROR_TYPE, response.getErrors().get(0).getTarget().getType()); - assertEquals(NAME, response.getErrors().get(0).getTarget().getName()); - assertEquals(OBJECT, response.getTrainingData().getObjects().get(0).object()); - assertEquals(TOP, response.getTrainingData().getObjects().get(0).location().top()); - assertEquals(LEFT, response.getTrainingData().getObjects().get(0).location().left()); - assertEquals(WIDTH, response.getTrainingData().getObjects().get(0).location().width()); - assertEquals(HEIGHT, response.getTrainingData().getObjects().get(0).location().height()); - } - - /** Test add images. */ - @Test - public void testAddImages() { - server.enqueue(jsonResponse(imageDetailsList)); + // Test the deleteImage operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteImageNoOptions() throws Throwable { + // construct the service + constructClientService(); - AddImagesOptions options = - new AddImagesOptions.Builder() - .addImagesFile(fileWithMetadata) - .addImageUrl(IMAGE_URL) - .collectionId(COLLECTION_ID) - .trainingData(TRAINING_DATA) - .build(); - ImageDetailsList response = service.addImages(options).execute().getResult(); + server.enqueue(new MockResponse()); - assertImageDetails(response.getImages().get(0)); - assertEquals(CODE, response.getWarnings().get(0).getCode()); - assertEquals(MESSAGE, response.getWarnings().get(0).getMessage()); - assertEquals(MORE_INFO, response.getWarnings().get(0).getMoreInfo()); - assertEquals(TRACE, response.getTrace()); + // Invoke operation with null options model (negative test) + visualRecognitionService.deleteImage(null).execute(); } - /** Test list images. */ @Test - public void testListImages() { - server.enqueue(jsonResponse(imageSummaryList)); + public void testGetJpegImageWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = "This is a mock binary response."; + String getJpegImagePath = "/v4/collections/testString/images/testString/jpeg"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "image/jpeg") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the GetJpegImageOptions model + GetJpegImageOptions getJpegImageOptionsModel = + new GetJpegImageOptions.Builder() + .collectionId("testString") + .imageId("testString") + .size("full") + .build(); - ListImagesOptions options = new ListImagesOptions.Builder().collectionId(COLLECTION_ID).build(); - ImageSummaryList response = service.listImages(options).execute().getResult(); + // Invoke operation with valid options model (positive test) + Response response = + visualRecognitionService.getJpegImage(getJpegImageOptionsModel).execute(); + assertNotNull(response); + InputStream responseObj = response.getResult(); + assertNotNull(responseObj); - assertEquals(IMAGE_ID, response.getImages().get(0).getImageId()); - assertEquals(testDate, response.getImages().get(0).getUpdated()); + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(query.get("size"), "full"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getJpegImagePath); } - /** Test get image details. */ - @Test - public void testGetImageDetails() { - server.enqueue(jsonResponse(imageDetails)); + // Test the getJpegImage operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetJpegImageNoOptions() throws Throwable { + // construct the service + constructClientService(); - GetImageDetailsOptions options = - new GetImageDetailsOptions.Builder().collectionId(COLLECTION_ID).imageId(IMAGE_ID).build(); - ImageDetails response = service.getImageDetails(options).execute().getResult(); + server.enqueue(new MockResponse()); - assertImageDetails(response); + // Invoke operation with null options model (negative test) + visualRecognitionService.getJpegImage(null).execute(); } - /** - * Test delete image. - * - * @throws InterruptedException the interrupted exception - */ @Test - public void testDeleteImage() throws InterruptedException { - server.enqueue(new MockResponse()); + public void testListObjectMetadataWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"object_count\": 11, \"objects\": [{\"object\": \"object\", \"count\": 5}]}"; + String listObjectMetadataPath = "/v4/collections/testString/objects"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the ListObjectMetadataOptions model + ListObjectMetadataOptions listObjectMetadataOptionsModel = + new ListObjectMetadataOptions.Builder().collectionId("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = + visualRecognitionService.listObjectMetadata(listObjectMetadataOptionsModel).execute(); + assertNotNull(response); + ObjectMetadataList responseObj = response.getResult(); + assertNotNull(responseObj); - DeleteImageOptions options = - new DeleteImageOptions.Builder().collectionId(COLLECTION_ID).imageId(IMAGE_ID).build(); - service.deleteImage(options).execute(); + // Verify the contents of the request RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, listObjectMetadataPath); + } + + // Test the listObjectMetadata operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListObjectMetadataNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); - assertEquals("DELETE", request.getMethod()); + // Invoke operation with null options model (negative test) + visualRecognitionService.listObjectMetadata(null).execute(); } - /** - * Test get jpeg image. - * - * @throws IOException Signals that an I/O exception has occurred. - * @throws InterruptedException the interrupted exception - */ @Test - public void testGetJpegImage() throws IOException, InterruptedException { - @SuppressWarnings("resource") - Buffer buffer = new Buffer().write(Files.toByteArray(imageFile)); - server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, "image/jpeg").setBody(buffer)); + public void testUpdateObjectMetadataWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = "{\"object\": \"object\", \"count\": 5}"; + String updateObjectMetadataPath = "/v4/collections/testString/objects/testString"; - GetJpegImageOptions options = - new GetJpegImageOptions.Builder() - .collectionId(COLLECTION_ID) - .imageId(IMAGE_ID) - .size(GetJpegImageOptions.Size.FULL) + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the UpdateObjectMetadataOptions model + UpdateObjectMetadataOptions updateObjectMetadataOptionsModel = + new UpdateObjectMetadataOptions.Builder() + .collectionId("testString") + .object("testString") + .newObject("testString") .build(); - InputStream response = service.getJpegImage(options).execute().getResult(); - RecordedRequest request = server.takeRequest(); - assertEquals("GET", request.getMethod()); + // Invoke operation with valid options model (positive test) + Response response = + visualRecognitionService.updateObjectMetadata(updateObjectMetadataOptionsModel).execute(); assertNotNull(response); - response.close(); + UpdateObjectMetadata responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, updateObjectMetadataPath); } - /** Test train. */ - @Test - public void testTrain() { - server.enqueue(jsonResponse(collection)); + // Test the updateObjectMetadata operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateObjectMetadataNoOptions() throws Throwable { + // construct the service + constructClientService(); - TrainOptions options = new TrainOptions.Builder().collectionId(COLLECTION_ID).build(); - Collection response = service.train(options).execute().getResult(); + server.enqueue(new MockResponse()); - assertCollection(response); + // Invoke operation with null options model (negative test) + visualRecognitionService.updateObjectMetadata(null).execute(); } - /** Test add image training data. */ @Test - public void testAddImageTrainingData() { - server.enqueue(jsonResponse(trainingDataObjects)); - - AddImageTrainingDataOptions options = - new AddImageTrainingDataOptions.Builder() - .collectionId(COLLECTION_ID) - .imageId(IMAGE_ID) - .addObjects(trainingDataObject) + public void testGetObjectMetadataWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = "{\"object\": \"object\", \"count\": 5}"; + String getObjectMetadataPath = "/v4/collections/testString/objects/testString"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the GetObjectMetadataOptions model + GetObjectMetadataOptions getObjectMetadataOptionsModel = + new GetObjectMetadataOptions.Builder() + .collectionId("testString") + .object("testString") .build(); - TrainingDataObjects response = service.addImageTrainingData(options).execute().getResult(); - assertEquals(OBJECT, response.getObjects().get(0).object()); - assertEquals(TOP, response.getObjects().get(0).location().top()); - assertEquals(LEFT, response.getObjects().get(0).location().left()); - assertEquals(WIDTH, response.getObjects().get(0).location().width()); - assertEquals(HEIGHT, response.getObjects().get(0).location().height()); + // Invoke operation with valid options model (positive test) + Response response = + visualRecognitionService.getObjectMetadata(getObjectMetadataOptionsModel).execute(); + assertNotNull(response); + ObjectMetadata responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getObjectMetadataPath); } - /** - * Test delete user data. - * - * @throws InterruptedException the interrupted exception - */ - @Test - public void testDeleteUserData() throws InterruptedException { - server.enqueue(new MockResponse()); + // Test the getObjectMetadata operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetObjectMetadataNoOptions() throws Throwable { + // construct the service + constructClientService(); - DeleteUserDataOptions options = - new DeleteUserDataOptions.Builder().customerId(CUSTOMER_ID).build(); - service.deleteUserData(options).execute(); - RecordedRequest request = server.takeRequest(); + server.enqueue(new MockResponse()); - assertEquals("DELETE", request.getMethod()); + // Invoke operation with null options model (negative test) + visualRecognitionService.getObjectMetadata(null).execute(); } - /** - * Test get training usage. - * - * @throws InterruptedException the interrupted exception - */ @Test - public void testGetTrainingUsage() throws InterruptedException { - server.enqueue(jsonResponse(trainingEvents)); + public void testDeleteObjectWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String deleteObjectPath = "/v4/collections/testString/objects/testString"; - GetTrainingUsageOptions options = new GetTrainingUsageOptions.Builder().build(); - TrainingEvents response = service.getTrainingUsage(options).execute().getResult(); + server.enqueue(new MockResponse().setResponseCode(200).setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the DeleteObjectOptions model + DeleteObjectOptions deleteObjectOptionsModel = + new DeleteObjectOptions.Builder().collectionId("testString").object("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = + visualRecognitionService.deleteObject(deleteObjectOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); + + // Verify the contents of the request RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteObjectPath); + } + + // Test the deleteObject operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteObjectNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + visualRecognitionService.deleteObject(null).execute(); + } - assertEquals("GET", request.getMethod()); - assertEquals(testDate, response.getStartTime()); - assertEquals(testDate, response.getEndTime()); - assertEquals(COMPLETED_EVENTS, response.getCompletedEvents()); - assertEquals(TRAINED_IMAGES, response.getTrainedImages()); - assertEquals(TYPE, response.getEvents().get(0).getType()); - assertEquals(COLLECTION_ID, response.getEvents().get(0).getCollectionId()); - assertEquals(testDate, response.getEvents().get(0).getCompletionTime()); - assertEquals(STATUS, response.getEvents().get(0).getStatus()); - assertEquals(IMAGE_COUNT, response.getEvents().get(0).getImageCount()); - } - - /** - * Test list object metadata. - * - * @throws InterruptedException the interrupted exception - */ @Test - public void testListObjectMetadata() throws InterruptedException { - server.enqueue(jsonResponse(objectMetadataList)); + public void testTrainWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"collection_id\": \"collectionId\", \"name\": \"name\", \"description\": \"description\", \"created\": \"2019-01-01T12:00:00\", \"updated\": \"2019-01-01T12:00:00\", \"image_count\": 10, \"training_status\": {\"objects\": {\"ready\": false, \"in_progress\": true, \"data_changed\": false, \"latest_failed\": true, \"rscnn_ready\": true, \"description\": \"description\"}}}"; + String trainPath = "/v4/collections/testString/train"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(202) + .setBody(mockResponseBody)); - ListObjectMetadataOptions options = - new ListObjectMetadataOptions.Builder().collectionId(COLLECTION_ID).build(); - ObjectMetadataList response = service.listObjectMetadata(options).execute().getResult(); + constructClientService(); + + // Construct an instance of the TrainOptions model + TrainOptions trainOptionsModel = new TrainOptions.Builder().collectionId("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = visualRecognitionService.train(trainOptionsModel).execute(); + assertNotNull(response); + Collection responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, trainPath); + } + + // Test the train operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testTrainNoOptions() throws Throwable { + // construct the service + constructClientService(); - assertEquals("GET", request.getMethod()); - assertEquals(objectMetadataList.getObjects(), response.getObjects()); - assertEquals(objectMetadataList.getObjectCount(), response.getObjectCount()); + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + visualRecognitionService.train(null).execute(); } - /** - * Test update object name. - * - * @throws InterruptedException the interrupted exception - */ @Test - public void testUpdateObjectName() throws InterruptedException { - server.enqueue(jsonResponse(objectName)); + public void testAddImageTrainingDataWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"objects\": [{\"object\": \"object\", \"location\": {\"top\": 3, \"left\": 4, \"width\": 5, \"height\": 6}}]}"; + String addImageTrainingDataPath = "/v4/collections/testString/images/testString/training_data"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the Location model + Location locationModel = + new Location.Builder() + .top(Long.valueOf("26")) + .left(Long.valueOf("26")) + .width(Long.valueOf("26")) + .height(Long.valueOf("26")) + .build(); - UpdateObjectMetadataOptions options = - new UpdateObjectMetadataOptions.Builder() - .collectionId(COLLECTION_ID) - .object(NAME) - .newObject(MESSAGE) + // Construct an instance of the TrainingDataObject model + TrainingDataObject trainingDataObjectModel = + new TrainingDataObject.Builder().object("testString").location(locationModel).build(); + + // Construct an instance of the AddImageTrainingDataOptions model + AddImageTrainingDataOptions addImageTrainingDataOptionsModel = + new AddImageTrainingDataOptions.Builder() + .collectionId("testString") + .imageId("testString") + .objects( + new java.util.ArrayList( + java.util.Arrays.asList(trainingDataObjectModel))) .build(); - UpdateObjectMetadata response = service.updateObjectMetadata(options).execute().getResult(); + + // Invoke operation with valid options model (positive test) + Response response = + visualRecognitionService.addImageTrainingData(addImageTrainingDataOptionsModel).execute(); + assertNotNull(response); + TrainingDataObjects responseObj = response.getResult(); + assertNotNull(responseObj); + + // Verify the contents of the request RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "POST"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, addImageTrainingDataPath); + } + + // Test the addImageTrainingData operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAddImageTrainingDataNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); - assertEquals("POST", request.getMethod()); - assertEquals(objectName.getObject(), response.object()); - assertEquals(objectName.getCount(), response.count()); + // Invoke operation with null options model (negative test) + visualRecognitionService.addImageTrainingData(null).execute(); } - /** - * Test get object metadata. - * - * @throws InterruptedException the interrupted exception - */ @Test - public void testGetObjectMetadata() throws InterruptedException { - server.enqueue(jsonResponse(objectName)); + public void testGetTrainingUsageWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = + "{\"start_time\": \"2019-01-01T12:00:00\", \"end_time\": \"2019-01-01T12:00:00\", \"completed_events\": 15, \"trained_images\": 13, \"events\": [{\"type\": \"objects\", \"collection_id\": \"collectionId\", \"completion_time\": \"2019-01-01T12:00:00\", \"status\": \"failed\", \"image_count\": 10}]}"; + String getTrainingUsagePath = "/v4/training_usage"; + + server.enqueue( + new MockResponse() + .setHeader("Content-type", "application/json") + .setResponseCode(200) + .setBody(mockResponseBody)); + + constructClientService(); + + // Construct an instance of the GetTrainingUsageOptions model + GetTrainingUsageOptions getTrainingUsageOptionsModel = + new GetTrainingUsageOptions.Builder() + .startTime(TestUtilities.createMockDate("2019-01-01")) + .endTime(TestUtilities.createMockDate("2019-01-01")) + .build(); - GetObjectMetadataOptions options = - new GetObjectMetadataOptions.Builder().collectionId(COLLECTION_ID).object(NAME).build(); - ObjectMetadata response = service.getObjectMetadata(options).execute().getResult(); - RecordedRequest request = server.takeRequest(); + // Invoke operation with valid options model (positive test) + Response response = + visualRecognitionService.getTrainingUsage(getTrainingUsageOptionsModel).execute(); + assertNotNull(response); + TrainingEvents responseObj = response.getResult(); + assertNotNull(responseObj); - assertEquals("GET", request.getMethod()); - assertEquals(objectName.getObject(), response.getObject()); - assertEquals(objectName.getCount(), response.getCount()); + // Verify the contents of the request + RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "GET"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, getTrainingUsagePath); } - /** - * Test delete object. - * - * @throws InterruptedException the interrupted exception - */ @Test - public void testDeleteObject() throws InterruptedException { - server.enqueue(new MockResponse()); + public void testDeleteUserDataWOptions() throws Throwable { + // Schedule some responses. + String mockResponseBody = ""; + String deleteUserDataPath = "/v4/user_data"; - DeleteObjectOptions options = - new DeleteObjectOptions.Builder().collectionId(COLLECTION_ID).object(NAME).build(); + server.enqueue(new MockResponse().setResponseCode(202).setBody(mockResponseBody)); - service.deleteObject(options).execute(); + constructClientService(); + + // Construct an instance of the DeleteUserDataOptions model + DeleteUserDataOptions deleteUserDataOptionsModel = + new DeleteUserDataOptions.Builder().customerId("testString").build(); + + // Invoke operation with valid options model (positive test) + Response response = + visualRecognitionService.deleteUserData(deleteUserDataOptionsModel).execute(); + assertNotNull(response); + Void responseObj = response.getResult(); + // Response does not have a return type. Check that the result is null. + assertNull(responseObj); + + // Verify the contents of the request RecordedRequest request = server.takeRequest(); + assertNotNull(request); + assertEquals(request.getMethod(), "DELETE"); + + // Check query + Map query = TestUtilities.parseQueryString(request); + assertNotNull(query); + // Get query params + assertEquals(query.get("version"), "testString"); + assertEquals(query.get("customer_id"), "testString"); + // Check request path + String parsedPath = TestUtilities.parseReqPath(request); + assertEquals(parsedPath, deleteUserDataPath); + } + + // Test the deleteUserData operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteUserDataNoOptions() throws Throwable { + // construct the service + constructClientService(); + + server.enqueue(new MockResponse()); + + // Invoke operation with null options model (negative test) + visualRecognitionService.deleteUserData(null).execute(); + } + + /** Initialize the server */ + @BeforeMethod + public void setUpMockServer() { + try { + server = new MockWebServer(); + // register handler + server.start(); + } catch (IOException err) { + fail("Failed to instantiate mock web server"); + } + } - assertEquals("DELETE", request.getMethod()); + @AfterMethod + public void tearDownMockServer() throws IOException { + server.shutdown(); + visualRecognitionService = null; } } diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/AddImageTrainingDataOptionsTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/AddImageTrainingDataOptionsTest.java new file mode 100644 index 00000000000..6a1d9552dbf --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/AddImageTrainingDataOptionsTest.java @@ -0,0 +1,70 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v4.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v4.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the AddImageTrainingDataOptions model. */ +public class AddImageTrainingDataOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAddImageTrainingDataOptions() throws Throwable { + Location locationModel = + new Location.Builder() + .top(Long.valueOf("26")) + .left(Long.valueOf("26")) + .width(Long.valueOf("26")) + .height(Long.valueOf("26")) + .build(); + assertEquals(locationModel.top(), Long.valueOf("26")); + assertEquals(locationModel.left(), Long.valueOf("26")); + assertEquals(locationModel.width(), Long.valueOf("26")); + assertEquals(locationModel.height(), Long.valueOf("26")); + + TrainingDataObject trainingDataObjectModel = + new TrainingDataObject.Builder().object("testString").location(locationModel).build(); + assertEquals(trainingDataObjectModel.object(), "testString"); + assertEquals(trainingDataObjectModel.location(), locationModel); + + AddImageTrainingDataOptions addImageTrainingDataOptionsModel = + new AddImageTrainingDataOptions.Builder() + .collectionId("testString") + .imageId("testString") + .objects( + new java.util.ArrayList( + java.util.Arrays.asList(trainingDataObjectModel))) + .build(); + assertEquals(addImageTrainingDataOptionsModel.collectionId(), "testString"); + assertEquals(addImageTrainingDataOptionsModel.imageId(), "testString"); + assertEquals( + addImageTrainingDataOptionsModel.objects(), + new java.util.ArrayList( + java.util.Arrays.asList(trainingDataObjectModel))); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAddImageTrainingDataOptionsError() throws Throwable { + new AddImageTrainingDataOptions.Builder().build(); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/AddImagesOptionsTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/AddImagesOptionsTest.java new file mode 100644 index 00000000000..fe32b8fd001 --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/AddImagesOptionsTest.java @@ -0,0 +1,55 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v4.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v4.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the AddImagesOptions model. */ +public class AddImagesOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAddImagesOptions() throws Throwable { + AddImagesOptions addImagesOptionsModel = + new AddImagesOptions.Builder() + .collectionId("testString") + .imagesFile(mockListFileWithMetadata) + .imageUrl(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .trainingData( + "\"{\"objects\":[{\"object\":\"2018-Fit\",\"location\":{\"left\":33,\"top\":8,\"width\":760,\"height\":419}}]}\"") + .build(); + assertEquals(addImagesOptionsModel.collectionId(), "testString"); + assertEquals(addImagesOptionsModel.imagesFile(), mockListFileWithMetadata); + assertEquals( + addImagesOptionsModel.imageUrl(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals( + addImagesOptionsModel.trainingData(), + "\"{\"objects\":[{\"object\":\"2018-Fit\",\"location\":{\"left\":33,\"top\":8,\"width\":760,\"height\":419}}]}\""); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAddImagesOptionsError() throws Throwable { + new AddImagesOptions.Builder().build(); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/AnalyzeOptionsTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/AnalyzeOptionsTest.java new file mode 100644 index 00000000000..1f613b7c017 --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/AnalyzeOptionsTest.java @@ -0,0 +1,58 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v4.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v4.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the AnalyzeOptions model. */ +public class AnalyzeOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAnalyzeOptions() throws Throwable { + AnalyzeOptions analyzeOptionsModel = + new AnalyzeOptions.Builder() + .collectionIds(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .features(new java.util.ArrayList(java.util.Arrays.asList("objects"))) + .imagesFile(mockListFileWithMetadata) + .imageUrl(new java.util.ArrayList(java.util.Arrays.asList("testString"))) + .threshold(Float.valueOf("0.15")) + .build(); + assertEquals( + analyzeOptionsModel.collectionIds(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals( + analyzeOptionsModel.features(), + new java.util.ArrayList(java.util.Arrays.asList("objects"))); + assertEquals(analyzeOptionsModel.imagesFile(), mockListFileWithMetadata); + assertEquals( + analyzeOptionsModel.imageUrl(), + new java.util.ArrayList(java.util.Arrays.asList("testString"))); + assertEquals(analyzeOptionsModel.threshold(), Float.valueOf("0.15")); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testAnalyzeOptionsError() throws Throwable { + new AnalyzeOptions.Builder().build(); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/AnalyzeResponseTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/AnalyzeResponseTest.java new file mode 100644 index 00000000000..bed09666b82 --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/AnalyzeResponseTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v4.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v4.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the AnalyzeResponse model. */ +public class AnalyzeResponseTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testAnalyzeResponse() throws Throwable { + AnalyzeResponse analyzeResponseModel = new AnalyzeResponse(); + assertNull(analyzeResponseModel.getImages()); + assertNull(analyzeResponseModel.getWarnings()); + assertNull(analyzeResponseModel.getTrace()); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/CollectionObjectsTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/CollectionObjectsTest.java new file mode 100644 index 00000000000..f4f353705f8 --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/CollectionObjectsTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v4.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v4.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CollectionObjects model. */ +public class CollectionObjectsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCollectionObjects() throws Throwable { + CollectionObjects collectionObjectsModel = new CollectionObjects(); + assertNull(collectionObjectsModel.getCollectionId()); + assertNull(collectionObjectsModel.getObjects()); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/CollectionTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/CollectionTest.java new file mode 100644 index 00000000000..1acf79e1ad6 --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/CollectionTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v4.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v4.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Collection model. */ +public class CollectionTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCollection() throws Throwable { + Collection collectionModel = new Collection(); + assertNull(collectionModel.getName()); + assertNull(collectionModel.getDescription()); + assertNull(collectionModel.getTrainingStatus()); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/CollectionTrainingStatusTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/CollectionTrainingStatusTest.java new file mode 100644 index 00000000000..347f2618ee1 --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/CollectionTrainingStatusTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v4.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v4.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CollectionTrainingStatus model. */ +public class CollectionTrainingStatusTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCollectionTrainingStatus() throws Throwable { + CollectionTrainingStatus collectionTrainingStatusModel = new CollectionTrainingStatus(); + assertNull(collectionTrainingStatusModel.getObjects()); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/CollectionsListTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/CollectionsListTest.java new file mode 100644 index 00000000000..a4d4d09e20e --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/CollectionsListTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v4.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v4.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CollectionsList model. */ +public class CollectionsListTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCollectionsList() throws Throwable { + CollectionsList collectionsListModel = new CollectionsList(); + assertNull(collectionsListModel.getCollections()); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/CreateCollectionOptionsTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/CreateCollectionOptionsTest.java new file mode 100644 index 00000000000..b057a107d13 --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/CreateCollectionOptionsTest.java @@ -0,0 +1,63 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v4.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v4.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the CreateCollectionOptions model. */ +public class CreateCollectionOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testCreateCollectionOptions() throws Throwable { + ObjectTrainingStatus objectTrainingStatusModel = + new ObjectTrainingStatus.Builder() + .ready(true) + .inProgress(true) + .dataChanged(true) + .latestFailed(true) + .rscnnReady(true) + .description("testString") + .build(); + assertEquals(objectTrainingStatusModel.ready(), Boolean.valueOf(true)); + assertEquals(objectTrainingStatusModel.inProgress(), Boolean.valueOf(true)); + assertEquals(objectTrainingStatusModel.dataChanged(), Boolean.valueOf(true)); + assertEquals(objectTrainingStatusModel.latestFailed(), Boolean.valueOf(true)); + assertEquals(objectTrainingStatusModel.rscnnReady(), Boolean.valueOf(true)); + assertEquals(objectTrainingStatusModel.description(), "testString"); + + TrainingStatus trainingStatusModel = + new TrainingStatus.Builder().objects(objectTrainingStatusModel).build(); + assertEquals(trainingStatusModel.objects(), objectTrainingStatusModel); + + CreateCollectionOptions createCollectionOptionsModel = + new CreateCollectionOptions.Builder() + .name("testString") + .description("testString") + .trainingStatus(trainingStatusModel) + .build(); + assertEquals(createCollectionOptionsModel.name(), "testString"); + assertEquals(createCollectionOptionsModel.description(), "testString"); + assertEquals(createCollectionOptionsModel.trainingStatus(), trainingStatusModel); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/DeleteCollectionOptionsTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/DeleteCollectionOptionsTest.java new file mode 100644 index 00000000000..d6908edd79f --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/DeleteCollectionOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v4.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v4.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteCollectionOptions model. */ +public class DeleteCollectionOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteCollectionOptions() throws Throwable { + DeleteCollectionOptions deleteCollectionOptionsModel = + new DeleteCollectionOptions.Builder().collectionId("testString").build(); + assertEquals(deleteCollectionOptionsModel.collectionId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteCollectionOptionsError() throws Throwable { + new DeleteCollectionOptions.Builder().build(); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/DeleteImageOptionsTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/DeleteImageOptionsTest.java new file mode 100644 index 00000000000..57bf1a9f2c7 --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/DeleteImageOptionsTest.java @@ -0,0 +1,43 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v4.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v4.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteImageOptions model. */ +public class DeleteImageOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteImageOptions() throws Throwable { + DeleteImageOptions deleteImageOptionsModel = + new DeleteImageOptions.Builder().collectionId("testString").imageId("testString").build(); + assertEquals(deleteImageOptionsModel.collectionId(), "testString"); + assertEquals(deleteImageOptionsModel.imageId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteImageOptionsError() throws Throwable { + new DeleteImageOptions.Builder().build(); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/DeleteObjectOptionsTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/DeleteObjectOptionsTest.java new file mode 100644 index 00000000000..2e79ca49ecb --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/DeleteObjectOptionsTest.java @@ -0,0 +1,43 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v4.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v4.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteObjectOptions model. */ +public class DeleteObjectOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteObjectOptions() throws Throwable { + DeleteObjectOptions deleteObjectOptionsModel = + new DeleteObjectOptions.Builder().collectionId("testString").object("testString").build(); + assertEquals(deleteObjectOptionsModel.collectionId(), "testString"); + assertEquals(deleteObjectOptionsModel.object(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteObjectOptionsError() throws Throwable { + new DeleteObjectOptions.Builder().build(); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/DeleteUserDataOptionsTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/DeleteUserDataOptionsTest.java new file mode 100644 index 00000000000..3fe6000c87d --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/DeleteUserDataOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v4.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v4.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DeleteUserDataOptions model. */ +public class DeleteUserDataOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDeleteUserDataOptions() throws Throwable { + DeleteUserDataOptions deleteUserDataOptionsModel = + new DeleteUserDataOptions.Builder().customerId("testString").build(); + assertEquals(deleteUserDataOptionsModel.customerId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testDeleteUserDataOptionsError() throws Throwable { + new DeleteUserDataOptions.Builder().build(); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/DetectedObjectsTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/DetectedObjectsTest.java new file mode 100644 index 00000000000..a2cea16b8bd --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/DetectedObjectsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v4.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v4.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the DetectedObjects model. */ +public class DetectedObjectsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testDetectedObjects() throws Throwable { + DetectedObjects detectedObjectsModel = new DetectedObjects(); + assertNull(detectedObjectsModel.getCollections()); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/ErrorTargetTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/ErrorTargetTest.java new file mode 100644 index 00000000000..778b63fd980 --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/ErrorTargetTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v4.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v4.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ErrorTarget model. */ +public class ErrorTargetTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testErrorTarget() throws Throwable { + ErrorTarget errorTargetModel = new ErrorTarget(); + assertNull(errorTargetModel.getType()); + assertNull(errorTargetModel.getName()); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/ErrorTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/ErrorTest.java new file mode 100644 index 00000000000..dd1323d81a3 --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/ErrorTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v4.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v4.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Error model. */ +public class ErrorTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testError() throws Throwable { + Error errorModel = new Error(); + assertNull(errorModel.getCode()); + assertNull(errorModel.getMessage()); + assertNull(errorModel.getMoreInfo()); + assertNull(errorModel.getTarget()); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/GetCollectionOptionsTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/GetCollectionOptionsTest.java new file mode 100644 index 00000000000..ad89f6f0157 --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/GetCollectionOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v4.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v4.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetCollectionOptions model. */ +public class GetCollectionOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetCollectionOptions() throws Throwable { + GetCollectionOptions getCollectionOptionsModel = + new GetCollectionOptions.Builder().collectionId("testString").build(); + assertEquals(getCollectionOptionsModel.collectionId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetCollectionOptionsError() throws Throwable { + new GetCollectionOptions.Builder().build(); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/GetImageDetailsOptionsTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/GetImageDetailsOptionsTest.java new file mode 100644 index 00000000000..d789502ad7e --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/GetImageDetailsOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v4.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v4.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetImageDetailsOptions model. */ +public class GetImageDetailsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetImageDetailsOptions() throws Throwable { + GetImageDetailsOptions getImageDetailsOptionsModel = + new GetImageDetailsOptions.Builder() + .collectionId("testString") + .imageId("testString") + .build(); + assertEquals(getImageDetailsOptionsModel.collectionId(), "testString"); + assertEquals(getImageDetailsOptionsModel.imageId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetImageDetailsOptionsError() throws Throwable { + new GetImageDetailsOptions.Builder().build(); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/GetJpegImageOptionsTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/GetJpegImageOptionsTest.java new file mode 100644 index 00000000000..62ea7d4c7c9 --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/GetJpegImageOptionsTest.java @@ -0,0 +1,48 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v4.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v4.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetJpegImageOptions model. */ +public class GetJpegImageOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetJpegImageOptions() throws Throwable { + GetJpegImageOptions getJpegImageOptionsModel = + new GetJpegImageOptions.Builder() + .collectionId("testString") + .imageId("testString") + .size("full") + .build(); + assertEquals(getJpegImageOptionsModel.collectionId(), "testString"); + assertEquals(getJpegImageOptionsModel.imageId(), "testString"); + assertEquals(getJpegImageOptionsModel.size(), "full"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetJpegImageOptionsError() throws Throwable { + new GetJpegImageOptions.Builder().build(); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/GetModelFileOptionsTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/GetModelFileOptionsTest.java new file mode 100644 index 00000000000..1a6ded5f833 --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/GetModelFileOptionsTest.java @@ -0,0 +1,48 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v4.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v4.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetModelFileOptions model. */ +public class GetModelFileOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetModelFileOptions() throws Throwable { + GetModelFileOptions getModelFileOptionsModel = + new GetModelFileOptions.Builder() + .collectionId("testString") + .feature("objects") + .modelFormat("rscnn") + .build(); + assertEquals(getModelFileOptionsModel.collectionId(), "testString"); + assertEquals(getModelFileOptionsModel.feature(), "objects"); + assertEquals(getModelFileOptionsModel.modelFormat(), "rscnn"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetModelFileOptionsError() throws Throwable { + new GetModelFileOptions.Builder().build(); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/GetObjectMetadataOptionsTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/GetObjectMetadataOptionsTest.java new file mode 100644 index 00000000000..f32294f1986 --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/GetObjectMetadataOptionsTest.java @@ -0,0 +1,46 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v4.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v4.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetObjectMetadataOptions model. */ +public class GetObjectMetadataOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetObjectMetadataOptions() throws Throwable { + GetObjectMetadataOptions getObjectMetadataOptionsModel = + new GetObjectMetadataOptions.Builder() + .collectionId("testString") + .object("testString") + .build(); + assertEquals(getObjectMetadataOptionsModel.collectionId(), "testString"); + assertEquals(getObjectMetadataOptionsModel.object(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testGetObjectMetadataOptionsError() throws Throwable { + new GetObjectMetadataOptions.Builder().build(); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/GetTrainingUsageOptionsTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/GetTrainingUsageOptionsTest.java new file mode 100644 index 00000000000..335d486649e --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/GetTrainingUsageOptionsTest.java @@ -0,0 +1,43 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v4.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v4.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the GetTrainingUsageOptions model. */ +public class GetTrainingUsageOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testGetTrainingUsageOptions() throws Throwable { + GetTrainingUsageOptions getTrainingUsageOptionsModel = + new GetTrainingUsageOptions.Builder() + .startTime(TestUtilities.createMockDate("2019-01-01")) + .endTime(TestUtilities.createMockDate("2019-01-01")) + .build(); + assertEquals( + getTrainingUsageOptionsModel.startTime(), TestUtilities.createMockDate("2019-01-01")); + assertEquals( + getTrainingUsageOptionsModel.endTime(), TestUtilities.createMockDate("2019-01-01")); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/ImageDetailsListTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/ImageDetailsListTest.java new file mode 100644 index 00000000000..1b63fb33e0b --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/ImageDetailsListTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v4.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v4.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ImageDetailsList model. */ +public class ImageDetailsListTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testImageDetailsList() throws Throwable { + ImageDetailsList imageDetailsListModel = new ImageDetailsList(); + assertNull(imageDetailsListModel.getImages()); + assertNull(imageDetailsListModel.getWarnings()); + assertNull(imageDetailsListModel.getTrace()); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/ImageDetailsTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/ImageDetailsTest.java new file mode 100644 index 00000000000..e99fbd1bec9 --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/ImageDetailsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v4.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v4.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ImageDetails model. */ +public class ImageDetailsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testImageDetails() throws Throwable { + ImageDetails imageDetailsModel = new ImageDetails(); + assertNull(imageDetailsModel.getImageId()); + assertNull(imageDetailsModel.getUpdated()); + assertNull(imageDetailsModel.getCreated()); + assertNull(imageDetailsModel.getSource()); + assertNull(imageDetailsModel.getDimensions()); + assertNull(imageDetailsModel.getErrors()); + assertNull(imageDetailsModel.getTrainingData()); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/ImageDimensionsTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/ImageDimensionsTest.java new file mode 100644 index 00000000000..86f61d58fdc --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/ImageDimensionsTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v4.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v4.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ImageDimensions model. */ +public class ImageDimensionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testImageDimensions() throws Throwable { + ImageDimensions imageDimensionsModel = new ImageDimensions(); + assertNull(imageDimensionsModel.getHeight()); + assertNull(imageDimensionsModel.getWidth()); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/ImageSourceTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/ImageSourceTest.java new file mode 100644 index 00000000000..6c15b200e59 --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/ImageSourceTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v4.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v4.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ImageSource model. */ +public class ImageSourceTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testImageSource() throws Throwable { + ImageSource imageSourceModel = new ImageSource(); + assertNull(imageSourceModel.getType()); + assertNull(imageSourceModel.getFilename()); + assertNull(imageSourceModel.getArchiveFilename()); + assertNull(imageSourceModel.getSourceUrl()); + assertNull(imageSourceModel.getResolvedUrl()); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/ImageSummaryListTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/ImageSummaryListTest.java new file mode 100644 index 00000000000..9de3cbf35eb --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/ImageSummaryListTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v4.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v4.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ImageSummaryList model. */ +public class ImageSummaryListTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testImageSummaryList() throws Throwable { + ImageSummaryList imageSummaryListModel = new ImageSummaryList(); + assertNull(imageSummaryListModel.getImages()); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/ImageSummaryTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/ImageSummaryTest.java new file mode 100644 index 00000000000..f4367f39973 --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/ImageSummaryTest.java @@ -0,0 +1,37 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v4.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v4.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ImageSummary model. */ +public class ImageSummaryTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testImageSummary() throws Throwable { + ImageSummary imageSummaryModel = new ImageSummary(); + assertNull(imageSummaryModel.getImageId()); + assertNull(imageSummaryModel.getUpdated()); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/ImageTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/ImageTest.java new file mode 100644 index 00000000000..6de9a646704 --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/ImageTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v4.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v4.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Image model. */ +public class ImageTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testImage() throws Throwable { + Image imageModel = new Image(); + assertNull(imageModel.getSource()); + assertNull(imageModel.getDimensions()); + assertNull(imageModel.getObjects()); + assertNull(imageModel.getErrors()); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/ListCollectionsOptionsTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/ListCollectionsOptionsTest.java new file mode 100644 index 00000000000..aebe353519b --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/ListCollectionsOptionsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v4.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v4.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListCollectionsOptions model. */ +public class ListCollectionsOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListCollectionsOptions() throws Throwable { + ListCollectionsOptions listCollectionsOptionsModel = new ListCollectionsOptions(); + assertNotNull(listCollectionsOptionsModel); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/ListImagesOptionsTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/ListImagesOptionsTest.java new file mode 100644 index 00000000000..c6d289db489 --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/ListImagesOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v4.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v4.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListImagesOptions model. */ +public class ListImagesOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListImagesOptions() throws Throwable { + ListImagesOptions listImagesOptionsModel = + new ListImagesOptions.Builder().collectionId("testString").build(); + assertEquals(listImagesOptionsModel.collectionId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListImagesOptionsError() throws Throwable { + new ListImagesOptions.Builder().build(); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/ListObjectMetadataOptionsTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/ListObjectMetadataOptionsTest.java new file mode 100644 index 00000000000..385622c3f33 --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/ListObjectMetadataOptionsTest.java @@ -0,0 +1,42 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v4.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v4.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ListObjectMetadataOptions model. */ +public class ListObjectMetadataOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testListObjectMetadataOptions() throws Throwable { + ListObjectMetadataOptions listObjectMetadataOptionsModel = + new ListObjectMetadataOptions.Builder().collectionId("testString").build(); + assertEquals(listObjectMetadataOptionsModel.collectionId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testListObjectMetadataOptionsError() throws Throwable { + new ListObjectMetadataOptions.Builder().build(); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/LocationTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/LocationTest.java new file mode 100644 index 00000000000..8b61f02398f --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/LocationTest.java @@ -0,0 +1,59 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v4.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v4.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Location model. */ +public class LocationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testLocation() throws Throwable { + Location locationModel = + new Location.Builder() + .top(Long.valueOf("26")) + .left(Long.valueOf("26")) + .width(Long.valueOf("26")) + .height(Long.valueOf("26")) + .build(); + assertEquals(locationModel.top(), Long.valueOf("26")); + assertEquals(locationModel.left(), Long.valueOf("26")); + assertEquals(locationModel.width(), Long.valueOf("26")); + assertEquals(locationModel.height(), Long.valueOf("26")); + + String json = TestUtilities.serialize(locationModel); + + Location locationModelNew = TestUtilities.deserialize(json, Location.class); + assertTrue(locationModelNew instanceof Location); + assertEquals(locationModelNew.top(), Long.valueOf("26")); + assertEquals(locationModelNew.left(), Long.valueOf("26")); + assertEquals(locationModelNew.width(), Long.valueOf("26")); + assertEquals(locationModelNew.height(), Long.valueOf("26")); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testLocationError() throws Throwable { + new Location.Builder().build(); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/ObjectDetailLocationTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/ObjectDetailLocationTest.java new file mode 100644 index 00000000000..63f85a66715 --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/ObjectDetailLocationTest.java @@ -0,0 +1,39 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v4.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v4.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ObjectDetailLocation model. */ +public class ObjectDetailLocationTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testObjectDetailLocation() throws Throwable { + ObjectDetailLocation objectDetailLocationModel = new ObjectDetailLocation(); + assertNull(objectDetailLocationModel.getTop()); + assertNull(objectDetailLocationModel.getLeft()); + assertNull(objectDetailLocationModel.getWidth()); + assertNull(objectDetailLocationModel.getHeight()); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/ObjectDetailTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/ObjectDetailTest.java new file mode 100644 index 00000000000..83351deaf47 --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/ObjectDetailTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v4.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v4.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ObjectDetail model. */ +public class ObjectDetailTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testObjectDetail() throws Throwable { + ObjectDetail objectDetailModel = new ObjectDetail(); + assertNull(objectDetailModel.getObject()); + assertNull(objectDetailModel.getLocation()); + assertNull(objectDetailModel.getScore()); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/ObjectMetadataListTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/ObjectMetadataListTest.java new file mode 100644 index 00000000000..b6b79ec5c74 --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/ObjectMetadataListTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v4.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v4.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ObjectMetadataList model. */ +public class ObjectMetadataListTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testObjectMetadataList() throws Throwable { + ObjectMetadataList objectMetadataListModel = new ObjectMetadataList(); + assertNull(objectMetadataListModel.getObjects()); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/ObjectMetadataTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/ObjectMetadataTest.java new file mode 100644 index 00000000000..440059d00d8 --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/ObjectMetadataTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v4.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v4.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ObjectMetadata model. */ +public class ObjectMetadataTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testObjectMetadata() throws Throwable { + ObjectMetadata objectMetadataModel = new ObjectMetadata(); + assertNull(objectMetadataModel.getObject()); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/ObjectTrainingStatusTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/ObjectTrainingStatusTest.java new file mode 100644 index 00000000000..1f5597cbec0 --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/ObjectTrainingStatusTest.java @@ -0,0 +1,66 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v4.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v4.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the ObjectTrainingStatus model. */ +public class ObjectTrainingStatusTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testObjectTrainingStatus() throws Throwable { + ObjectTrainingStatus objectTrainingStatusModel = + new ObjectTrainingStatus.Builder() + .ready(true) + .inProgress(true) + .dataChanged(true) + .latestFailed(true) + .rscnnReady(true) + .description("testString") + .build(); + assertEquals(objectTrainingStatusModel.ready(), Boolean.valueOf(true)); + assertEquals(objectTrainingStatusModel.inProgress(), Boolean.valueOf(true)); + assertEquals(objectTrainingStatusModel.dataChanged(), Boolean.valueOf(true)); + assertEquals(objectTrainingStatusModel.latestFailed(), Boolean.valueOf(true)); + assertEquals(objectTrainingStatusModel.rscnnReady(), Boolean.valueOf(true)); + assertEquals(objectTrainingStatusModel.description(), "testString"); + + String json = TestUtilities.serialize(objectTrainingStatusModel); + + ObjectTrainingStatus objectTrainingStatusModelNew = + TestUtilities.deserialize(json, ObjectTrainingStatus.class); + assertTrue(objectTrainingStatusModelNew instanceof ObjectTrainingStatus); + assertEquals(objectTrainingStatusModelNew.ready(), Boolean.valueOf(true)); + assertEquals(objectTrainingStatusModelNew.inProgress(), Boolean.valueOf(true)); + assertEquals(objectTrainingStatusModelNew.dataChanged(), Boolean.valueOf(true)); + assertEquals(objectTrainingStatusModelNew.latestFailed(), Boolean.valueOf(true)); + assertEquals(objectTrainingStatusModelNew.rscnnReady(), Boolean.valueOf(true)); + assertEquals(objectTrainingStatusModelNew.description(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testObjectTrainingStatusError() throws Throwable { + new ObjectTrainingStatus.Builder().build(); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/TrainOptionsTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/TrainOptionsTest.java new file mode 100644 index 00000000000..b491daa082f --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/TrainOptionsTest.java @@ -0,0 +1,41 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v4.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v4.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TrainOptions model. */ +public class TrainOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTrainOptions() throws Throwable { + TrainOptions trainOptionsModel = new TrainOptions.Builder().collectionId("testString").build(); + assertEquals(trainOptionsModel.collectionId(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testTrainOptionsError() throws Throwable { + new TrainOptions.Builder().build(); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/TrainingDataObjectTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/TrainingDataObjectTest.java new file mode 100644 index 00000000000..9fe3aa205e8 --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/TrainingDataObjectTest.java @@ -0,0 +1,58 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v4.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v4.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TrainingDataObject model. */ +public class TrainingDataObjectTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTrainingDataObject() throws Throwable { + Location locationModel = + new Location.Builder() + .top(Long.valueOf("26")) + .left(Long.valueOf("26")) + .width(Long.valueOf("26")) + .height(Long.valueOf("26")) + .build(); + assertEquals(locationModel.top(), Long.valueOf("26")); + assertEquals(locationModel.left(), Long.valueOf("26")); + assertEquals(locationModel.width(), Long.valueOf("26")); + assertEquals(locationModel.height(), Long.valueOf("26")); + + TrainingDataObject trainingDataObjectModel = + new TrainingDataObject.Builder().object("testString").location(locationModel).build(); + assertEquals(trainingDataObjectModel.object(), "testString"); + assertEquals(trainingDataObjectModel.location(), locationModel); + + String json = TestUtilities.serialize(trainingDataObjectModel); + + TrainingDataObject trainingDataObjectModelNew = + TestUtilities.deserialize(json, TrainingDataObject.class); + assertTrue(trainingDataObjectModelNew instanceof TrainingDataObject); + assertEquals(trainingDataObjectModelNew.object(), "testString"); + assertEquals(trainingDataObjectModelNew.location().toString(), locationModel.toString()); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/TrainingDataObjectsTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/TrainingDataObjectsTest.java new file mode 100644 index 00000000000..6119aab505d --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/TrainingDataObjectsTest.java @@ -0,0 +1,36 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v4.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v4.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TrainingDataObjects model. */ +public class TrainingDataObjectsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTrainingDataObjects() throws Throwable { + TrainingDataObjects trainingDataObjectsModel = new TrainingDataObjects(); + assertNull(trainingDataObjectsModel.getObjects()); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/TrainingEventTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/TrainingEventTest.java new file mode 100644 index 00000000000..4b32a756323 --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/TrainingEventTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v4.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v4.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TrainingEvent model. */ +public class TrainingEventTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTrainingEvent() throws Throwable { + TrainingEvent trainingEventModel = new TrainingEvent(); + assertNull(trainingEventModel.getType()); + assertNull(trainingEventModel.getCollectionId()); + assertNull(trainingEventModel.getCompletionTime()); + assertNull(trainingEventModel.getStatus()); + assertNull(trainingEventModel.getImageCount()); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/TrainingEventsTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/TrainingEventsTest.java new file mode 100644 index 00000000000..874105d0776 --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/TrainingEventsTest.java @@ -0,0 +1,40 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v4.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v4.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TrainingEvents model. */ +public class TrainingEventsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTrainingEvents() throws Throwable { + TrainingEvents trainingEventsModel = new TrainingEvents(); + assertNull(trainingEventsModel.getStartTime()); + assertNull(trainingEventsModel.getEndTime()); + assertNull(trainingEventsModel.getCompletedEvents()); + assertNull(trainingEventsModel.getTrainedImages()); + assertNull(trainingEventsModel.getEvents()); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/TrainingStatusTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/TrainingStatusTest.java new file mode 100644 index 00000000000..205ecd4e090 --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/TrainingStatusTest.java @@ -0,0 +1,64 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v4.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v4.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the TrainingStatus model. */ +public class TrainingStatusTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testTrainingStatus() throws Throwable { + ObjectTrainingStatus objectTrainingStatusModel = + new ObjectTrainingStatus.Builder() + .ready(true) + .inProgress(true) + .dataChanged(true) + .latestFailed(true) + .rscnnReady(true) + .description("testString") + .build(); + assertEquals(objectTrainingStatusModel.ready(), Boolean.valueOf(true)); + assertEquals(objectTrainingStatusModel.inProgress(), Boolean.valueOf(true)); + assertEquals(objectTrainingStatusModel.dataChanged(), Boolean.valueOf(true)); + assertEquals(objectTrainingStatusModel.latestFailed(), Boolean.valueOf(true)); + assertEquals(objectTrainingStatusModel.rscnnReady(), Boolean.valueOf(true)); + assertEquals(objectTrainingStatusModel.description(), "testString"); + + TrainingStatus trainingStatusModel = + new TrainingStatus.Builder().objects(objectTrainingStatusModel).build(); + assertEquals(trainingStatusModel.objects(), objectTrainingStatusModel); + + String json = TestUtilities.serialize(trainingStatusModel); + + TrainingStatus trainingStatusModelNew = TestUtilities.deserialize(json, TrainingStatus.class); + assertTrue(trainingStatusModelNew instanceof TrainingStatus); + assertEquals(trainingStatusModelNew.objects().toString(), objectTrainingStatusModel.toString()); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testTrainingStatusError() throws Throwable { + new TrainingStatus.Builder().build(); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/UpdateCollectionOptionsTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/UpdateCollectionOptionsTest.java new file mode 100644 index 00000000000..db6c45728c7 --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/UpdateCollectionOptionsTest.java @@ -0,0 +1,70 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v4.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v4.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the UpdateCollectionOptions model. */ +public class UpdateCollectionOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateCollectionOptions() throws Throwable { + ObjectTrainingStatus objectTrainingStatusModel = + new ObjectTrainingStatus.Builder() + .ready(true) + .inProgress(true) + .dataChanged(true) + .latestFailed(true) + .rscnnReady(true) + .description("testString") + .build(); + assertEquals(objectTrainingStatusModel.ready(), Boolean.valueOf(true)); + assertEquals(objectTrainingStatusModel.inProgress(), Boolean.valueOf(true)); + assertEquals(objectTrainingStatusModel.dataChanged(), Boolean.valueOf(true)); + assertEquals(objectTrainingStatusModel.latestFailed(), Boolean.valueOf(true)); + assertEquals(objectTrainingStatusModel.rscnnReady(), Boolean.valueOf(true)); + assertEquals(objectTrainingStatusModel.description(), "testString"); + + TrainingStatus trainingStatusModel = + new TrainingStatus.Builder().objects(objectTrainingStatusModel).build(); + assertEquals(trainingStatusModel.objects(), objectTrainingStatusModel); + + UpdateCollectionOptions updateCollectionOptionsModel = + new UpdateCollectionOptions.Builder() + .collectionId("testString") + .name("testString") + .description("testString") + .trainingStatus(trainingStatusModel) + .build(); + assertEquals(updateCollectionOptionsModel.collectionId(), "testString"); + assertEquals(updateCollectionOptionsModel.name(), "testString"); + assertEquals(updateCollectionOptionsModel.description(), "testString"); + assertEquals(updateCollectionOptionsModel.trainingStatus(), trainingStatusModel); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateCollectionOptionsError() throws Throwable { + new UpdateCollectionOptions.Builder().build(); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/UpdateObjectMetadataOptionsTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/UpdateObjectMetadataOptionsTest.java new file mode 100644 index 00000000000..d897a37c9a7 --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/UpdateObjectMetadataOptionsTest.java @@ -0,0 +1,48 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v4.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v4.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the UpdateObjectMetadataOptions model. */ +public class UpdateObjectMetadataOptionsTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateObjectMetadataOptions() throws Throwable { + UpdateObjectMetadataOptions updateObjectMetadataOptionsModel = + new UpdateObjectMetadataOptions.Builder() + .collectionId("testString") + .object("testString") + .newObject("testString") + .build(); + assertEquals(updateObjectMetadataOptionsModel.collectionId(), "testString"); + assertEquals(updateObjectMetadataOptionsModel.object(), "testString"); + assertEquals(updateObjectMetadataOptionsModel.newObject(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateObjectMetadataOptionsError() throws Throwable { + new UpdateObjectMetadataOptions.Builder().build(); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/UpdateObjectMetadataTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/UpdateObjectMetadataTest.java new file mode 100644 index 00000000000..49f6d867182 --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/UpdateObjectMetadataTest.java @@ -0,0 +1,49 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v4.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v4.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the UpdateObjectMetadata model. */ +public class UpdateObjectMetadataTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testUpdateObjectMetadata() throws Throwable { + UpdateObjectMetadata updateObjectMetadataModel = + new UpdateObjectMetadata.Builder().object("testString").build(); + assertEquals(updateObjectMetadataModel.object(), "testString"); + + String json = TestUtilities.serialize(updateObjectMetadataModel); + + UpdateObjectMetadata updateObjectMetadataModelNew = + TestUtilities.deserialize(json, UpdateObjectMetadata.class); + assertTrue(updateObjectMetadataModelNew instanceof UpdateObjectMetadata); + assertEquals(updateObjectMetadataModelNew.object(), "testString"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateObjectMetadataError() throws Throwable { + new UpdateObjectMetadata.Builder().build(); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/WarningTest.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/WarningTest.java new file mode 100644 index 00000000000..3b07c34e2a5 --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/model/WarningTest.java @@ -0,0 +1,38 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v4.model; + +import static org.testng.Assert.*; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.watson.visual_recognition.v4.utils.TestUtilities; +import java.io.InputStream; +import java.util.HashMap; +import java.util.List; +import org.testng.annotations.Test; + +/** Unit test class for the Warning model. */ +public class WarningTest { + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + @Test + public void testWarning() throws Throwable { + Warning warningModel = new Warning(); + assertNull(warningModel.getCode()); + assertNull(warningModel.getMessage()); + assertNull(warningModel.getMoreInfo()); + } +} diff --git a/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/utils/TestUtilities.java b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/utils/TestUtilities.java new file mode 100644 index 00000000000..17f0fe29a68 --- /dev/null +++ b/visual-recognition/src/test/java/com/ibm/watson/visual_recognition/v4/utils/TestUtilities.java @@ -0,0 +1,128 @@ +/* + * (C) Copyright IBM Corp. 2020. + * + * 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.watson.visual_recognition.v4.utils; + +import com.ibm.cloud.sdk.core.service.model.FileWithMetadata; +import com.ibm.cloud.sdk.core.util.GsonSingleton; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import okhttp3.HttpUrl; +import okhttp3.mockwebserver.RecordedRequest; + +/** A class used by the unit tests containing utility functions. */ +public class TestUtilities { + public static Map createMockMap() { + Map mockMap = new HashMap<>(); + mockMap.put("foo", "bar"); + return mockMap; + } + + public static HashMap createMockStreamMap() { + return new HashMap() { + { + put("key1", createMockStream("This is a mock file.")); + } + }; + } + + public static Map parseQueryString(RecordedRequest req) { + Map queryMap = new HashMap<>(); + + try { + HttpUrl requestUrl = req.getRequestUrl(); + + if (requestUrl != null) { + Set queryParamsNames = requestUrl.queryParameterNames(); + // map the parameter name to its corresponding value + for (String p : queryParamsNames) { + // get the corresponding value for the parameter (p) + List val = requestUrl.queryParameterValues(p); + if (val != null && !val.isEmpty()) { + String joinedQuery = String.join(",", val); + queryMap.put(p, joinedQuery); + } + } + } + if (queryMap.isEmpty()) { + return null; + } + } catch (Exception e) { + return null; + } + + return queryMap; + } + + public static String parseReqPath(RecordedRequest req) { + String parsedPath = null; + + try { + String fullPath = req.getPath(); + if (fullPath != null && !fullPath.isEmpty()) { + // retrieve the path segment before the query parameter + parsedPath = fullPath.split("\\?", 2)[0]; + } + if (parsedPath.isEmpty() || parsedPath == null) { + return null; + } + + } catch (Exception e) { + return null; + } + + return parsedPath; + } + + public static String serialize(Object obj) { + return GsonSingleton.getGson().toJson(obj); + } + + public static T deserialize(String json, Class clazz) { + return GsonSingleton.getGson().fromJson(json, clazz); + } + + public static InputStream createMockStream(String s) { + return new ByteArrayInputStream(s.getBytes()); + } + + public static List creatMockListFileWithMetadata() { + List list = new ArrayList(); + byte[] fileBytes = {(byte) 0xde, (byte) 0xad, (byte) 0xbe, (byte) 0xef}; + InputStream inputStream = new ByteArrayInputStream(fileBytes); + FileWithMetadata.Builder builder = new FileWithMetadata.Builder(); + builder.data(inputStream); + FileWithMetadata fileWithMetadata = builder.build(); + list.add(fileWithMetadata); + + return list; + } + + public static byte[] createMockByteArray(String bytes) { + return bytes.getBytes(); + } + + public static Date createMockDate(String date) throws Exception { + return new SimpleDateFormat("yyyy-MM-dd").parse(date); + } + + public static Date createMockDateTime(String date) throws Exception { + return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").parse(date); + } +}