From 6ff28ff62c2bf9b34d3abd6e1607337ac92ad9bf Mon Sep 17 00:00:00 2001 From: Denilson Nastacio Date: Sat, 2 Jul 2016 16:51:01 -0400 Subject: [PATCH 01/10] TypedRelation service call in Alchemy Language Java SDK not returning entities #367 --- .../v1/model/TypedEntitiesAdapter.java | 58 +++++++++++++++++++ .../alchemy/v1/model/TypedRelation.java | 23 ++++---- .../alchemy/v1/AlchemyLanguageIT.java | 38 +++++++----- 3 files changed, 95 insertions(+), 24 deletions(-) create mode 100644 src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/TypedEntitiesAdapter.java diff --git a/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/TypedEntitiesAdapter.java b/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/TypedEntitiesAdapter.java new file mode 100644 index 00000000000..6b086849453 --- /dev/null +++ b/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/TypedEntitiesAdapter.java @@ -0,0 +1,58 @@ +package com.ibm.watson.developer_cloud.alchemy.v1.model; + +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +public class TypedEntitiesAdapter extends TypeAdapter> { + + @Override + public void write(JsonWriter writer, List value) throws IOException { + } + + @Override + public List read(JsonReader reader) throws IOException { + List es = new ArrayList(); + + reader.beginArray(); // arguments + while (reader.hasNext()) { + reader.beginObject(); // argument + while (reader.hasNext()) { + String name = reader.nextName(); + if ("entities".equals(name)) { + reader.beginArray(); + while (reader.hasNext()) { + TypedEntity e = new TypedEntity(); + reader.beginObject(); + while (reader.hasNext()) { + String name1 = reader.nextName(); + if ("text".equals(name1)) { + e.setText(reader.nextString()); + } else if ("type".equals(name1)) { + e.setType(reader.nextString()); + } else if ("id".equals(name1)) { + e.setId(reader.nextString()); + } else { + reader.skipValue(); + } + } + reader.endObject(); + es.add(e); + } + reader.endArray(); + } else { + reader.skipValue(); + } + } + reader.endObject(); + } + reader.endArray(); + + return es; + } + +} diff --git a/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/TypedRelation.java b/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/TypedRelation.java index 52a350c57bf..68aa0bef79d 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/TypedRelation.java +++ b/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/TypedRelation.java @@ -14,10 +14,12 @@ package com.ibm.watson.developer_cloud.alchemy.v1.model; -import java.util.List; - +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; import com.ibm.watson.developer_cloud.alchemy.v1.AlchemyLanguage; +import java.util.List; + /** * Typed relation between {@link TypedEntity}. * @see AlchemyLanguage#getTypedRelations(java.util.Map) @@ -27,7 +29,10 @@ public class TypedRelation { private String text; private String type; private Double score; - private List entities; + + @JsonAdapter(TypedEntitiesAdapter.class) + @SerializedName("arguments") + private List entities; /** * Gets the text. @@ -84,20 +89,16 @@ public void setScore(Double score) { } /** - * Gets the entities. - * - * @return The entities + * @return the entities */ - public List getEntities() { + public List getEntities() { return entities; } /** - * Sets the entities. - * - * @param entities The entities + * @param entities the entities to set */ - public void setEntities(List entities) { + public void setEntities(List entities) { this.entities = entities; } 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 db197d06ca9..3c046b2d054 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 @@ -13,16 +13,6 @@ */ package com.ibm.watson.developer_cloud.alchemy.v1; -import java.io.FileInputStream; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; - import com.ibm.watson.developer_cloud.WatsonServiceTest; import com.ibm.watson.developer_cloud.alchemy.v1.model.CombinedResults; import com.ibm.watson.developer_cloud.alchemy.v1.model.Concepts; @@ -40,8 +30,20 @@ import com.ibm.watson.developer_cloud.alchemy.v1.model.Microformats; import com.ibm.watson.developer_cloud.alchemy.v1.model.SAORelations; import com.ibm.watson.developer_cloud.alchemy.v1.model.Taxonomies; +import com.ibm.watson.developer_cloud.alchemy.v1.model.TypedRelation; import com.ibm.watson.developer_cloud.alchemy.v1.model.TypedRelations; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; + +import java.io.FileInputStream; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + /** * Created by nizar on 8/25/15. */ @@ -485,11 +487,21 @@ public void testGetTypedRelationsHTML() { @Test public void testGetTypedRelationsText() { final Map params = new HashMap(); - params.put(AlchemyLanguage.TEXT, "Jake is one of the developers in the team."); - params.put(AlchemyLanguage.MODEL_ID, "en-us-tir"); + params.put(AlchemyLanguage.TEXT, "Leiming Qian lives in New York."); + params.put(AlchemyLanguage.MODEL_ID, "ie-en-news"); final TypedRelations typedRelations = service.getTypedRelations(params).execute(); Assert.assertNotNull(typedRelations); - Assert.assertNotNull(typedRelations.getTypedRelations()); + List trs = typedRelations.getTypedRelations(); + Assert.assertNotNull(trs); + Assert.assertFalse(trs.isEmpty()); + trs.stream().forEach(tr -> Assert.assertNotNull(tr.getType())); + trs.stream().forEach(tr -> Assert.assertNotNull(tr.getEntities())); + trs.stream().forEach(tr -> Assert.assertFalse(tr.getEntities().isEmpty())); + trs.stream().forEach(tr -> tr.getEntities().stream().forEach(e -> { + Assert.assertNotNull(e.getId()); + Assert.assertNotNull(e.getText()); + Assert.assertNotNull(e.getType()); + })); } /** From 0926ae345277f42c48a781f93f0ec8e3bd18e75d Mon Sep 17 00:00:00 2001 From: Denilson Nastacio Date: Sat, 2 Jul 2016 17:03:15 -0400 Subject: [PATCH 02/10] Removing usage of Java 1.8 streams. --- .../alchemy/v1/AlchemyLanguageIT.java | 914 +++++++++--------- 1 file changed, 456 insertions(+), 458 deletions(-) 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 3c046b2d054..6096f830add 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 @@ -30,6 +30,7 @@ import com.ibm.watson.developer_cloud.alchemy.v1.model.Microformats; import com.ibm.watson.developer_cloud.alchemy.v1.model.SAORelations; import com.ibm.watson.developer_cloud.alchemy.v1.model.Taxonomies; +import com.ibm.watson.developer_cloud.alchemy.v1.model.TypedEntity; import com.ibm.watson.developer_cloud.alchemy.v1.model.TypedRelation; import com.ibm.watson.developer_cloud.alchemy.v1.model.TypedRelations; @@ -49,442 +50,437 @@ */ public class AlchemyLanguageIT extends WatsonServiceTest { - /** The html example. */ - private String htmlExample; - - /** The service. */ - private AlchemyLanguage service; - - /* - * (non-Javadoc) - * - * @see com.ibm.watson.developer_cloud.WatsonServiceTest#setUp() - */ - @Override - @Before - 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")); - - } - - /** - * Test api key is null. - */ - @Test(expected = IllegalArgumentException.class) - public void testApiKeyIsNull() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.URL, "http://www.techcrunch.com/"); - - final AlchemyLanguage language = new AlchemyLanguage(); - language.setApiKey(null); - language.getKeywords(params).execute(); - } - - /** - * Test comboined. - */ - @Test - public void testComboined() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.URL, "http://www.techcrunch.com/"); - final CombinedResults combined = service.getCombinedResults(params).execute(); - Assert.assertNotNull(combined); - } - - /** - * Test Get testFeeds. - */ - @Test - public void testFeeds() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.URL, "http://www.techcrunch.com/"); - final Feeds feeds = service.getFeeds(params).execute(); - Assert.assertNotNull(feeds); - } - - /** - * Test Get testGetAuthor. - */ - @Test - public void testGetAuthors() { - final Map params = new HashMap(); - params - .put(AlchemyLanguage.URL, - "http://www.politico.com/blogs/media/2012/02/detroit-news-ed-upset-over-romney-edit-115247.html"); - final DocumentAuthors authors = service.getAuthors(params).execute(); - Assert.assertNotNull(authors); - } - - /** - * Test get concepts HTML. - */ - @Test - public void testGetConceptsHTML() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.HTML, htmlExample); - final Concepts concepts = service.getConcepts(params).execute(); - Assert.assertNotNull(concepts); - Assert.assertFalse(concepts.getConcepts().isEmpty()); - } - - /** - * Test get concepts Tet. - */ - @Test - public void testGetConceptsText() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.TEXT, htmlExample); - final Concepts concepts = service.getConcepts(params).execute(); - Assert.assertNotNull(concepts); - Assert.assertFalse(concepts.getConcepts().isEmpty()); - } - - /** - * Test Get getTaxonomy URL. - */ - @Test - public void testGetConceptsUrl() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.URL, "http://www.techcrunch.com/"); - final Concepts concepts = service.getConcepts(params).execute(); - Assert.assertNotNull(concepts); - Assert.assertFalse(concepts.getConcepts().isEmpty()); - } - - /** - * Test Get entities HTML. - */ - @Test - public void testGetEntitiesHtml() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.HTML, htmlExample); - - final Entities entities = service.getEntities(params).execute(); - Assert.assertNotNull(entities); - Assert.assertFalse(entities.getEntities().isEmpty()); - } - - /** - * Test Get entities URL. - */ - @Test - public void testGetEntitiesUrl() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.URL, "http://www.techcrunch.com/"); - final Entities entities = service.getEntities(params).execute(); - Assert.assertNotNull(entities); - Assert.assertFalse(entities.getEntities().isEmpty()); - } - - /** - * Test Get entities HTML. - */ - @Test - public void testGetEntitiesWithDifferentCharacters() { - final Map params = new HashMap(); - final String text = - "Mr. Vice President, my old colleague from Massachusetts" - + "and your new Speaker & John McCormack, Members of the 87th Congress, " - + "ladies and gentlemen: -.*&^%$#@!@#$%^&*()"; - params.put(AlchemyLanguage.TEXT, text); - - final Entities entities = service.getEntities(params).execute(); - Assert.assertNotNull(entities); - Assert.assertFalse(entities.getEntities().isEmpty()); - } - - /** - * Test Get testGetLanguage. - */ - @Test - public void testGetLanguage() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.URL, "http://news.google.fr/"); - final Language language = service.getLanguage(params).execute(); - Assert.assertNotNull(language); - } - - /** - * Test get publication date html. - */ - @Test - public void testGetPublicationDateHTML() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.HTML, htmlExample); - final DocumentPublicationDate date = service.getPublicationDate(params).execute(); - Assert.assertNotNull(date); - Assert.assertNotNull(date.getPublicationDate()); - } - - /** - * Test get publication date url. - */ - @Test - public void testGetPublicationDateURL() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.URL, "http://www.techcrunch.com/"); - final DocumentPublicationDate date = service.getPublicationDate(params).execute(); - Assert.assertNotNull(date); - Assert.assertNotNull(date.getPublicationDate()); - } - - /** - * Test Get testGetRelationsHtml HTML. - * - */ - @Test - public void testGetRelationsHtml() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.HTML, htmlExample); - final SAORelations relations = service.getRelations(params).execute(); - Assert.assertNotNull(relations); - } - - /** - * Test Get testGetRelationsUrl URL. - */ - @Test - public void testGetRelationsUrl() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.URL, "http://www.techcrunch.com/"); - final SAORelations relations = service.getRelations(params).execute(); - Assert.assertNotNull(relations); - } - - /** - * Test Get testGetTargetedSentiment HTML. - */ - @Test - public void testGetTargetedSentimentHtml() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.HTML, htmlExample); - params.put(AlchemyLanguage.TARGET, "Watson"); - final DocumentSentiment documentSentiment = service.getSentiment(params).execute(); - Assert.assertNotNull(documentSentiment); - } - - /** - * Test Get testGetTargetedSentiment Url. - */ - @Test - public void testGetTargetedSentimentURL() { - final Map params = new HashMap(); - params - .put( - AlchemyLanguage.URL, - "http://techcrunch.com/2012/03/01/keen-on-anand-rajaraman-how-walmart-wants-to-leapfrog-over-amazon-tctv/"); - params.put(AlchemyLanguage.TARGET, "Walmart"); - final DocumentSentiment documentSentiment = service.getSentiment(params).execute(); - Assert.assertNotNull(documentSentiment); - } - - /** - * Test Get testGetTargetedSentiment Url and multiple targets. - */ - @Test - public void testGetTargetedSentimentURLAndTargets() { - final Map params = new HashMap(); - params - .put( - AlchemyLanguage.URL, - "http://techcrunch.com/2012/03/01/keen-on-anand-rajaraman-how-walmart-wants-to-leapfrog-over-amazon-tctv/"); - params.put(AlchemyLanguage.TARGETS, "Walmart|Walmart"); - final DocumentSentiment documentSentiment = service.getSentiment(params).execute(); - Assert.assertNotNull(documentSentiment); - } - - /** - * Test Get getTaxonomy HTML. - * - * @throws IOException Signals that an I/O exception has occurred. - */ - @Test - public void testGetTaxonomyHtml() throws IOException { - final Map params = new HashMap(); - params.put(AlchemyLanguage.HTML, htmlExample); - final Taxonomies taxonomy = service.getTaxonomy(params).execute(); - Assert.assertNotNull(taxonomy); - Assert.assertFalse(taxonomy.getTaxonomy().isEmpty()); - } - - /** - * Test Get getTaxonomy URL. - */ - @Test - public void testGetTaxonomyUrl() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.URL, "http://www.techcrunch.com/"); - final Taxonomies taxonomy = service.getTaxonomy(params).execute(); - Assert.assertNotNull(taxonomy); - Assert.assertFalse(taxonomy.getTaxonomy().isEmpty()); - } - - /** - * Test Get testGetTextSentiment HTML. - */ - @Test - public void testGetTextSentimentHtml() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.HTML, htmlExample); - final DocumentSentiment documentSentiment = service.getSentiment(params).execute(); - Assert.assertNotNull(documentSentiment); - } - - /** - * Test Get testGetTextSentiment URL. - */ - @Test - public void testGetTextSentimentUrl() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.URL, "http://www.techcrunch.com/"); - final DocumentSentiment documentSentiment = service.getSentiment(params).execute(); - Assert.assertNotNull(documentSentiment); - } - - /** - * Test Get testGetTitle. - */ - @Test - public void testGetTitle() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.URL, "http://www.techcrunch.com/"); - final DocumentTitle title = service.getTitle(params).execute(); - Assert.assertNotNull(title); - } - - /** - * Test Get keywords HTML. - * - */ - @Test - public void testGetWordsHtml() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.HTML, htmlExample); - - final Keywords keywords = service.getKeywords(params).execute(); - Assert.assertNotNull(keywords); - Assert.assertFalse(keywords.getKeywords().isEmpty()); - } - - /** - * Test Get keywords URL. - */ - @Test - public void testGetWordsUrl() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.URL, "http://www.techcrunch.com/"); - final Keywords keywords = service.getKeywords(params).execute(); - Assert.assertNotNull(keywords); - Assert.assertFalse(keywords.getKeywords().isEmpty()); - } - - /** - * Test microformats. - */ - @Test - public void testMicroformats() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.URL, "http://microformats.org/wiki/hcard"); - final Microformats microformats = service.getMicroformats(params).execute(); - Assert.assertNotNull(microformats); - } - - /** - * Test Get testGetRawText. - */ - @Test - public void testRawText() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.URL, "http://www.test.com/"); - params.put(AlchemyLanguage.RAW, true); - final DocumentText text = service.getText(params).execute(); - Assert.assertNotNull(text); - } - - /** - * Test Get testGetText. - */ - @Test - public void testText() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.URL, "http://www.techcrunch.com/"); - final DocumentText text = service.getText(params).execute(); - Assert.assertNotNull(text); - } - - /** - * Test get dates from a url. - */ - @Test - public void testGetDates() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.TEXT, "Let's meet on January 4th, 2004"); - params.put(AlchemyLanguage.ANCHOR_DATE, "2013-12-16 20:06:18"); - - final Dates dates = service.getDates(params).execute(); - Assert.assertNotNull(dates); - Assert.assertNotNull(dates.getDates()); - Assert.assertFalse(dates.getDates().isEmpty()); - } - - /** - * Test get emotion from HTML. - */ - @Test - public void testGetEmotionHTML() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.HTML, htmlExample); - final DocumentEmotion emotion = service.getEmotion(params).execute(); - Assert.assertNotNull(emotion); - Assert.assertNotNull(emotion.getEmotion()); - } - - /** - * Test get emotion from text. - */ - @Test - public void testGetEmotionText() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.TEXT, htmlExample); - final DocumentEmotion emotion = service.getEmotion(params).execute(); - Assert.assertNotNull(emotion); - Assert.assertNotNull(emotion.getEmotion()); - } - - /** - * Test Get emotion from URL. - */ - @Test - public void testGetEmotionUrl() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.URL, "http://www.techcrunch.com/"); - final DocumentEmotion emotion = service.getEmotion(params).execute(); - Assert.assertNotNull(emotion); - Assert.assertNotNull(emotion.getEmotion()); - } - - /** - * Test get typed relations from HTML. - */ - @Test - @Ignore - public void testGetTypedRelationsHTML() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.HTML, htmlExample); - final TypedRelations typedRelations = service.getTypedRelations(params).execute(); - Assert.assertNotNull(typedRelations); - Assert.assertNotNull(typedRelations.getTypedRelations()); - } - - /** - * Test get typed relations from text. - */ - @Test + /** The html example. */ + private String htmlExample; + + /** The service. */ + private AlchemyLanguage service; + + /* + * (non-Javadoc) + * + * @see com.ibm.watson.developer_cloud.WatsonServiceTest#setUp() + */ + @Override + @Before + 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")); + + } + + /** + * Test api key is null. + */ + @Test(expected = IllegalArgumentException.class) + public void testApiKeyIsNull() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.URL, "http://www.techcrunch.com/"); + + final AlchemyLanguage language = new AlchemyLanguage(); + language.setApiKey(null); + language.getKeywords(params).execute(); + } + + /** + * Test comboined. + */ + @Test + public void testComboined() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.URL, "http://www.techcrunch.com/"); + final CombinedResults combined = service.getCombinedResults(params).execute(); + Assert.assertNotNull(combined); + } + + /** + * Test Get testFeeds. + */ + @Test + public void testFeeds() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.URL, "http://www.techcrunch.com/"); + final Feeds feeds = service.getFeeds(params).execute(); + Assert.assertNotNull(feeds); + } + + /** + * Test Get testGetAuthor. + */ + @Test + public void testGetAuthors() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.URL, + "http://www.politico.com/blogs/media/2012/02/detroit-news-ed-upset-over-romney-edit-115247.html"); + final DocumentAuthors authors = service.getAuthors(params).execute(); + Assert.assertNotNull(authors); + } + + /** + * Test get concepts HTML. + */ + @Test + public void testGetConceptsHTML() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.HTML, htmlExample); + final Concepts concepts = service.getConcepts(params).execute(); + Assert.assertNotNull(concepts); + Assert.assertFalse(concepts.getConcepts().isEmpty()); + } + + /** + * Test get concepts Tet. + */ + @Test + public void testGetConceptsText() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.TEXT, htmlExample); + final Concepts concepts = service.getConcepts(params).execute(); + Assert.assertNotNull(concepts); + Assert.assertFalse(concepts.getConcepts().isEmpty()); + } + + /** + * Test Get getTaxonomy URL. + */ + @Test + public void testGetConceptsUrl() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.URL, "http://www.techcrunch.com/"); + final Concepts concepts = service.getConcepts(params).execute(); + Assert.assertNotNull(concepts); + Assert.assertFalse(concepts.getConcepts().isEmpty()); + } + + /** + * Test Get entities HTML. + */ + @Test + public void testGetEntitiesHtml() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.HTML, htmlExample); + + final Entities entities = service.getEntities(params).execute(); + Assert.assertNotNull(entities); + Assert.assertFalse(entities.getEntities().isEmpty()); + } + + /** + * Test Get entities URL. + */ + @Test + public void testGetEntitiesUrl() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.URL, "http://www.techcrunch.com/"); + final Entities entities = service.getEntities(params).execute(); + Assert.assertNotNull(entities); + Assert.assertFalse(entities.getEntities().isEmpty()); + } + + /** + * Test Get entities HTML. + */ + @Test + public void testGetEntitiesWithDifferentCharacters() { + final Map params = new HashMap(); + final String text = "Mr. Vice President, my old colleague from Massachusetts" + + "and your new Speaker & John McCormack, Members of the 87th Congress, " + + "ladies and gentlemen: -.*&^%$#@!@#$%^&*()"; + params.put(AlchemyLanguage.TEXT, text); + + final Entities entities = service.getEntities(params).execute(); + Assert.assertNotNull(entities); + Assert.assertFalse(entities.getEntities().isEmpty()); + } + + /** + * Test Get testGetLanguage. + */ + @Test + public void testGetLanguage() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.URL, "http://news.google.fr/"); + final Language language = service.getLanguage(params).execute(); + Assert.assertNotNull(language); + } + + /** + * Test get publication date html. + */ + @Test + public void testGetPublicationDateHTML() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.HTML, htmlExample); + final DocumentPublicationDate date = service.getPublicationDate(params).execute(); + Assert.assertNotNull(date); + Assert.assertNotNull(date.getPublicationDate()); + } + + /** + * Test get publication date url. + */ + @Test + public void testGetPublicationDateURL() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.URL, "http://www.techcrunch.com/"); + final DocumentPublicationDate date = service.getPublicationDate(params).execute(); + Assert.assertNotNull(date); + Assert.assertNotNull(date.getPublicationDate()); + } + + /** + * Test Get testGetRelationsHtml HTML. + * + */ + @Test + public void testGetRelationsHtml() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.HTML, htmlExample); + final SAORelations relations = service.getRelations(params).execute(); + Assert.assertNotNull(relations); + } + + /** + * Test Get testGetRelationsUrl URL. + */ + @Test + public void testGetRelationsUrl() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.URL, "http://www.techcrunch.com/"); + final SAORelations relations = service.getRelations(params).execute(); + Assert.assertNotNull(relations); + } + + /** + * Test Get testGetTargetedSentiment HTML. + */ + @Test + public void testGetTargetedSentimentHtml() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.HTML, htmlExample); + params.put(AlchemyLanguage.TARGET, "Watson"); + final DocumentSentiment documentSentiment = service.getSentiment(params).execute(); + Assert.assertNotNull(documentSentiment); + } + + /** + * Test Get testGetTargetedSentiment Url. + */ + @Test + public void testGetTargetedSentimentURL() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.URL, + "http://techcrunch.com/2012/03/01/keen-on-anand-rajaraman-how-walmart-wants-to-leapfrog-over-amazon-tctv/"); + params.put(AlchemyLanguage.TARGET, "Walmart"); + final DocumentSentiment documentSentiment = service.getSentiment(params).execute(); + Assert.assertNotNull(documentSentiment); + } + + /** + * Test Get testGetTargetedSentiment Url and multiple targets. + */ + @Test + public void testGetTargetedSentimentURLAndTargets() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.URL, + "http://techcrunch.com/2012/03/01/keen-on-anand-rajaraman-how-walmart-wants-to-leapfrog-over-amazon-tctv/"); + params.put(AlchemyLanguage.TARGETS, "Walmart|Walmart"); + final DocumentSentiment documentSentiment = service.getSentiment(params).execute(); + Assert.assertNotNull(documentSentiment); + } + + /** + * Test Get getTaxonomy HTML. + * + * @throws IOException + * Signals that an I/O exception has occurred. + */ + @Test + public void testGetTaxonomyHtml() throws IOException { + final Map params = new HashMap(); + params.put(AlchemyLanguage.HTML, htmlExample); + final Taxonomies taxonomy = service.getTaxonomy(params).execute(); + Assert.assertNotNull(taxonomy); + Assert.assertFalse(taxonomy.getTaxonomy().isEmpty()); + } + + /** + * Test Get getTaxonomy URL. + */ + @Test + public void testGetTaxonomyUrl() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.URL, "http://www.techcrunch.com/"); + final Taxonomies taxonomy = service.getTaxonomy(params).execute(); + Assert.assertNotNull(taxonomy); + Assert.assertFalse(taxonomy.getTaxonomy().isEmpty()); + } + + /** + * Test Get testGetTextSentiment HTML. + */ + @Test + public void testGetTextSentimentHtml() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.HTML, htmlExample); + final DocumentSentiment documentSentiment = service.getSentiment(params).execute(); + Assert.assertNotNull(documentSentiment); + } + + /** + * Test Get testGetTextSentiment URL. + */ + @Test + public void testGetTextSentimentUrl() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.URL, "http://www.techcrunch.com/"); + final DocumentSentiment documentSentiment = service.getSentiment(params).execute(); + Assert.assertNotNull(documentSentiment); + } + + /** + * Test Get testGetTitle. + */ + @Test + public void testGetTitle() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.URL, "http://www.techcrunch.com/"); + final DocumentTitle title = service.getTitle(params).execute(); + Assert.assertNotNull(title); + } + + /** + * Test Get keywords HTML. + * + */ + @Test + public void testGetWordsHtml() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.HTML, htmlExample); + + final Keywords keywords = service.getKeywords(params).execute(); + Assert.assertNotNull(keywords); + Assert.assertFalse(keywords.getKeywords().isEmpty()); + } + + /** + * Test Get keywords URL. + */ + @Test + public void testGetWordsUrl() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.URL, "http://www.techcrunch.com/"); + final Keywords keywords = service.getKeywords(params).execute(); + Assert.assertNotNull(keywords); + Assert.assertFalse(keywords.getKeywords().isEmpty()); + } + + /** + * Test microformats. + */ + @Test + public void testMicroformats() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.URL, "http://microformats.org/wiki/hcard"); + final Microformats microformats = service.getMicroformats(params).execute(); + Assert.assertNotNull(microformats); + } + + /** + * Test Get testGetRawText. + */ + @Test + public void testRawText() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.URL, "http://www.test.com/"); + params.put(AlchemyLanguage.RAW, true); + final DocumentText text = service.getText(params).execute(); + Assert.assertNotNull(text); + } + + /** + * Test Get testGetText. + */ + @Test + public void testText() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.URL, "http://www.techcrunch.com/"); + final DocumentText text = service.getText(params).execute(); + Assert.assertNotNull(text); + } + + /** + * Test get dates from a url. + */ + @Test + public void testGetDates() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.TEXT, "Let's meet on January 4th, 2004"); + params.put(AlchemyLanguage.ANCHOR_DATE, "2013-12-16 20:06:18"); + + final Dates dates = service.getDates(params).execute(); + Assert.assertNotNull(dates); + Assert.assertNotNull(dates.getDates()); + Assert.assertFalse(dates.getDates().isEmpty()); + } + + /** + * Test get emotion from HTML. + */ + @Test + public void testGetEmotionHTML() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.HTML, htmlExample); + final DocumentEmotion emotion = service.getEmotion(params).execute(); + Assert.assertNotNull(emotion); + Assert.assertNotNull(emotion.getEmotion()); + } + + /** + * Test get emotion from text. + */ + @Test + public void testGetEmotionText() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.TEXT, htmlExample); + final DocumentEmotion emotion = service.getEmotion(params).execute(); + Assert.assertNotNull(emotion); + Assert.assertNotNull(emotion.getEmotion()); + } + + /** + * Test Get emotion from URL. + */ + @Test + public void testGetEmotionUrl() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.URL, "http://www.techcrunch.com/"); + final DocumentEmotion emotion = service.getEmotion(params).execute(); + Assert.assertNotNull(emotion); + Assert.assertNotNull(emotion.getEmotion()); + } + + /** + * Test get typed relations from HTML. + */ + @Test + @Ignore + public void testGetTypedRelationsHTML() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.HTML, htmlExample); + final TypedRelations typedRelations = service.getTypedRelations(params).execute(); + Assert.assertNotNull(typedRelations); + Assert.assertNotNull(typedRelations.getTypedRelations()); + } + + /** + * Test get typed relations from text. + */ + @Test public void testGetTypedRelationsText() { final Map params = new HashMap(); params.put(AlchemyLanguage.TEXT, "Leiming Qian lives in New York."); @@ -494,26 +490,28 @@ public void testGetTypedRelationsText() { List trs = typedRelations.getTypedRelations(); Assert.assertNotNull(trs); Assert.assertFalse(trs.isEmpty()); - trs.stream().forEach(tr -> Assert.assertNotNull(tr.getType())); - trs.stream().forEach(tr -> Assert.assertNotNull(tr.getEntities())); - trs.stream().forEach(tr -> Assert.assertFalse(tr.getEntities().isEmpty())); - trs.stream().forEach(tr -> tr.getEntities().stream().forEach(e -> { - Assert.assertNotNull(e.getId()); - Assert.assertNotNull(e.getText()); - Assert.assertNotNull(e.getType()); - })); - } - - /** - * Test Get typed relations from URL. - */ - @Test - @Ignore - public void testGetTypedRelationsUrl() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.URL, "http://www.techcrunch.com/"); - final TypedRelations typedRelations = service.getTypedRelations(params).execute(); - Assert.assertNotNull(typedRelations); - Assert.assertNotNull(typedRelations.getTypedRelations()); - } + for (TypedRelation tr : trs) { + Assert.assertNotNull(tr.getType()); + Assert.assertNotNull(tr.getEntities()); + Assert.assertFalse(tr.getEntities().isEmpty()); + for (TypedEntity e : tr.getEntities()) { + Assert.assertNotNull(e.getId()); + Assert.assertNotNull(e.getText()); + Assert.assertNotNull(e.getType()); + } + } + } + + /** + * Test Get typed relations from URL. + */ + @Test + @Ignore + public void testGetTypedRelationsUrl() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.URL, "http://www.techcrunch.com/"); + final TypedRelations typedRelations = service.getTypedRelations(params).execute(); + Assert.assertNotNull(typedRelations); + Assert.assertNotNull(typedRelations.getTypedRelations()); + } } From aad48a46e8a02a7f4c029c35d8f23e42d0e9be0f Mon Sep 17 00:00:00 2001 From: Denilson Nastacio Date: Sat, 2 Jul 2016 17:07:34 -0400 Subject: [PATCH 03/10] Fixing imports --- .../alchemy/v1/AlchemyLanguageIT.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) 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 6096f830add..29a71a7b887 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 @@ -13,6 +13,17 @@ */ package com.ibm.watson.developer_cloud.alchemy.v1; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; + import com.ibm.watson.developer_cloud.WatsonServiceTest; import com.ibm.watson.developer_cloud.alchemy.v1.model.CombinedResults; import com.ibm.watson.developer_cloud.alchemy.v1.model.Concepts; @@ -34,17 +45,6 @@ import com.ibm.watson.developer_cloud.alchemy.v1.model.TypedRelation; import com.ibm.watson.developer_cloud.alchemy.v1.model.TypedRelations; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; - -import java.io.FileInputStream; -import java.io.IOException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - /** * Created by nizar on 8/25/15. */ From cea17fe514740d4734fd36b681f7a52f607e57cb Mon Sep 17 00:00:00 2001 From: Denilson Nastacio Date: Sat, 2 Jul 2016 17:18:06 -0400 Subject: [PATCH 04/10] Fixing imports --- .../developer_cloud/alchemy/v1/model/TypedRelation.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/TypedRelation.java b/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/TypedRelation.java index 68aa0bef79d..3d39f4847bc 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/TypedRelation.java +++ b/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/TypedRelation.java @@ -14,12 +14,12 @@ package com.ibm.watson.developer_cloud.alchemy.v1.model; +import java.util.List; + import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; import com.ibm.watson.developer_cloud.alchemy.v1.AlchemyLanguage; -import java.util.List; - /** * Typed relation between {@link TypedEntity}. * @see AlchemyLanguage#getTypedRelations(java.util.Map) From 095a3ff1a6794bf3a9e9486f6412f3f87a21c661 Mon Sep 17 00:00:00 2001 From: Denilson Nastacio Date: Sat, 2 Jul 2016 17:23:44 -0400 Subject: [PATCH 05/10] Reverting formatting changes --- .../alchemy/v1/AlchemyLanguageIT.java | 925 +++++++++--------- 1 file changed, 465 insertions(+), 460 deletions(-) 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 29a71a7b887..223f4062294 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 @@ -50,468 +50,473 @@ */ public class AlchemyLanguageIT extends WatsonServiceTest { - /** The html example. */ - private String htmlExample; - - /** The service. */ - private AlchemyLanguage service; - - /* - * (non-Javadoc) - * - * @see com.ibm.watson.developer_cloud.WatsonServiceTest#setUp() - */ - @Override - @Before - 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")); - - } - - /** - * Test api key is null. - */ - @Test(expected = IllegalArgumentException.class) - public void testApiKeyIsNull() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.URL, "http://www.techcrunch.com/"); - - final AlchemyLanguage language = new AlchemyLanguage(); - language.setApiKey(null); - language.getKeywords(params).execute(); - } - - /** - * Test comboined. - */ - @Test - public void testComboined() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.URL, "http://www.techcrunch.com/"); - final CombinedResults combined = service.getCombinedResults(params).execute(); - Assert.assertNotNull(combined); - } - - /** - * Test Get testFeeds. - */ - @Test - public void testFeeds() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.URL, "http://www.techcrunch.com/"); - final Feeds feeds = service.getFeeds(params).execute(); - Assert.assertNotNull(feeds); - } - - /** - * Test Get testGetAuthor. - */ - @Test - public void testGetAuthors() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.URL, - "http://www.politico.com/blogs/media/2012/02/detroit-news-ed-upset-over-romney-edit-115247.html"); - final DocumentAuthors authors = service.getAuthors(params).execute(); - Assert.assertNotNull(authors); - } - - /** - * Test get concepts HTML. - */ - @Test - public void testGetConceptsHTML() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.HTML, htmlExample); - final Concepts concepts = service.getConcepts(params).execute(); - Assert.assertNotNull(concepts); - Assert.assertFalse(concepts.getConcepts().isEmpty()); - } - - /** - * Test get concepts Tet. - */ - @Test - public void testGetConceptsText() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.TEXT, htmlExample); - final Concepts concepts = service.getConcepts(params).execute(); - Assert.assertNotNull(concepts); - Assert.assertFalse(concepts.getConcepts().isEmpty()); - } - - /** - * Test Get getTaxonomy URL. - */ - @Test - public void testGetConceptsUrl() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.URL, "http://www.techcrunch.com/"); - final Concepts concepts = service.getConcepts(params).execute(); - Assert.assertNotNull(concepts); - Assert.assertFalse(concepts.getConcepts().isEmpty()); - } - - /** - * Test Get entities HTML. - */ - @Test - public void testGetEntitiesHtml() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.HTML, htmlExample); - - final Entities entities = service.getEntities(params).execute(); - Assert.assertNotNull(entities); - Assert.assertFalse(entities.getEntities().isEmpty()); - } - - /** - * Test Get entities URL. - */ - @Test - public void testGetEntitiesUrl() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.URL, "http://www.techcrunch.com/"); - final Entities entities = service.getEntities(params).execute(); - Assert.assertNotNull(entities); - Assert.assertFalse(entities.getEntities().isEmpty()); - } - - /** - * Test Get entities HTML. - */ - @Test - public void testGetEntitiesWithDifferentCharacters() { - final Map params = new HashMap(); - final String text = "Mr. Vice President, my old colleague from Massachusetts" - + "and your new Speaker & John McCormack, Members of the 87th Congress, " - + "ladies and gentlemen: -.*&^%$#@!@#$%^&*()"; - params.put(AlchemyLanguage.TEXT, text); - - final Entities entities = service.getEntities(params).execute(); - Assert.assertNotNull(entities); - Assert.assertFalse(entities.getEntities().isEmpty()); - } - - /** - * Test Get testGetLanguage. - */ - @Test - public void testGetLanguage() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.URL, "http://news.google.fr/"); - final Language language = service.getLanguage(params).execute(); - Assert.assertNotNull(language); - } - - /** - * Test get publication date html. - */ - @Test - public void testGetPublicationDateHTML() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.HTML, htmlExample); - final DocumentPublicationDate date = service.getPublicationDate(params).execute(); - Assert.assertNotNull(date); - Assert.assertNotNull(date.getPublicationDate()); - } - - /** - * Test get publication date url. - */ - @Test - public void testGetPublicationDateURL() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.URL, "http://www.techcrunch.com/"); - final DocumentPublicationDate date = service.getPublicationDate(params).execute(); - Assert.assertNotNull(date); - Assert.assertNotNull(date.getPublicationDate()); - } - - /** - * Test Get testGetRelationsHtml HTML. - * - */ - @Test - public void testGetRelationsHtml() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.HTML, htmlExample); - final SAORelations relations = service.getRelations(params).execute(); - Assert.assertNotNull(relations); - } - - /** - * Test Get testGetRelationsUrl URL. - */ - @Test - public void testGetRelationsUrl() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.URL, "http://www.techcrunch.com/"); - final SAORelations relations = service.getRelations(params).execute(); - Assert.assertNotNull(relations); - } - - /** - * Test Get testGetTargetedSentiment HTML. - */ - @Test - public void testGetTargetedSentimentHtml() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.HTML, htmlExample); - params.put(AlchemyLanguage.TARGET, "Watson"); - final DocumentSentiment documentSentiment = service.getSentiment(params).execute(); - Assert.assertNotNull(documentSentiment); - } - - /** - * Test Get testGetTargetedSentiment Url. - */ - @Test - public void testGetTargetedSentimentURL() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.URL, - "http://techcrunch.com/2012/03/01/keen-on-anand-rajaraman-how-walmart-wants-to-leapfrog-over-amazon-tctv/"); - params.put(AlchemyLanguage.TARGET, "Walmart"); - final DocumentSentiment documentSentiment = service.getSentiment(params).execute(); - Assert.assertNotNull(documentSentiment); - } - - /** - * Test Get testGetTargetedSentiment Url and multiple targets. - */ - @Test - public void testGetTargetedSentimentURLAndTargets() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.URL, - "http://techcrunch.com/2012/03/01/keen-on-anand-rajaraman-how-walmart-wants-to-leapfrog-over-amazon-tctv/"); - params.put(AlchemyLanguage.TARGETS, "Walmart|Walmart"); - final DocumentSentiment documentSentiment = service.getSentiment(params).execute(); - Assert.assertNotNull(documentSentiment); - } - - /** - * Test Get getTaxonomy HTML. - * - * @throws IOException - * Signals that an I/O exception has occurred. - */ - @Test - public void testGetTaxonomyHtml() throws IOException { - final Map params = new HashMap(); - params.put(AlchemyLanguage.HTML, htmlExample); - final Taxonomies taxonomy = service.getTaxonomy(params).execute(); - Assert.assertNotNull(taxonomy); - Assert.assertFalse(taxonomy.getTaxonomy().isEmpty()); - } - - /** - * Test Get getTaxonomy URL. - */ - @Test - public void testGetTaxonomyUrl() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.URL, "http://www.techcrunch.com/"); - final Taxonomies taxonomy = service.getTaxonomy(params).execute(); - Assert.assertNotNull(taxonomy); - Assert.assertFalse(taxonomy.getTaxonomy().isEmpty()); - } - - /** - * Test Get testGetTextSentiment HTML. - */ - @Test - public void testGetTextSentimentHtml() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.HTML, htmlExample); - final DocumentSentiment documentSentiment = service.getSentiment(params).execute(); - Assert.assertNotNull(documentSentiment); - } - - /** - * Test Get testGetTextSentiment URL. - */ - @Test - public void testGetTextSentimentUrl() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.URL, "http://www.techcrunch.com/"); - final DocumentSentiment documentSentiment = service.getSentiment(params).execute(); - Assert.assertNotNull(documentSentiment); - } - - /** - * Test Get testGetTitle. - */ - @Test - public void testGetTitle() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.URL, "http://www.techcrunch.com/"); - final DocumentTitle title = service.getTitle(params).execute(); - Assert.assertNotNull(title); - } - - /** - * Test Get keywords HTML. - * - */ - @Test - public void testGetWordsHtml() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.HTML, htmlExample); - - final Keywords keywords = service.getKeywords(params).execute(); - Assert.assertNotNull(keywords); - Assert.assertFalse(keywords.getKeywords().isEmpty()); - } - - /** - * Test Get keywords URL. - */ - @Test - public void testGetWordsUrl() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.URL, "http://www.techcrunch.com/"); - final Keywords keywords = service.getKeywords(params).execute(); - Assert.assertNotNull(keywords); - Assert.assertFalse(keywords.getKeywords().isEmpty()); - } - - /** - * Test microformats. - */ - @Test - public void testMicroformats() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.URL, "http://microformats.org/wiki/hcard"); - final Microformats microformats = service.getMicroformats(params).execute(); - Assert.assertNotNull(microformats); - } - - /** - * Test Get testGetRawText. - */ - @Test - public void testRawText() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.URL, "http://www.test.com/"); - params.put(AlchemyLanguage.RAW, true); - final DocumentText text = service.getText(params).execute(); - Assert.assertNotNull(text); - } - - /** - * Test Get testGetText. - */ - @Test - public void testText() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.URL, "http://www.techcrunch.com/"); - final DocumentText text = service.getText(params).execute(); - Assert.assertNotNull(text); - } - - /** - * Test get dates from a url. - */ - @Test - public void testGetDates() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.TEXT, "Let's meet on January 4th, 2004"); - params.put(AlchemyLanguage.ANCHOR_DATE, "2013-12-16 20:06:18"); - - final Dates dates = service.getDates(params).execute(); - Assert.assertNotNull(dates); - Assert.assertNotNull(dates.getDates()); - Assert.assertFalse(dates.getDates().isEmpty()); - } - - /** - * Test get emotion from HTML. - */ - @Test - public void testGetEmotionHTML() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.HTML, htmlExample); - final DocumentEmotion emotion = service.getEmotion(params).execute(); - Assert.assertNotNull(emotion); - Assert.assertNotNull(emotion.getEmotion()); - } - - /** - * Test get emotion from text. - */ - @Test - public void testGetEmotionText() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.TEXT, htmlExample); - final DocumentEmotion emotion = service.getEmotion(params).execute(); - Assert.assertNotNull(emotion); - Assert.assertNotNull(emotion.getEmotion()); - } - - /** - * Test Get emotion from URL. - */ - @Test - public void testGetEmotionUrl() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.URL, "http://www.techcrunch.com/"); - final DocumentEmotion emotion = service.getEmotion(params).execute(); - Assert.assertNotNull(emotion); - Assert.assertNotNull(emotion.getEmotion()); - } - - /** - * Test get typed relations from HTML. - */ - @Test - @Ignore - public void testGetTypedRelationsHTML() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.HTML, htmlExample); - final TypedRelations typedRelations = service.getTypedRelations(params).execute(); - Assert.assertNotNull(typedRelations); - Assert.assertNotNull(typedRelations.getTypedRelations()); - } - - /** - * Test get typed relations from text. - */ - @Test + /** The html example. */ + private String htmlExample; + + /** The service. */ + private AlchemyLanguage service; + + /* + * (non-Javadoc) + * + * @see com.ibm.watson.developer_cloud.WatsonServiceTest#setUp() + */ + @Override + @Before + 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")); + + } + + /** + * Test api key is null. + */ + @Test(expected = IllegalArgumentException.class) + public void testApiKeyIsNull() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.URL, "http://www.techcrunch.com/"); + + final AlchemyLanguage language = new AlchemyLanguage(); + language.setApiKey(null); + language.getKeywords(params).execute(); + } + + /** + * Test comboined. + */ + @Test + public void testComboined() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.URL, "http://www.techcrunch.com/"); + final CombinedResults combined = service.getCombinedResults(params).execute(); + Assert.assertNotNull(combined); + } + + /** + * Test Get testFeeds. + */ + @Test + public void testFeeds() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.URL, "http://www.techcrunch.com/"); + final Feeds feeds = service.getFeeds(params).execute(); + Assert.assertNotNull(feeds); + } + + /** + * Test Get testGetAuthor. + */ + @Test + public void testGetAuthors() { + final Map params = new HashMap(); + params + .put(AlchemyLanguage.URL, + "http://www.politico.com/blogs/media/2012/02/detroit-news-ed-upset-over-romney-edit-115247.html"); + final DocumentAuthors authors = service.getAuthors(params).execute(); + Assert.assertNotNull(authors); + } + + /** + * Test get concepts HTML. + */ + @Test + public void testGetConceptsHTML() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.HTML, htmlExample); + final Concepts concepts = service.getConcepts(params).execute(); + Assert.assertNotNull(concepts); + Assert.assertFalse(concepts.getConcepts().isEmpty()); + } + + /** + * Test get concepts Tet. + */ + @Test + public void testGetConceptsText() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.TEXT, htmlExample); + final Concepts concepts = service.getConcepts(params).execute(); + Assert.assertNotNull(concepts); + Assert.assertFalse(concepts.getConcepts().isEmpty()); + } + + /** + * Test Get getTaxonomy URL. + */ + @Test + public void testGetConceptsUrl() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.URL, "http://www.techcrunch.com/"); + final Concepts concepts = service.getConcepts(params).execute(); + Assert.assertNotNull(concepts); + Assert.assertFalse(concepts.getConcepts().isEmpty()); + } + + /** + * Test Get entities HTML. + */ + @Test + public void testGetEntitiesHtml() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.HTML, htmlExample); + + final Entities entities = service.getEntities(params).execute(); + Assert.assertNotNull(entities); + Assert.assertFalse(entities.getEntities().isEmpty()); + } + + /** + * Test Get entities URL. + */ + @Test + public void testGetEntitiesUrl() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.URL, "http://www.techcrunch.com/"); + final Entities entities = service.getEntities(params).execute(); + Assert.assertNotNull(entities); + Assert.assertFalse(entities.getEntities().isEmpty()); + } + + /** + * Test Get entities HTML. + */ + @Test + public void testGetEntitiesWithDifferentCharacters() { + final Map params = new HashMap(); + final String text = + "Mr. Vice President, my old colleague from Massachusetts" + + "and your new Speaker & John McCormack, Members of the 87th Congress, " + + "ladies and gentlemen: -.*&^%$#@!@#$%^&*()"; + params.put(AlchemyLanguage.TEXT, text); + + final Entities entities = service.getEntities(params).execute(); + Assert.assertNotNull(entities); + Assert.assertFalse(entities.getEntities().isEmpty()); + } + + /** + * Test Get testGetLanguage. + */ + @Test + public void testGetLanguage() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.URL, "http://news.google.fr/"); + final Language language = service.getLanguage(params).execute(); + Assert.assertNotNull(language); + } + + /** + * Test get publication date html. + */ + @Test + public void testGetPublicationDateHTML() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.HTML, htmlExample); + final DocumentPublicationDate date = service.getPublicationDate(params).execute(); + Assert.assertNotNull(date); + Assert.assertNotNull(date.getPublicationDate()); + } + + /** + * Test get publication date url. + */ + @Test + public void testGetPublicationDateURL() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.URL, "http://www.techcrunch.com/"); + final DocumentPublicationDate date = service.getPublicationDate(params).execute(); + Assert.assertNotNull(date); + Assert.assertNotNull(date.getPublicationDate()); + } + + /** + * Test Get testGetRelationsHtml HTML. + * + */ + @Test + public void testGetRelationsHtml() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.HTML, htmlExample); + final SAORelations relations = service.getRelations(params).execute(); + Assert.assertNotNull(relations); + } + + /** + * Test Get testGetRelationsUrl URL. + */ + @Test + public void testGetRelationsUrl() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.URL, "http://www.techcrunch.com/"); + final SAORelations relations = service.getRelations(params).execute(); + Assert.assertNotNull(relations); + } + + /** + * Test Get testGetTargetedSentiment HTML. + */ + @Test + public void testGetTargetedSentimentHtml() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.HTML, htmlExample); + params.put(AlchemyLanguage.TARGET, "Watson"); + final DocumentSentiment documentSentiment = service.getSentiment(params).execute(); + Assert.assertNotNull(documentSentiment); + } + + /** + * Test Get testGetTargetedSentiment Url. + */ + @Test + public void testGetTargetedSentimentURL() { + final Map params = new HashMap(); + params + .put( + AlchemyLanguage.URL, + "http://techcrunch.com/2012/03/01/keen-on-anand-rajaraman-how-walmart-wants-to-leapfrog-over-amazon-tctv/"); + params.put(AlchemyLanguage.TARGET, "Walmart"); + final DocumentSentiment documentSentiment = service.getSentiment(params).execute(); + Assert.assertNotNull(documentSentiment); + } + + /** + * Test Get testGetTargetedSentiment Url and multiple targets. + */ + @Test + public void testGetTargetedSentimentURLAndTargets() { + final Map params = new HashMap(); + params + .put( + AlchemyLanguage.URL, + "http://techcrunch.com/2012/03/01/keen-on-anand-rajaraman-how-walmart-wants-to-leapfrog-over-amazon-tctv/"); + params.put(AlchemyLanguage.TARGETS, "Walmart|Walmart"); + final DocumentSentiment documentSentiment = service.getSentiment(params).execute(); + Assert.assertNotNull(documentSentiment); + } + + /** + * Test Get getTaxonomy HTML. + * + * @throws IOException Signals that an I/O exception has occurred. + */ + @Test + public void testGetTaxonomyHtml() throws IOException { + final Map params = new HashMap(); + params.put(AlchemyLanguage.HTML, htmlExample); + final Taxonomies taxonomy = service.getTaxonomy(params).execute(); + Assert.assertNotNull(taxonomy); + Assert.assertFalse(taxonomy.getTaxonomy().isEmpty()); + } + + /** + * Test Get getTaxonomy URL. + */ + @Test + public void testGetTaxonomyUrl() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.URL, "http://www.techcrunch.com/"); + final Taxonomies taxonomy = service.getTaxonomy(params).execute(); + Assert.assertNotNull(taxonomy); + Assert.assertFalse(taxonomy.getTaxonomy().isEmpty()); + } + + /** + * Test Get testGetTextSentiment HTML. + */ + @Test + public void testGetTextSentimentHtml() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.HTML, htmlExample); + final DocumentSentiment documentSentiment = service.getSentiment(params).execute(); + Assert.assertNotNull(documentSentiment); + } + + /** + * Test Get testGetTextSentiment URL. + */ + @Test + public void testGetTextSentimentUrl() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.URL, "http://www.techcrunch.com/"); + final DocumentSentiment documentSentiment = service.getSentiment(params).execute(); + Assert.assertNotNull(documentSentiment); + } + + /** + * Test Get testGetTitle. + */ + @Test + public void testGetTitle() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.URL, "http://www.techcrunch.com/"); + final DocumentTitle title = service.getTitle(params).execute(); + Assert.assertNotNull(title); + } + + /** + * Test Get keywords HTML. + * + */ + @Test + public void testGetWordsHtml() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.HTML, htmlExample); + + final Keywords keywords = service.getKeywords(params).execute(); + Assert.assertNotNull(keywords); + Assert.assertFalse(keywords.getKeywords().isEmpty()); + } + + /** + * Test Get keywords URL. + */ + @Test + public void testGetWordsUrl() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.URL, "http://www.techcrunch.com/"); + final Keywords keywords = service.getKeywords(params).execute(); + Assert.assertNotNull(keywords); + Assert.assertFalse(keywords.getKeywords().isEmpty()); + } + + /** + * Test microformats. + */ + @Test + public void testMicroformats() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.URL, "http://microformats.org/wiki/hcard"); + final Microformats microformats = service.getMicroformats(params).execute(); + Assert.assertNotNull(microformats); + } + + /** + * Test Get testGetRawText. + */ + @Test + public void testRawText() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.URL, "http://www.test.com/"); + params.put(AlchemyLanguage.RAW, true); + final DocumentText text = service.getText(params).execute(); + Assert.assertNotNull(text); + } + + /** + * Test Get testGetText. + */ + @Test + public void testText() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.URL, "http://www.techcrunch.com/"); + final DocumentText text = service.getText(params).execute(); + Assert.assertNotNull(text); + } + + /** + * Test get dates from a url. + */ + @Test + public void testGetDates() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.TEXT, "Let's meet on January 4th, 2004"); + params.put(AlchemyLanguage.ANCHOR_DATE, "2013-12-16 20:06:18"); + + final Dates dates = service.getDates(params).execute(); + Assert.assertNotNull(dates); + Assert.assertNotNull(dates.getDates()); + Assert.assertFalse(dates.getDates().isEmpty()); + } + + /** + * Test get emotion from HTML. + */ + @Test + public void testGetEmotionHTML() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.HTML, htmlExample); + final DocumentEmotion emotion = service.getEmotion(params).execute(); + Assert.assertNotNull(emotion); + Assert.assertNotNull(emotion.getEmotion()); + } + + /** + * Test get emotion from text. + */ + @Test + public void testGetEmotionText() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.TEXT, htmlExample); + final DocumentEmotion emotion = service.getEmotion(params).execute(); + Assert.assertNotNull(emotion); + Assert.assertNotNull(emotion.getEmotion()); + } + + /** + * Test Get emotion from URL. + */ + @Test + public void testGetEmotionUrl() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.URL, "http://www.techcrunch.com/"); + final DocumentEmotion emotion = service.getEmotion(params).execute(); + Assert.assertNotNull(emotion); + Assert.assertNotNull(emotion.getEmotion()); + } + + /** + * Test get typed relations from HTML. + */ + @Test + @Ignore + public void testGetTypedRelationsHTML() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.HTML, htmlExample); + final TypedRelations typedRelations = service.getTypedRelations(params).execute(); + Assert.assertNotNull(typedRelations); + Assert.assertNotNull(typedRelations.getTypedRelations()); + } + + /** + * Test get typed relations from text. + */ + @Test public void testGetTypedRelationsText() { + final Map params = new HashMap(); + params.put(AlchemyLanguage.TEXT, "Leiming Qian lives in New York."); + params.put(AlchemyLanguage.MODEL_ID, "ie-en-news"); + final TypedRelations typedRelations = service.getTypedRelations(params).execute(); + Assert.assertNotNull(typedRelations); + List trs = typedRelations.getTypedRelations(); + Assert.assertNotNull(trs); + Assert.assertFalse(trs.isEmpty()); + for (TypedRelation tr : trs) { + Assert.assertNotNull(tr.getType()); + Assert.assertNotNull(tr.getEntities()); + Assert.assertFalse(tr.getEntities().isEmpty()); + for (TypedEntity e : tr.getEntities()) { + Assert.assertNotNull(e.getId()); + Assert.assertNotNull(e.getText()); + Assert.assertNotNull(e.getType()); + } + } + } + + /** + * Test Get typed relations from URL. + */ + @Test + @Ignore + public void testGetTypedRelationsUrl() { final Map params = new HashMap(); - params.put(AlchemyLanguage.TEXT, "Leiming Qian lives in New York."); - params.put(AlchemyLanguage.MODEL_ID, "ie-en-news"); + params.put(AlchemyLanguage.URL, "http://www.techcrunch.com/"); final TypedRelations typedRelations = service.getTypedRelations(params).execute(); Assert.assertNotNull(typedRelations); - List trs = typedRelations.getTypedRelations(); - Assert.assertNotNull(trs); - Assert.assertFalse(trs.isEmpty()); - for (TypedRelation tr : trs) { - Assert.assertNotNull(tr.getType()); - Assert.assertNotNull(tr.getEntities()); - Assert.assertFalse(tr.getEntities().isEmpty()); - for (TypedEntity e : tr.getEntities()) { - Assert.assertNotNull(e.getId()); - Assert.assertNotNull(e.getText()); - Assert.assertNotNull(e.getType()); - } - } - } - - /** - * Test Get typed relations from URL. - */ - @Test - @Ignore - public void testGetTypedRelationsUrl() { - final Map params = new HashMap(); - params.put(AlchemyLanguage.URL, "http://www.techcrunch.com/"); - final TypedRelations typedRelations = service.getTypedRelations(params).execute(); - Assert.assertNotNull(typedRelations); - Assert.assertNotNull(typedRelations.getTypedRelations()); - } + Assert.assertNotNull(typedRelations.getTypedRelations()); + } } From bc4479f8a3bd98359e49653f5b006ed8d96a2b86 Mon Sep 17 00:00:00 2001 From: Denilson Nastacio Date: Sat, 2 Jul 2016 17:34:04 -0400 Subject: [PATCH 06/10] Adding copyright/type comments. --- .../alchemy/v1/model/TypedEntitiesAdapter.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/TypedEntitiesAdapter.java b/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/TypedEntitiesAdapter.java index 6b086849453..985a11a12db 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/TypedEntitiesAdapter.java +++ b/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/TypedEntitiesAdapter.java @@ -1,3 +1,16 @@ +/** + * Copyright 2015 IBM Corp. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ package com.ibm.watson.developer_cloud.alchemy.v1.model; import com.google.gson.TypeAdapter; @@ -8,6 +21,9 @@ import java.util.ArrayList; import java.util.List; +/** + * Created by nastacio on 7/2/2016 + */ public class TypedEntitiesAdapter extends TypeAdapter> { @Override From 050c23db570a3b40a7dc4f0a897863bd1f983081 Mon Sep 17 00:00:00 2001 From: Denilson Nastacio Date: Sat, 2 Jul 2016 17:37:39 -0400 Subject: [PATCH 07/10] Adding more comments. --- .../developer_cloud/alchemy/v1/model/TypedEntitiesAdapter.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/TypedEntitiesAdapter.java b/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/TypedEntitiesAdapter.java index 985a11a12db..1e30b0ea422 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/TypedEntitiesAdapter.java +++ b/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/TypedEntitiesAdapter.java @@ -28,6 +28,8 @@ public class TypedEntitiesAdapter extends TypeAdapter> { @Override public void write(JsonWriter writer, List value) throws IOException { + // No coding the serialization as there is no code relying on this + // type to serialize payloads } @Override From 338bfa0de767f231d800c947e5c66d0f8e9185c5 Mon Sep 17 00:00:00 2001 From: German Attanasio Ruiz Date: Mon, 1 Aug 2016 12:52:40 -0400 Subject: [PATCH 08/10] :bug: add typed relations to AlchemyLanguage --- .../v1/AlchemyLanguageExample.java | 9 +- .../alchemy/v1/model/TypedArguments.java | 86 +++++++++++ .../v1/model/TypedEntitiesAdapter.java | 76 --------- .../alchemy/v1/model/TypedEntity.java | 45 +----- .../alchemy/v1/model/TypedRelation.java | 144 +++++++++--------- .../alchemy/v1/model/TypedRelations.java | 28 +++- .../alchemy/v1/AlchemyLanguageIT.java | 34 +++-- 7 files changed, 213 insertions(+), 209 deletions(-) create mode 100644 src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/TypedArguments.java delete mode 100644 src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/TypedEntitiesAdapter.java diff --git a/examples/java/com/ibm/watson/developer_cloud/alchemy_language/v1/AlchemyLanguageExample.java b/examples/java/com/ibm/watson/developer_cloud/alchemy_language/v1/AlchemyLanguageExample.java index 9011414f815..f0f218612c0 100644 --- a/examples/java/com/ibm/watson/developer_cloud/alchemy_language/v1/AlchemyLanguageExample.java +++ b/examples/java/com/ibm/watson/developer_cloud/alchemy_language/v1/AlchemyLanguageExample.java @@ -20,6 +20,7 @@ import com.ibm.watson.developer_cloud.alchemy.v1.AlchemyLanguage; import com.ibm.watson.developer_cloud.alchemy.v1.model.DocumentSentiment; import com.ibm.watson.developer_cloud.alchemy.v1.model.Entities; +import com.ibm.watson.developer_cloud.alchemy.v1.model.TypedRelations; public class AlchemyLanguageExample { @@ -31,12 +32,18 @@ public static void main(String[] args) { params.put(AlchemyLanguage.TEXT, "IBM Watson won the Jeopardy television show hosted by Alex Trebek"); + // get sentiment DocumentSentiment sentiment = service.getSentiment(params).execute(); System.out.println("Sentiment: " + sentiment); - + + // get entities Entities entities = service.getEntities(params).execute(); System.out.println("Entities: " + entities); + // get typed relations + TypedRelations relations = service.getTypedRelations(params).execute(); + System.out.println("Relations: " + relations); + } } diff --git a/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/TypedArguments.java b/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/TypedArguments.java new file mode 100644 index 00000000000..ad3b5bda1ba --- /dev/null +++ b/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/TypedArguments.java @@ -0,0 +1,86 @@ +/** + * Copyright 2015 IBM Corp. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ +package com.ibm.watson.developer_cloud.alchemy.v1.model; + +import java.util.List; + +import com.ibm.watson.developer_cloud.alchemy.v1.AlchemyLanguage; +import com.ibm.watson.developer_cloud.service.model.GenericModel; + +/** + * Argument of a typed relation. It includes the detected {@link TypedEntity}, text and part. + * + * @see AlchemyLanguage#getTypedRelations(java.util.Map) + */ +public class TypedArguments extends GenericModel { + + private String part; + private String text; + private List entities; + + /** + * Gets the entities. + * + * @return the entities + */ + public List getEntities() { + return entities; + } + + /** + * Sets the entities. + * + * @param entities the new entities + */ + public void setTypedEntities(List entities) { + this.entities = entities; + } + + /** + * Gets the part. + * + * @return the part + */ + public String getPart() { + return part; + } + + /** + * Sets the part. + * + * @param part the new part + */ + public void setPart(String part) { + this.part = part; + } + + /** + * Gets the text. + * + * @return the text + */ + public String getText() { + return text; + } + + /** + * Sets the text. + * + * @param text the new text + */ + public void setText(String text) { + this.text = text; + } + +} diff --git a/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/TypedEntitiesAdapter.java b/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/TypedEntitiesAdapter.java deleted file mode 100644 index 1e30b0ea422..00000000000 --- a/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/TypedEntitiesAdapter.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * Copyright 2015 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - */ -package com.ibm.watson.developer_cloud.alchemy.v1.model; - -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -/** - * Created by nastacio on 7/2/2016 - */ -public class TypedEntitiesAdapter extends TypeAdapter> { - - @Override - public void write(JsonWriter writer, List value) throws IOException { - // No coding the serialization as there is no code relying on this - // type to serialize payloads - } - - @Override - public List read(JsonReader reader) throws IOException { - List es = new ArrayList(); - - reader.beginArray(); // arguments - while (reader.hasNext()) { - reader.beginObject(); // argument - while (reader.hasNext()) { - String name = reader.nextName(); - if ("entities".equals(name)) { - reader.beginArray(); - while (reader.hasNext()) { - TypedEntity e = new TypedEntity(); - reader.beginObject(); - while (reader.hasNext()) { - String name1 = reader.nextName(); - if ("text".equals(name1)) { - e.setText(reader.nextString()); - } else if ("type".equals(name1)) { - e.setType(reader.nextString()); - } else if ("id".equals(name1)) { - e.setId(reader.nextString()); - } else { - reader.skipValue(); - } - } - reader.endObject(); - es.add(e); - } - reader.endArray(); - } else { - reader.skipValue(); - } - } - reader.endObject(); - } - reader.endArray(); - - return es; - } - -} diff --git a/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/TypedEntity.java b/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/TypedEntity.java index 54e17cd4a72..850ef38f748 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/TypedEntity.java +++ b/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/TypedEntity.java @@ -14,20 +14,17 @@ package com.ibm.watson.developer_cloud.alchemy.v1.model; -import com.google.gson.annotations.SerializedName; import com.ibm.watson.developer_cloud.alchemy.v1.AlchemyLanguage; +import com.ibm.watson.developer_cloud.service.model.GenericModel; /** * Recognized entity from {@link AlchemyLanguage#getTypedRelations(java.util.Map)} */ -public class TypedEntity { +public class TypedEntity extends GenericModel { + private String id; private String text; - private String mention; private String type; - @SerializedName("argNum") - private Integer argumentNumber; - private String id; /** * Gets the text. @@ -47,24 +44,6 @@ public void setText(String text) { this.text = text; } - /** - * Gets the mention. - * - * @return The mention - */ - public String getMention() { - return mention; - } - - /** - * Sets the mention. - * - * @param mention The mention - */ - public void setMention(String mention) { - this.mention = mention; - } - /** * Gets the type. * @@ -83,24 +62,6 @@ public void setType(String type) { this.type = type; } - /** - * Gets the argument number. - * - * @return The argument number - */ - public Integer getArgumentNumber() { - return argumentNumber; - } - - /** - * Sets the argument number. - * - * @param argumentNumber the new argument number - */ - public void setArgumentNumber(Integer argumentNumber) { - this.argumentNumber = argumentNumber; - } - /** * Gets the id. * diff --git a/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/TypedRelation.java b/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/TypedRelation.java index 3d39f4847bc..f782607bca6 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/TypedRelation.java +++ b/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/TypedRelation.java @@ -1,4 +1,4 @@ -/* +/** * Copyright 2015 IBM Corp. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except @@ -16,90 +16,92 @@ import java.util.List; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; import com.ibm.watson.developer_cloud.alchemy.v1.AlchemyLanguage; +import com.ibm.watson.developer_cloud.service.model.GenericModel; /** - * Typed relation between {@link TypedEntity}. + * Typed relation between {@link TypedArguments}. + * * @see AlchemyLanguage#getTypedRelations(java.util.Map) */ -public class TypedRelation { +public class TypedRelation extends GenericModel { - private String text; - private String type; - private Double score; + private String sentence; + private String type; + private Double score; - @JsonAdapter(TypedEntitiesAdapter.class) - @SerializedName("arguments") - private List entities; + private List arguments; - /** - * Gets the text. - * - * @return The text - */ - public String getText() { - return text; - } + /** + * Gets the type. + * + * @return The type + */ + public String getType() { + return type; + } - /** - * Sets the text. - * - * @param text The text - */ - public void setText(String text) { - this.text = text; - } + /** + * Sets the type. + * + * @param type The type + */ + public void setType(String type) { + this.type = type; + } - /** - * Gets the type. - * - * @return The type - */ - public String getType() { - return type; - } + /** + * Gets the score. + * + * @return The score + */ + public Double getScore() { + return score; + } - /** - * Sets the type. - * - * @param type The type - */ - public void setType(String type) { - this.type = type; - } + /** + * Sets the score. + * + * @param score The score + */ + public void setScore(Double score) { + this.score = score; + } - /** - * Gets the score. - * - * @return The score - */ - public Double getScore() { - return score; - } + /** + * Gets the sentence. + * + * @return the sentence + */ + public String getSentence() { + return sentence; + } - /** - * Sets the score. - * - * @param score The score - */ - public void setScore(Double score) { - this.score = score; - } + /** + * Sets the sentence. + * + * @param sentence the new sentence + */ + public void setSentence(String sentence) { + this.sentence = sentence; + } - /** - * @return the entities - */ - public List getEntities() { - return entities; - } + /** + * Gets the arguments. + * + * @return the arguments + */ + public List getArguments() { + return arguments; + } - /** - * @param entities the entities to set - */ - public void setEntities(List entities) { - this.entities = entities; - } + /** + * Sets the arguments. + * + * @param arguments the new arguments + */ + public void setArguments(List arguments) { + this.arguments = arguments; + } } diff --git a/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/TypedRelations.java b/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/TypedRelations.java index 8426f8b2230..4969c88707a 100644 --- a/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/TypedRelations.java +++ b/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/TypedRelations.java @@ -1,4 +1,4 @@ -/* +/** * Copyright 2015 IBM Corp. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except @@ -20,10 +20,30 @@ /** * Typed relation between {@link TypedEntity}. + * * @see AlchemyLanguage#getTypedRelations(java.util.Map) */ -public class TypedRelations extends AlchemyLanguageGenericModel{ +public class TypedRelations extends AlchemyLanguageGenericModel { + private String model; + + /** + * Gets the model. + * + * @return the model + */ + public String getModel() { + return model; + } + + /** + * Sets the model. + * + * @param model the new model + */ + public void setModel(String model) { + this.model = model; + } /** The typedRelations. */ private List typedRelations; @@ -45,6 +65,6 @@ public List getTypedRelations() { public void setTypedRelations(List typedRelations) { this.typedRelations = typedRelations; } - - + + } 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 223f4062294..1df062564a0 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 @@ -41,19 +41,17 @@ import com.ibm.watson.developer_cloud.alchemy.v1.model.Microformats; import com.ibm.watson.developer_cloud.alchemy.v1.model.SAORelations; import com.ibm.watson.developer_cloud.alchemy.v1.model.Taxonomies; +import com.ibm.watson.developer_cloud.alchemy.v1.model.TypedArguments; import com.ibm.watson.developer_cloud.alchemy.v1.model.TypedEntity; import com.ibm.watson.developer_cloud.alchemy.v1.model.TypedRelation; import com.ibm.watson.developer_cloud.alchemy.v1.model.TypedRelations; /** - * Created by nizar on 8/25/15. + * Alchemy Language Integration tests */ public class AlchemyLanguageIT extends WatsonServiceTest { - /** The html example. */ private String htmlExample; - - /** The service. */ private AlchemyLanguage service; /* @@ -492,17 +490,23 @@ public void testGetTypedRelationsText() { params.put(AlchemyLanguage.MODEL_ID, "ie-en-news"); final TypedRelations typedRelations = service.getTypedRelations(params).execute(); Assert.assertNotNull(typedRelations); - List trs = typedRelations.getTypedRelations(); - Assert.assertNotNull(trs); - Assert.assertFalse(trs.isEmpty()); - for (TypedRelation tr : trs) { - Assert.assertNotNull(tr.getType()); - Assert.assertNotNull(tr.getEntities()); - Assert.assertFalse(tr.getEntities().isEmpty()); - for (TypedEntity e : tr.getEntities()) { - Assert.assertNotNull(e.getId()); - Assert.assertNotNull(e.getText()); - Assert.assertNotNull(e.getType()); + List relations = typedRelations.getTypedRelations(); + Assert.assertNotNull(relations); + Assert.assertFalse(relations.isEmpty()); + for (TypedRelation relation : relations) { + Assert.assertNotNull(relation.getType()); + Assert.assertNotNull(relation.getSentence()); + Assert.assertNotNull(relation.getArguments()); + Assert.assertFalse(relation.getArguments().isEmpty()); + for (TypedArguments arg : relation.getArguments()) { + Assert.assertNotNull(arg.getPart()); + Assert.assertNotNull(arg.getText()); + Assert.assertNotNull(arg.getEntities()); + for (TypedEntity e : arg.getEntities()) { + Assert.assertNotNull(e.getId()); + Assert.assertNotNull(e.getText()); + Assert.assertNotNull(e.getType()); + } } } } From 96a084662be9fda4898032f60540817e8dbf5559 Mon Sep 17 00:00:00 2001 From: German Attanasio Ruiz Date: Mon, 1 Aug 2016 13:02:13 -0400 Subject: [PATCH 09/10] [ci skip] :unamused: code formatting and organize imports --- .../alchemy/v1/model/Article.java | 23 +++++++++++++++---- .../alchemy/v1/model/ImageKeyword.java | 2 +- .../alchemy/v1/model/Taxonomy.java | 1 - .../v2/PersonalityInsightsIT.java | 1 - 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/Article.java b/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/Article.java index 2697225d3a0..ab680983164 100755 --- a/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/Article.java +++ b/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/Article.java @@ -37,7 +37,7 @@ public static class EnrichedTitle extends GenericModel { private Sentiment sentiment; private List taxonomy; - + /** * Gets the concepts. * @@ -64,6 +64,7 @@ public List getEntities() { public List getKeywords() { return keywords; } + /** * Gets the relations. * @@ -72,7 +73,7 @@ public List getKeywords() { public List getRelations() { return relations; } - + /** * Gets the sentiment. * @@ -200,6 +201,7 @@ public List getConcepts() { public EnrichedTitle getEnrichedTitle() { return enrichedTitle; } + /** * Gets the entities. * @@ -208,6 +210,7 @@ public EnrichedTitle getEnrichedTitle() { public List getEntities() { return entities; } + /** * Gets the feeds. * @@ -216,6 +219,7 @@ public List getEntities() { public List getFeeds() { return feeds; } + /** * Gets the image. * @@ -224,6 +228,7 @@ public List getFeeds() { public String getImage() { return image; } + /** * Gets the image keywords. * @@ -232,6 +237,7 @@ public String getImage() { public List getImageKeywords() { return imageKeywords; } + /** * Gets the keywords. * @@ -240,6 +246,7 @@ public List getImageKeywords() { public List getKeywords() { return keywords; } + /** * Gets the language. * @@ -248,6 +255,7 @@ public List getKeywords() { public String getLanguage() { return language; } + /** * Gets the publication date. * @@ -256,6 +264,7 @@ public String getLanguage() { public PublicationDate getPublicationDate() { return publicationDate; } + /** * Gets the relations. * @@ -264,6 +273,7 @@ public PublicationDate getPublicationDate() { public List getRelations() { return relations; } + /** * Gets the sentiment. * @@ -272,6 +282,7 @@ public List getRelations() { public Sentiment getSentiment() { return sentiment; } + /** * Gets the taxonomy. * @@ -280,6 +291,7 @@ public Sentiment getSentiment() { public List getTaxonomy() { return taxonomy; } + /** * Gets the text. * @@ -288,6 +300,7 @@ public List getTaxonomy() { public String getText() { return text; } + /** * Gets the title. * @@ -296,6 +309,7 @@ public String getText() { public String getTitle() { return title; } + /** * Gets the url. * @@ -304,6 +318,7 @@ public String getTitle() { public String getUrl() { return url; } + /** * Sets the author. * @@ -322,7 +337,7 @@ public void setCleanedTitle(String cleanedTitle) { this.cleanedTitle = cleanedTitle; } - + /** * Sets the concepts. * @@ -349,7 +364,7 @@ public void setEnrichedTitle(EnrichedTitle enrichedTitle) { public void setEntities(List entities) { this.entities = entities; } - + /** * Sets the feeds. * diff --git a/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/ImageKeyword.java b/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/ImageKeyword.java index d0e743e24c5..448d3a80d1d 100755 --- a/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/ImageKeyword.java +++ b/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/ImageKeyword.java @@ -65,7 +65,7 @@ public String getText() { * @param hierarchy The hierarchy. */ public void setHierarchy(String hierarchy) { - if(knowledgeGraph == null) { + if (knowledgeGraph == null) { knowledgeGraph = new KnowledgeGraph(); } diff --git a/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/Taxonomy.java b/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/Taxonomy.java index 3cf5a6ea28c..8d4a902ebd6 100755 --- a/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/Taxonomy.java +++ b/src/main/java/com/ibm/watson/developer_cloud/alchemy/v1/model/Taxonomy.java @@ -14,7 +14,6 @@ package com.ibm.watson.developer_cloud.alchemy.v1.model; import com.google.gson.annotations.JsonAdapter; - import com.ibm.watson.developer_cloud.service.model.GenericModel; import com.ibm.watson.developer_cloud.util.BooleanToStringTypeAdapter; 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 77c164c264b..5e2e4e19d5f 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 @@ -17,7 +17,6 @@ import java.io.File; import java.io.FileInputStream; -import java.util.Arrays; import java.util.Collections; import java.util.Date; From 9839d6c5f533a9461fa5d504e62d440168ba4d8f Mon Sep 17 00:00:00 2001 From: German Attanasio Ruiz Date: Mon, 1 Aug 2016 14:04:43 -0400 Subject: [PATCH 10/10] :green_heart: ignore deprecated tests and update travis credentials --- .config.properties.enc | Bin 3984 -> 3984 bytes .../alchemy/v1/AlchemyVisionIT.java | 2 +- .../v2/ConceptInsightsIT.java | 2 ++ .../ConversationServiceIT.java | 2 ++ .../v1/RetrieveAndRankIT.java | 9 ++++++++- .../tone_analyzer/v3_beta/ToneAnalyzerIT.java | 4 +++- 6 files changed, 16 insertions(+), 3 deletions(-) diff --git a/.config.properties.enc b/.config.properties.enc index e1674470ae098d60688cb08235acb22722ea4b0d..af005d956a18e87f4861baab30e7a9d910e6c86e 100644 GIT binary patch literal 3984 zcmV;B4{z`fvZc&Bsc*wun63JB#m|Oug+r~J7myy+ML=|u;Fu~)Um%xxbXr@a982{A zFKHeU0bpvlJheOX-ev!Bb6uhn$1-a5x}KCP|33LJ-e4~1!CKY9i|YrBSj5T9&$PPB$-9P0Q7rm(h_TC znCch3>fH)W@H9MqBxD(yyomqQy$MW0j3?A4wcsRr(CLxm-ti9J7f>}OvY+5ExFA-} zSDe=6nq{Iey!Yp!6pln}4}P$xe$(nq7J|!3=@O%9vl8i8AFf>8#I5c#XemrBnduF4 z0QeSzMg^iC-BqjeaU`ID83lxj3!Mo4*0&k|KS(M#9p4kR;)v|{3H_EI zpGW0wL1F$%Ua}}sm%Dk4iXXRTjc+{U>$rc%)M~GKO^At@;Q8<1v%m=wQ38 zBpPVM@TTu>XhhYH&KwN)SB;a9d~{ViH`^28d=x%Xbo2NKLo-?t!QbQ`F1R<@rOw<# zaPYU6N$@pa|C$B~>4|Xk>(bPUWIFU968|%)2$mrj1y}N3!Pk<`r~%$clazI$h`y&! z&d>On?^?Oz)cKojnFsn--zkT=-|teKf_yb;9t&ON!0Og z-gVK=;f6PJ+}($CW)LaxiJaziN$5;P7`l51+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o>kEps+sM5V!Pm`RDQ86- zS{}QvwEUz9s4am;Jn1}resXxz6p0Cpk9o;Y)FJ%Lq=S{o`dUy#9?u9@aMCmhbN%Hi zqPC)m>?kD;JY_FYZ84m=kjpx{Ly@Ca*6ne52NTk1a3vjkQUX2=ozqPH(W$EddNX(q+K5< za)aUKk%{rFycQbb zyX1onZmXD(T)On(=0nW5yIVu#SCvW*+?2a5L-Fk)+vSI`h$)`|@HRnNuCH8x*B=Ee z!X3|yYt5vvla{K?lw@2?#thm+nDB}p=eYl``|MySjIFAWjE-37mIPI~cO)8+ofhPe zh!D|)b*j$UdkTxugV7n;Pp||5gS2ZuJoGzr3R6SRTl4n!e5i~BG$HjkwYb|(Zi^ue zyW&BLR?E6g<(oOaAO?n-bFRU!R!N|zj06nI=cE64hHX?T>1K{h%#&5xXvZhF_>bWl zeoCv;PGpe)V7#Xk!tmx2bCbS~QWhRl52+`OhtV$4FksSYW}|fDBpxy$*uD+uL!e(< zVG1-&CP>W8NHnz8Doc=NG6zg~ZCyC$BP-ll7}zD78CSC)VnZxI%~@Utz}}9n?@DGF zVAh`)ues@lYqqSKkgD;e!N5U_)6>iy1MX$n1T7hIeo#A#@?a1np&@f!R{!vaV<^as z+@;7weZm(%k&cI)%9CS31p7;d-hbi#P|oT}DW-}EwXyQ!>oH;s0$fZK>mviq}uFsy<;d!A)!wMl-bw=A&%{0=t^CZ_W qujI1c)Lv4%!vYjw>Ym_ZO~cN*M2)R=Q@A=T$RpvA&VO&mBAybTnaMT) 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 9a4447ff03d..0838921ae54 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 @@ -38,7 +38,7 @@ public class AlchemyVisionIT extends WatsonServiceTest { private static final String IMAGE_OBAMA = "src/test/resources/alchemy/obama.jpg"; private static final String IMAGE_COLORADO = "src/test/resources/alchemy/colorado.jpg"; - private static final String IMAGE_COLORADO_URL = "http://vision.alchemy.ai/img/demo/1754836.jpg"; + private static final String IMAGE_COLORADO_URL = "https://raw.githubusercontent.com/watson-developer-cloud/doc-tutorial-downloads/master/visual-recognition/colorado.jpg"; private static final String BABY_IMAGE = "https://visual-recognition-demo.mybluemix.net/images/samples/1.jpg"; 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 4ef960e66ad..ce1cfcba848 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 @@ -21,6 +21,7 @@ import org.junit.Assert; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; import com.ibm.watson.developer_cloud.WatsonServiceTest; @@ -53,6 +54,7 @@ /** * The Class ConceptInsightsTest. */ +@Ignore public class ConceptInsightsIT extends WatsonServiceTest { /** The Constant PUBLIC. */ diff --git a/src/test/java/com/ibm/watson/developer_cloud/conversation/v1_experimental/ConversationServiceIT.java b/src/test/java/com/ibm/watson/developer_cloud/conversation/v1_experimental/ConversationServiceIT.java index b7847064841..9be20b178bf 100644 --- a/src/test/java/com/ibm/watson/developer_cloud/conversation/v1_experimental/ConversationServiceIT.java +++ b/src/test/java/com/ibm/watson/developer_cloud/conversation/v1_experimental/ConversationServiceIT.java @@ -18,6 +18,7 @@ import java.util.Map; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; import com.ibm.watson.developer_cloud.WatsonServiceTest; @@ -27,6 +28,7 @@ /** * Integration test for the {@link ConversationService}. */ +@Ignore public class ConversationServiceIT extends WatsonServiceTest { private ConversationService service; 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 653dd5fd8cd..bbacc41b015 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 @@ -13,7 +13,11 @@ */ package com.ibm.watson.developer_cloud.retrieve_and_rank.v1; -import static org.junit.Assert.*; +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 java.io.File; import java.io.FileInputStream; @@ -81,6 +85,7 @@ public void setUp() throws Exception { /** * Test delete all rankers. */ + @Ignore @Test public void testDeleteAllRankers() { List rankers = service.getRankers().execute().getRankers(); @@ -208,6 +213,7 @@ public void testGetRankerStatus() { * Test get solr cluster. */ @Test + @Ignore public void testGetSolrCluster() { final SolrCluster cluster = service.getSolrCluster(clusterId).execute(); assertNotNull(cluster); @@ -323,6 +329,7 @@ public void testUploadAndDeleteSolrClusterConfigurationZip() { * @throws InterruptedException */ @Test + @Ignore public void testSolrClusterResize() throws InterruptedException { SolrClusterSizeResponse resizeRequestResponse = service.resizeSolrCluster(clusterId, 2).execute(); diff --git a/src/test/java/com/ibm/watson/developer_cloud/tone_analyzer/v3_beta/ToneAnalyzerIT.java b/src/test/java/com/ibm/watson/developer_cloud/tone_analyzer/v3_beta/ToneAnalyzerIT.java index 5bf3b57641c..4b1d51a2e80 100644 --- a/src/test/java/com/ibm/watson/developer_cloud/tone_analyzer/v3_beta/ToneAnalyzerIT.java +++ b/src/test/java/com/ibm/watson/developer_cloud/tone_analyzer/v3_beta/ToneAnalyzerIT.java @@ -15,14 +15,16 @@ import org.junit.Assert; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; import com.ibm.watson.developer_cloud.WatsonServiceTest; import com.ibm.watson.developer_cloud.tone_analyzer.v3_beta.model.ToneAnalysis; /** - * Tone Analyzer Integration tests. + * Tone Analyzer v3 Beta Integration tests. */ +@Ignore public class ToneAnalyzerIT extends WatsonServiceTest { /** The service. */