| library googleapis.freebase.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/common/common.dart' as common; |
| import 'package:googleapis/src/common_internal.dart' as common_internal; |
| import '../common/common_internal_test.dart' as common_test; |
| |
| import 'package:googleapis/freebase/v1.dart' as api; |
| |
| |
| |
| core.int buildCounterReconcileCandidateNotable = 0; |
| buildReconcileCandidateNotable() { |
| var o = new api.ReconcileCandidateNotable(); |
| buildCounterReconcileCandidateNotable++; |
| if (buildCounterReconcileCandidateNotable < 3) { |
| o.id = "foo"; |
| o.name = "foo"; |
| } |
| buildCounterReconcileCandidateNotable--; |
| return o; |
| } |
| |
| checkReconcileCandidateNotable(api.ReconcileCandidateNotable o) { |
| buildCounterReconcileCandidateNotable++; |
| if (buildCounterReconcileCandidateNotable < 3) { |
| unittest.expect(o.id, unittest.equals('foo')); |
| unittest.expect(o.name, unittest.equals('foo')); |
| } |
| buildCounterReconcileCandidateNotable--; |
| } |
| |
| core.int buildCounterReconcileCandidate = 0; |
| buildReconcileCandidate() { |
| var o = new api.ReconcileCandidate(); |
| buildCounterReconcileCandidate++; |
| if (buildCounterReconcileCandidate < 3) { |
| o.confidence = 42.0; |
| o.lang = "foo"; |
| o.mid = "foo"; |
| o.name = "foo"; |
| o.notable = buildReconcileCandidateNotable(); |
| } |
| buildCounterReconcileCandidate--; |
| return o; |
| } |
| |
| checkReconcileCandidate(api.ReconcileCandidate o) { |
| buildCounterReconcileCandidate++; |
| if (buildCounterReconcileCandidate < 3) { |
| unittest.expect(o.confidence, unittest.equals(42.0)); |
| unittest.expect(o.lang, unittest.equals('foo')); |
| unittest.expect(o.mid, unittest.equals('foo')); |
| unittest.expect(o.name, unittest.equals('foo')); |
| checkReconcileCandidateNotable(o.notable); |
| } |
| buildCounterReconcileCandidate--; |
| } |
| |
| buildUnnamed766() { |
| var o = new core.List<api.ReconcileCandidate>(); |
| o.add(buildReconcileCandidate()); |
| o.add(buildReconcileCandidate()); |
| return o; |
| } |
| |
| checkUnnamed766(core.List<api.ReconcileCandidate> o) { |
| unittest.expect(o, unittest.hasLength(2)); |
| checkReconcileCandidate(o[0]); |
| checkReconcileCandidate(o[1]); |
| } |
| |
| core.int buildCounterReconcileGetCosts = 0; |
| buildReconcileGetCosts() { |
| var o = new api.ReconcileGetCosts(); |
| buildCounterReconcileGetCosts++; |
| if (buildCounterReconcileGetCosts < 3) { |
| o.hits = 42; |
| o.ms = 42; |
| } |
| buildCounterReconcileGetCosts--; |
| return o; |
| } |
| |
| checkReconcileGetCosts(api.ReconcileGetCosts o) { |
| buildCounterReconcileGetCosts++; |
| if (buildCounterReconcileGetCosts < 3) { |
| unittest.expect(o.hits, unittest.equals(42)); |
| unittest.expect(o.ms, unittest.equals(42)); |
| } |
| buildCounterReconcileGetCosts--; |
| } |
| |
| core.int buildCounterReconcileGetWarning = 0; |
| buildReconcileGetWarning() { |
| var o = new api.ReconcileGetWarning(); |
| buildCounterReconcileGetWarning++; |
| if (buildCounterReconcileGetWarning < 3) { |
| o.location = "foo"; |
| o.message = "foo"; |
| o.reason = "foo"; |
| } |
| buildCounterReconcileGetWarning--; |
| return o; |
| } |
| |
| checkReconcileGetWarning(api.ReconcileGetWarning o) { |
| buildCounterReconcileGetWarning++; |
| if (buildCounterReconcileGetWarning < 3) { |
| unittest.expect(o.location, unittest.equals('foo')); |
| unittest.expect(o.message, unittest.equals('foo')); |
| unittest.expect(o.reason, unittest.equals('foo')); |
| } |
| buildCounterReconcileGetWarning--; |
| } |
| |
| buildUnnamed767() { |
| var o = new core.List<api.ReconcileGetWarning>(); |
| o.add(buildReconcileGetWarning()); |
| o.add(buildReconcileGetWarning()); |
| return o; |
| } |
| |
| checkUnnamed767(core.List<api.ReconcileGetWarning> o) { |
| unittest.expect(o, unittest.hasLength(2)); |
| checkReconcileGetWarning(o[0]); |
| checkReconcileGetWarning(o[1]); |
| } |
| |
| core.int buildCounterReconcileGet = 0; |
| buildReconcileGet() { |
| var o = new api.ReconcileGet(); |
| buildCounterReconcileGet++; |
| if (buildCounterReconcileGet < 3) { |
| o.candidate = buildUnnamed766(); |
| o.costs = buildReconcileGetCosts(); |
| o.match = buildReconcileCandidate(); |
| o.warning = buildUnnamed767(); |
| } |
| buildCounterReconcileGet--; |
| return o; |
| } |
| |
| checkReconcileGet(api.ReconcileGet o) { |
| buildCounterReconcileGet++; |
| if (buildCounterReconcileGet < 3) { |
| checkUnnamed766(o.candidate); |
| checkReconcileGetCosts(o.costs); |
| checkReconcileCandidate(o.match); |
| checkUnnamed767(o.warning); |
| } |
| buildCounterReconcileGet--; |
| } |
| |
| buildUnnamed768() { |
| var o = new core.List<core.String>(); |
| o.add("foo"); |
| o.add("foo"); |
| return o; |
| } |
| |
| checkUnnamed768(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')); |
| } |
| |
| buildUnnamed769() { |
| var o = new core.List<core.String>(); |
| o.add("foo"); |
| o.add("foo"); |
| return o; |
| } |
| |
| checkUnnamed769(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')); |
| } |
| |
| buildUnnamed770() { |
| var o = new core.List<core.String>(); |
| o.add("foo"); |
| o.add("foo"); |
| return o; |
| } |
| |
| checkUnnamed770(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')); |
| } |
| |
| buildUnnamed771() { |
| var o = new core.List<core.String>(); |
| o.add("foo"); |
| o.add("foo"); |
| return o; |
| } |
| |
| checkUnnamed771(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')); |
| } |
| |
| buildUnnamed772() { |
| var o = new core.List<core.String>(); |
| o.add("foo"); |
| o.add("foo"); |
| return o; |
| } |
| |
| checkUnnamed772(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')); |
| } |
| |
| buildUnnamed773() { |
| var o = new core.List<core.String>(); |
| o.add("foo"); |
| o.add("foo"); |
| return o; |
| } |
| |
| checkUnnamed773(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')); |
| } |
| |
| buildUnnamed774() { |
| var o = new core.List<core.String>(); |
| o.add("foo"); |
| o.add("foo"); |
| return o; |
| } |
| |
| checkUnnamed774(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')); |
| } |
| |
| buildUnnamed775() { |
| var o = new core.List<core.String>(); |
| o.add("foo"); |
| o.add("foo"); |
| return o; |
| } |
| |
| checkUnnamed775(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')); |
| } |
| |
| buildUnnamed776() { |
| var o = new core.List<core.String>(); |
| o.add("foo"); |
| o.add("foo"); |
| return o; |
| } |
| |
| checkUnnamed776(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')); |
| } |
| |
| buildUnnamed777() { |
| var o = new core.List<core.String>(); |
| o.add("foo"); |
| o.add("foo"); |
| return o; |
| } |
| |
| checkUnnamed777(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')); |
| } |
| |
| |
| main() { |
| unittest.group("obj-schema-ReconcileCandidateNotable", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildReconcileCandidateNotable(); |
| var od = new api.ReconcileCandidateNotable.fromJson(o.toJson()); |
| checkReconcileCandidateNotable(od); |
| }); |
| }); |
| |
| |
| unittest.group("obj-schema-ReconcileCandidate", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildReconcileCandidate(); |
| var od = new api.ReconcileCandidate.fromJson(o.toJson()); |
| checkReconcileCandidate(od); |
| }); |
| }); |
| |
| |
| unittest.group("obj-schema-ReconcileGetCosts", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildReconcileGetCosts(); |
| var od = new api.ReconcileGetCosts.fromJson(o.toJson()); |
| checkReconcileGetCosts(od); |
| }); |
| }); |
| |
| |
| unittest.group("obj-schema-ReconcileGetWarning", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildReconcileGetWarning(); |
| var od = new api.ReconcileGetWarning.fromJson(o.toJson()); |
| checkReconcileGetWarning(od); |
| }); |
| }); |
| |
| |
| unittest.group("obj-schema-ReconcileGet", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildReconcileGet(); |
| var od = new api.ReconcileGet.fromJson(o.toJson()); |
| checkReconcileGet(od); |
| }); |
| }); |
| |
| |
| unittest.group("resource-FreebaseApi", () { |
| unittest.test("method--reconcile", () { |
| |
| var mock = new common_test.HttpServerMock(); |
| api.FreebaseApi res = new api.FreebaseApi(mock); |
| var arg_confidence = 42.0; |
| var arg_kind = buildUnnamed768(); |
| var arg_lang = buildUnnamed769(); |
| var arg_limit = 42; |
| var arg_name = "foo"; |
| var arg_prop = buildUnnamed770(); |
| 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 + 12), unittest.equals("freebase/v1/")); |
| pathOffset += 12; |
| unittest.expect(path.substring(pathOffset, pathOffset + 9), unittest.equals("reconcile")); |
| pathOffset += 9; |
| |
| 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.num.parse(queryMap["confidence"].first), unittest.equals(arg_confidence)); |
| unittest.expect(queryMap["kind"], unittest.equals(arg_kind)); |
| unittest.expect(queryMap["lang"], unittest.equals(arg_lang)); |
| unittest.expect(core.int.parse(queryMap["limit"].first), unittest.equals(arg_limit)); |
| unittest.expect(queryMap["name"].first, unittest.equals(arg_name)); |
| unittest.expect(queryMap["prop"], unittest.equals(arg_prop)); |
| |
| |
| var h = { |
| "content-type" : "application/json; charset=utf-8", |
| }; |
| var resp = convert.JSON.encode(buildReconcileGet()); |
| return new async.Future.value(common_test.stringResponse(200, h, resp)); |
| }), true); |
| res.reconcile(confidence: arg_confidence, kind: arg_kind, lang: arg_lang, limit: arg_limit, name: arg_name, prop: arg_prop).then(unittest.expectAsync(((api.ReconcileGet response) { |
| checkReconcileGet(response); |
| }))); |
| }); |
| |
| unittest.test("method--search", () { |
| // TODO: Implement tests for media upload; |
| // TODO: Implement tests for media download; |
| |
| var mock = new common_test.HttpServerMock(); |
| api.FreebaseApi res = new api.FreebaseApi(mock); |
| var arg_asOfTime = "foo"; |
| var arg_callback = "foo"; |
| var arg_cursor = 42; |
| var arg_domain = buildUnnamed771(); |
| var arg_encode = "foo"; |
| var arg_exact = true; |
| var arg_filter = buildUnnamed772(); |
| var arg_format = "foo"; |
| var arg_help = "foo"; |
| var arg_indent = true; |
| var arg_lang = buildUnnamed773(); |
| var arg_limit = 42; |
| var arg_mid = buildUnnamed774(); |
| var arg_mqlOutput = "foo"; |
| var arg_output = "foo"; |
| var arg_prefixed = true; |
| var arg_query = "foo"; |
| var arg_scoring = "foo"; |
| var arg_spell = "foo"; |
| var arg_stemmed = true; |
| var arg_type = buildUnnamed775(); |
| var arg_with_ = buildUnnamed776(); |
| var arg_without = buildUnnamed777(); |
| 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 + 12), unittest.equals("freebase/v1/")); |
| pathOffset += 12; |
| unittest.expect(path.substring(pathOffset, pathOffset + 6), unittest.equals("search")); |
| pathOffset += 6; |
| |
| 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["as_of_time"].first, unittest.equals(arg_asOfTime)); |
| unittest.expect(queryMap["callback"].first, unittest.equals(arg_callback)); |
| unittest.expect(core.int.parse(queryMap["cursor"].first), unittest.equals(arg_cursor)); |
| unittest.expect(queryMap["domain"], unittest.equals(arg_domain)); |
| unittest.expect(queryMap["encode"].first, unittest.equals(arg_encode)); |
| unittest.expect(queryMap["exact"].first, unittest.equals("$arg_exact")); |
| unittest.expect(queryMap["filter"], unittest.equals(arg_filter)); |
| unittest.expect(queryMap["format"].first, unittest.equals(arg_format)); |
| unittest.expect(queryMap["help"].first, unittest.equals(arg_help)); |
| unittest.expect(queryMap["indent"].first, unittest.equals("$arg_indent")); |
| unittest.expect(queryMap["lang"], unittest.equals(arg_lang)); |
| unittest.expect(core.int.parse(queryMap["limit"].first), unittest.equals(arg_limit)); |
| unittest.expect(queryMap["mid"], unittest.equals(arg_mid)); |
| unittest.expect(queryMap["mql_output"].first, unittest.equals(arg_mqlOutput)); |
| unittest.expect(queryMap["output"].first, unittest.equals(arg_output)); |
| unittest.expect(queryMap["prefixed"].first, unittest.equals("$arg_prefixed")); |
| unittest.expect(queryMap["query"].first, unittest.equals(arg_query)); |
| unittest.expect(queryMap["scoring"].first, unittest.equals(arg_scoring)); |
| unittest.expect(queryMap["spell"].first, unittest.equals(arg_spell)); |
| unittest.expect(queryMap["stemmed"].first, unittest.equals("$arg_stemmed")); |
| unittest.expect(queryMap["type"], unittest.equals(arg_type)); |
| unittest.expect(queryMap["with"], unittest.equals(arg_with_)); |
| unittest.expect(queryMap["without"], unittest.equals(arg_without)); |
| |
| |
| var h = { |
| "content-type" : "application/json; charset=utf-8", |
| }; |
| var resp = ""; |
| return new async.Future.value(common_test.stringResponse(200, h, resp)); |
| }), true); |
| res.search(asOfTime: arg_asOfTime, callback: arg_callback, cursor: arg_cursor, domain: arg_domain, encode: arg_encode, exact: arg_exact, filter: arg_filter, format: arg_format, help: arg_help, indent: arg_indent, lang: arg_lang, limit: arg_limit, mid: arg_mid, mqlOutput: arg_mqlOutput, output: arg_output, prefixed: arg_prefixed, query: arg_query, scoring: arg_scoring, spell: arg_spell, stemmed: arg_stemmed, type: arg_type, with_: arg_with_, without: arg_without).then(unittest.expectAsync((_) {})); |
| }); |
| |
| }); |
| |
| |
| } |
| |