Skip to content

Commit d3bcce7

Browse files
committed
Merge pull request #27 from watson-developer-cloud/dev
Mock API test cases
2 parents 7478d8c + a3c7f70 commit d3bcce7

File tree

28 files changed

+2404
-74
lines changed

28 files changed

+2404
-74
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Watson Developer Cloud Java Wrapper
22
[![Build Status](https://secure.travis-ci.org/watson-developer-cloud/java-wrapper.png)](http://travis-ci.org/watson-developer-cloud/java-wrapper)
3-
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.ibm.watson.developer_cloud/java-wrapper/badge.svg)](https://maven-badges.herokuapp.com/maven-central/cz.jirutka.rsql/rsql-parser)
3+
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.ibm.watson.developer_cloud/java-wrapper/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.ibm.watson.developer_cloud/java-wrapper)
44
[![Coverage Status](https://coveralls.io/repos/watson-developer-cloud/java-wrapper/badge.svg?branch=master&service=github)](https://coveralls.io/github/watson-developer-cloud/java-wrapper?branch=master)
55

66
Java code wrappers to quickly get started with the various [Watson Developer Cloud][wdc] services - A collection of REST APIs and SDKs that use cognitive computing to solve complex problems.

pom.xml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,6 @@
2828
<version>2.3.1</version>
2929
<scope>compile</scope>
3030
</dependency>
31-
<dependency>
32-
<groupId>org.mockito</groupId>
33-
<artifactId>mockito-core</artifactId>
34-
<version>1.10.19</version>
35-
<scope>test</scope>
36-
</dependency>
3731
<dependency>
3832
<groupId>org.apache.httpcomponents</groupId>
3933
<artifactId>httpclient</artifactId>
@@ -46,6 +40,13 @@
4640
<version>4.11</version>
4741
<scope>test</scope>
4842
</dependency>
43+
<!-- mockserver -->
44+
<dependency>
45+
<groupId>org.mock-server</groupId>
46+
<artifactId>mockserver-netty</artifactId>
47+
<version>3.9.17</version>
48+
<scope>test</scope>
49+
</dependency>
4950
</dependencies>
5051
<developers>
5152
<developer>

src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/model/Classification.java

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,37 @@ public List<ClassifiedClass> getClasses() {
140140
return classes;
141141
}
142142

143+
144+
@Override
145+
public boolean equals(Object o) {
146+
if (this == o) return true;
147+
if (o == null || getClass() != o.getClass()) return false;
148+
149+
Classification that = (Classification) o;
150+
151+
if (!id.equals(that.id)) return false;
152+
if (url != null ? !url.equals(that.url) : that.url != null) return false;
153+
if (text != null ? !text.equals(that.text) : that.text != null) return false;
154+
if (topClass != null ? !topClass.equals(that.topClass) : that.topClass != null) return false;
155+
return !(classes != null ? !classes.equals(that.classes) : that.classes != null);
156+
157+
}
158+
159+
@Override
160+
public int hashCode() {
161+
int result = id.hashCode();
162+
result = 31 * result + (url != null ? url.hashCode() : 0);
163+
result = 31 * result + (text != null ? text.hashCode() : 0);
164+
result = 31 * result + (topClass != null ? topClass.hashCode() : 0);
165+
result = 31 * result + (classes != null ? classes.hashCode() : 0);
166+
return result;
167+
}
168+
143169
/*
144-
* (non-Javadoc)
145-
*
146-
* @see java.lang.Object#toString()
147-
*/
170+
* (non-Javadoc)
171+
*
172+
* @see java.lang.Object#toString()
173+
*/
148174
@Override
149175
public String toString() {
150176
return getClass().getName() + " "

src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/model/ClassifiedClass.java

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,33 @@ public void setConfidence(double confidence) {
7272
this.confidence = confidence;
7373
}
7474

75+
@Override
76+
public boolean equals(Object o) {
77+
if (this == o) return true;
78+
if (o == null || getClass() != o.getClass()) return false;
79+
80+
ClassifiedClass that = (ClassifiedClass) o;
81+
82+
if (Double.compare(that.confidence, confidence) != 0) return false;
83+
return name.equals(that.name);
84+
85+
}
86+
87+
@Override
88+
public int hashCode() {
89+
int result;
90+
long temp;
91+
result = name.hashCode();
92+
temp = Double.doubleToLongBits(confidence);
93+
result = 31 * result + (int) (temp ^ (temp >>> 32));
94+
return result;
95+
}
96+
7597
/*
76-
* (non-Javadoc)
77-
*
78-
* @see java.lang.Object#toString()
79-
*/
98+
* (non-Javadoc)
99+
*
100+
* @see java.lang.Object#toString()
101+
*/
80102
@Override
81103
public String toString() {
82104
return getClass().getName() + " "

src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/model/Classifier.java

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,34 @@ public void setStatusDescription(String statusDescription) {
142142
this.statusDescription = statusDescription;
143143
}
144144

145+
@Override
146+
public boolean equals(Object o) {
147+
if (this == o) return true;
148+
if (o == null || getClass() != o.getClass()) return false;
149+
150+
Classifier that = (Classifier) o;
151+
152+
if (!id.equals(that.id)) return false;
153+
if (url != null ? !url.equals(that.url) : that.url != null) return false;
154+
if (status != that.status) return false;
155+
return !(statusDescription != null ? !statusDescription.equals(that.statusDescription) : that.statusDescription != null);
156+
157+
}
158+
159+
@Override
160+
public int hashCode() {
161+
int result = id.hashCode();
162+
result = 31 * result + (url != null ? url.hashCode() : 0);
163+
result = 31 * result + (status != null ? status.hashCode() : 0);
164+
result = 31 * result + (statusDescription != null ? statusDescription.hashCode() : 0);
165+
return result;
166+
}
167+
145168
/*
146-
* (non-Javadoc)
147-
*
148-
* @see java.lang.Object#toString()
149-
*/
169+
* (non-Javadoc)
170+
*
171+
* @see java.lang.Object#toString()
172+
*/
150173
@Override
151174
public String toString() {
152175
return getClass().getName() + " "

src/main/java/com/ibm/watson/developer_cloud/personality_insights/v2/model/Profile.java

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,39 @@ public void setWordCount(int wordCount) {
160160
this.wordCount = wordCount;
161161
}
162162

163+
@Override
164+
public boolean equals(Object o) {
165+
if (this == o) return true;
166+
if (o == null || getClass() != o.getClass()) return false;
167+
168+
Profile profile = (Profile) o;
169+
170+
if (wordCount != profile.wordCount) return false;
171+
if (!id.equals(profile.id)) return false;
172+
if (source != null ? !source.equals(profile.source) : profile.source != null) return false;
173+
if (tree != null ? !tree.equals(profile.tree) : profile.tree != null) return false;
174+
if (wordCountMessage != null ? !wordCountMessage.equals(profile.wordCountMessage) : profile.wordCountMessage != null)
175+
return false;
176+
return !(processedLanguage != null ? !processedLanguage.equals(profile.processedLanguage) : profile.processedLanguage != null);
177+
178+
}
179+
180+
@Override
181+
public int hashCode() {
182+
int result = id.hashCode();
183+
result = 31 * result + (source != null ? source.hashCode() : 0);
184+
result = 31 * result + (tree != null ? tree.hashCode() : 0);
185+
result = 31 * result + wordCount;
186+
result = 31 * result + (wordCountMessage != null ? wordCountMessage.hashCode() : 0);
187+
result = 31 * result + (processedLanguage != null ? processedLanguage.hashCode() : 0);
188+
return result;
189+
}
190+
163191
/*
164-
* (non-Javadoc)
165-
*
166-
* @see java.lang.Object#toString()
167-
*/
192+
* (non-Javadoc)
193+
*
194+
* @see java.lang.Object#toString()
195+
*/
168196
@Override
169197
public String toString() {
170198
return getClass().getName() + " "

src/main/java/com/ibm/watson/developer_cloud/personality_insights/v2/model/Trait.java

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,45 @@ public void setSamplingError(double samplingError) {
211211
this.samplingError = samplingError;
212212
}
213213

214+
@Override
215+
public boolean equals(Object o) {
216+
if (this == o) return true;
217+
if (o == null || getClass() != o.getClass()) return false;
218+
219+
Trait trait = (Trait) o;
220+
221+
if (Double.compare(trait.percentage, percentage) != 0) return false;
222+
if (Double.compare(trait.samplingError, samplingError) != 0) return false;
223+
if (category != null ? !category.equals(trait.category) : trait.category != null) return false;
224+
if (children != null ? !children.equals(trait.children) : trait.children != null) return false;
225+
if (!id.equals(trait.id)) return false;
226+
if (name != null ? !name.equals(trait.name) : trait.name != null) return false;
227+
if (rawSamplingError != null ? !rawSamplingError.equals(trait.rawSamplingError) : trait.rawSamplingError != null)
228+
return false;
229+
return !(rawScore != null ? !rawScore.equals(trait.rawScore) : trait.rawScore != null);
230+
231+
}
232+
233+
@Override
234+
public int hashCode() {
235+
int result;
236+
long temp;
237+
result = category != null ? category.hashCode() : 0;
238+
result = 31 * result + (children != null ? children.hashCode() : 0);
239+
result = 31 * result + id.hashCode();
240+
result = 31 * result + (name != null ? name.hashCode() : 0);
241+
temp = Double.doubleToLongBits(percentage);
242+
result = 31 * result + (int) (temp ^ (temp >>> 32));
243+
result = 31 * result + (rawSamplingError != null ? rawSamplingError.hashCode() : 0);
244+
result = 31 * result + (rawScore != null ? rawScore.hashCode() : 0);
245+
temp = Double.doubleToLongBits(samplingError);
246+
result = 31 * result + (int) (temp ^ (temp >>> 32));
247+
return result;
248+
}
249+
214250
/* (non-Javadoc)
215-
* @see java.lang.Object#toString()
216-
*/
251+
* @see java.lang.Object#toString()
252+
*/
217253
@Override
218254
public String toString() {
219255
return getClass().getName() + " "

src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/SpeechAlternative.java

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,27 @@ public SpeechAlternative withTranscript(final String transcript) {
5757
return this;
5858
}
5959

60+
@Override
61+
public boolean equals(Object o) {
62+
if (this == o) return true;
63+
if (o == null || getClass() != o.getClass()) return false;
64+
65+
SpeechAlternative that = (SpeechAlternative) o;
66+
67+
return transcript.equals(that.transcript);
68+
69+
}
70+
71+
@Override
72+
public int hashCode() {
73+
return transcript.hashCode();
74+
}
75+
6076
/*
61-
* (non-Javadoc)
62-
*
63-
* @see java.lang.Object#toString()
64-
*/
77+
* (non-Javadoc)
78+
*
79+
* @see java.lang.Object#toString()
80+
*/
6581
@Override
6682
public String toString() {
6783
return getClass().getName() + " "

src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/SpeechModel.java

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,32 @@ public void setSessions(final String sessions) {
139139
this.sessions = sessions;
140140
}
141141

142+
@Override
143+
public boolean equals(Object o) {
144+
if (this == o) return true;
145+
if (o == null || getClass() != o.getClass()) return false;
146+
147+
SpeechModel that = (SpeechModel) o;
148+
149+
if (rate != that.rate) return false;
150+
if (name != null ? !name.equals(that.name) : that.name != null) return false;
151+
return !(sessions != null ? !sessions.equals(that.sessions) : that.sessions != null);
152+
153+
}
154+
155+
@Override
156+
public int hashCode() {
157+
int result = name != null ? name.hashCode() : 0;
158+
result = 31 * result + rate;
159+
result = 31 * result + (sessions != null ? sessions.hashCode() : 0);
160+
return result;
161+
}
162+
142163
/*
143-
* (non-Javadoc)
144-
*
145-
* @see java.lang.Object#toString()
146-
*/
164+
* (non-Javadoc)
165+
*
166+
* @see java.lang.Object#toString()
167+
*/
147168
@Override
148169
public String toString() {
149170
return getClass().getName() + " "

src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/SpeechModelSet.java

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,27 @@ public SpeechModelSet withModels(final List<SpeechModel> models) {
6262
return this;
6363
}
6464

65+
@Override
66+
public boolean equals(Object o) {
67+
if (this == o) return true;
68+
if (o == null || getClass() != o.getClass()) return false;
69+
70+
SpeechModelSet that = (SpeechModelSet) o;
71+
72+
return !(models != null ? !models.equals(that.models) : that.models != null);
73+
74+
}
75+
76+
@Override
77+
public int hashCode() {
78+
return models != null ? models.hashCode() : 0;
79+
}
80+
6581
/*
66-
* (non-Javadoc)
67-
*
68-
* @see java.lang.Object#toString()
69-
*/
82+
* (non-Javadoc)
83+
*
84+
* @see java.lang.Object#toString()
85+
*/
7086
@Override
7187
public String toString() {
7288
return getClass().getName() + " "

0 commit comments

Comments
 (0)