Chromium Code Reviews

Unified Diff: generated/googleapis/test/runtimeconfig/v1_test.dart

Issue 2485703002: Api-roll 42: 2016-11-08 (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Index: generated/googleapis/test/runtimeconfig/v1_test.dart
diff --git a/generated/googleapis/test/runtimeconfig/v1_test.dart b/generated/googleapis/test/runtimeconfig/v1_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..5ecc0b4064098f89a28b552f4c3cc5fb4eaf3922
--- /dev/null
+++ b/generated/googleapis/test/runtimeconfig/v1_test.dart
@@ -0,0 +1,421 @@
+library googleapis.runtimeconfig.v1.test;
+
+import "dart:core" as core;
+import "dart:collection" as collection;
+import "dart:async" as async;
+import "dart:convert" as convert;
+
+import 'package:http/http.dart' as http;
+import 'package:http/testing.dart' as http_testing;
+import 'package:unittest/unittest.dart' as unittest;
+
+import 'package:googleapis/runtimeconfig/v1.dart' as api;
+
+class HttpServerMock extends http.BaseClient {
+ core.Function _callback;
+ core.bool _expectJson;
+
+ void register(core.Function callback, core.bool expectJson) {
+ _callback = callback;
+ _expectJson = expectJson;
+ }
+
+ async.Future<http.StreamedResponse> send(http.BaseRequest request) {
+ if (_expectJson) {
+ return request.finalize()
+ .transform(convert.UTF8.decoder)
+ .join('')
+ .then((core.String jsonString) {
+ if (jsonString.isEmpty) {
+ return _callback(request, null);
+ } else {
+ return _callback(request, convert.JSON.decode(jsonString));
+ }
+ });
+ } else {
+ var stream = request.finalize();
+ if (stream == null) {
+ return _callback(request, []);
+ } else {
+ return stream.toBytes().then((data) {
+ return _callback(request, data);
+ });
+ }
+ }
+ }
+}
+
+http.StreamedResponse stringResponse(
+ core.int status, core.Map headers, core.String body) {
+ var stream = new async.Stream.fromIterable([convert.UTF8.encode(body)]);
+ return new http.StreamedResponse(stream, status, headers: headers);
+}
+
+core.int buildCounterCancelOperationRequest = 0;
+buildCancelOperationRequest() {
+ var o = new api.CancelOperationRequest();
+ buildCounterCancelOperationRequest++;
+ if (buildCounterCancelOperationRequest < 3) {
+ }
+ buildCounterCancelOperationRequest--;
+ return o;
+}
+
+checkCancelOperationRequest(api.CancelOperationRequest o) {
+ buildCounterCancelOperationRequest++;
+ if (buildCounterCancelOperationRequest < 3) {
+ }
+ buildCounterCancelOperationRequest--;
+}
+
+core.int buildCounterEmpty = 0;
+buildEmpty() {
+ var o = new api.Empty();
+ buildCounterEmpty++;
+ if (buildCounterEmpty < 3) {
+ }
+ buildCounterEmpty--;
+ return o;
+}
+
+checkEmpty(api.Empty o) {
+ buildCounterEmpty++;
+ if (buildCounterEmpty < 3) {
+ }
+ buildCounterEmpty--;
+}
+
+buildUnnamed2011() {
+ var o = new core.List<api.Operation>();
+ o.add(buildOperation());
+ o.add(buildOperation());
+ return o;
+}
+
+checkUnnamed2011(core.List<api.Operation> o) {
+ unittest.expect(o, unittest.hasLength(2));
+ checkOperation(o[0]);
+ checkOperation(o[1]);
+}
+
+core.int buildCounterListOperationsResponse = 0;
+buildListOperationsResponse() {
+ var o = new api.ListOperationsResponse();
+ buildCounterListOperationsResponse++;
+ if (buildCounterListOperationsResponse < 3) {
+ o.nextPageToken = "foo";
+ o.operations = buildUnnamed2011();
+ }
+ buildCounterListOperationsResponse--;
+ return o;
+}
+
+checkListOperationsResponse(api.ListOperationsResponse o) {
+ buildCounterListOperationsResponse++;
+ if (buildCounterListOperationsResponse < 3) {
+ unittest.expect(o.nextPageToken, unittest.equals('foo'));
+ checkUnnamed2011(o.operations);
+ }
+ buildCounterListOperationsResponse--;
+}
+
+buildUnnamed2012() {
+ var o = new core.Map<core.String, core.Object>();
+ o["x"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'};
+ o["y"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'};
+ return o;
+}
+
+checkUnnamed2012(core.Map<core.String, core.Object> o) {
+ unittest.expect(o, unittest.hasLength(2));
+ var casted1 = (o["x"]) as core.Map; unittest.expect(casted1, unittest.hasLength(3)); unittest.expect(casted1["list"], unittest.equals([1, 2, 3])); unittest.expect(casted1["bool"], unittest.equals(true)); unittest.expect(casted1["string"], unittest.equals('foo'));
+ var casted2 = (o["y"]) as core.Map; unittest.expect(casted2, unittest.hasLength(3)); unittest.expect(casted2["list"], unittest.equals([1, 2, 3])); unittest.expect(casted2["bool"], unittest.equals(true)); unittest.expect(casted2["string"], unittest.equals('foo'));
+}
+
+buildUnnamed2013() {
+ var o = new core.Map<core.String, core.Object>();
+ o["x"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'};
+ o["y"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'};
+ return o;
+}
+
+checkUnnamed2013(core.Map<core.String, core.Object> o) {
+ unittest.expect(o, unittest.hasLength(2));
+ var casted3 = (o["x"]) as core.Map; unittest.expect(casted3, unittest.hasLength(3)); unittest.expect(casted3["list"], unittest.equals([1, 2, 3])); unittest.expect(casted3["bool"], unittest.equals(true)); unittest.expect(casted3["string"], unittest.equals('foo'));
+ var casted4 = (o["y"]) as core.Map; unittest.expect(casted4, unittest.hasLength(3)); unittest.expect(casted4["list"], unittest.equals([1, 2, 3])); unittest.expect(casted4["bool"], unittest.equals(true)); unittest.expect(casted4["string"], unittest.equals('foo'));
+}
+
+core.int buildCounterOperation = 0;
+buildOperation() {
+ var o = new api.Operation();
+ buildCounterOperation++;
+ if (buildCounterOperation < 3) {
+ o.done = true;
+ o.error = buildStatus();
+ o.metadata = buildUnnamed2012();
+ o.name = "foo";
+ o.response = buildUnnamed2013();
+ }
+ buildCounterOperation--;
+ return o;
+}
+
+checkOperation(api.Operation o) {
+ buildCounterOperation++;
+ if (buildCounterOperation < 3) {
+ unittest.expect(o.done, unittest.isTrue);
+ checkStatus(o.error);
+ checkUnnamed2012(o.metadata);
+ unittest.expect(o.name, unittest.equals('foo'));
+ checkUnnamed2013(o.response);
+ }
+ buildCounterOperation--;
+}
+
+buildUnnamed2014() {
+ var o = new core.Map<core.String, core.Object>();
+ o["x"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'};
+ o["y"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'};
+ return o;
+}
+
+checkUnnamed2014(core.Map<core.String, core.Object> o) {
+ unittest.expect(o, unittest.hasLength(2));
+ var casted5 = (o["x"]) as core.Map; unittest.expect(casted5, unittest.hasLength(3)); unittest.expect(casted5["list"], unittest.equals([1, 2, 3])); unittest.expect(casted5["bool"], unittest.equals(true)); unittest.expect(casted5["string"], unittest.equals('foo'));
+ var casted6 = (o["y"]) as core.Map; unittest.expect(casted6, unittest.hasLength(3)); unittest.expect(casted6["list"], unittest.equals([1, 2, 3])); unittest.expect(casted6["bool"], unittest.equals(true)); unittest.expect(casted6["string"], unittest.equals('foo'));
+}
+
+buildUnnamed2015() {
+ var o = new core.List<core.Map<core.String, core.Object>>();
+ o.add(buildUnnamed2014());
+ o.add(buildUnnamed2014());
+ return o;
+}
+
+checkUnnamed2015(core.List<core.Map<core.String, core.Object>> o) {
+ unittest.expect(o, unittest.hasLength(2));
+ checkUnnamed2014(o[0]);
+ checkUnnamed2014(o[1]);
+}
+
+core.int buildCounterStatus = 0;
+buildStatus() {
+ var o = new api.Status();
+ buildCounterStatus++;
+ if (buildCounterStatus < 3) {
+ o.code = 42;
+ o.details = buildUnnamed2015();
+ o.message = "foo";
+ }
+ buildCounterStatus--;
+ return o;
+}
+
+checkStatus(api.Status o) {
+ buildCounterStatus++;
+ if (buildCounterStatus < 3) {
+ unittest.expect(o.code, unittest.equals(42));
+ checkUnnamed2015(o.details);
+ unittest.expect(o.message, unittest.equals('foo'));
+ }
+ buildCounterStatus--;
+}
+
+
+main() {
+ unittest.group("obj-schema-CancelOperationRequest", () {
+ unittest.test("to-json--from-json", () {
+ var o = buildCancelOperationRequest();
+ var od = new api.CancelOperationRequest.fromJson(o.toJson());
+ checkCancelOperationRequest(od);
+ });
+ });
+
+
+ unittest.group("obj-schema-Empty", () {
+ unittest.test("to-json--from-json", () {
+ var o = buildEmpty();
+ var od = new api.Empty.fromJson(o.toJson());
+ checkEmpty(od);
+ });
+ });
+
+
+ unittest.group("obj-schema-ListOperationsResponse", () {
+ unittest.test("to-json--from-json", () {
+ var o = buildListOperationsResponse();
+ var od = new api.ListOperationsResponse.fromJson(o.toJson());
+ checkListOperationsResponse(od);
+ });
+ });
+
+
+ unittest.group("obj-schema-Operation", () {
+ unittest.test("to-json--from-json", () {
+ var o = buildOperation();
+ var od = new api.Operation.fromJson(o.toJson());
+ checkOperation(od);
+ });
+ });
+
+
+ unittest.group("obj-schema-Status", () {
+ unittest.test("to-json--from-json", () {
+ var o = buildStatus();
+ var od = new api.Status.fromJson(o.toJson());
+ checkStatus(od);
+ });
+ });
+
+
+ unittest.group("resource-OperationsResourceApi", () {
+ unittest.test("method--cancel", () {
+
+ var mock = new HttpServerMock();
+ api.OperationsResourceApi res = new api.RuntimeconfigApi(mock).operations;
+ var arg_request = buildCancelOperationRequest();
+ var arg_name = "foo";
+ mock.register(unittest.expectAsync((http.BaseRequest req, json) {
+ var obj = new api.CancelOperationRequest.fromJson(json);
+ checkCancelOperationRequest(obj);
+
+ var path = (req.url).path;
+ var pathOffset = 0;
+ var index;
+ var subPart;
+ unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equals("/"));
+ pathOffset += 1;
+ unittest.expect(path.substring(pathOffset, pathOffset + 3), unittest.equals("v1/"));
+ pathOffset += 3;
+ // NOTE: We cannot test reserved expansions due to the inability to reverse the operation;
+
+ var query = (req.url).query;
+ var queryOffset = 0;
+ var queryMap = {};
+ addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
+ parseBool(n) {
+ if (n == "true") return true;
+ if (n == "false") return false;
+ if (n == null) return null;
+ throw new core.ArgumentError("Invalid boolean: $n");
+ }
+ if (query.length > 0) {
+ for (var part in query.split("&")) {
+ var keyvalue = part.split("=");
+ addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.decodeQueryComponent(keyvalue[1]));
+ }
+ }
+
+
+ var h = {
+ "content-type" : "application/json; charset=utf-8",
+ };
+ var resp = convert.JSON.encode(buildEmpty());
+ return new async.Future.value(stringResponse(200, h, resp));
+ }), true);
+ res.cancel(arg_request, arg_name).then(unittest.expectAsync(((api.Empty response) {
+ checkEmpty(response);
+ })));
+ });
+
+ unittest.test("method--delete", () {
+
+ var mock = new HttpServerMock();
+ api.OperationsResourceApi res = new api.RuntimeconfigApi(mock).operations;
+ var arg_name = "foo";
+ mock.register(unittest.expectAsync((http.BaseRequest req, json) {
+ var path = (req.url).path;
+ var pathOffset = 0;
+ var index;
+ var subPart;
+ unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equals("/"));
+ pathOffset += 1;
+ unittest.expect(path.substring(pathOffset, pathOffset + 3), unittest.equals("v1/"));
+ pathOffset += 3;
+ // NOTE: We cannot test reserved expansions due to the inability to reverse the operation;
+
+ var query = (req.url).query;
+ var queryOffset = 0;
+ var queryMap = {};
+ addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
+ parseBool(n) {
+ if (n == "true") return true;
+ if (n == "false") return false;
+ if (n == null) return null;
+ throw new core.ArgumentError("Invalid boolean: $n");
+ }
+ if (query.length > 0) {
+ for (var part in query.split("&")) {
+ var keyvalue = part.split("=");
+ addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.decodeQueryComponent(keyvalue[1]));
+ }
+ }
+
+
+ var h = {
+ "content-type" : "application/json; charset=utf-8",
+ };
+ var resp = convert.JSON.encode(buildEmpty());
+ return new async.Future.value(stringResponse(200, h, resp));
+ }), true);
+ res.delete(arg_name).then(unittest.expectAsync(((api.Empty response) {
+ checkEmpty(response);
+ })));
+ });
+
+ unittest.test("method--list", () {
+
+ var mock = new HttpServerMock();
+ api.OperationsResourceApi res = new api.RuntimeconfigApi(mock).operations;
+ var arg_name = "foo";
+ var arg_pageSize = 42;
+ var arg_filter = "foo";
+ var arg_pageToken = "foo";
+ mock.register(unittest.expectAsync((http.BaseRequest req, json) {
+ var path = (req.url).path;
+ var pathOffset = 0;
+ var index;
+ var subPart;
+ unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equals("/"));
+ pathOffset += 1;
+ unittest.expect(path.substring(pathOffset, pathOffset + 3), unittest.equals("v1/"));
+ pathOffset += 3;
+ // NOTE: We cannot test reserved expansions due to the inability to reverse the operation;
+
+ var query = (req.url).query;
+ var queryOffset = 0;
+ var queryMap = {};
+ addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
+ parseBool(n) {
+ if (n == "true") return true;
+ if (n == "false") return false;
+ if (n == null) return null;
+ throw new core.ArgumentError("Invalid boolean: $n");
+ }
+ if (query.length > 0) {
+ for (var part in query.split("&")) {
+ var keyvalue = part.split("=");
+ addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.decodeQueryComponent(keyvalue[1]));
+ }
+ }
+ unittest.expect(core.int.parse(queryMap["pageSize"].first), unittest.equals(arg_pageSize));
+ unittest.expect(queryMap["filter"].first, unittest.equals(arg_filter));
+ unittest.expect(queryMap["pageToken"].first, unittest.equals(arg_pageToken));
+
+
+ var h = {
+ "content-type" : "application/json; charset=utf-8",
+ };
+ var resp = convert.JSON.encode(buildListOperationsResponse());
+ return new async.Future.value(stringResponse(200, h, resp));
+ }), true);
+ res.list(arg_name, pageSize: arg_pageSize, filter: arg_filter, pageToken: arg_pageToken).then(unittest.expectAsync(((api.ListOperationsResponse response) {
+ checkListOperationsResponse(response);
+ })));
+ });
+
+ });
+
+
+}
+
« 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