Skip to content

Commit d69fd96

Browse files
committed
Add XML put tests
1 parent 659bdea commit d69fd96

8 files changed

Lines changed: 314 additions & 18 deletions

File tree

test/swagger/xml-service.json

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,34 @@
3737
}
3838
}
3939
}
40+
},
41+
"put": {
42+
"operationId": "xml_putSimple",
43+
"description": "Put a simple XML document",
44+
"tags": [
45+
"XML Operations"
46+
],
47+
"parameters": [
48+
{
49+
"name": "wrappedLists",
50+
"in": "body",
51+
"schema": {
52+
"$ref": "#/definitions/Slideshow"
53+
},
54+
"required": true
55+
}
56+
],
57+
"responses": {
58+
"201": {
59+
"description": "Indicates success"
60+
},
61+
"default": {
62+
"description": "Unexpected error",
63+
"schema": {
64+
"$ref": "#/definitions/Error"
65+
}
66+
}
67+
}
4068
}
4169
},
4270
"/xml/wrapped-lists": {
@@ -54,6 +82,34 @@
5482
}
5583
}
5684
}
85+
},
86+
"put": {
87+
"operationId": "xml_putWrappedLists",
88+
"description": "Put an XML document with multiple wrapped lists",
89+
"tags": [
90+
"XML Operations"
91+
],
92+
"parameters": [
93+
{
94+
"name": "wrappedLists",
95+
"in": "body",
96+
"schema": {
97+
"$ref": "#/definitions/AppleBarrel"
98+
},
99+
"required": true
100+
}
101+
],
102+
"responses": {
103+
"201": {
104+
"description": "Indicates success"
105+
},
106+
"default": {
107+
"description": "Unexpected error",
108+
"schema": {
109+
"$ref": "#/definitions/Error"
110+
}
111+
}
112+
}
57113
}
58114
},
59115
"/xml/headers": {
@@ -116,6 +172,9 @@
116172
"Slideshow": {
117173
"type": "object",
118174
"description": "Data about a slideshow",
175+
"xml": {
176+
"name": "slideshow"
177+
},
119178
"properties": {
120179
"title": {
121180
"type": "string",

test/xml/src/main/java/fixtures/xml/Xmls.java

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,44 @@ public interface Xmls {
5858
*/
5959
Maybe<Slideshow> getSimpleAsync();
6060

61+
/**
62+
* Put a simple XML document.
63+
*
64+
* @param wrappedLists the Slideshow value.
65+
* @throws IllegalArgumentException thrown if parameters fail the validation.
66+
* @throws ErrorException thrown if the request is rejected by server.
67+
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
68+
*/
69+
void putSimple(@NonNull Slideshow wrappedLists);
70+
71+
/**
72+
* Put a simple XML document.
73+
*
74+
* @param wrappedLists the Slideshow value.
75+
* @param serviceCallback the async ServiceCallback to handle successful and failed responses.
76+
* @throws IllegalArgumentException thrown if parameters fail the validation.
77+
* @return the {@link ServiceFuture&lt;Void&gt;} object.
78+
*/
79+
ServiceFuture<Void> putSimpleAsync(@NonNull Slideshow wrappedLists, @NonNull ServiceCallback<Void> serviceCallback);
80+
81+
/**
82+
* Put a simple XML document.
83+
*
84+
* @param wrappedLists the Slideshow value.
85+
* @throws IllegalArgumentException thrown if parameters fail the validation.
86+
* @return the {@link Single&lt;RestResponse&lt;Void, Void&gt;&gt;} object if successful.
87+
*/
88+
Single<RestResponse<Void, Void>> putSimpleWithRestResponseAsync(@NonNull Slideshow wrappedLists);
89+
90+
/**
91+
* Put a simple XML document.
92+
*
93+
* @param wrappedLists the Slideshow value.
94+
* @throws IllegalArgumentException thrown if parameters fail the validation.
95+
* @return the {@link Completable} object if successful.
96+
*/
97+
Completable putSimpleAsync(@NonNull Slideshow wrappedLists);
98+
6199
/**
62100
* Get an XML document with multiple wrapped lists.
63101
*
@@ -89,6 +127,44 @@ public interface Xmls {
89127
*/
90128
Maybe<AppleBarrel> getWrappedListsAsync();
91129

130+
/**
131+
* Put an XML document with multiple wrapped lists.
132+
*
133+
* @param wrappedLists the AppleBarrel value.
134+
* @throws IllegalArgumentException thrown if parameters fail the validation.
135+
* @throws ErrorException thrown if the request is rejected by server.
136+
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
137+
*/
138+
void putWrappedLists(@NonNull AppleBarrel wrappedLists);
139+
140+
/**
141+
* Put an XML document with multiple wrapped lists.
142+
*
143+
* @param wrappedLists the AppleBarrel value.
144+
* @param serviceCallback the async ServiceCallback to handle successful and failed responses.
145+
* @throws IllegalArgumentException thrown if parameters fail the validation.
146+
* @return the {@link ServiceFuture&lt;Void&gt;} object.
147+
*/
148+
ServiceFuture<Void> putWrappedListsAsync(@NonNull AppleBarrel wrappedLists, @NonNull ServiceCallback<Void> serviceCallback);
149+
150+
/**
151+
* Put an XML document with multiple wrapped lists.
152+
*
153+
* @param wrappedLists the AppleBarrel value.
154+
* @throws IllegalArgumentException thrown if parameters fail the validation.
155+
* @return the {@link Single&lt;RestResponse&lt;Void, Void&gt;&gt;} object if successful.
156+
*/
157+
Single<RestResponse<Void, Void>> putWrappedListsWithRestResponseAsync(@NonNull AppleBarrel wrappedLists);
158+
159+
/**
160+
* Put an XML document with multiple wrapped lists.
161+
*
162+
* @param wrappedLists the AppleBarrel value.
163+
* @throws IllegalArgumentException thrown if parameters fail the validation.
164+
* @return the {@link Completable} object if successful.
165+
*/
166+
Completable putWrappedListsAsync(@NonNull AppleBarrel wrappedLists);
167+
92168
/**
93169
* Get strongly-typed response headers.
94170
*

test/xml/src/main/java/fixtures/xml/implementation/XmlsImpl.java

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@
1414
import com.microsoft.rest.v2.RestResponse;
1515
import com.microsoft.rest.v2.ServiceCallback;
1616
import com.microsoft.rest.v2.ServiceFuture;
17+
import com.microsoft.rest.v2.Validator;
18+
import com.microsoft.rest.v2.annotations.BodyParam;
1719
import com.microsoft.rest.v2.annotations.ExpectedResponses;
1820
import com.microsoft.rest.v2.annotations.GET;
1921
import com.microsoft.rest.v2.annotations.Host;
22+
import com.microsoft.rest.v2.annotations.PUT;
2023
import com.microsoft.rest.v2.annotations.UnexpectedResponseExceptionType;
2124
import fixtures.xml.Xmls;
2225
import fixtures.xml.models.AppleBarrel;
@@ -65,10 +68,20 @@ private interface XmlsService {
6568
@UnexpectedResponseExceptionType(ErrorException.class)
6669
Single<RestResponse<Void, Slideshow>> getSimple();
6770

71+
@PUT("xml/simple")
72+
@ExpectedResponses({201})
73+
@UnexpectedResponseExceptionType(ErrorException.class)
74+
Single<RestResponse<Void, Void>> putSimple(@BodyParam("application/xml; charset=utf-8") Slideshow wrappedLists);
75+
6876
@GET("xml/wrapped-lists")
6977
@ExpectedResponses({200})
7078
Single<RestResponse<Void, AppleBarrel>> getWrappedLists();
7179

80+
@PUT("xml/wrapped-lists")
81+
@ExpectedResponses({201})
82+
@UnexpectedResponseExceptionType(ErrorException.class)
83+
Single<RestResponse<Void, Void>> putWrappedLists(@BodyParam("application/xml; charset=utf-8") AppleBarrel wrappedLists);
84+
7285
@GET("xml/headers")
7386
@ExpectedResponses({200})
7487
Single<RestResponse<XmlGetHeadersHeaders, Void>> getHeaders();
@@ -123,6 +136,57 @@ public Maybe<Slideshow> apply(RestResponse<Void, Slideshow> restResponse) {
123136
});
124137
}
125138

139+
/**
140+
* Put a simple XML document.
141+
*
142+
* @param wrappedLists the Slideshow value.
143+
* @throws IllegalArgumentException thrown if parameters fail the validation.
144+
* @throws ErrorException thrown if the request is rejected by server.
145+
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
146+
*/
147+
public void putSimple(@NonNull Slideshow wrappedLists) {
148+
putSimpleAsync(wrappedLists).blockingAwait();
149+
}
150+
151+
/**
152+
* Put a simple XML document.
153+
*
154+
* @param wrappedLists the Slideshow value.
155+
* @param serviceCallback the async ServiceCallback to handle successful and failed responses.
156+
* @throws IllegalArgumentException thrown if parameters fail the validation.
157+
* @return the {@link ServiceFuture&lt;Void&gt;} object.
158+
*/
159+
public ServiceFuture<Void> putSimpleAsync(@NonNull Slideshow wrappedLists, @NonNull ServiceCallback<Void> serviceCallback) {
160+
return ServiceFuture.fromBody(putSimpleAsync(wrappedLists), serviceCallback);
161+
}
162+
163+
/**
164+
* Put a simple XML document.
165+
*
166+
* @param wrappedLists the Slideshow value.
167+
* @throws IllegalArgumentException thrown if parameters fail the validation.
168+
* @return the {@link Single&lt;RestResponse&lt;Void, Void&gt;&gt;} object if successful.
169+
*/
170+
public Single<RestResponse<Void, Void>> putSimpleWithRestResponseAsync(@NonNull Slideshow wrappedLists) {
171+
if (wrappedLists == null) {
172+
throw new IllegalArgumentException("Parameter wrappedLists is required and cannot be null.");
173+
}
174+
Validator.validate(wrappedLists);
175+
return service.putSimple(wrappedLists);
176+
}
177+
178+
/**
179+
* Put a simple XML document.
180+
*
181+
* @param wrappedLists the Slideshow value.
182+
* @throws IllegalArgumentException thrown if parameters fail the validation.
183+
* @return the {@link Completable} object if successful.
184+
*/
185+
public Completable putSimpleAsync(@NonNull Slideshow wrappedLists) {
186+
return putSimpleWithRestResponseAsync(wrappedLists)
187+
.toCompletable();
188+
}
189+
126190
/**
127191
* Get an XML document with multiple wrapped lists.
128192
*
@@ -171,6 +235,57 @@ public Maybe<AppleBarrel> apply(RestResponse<Void, AppleBarrel> restResponse) {
171235
});
172236
}
173237

238+
/**
239+
* Put an XML document with multiple wrapped lists.
240+
*
241+
* @param wrappedLists the AppleBarrel value.
242+
* @throws IllegalArgumentException thrown if parameters fail the validation.
243+
* @throws ErrorException thrown if the request is rejected by server.
244+
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
245+
*/
246+
public void putWrappedLists(@NonNull AppleBarrel wrappedLists) {
247+
putWrappedListsAsync(wrappedLists).blockingAwait();
248+
}
249+
250+
/**
251+
* Put an XML document with multiple wrapped lists.
252+
*
253+
* @param wrappedLists the AppleBarrel value.
254+
* @param serviceCallback the async ServiceCallback to handle successful and failed responses.
255+
* @throws IllegalArgumentException thrown if parameters fail the validation.
256+
* @return the {@link ServiceFuture&lt;Void&gt;} object.
257+
*/
258+
public ServiceFuture<Void> putWrappedListsAsync(@NonNull AppleBarrel wrappedLists, @NonNull ServiceCallback<Void> serviceCallback) {
259+
return ServiceFuture.fromBody(putWrappedListsAsync(wrappedLists), serviceCallback);
260+
}
261+
262+
/**
263+
* Put an XML document with multiple wrapped lists.
264+
*
265+
* @param wrappedLists the AppleBarrel value.
266+
* @throws IllegalArgumentException thrown if parameters fail the validation.
267+
* @return the {@link Single&lt;RestResponse&lt;Void, Void&gt;&gt;} object if successful.
268+
*/
269+
public Single<RestResponse<Void, Void>> putWrappedListsWithRestResponseAsync(@NonNull AppleBarrel wrappedLists) {
270+
if (wrappedLists == null) {
271+
throw new IllegalArgumentException("Parameter wrappedLists is required and cannot be null.");
272+
}
273+
Validator.validate(wrappedLists);
274+
return service.putWrappedLists(wrappedLists);
275+
}
276+
277+
/**
278+
* Put an XML document with multiple wrapped lists.
279+
*
280+
* @param wrappedLists the AppleBarrel value.
281+
* @throws IllegalArgumentException thrown if parameters fail the validation.
282+
* @return the {@link Completable} object if successful.
283+
*/
284+
public Completable putWrappedListsAsync(@NonNull AppleBarrel wrappedLists) {
285+
return putWrappedListsWithRestResponseAsync(wrappedLists)
286+
.toCompletable();
287+
}
288+
174289
/**
175290
* Get strongly-typed response headers.
176291
*

test/xml/src/main/java/fixtures/xml/models/Slideshow.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
/**
2020
* Data about a slideshow.
2121
*/
22-
@JacksonXmlRootElement(localName = "Slideshow")
22+
@JacksonXmlRootElement(localName = "slideshow")
2323
public final class Slideshow {
2424
/**
2525
* The title property.

0 commit comments

Comments
 (0)