Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(982)

Side by Side Diff: generated/googleapis/test/kgsearch/v1_test.dart

Issue 2695743002: Api-roll 45: 2017-02-13 (Closed)
Patch Set: reverted local changes to pubspec file Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 library googleapis.kgsearch.v1.test; 1 library googleapis.kgsearch.v1.test;
2 2
3 import "dart:core" as core; 3 import "dart:core" as core;
4 import "dart:collection" as collection; 4 import "dart:collection" as collection;
5 import "dart:async" as async; 5 import "dart:async" as async;
6 import "dart:convert" as convert; 6 import "dart:convert" as convert;
7 7
8 import 'package:http/http.dart' as http; 8 import 'package:http/http.dart' as http;
9 import 'package:http/testing.dart' as http_testing; 9 import 'package:http/testing.dart' as http_testing;
10 import 'package:unittest/unittest.dart' as unittest; 10 import 'package:unittest/unittest.dart' as unittest;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 } 44 }
45 } 45 }
46 } 46 }
47 47
48 http.StreamedResponse stringResponse( 48 http.StreamedResponse stringResponse(
49 core.int status, core.Map headers, core.String body) { 49 core.int status, core.Map headers, core.String body) {
50 var stream = new async.Stream.fromIterable([convert.UTF8.encode(body)]); 50 var stream = new async.Stream.fromIterable([convert.UTF8.encode(body)]);
51 return new http.StreamedResponse(stream, status, headers: headers); 51 return new http.StreamedResponse(stream, status, headers: headers);
52 } 52 }
53 53
54 buildUnnamed861() { 54 buildUnnamed868() {
55 var o = new core.List<core.Object>(); 55 var o = new core.List<core.Object>();
56 o.add({'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}); 56 o.add({'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'});
57 o.add({'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}); 57 o.add({'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'});
58 return o; 58 return o;
59 } 59 }
60 60
61 checkUnnamed861(core.List<core.Object> o) { 61 checkUnnamed868(core.List<core.Object> o) {
62 unittest.expect(o, unittest.hasLength(2)); 62 unittest.expect(o, unittest.hasLength(2));
63 var casted1 = (o[0]) as core.Map; unittest.expect(casted1, unittest.hasLength( 3)); unittest.expect(casted1["list"], unittest.equals([1, 2, 3])); unittest.expe ct(casted1["bool"], unittest.equals(true)); unittest.expect(casted1["string"], u nittest.equals('foo')); 63 var casted1 = (o[0]) as core.Map; unittest.expect(casted1, unittest.hasLength( 3)); unittest.expect(casted1["list"], unittest.equals([1, 2, 3])); unittest.expe ct(casted1["bool"], unittest.equals(true)); unittest.expect(casted1["string"], u nittest.equals('foo'));
64 var casted2 = (o[1]) as core.Map; unittest.expect(casted2, unittest.hasLength( 3)); unittest.expect(casted2["list"], unittest.equals([1, 2, 3])); unittest.expe ct(casted2["bool"], unittest.equals(true)); unittest.expect(casted2["string"], u nittest.equals('foo')); 64 var casted2 = (o[1]) as core.Map; unittest.expect(casted2, unittest.hasLength( 3)); unittest.expect(casted2["list"], unittest.equals([1, 2, 3])); unittest.expe ct(casted2["bool"], unittest.equals(true)); unittest.expect(casted2["string"], u nittest.equals('foo'));
65 } 65 }
66 66
67 core.int buildCounterSearchResponse = 0; 67 core.int buildCounterSearchResponse = 0;
68 buildSearchResponse() { 68 buildSearchResponse() {
69 var o = new api.SearchResponse(); 69 var o = new api.SearchResponse();
70 buildCounterSearchResponse++; 70 buildCounterSearchResponse++;
71 if (buildCounterSearchResponse < 3) { 71 if (buildCounterSearchResponse < 3) {
72 o.P_context = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; 72 o.P_context = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'};
73 o.P_type = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; 73 o.P_type = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'};
74 o.itemListElement = buildUnnamed861(); 74 o.itemListElement = buildUnnamed868();
75 } 75 }
76 buildCounterSearchResponse--; 76 buildCounterSearchResponse--;
77 return o; 77 return o;
78 } 78 }
79 79
80 checkSearchResponse(api.SearchResponse o) { 80 checkSearchResponse(api.SearchResponse o) {
81 buildCounterSearchResponse++; 81 buildCounterSearchResponse++;
82 if (buildCounterSearchResponse < 3) { 82 if (buildCounterSearchResponse < 3) {
83 var casted3 = (o.P_context) as core.Map; unittest.expect(casted3, unittest.h asLength(3)); unittest.expect(casted3["list"], unittest.equals([1, 2, 3])); unit test.expect(casted3["bool"], unittest.equals(true)); unittest.expect(casted3["st ring"], unittest.equals('foo')); 83 var casted3 = (o.P_context) as core.Map; unittest.expect(casted3, unittest.h asLength(3)); unittest.expect(casted3["list"], unittest.equals([1, 2, 3])); unit test.expect(casted3["bool"], unittest.equals(true)); unittest.expect(casted3["st ring"], unittest.equals('foo'));
84 var casted4 = (o.P_type) as core.Map; unittest.expect(casted4, unittest.hasL ength(3)); unittest.expect(casted4["list"], unittest.equals([1, 2, 3])); unittes t.expect(casted4["bool"], unittest.equals(true)); unittest.expect(casted4["strin g"], unittest.equals('foo')); 84 var casted4 = (o.P_type) as core.Map; unittest.expect(casted4, unittest.hasL ength(3)); unittest.expect(casted4["list"], unittest.equals([1, 2, 3])); unittes t.expect(casted4["bool"], unittest.equals(true)); unittest.expect(casted4["strin g"], unittest.equals('foo'));
85 checkUnnamed861(o.itemListElement); 85 checkUnnamed868(o.itemListElement);
86 } 86 }
87 buildCounterSearchResponse--; 87 buildCounterSearchResponse--;
88 } 88 }
89 89
90 buildUnnamed862() { 90 buildUnnamed869() {
91 var o = new core.List<core.String>(); 91 var o = new core.List<core.String>();
92 o.add("foo"); 92 o.add("foo");
93 o.add("foo"); 93 o.add("foo");
94 return o; 94 return o;
95 } 95 }
96 96
97 checkUnnamed862(core.List<core.String> o) { 97 checkUnnamed869(core.List<core.String> o) {
98 unittest.expect(o, unittest.hasLength(2)); 98 unittest.expect(o, unittest.hasLength(2));
99 unittest.expect(o[0], unittest.equals('foo')); 99 unittest.expect(o[0], unittest.equals('foo'));
100 unittest.expect(o[1], unittest.equals('foo')); 100 unittest.expect(o[1], unittest.equals('foo'));
101 } 101 }
102 102
103 buildUnnamed863() { 103 buildUnnamed870() {
104 var o = new core.List<core.String>(); 104 var o = new core.List<core.String>();
105 o.add("foo"); 105 o.add("foo");
106 o.add("foo"); 106 o.add("foo");
107 return o; 107 return o;
108 } 108 }
109 109
110 checkUnnamed863(core.List<core.String> o) { 110 checkUnnamed870(core.List<core.String> o) {
111 unittest.expect(o, unittest.hasLength(2)); 111 unittest.expect(o, unittest.hasLength(2));
112 unittest.expect(o[0], unittest.equals('foo')); 112 unittest.expect(o[0], unittest.equals('foo'));
113 unittest.expect(o[1], unittest.equals('foo')); 113 unittest.expect(o[1], unittest.equals('foo'));
114 } 114 }
115 115
116 buildUnnamed864() { 116 buildUnnamed871() {
117 var o = new core.List<core.String>(); 117 var o = new core.List<core.String>();
118 o.add("foo"); 118 o.add("foo");
119 o.add("foo"); 119 o.add("foo");
120 return o; 120 return o;
121 } 121 }
122 122
123 checkUnnamed864(core.List<core.String> o) { 123 checkUnnamed871(core.List<core.String> o) {
124 unittest.expect(o, unittest.hasLength(2)); 124 unittest.expect(o, unittest.hasLength(2));
125 unittest.expect(o[0], unittest.equals('foo')); 125 unittest.expect(o[0], unittest.equals('foo'));
126 unittest.expect(o[1], unittest.equals('foo')); 126 unittest.expect(o[1], unittest.equals('foo'));
127 } 127 }
128 128
129 129
130 main() { 130 main() {
131 unittest.group("obj-schema-SearchResponse", () { 131 unittest.group("obj-schema-SearchResponse", () {
132 unittest.test("to-json--from-json", () { 132 unittest.test("to-json--from-json", () {
133 var o = buildSearchResponse(); 133 var o = buildSearchResponse();
134 var od = new api.SearchResponse.fromJson(o.toJson()); 134 var od = new api.SearchResponse.fromJson(o.toJson());
135 checkSearchResponse(od); 135 checkSearchResponse(od);
136 }); 136 });
137 }); 137 });
138 138
139 139
140 unittest.group("resource-EntitiesResourceApi", () { 140 unittest.group("resource-EntitiesResourceApi", () {
141 unittest.test("method--search", () { 141 unittest.test("method--search", () {
142 142
143 var mock = new HttpServerMock(); 143 var mock = new HttpServerMock();
144 api.EntitiesResourceApi res = new api.KgsearchApi(mock).entities; 144 api.EntitiesResourceApi res = new api.KgsearchApi(mock).entities;
145 var arg_ids = buildUnnamed869();
145 var arg_limit = 42; 146 var arg_limit = 42;
146 var arg_ids = buildUnnamed862();
147 var arg_prefix = true; 147 var arg_prefix = true;
148 var arg_query = "foo"; 148 var arg_query = "foo";
149 var arg_types = buildUnnamed870();
149 var arg_indent = true; 150 var arg_indent = true;
150 var arg_types = buildUnnamed863(); 151 var arg_languages = buildUnnamed871();
151 var arg_languages = buildUnnamed864();
152 mock.register(unittest.expectAsync((http.BaseRequest req, json) { 152 mock.register(unittest.expectAsync((http.BaseRequest req, json) {
153 var path = (req.url).path; 153 var path = (req.url).path;
154 var pathOffset = 0; 154 var pathOffset = 0;
155 var index; 155 var index;
156 var subPart; 156 var subPart;
157 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ als("/")); 157 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ als("/"));
158 pathOffset += 1; 158 pathOffset += 1;
159 unittest.expect(path.substring(pathOffset, pathOffset + 18), unittest.eq uals("v1/entities:search")); 159 unittest.expect(path.substring(pathOffset, pathOffset + 18), unittest.eq uals("v1/entities:search"));
160 pathOffset += 18; 160 pathOffset += 18;
161 161
162 var query = (req.url).query; 162 var query = (req.url).query;
163 var queryOffset = 0; 163 var queryOffset = 0;
164 var queryMap = {}; 164 var queryMap = {};
165 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); 165 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
166 parseBool(n) { 166 parseBool(n) {
167 if (n == "true") return true; 167 if (n == "true") return true;
168 if (n == "false") return false; 168 if (n == "false") return false;
169 if (n == null) return null; 169 if (n == null) return null;
170 throw new core.ArgumentError("Invalid boolean: $n"); 170 throw new core.ArgumentError("Invalid boolean: $n");
171 } 171 }
172 if (query.length > 0) { 172 if (query.length > 0) {
173 for (var part in query.split("&")) { 173 for (var part in query.split("&")) {
174 var keyvalue = part.split("="); 174 var keyvalue = part.split("=");
175 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d ecodeQueryComponent(keyvalue[1])); 175 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d ecodeQueryComponent(keyvalue[1]));
176 } 176 }
177 } 177 }
178 unittest.expect(queryMap["ids"], unittest.equals(arg_ids));
178 unittest.expect(core.int.parse(queryMap["limit"].first), unittest.equals (arg_limit)); 179 unittest.expect(core.int.parse(queryMap["limit"].first), unittest.equals (arg_limit));
179 unittest.expect(queryMap["ids"], unittest.equals(arg_ids));
180 unittest.expect(queryMap["prefix"].first, unittest.equals("$arg_prefix") ); 180 unittest.expect(queryMap["prefix"].first, unittest.equals("$arg_prefix") );
181 unittest.expect(queryMap["query"].first, unittest.equals(arg_query)); 181 unittest.expect(queryMap["query"].first, unittest.equals(arg_query));
182 unittest.expect(queryMap["types"], unittest.equals(arg_types));
182 unittest.expect(queryMap["indent"].first, unittest.equals("$arg_indent") ); 183 unittest.expect(queryMap["indent"].first, unittest.equals("$arg_indent") );
183 unittest.expect(queryMap["types"], unittest.equals(arg_types));
184 unittest.expect(queryMap["languages"], unittest.equals(arg_languages)); 184 unittest.expect(queryMap["languages"], unittest.equals(arg_languages));
185 185
186 186
187 var h = { 187 var h = {
188 "content-type" : "application/json; charset=utf-8", 188 "content-type" : "application/json; charset=utf-8",
189 }; 189 };
190 var resp = convert.JSON.encode(buildSearchResponse()); 190 var resp = convert.JSON.encode(buildSearchResponse());
191 return new async.Future.value(stringResponse(200, h, resp)); 191 return new async.Future.value(stringResponse(200, h, resp));
192 }), true); 192 }), true);
193 res.search(limit: arg_limit, ids: arg_ids, prefix: arg_prefix, query: arg_ query, indent: arg_indent, types: arg_types, languages: arg_languages).then(unit test.expectAsync(((api.SearchResponse response) { 193 res.search(ids: arg_ids, limit: arg_limit, prefix: arg_prefix, query: arg_ query, types: arg_types, indent: arg_indent, languages: arg_languages).then(unit test.expectAsync(((api.SearchResponse response) {
194 checkSearchResponse(response); 194 checkSearchResponse(response);
195 }))); 195 })));
196 }); 196 });
197 197
198 }); 198 });
199 199
200 200
201 } 201 }
202 202
OLDNEW
« no previous file with comments | « generated/googleapis/test/identitytoolkit/v3_test.dart ('k') | generated/googleapis/test/language/v1_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698