| OLD | NEW |
| 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 Loading... |
| 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 buildUnnamed1084() { | 54 buildUnnamed1110() { |
| 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 checkUnnamed1084(core.List<core.Object> o) { | 61 checkUnnamed1110(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.context = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; | 72 o.context = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; |
| 73 o.itemListElement = buildUnnamed1084(); | 73 o.itemListElement = buildUnnamed1110(); |
| 74 o.type = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; | 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.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')); |
| 84 checkUnnamed1084(o.itemListElement); | 84 checkUnnamed1110(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')); | 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 buildUnnamed1085() { | 90 buildUnnamed1111() { |
| 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 checkUnnamed1085(core.List<core.String> o) { | 97 checkUnnamed1111(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 buildUnnamed1086() { | 103 buildUnnamed1112() { |
| 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 checkUnnamed1086(core.List<core.String> o) { | 110 checkUnnamed1112(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 buildUnnamed1087() { | 116 buildUnnamed1113() { |
| 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 checkUnnamed1087(core.List<core.String> o) { | 123 checkUnnamed1113(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_query = "foo"; | 145 var arg_query = "foo"; |
| 146 var arg_ids = buildUnnamed1085(); | 146 var arg_ids = buildUnnamed1111(); |
| 147 var arg_languages = buildUnnamed1086(); | 147 var arg_languages = buildUnnamed1112(); |
| 148 var arg_types = buildUnnamed1087(); | 148 var arg_types = buildUnnamed1113(); |
| 149 var arg_indent = true; | 149 var arg_indent = true; |
| 150 var arg_prefix = true; | 150 var arg_prefix = true; |
| 151 var arg_limit = 42; | 151 var arg_limit = 42; |
| 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; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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(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) { |
| 194 checkSearchResponse(response); | 194 checkSearchResponse(response); |
| 195 }))); | 195 }))); |
| 196 }); | 196 }); |
| 197 | 197 |
| 198 }); | 198 }); |
| 199 | 199 |
| 200 | 200 |
| 201 } | 201 } |
| 202 | 202 |
| OLD | NEW |