Api-roll 42: 2016-11-08

R=whesse@google.com

Review URL: https://codereview.chromium.org//2485703002 .
diff --git a/generated/googleapis/test/manufacturers/v1_test.dart b/generated/googleapis/test/manufacturers/v1_test.dart
new file mode 100644
index 0000000..c8e95ea
--- /dev/null
+++ b/generated/googleapis/test/manufacturers/v1_test.dart
@@ -0,0 +1,373 @@
+library googleapis.manufacturers.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/manufacturers/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);
+}
+
+buildUnnamed1811() {
+  var o = new core.List<core.String>();
+  o.add("foo");
+  o.add("foo");
+  return o;
+}
+
+checkUnnamed1811(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'));
+}
+
+buildUnnamed1812() {
+  var o = new core.List<core.String>();
+  o.add("foo");
+  o.add("foo");
+  return o;
+}
+
+checkUnnamed1812(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 buildCounterAttributes = 0;
+buildAttributes() {
+  var o = new api.Attributes();
+  buildCounterAttributes++;
+  if (buildCounterAttributes < 3) {
+    o.brand = "foo";
+    o.gtin = buildUnnamed1811();
+    o.mpn = "foo";
+    o.productLine = "foo";
+    o.productName = "foo";
+    o.productPageUrl = "foo";
+    o.productType = buildUnnamed1812();
+    o.title = "foo";
+  }
+  buildCounterAttributes--;
+  return o;
+}
+
+checkAttributes(api.Attributes o) {
+  buildCounterAttributes++;
+  if (buildCounterAttributes < 3) {
+    unittest.expect(o.brand, unittest.equals('foo'));
+    checkUnnamed1811(o.gtin);
+    unittest.expect(o.mpn, unittest.equals('foo'));
+    unittest.expect(o.productLine, unittest.equals('foo'));
+    unittest.expect(o.productName, unittest.equals('foo'));
+    unittest.expect(o.productPageUrl, unittest.equals('foo'));
+    checkUnnamed1812(o.productType);
+    unittest.expect(o.title, unittest.equals('foo'));
+  }
+  buildCounterAttributes--;
+}
+
+core.int buildCounterIssue = 0;
+buildIssue() {
+  var o = new api.Issue();
+  buildCounterIssue++;
+  if (buildCounterIssue < 3) {
+    o.attribute = "foo";
+    o.description = "foo";
+    o.severity = "foo";
+    o.type = "foo";
+  }
+  buildCounterIssue--;
+  return o;
+}
+
+checkIssue(api.Issue o) {
+  buildCounterIssue++;
+  if (buildCounterIssue < 3) {
+    unittest.expect(o.attribute, unittest.equals('foo'));
+    unittest.expect(o.description, unittest.equals('foo'));
+    unittest.expect(o.severity, unittest.equals('foo'));
+    unittest.expect(o.type, unittest.equals('foo'));
+  }
+  buildCounterIssue--;
+}
+
+buildUnnamed1813() {
+  var o = new core.List<api.Product>();
+  o.add(buildProduct());
+  o.add(buildProduct());
+  return o;
+}
+
+checkUnnamed1813(core.List<api.Product> o) {
+  unittest.expect(o, unittest.hasLength(2));
+  checkProduct(o[0]);
+  checkProduct(o[1]);
+}
+
+core.int buildCounterListProductsResponse = 0;
+buildListProductsResponse() {
+  var o = new api.ListProductsResponse();
+  buildCounterListProductsResponse++;
+  if (buildCounterListProductsResponse < 3) {
+    o.nextPageToken = "foo";
+    o.products = buildUnnamed1813();
+  }
+  buildCounterListProductsResponse--;
+  return o;
+}
+
+checkListProductsResponse(api.ListProductsResponse o) {
+  buildCounterListProductsResponse++;
+  if (buildCounterListProductsResponse < 3) {
+    unittest.expect(o.nextPageToken, unittest.equals('foo'));
+    checkUnnamed1813(o.products);
+  }
+  buildCounterListProductsResponse--;
+}
+
+buildUnnamed1814() {
+  var o = new core.List<api.Issue>();
+  o.add(buildIssue());
+  o.add(buildIssue());
+  return o;
+}
+
+checkUnnamed1814(core.List<api.Issue> o) {
+  unittest.expect(o, unittest.hasLength(2));
+  checkIssue(o[0]);
+  checkIssue(o[1]);
+}
+
+buildUnnamed1815() {
+  var o = new core.List<core.String>();
+  o.add("foo");
+  o.add("foo");
+  return o;
+}
+
+checkUnnamed1815(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 buildCounterProduct = 0;
+buildProduct() {
+  var o = new api.Product();
+  buildCounterProduct++;
+  if (buildCounterProduct < 3) {
+    o.contentLanguage = "foo";
+    o.finalAttributes = buildAttributes();
+    o.issues = buildUnnamed1814();
+    o.manuallyDeletedAttributes = buildUnnamed1815();
+    o.manuallyProvidedAttributes = buildAttributes();
+    o.name = "foo";
+    o.parent = "foo";
+    o.productId = "foo";
+    o.targetCountry = "foo";
+    o.uploadedAttributes = buildAttributes();
+  }
+  buildCounterProduct--;
+  return o;
+}
+
+checkProduct(api.Product o) {
+  buildCounterProduct++;
+  if (buildCounterProduct < 3) {
+    unittest.expect(o.contentLanguage, unittest.equals('foo'));
+    checkAttributes(o.finalAttributes);
+    checkUnnamed1814(o.issues);
+    checkUnnamed1815(o.manuallyDeletedAttributes);
+    checkAttributes(o.manuallyProvidedAttributes);
+    unittest.expect(o.name, unittest.equals('foo'));
+    unittest.expect(o.parent, unittest.equals('foo'));
+    unittest.expect(o.productId, unittest.equals('foo'));
+    unittest.expect(o.targetCountry, unittest.equals('foo'));
+    checkAttributes(o.uploadedAttributes);
+  }
+  buildCounterProduct--;
+}
+
+
+main() {
+  unittest.group("obj-schema-Attributes", () {
+    unittest.test("to-json--from-json", () {
+      var o = buildAttributes();
+      var od = new api.Attributes.fromJson(o.toJson());
+      checkAttributes(od);
+    });
+  });
+
+
+  unittest.group("obj-schema-Issue", () {
+    unittest.test("to-json--from-json", () {
+      var o = buildIssue();
+      var od = new api.Issue.fromJson(o.toJson());
+      checkIssue(od);
+    });
+  });
+
+
+  unittest.group("obj-schema-ListProductsResponse", () {
+    unittest.test("to-json--from-json", () {
+      var o = buildListProductsResponse();
+      var od = new api.ListProductsResponse.fromJson(o.toJson());
+      checkListProductsResponse(od);
+    });
+  });
+
+
+  unittest.group("obj-schema-Product", () {
+    unittest.test("to-json--from-json", () {
+      var o = buildProduct();
+      var od = new api.Product.fromJson(o.toJson());
+      checkProduct(od);
+    });
+  });
+
+
+  unittest.group("resource-AccountsProductsResourceApi", () {
+    unittest.test("method--get", () {
+
+      var mock = new HttpServerMock();
+      api.AccountsProductsResourceApi res = new api.ManufacturersApi(mock).accounts.products;
+      var arg_parent = "foo";
+      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(buildProduct());
+        return new async.Future.value(stringResponse(200, h, resp));
+      }), true);
+      res.get(arg_parent, arg_name).then(unittest.expectAsync(((api.Product response) {
+        checkProduct(response);
+      })));
+    });
+
+    unittest.test("method--list", () {
+
+      var mock = new HttpServerMock();
+      api.AccountsProductsResourceApi res = new api.ManufacturersApi(mock).accounts.products;
+      var arg_parent = "foo";
+      var arg_pageSize = 42;
+      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["pageToken"].first, unittest.equals(arg_pageToken));
+
+
+        var h = {
+          "content-type" : "application/json; charset=utf-8",
+        };
+        var resp = convert.JSON.encode(buildListProductsResponse());
+        return new async.Future.value(stringResponse(200, h, resp));
+      }), true);
+      res.list(arg_parent, pageSize: arg_pageSize, pageToken: arg_pageToken).then(unittest.expectAsync(((api.ListProductsResponse response) {
+        checkListProductsResponse(response);
+      })));
+    });
+
+  });
+
+
+}
+