| Index: generated/googleapis/test/adexperiencereport/v1_test.dart
|
| diff --git a/generated/googleapis/test/adexperiencereport/v1_test.dart b/generated/googleapis/test/adexperiencereport/v1_test.dart
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..a92f1a7b47a86e21862a7b616a884b1cbb13cf2c
|
| --- /dev/null
|
| +++ b/generated/googleapis/test/adexperiencereport/v1_test.dart
|
| @@ -0,0 +1,281 @@
|
| +library googleapis.adexperiencereport.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/adexperiencereport/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);
|
| +}
|
| +
|
| +buildUnnamed1725() {
|
| + var o = new core.List<core.String>();
|
| + o.add("foo");
|
| + o.add("foo");
|
| + return o;
|
| +}
|
| +
|
| +checkUnnamed1725(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 buildCounterPlatformSummary = 0;
|
| +buildPlatformSummary() {
|
| + var o = new api.PlatformSummary();
|
| + buildCounterPlatformSummary++;
|
| + if (buildCounterPlatformSummary < 3) {
|
| + o.betterAdsStatus = "foo";
|
| + o.egregiousStatus = "foo";
|
| + o.enforcementTime = "foo";
|
| + o.filterStatus = "foo";
|
| + o.lastChangeTime = "foo";
|
| + o.region = buildUnnamed1725();
|
| + o.reportUrl = "foo";
|
| + o.underReview = true;
|
| + }
|
| + buildCounterPlatformSummary--;
|
| + return o;
|
| +}
|
| +
|
| +checkPlatformSummary(api.PlatformSummary o) {
|
| + buildCounterPlatformSummary++;
|
| + if (buildCounterPlatformSummary < 3) {
|
| + unittest.expect(o.betterAdsStatus, unittest.equals('foo'));
|
| + unittest.expect(o.egregiousStatus, unittest.equals('foo'));
|
| + unittest.expect(o.enforcementTime, unittest.equals('foo'));
|
| + unittest.expect(o.filterStatus, unittest.equals('foo'));
|
| + unittest.expect(o.lastChangeTime, unittest.equals('foo'));
|
| + checkUnnamed1725(o.region);
|
| + unittest.expect(o.reportUrl, unittest.equals('foo'));
|
| + unittest.expect(o.underReview, unittest.isTrue);
|
| + }
|
| + buildCounterPlatformSummary--;
|
| +}
|
| +
|
| +core.int buildCounterSiteSummaryResponse = 0;
|
| +buildSiteSummaryResponse() {
|
| + var o = new api.SiteSummaryResponse();
|
| + buildCounterSiteSummaryResponse++;
|
| + if (buildCounterSiteSummaryResponse < 3) {
|
| + o.desktopSummary = buildPlatformSummary();
|
| + o.mobileSummary = buildPlatformSummary();
|
| + o.reviewedSite = "foo";
|
| + }
|
| + buildCounterSiteSummaryResponse--;
|
| + return o;
|
| +}
|
| +
|
| +checkSiteSummaryResponse(api.SiteSummaryResponse o) {
|
| + buildCounterSiteSummaryResponse++;
|
| + if (buildCounterSiteSummaryResponse < 3) {
|
| + checkPlatformSummary(o.desktopSummary);
|
| + checkPlatformSummary(o.mobileSummary);
|
| + unittest.expect(o.reviewedSite, unittest.equals('foo'));
|
| + }
|
| + buildCounterSiteSummaryResponse--;
|
| +}
|
| +
|
| +buildUnnamed1726() {
|
| + var o = new core.List<api.SiteSummaryResponse>();
|
| + o.add(buildSiteSummaryResponse());
|
| + o.add(buildSiteSummaryResponse());
|
| + return o;
|
| +}
|
| +
|
| +checkUnnamed1726(core.List<api.SiteSummaryResponse> o) {
|
| + unittest.expect(o, unittest.hasLength(2));
|
| + checkSiteSummaryResponse(o[0]);
|
| + checkSiteSummaryResponse(o[1]);
|
| +}
|
| +
|
| +core.int buildCounterViolatingSitesResponse = 0;
|
| +buildViolatingSitesResponse() {
|
| + var o = new api.ViolatingSitesResponse();
|
| + buildCounterViolatingSitesResponse++;
|
| + if (buildCounterViolatingSitesResponse < 3) {
|
| + o.violatingSites = buildUnnamed1726();
|
| + }
|
| + buildCounterViolatingSitesResponse--;
|
| + return o;
|
| +}
|
| +
|
| +checkViolatingSitesResponse(api.ViolatingSitesResponse o) {
|
| + buildCounterViolatingSitesResponse++;
|
| + if (buildCounterViolatingSitesResponse < 3) {
|
| + checkUnnamed1726(o.violatingSites);
|
| + }
|
| + buildCounterViolatingSitesResponse--;
|
| +}
|
| +
|
| +
|
| +main() {
|
| + unittest.group("obj-schema-PlatformSummary", () {
|
| + unittest.test("to-json--from-json", () {
|
| + var o = buildPlatformSummary();
|
| + var od = new api.PlatformSummary.fromJson(o.toJson());
|
| + checkPlatformSummary(od);
|
| + });
|
| + });
|
| +
|
| +
|
| + unittest.group("obj-schema-SiteSummaryResponse", () {
|
| + unittest.test("to-json--from-json", () {
|
| + var o = buildSiteSummaryResponse();
|
| + var od = new api.SiteSummaryResponse.fromJson(o.toJson());
|
| + checkSiteSummaryResponse(od);
|
| + });
|
| + });
|
| +
|
| +
|
| + unittest.group("obj-schema-ViolatingSitesResponse", () {
|
| + unittest.test("to-json--from-json", () {
|
| + var o = buildViolatingSitesResponse();
|
| + var od = new api.ViolatingSitesResponse.fromJson(o.toJson());
|
| + checkViolatingSitesResponse(od);
|
| + });
|
| + });
|
| +
|
| +
|
| + unittest.group("resource-SitesResourceApi", () {
|
| + unittest.test("method--get", () {
|
| +
|
| + var mock = new HttpServerMock();
|
| + api.SitesResourceApi res = new api.AdexperiencereportApi(mock).sites;
|
| + 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(buildSiteSummaryResponse());
|
| + return new async.Future.value(stringResponse(200, h, resp));
|
| + }), true);
|
| + res.get(arg_name).then(unittest.expectAsync1(((api.SiteSummaryResponse response) {
|
| + checkSiteSummaryResponse(response);
|
| + })));
|
| + });
|
| +
|
| + });
|
| +
|
| +
|
| + unittest.group("resource-ViolatingSitesResourceApi", () {
|
| + unittest.test("method--list", () {
|
| +
|
| + var mock = new HttpServerMock();
|
| + api.ViolatingSitesResourceApi res = new api.AdexperiencereportApi(mock).violatingSites;
|
| + 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 + 17), unittest.equals("v1/violatingSites"));
|
| + pathOffset += 17;
|
| +
|
| + 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(buildViolatingSitesResponse());
|
| + return new async.Future.value(stringResponse(200, h, resp));
|
| + }), true);
|
| + res.list().then(unittest.expectAsync1(((api.ViolatingSitesResponse response) {
|
| + checkViolatingSitesResponse(response);
|
| + })));
|
| + });
|
| +
|
| + });
|
| +
|
| +
|
| +}
|
| +
|
|
|