| library googleapis.sourcerepo.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:test/test.dart' as unittest; |
| |
| import 'package:googleapis/sourcerepo/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<core.String, core.String> headers, core.String body) { |
| var stream = new async.Stream.fromIterable([convert.UTF8.encode(body)]); |
| return new http.StreamedResponse(stream, status, headers: headers); |
| } |
| |
| buildUnnamed496() { |
| var o = new core.List<api.AuditLogConfig>(); |
| o.add(buildAuditLogConfig()); |
| o.add(buildAuditLogConfig()); |
| return o; |
| } |
| |
| checkUnnamed496(core.List<api.AuditLogConfig> o) { |
| unittest.expect(o, unittest.hasLength(2)); |
| checkAuditLogConfig(o[0]); |
| checkAuditLogConfig(o[1]); |
| } |
| |
| buildUnnamed497() { |
| var o = new core.List<core.String>(); |
| o.add("foo"); |
| o.add("foo"); |
| return o; |
| } |
| |
| checkUnnamed497(core.List<core.String> o) { |
| unittest.expect(o, unittest.hasLength(2)); |
| unittest.expect(o[0], unittest.equals('foo')); |
| unittest.expect(o[1], unittest.equals('foo')); |
| } |
| |
| core.int buildCounterAuditConfig = 0; |
| buildAuditConfig() { |
| var o = new api.AuditConfig(); |
| buildCounterAuditConfig++; |
| if (buildCounterAuditConfig < 3) { |
| o.auditLogConfigs = buildUnnamed496(); |
| o.exemptedMembers = buildUnnamed497(); |
| o.service = "foo"; |
| } |
| buildCounterAuditConfig--; |
| return o; |
| } |
| |
| checkAuditConfig(api.AuditConfig o) { |
| buildCounterAuditConfig++; |
| if (buildCounterAuditConfig < 3) { |
| checkUnnamed496(o.auditLogConfigs); |
| checkUnnamed497(o.exemptedMembers); |
| unittest.expect(o.service, unittest.equals('foo')); |
| } |
| buildCounterAuditConfig--; |
| } |
| |
| buildUnnamed498() { |
| var o = new core.List<core.String>(); |
| o.add("foo"); |
| o.add("foo"); |
| return o; |
| } |
| |
| checkUnnamed498(core.List<core.String> o) { |
| unittest.expect(o, unittest.hasLength(2)); |
| unittest.expect(o[0], unittest.equals('foo')); |
| unittest.expect(o[1], unittest.equals('foo')); |
| } |
| |
| core.int buildCounterAuditLogConfig = 0; |
| buildAuditLogConfig() { |
| var o = new api.AuditLogConfig(); |
| buildCounterAuditLogConfig++; |
| if (buildCounterAuditLogConfig < 3) { |
| o.exemptedMembers = buildUnnamed498(); |
| o.logType = "foo"; |
| } |
| buildCounterAuditLogConfig--; |
| return o; |
| } |
| |
| checkAuditLogConfig(api.AuditLogConfig o) { |
| buildCounterAuditLogConfig++; |
| if (buildCounterAuditLogConfig < 3) { |
| checkUnnamed498(o.exemptedMembers); |
| unittest.expect(o.logType, unittest.equals('foo')); |
| } |
| buildCounterAuditLogConfig--; |
| } |
| |
| buildUnnamed499() { |
| var o = new core.List<core.String>(); |
| o.add("foo"); |
| o.add("foo"); |
| return o; |
| } |
| |
| checkUnnamed499(core.List<core.String> o) { |
| unittest.expect(o, unittest.hasLength(2)); |
| unittest.expect(o[0], unittest.equals('foo')); |
| unittest.expect(o[1], unittest.equals('foo')); |
| } |
| |
| core.int buildCounterBinding = 0; |
| buildBinding() { |
| var o = new api.Binding(); |
| buildCounterBinding++; |
| if (buildCounterBinding < 3) { |
| o.members = buildUnnamed499(); |
| o.role = "foo"; |
| } |
| buildCounterBinding--; |
| return o; |
| } |
| |
| checkBinding(api.Binding o) { |
| buildCounterBinding++; |
| if (buildCounterBinding < 3) { |
| checkUnnamed499(o.members); |
| unittest.expect(o.role, unittest.equals('foo')); |
| } |
| buildCounterBinding--; |
| } |
| |
| core.int buildCounterCloudAuditOptions = 0; |
| buildCloudAuditOptions() { |
| var o = new api.CloudAuditOptions(); |
| buildCounterCloudAuditOptions++; |
| if (buildCounterCloudAuditOptions < 3) { |
| o.logName = "foo"; |
| } |
| buildCounterCloudAuditOptions--; |
| return o; |
| } |
| |
| checkCloudAuditOptions(api.CloudAuditOptions o) { |
| buildCounterCloudAuditOptions++; |
| if (buildCounterCloudAuditOptions < 3) { |
| unittest.expect(o.logName, unittest.equals('foo')); |
| } |
| buildCounterCloudAuditOptions--; |
| } |
| |
| buildUnnamed500() { |
| var o = new core.List<core.String>(); |
| o.add("foo"); |
| o.add("foo"); |
| return o; |
| } |
| |
| checkUnnamed500(core.List<core.String> o) { |
| unittest.expect(o, unittest.hasLength(2)); |
| unittest.expect(o[0], unittest.equals('foo')); |
| unittest.expect(o[1], unittest.equals('foo')); |
| } |
| |
| core.int buildCounterCondition = 0; |
| buildCondition() { |
| var o = new api.Condition(); |
| buildCounterCondition++; |
| if (buildCounterCondition < 3) { |
| o.iam = "foo"; |
| o.op = "foo"; |
| o.svc = "foo"; |
| o.sys = "foo"; |
| o.value = "foo"; |
| o.values = buildUnnamed500(); |
| } |
| buildCounterCondition--; |
| return o; |
| } |
| |
| checkCondition(api.Condition o) { |
| buildCounterCondition++; |
| if (buildCounterCondition < 3) { |
| unittest.expect(o.iam, unittest.equals('foo')); |
| unittest.expect(o.op, unittest.equals('foo')); |
| unittest.expect(o.svc, unittest.equals('foo')); |
| unittest.expect(o.sys, unittest.equals('foo')); |
| unittest.expect(o.value, unittest.equals('foo')); |
| checkUnnamed500(o.values); |
| } |
| buildCounterCondition--; |
| } |
| |
| core.int buildCounterCounterOptions = 0; |
| buildCounterOptions() { |
| var o = new api.CounterOptions(); |
| buildCounterCounterOptions++; |
| if (buildCounterCounterOptions < 3) { |
| o.field = "foo"; |
| o.metric = "foo"; |
| } |
| buildCounterCounterOptions--; |
| return o; |
| } |
| |
| checkCounterOptions(api.CounterOptions o) { |
| buildCounterCounterOptions++; |
| if (buildCounterCounterOptions < 3) { |
| unittest.expect(o.field, unittest.equals('foo')); |
| unittest.expect(o.metric, unittest.equals('foo')); |
| } |
| buildCounterCounterOptions--; |
| } |
| |
| core.int buildCounterDataAccessOptions = 0; |
| buildDataAccessOptions() { |
| var o = new api.DataAccessOptions(); |
| buildCounterDataAccessOptions++; |
| if (buildCounterDataAccessOptions < 3) { |
| } |
| buildCounterDataAccessOptions--; |
| return o; |
| } |
| |
| checkDataAccessOptions(api.DataAccessOptions o) { |
| buildCounterDataAccessOptions++; |
| if (buildCounterDataAccessOptions < 3) { |
| } |
| buildCounterDataAccessOptions--; |
| } |
| |
| 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--; |
| } |
| |
| buildUnnamed501() { |
| var o = new core.List<api.Repo>(); |
| o.add(buildRepo()); |
| o.add(buildRepo()); |
| return o; |
| } |
| |
| checkUnnamed501(core.List<api.Repo> o) { |
| unittest.expect(o, unittest.hasLength(2)); |
| checkRepo(o[0]); |
| checkRepo(o[1]); |
| } |
| |
| core.int buildCounterListReposResponse = 0; |
| buildListReposResponse() { |
| var o = new api.ListReposResponse(); |
| buildCounterListReposResponse++; |
| if (buildCounterListReposResponse < 3) { |
| o.nextPageToken = "foo"; |
| o.repos = buildUnnamed501(); |
| } |
| buildCounterListReposResponse--; |
| return o; |
| } |
| |
| checkListReposResponse(api.ListReposResponse o) { |
| buildCounterListReposResponse++; |
| if (buildCounterListReposResponse < 3) { |
| unittest.expect(o.nextPageToken, unittest.equals('foo')); |
| checkUnnamed501(o.repos); |
| } |
| buildCounterListReposResponse--; |
| } |
| |
| core.int buildCounterLogConfig = 0; |
| buildLogConfig() { |
| var o = new api.LogConfig(); |
| buildCounterLogConfig++; |
| if (buildCounterLogConfig < 3) { |
| o.cloudAudit = buildCloudAuditOptions(); |
| o.counter = buildCounterOptions(); |
| o.dataAccess = buildDataAccessOptions(); |
| } |
| buildCounterLogConfig--; |
| return o; |
| } |
| |
| checkLogConfig(api.LogConfig o) { |
| buildCounterLogConfig++; |
| if (buildCounterLogConfig < 3) { |
| checkCloudAuditOptions(o.cloudAudit); |
| checkCounterOptions(o.counter); |
| checkDataAccessOptions(o.dataAccess); |
| } |
| buildCounterLogConfig--; |
| } |
| |
| core.int buildCounterMirrorConfig = 0; |
| buildMirrorConfig() { |
| var o = new api.MirrorConfig(); |
| buildCounterMirrorConfig++; |
| if (buildCounterMirrorConfig < 3) { |
| o.deployKeyId = "foo"; |
| o.url = "foo"; |
| o.webhookId = "foo"; |
| } |
| buildCounterMirrorConfig--; |
| return o; |
| } |
| |
| checkMirrorConfig(api.MirrorConfig o) { |
| buildCounterMirrorConfig++; |
| if (buildCounterMirrorConfig < 3) { |
| unittest.expect(o.deployKeyId, unittest.equals('foo')); |
| unittest.expect(o.url, unittest.equals('foo')); |
| unittest.expect(o.webhookId, unittest.equals('foo')); |
| } |
| buildCounterMirrorConfig--; |
| } |
| |
| buildUnnamed502() { |
| var o = new core.List<api.AuditConfig>(); |
| o.add(buildAuditConfig()); |
| o.add(buildAuditConfig()); |
| return o; |
| } |
| |
| checkUnnamed502(core.List<api.AuditConfig> o) { |
| unittest.expect(o, unittest.hasLength(2)); |
| checkAuditConfig(o[0]); |
| checkAuditConfig(o[1]); |
| } |
| |
| buildUnnamed503() { |
| var o = new core.List<api.Binding>(); |
| o.add(buildBinding()); |
| o.add(buildBinding()); |
| return o; |
| } |
| |
| checkUnnamed503(core.List<api.Binding> o) { |
| unittest.expect(o, unittest.hasLength(2)); |
| checkBinding(o[0]); |
| checkBinding(o[1]); |
| } |
| |
| buildUnnamed504() { |
| var o = new core.List<api.Rule>(); |
| o.add(buildRule()); |
| o.add(buildRule()); |
| return o; |
| } |
| |
| checkUnnamed504(core.List<api.Rule> o) { |
| unittest.expect(o, unittest.hasLength(2)); |
| checkRule(o[0]); |
| checkRule(o[1]); |
| } |
| |
| core.int buildCounterPolicy = 0; |
| buildPolicy() { |
| var o = new api.Policy(); |
| buildCounterPolicy++; |
| if (buildCounterPolicy < 3) { |
| o.auditConfigs = buildUnnamed502(); |
| o.bindings = buildUnnamed503(); |
| o.etag = "foo"; |
| o.iamOwned = true; |
| o.rules = buildUnnamed504(); |
| o.version = 42; |
| } |
| buildCounterPolicy--; |
| return o; |
| } |
| |
| checkPolicy(api.Policy o) { |
| buildCounterPolicy++; |
| if (buildCounterPolicy < 3) { |
| checkUnnamed502(o.auditConfigs); |
| checkUnnamed503(o.bindings); |
| unittest.expect(o.etag, unittest.equals('foo')); |
| unittest.expect(o.iamOwned, unittest.isTrue); |
| checkUnnamed504(o.rules); |
| unittest.expect(o.version, unittest.equals(42)); |
| } |
| buildCounterPolicy--; |
| } |
| |
| core.int buildCounterRepo = 0; |
| buildRepo() { |
| var o = new api.Repo(); |
| buildCounterRepo++; |
| if (buildCounterRepo < 3) { |
| o.mirrorConfig = buildMirrorConfig(); |
| o.name = "foo"; |
| o.size = "foo"; |
| o.url = "foo"; |
| } |
| buildCounterRepo--; |
| return o; |
| } |
| |
| checkRepo(api.Repo o) { |
| buildCounterRepo++; |
| if (buildCounterRepo < 3) { |
| checkMirrorConfig(o.mirrorConfig); |
| unittest.expect(o.name, unittest.equals('foo')); |
| unittest.expect(o.size, unittest.equals('foo')); |
| unittest.expect(o.url, unittest.equals('foo')); |
| } |
| buildCounterRepo--; |
| } |
| |
| buildUnnamed505() { |
| var o = new core.List<api.Condition>(); |
| o.add(buildCondition()); |
| o.add(buildCondition()); |
| return o; |
| } |
| |
| checkUnnamed505(core.List<api.Condition> o) { |
| unittest.expect(o, unittest.hasLength(2)); |
| checkCondition(o[0]); |
| checkCondition(o[1]); |
| } |
| |
| buildUnnamed506() { |
| var o = new core.List<core.String>(); |
| o.add("foo"); |
| o.add("foo"); |
| return o; |
| } |
| |
| checkUnnamed506(core.List<core.String> o) { |
| unittest.expect(o, unittest.hasLength(2)); |
| unittest.expect(o[0], unittest.equals('foo')); |
| unittest.expect(o[1], unittest.equals('foo')); |
| } |
| |
| buildUnnamed507() { |
| var o = new core.List<api.LogConfig>(); |
| o.add(buildLogConfig()); |
| o.add(buildLogConfig()); |
| return o; |
| } |
| |
| checkUnnamed507(core.List<api.LogConfig> o) { |
| unittest.expect(o, unittest.hasLength(2)); |
| checkLogConfig(o[0]); |
| checkLogConfig(o[1]); |
| } |
| |
| buildUnnamed508() { |
| var o = new core.List<core.String>(); |
| o.add("foo"); |
| o.add("foo"); |
| return o; |
| } |
| |
| checkUnnamed508(core.List<core.String> o) { |
| unittest.expect(o, unittest.hasLength(2)); |
| unittest.expect(o[0], unittest.equals('foo')); |
| unittest.expect(o[1], unittest.equals('foo')); |
| } |
| |
| buildUnnamed509() { |
| var o = new core.List<core.String>(); |
| o.add("foo"); |
| o.add("foo"); |
| return o; |
| } |
| |
| checkUnnamed509(core.List<core.String> o) { |
| unittest.expect(o, unittest.hasLength(2)); |
| unittest.expect(o[0], unittest.equals('foo')); |
| unittest.expect(o[1], unittest.equals('foo')); |
| } |
| |
| core.int buildCounterRule = 0; |
| buildRule() { |
| var o = new api.Rule(); |
| buildCounterRule++; |
| if (buildCounterRule < 3) { |
| o.action = "foo"; |
| o.conditions = buildUnnamed505(); |
| o.description = "foo"; |
| o.in_ = buildUnnamed506(); |
| o.logConfig = buildUnnamed507(); |
| o.notIn = buildUnnamed508(); |
| o.permissions = buildUnnamed509(); |
| } |
| buildCounterRule--; |
| return o; |
| } |
| |
| checkRule(api.Rule o) { |
| buildCounterRule++; |
| if (buildCounterRule < 3) { |
| unittest.expect(o.action, unittest.equals('foo')); |
| checkUnnamed505(o.conditions); |
| unittest.expect(o.description, unittest.equals('foo')); |
| checkUnnamed506(o.in_); |
| checkUnnamed507(o.logConfig); |
| checkUnnamed508(o.notIn); |
| checkUnnamed509(o.permissions); |
| } |
| buildCounterRule--; |
| } |
| |
| core.int buildCounterSetIamPolicyRequest = 0; |
| buildSetIamPolicyRequest() { |
| var o = new api.SetIamPolicyRequest(); |
| buildCounterSetIamPolicyRequest++; |
| if (buildCounterSetIamPolicyRequest < 3) { |
| o.policy = buildPolicy(); |
| o.updateMask = "foo"; |
| } |
| buildCounterSetIamPolicyRequest--; |
| return o; |
| } |
| |
| checkSetIamPolicyRequest(api.SetIamPolicyRequest o) { |
| buildCounterSetIamPolicyRequest++; |
| if (buildCounterSetIamPolicyRequest < 3) { |
| checkPolicy(o.policy); |
| unittest.expect(o.updateMask, unittest.equals('foo')); |
| } |
| buildCounterSetIamPolicyRequest--; |
| } |
| |
| buildUnnamed510() { |
| var o = new core.List<core.String>(); |
| o.add("foo"); |
| o.add("foo"); |
| return o; |
| } |
| |
| checkUnnamed510(core.List<core.String> o) { |
| unittest.expect(o, unittest.hasLength(2)); |
| unittest.expect(o[0], unittest.equals('foo')); |
| unittest.expect(o[1], unittest.equals('foo')); |
| } |
| |
| core.int buildCounterTestIamPermissionsRequest = 0; |
| buildTestIamPermissionsRequest() { |
| var o = new api.TestIamPermissionsRequest(); |
| buildCounterTestIamPermissionsRequest++; |
| if (buildCounterTestIamPermissionsRequest < 3) { |
| o.permissions = buildUnnamed510(); |
| } |
| buildCounterTestIamPermissionsRequest--; |
| return o; |
| } |
| |
| checkTestIamPermissionsRequest(api.TestIamPermissionsRequest o) { |
| buildCounterTestIamPermissionsRequest++; |
| if (buildCounterTestIamPermissionsRequest < 3) { |
| checkUnnamed510(o.permissions); |
| } |
| buildCounterTestIamPermissionsRequest--; |
| } |
| |
| buildUnnamed511() { |
| var o = new core.List<core.String>(); |
| o.add("foo"); |
| o.add("foo"); |
| return o; |
| } |
| |
| checkUnnamed511(core.List<core.String> o) { |
| unittest.expect(o, unittest.hasLength(2)); |
| unittest.expect(o[0], unittest.equals('foo')); |
| unittest.expect(o[1], unittest.equals('foo')); |
| } |
| |
| core.int buildCounterTestIamPermissionsResponse = 0; |
| buildTestIamPermissionsResponse() { |
| var o = new api.TestIamPermissionsResponse(); |
| buildCounterTestIamPermissionsResponse++; |
| if (buildCounterTestIamPermissionsResponse < 3) { |
| o.permissions = buildUnnamed511(); |
| } |
| buildCounterTestIamPermissionsResponse--; |
| return o; |
| } |
| |
| checkTestIamPermissionsResponse(api.TestIamPermissionsResponse o) { |
| buildCounterTestIamPermissionsResponse++; |
| if (buildCounterTestIamPermissionsResponse < 3) { |
| checkUnnamed511(o.permissions); |
| } |
| buildCounterTestIamPermissionsResponse--; |
| } |
| |
| |
| main() { |
| unittest.group("obj-schema-AuditConfig", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildAuditConfig(); |
| var od = new api.AuditConfig.fromJson(o.toJson()); |
| checkAuditConfig(od); |
| }); |
| }); |
| |
| |
| unittest.group("obj-schema-AuditLogConfig", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildAuditLogConfig(); |
| var od = new api.AuditLogConfig.fromJson(o.toJson()); |
| checkAuditLogConfig(od); |
| }); |
| }); |
| |
| |
| unittest.group("obj-schema-Binding", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildBinding(); |
| var od = new api.Binding.fromJson(o.toJson()); |
| checkBinding(od); |
| }); |
| }); |
| |
| |
| unittest.group("obj-schema-CloudAuditOptions", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildCloudAuditOptions(); |
| var od = new api.CloudAuditOptions.fromJson(o.toJson()); |
| checkCloudAuditOptions(od); |
| }); |
| }); |
| |
| |
| unittest.group("obj-schema-Condition", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildCondition(); |
| var od = new api.Condition.fromJson(o.toJson()); |
| checkCondition(od); |
| }); |
| }); |
| |
| |
| unittest.group("obj-schema-CounterOptions", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildCounterOptions(); |
| var od = new api.CounterOptions.fromJson(o.toJson()); |
| checkCounterOptions(od); |
| }); |
| }); |
| |
| |
| unittest.group("obj-schema-DataAccessOptions", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildDataAccessOptions(); |
| var od = new api.DataAccessOptions.fromJson(o.toJson()); |
| checkDataAccessOptions(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-ListReposResponse", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildListReposResponse(); |
| var od = new api.ListReposResponse.fromJson(o.toJson()); |
| checkListReposResponse(od); |
| }); |
| }); |
| |
| |
| unittest.group("obj-schema-LogConfig", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildLogConfig(); |
| var od = new api.LogConfig.fromJson(o.toJson()); |
| checkLogConfig(od); |
| }); |
| }); |
| |
| |
| unittest.group("obj-schema-MirrorConfig", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildMirrorConfig(); |
| var od = new api.MirrorConfig.fromJson(o.toJson()); |
| checkMirrorConfig(od); |
| }); |
| }); |
| |
| |
| unittest.group("obj-schema-Policy", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildPolicy(); |
| var od = new api.Policy.fromJson(o.toJson()); |
| checkPolicy(od); |
| }); |
| }); |
| |
| |
| unittest.group("obj-schema-Repo", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildRepo(); |
| var od = new api.Repo.fromJson(o.toJson()); |
| checkRepo(od); |
| }); |
| }); |
| |
| |
| unittest.group("obj-schema-Rule", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildRule(); |
| var od = new api.Rule.fromJson(o.toJson()); |
| checkRule(od); |
| }); |
| }); |
| |
| |
| unittest.group("obj-schema-SetIamPolicyRequest", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildSetIamPolicyRequest(); |
| var od = new api.SetIamPolicyRequest.fromJson(o.toJson()); |
| checkSetIamPolicyRequest(od); |
| }); |
| }); |
| |
| |
| unittest.group("obj-schema-TestIamPermissionsRequest", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildTestIamPermissionsRequest(); |
| var od = new api.TestIamPermissionsRequest.fromJson(o.toJson()); |
| checkTestIamPermissionsRequest(od); |
| }); |
| }); |
| |
| |
| unittest.group("obj-schema-TestIamPermissionsResponse", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildTestIamPermissionsResponse(); |
| var od = new api.TestIamPermissionsResponse.fromJson(o.toJson()); |
| checkTestIamPermissionsResponse(od); |
| }); |
| }); |
| |
| |
| unittest.group("resource-ProjectsReposResourceApi", () { |
| unittest.test("method--create", () { |
| |
| var mock = new HttpServerMock(); |
| api.ProjectsReposResourceApi res = new api.SourcerepoApi(mock).projects.repos; |
| var arg_request = buildRepo(); |
| var arg_parent = "foo"; |
| mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
| var obj = new api.Repo.fromJson(json); |
| checkRepo(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(buildRepo()); |
| return new async.Future.value(stringResponse(200, h, resp)); |
| }), true); |
| res.create(arg_request, arg_parent).then(unittest.expectAsync1(((api.Repo response) { |
| checkRepo(response); |
| }))); |
| }); |
| |
| unittest.test("method--delete", () { |
| |
| var mock = new HttpServerMock(); |
| api.ProjectsReposResourceApi res = new api.SourcerepoApi(mock).projects.repos; |
| var arg_name = "foo"; |
| mock.register(unittest.expectAsync2((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.expectAsync1(((api.Empty response) { |
| checkEmpty(response); |
| }))); |
| }); |
| |
| unittest.test("method--get", () { |
| |
| var mock = new HttpServerMock(); |
| api.ProjectsReposResourceApi res = new api.SourcerepoApi(mock).projects.repos; |
| var arg_name = "foo"; |
| mock.register(unittest.expectAsync2((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(buildRepo()); |
| return new async.Future.value(stringResponse(200, h, resp)); |
| }), true); |
| res.get(arg_name).then(unittest.expectAsync1(((api.Repo response) { |
| checkRepo(response); |
| }))); |
| }); |
| |
| unittest.test("method--getIamPolicy", () { |
| |
| var mock = new HttpServerMock(); |
| api.ProjectsReposResourceApi res = new api.SourcerepoApi(mock).projects.repos; |
| var arg_resource = "foo"; |
| mock.register(unittest.expectAsync2((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(buildPolicy()); |
| return new async.Future.value(stringResponse(200, h, resp)); |
| }), true); |
| res.getIamPolicy(arg_resource).then(unittest.expectAsync1(((api.Policy response) { |
| checkPolicy(response); |
| }))); |
| }); |
| |
| unittest.test("method--list", () { |
| |
| var mock = new HttpServerMock(); |
| api.ProjectsReposResourceApi res = new api.SourcerepoApi(mock).projects.repos; |
| var arg_name = "foo"; |
| var arg_pageToken = "foo"; |
| var arg_pageSize = 42; |
| mock.register(unittest.expectAsync2((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(queryMap["pageToken"].first, unittest.equals(arg_pageToken)); |
| unittest.expect(core.int.parse(queryMap["pageSize"].first), unittest.equals(arg_pageSize)); |
| |
| |
| var h = { |
| "content-type" : "application/json; charset=utf-8", |
| }; |
| var resp = convert.JSON.encode(buildListReposResponse()); |
| return new async.Future.value(stringResponse(200, h, resp)); |
| }), true); |
| res.list(arg_name, pageToken: arg_pageToken, pageSize: arg_pageSize).then(unittest.expectAsync1(((api.ListReposResponse response) { |
| checkListReposResponse(response); |
| }))); |
| }); |
| |
| unittest.test("method--setIamPolicy", () { |
| |
| var mock = new HttpServerMock(); |
| api.ProjectsReposResourceApi res = new api.SourcerepoApi(mock).projects.repos; |
| var arg_request = buildSetIamPolicyRequest(); |
| var arg_resource = "foo"; |
| mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
| var obj = new api.SetIamPolicyRequest.fromJson(json); |
| checkSetIamPolicyRequest(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(buildPolicy()); |
| return new async.Future.value(stringResponse(200, h, resp)); |
| }), true); |
| res.setIamPolicy(arg_request, arg_resource).then(unittest.expectAsync1(((api.Policy response) { |
| checkPolicy(response); |
| }))); |
| }); |
| |
| unittest.test("method--testIamPermissions", () { |
| |
| var mock = new HttpServerMock(); |
| api.ProjectsReposResourceApi res = new api.SourcerepoApi(mock).projects.repos; |
| var arg_request = buildTestIamPermissionsRequest(); |
| var arg_resource = "foo"; |
| mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
| var obj = new api.TestIamPermissionsRequest.fromJson(json); |
| checkTestIamPermissionsRequest(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(buildTestIamPermissionsResponse()); |
| return new async.Future.value(stringResponse(200, h, resp)); |
| }), true); |
| res.testIamPermissions(arg_request, arg_resource).then(unittest.expectAsync1(((api.TestIamPermissionsResponse response) { |
| checkTestIamPermissionsResponse(response); |
| }))); |
| }); |
| |
| }); |
| |
| |
| } |
| |