Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(390)

Side by Side Diff: generated/googleapis/test/runtimeconfig/v1_test.dart

Issue 3006323002: Api-Roll 54: 2017-09-11 (Closed)
Patch Set: use 2.0.0-dev.infinity sdk constraint in pubspecs Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 library googleapis.runtimeconfig.v1.test; 1 library googleapis.runtimeconfig.v1.test;
2 2
3 import "dart:core" as core; 3 import "dart:core" as core;
4 import "dart:collection" as collection;
5 import "dart:async" as async; 4 import "dart:async" as async;
6 import "dart:convert" as convert; 5 import "dart:convert" as convert;
7 6
8 import 'package:http/http.dart' as http; 7 import 'package:http/http.dart' as http;
9 import 'package:http/testing.dart' as http_testing;
10 import 'package:test/test.dart' as unittest; 8 import 'package:test/test.dart' as unittest;
11 9
12 import 'package:googleapis/runtimeconfig/v1.dart' as api; 10 import 'package:googleapis/runtimeconfig/v1.dart' as api;
13 11
14 class HttpServerMock extends http.BaseClient { 12 class HttpServerMock extends http.BaseClient {
15 core.Function _callback; 13 core.Function _callback;
16 core.bool _expectJson; 14 core.bool _expectJson;
17 15
18 void register(core.Function callback, core.bool expectJson) { 16 void register(core.Function callback, core.bool expectJson) {
19 _callback = callback; 17 _callback = callback;
20 _expectJson = expectJson; 18 _expectJson = expectJson;
21 } 19 }
22 20
23 async.Future<http.StreamedResponse> send(http.BaseRequest request) { 21 async.Future<http.StreamedResponse> send(http.BaseRequest request) {
24 if (_expectJson) { 22 if (_expectJson) {
25 return request.finalize() 23 return request
24 .finalize()
26 .transform(convert.UTF8.decoder) 25 .transform(convert.UTF8.decoder)
27 .join('') 26 .join('')
28 .then((core.String jsonString) { 27 .then((core.String jsonString) {
29 if (jsonString.isEmpty) { 28 if (jsonString.isEmpty) {
30 return _callback(request, null); 29 return _callback(request, null);
31 } else { 30 } else {
32 return _callback(request, convert.JSON.decode(jsonString)); 31 return _callback(request, convert.JSON.decode(jsonString));
33 } 32 }
34 }); 33 });
35 } else { 34 } else {
36 var stream = request.finalize(); 35 var stream = request.finalize();
37 if (stream == null) { 36 if (stream == null) {
38 return _callback(request, []); 37 return _callback(request, []);
39 } else { 38 } else {
40 return stream.toBytes().then((data) { 39 return stream.toBytes().then((data) {
41 return _callback(request, data); 40 return _callback(request, data);
42 }); 41 });
43 } 42 }
44 } 43 }
45 } 44 }
46 } 45 }
47 46
48 http.StreamedResponse stringResponse( 47 http.StreamedResponse stringResponse(core.int status,
49 core.int status, core.Map<core.String, core.String> headers, core.String bod y) { 48 core.Map<core.String, core.String> headers, core.String body) {
50 var stream = new async.Stream.fromIterable([convert.UTF8.encode(body)]); 49 var stream = new async.Stream.fromIterable([convert.UTF8.encode(body)]);
51 return new http.StreamedResponse(stream, status, headers: headers); 50 return new http.StreamedResponse(stream, status, headers: headers);
52 } 51 }
53 52
54 core.int buildCounterCancelOperationRequest = 0; 53 core.int buildCounterCancelOperationRequest = 0;
55 buildCancelOperationRequest() { 54 buildCancelOperationRequest() {
56 var o = new api.CancelOperationRequest(); 55 var o = new api.CancelOperationRequest();
57 buildCounterCancelOperationRequest++; 56 buildCounterCancelOperationRequest++;
58 if (buildCounterCancelOperationRequest < 3) { 57 if (buildCounterCancelOperationRequest < 3) {}
59 }
60 buildCounterCancelOperationRequest--; 58 buildCounterCancelOperationRequest--;
61 return o; 59 return o;
62 } 60 }
63 61
64 checkCancelOperationRequest(api.CancelOperationRequest o) { 62 checkCancelOperationRequest(api.CancelOperationRequest o) {
65 buildCounterCancelOperationRequest++; 63 buildCounterCancelOperationRequest++;
66 if (buildCounterCancelOperationRequest < 3) { 64 if (buildCounterCancelOperationRequest < 3) {}
67 }
68 buildCounterCancelOperationRequest--; 65 buildCounterCancelOperationRequest--;
69 } 66 }
70 67
71 core.int buildCounterEmpty = 0; 68 core.int buildCounterEmpty = 0;
72 buildEmpty() { 69 buildEmpty() {
73 var o = new api.Empty(); 70 var o = new api.Empty();
74 buildCounterEmpty++; 71 buildCounterEmpty++;
75 if (buildCounterEmpty < 3) { 72 if (buildCounterEmpty < 3) {}
76 }
77 buildCounterEmpty--; 73 buildCounterEmpty--;
78 return o; 74 return o;
79 } 75 }
80 76
81 checkEmpty(api.Empty o) { 77 checkEmpty(api.Empty o) {
82 buildCounterEmpty++; 78 buildCounterEmpty++;
83 if (buildCounterEmpty < 3) { 79 if (buildCounterEmpty < 3) {}
84 }
85 buildCounterEmpty--; 80 buildCounterEmpty--;
86 } 81 }
87 82
88 buildUnnamed1946() { 83 buildUnnamed1944() {
89 var o = new core.List<api.Operation>(); 84 var o = new core.List<api.Operation>();
90 o.add(buildOperation()); 85 o.add(buildOperation());
91 o.add(buildOperation()); 86 o.add(buildOperation());
92 return o; 87 return o;
93 } 88 }
94 89
95 checkUnnamed1946(core.List<api.Operation> o) { 90 checkUnnamed1944(core.List<api.Operation> o) {
96 unittest.expect(o, unittest.hasLength(2)); 91 unittest.expect(o, unittest.hasLength(2));
97 checkOperation(o[0]); 92 checkOperation(o[0]);
98 checkOperation(o[1]); 93 checkOperation(o[1]);
99 } 94 }
100 95
101 core.int buildCounterListOperationsResponse = 0; 96 core.int buildCounterListOperationsResponse = 0;
102 buildListOperationsResponse() { 97 buildListOperationsResponse() {
103 var o = new api.ListOperationsResponse(); 98 var o = new api.ListOperationsResponse();
104 buildCounterListOperationsResponse++; 99 buildCounterListOperationsResponse++;
105 if (buildCounterListOperationsResponse < 3) { 100 if (buildCounterListOperationsResponse < 3) {
106 o.nextPageToken = "foo"; 101 o.nextPageToken = "foo";
107 o.operations = buildUnnamed1946(); 102 o.operations = buildUnnamed1944();
108 } 103 }
109 buildCounterListOperationsResponse--; 104 buildCounterListOperationsResponse--;
110 return o; 105 return o;
111 } 106 }
112 107
113 checkListOperationsResponse(api.ListOperationsResponse o) { 108 checkListOperationsResponse(api.ListOperationsResponse o) {
114 buildCounterListOperationsResponse++; 109 buildCounterListOperationsResponse++;
115 if (buildCounterListOperationsResponse < 3) { 110 if (buildCounterListOperationsResponse < 3) {
116 unittest.expect(o.nextPageToken, unittest.equals('foo')); 111 unittest.expect(o.nextPageToken, unittest.equals('foo'));
117 checkUnnamed1946(o.operations); 112 checkUnnamed1944(o.operations);
118 } 113 }
119 buildCounterListOperationsResponse--; 114 buildCounterListOperationsResponse--;
120 } 115 }
121 116
122 buildUnnamed1947() { 117 buildUnnamed1945() {
123 var o = new core.Map<core.String, core.Object>(); 118 var o = new core.Map<core.String, core.Object>();
124 o["x"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; 119 o["x"] = {
125 o["y"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; 120 'list': [1, 2, 3],
121 'bool': true,
122 'string': 'foo'
123 };
124 o["y"] = {
125 'list': [1, 2, 3],
126 'bool': true,
127 'string': 'foo'
128 };
126 return o; 129 return o;
127 } 130 }
128 131
129 checkUnnamed1947(core.Map<core.String, core.Object> o) { 132 checkUnnamed1945(core.Map<core.String, core.Object> o) {
130 unittest.expect(o, unittest.hasLength(2)); 133 unittest.expect(o, unittest.hasLength(2));
131 var casted1 = (o["x"]) as core.Map; unittest.expect(casted1, unittest.hasLengt h(3)); unittest.expect(casted1["list"], unittest.equals([1, 2, 3])); unittest.ex pect(casted1["bool"], unittest.equals(true)); unittest.expect(casted1["string"], unittest.equals('foo')); 134 var casted1 = (o["x"]) as core.Map;
132 var casted2 = (o["y"]) as core.Map; unittest.expect(casted2, unittest.hasLengt h(3)); unittest.expect(casted2["list"], unittest.equals([1, 2, 3])); unittest.ex pect(casted2["bool"], unittest.equals(true)); unittest.expect(casted2["string"], unittest.equals('foo')); 135 unittest.expect(casted1, unittest.hasLength(3));
136 unittest.expect(casted1["list"], unittest.equals([1, 2, 3]));
137 unittest.expect(casted1["bool"], unittest.equals(true));
138 unittest.expect(casted1["string"], unittest.equals('foo'));
139 var casted2 = (o["y"]) as core.Map;
140 unittest.expect(casted2, unittest.hasLength(3));
141 unittest.expect(casted2["list"], unittest.equals([1, 2, 3]));
142 unittest.expect(casted2["bool"], unittest.equals(true));
143 unittest.expect(casted2["string"], unittest.equals('foo'));
133 } 144 }
134 145
135 buildUnnamed1948() { 146 buildUnnamed1946() {
136 var o = new core.Map<core.String, core.Object>(); 147 var o = new core.Map<core.String, core.Object>();
137 o["x"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; 148 o["x"] = {
138 o["y"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; 149 'list': [1, 2, 3],
150 'bool': true,
151 'string': 'foo'
152 };
153 o["y"] = {
154 'list': [1, 2, 3],
155 'bool': true,
156 'string': 'foo'
157 };
139 return o; 158 return o;
140 } 159 }
141 160
142 checkUnnamed1948(core.Map<core.String, core.Object> o) { 161 checkUnnamed1946(core.Map<core.String, core.Object> o) {
143 unittest.expect(o, unittest.hasLength(2)); 162 unittest.expect(o, unittest.hasLength(2));
144 var casted3 = (o["x"]) as core.Map; unittest.expect(casted3, unittest.hasLengt h(3)); unittest.expect(casted3["list"], unittest.equals([1, 2, 3])); unittest.ex pect(casted3["bool"], unittest.equals(true)); unittest.expect(casted3["string"], unittest.equals('foo')); 163 var casted3 = (o["x"]) as core.Map;
145 var casted4 = (o["y"]) as core.Map; unittest.expect(casted4, unittest.hasLengt h(3)); unittest.expect(casted4["list"], unittest.equals([1, 2, 3])); unittest.ex pect(casted4["bool"], unittest.equals(true)); unittest.expect(casted4["string"], unittest.equals('foo')); 164 unittest.expect(casted3, unittest.hasLength(3));
165 unittest.expect(casted3["list"], unittest.equals([1, 2, 3]));
166 unittest.expect(casted3["bool"], unittest.equals(true));
167 unittest.expect(casted3["string"], unittest.equals('foo'));
168 var casted4 = (o["y"]) as core.Map;
169 unittest.expect(casted4, unittest.hasLength(3));
170 unittest.expect(casted4["list"], unittest.equals([1, 2, 3]));
171 unittest.expect(casted4["bool"], unittest.equals(true));
172 unittest.expect(casted4["string"], unittest.equals('foo'));
146 } 173 }
147 174
148 core.int buildCounterOperation = 0; 175 core.int buildCounterOperation = 0;
149 buildOperation() { 176 buildOperation() {
150 var o = new api.Operation(); 177 var o = new api.Operation();
151 buildCounterOperation++; 178 buildCounterOperation++;
152 if (buildCounterOperation < 3) { 179 if (buildCounterOperation < 3) {
153 o.done = true; 180 o.done = true;
154 o.error = buildStatus(); 181 o.error = buildStatus();
155 o.metadata = buildUnnamed1947(); 182 o.metadata = buildUnnamed1945();
156 o.name = "foo"; 183 o.name = "foo";
157 o.response = buildUnnamed1948(); 184 o.response = buildUnnamed1946();
158 } 185 }
159 buildCounterOperation--; 186 buildCounterOperation--;
160 return o; 187 return o;
161 } 188 }
162 189
163 checkOperation(api.Operation o) { 190 checkOperation(api.Operation o) {
164 buildCounterOperation++; 191 buildCounterOperation++;
165 if (buildCounterOperation < 3) { 192 if (buildCounterOperation < 3) {
166 unittest.expect(o.done, unittest.isTrue); 193 unittest.expect(o.done, unittest.isTrue);
167 checkStatus(o.error); 194 checkStatus(o.error);
168 checkUnnamed1947(o.metadata); 195 checkUnnamed1945(o.metadata);
169 unittest.expect(o.name, unittest.equals('foo')); 196 unittest.expect(o.name, unittest.equals('foo'));
170 checkUnnamed1948(o.response); 197 checkUnnamed1946(o.response);
171 } 198 }
172 buildCounterOperation--; 199 buildCounterOperation--;
173 } 200 }
174 201
175 buildUnnamed1949() { 202 buildUnnamed1947() {
176 var o = new core.Map<core.String, core.Object>(); 203 var o = new core.Map<core.String, core.Object>();
177 o["x"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; 204 o["x"] = {
178 o["y"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; 205 'list': [1, 2, 3],
206 'bool': true,
207 'string': 'foo'
208 };
209 o["y"] = {
210 'list': [1, 2, 3],
211 'bool': true,
212 'string': 'foo'
213 };
179 return o; 214 return o;
180 } 215 }
181 216
182 checkUnnamed1949(core.Map<core.String, core.Object> o) { 217 checkUnnamed1947(core.Map<core.String, core.Object> o) {
183 unittest.expect(o, unittest.hasLength(2)); 218 unittest.expect(o, unittest.hasLength(2));
184 var casted5 = (o["x"]) as core.Map; unittest.expect(casted5, unittest.hasLengt h(3)); unittest.expect(casted5["list"], unittest.equals([1, 2, 3])); unittest.ex pect(casted5["bool"], unittest.equals(true)); unittest.expect(casted5["string"], unittest.equals('foo')); 219 var casted5 = (o["x"]) as core.Map;
185 var casted6 = (o["y"]) as core.Map; unittest.expect(casted6, unittest.hasLengt h(3)); unittest.expect(casted6["list"], unittest.equals([1, 2, 3])); unittest.ex pect(casted6["bool"], unittest.equals(true)); unittest.expect(casted6["string"], unittest.equals('foo')); 220 unittest.expect(casted5, unittest.hasLength(3));
221 unittest.expect(casted5["list"], unittest.equals([1, 2, 3]));
222 unittest.expect(casted5["bool"], unittest.equals(true));
223 unittest.expect(casted5["string"], unittest.equals('foo'));
224 var casted6 = (o["y"]) as core.Map;
225 unittest.expect(casted6, unittest.hasLength(3));
226 unittest.expect(casted6["list"], unittest.equals([1, 2, 3]));
227 unittest.expect(casted6["bool"], unittest.equals(true));
228 unittest.expect(casted6["string"], unittest.equals('foo'));
186 } 229 }
187 230
188 buildUnnamed1950() { 231 buildUnnamed1948() {
189 var o = new core.List<core.Map<core.String, core.Object>>(); 232 var o = new core.List<core.Map<core.String, core.Object>>();
190 o.add(buildUnnamed1949()); 233 o.add(buildUnnamed1947());
191 o.add(buildUnnamed1949()); 234 o.add(buildUnnamed1947());
192 return o; 235 return o;
193 } 236 }
194 237
195 checkUnnamed1950(core.List<core.Map<core.String, core.Object>> o) { 238 checkUnnamed1948(core.List<core.Map<core.String, core.Object>> o) {
196 unittest.expect(o, unittest.hasLength(2)); 239 unittest.expect(o, unittest.hasLength(2));
197 checkUnnamed1949(o[0]); 240 checkUnnamed1947(o[0]);
198 checkUnnamed1949(o[1]); 241 checkUnnamed1947(o[1]);
199 } 242 }
200 243
201 core.int buildCounterStatus = 0; 244 core.int buildCounterStatus = 0;
202 buildStatus() { 245 buildStatus() {
203 var o = new api.Status(); 246 var o = new api.Status();
204 buildCounterStatus++; 247 buildCounterStatus++;
205 if (buildCounterStatus < 3) { 248 if (buildCounterStatus < 3) {
206 o.code = 42; 249 o.code = 42;
207 o.details = buildUnnamed1950(); 250 o.details = buildUnnamed1948();
208 o.message = "foo"; 251 o.message = "foo";
209 } 252 }
210 buildCounterStatus--; 253 buildCounterStatus--;
211 return o; 254 return o;
212 } 255 }
213 256
214 checkStatus(api.Status o) { 257 checkStatus(api.Status o) {
215 buildCounterStatus++; 258 buildCounterStatus++;
216 if (buildCounterStatus < 3) { 259 if (buildCounterStatus < 3) {
217 unittest.expect(o.code, unittest.equals(42)); 260 unittest.expect(o.code, unittest.equals(42));
218 checkUnnamed1950(o.details); 261 checkUnnamed1948(o.details);
219 unittest.expect(o.message, unittest.equals('foo')); 262 unittest.expect(o.message, unittest.equals('foo'));
220 } 263 }
221 buildCounterStatus--; 264 buildCounterStatus--;
222 } 265 }
223 266
224
225 main() { 267 main() {
226 unittest.group("obj-schema-CancelOperationRequest", () { 268 unittest.group("obj-schema-CancelOperationRequest", () {
227 unittest.test("to-json--from-json", () { 269 unittest.test("to-json--from-json", () {
228 var o = buildCancelOperationRequest(); 270 var o = buildCancelOperationRequest();
229 var od = new api.CancelOperationRequest.fromJson(o.toJson()); 271 var od = new api.CancelOperationRequest.fromJson(o.toJson());
230 checkCancelOperationRequest(od); 272 checkCancelOperationRequest(od);
231 }); 273 });
232 }); 274 });
233 275
234
235 unittest.group("obj-schema-Empty", () { 276 unittest.group("obj-schema-Empty", () {
236 unittest.test("to-json--from-json", () { 277 unittest.test("to-json--from-json", () {
237 var o = buildEmpty(); 278 var o = buildEmpty();
238 var od = new api.Empty.fromJson(o.toJson()); 279 var od = new api.Empty.fromJson(o.toJson());
239 checkEmpty(od); 280 checkEmpty(od);
240 }); 281 });
241 }); 282 });
242 283
243
244 unittest.group("obj-schema-ListOperationsResponse", () { 284 unittest.group("obj-schema-ListOperationsResponse", () {
245 unittest.test("to-json--from-json", () { 285 unittest.test("to-json--from-json", () {
246 var o = buildListOperationsResponse(); 286 var o = buildListOperationsResponse();
247 var od = new api.ListOperationsResponse.fromJson(o.toJson()); 287 var od = new api.ListOperationsResponse.fromJson(o.toJson());
248 checkListOperationsResponse(od); 288 checkListOperationsResponse(od);
249 }); 289 });
250 }); 290 });
251 291
252
253 unittest.group("obj-schema-Operation", () { 292 unittest.group("obj-schema-Operation", () {
254 unittest.test("to-json--from-json", () { 293 unittest.test("to-json--from-json", () {
255 var o = buildOperation(); 294 var o = buildOperation();
256 var od = new api.Operation.fromJson(o.toJson()); 295 var od = new api.Operation.fromJson(o.toJson());
257 checkOperation(od); 296 checkOperation(od);
258 }); 297 });
259 }); 298 });
260 299
261
262 unittest.group("obj-schema-Status", () { 300 unittest.group("obj-schema-Status", () {
263 unittest.test("to-json--from-json", () { 301 unittest.test("to-json--from-json", () {
264 var o = buildStatus(); 302 var o = buildStatus();
265 var od = new api.Status.fromJson(o.toJson()); 303 var od = new api.Status.fromJson(o.toJson());
266 checkStatus(od); 304 checkStatus(od);
267 }); 305 });
268 }); 306 });
269 307
270
271 unittest.group("resource-OperationsResourceApi", () { 308 unittest.group("resource-OperationsResourceApi", () {
272 unittest.test("method--cancel", () { 309 unittest.test("method--cancel", () {
273
274 var mock = new HttpServerMock(); 310 var mock = new HttpServerMock();
275 api.OperationsResourceApi res = new api.RuntimeconfigApi(mock).operations; 311 api.OperationsResourceApi res = new api.RuntimeconfigApi(mock).operations;
276 var arg_request = buildCancelOperationRequest(); 312 var arg_request = buildCancelOperationRequest();
277 var arg_name = "foo"; 313 var arg_name = "foo";
278 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { 314 mock.register(unittest.expectAsync2((http.BaseRequest req, json) {
279 var obj = new api.CancelOperationRequest.fromJson(json); 315 var obj = new api.CancelOperationRequest.fromJson(json);
280 checkCancelOperationRequest(obj); 316 checkCancelOperationRequest(obj);
281 317
282 var path = (req.url).path; 318 var path = (req.url).path;
283 var pathOffset = 0; 319 var pathOffset = 0;
284 var index; 320 var index;
285 var subPart; 321 var subPart;
286 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ als("/")); 322 unittest.expect(
323 path.substring(pathOffset, pathOffset + 1), unittest.equals("/"));
287 pathOffset += 1; 324 pathOffset += 1;
288 unittest.expect(path.substring(pathOffset, pathOffset + 3), unittest.equ als("v1/")); 325 unittest.expect(
326 path.substring(pathOffset, pathOffset + 3), unittest.equals("v1/"));
289 pathOffset += 3; 327 pathOffset += 3;
290 // NOTE: We cannot test reserved expansions due to the inability to reve rse the operation; 328 // NOTE: We cannot test reserved expansions due to the inability to reve rse the operation;
291 329
292 var query = (req.url).query; 330 var query = (req.url).query;
293 var queryOffset = 0; 331 var queryOffset = 0;
294 var queryMap = {}; 332 var queryMap = {};
295 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); 333 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
296 parseBool(n) { 334 parseBool(n) {
297 if (n == "true") return true; 335 if (n == "true") return true;
298 if (n == "false") return false; 336 if (n == "false") return false;
299 if (n == null) return null; 337 if (n == null) return null;
300 throw new core.ArgumentError("Invalid boolean: $n"); 338 throw new core.ArgumentError("Invalid boolean: $n");
301 } 339 }
340
302 if (query.length > 0) { 341 if (query.length > 0) {
303 for (var part in query.split("&")) { 342 for (var part in query.split("&")) {
304 var keyvalue = part.split("="); 343 var keyvalue = part.split("=");
305 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d ecodeQueryComponent(keyvalue[1])); 344 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]),
345 core.Uri.decodeQueryComponent(keyvalue[1]));
306 } 346 }
307 } 347 }
308 348
309
310 var h = { 349 var h = {
311 "content-type" : "application/json; charset=utf-8", 350 "content-type": "application/json; charset=utf-8",
312 }; 351 };
313 var resp = convert.JSON.encode(buildEmpty()); 352 var resp = convert.JSON.encode(buildEmpty());
314 return new async.Future.value(stringResponse(200, h, resp)); 353 return new async.Future.value(stringResponse(200, h, resp));
315 }), true); 354 }), true);
316 res.cancel(arg_request, arg_name).then(unittest.expectAsync1(((api.Empty r esponse) { 355 res
356 .cancel(arg_request, arg_name)
357 .then(unittest.expectAsync1(((api.Empty response) {
317 checkEmpty(response); 358 checkEmpty(response);
318 }))); 359 })));
319 }); 360 });
320 361
321 unittest.test("method--delete", () { 362 unittest.test("method--delete", () {
322
323 var mock = new HttpServerMock(); 363 var mock = new HttpServerMock();
324 api.OperationsResourceApi res = new api.RuntimeconfigApi(mock).operations; 364 api.OperationsResourceApi res = new api.RuntimeconfigApi(mock).operations;
325 var arg_name = "foo"; 365 var arg_name = "foo";
326 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { 366 mock.register(unittest.expectAsync2((http.BaseRequest req, json) {
327 var path = (req.url).path; 367 var path = (req.url).path;
328 var pathOffset = 0; 368 var pathOffset = 0;
329 var index; 369 var index;
330 var subPart; 370 var subPart;
331 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ als("/")); 371 unittest.expect(
372 path.substring(pathOffset, pathOffset + 1), unittest.equals("/"));
332 pathOffset += 1; 373 pathOffset += 1;
333 unittest.expect(path.substring(pathOffset, pathOffset + 3), unittest.equ als("v1/")); 374 unittest.expect(
375 path.substring(pathOffset, pathOffset + 3), unittest.equals("v1/"));
334 pathOffset += 3; 376 pathOffset += 3;
335 // NOTE: We cannot test reserved expansions due to the inability to reve rse the operation; 377 // NOTE: We cannot test reserved expansions due to the inability to reve rse the operation;
336 378
337 var query = (req.url).query; 379 var query = (req.url).query;
338 var queryOffset = 0; 380 var queryOffset = 0;
339 var queryMap = {}; 381 var queryMap = {};
340 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); 382 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
341 parseBool(n) { 383 parseBool(n) {
342 if (n == "true") return true; 384 if (n == "true") return true;
343 if (n == "false") return false; 385 if (n == "false") return false;
344 if (n == null) return null; 386 if (n == null) return null;
345 throw new core.ArgumentError("Invalid boolean: $n"); 387 throw new core.ArgumentError("Invalid boolean: $n");
346 } 388 }
389
347 if (query.length > 0) { 390 if (query.length > 0) {
348 for (var part in query.split("&")) { 391 for (var part in query.split("&")) {
349 var keyvalue = part.split("="); 392 var keyvalue = part.split("=");
350 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d ecodeQueryComponent(keyvalue[1])); 393 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]),
394 core.Uri.decodeQueryComponent(keyvalue[1]));
351 } 395 }
352 } 396 }
353 397
354
355 var h = { 398 var h = {
356 "content-type" : "application/json; charset=utf-8", 399 "content-type": "application/json; charset=utf-8",
357 }; 400 };
358 var resp = convert.JSON.encode(buildEmpty()); 401 var resp = convert.JSON.encode(buildEmpty());
359 return new async.Future.value(stringResponse(200, h, resp)); 402 return new async.Future.value(stringResponse(200, h, resp));
360 }), true); 403 }), true);
361 res.delete(arg_name).then(unittest.expectAsync1(((api.Empty response) { 404 res.delete(arg_name).then(unittest.expectAsync1(((api.Empty response) {
362 checkEmpty(response); 405 checkEmpty(response);
363 }))); 406 })));
364 }); 407 });
365 408
366 unittest.test("method--list", () { 409 unittest.test("method--list", () {
367
368 var mock = new HttpServerMock(); 410 var mock = new HttpServerMock();
369 api.OperationsResourceApi res = new api.RuntimeconfigApi(mock).operations; 411 api.OperationsResourceApi res = new api.RuntimeconfigApi(mock).operations;
370 var arg_name = "foo"; 412 var arg_name = "foo";
413 var arg_filter = "foo";
371 var arg_pageToken = "foo"; 414 var arg_pageToken = "foo";
372 var arg_pageSize = 42; 415 var arg_pageSize = 42;
373 var arg_filter = "foo";
374 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { 416 mock.register(unittest.expectAsync2((http.BaseRequest req, json) {
375 var path = (req.url).path; 417 var path = (req.url).path;
376 var pathOffset = 0; 418 var pathOffset = 0;
377 var index; 419 var index;
378 var subPart; 420 var subPart;
379 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ als("/")); 421 unittest.expect(
422 path.substring(pathOffset, pathOffset + 1), unittest.equals("/"));
380 pathOffset += 1; 423 pathOffset += 1;
381 unittest.expect(path.substring(pathOffset, pathOffset + 3), unittest.equ als("v1/")); 424 unittest.expect(
425 path.substring(pathOffset, pathOffset + 3), unittest.equals("v1/"));
382 pathOffset += 3; 426 pathOffset += 3;
383 // NOTE: We cannot test reserved expansions due to the inability to reve rse the operation; 427 // NOTE: We cannot test reserved expansions due to the inability to reve rse the operation;
384 428
385 var query = (req.url).query; 429 var query = (req.url).query;
386 var queryOffset = 0; 430 var queryOffset = 0;
387 var queryMap = {}; 431 var queryMap = {};
388 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); 432 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
389 parseBool(n) { 433 parseBool(n) {
390 if (n == "true") return true; 434 if (n == "true") return true;
391 if (n == "false") return false; 435 if (n == "false") return false;
392 if (n == null) return null; 436 if (n == null) return null;
393 throw new core.ArgumentError("Invalid boolean: $n"); 437 throw new core.ArgumentError("Invalid boolean: $n");
394 } 438 }
439
395 if (query.length > 0) { 440 if (query.length > 0) {
396 for (var part in query.split("&")) { 441 for (var part in query.split("&")) {
397 var keyvalue = part.split("="); 442 var keyvalue = part.split("=");
398 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d ecodeQueryComponent(keyvalue[1])); 443 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]),
444 core.Uri.decodeQueryComponent(keyvalue[1]));
399 } 445 }
400 } 446 }
401 unittest.expect(queryMap["pageToken"].first, unittest.equals(arg_pageTok en));
402 unittest.expect(core.int.parse(queryMap["pageSize"].first), unittest.equ als(arg_pageSize));
403 unittest.expect(queryMap["filter"].first, unittest.equals(arg_filter)); 447 unittest.expect(queryMap["filter"].first, unittest.equals(arg_filter));
404 448 unittest.expect(
449 queryMap["pageToken"].first, unittest.equals(arg_pageToken));
450 unittest.expect(core.int.parse(queryMap["pageSize"].first),
451 unittest.equals(arg_pageSize));
405 452
406 var h = { 453 var h = {
407 "content-type" : "application/json; charset=utf-8", 454 "content-type": "application/json; charset=utf-8",
408 }; 455 };
409 var resp = convert.JSON.encode(buildListOperationsResponse()); 456 var resp = convert.JSON.encode(buildListOperationsResponse());
410 return new async.Future.value(stringResponse(200, h, resp)); 457 return new async.Future.value(stringResponse(200, h, resp));
411 }), true); 458 }), true);
412 res.list(arg_name, pageToken: arg_pageToken, pageSize: arg_pageSize, filte r: arg_filter).then(unittest.expectAsync1(((api.ListOperationsResponse response) { 459 res
460 .list(arg_name,
461 filter: arg_filter,
462 pageToken: arg_pageToken,
463 pageSize: arg_pageSize)
464 .then(unittest.expectAsync1(((api.ListOperationsResponse response) {
413 checkListOperationsResponse(response); 465 checkListOperationsResponse(response);
414 }))); 466 })));
415 }); 467 });
416
417 }); 468 });
418
419
420 } 469 }
421
OLDNEW
« no previous file with comments | « generated/googleapis/test/reseller/v1_test.dart ('k') | generated/googleapis/test/safebrowsing/v4_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698