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

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

Issue 2649893002: Api-roll 44: 2017-01-23 (Closed)
Patch Set: Created 3 years, 11 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
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.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.itemListElement = buildUnnamed861(); 74 o.itemListElement = buildUnnamed861();
74 o.type = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'};
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.context) as core.Map; unittest.expect(casted3, unittest.has Length(3)); unittest.expect(casted3["list"], unittest.equals([1, 2, 3])); unitte st.expect(casted3["bool"], unittest.equals(true)); unittest.expect(casted3["stri ng"], 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 checkUnnamed861(o.itemListElement); 85 checkUnnamed861(o.itemListElement);
85 var casted4 = (o.type) as core.Map; unittest.expect(casted4, unittest.hasLen gth(3)); unittest.expect(casted4["list"], unittest.equals([1, 2, 3])); unittest. expect(casted4["bool"], unittest.equals(true)); unittest.expect(casted4["string" ], unittest.equals('foo'));
86 } 86 }
87 buildCounterSearchResponse--; 87 buildCounterSearchResponse--;
88 } 88 }
89 89
90 buildUnnamed862() { 90 buildUnnamed862() {
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 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_limit = 42;
146 var arg_ids = buildUnnamed862();
147 var arg_prefix = true;
145 var arg_query = "foo"; 148 var arg_query = "foo";
146 var arg_ids = buildUnnamed862();
147 var arg_languages = buildUnnamed863();
148 var arg_types = buildUnnamed864();
149 var arg_indent = true; 149 var arg_indent = true;
150 var arg_prefix = true; 150 var arg_types = buildUnnamed863();
151 var arg_limit = 42; 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(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") );
178 unittest.expect(queryMap["query"].first, unittest.equals(arg_query)); 181 unittest.expect(queryMap["query"].first, unittest.equals(arg_query));
179 unittest.expect(queryMap["ids"], unittest.equals(arg_ids)); 182 unittest.expect(queryMap["indent"].first, unittest.equals("$arg_indent") );
183 unittest.expect(queryMap["types"], unittest.equals(arg_types));
180 unittest.expect(queryMap["languages"], unittest.equals(arg_languages)); 184 unittest.expect(queryMap["languages"], unittest.equals(arg_languages));
181 unittest.expect(queryMap["types"], unittest.equals(arg_types));
182 unittest.expect(queryMap["indent"].first, unittest.equals("$arg_indent") );
183 unittest.expect(queryMap["prefix"].first, unittest.equals("$arg_prefix") );
184 unittest.expect(core.int.parse(queryMap["limit"].first), unittest.equals (arg_limit));
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(query: arg_query, ids: arg_ids, languages: arg_languages, types : arg_types, indent: arg_indent, prefix: arg_prefix, limit: arg_limit).then(unit test.expectAsync(((api.SearchResponse response) { 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) {
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/logging/v2_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698