diff --git a/.travis.yml b/.travis.yml index ce050d76918..7105be3b071 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,9 +9,8 @@ cache: directories: - $HOME/.m2/repository before_install: +- '[ "${TRAVIS_PULL_REQUEST}" = "false" ] && openssl aes-256-cbc -K $encrypted_a973fe4f8e79_key -iv $encrypted_a973fe4f8e79_iv -in config.properties.enc -out src/test/resources/config.properties -d || true' - pip install --user codecov -- openssl aes-256-cbc -K $encrypted_a973fe4f8e79_key -iv $encrypted_a973fe4f8e79_iv - -in config.properties.enc -out src/test/resources/config.properties -d notifications: email: false env: diff --git a/README.md b/README.md index 603f8b8d6d4..debb1045013 100644 --- a/README.md +++ b/README.md @@ -459,7 +459,7 @@ System.out.println(recognizedImage); ``` ## Android -he library supports Android 2.3 and above. For Java, the minimum requirement is 1.7. +The library supports Android 2.3 and above. For Java, the minimum requirement is 1.7. It depends on [OkHttp][] and [gson][]. diff --git a/config.properties.enc b/config.properties.enc index fde13015d00..2446665679e 100644 Binary files a/config.properties.enc and b/config.properties.enc differ diff --git a/pom.xml b/pom.xml index 12ae8defbba..f2f705c884e 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.ibm.watson.developer_cloud - 2.7.1-SNAPSHOT + 2.7.2-SNAPSHOT jar java-sdk Watson Developer Cloud Java SDK @@ -41,7 +41,7 @@ com.neovisionaries nv-websocket-client - 1.19 + 1.21 @@ -179,10 +179,10 @@ jacoco-maven-plugin 0.7.5.201505241946 - - com/ibm/watson/developer_cloud/*/v*/model/**/*.class - com/ibm/watson/developer_cloud/**/*Example.* - + + com/ibm/watson/developer_cloud/*/v*/model/**/*.class + com/ibm/watson/developer_cloud/**/*Example.* + @@ -199,6 +199,26 @@ + diff --git a/src/main/java/com/ibm/watson/developer_cloud/concept_insights/v2/model/Corpus.java b/src/main/java/com/ibm/watson/developer_cloud/concept_insights/v2/model/Corpus.java index 1cf0e095516..bda9baf32fc 100755 --- a/src/main/java/com/ibm/watson/developer_cloud/concept_insights/v2/model/Corpus.java +++ b/src/main/java/com/ibm/watson/developer_cloud/concept_insights/v2/model/Corpus.java @@ -48,6 +48,56 @@ public class Corpus extends GenericModel { /** The corpus name. */ private String name; + @SerializedName("ttl_hours") + private Integer ttlInHours; + // ttl_hours (integer, optional): Specify the TTL for the corpus in hours. This will internally + // set the expiration time after which the corpus will be automatically deleted. , + // expires_on (string, optional): Date and time in standard ISO format at which the corpus will + // expire and be marked for deletion. + + @SerializedName("expires_on") + private String expiresOn; + + /** + * Gets the time to live in hours. + * + * @return the time to live in hours + */ + public Integer getTtlInHours() { + return ttlInHours; + } + + /** + * Sets the time to live in hours. This will internally set the expiration time after which the + * corpus will be automatically deleted. + * + * @param ttlInHours the new time to live in hours + */ + public void setTtlInHours(Integer ttlInHours) { + this.ttlInHours = ttlInHours; + } + + /** + * Gets the expires on. + * + * @return the expires on + */ + public String getExpiresOn() { + return expiresOn; + } + + /** + * Sets the expires on. The value needs to be in standard ISO format at which the corpus will + * expire and be marked for deletion. + * + * For example: YYYY-MM-DD (e.g. 2016-07-16) + * + * @param expiresOn the new expires on + */ + public void setExpiresOn(String expiresOn) { + this.expiresOn = expiresOn; + } + /** * Instantiates a new corpus. */ diff --git a/src/main/java/com/ibm/watson/developer_cloud/concept_insights/v2/util/IDHelper.java b/src/main/java/com/ibm/watson/developer_cloud/concept_insights/v2/util/IDHelper.java index 784aa4bcbf2..989839a9963 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/concept_insights/v2/util/IDHelper.java +++ b/src/main/java/com/ibm/watson/developer_cloud/concept_insights/v2/util/IDHelper.java @@ -72,10 +72,10 @@ public static String getConceptId(final Concept concept) { * generated it. * * @param corpus Corpus the corpus object, - * @param accoundId String the account id. + * @param accountId String the account id. * @return the corpus id */ - public static String getCorpusId(final Corpus corpus, final String accoundId) { + public static String getCorpusId(final Corpus corpus, final String accountId) { Validate.notNull(corpus, "corpus cannot be null"); if (corpus.getId() != null) { validate(CORPUS_ID_REGEX, corpus.getId(), "Provide a valid corpus.id (format is " + '"' @@ -83,7 +83,7 @@ public static String getCorpusId(final Corpus corpus, final String accoundId) { return corpus.getId(); } else { Validate.notNull(corpus.getName(), "corpus.name cannot be null"); - return "/corpora/" + accoundId + "/" + corpus.getName(); + return "/corpora/" + accountId + "/" + corpus.getName(); } } @@ -107,10 +107,10 @@ public static String getDocumentId(final Document document) { * generated it. * * @param graph Graph the graph object, - * @param accoundId String the account id. + * @param accountId String the account id. * @return the graph id */ - public static String getGraphId(final Graph graph, final String accoundId) { + public static String getGraphId(final Graph graph, final String accountId) { Validate.notNull(graph, "graph object cannot be null"); if (graph.getId() != null) { validate(GRAPH_ID_REGEX, graph.getId(), "Provide a valid graph.id (format is " + '"' @@ -118,7 +118,7 @@ public static String getGraphId(final Graph graph, final String accoundId) { return graph.getId(); } else { Validate.notNull(graph.getName(), "graph.name cannot be null"); - return "/graphs/" + accoundId + "/" + graph.getName(); + return "/graphs/" + accountId + "/" + graph.getName(); } } diff --git a/src/main/java/com/ibm/watson/developer_cloud/dialog/v1/DialogService.java b/src/main/java/com/ibm/watson/developer_cloud/dialog/v1/DialogService.java index 1abb8246d15..313c5c3e3bf 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/dialog/v1/DialogService.java +++ b/src/main/java/com/ibm/watson/developer_cloud/dialog/v1/DialogService.java @@ -148,6 +148,7 @@ public Conversation converse(final Conversation conversation, String newMessage) * * @param params the params * @return the {@link Conversation} with the response + * @deprecated Use {@link DialogService#converse(Conversation, String)} */ public Conversation converse(final Map params) { diff --git a/src/main/java/com/ibm/watson/developer_cloud/http/HttpHeaders.java b/src/main/java/com/ibm/watson/developer_cloud/http/HttpHeaders.java index 63db918e4e2..6ce0e7c0bde 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/http/HttpHeaders.java +++ b/src/main/java/com/ibm/watson/developer_cloud/http/HttpHeaders.java @@ -181,4 +181,8 @@ public interface HttpHeaders { /** The Authorization token header. */ public static final String X_WATSON_AUTHORIZATION_TOKEN = "X-Watson-Authorization-Token"; + + /** Allow Watson to collect the payload. */ + public static final String X_WATSON_LEARNING_OPT_OUT = "X-Watson-Learning-Opt-Out"; + } diff --git a/src/main/java/com/ibm/watson/developer_cloud/language_translation/v2/LanguageTranslation.java b/src/main/java/com/ibm/watson/developer_cloud/language_translation/v2/LanguageTranslation.java index 0e82533d077..cb34184350e 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/language_translation/v2/LanguageTranslation.java +++ b/src/main/java/com/ibm/watson/developer_cloud/language_translation/v2/LanguageTranslation.java @@ -39,8 +39,8 @@ * identifies the language in which text is written. * * @version v2 - * @see + * @see * Language Translation */ public class LanguageTranslation extends WatsonService { @@ -68,8 +68,8 @@ public class LanguageTranslation extends WatsonService { /** The Constant NAME (value is "name"). */ private static final String NAME = "name"; - /** The Constant PARALLEL_CORPUS (value is "prallel_corpus"). */ - private static final String PARALLEL_CORPUS = "prallel_corpus"; + /** The Constant PARALLEL_CORPUS (value is "parallel_corpus"). */ + private static final String PARALLEL_CORPUS = "parallel_corpus"; /** The Constant SOURCE (value is "source"). */ private static final String SOURCE = "source"; @@ -112,10 +112,10 @@ public TranslationModel createModel(CreateModelOptions options) { if (options.getForcedGlossary() != null) bodyBuilder.addFormDataPart(FORCED_GLOSSARY, options.getForcedGlossary().getName(), RequestBody.create(HttpMediaType.BINARY_FILE, options.getForcedGlossary())); - else if (options.getMonolingualCorpus() != null) + if (options.getMonolingualCorpus() != null) bodyBuilder.addFormDataPart(MONOLINGUAL_CORPUS, options.getMonolingualCorpus().getName(), RequestBody.create(HttpMediaType.BINARY_FILE, options.getMonolingualCorpus())); - else if (options.getParallelCorpus() != null) + if (options.getParallelCorpus() != null) bodyBuilder.addFormDataPart(PARALLEL_CORPUS, options.getParallelCorpus().getName(), RequestBody.create(HttpMediaType.BINARY_FILE, options.getParallelCorpus())); @@ -208,9 +208,9 @@ public List getModels(final Boolean showDefault, final String */ @SuppressWarnings("unchecked") public List identify(final String text) { - final Request request = - RequestBuilder.post(PATH_IDENTIFY).withBodyContent(text, HttpMediaType.TEXT_PLAIN) - .withHeader(HttpHeaders.ACCEPT, HttpMediaType.APPLICATION_JSON).build(); + final Request request = RequestBuilder.post(PATH_IDENTIFY) + .withHeader(HttpHeaders.ACCEPT, HttpMediaType.APPLICATION_JSON) + .withBodyContent(text, HttpMediaType.TEXT_PLAIN).build(); final LanguageList languages = executeRequest(request, LanguageList.class); @@ -276,8 +276,9 @@ private TranslationResult translateRequest(String text, String modelId, String s paragraphs.add(new JsonPrimitive(text)); contentJson.add(TEXT, paragraphs); - final RequestBuilder requestBuilder = RequestBuilder.post(PATH_TRANSLATE); - + final RequestBuilder requestBuilder = RequestBuilder.post(PATH_TRANSLATE) + .withHeader(HttpHeaders.ACCEPT, HttpMediaType.APPLICATION_JSON); + if (source != null && !source.isEmpty()) contentJson.addProperty(SOURCE, source); diff --git a/src/main/java/com/ibm/watson/developer_cloud/relationship_extraction/v1/RelationshipExtraction.java b/src/main/java/com/ibm/watson/developer_cloud/relationship_extraction/v1/RelationshipExtraction.java index c18051bd5bd..e55cb181120 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/relationship_extraction/v1/RelationshipExtraction.java +++ b/src/main/java/com/ibm/watson/developer_cloud/relationship_extraction/v1/RelationshipExtraction.java @@ -38,6 +38,9 @@ public class RelationshipExtraction extends WatsonService { /** The dataset. */ private Dataset dataset; + + /** The return type. */ + private String returnType = "xml"; /** * Instantiates a new relationship extraction service. @@ -65,7 +68,7 @@ public RelationshipExtraction() { * * @param text the text to analyze * - * @return the result as XML string + * @return the result as an XML/JSON string */ public String extract(final String text) { Validate.notNull(dataset, "dataset cannot be null"); @@ -73,7 +76,7 @@ public String extract(final String text) { final Request request = RequestBuilder.post("/v1/sire/0") - .withForm("sid", dataset.getId(), "rt", "xml", "txt", text).build(); + .withForm("sid", dataset.getId(), "rt", returnType, "txt", text).build(); final Response response = execute(request); return ResponseUtil.getString(response); } @@ -96,5 +99,18 @@ public Dataset getDataset() { public void setDataset(final Dataset dataset) { this.dataset = dataset; } + + /** + * Sets the returnType. + * + * @param returnType the new returnType + */ + public void setReturnType(final ReturnType returnType) { + if (returnType == ReturnType.XML) { + this.returnType = "xml"; + } else if (returnType == ReturnType.JSON) { + this.returnType = "json"; + } + } } diff --git a/src/main/java/com/ibm/watson/developer_cloud/relationship_extraction/v1/ReturnType.java b/src/main/java/com/ibm/watson/developer_cloud/relationship_extraction/v1/ReturnType.java new file mode 100644 index 00000000000..b4a9dfa5523 --- /dev/null +++ b/src/main/java/com/ibm/watson/developer_cloud/relationship_extraction/v1/ReturnType.java @@ -0,0 +1,6 @@ +package com.ibm.watson.developer_cloud.relationship_extraction.v1; + +public enum ReturnType { + XML, + JSON +} diff --git a/src/main/java/com/ibm/watson/developer_cloud/service/WatsonService.java b/src/main/java/com/ibm/watson/developer_cloud/service/WatsonService.java index 2a66a497915..6a4c5a3595b 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/service/WatsonService.java +++ b/src/main/java/com/ibm/watson/developer_cloud/service/WatsonService.java @@ -105,7 +105,8 @@ protected Response execute(Request request) { // Set default headers if (defaultHeaders != null) { - builder.headers(defaultHeaders); + for(String key: defaultHeaders.names()) + builder.header(key, defaultHeaders.get(key)); } // Set User-Agent @@ -248,7 +249,7 @@ public String getToken() { * @return the error message from the JSON object */ private String getErrorMessage(Response response) { - String error = ResponseUtil.getResponseString(response); + String error = ResponseUtil.getString(response); try { final JsonObject jsonObject = ResponseUtil.getJsonObject(error); diff --git a/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/websocket/WebSocketSpeechToTextClient.java b/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/websocket/WebSocketSpeechToTextClient.java index 730f5b789be..8f95a2a9002 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/websocket/WebSocketSpeechToTextClient.java +++ b/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/websocket/WebSocketSpeechToTextClient.java @@ -42,7 +42,7 @@ public class WebSocketSpeechToTextClient { */ public class WebSocketListener extends WebSocketAdapter { private RecognizeDelegate delegate; - + private boolean audioSent = false; /** * Instantiates a new WebSocket listener. * @@ -51,6 +51,7 @@ public class WebSocketListener extends WebSocketAdapter { public WebSocketListener(RecognizeDelegate delegate) { super(); this.delegate = delegate; + audioSent = false; } /* @@ -69,10 +70,8 @@ public void onTextMessage(WebSocket websocket, String message) { } else if (json.has(RESULTS)) { SpeechResults transcript = GsonSingleton.getGson().fromJson(message, SpeechResults.class); delegate.onMessage(transcript); - - // if final is true - if (transcript.isFinal()) - websocket.disconnect(); + } else if (audioSent) { + websocket.sendClose(); } } catch (JsonParseException e) { new RuntimeException("Error parsing the incoming message: " + message); @@ -174,7 +173,10 @@ public void recognize(InputStream stream, RecognizeOptions options, RecognizeDel // 4. Send the input stream as binary data sendInputStream(ws, stream); - + + // 5. Tell the listener that we sent the audio + listener.audioSent = true; + // 5. Send stop message ws.sendText(buildStopMessage()); @@ -221,9 +223,8 @@ private void sendInputStream(WebSocket ws, InputStream stream) throws IOExceptio else ws.sendBinary(Arrays.copyOfRange(buffer, 0, read)); - Thread.sleep(10); + Thread.sleep(20); } - stream.close(); } diff --git a/src/main/java/com/ibm/watson/developer_cloud/util/CredentialUtils.java b/src/main/java/com/ibm/watson/developer_cloud/util/CredentialUtils.java index 1fb653d31e1..7457bb2bd73 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/util/CredentialUtils.java +++ b/src/main/java/com/ibm/watson/developer_cloud/util/CredentialUtils.java @@ -117,20 +117,27 @@ public static String getAPIKey(String serviceName, String plan) { /** * Attempt to get the Base64-encoded API key through JNDI + * * @param serviceName Name of the bluemix service * @return The encoded API Key */ - private static String getKeyUsingJNDI(String serviceName){ - try{ - Context context = new InitialContext(); - String lookupName = "watson-developer-cloud/" + serviceName + "/credentials"; - String apiKey = (String) context.lookup(lookupName); - return apiKey; - }catch(NamingException e){ - //ignore - return null; + private static String getKeyUsingJNDI(String serviceName) { + try { + Class.forName("javax.naming.Context"); + try { + Context context = new InitialContext(); + String lookupName = "watson-developer-cloud/" + serviceName + "/credentials"; + String apiKey = (String) context.lookup(lookupName); + return apiKey; + } catch (NamingException e) { + return null; + } + } catch (ClassNotFoundException exception) { + log.info("JNDI string lookups is not available."); } + return null; } + /** * Gets the VCAP_SERVICES environment variable and return it as a {@link JsonObject}. * diff --git a/src/main/java/com/ibm/watson/developer_cloud/util/ResponseUtil.java b/src/main/java/com/ibm/watson/developer_cloud/util/ResponseUtil.java index 39dfab787ab..2f509e5b477 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/util/ResponseUtil.java +++ b/src/main/java/com/ibm/watson/developer_cloud/util/ResponseUtil.java @@ -21,6 +21,7 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; +import com.google.gson.stream.JsonReader; import com.ibm.watson.developer_cloud.service.model.GenericModel; import com.squareup.okhttp.Response; @@ -52,21 +53,6 @@ public static InputStream getInputStream(Response response) { } } - /** - * Returns the HTTP Response as a {@link String}. - * - * @param response an HTTP response - * @return the content body as String - */ - public static String getResponseString(Response response) { - try { - return response.body().string(); - } catch (final IOException e) { - log.log(Level.SEVERE, ERROR_MESSAGE, e); - throw new RuntimeException(ERROR_MESSAGE, e); - } - } - /** * Return a {@link JsonElement} representation of the response. * @@ -111,11 +97,24 @@ public static JsonObject getJsonObject(String jsonString) { * @return the POJO */ public static T getObject(Response response, Class type) { - final String jsonString = getString(response); - final T model = GsonSingleton.getGson().fromJson(jsonString, type); - return model; + JsonReader reader; + try { + reader = new JsonReader(response.body().charStream()); + final T model = GsonSingleton.getGson().fromJson(reader, type); + return model; + } catch (IOException e) { + log.log(Level.SEVERE, ERROR_MESSAGE, e); + throw new RuntimeException(ERROR_MESSAGE, e); + } finally { + try { + response.body().close(); + } catch (IOException e) { + log.log(Level.SEVERE,"Error closing the HTTP Response", e); + } + } } + /** * Returns a String representation of the response. * diff --git a/src/test/java/com/ibm/watson/developer_cloud/WatsonServiceTest.java b/src/test/java/com/ibm/watson/developer_cloud/WatsonServiceTest.java index 99d04f05122..7d20687dee4 100755 --- a/src/test/java/com/ibm/watson/developer_cloud/WatsonServiceTest.java +++ b/src/test/java/com/ibm/watson/developer_cloud/WatsonServiceTest.java @@ -24,12 +24,15 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; +import java.util.HashMap; +import java.util.Map; import java.util.Properties; import java.util.logging.Level; import java.util.logging.Logger; import org.slf4j.LoggerFactory; +import com.ibm.watson.developer_cloud.http.HttpHeaders; import com.ibm.watson.developer_cloud.util.GsonSingleton; /** @@ -49,6 +52,11 @@ public WatsonServiceTest() { setupLogging(); } + protected Map getDefaultHeaders() { + Map headers = new HashMap(); + headers.put(HttpHeaders.X_WATSON_LEARNING_OPT_OUT, String.valueOf(true)); + return headers; + } /** * The Class EmptyPropertyException. */ diff --git a/src/test/java/com/ibm/watson/developer_cloud/alchemy/v1/AlchemyDataNewsIT.java b/src/test/java/com/ibm/watson/developer_cloud/alchemy/v1/AlchemyDataNewsIT.java index ec8e8444807..c6c47893794 100644 --- a/src/test/java/com/ibm/watson/developer_cloud/alchemy/v1/AlchemyDataNewsIT.java +++ b/src/test/java/com/ibm/watson/developer_cloud/alchemy/v1/AlchemyDataNewsIT.java @@ -43,7 +43,7 @@ public void setUp() throws Exception { super.setUp(); service = new AlchemyDataNews(); service.setApiKey(getValidProperty("alchemy.alchemy")); - + service.setDefaultHeaders(getDefaultHeaders()); } /** diff --git a/src/test/java/com/ibm/watson/developer_cloud/alchemy/v1/AlchemyLanguageIT.java b/src/test/java/com/ibm/watson/developer_cloud/alchemy/v1/AlchemyLanguageIT.java index 8ddbbac3537..2415fc27fd8 100644 --- a/src/test/java/com/ibm/watson/developer_cloud/alchemy/v1/AlchemyLanguageIT.java +++ b/src/test/java/com/ibm/watson/developer_cloud/alchemy/v1/AlchemyLanguageIT.java @@ -60,6 +60,7 @@ public void setUp() throws Exception { super.setUp(); service = new AlchemyLanguage(); service.setApiKey(getValidProperty("alchemy.alchemy")); + service.setDefaultHeaders(getDefaultHeaders()); htmlExample = getStringFromInputStream(new FileInputStream("src/test/resources/alchemy/example.html")); diff --git a/src/test/java/com/ibm/watson/developer_cloud/alchemy/v1/AlchemyVisionIT.java b/src/test/java/com/ibm/watson/developer_cloud/alchemy/v1/AlchemyVisionIT.java index 529619b475e..d3d5b1ab73c 100644 --- a/src/test/java/com/ibm/watson/developer_cloud/alchemy/v1/AlchemyVisionIT.java +++ b/src/test/java/com/ibm/watson/developer_cloud/alchemy/v1/AlchemyVisionIT.java @@ -52,6 +52,7 @@ public void setUp() throws Exception { super.setUp(); service = new AlchemyVision(); service.setApiKey(getValidProperty("alchemy.alchemy")); + service.setDefaultHeaders(getDefaultHeaders()); htmlExample = getStringFromInputStream(new FileInputStream("src/test/resources/alchemy/example.html")); } diff --git a/src/test/java/com/ibm/watson/developer_cloud/concept_expansion/v1/ConceptExpansionIT.java b/src/test/java/com/ibm/watson/developer_cloud/concept_expansion/v1/ConceptExpansionIT.java index d0025c174a6..b0f43b9c691 100644 --- a/src/test/java/com/ibm/watson/developer_cloud/concept_expansion/v1/ConceptExpansionIT.java +++ b/src/test/java/com/ibm/watson/developer_cloud/concept_expansion/v1/ConceptExpansionIT.java @@ -42,6 +42,7 @@ public void setUp() throws Exception { service.setUsernameAndPassword(getValidProperty("concept_expansion.username"), getValidProperty("concept_expansion.password")); service.setEndPoint(getValidProperty("concept_expansion.url")); + service.setDefaultHeaders(getDefaultHeaders()); } /** diff --git a/src/test/java/com/ibm/watson/developer_cloud/concept_insights/v2/ConceptInsightsIT.java b/src/test/java/com/ibm/watson/developer_cloud/concept_insights/v2/ConceptInsightsIT.java index 7a64e579fe6..6b5df3e53ad 100644 --- a/src/test/java/com/ibm/watson/developer_cloud/concept_insights/v2/ConceptInsightsIT.java +++ b/src/test/java/com/ibm/watson/developer_cloud/concept_insights/v2/ConceptInsightsIT.java @@ -76,6 +76,7 @@ public void setUp() throws Exception { service.setUsernameAndPassword(getValidProperty("concept_insights.username"), getValidProperty("concept_insights.password")); service.setEndPoint(getValidProperty("concept_insights.url")); + service.setDefaultHeaders(getDefaultHeaders()); } /** diff --git a/src/test/java/com/ibm/watson/developer_cloud/dialog/v1/DialogServiceIT.java b/src/test/java/com/ibm/watson/developer_cloud/dialog/v1/DialogServiceIT.java index 0cdf76e6a10..4c47f8d5503 100644 --- a/src/test/java/com/ibm/watson/developer_cloud/dialog/v1/DialogServiceIT.java +++ b/src/test/java/com/ibm/watson/developer_cloud/dialog/v1/DialogServiceIT.java @@ -59,7 +59,7 @@ public void setUp() throws Exception { service.setUsernameAndPassword(getValidProperty("dialog.username"), getValidProperty("dialog.password")); service.setEndPoint(getValidProperty("dialog.url")); - + service.setDefaultHeaders(getDefaultHeaders()); dialogId = getValidProperty("dialog.dialog_id"); } diff --git a/src/test/java/com/ibm/watson/developer_cloud/document_conversion/v1/DocumentConversionIT.java b/src/test/java/com/ibm/watson/developer_cloud/document_conversion/v1/DocumentConversionIT.java index 0a05cfcb1cf..aa4c5af9036 100644 --- a/src/test/java/com/ibm/watson/developer_cloud/document_conversion/v1/DocumentConversionIT.java +++ b/src/test/java/com/ibm/watson/developer_cloud/document_conversion/v1/DocumentConversionIT.java @@ -44,7 +44,7 @@ public void setUp() throws Exception { service.setUsernameAndPassword(prop.getProperty("document_conversion.username"), prop.getProperty("document_conversion.password")); service.setEndPoint(prop.getProperty("document_conversion.url")); - + service.setDefaultHeaders(getDefaultHeaders()); files = new File[] { new File("src/test/resources/document_conversion/word-docx-heading-input.docx"), diff --git a/src/test/java/com/ibm/watson/developer_cloud/language_translation/v2/LanguageTranslationIT.java b/src/test/java/com/ibm/watson/developer_cloud/language_translation/v2/LanguageTranslationIT.java index 7c70218fe4b..0a4e2b90a46 100644 --- a/src/test/java/com/ibm/watson/developer_cloud/language_translation/v2/LanguageTranslationIT.java +++ b/src/test/java/com/ibm/watson/developer_cloud/language_translation/v2/LanguageTranslationIT.java @@ -58,6 +58,7 @@ public void setUp() throws Exception { service.setUsernameAndPassword(getValidProperty("language_translation.username"), getValidProperty("language_translation.password")); service.setEndPoint(getValidProperty("language_translation.url")); + service.setDefaultHeaders(getDefaultHeaders()); } /** @@ -71,7 +72,10 @@ public void testCreateAndDeleteModel() { TranslationModel model = null; try { model = service.createModel(options); + Thread.sleep(3000); assertNotNull(model); + } catch (InterruptedException e) { + e.printStackTrace(); } finally { if (model != null) service.deleteModel(model.getId()); diff --git a/src/test/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/NaturalLanguageClassifierIT.java b/src/test/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/NaturalLanguageClassifierIT.java index ca1a6c31d1b..62939ce108a 100644 --- a/src/test/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/NaturalLanguageClassifierIT.java +++ b/src/test/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/NaturalLanguageClassifierIT.java @@ -91,6 +91,7 @@ public void testClassify() throws Exception { public void setUp() throws Exception { super.setUp(); service = new NaturalLanguageClassifier(); + service.setDefaultHeaders(getDefaultHeaders()); service.setUsernameAndPassword(getValidProperty("natural_language_classifier.username"), getValidProperty("natural_language_classifier.password")); service.setEndPoint(getValidProperty("natural_language_classifier.url")); diff --git a/src/test/java/com/ibm/watson/developer_cloud/personality_insights/v2/PersonalityInsightsIT.java b/src/test/java/com/ibm/watson/developer_cloud/personality_insights/v2/PersonalityInsightsIT.java index 8a61a81f6e5..2f9487b8fb5 100644 --- a/src/test/java/com/ibm/watson/developer_cloud/personality_insights/v2/PersonalityInsightsIT.java +++ b/src/test/java/com/ibm/watson/developer_cloud/personality_insights/v2/PersonalityInsightsIT.java @@ -48,6 +48,7 @@ public void setUp() throws Exception { service.setUsernameAndPassword(getValidProperty("personality_insights.username"), getValidProperty("personality_insights.password")); service.setEndPoint(getValidProperty("personality_insights.url")); + service.setDefaultHeaders(getDefaultHeaders()); } @Test diff --git a/src/test/java/com/ibm/watson/developer_cloud/relationship_extraction/v1/RelationshipExtractionIT.java b/src/test/java/com/ibm/watson/developer_cloud/relationship_extraction/v1/RelationshipExtractionIT.java index c269f9f8cdf..ef0f9f12d3a 100644 --- a/src/test/java/com/ibm/watson/developer_cloud/relationship_extraction/v1/RelationshipExtractionIT.java +++ b/src/test/java/com/ibm/watson/developer_cloud/relationship_extraction/v1/RelationshipExtractionIT.java @@ -45,6 +45,7 @@ public void setUp() throws Exception { service.setUsernameAndPassword(getValidProperty("relationship_extraction.username"), getValidProperty("relationship_extraction.password")); service.setEndPoint(getValidProperty("relationship_extraction.url")); + service.setDefaultHeaders(getDefaultHeaders()); } /** diff --git a/src/test/java/com/ibm/watson/developer_cloud/retrieve_and_rank/v1/RetrieveAndRankIT.java b/src/test/java/com/ibm/watson/developer_cloud/retrieve_and_rank/v1/RetrieveAndRankIT.java index 939765a08b3..9e1efc9e140 100644 --- a/src/test/java/com/ibm/watson/developer_cloud/retrieve_and_rank/v1/RetrieveAndRankIT.java +++ b/src/test/java/com/ibm/watson/developer_cloud/retrieve_and_rank/v1/RetrieveAndRankIT.java @@ -63,6 +63,7 @@ public void setUp() throws Exception { service.setUsernameAndPassword(getValidProperty("retrieve_and_rank.username"), getValidProperty("retrieve_and_rank.password")); service.setEndPoint(getValidProperty("retrieve_and_rank.url")); + service.setDefaultHeaders(getDefaultHeaders()); rankerId = getValidProperty("retrieve_and_rank.ranker_id"); clusterId = getValidProperty("retrieve_and_rank.cluster_id"); } diff --git a/src/test/java/com/ibm/watson/developer_cloud/speech_to_text/v1/SpeechToTextIT.java b/src/test/java/com/ibm/watson/developer_cloud/speech_to_text/v1/SpeechToTextIT.java index 3fbae1f5c25..4f17e74a8ed 100644 --- a/src/test/java/com/ibm/watson/developer_cloud/speech_to_text/v1/SpeechToTextIT.java +++ b/src/test/java/com/ibm/watson/developer_cloud/speech_to_text/v1/SpeechToTextIT.java @@ -59,6 +59,7 @@ public void setUp() throws Exception { service.setUsernameAndPassword(getValidProperty("speech_to_text.username"), getValidProperty("speech_to_text.password")); service.setEndPoint(getValidProperty("speech_to_text.url")); + service.setDefaultHeaders(getDefaultHeaders()); } /** @@ -203,8 +204,7 @@ public void onError(Exception e) { public void onMessage(SpeechResults speechResults) { if (speechResults != null && speechResults.isFinal()) { asyncResults = speechResults; - // System.out.println(speechResults); - lock.countDown(); + //System.out.println(speechResults); } } diff --git a/src/test/java/com/ibm/watson/developer_cloud/text_to_speech/v1/TextToSpeechIT.java b/src/test/java/com/ibm/watson/developer_cloud/text_to_speech/v1/TextToSpeechIT.java index 7b2861ecbb2..4ea176106b6 100644 --- a/src/test/java/com/ibm/watson/developer_cloud/text_to_speech/v1/TextToSpeechIT.java +++ b/src/test/java/com/ibm/watson/developer_cloud/text_to_speech/v1/TextToSpeechIT.java @@ -64,6 +64,7 @@ public void setUp() throws Exception { service.setUsernameAndPassword(prop.getProperty("text_to_speech.username"), prop.getProperty("text_to_speech.password")); service.setEndPoint(prop.getProperty("text_to_speech.url")); + service.setDefaultHeaders(getDefaultHeaders()); } diff --git a/src/test/java/com/ibm/watson/developer_cloud/tone_analyzer/v1/ToneAnalyzerIT.java b/src/test/java/com/ibm/watson/developer_cloud/tone_analyzer/v1/ToneAnalyzerIT.java index 3d204a91ba0..35792d7ae2d 100644 --- a/src/test/java/com/ibm/watson/developer_cloud/tone_analyzer/v1/ToneAnalyzerIT.java +++ b/src/test/java/com/ibm/watson/developer_cloud/tone_analyzer/v1/ToneAnalyzerIT.java @@ -46,6 +46,7 @@ public void setUp() throws Exception { service.setUsernameAndPassword(getValidProperty("tone_analyzer.username"), getValidProperty("tone_analyzer.password")); service.setEndPoint(getValidProperty("tone_analyzer.url")); + service.setDefaultHeaders(getDefaultHeaders()); } diff --git a/src/test/java/com/ibm/watson/developer_cloud/tradeoff_analytics/v1/TradeoffAnalyticsIT.java b/src/test/java/com/ibm/watson/developer_cloud/tradeoff_analytics/v1/TradeoffAnalyticsIT.java index 30280e91892..f9695f67d01 100644 --- a/src/test/java/com/ibm/watson/developer_cloud/tradeoff_analytics/v1/TradeoffAnalyticsIT.java +++ b/src/test/java/com/ibm/watson/developer_cloud/tradeoff_analytics/v1/TradeoffAnalyticsIT.java @@ -54,7 +54,7 @@ public void setUp() throws Exception { service.setUsernameAndPassword(getValidProperty("tradeoff_analytics.username"), getValidProperty("tradeoff_analytics.password")); service.setEndPoint(getValidProperty("tradeoff_analytics.url")); - + service.setDefaultHeaders(getDefaultHeaders()); problem = loadFixture("src/test/resources/tradeoff_analytics/problem.json", Problem.class); } diff --git a/src/test/java/com/ibm/watson/developer_cloud/visual_insights/v1/VisualInsightsIT.java b/src/test/java/com/ibm/watson/developer_cloud/visual_insights/v1/VisualInsightsIT.java index 81a1be7a540..fd8e257c783 100644 --- a/src/test/java/com/ibm/watson/developer_cloud/visual_insights/v1/VisualInsightsIT.java +++ b/src/test/java/com/ibm/watson/developer_cloud/visual_insights/v1/VisualInsightsIT.java @@ -52,6 +52,7 @@ public void setUp() throws Exception { service.setUsernameAndPassword(getValidProperty("visual_insights.username"), getValidProperty("visual_insights.password")); service.setEndPoint(getValidProperty("visual_insights.url")); + service.setDefaultHeaders(getDefaultHeaders()); } /** diff --git a/src/test/java/com/ibm/watson/developer_cloud/visual_recognition/v2/VisualRecognitionIT.java b/src/test/java/com/ibm/watson/developer_cloud/visual_recognition/v2/VisualRecognitionIT.java index ba18a90bb40..b1ebc0e971f 100644 --- a/src/test/java/com/ibm/watson/developer_cloud/visual_recognition/v2/VisualRecognitionIT.java +++ b/src/test/java/com/ibm/watson/developer_cloud/visual_recognition/v2/VisualRecognitionIT.java @@ -49,6 +49,7 @@ public void setUp() throws Exception { service.setUsernameAndPassword(getValidProperty("visual_recognition.v2.username"), getValidProperty("visual_recognition.v2.password")); service.setEndPoint(getValidProperty("visual_recognition.v2.url")); + service.setDefaultHeaders(getDefaultHeaders()); } /**