@@ -178,6 +178,30 @@ public void createJavaDocComment_throwsAndDeprecated() {
178
178
assertEquals (expected , javaDocComment .comment ());
179
179
}
180
180
181
+ @ Test
182
+ public void createJavaDocComment_paramsAndReturn () {
183
+ // No matter how many times or order `setThrows` and `setDeprecated` are called,
184
+ // only one @throws and @deprecated will be printed.
185
+ String paramName1 = "shelfName" ;
186
+ String paramDescription1 = "The name of the shelf where books are published to." ;
187
+ String paramName2 = "shelf" ;
188
+ String paramDescription2 = "The shelf to create." ;
189
+ String returnText = "This is the method return text." ;
190
+
191
+ JavaDocComment javaDocComment =
192
+ JavaDocComment .builder ()
193
+ .addParam (paramName1 , paramDescription1 )
194
+ .addParam (paramName2 , paramDescription2 )
195
+ .setReturn (returnText )
196
+ .build ();
197
+ String expected =
198
+ LineFormatter .lines (
199
+ "@param shelfName The name of the shelf where books are published to.\n " ,
200
+ "@param shelf The shelf to create.\n " ,
201
+ "@return This is the method return text." );
202
+ assertEquals (expected , javaDocComment .comment ());
203
+ }
204
+
181
205
@ Test
182
206
public void createJavaDocComment_allComponents () {
183
207
// No matter what order `setThrows`, `setDeprecated` are called,
@@ -190,6 +214,7 @@ public void createJavaDocComment_allComponents() {
190
214
String paramDescription1 = "The name of the shelf where books are published to." ;
191
215
String paramName2 = "shelf" ;
192
216
String paramDescription2 = "The shelf to create." ;
217
+ String returnText = "This is the method return text." ;
193
218
String paragraph1 =
194
219
"This class provides the ability to make remote calls to the backing service through"
195
220
+ " method calls that map to API methods. Sample code to get started:" ;
@@ -210,6 +235,7 @@ public void createJavaDocComment_allComponents() {
210
235
.addParagraph (paragraph2 )
211
236
.addOrderedList (orderedList )
212
237
.addParam (paramName2 , paramDescription2 )
238
+ .setReturn (returnText )
213
239
.build ();
214
240
String expected =
215
241
LineFormatter .lines (
@@ -225,6 +251,7 @@ public void createJavaDocComment_allComponents() {
225
251
"</ol>\n " ,
226
252
"@param shelfName The name of the shelf where books are published to.\n " ,
227
253
"@param shelf The shelf to create.\n " ,
254
+ "@return This is the method return text.\n " ,
228
255
"@throws com.google.api.gax.rpc.ApiException if the remote call fails.\n " ,
229
256
"@deprecated Use the {@link ArchivedBookName} class instead." );
230
257
assertEquals (expected , javaDocComment .comment ());
0 commit comments