blob: f567ad25cc89977a58dbede0b0a6c49d03c07ac7 [file] [log] [blame]
// ignore_for_file: camel_case_types
// ignore_for_file: comment_references
// ignore_for_file: constant_identifier_names
// ignore_for_file: directives_ordering
// ignore_for_file: file_names
// ignore_for_file: library_names
// ignore_for_file: lines_longer_than_80_chars
// ignore_for_file: non_constant_identifier_names
// ignore_for_file: omit_local_variable_types
// ignore_for_file: prefer_expression_function_bodies
// ignore_for_file: prefer_final_locals
// ignore_for_file: prefer_interpolation_to_compose_strings
// ignore_for_file: unnecessary_brace_in_string_interps
// ignore_for_file: unnecessary_cast
// ignore_for_file: unnecessary_lambdas
// ignore_for_file: unnecessary_parenthesis
// ignore_for_file: unnecessary_string_interpolations
// ignore_for_file: avoid_returning_null
// ignore_for_file: cascade_invocations
// ignore_for_file: prefer_single_quotes
// ignore_for_file: unused_local_variable
library googleapis.translate.v3.test;
import "dart:core" as core;
import "dart:async" as async;
import "dart:convert" as convert;
import 'package:http/http.dart' as http;
import 'package:test/test.dart' as unittest;
import 'package:googleapis/translate/v3.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;
}
@core.override
async.Future<http.StreamedResponse> send(http.BaseRequest request) async {
if (_expectJson) {
final jsonString =
await request.finalize().transform(convert.utf8.decoder).join('');
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 {
final data = await stream.toBytes();
return _callback(request, data);
}
}
}
}
http.StreamedResponse stringResponse(core.int status,
core.Map<core.String, core.String> headers, core.String body) {
var stream = async.Stream.fromIterable([convert.utf8.encode(body)]);
return http.StreamedResponse(stream, status, headers: headers);
}
core.Map<core.String, api.TranslateTextGlossaryConfig> buildUnnamed5103() {
var o = <core.String, api.TranslateTextGlossaryConfig>{};
o['x'] = buildTranslateTextGlossaryConfig();
o['y'] = buildTranslateTextGlossaryConfig();
return o;
}
void checkUnnamed5103(
core.Map<core.String, api.TranslateTextGlossaryConfig> o) {
unittest.expect(o, unittest.hasLength(2));
checkTranslateTextGlossaryConfig(o['x']);
checkTranslateTextGlossaryConfig(o['y']);
}
core.List<api.InputConfig> buildUnnamed5104() {
var o = <api.InputConfig>[];
o.add(buildInputConfig());
o.add(buildInputConfig());
return o;
}
void checkUnnamed5104(core.List<api.InputConfig> o) {
unittest.expect(o, unittest.hasLength(2));
checkInputConfig(o[0]);
checkInputConfig(o[1]);
}
core.Map<core.String, core.String> buildUnnamed5105() {
var o = <core.String, core.String>{};
o['x'] = 'foo';
o['y'] = 'foo';
return o;
}
void checkUnnamed5105(core.Map<core.String, core.String> o) {
unittest.expect(o, unittest.hasLength(2));
unittest.expect(o['x'], unittest.equals('foo'));
unittest.expect(o['y'], unittest.equals('foo'));
}
core.Map<core.String, core.String> buildUnnamed5106() {
var o = <core.String, core.String>{};
o['x'] = 'foo';
o['y'] = 'foo';
return o;
}
void checkUnnamed5106(core.Map<core.String, core.String> o) {
unittest.expect(o, unittest.hasLength(2));
unittest.expect(o['x'], unittest.equals('foo'));
unittest.expect(o['y'], unittest.equals('foo'));
}
core.List<core.String> buildUnnamed5107() {
var o = <core.String>[];
o.add('foo');
o.add('foo');
return o;
}
void checkUnnamed5107(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 buildCounterBatchTranslateTextRequest = 0;
api.BatchTranslateTextRequest buildBatchTranslateTextRequest() {
var o = api.BatchTranslateTextRequest();
buildCounterBatchTranslateTextRequest++;
if (buildCounterBatchTranslateTextRequest < 3) {
o.glossaries = buildUnnamed5103();
o.inputConfigs = buildUnnamed5104();
o.labels = buildUnnamed5105();
o.models = buildUnnamed5106();
o.outputConfig = buildOutputConfig();
o.sourceLanguageCode = 'foo';
o.targetLanguageCodes = buildUnnamed5107();
}
buildCounterBatchTranslateTextRequest--;
return o;
}
void checkBatchTranslateTextRequest(api.BatchTranslateTextRequest o) {
buildCounterBatchTranslateTextRequest++;
if (buildCounterBatchTranslateTextRequest < 3) {
checkUnnamed5103(o.glossaries);
checkUnnamed5104(o.inputConfigs);
checkUnnamed5105(o.labels);
checkUnnamed5106(o.models);
checkOutputConfig(o.outputConfig);
unittest.expect(o.sourceLanguageCode, unittest.equals('foo'));
checkUnnamed5107(o.targetLanguageCodes);
}
buildCounterBatchTranslateTextRequest--;
}
core.int buildCounterCancelOperationRequest = 0;
api.CancelOperationRequest buildCancelOperationRequest() {
var o = api.CancelOperationRequest();
buildCounterCancelOperationRequest++;
if (buildCounterCancelOperationRequest < 3) {}
buildCounterCancelOperationRequest--;
return o;
}
void checkCancelOperationRequest(api.CancelOperationRequest o) {
buildCounterCancelOperationRequest++;
if (buildCounterCancelOperationRequest < 3) {}
buildCounterCancelOperationRequest--;
}
core.Map<core.String, core.String> buildUnnamed5108() {
var o = <core.String, core.String>{};
o['x'] = 'foo';
o['y'] = 'foo';
return o;
}
void checkUnnamed5108(core.Map<core.String, core.String> o) {
unittest.expect(o, unittest.hasLength(2));
unittest.expect(o['x'], unittest.equals('foo'));
unittest.expect(o['y'], unittest.equals('foo'));
}
core.int buildCounterDetectLanguageRequest = 0;
api.DetectLanguageRequest buildDetectLanguageRequest() {
var o = api.DetectLanguageRequest();
buildCounterDetectLanguageRequest++;
if (buildCounterDetectLanguageRequest < 3) {
o.content = 'foo';
o.labels = buildUnnamed5108();
o.mimeType = 'foo';
o.model = 'foo';
}
buildCounterDetectLanguageRequest--;
return o;
}
void checkDetectLanguageRequest(api.DetectLanguageRequest o) {
buildCounterDetectLanguageRequest++;
if (buildCounterDetectLanguageRequest < 3) {
unittest.expect(o.content, unittest.equals('foo'));
checkUnnamed5108(o.labels);
unittest.expect(o.mimeType, unittest.equals('foo'));
unittest.expect(o.model, unittest.equals('foo'));
}
buildCounterDetectLanguageRequest--;
}
core.List<api.DetectedLanguage> buildUnnamed5109() {
var o = <api.DetectedLanguage>[];
o.add(buildDetectedLanguage());
o.add(buildDetectedLanguage());
return o;
}
void checkUnnamed5109(core.List<api.DetectedLanguage> o) {
unittest.expect(o, unittest.hasLength(2));
checkDetectedLanguage(o[0]);
checkDetectedLanguage(o[1]);
}
core.int buildCounterDetectLanguageResponse = 0;
api.DetectLanguageResponse buildDetectLanguageResponse() {
var o = api.DetectLanguageResponse();
buildCounterDetectLanguageResponse++;
if (buildCounterDetectLanguageResponse < 3) {
o.languages = buildUnnamed5109();
}
buildCounterDetectLanguageResponse--;
return o;
}
void checkDetectLanguageResponse(api.DetectLanguageResponse o) {
buildCounterDetectLanguageResponse++;
if (buildCounterDetectLanguageResponse < 3) {
checkUnnamed5109(o.languages);
}
buildCounterDetectLanguageResponse--;
}
core.int buildCounterDetectedLanguage = 0;
api.DetectedLanguage buildDetectedLanguage() {
var o = api.DetectedLanguage();
buildCounterDetectedLanguage++;
if (buildCounterDetectedLanguage < 3) {
o.confidence = 42.0;
o.languageCode = 'foo';
}
buildCounterDetectedLanguage--;
return o;
}
void checkDetectedLanguage(api.DetectedLanguage o) {
buildCounterDetectedLanguage++;
if (buildCounterDetectedLanguage < 3) {
unittest.expect(o.confidence, unittest.equals(42.0));
unittest.expect(o.languageCode, unittest.equals('foo'));
}
buildCounterDetectedLanguage--;
}
core.int buildCounterEmpty = 0;
api.Empty buildEmpty() {
var o = api.Empty();
buildCounterEmpty++;
if (buildCounterEmpty < 3) {}
buildCounterEmpty--;
return o;
}
void checkEmpty(api.Empty o) {
buildCounterEmpty++;
if (buildCounterEmpty < 3) {}
buildCounterEmpty--;
}
core.int buildCounterGcsDestination = 0;
api.GcsDestination buildGcsDestination() {
var o = api.GcsDestination();
buildCounterGcsDestination++;
if (buildCounterGcsDestination < 3) {
o.outputUriPrefix = 'foo';
}
buildCounterGcsDestination--;
return o;
}
void checkGcsDestination(api.GcsDestination o) {
buildCounterGcsDestination++;
if (buildCounterGcsDestination < 3) {
unittest.expect(o.outputUriPrefix, unittest.equals('foo'));
}
buildCounterGcsDestination--;
}
core.int buildCounterGcsSource = 0;
api.GcsSource buildGcsSource() {
var o = api.GcsSource();
buildCounterGcsSource++;
if (buildCounterGcsSource < 3) {
o.inputUri = 'foo';
}
buildCounterGcsSource--;
return o;
}
void checkGcsSource(api.GcsSource o) {
buildCounterGcsSource++;
if (buildCounterGcsSource < 3) {
unittest.expect(o.inputUri, unittest.equals('foo'));
}
buildCounterGcsSource--;
}
core.int buildCounterGlossary = 0;
api.Glossary buildGlossary() {
var o = api.Glossary();
buildCounterGlossary++;
if (buildCounterGlossary < 3) {
o.endTime = 'foo';
o.entryCount = 42;
o.inputConfig = buildGlossaryInputConfig();
o.languageCodesSet = buildLanguageCodesSet();
o.languagePair = buildLanguageCodePair();
o.name = 'foo';
o.submitTime = 'foo';
}
buildCounterGlossary--;
return o;
}
void checkGlossary(api.Glossary o) {
buildCounterGlossary++;
if (buildCounterGlossary < 3) {
unittest.expect(o.endTime, unittest.equals('foo'));
unittest.expect(o.entryCount, unittest.equals(42));
checkGlossaryInputConfig(o.inputConfig);
checkLanguageCodesSet(o.languageCodesSet);
checkLanguageCodePair(o.languagePair);
unittest.expect(o.name, unittest.equals('foo'));
unittest.expect(o.submitTime, unittest.equals('foo'));
}
buildCounterGlossary--;
}
core.int buildCounterGlossaryInputConfig = 0;
api.GlossaryInputConfig buildGlossaryInputConfig() {
var o = api.GlossaryInputConfig();
buildCounterGlossaryInputConfig++;
if (buildCounterGlossaryInputConfig < 3) {
o.gcsSource = buildGcsSource();
}
buildCounterGlossaryInputConfig--;
return o;
}
void checkGlossaryInputConfig(api.GlossaryInputConfig o) {
buildCounterGlossaryInputConfig++;
if (buildCounterGlossaryInputConfig < 3) {
checkGcsSource(o.gcsSource);
}
buildCounterGlossaryInputConfig--;
}
core.int buildCounterInputConfig = 0;
api.InputConfig buildInputConfig() {
var o = api.InputConfig();
buildCounterInputConfig++;
if (buildCounterInputConfig < 3) {
o.gcsSource = buildGcsSource();
o.mimeType = 'foo';
}
buildCounterInputConfig--;
return o;
}
void checkInputConfig(api.InputConfig o) {
buildCounterInputConfig++;
if (buildCounterInputConfig < 3) {
checkGcsSource(o.gcsSource);
unittest.expect(o.mimeType, unittest.equals('foo'));
}
buildCounterInputConfig--;
}
core.int buildCounterLanguageCodePair = 0;
api.LanguageCodePair buildLanguageCodePair() {
var o = api.LanguageCodePair();
buildCounterLanguageCodePair++;
if (buildCounterLanguageCodePair < 3) {
o.sourceLanguageCode = 'foo';
o.targetLanguageCode = 'foo';
}
buildCounterLanguageCodePair--;
return o;
}
void checkLanguageCodePair(api.LanguageCodePair o) {
buildCounterLanguageCodePair++;
if (buildCounterLanguageCodePair < 3) {
unittest.expect(o.sourceLanguageCode, unittest.equals('foo'));
unittest.expect(o.targetLanguageCode, unittest.equals('foo'));
}
buildCounterLanguageCodePair--;
}
core.List<core.String> buildUnnamed5110() {
var o = <core.String>[];
o.add('foo');
o.add('foo');
return o;
}
void checkUnnamed5110(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 buildCounterLanguageCodesSet = 0;
api.LanguageCodesSet buildLanguageCodesSet() {
var o = api.LanguageCodesSet();
buildCounterLanguageCodesSet++;
if (buildCounterLanguageCodesSet < 3) {
o.languageCodes = buildUnnamed5110();
}
buildCounterLanguageCodesSet--;
return o;
}
void checkLanguageCodesSet(api.LanguageCodesSet o) {
buildCounterLanguageCodesSet++;
if (buildCounterLanguageCodesSet < 3) {
checkUnnamed5110(o.languageCodes);
}
buildCounterLanguageCodesSet--;
}
core.List<api.Glossary> buildUnnamed5111() {
var o = <api.Glossary>[];
o.add(buildGlossary());
o.add(buildGlossary());
return o;
}
void checkUnnamed5111(core.List<api.Glossary> o) {
unittest.expect(o, unittest.hasLength(2));
checkGlossary(o[0]);
checkGlossary(o[1]);
}
core.int buildCounterListGlossariesResponse = 0;
api.ListGlossariesResponse buildListGlossariesResponse() {
var o = api.ListGlossariesResponse();
buildCounterListGlossariesResponse++;
if (buildCounterListGlossariesResponse < 3) {
o.glossaries = buildUnnamed5111();
o.nextPageToken = 'foo';
}
buildCounterListGlossariesResponse--;
return o;
}
void checkListGlossariesResponse(api.ListGlossariesResponse o) {
buildCounterListGlossariesResponse++;
if (buildCounterListGlossariesResponse < 3) {
checkUnnamed5111(o.glossaries);
unittest.expect(o.nextPageToken, unittest.equals('foo'));
}
buildCounterListGlossariesResponse--;
}
core.List<api.Location> buildUnnamed5112() {
var o = <api.Location>[];
o.add(buildLocation());
o.add(buildLocation());
return o;
}
void checkUnnamed5112(core.List<api.Location> o) {
unittest.expect(o, unittest.hasLength(2));
checkLocation(o[0]);
checkLocation(o[1]);
}
core.int buildCounterListLocationsResponse = 0;
api.ListLocationsResponse buildListLocationsResponse() {
var o = api.ListLocationsResponse();
buildCounterListLocationsResponse++;
if (buildCounterListLocationsResponse < 3) {
o.locations = buildUnnamed5112();
o.nextPageToken = 'foo';
}
buildCounterListLocationsResponse--;
return o;
}
void checkListLocationsResponse(api.ListLocationsResponse o) {
buildCounterListLocationsResponse++;
if (buildCounterListLocationsResponse < 3) {
checkUnnamed5112(o.locations);
unittest.expect(o.nextPageToken, unittest.equals('foo'));
}
buildCounterListLocationsResponse--;
}
core.List<api.Operation> buildUnnamed5113() {
var o = <api.Operation>[];
o.add(buildOperation());
o.add(buildOperation());
return o;
}
void checkUnnamed5113(core.List<api.Operation> o) {
unittest.expect(o, unittest.hasLength(2));
checkOperation(o[0]);
checkOperation(o[1]);
}
core.int buildCounterListOperationsResponse = 0;
api.ListOperationsResponse buildListOperationsResponse() {
var o = api.ListOperationsResponse();
buildCounterListOperationsResponse++;
if (buildCounterListOperationsResponse < 3) {
o.nextPageToken = 'foo';
o.operations = buildUnnamed5113();
}
buildCounterListOperationsResponse--;
return o;
}
void checkListOperationsResponse(api.ListOperationsResponse o) {
buildCounterListOperationsResponse++;
if (buildCounterListOperationsResponse < 3) {
unittest.expect(o.nextPageToken, unittest.equals('foo'));
checkUnnamed5113(o.operations);
}
buildCounterListOperationsResponse--;
}
core.Map<core.String, core.String> buildUnnamed5114() {
var o = <core.String, core.String>{};
o['x'] = 'foo';
o['y'] = 'foo';
return o;
}
void checkUnnamed5114(core.Map<core.String, core.String> o) {
unittest.expect(o, unittest.hasLength(2));
unittest.expect(o['x'], unittest.equals('foo'));
unittest.expect(o['y'], unittest.equals('foo'));
}
core.Map<core.String, core.Object> buildUnnamed5115() {
var o = <core.String, core.Object>{};
o['x'] = {
'list': [1, 2, 3],
'bool': true,
'string': 'foo'
};
o['y'] = {
'list': [1, 2, 3],
'bool': true,
'string': 'foo'
};
return o;
}
void checkUnnamed5115(core.Map<core.String, core.Object> o) {
unittest.expect(o, unittest.hasLength(2));
var casted1 = (o['x']) as core.Map;
unittest.expect(casted1, unittest.hasLength(3));
unittest.expect(casted1['list'], unittest.equals([1, 2, 3]));
unittest.expect(casted1['bool'], unittest.equals(true));
unittest.expect(casted1['string'], unittest.equals('foo'));
var casted2 = (o['y']) as core.Map;
unittest.expect(casted2, unittest.hasLength(3));
unittest.expect(casted2['list'], unittest.equals([1, 2, 3]));
unittest.expect(casted2['bool'], unittest.equals(true));
unittest.expect(casted2['string'], unittest.equals('foo'));
}
core.int buildCounterLocation = 0;
api.Location buildLocation() {
var o = api.Location();
buildCounterLocation++;
if (buildCounterLocation < 3) {
o.displayName = 'foo';
o.labels = buildUnnamed5114();
o.locationId = 'foo';
o.metadata = buildUnnamed5115();
o.name = 'foo';
}
buildCounterLocation--;
return o;
}
void checkLocation(api.Location o) {
buildCounterLocation++;
if (buildCounterLocation < 3) {
unittest.expect(o.displayName, unittest.equals('foo'));
checkUnnamed5114(o.labels);
unittest.expect(o.locationId, unittest.equals('foo'));
checkUnnamed5115(o.metadata);
unittest.expect(o.name, unittest.equals('foo'));
}
buildCounterLocation--;
}
core.Map<core.String, core.Object> buildUnnamed5116() {
var o = <core.String, core.Object>{};
o['x'] = {
'list': [1, 2, 3],
'bool': true,
'string': 'foo'
};
o['y'] = {
'list': [1, 2, 3],
'bool': true,
'string': 'foo'
};
return o;
}
void checkUnnamed5116(core.Map<core.String, core.Object> o) {
unittest.expect(o, unittest.hasLength(2));
var casted3 = (o['x']) as core.Map;
unittest.expect(casted3, unittest.hasLength(3));
unittest.expect(casted3['list'], unittest.equals([1, 2, 3]));
unittest.expect(casted3['bool'], unittest.equals(true));
unittest.expect(casted3['string'], unittest.equals('foo'));
var casted4 = (o['y']) as core.Map;
unittest.expect(casted4, unittest.hasLength(3));
unittest.expect(casted4['list'], unittest.equals([1, 2, 3]));
unittest.expect(casted4['bool'], unittest.equals(true));
unittest.expect(casted4['string'], unittest.equals('foo'));
}
core.Map<core.String, core.Object> buildUnnamed5117() {
var o = <core.String, core.Object>{};
o['x'] = {
'list': [1, 2, 3],
'bool': true,
'string': 'foo'
};
o['y'] = {
'list': [1, 2, 3],
'bool': true,
'string': 'foo'
};
return o;
}
void checkUnnamed5117(core.Map<core.String, core.Object> o) {
unittest.expect(o, unittest.hasLength(2));
var casted5 = (o['x']) as core.Map;
unittest.expect(casted5, unittest.hasLength(3));
unittest.expect(casted5['list'], unittest.equals([1, 2, 3]));
unittest.expect(casted5['bool'], unittest.equals(true));
unittest.expect(casted5['string'], unittest.equals('foo'));
var casted6 = (o['y']) as core.Map;
unittest.expect(casted6, unittest.hasLength(3));
unittest.expect(casted6['list'], unittest.equals([1, 2, 3]));
unittest.expect(casted6['bool'], unittest.equals(true));
unittest.expect(casted6['string'], unittest.equals('foo'));
}
core.int buildCounterOperation = 0;
api.Operation buildOperation() {
var o = api.Operation();
buildCounterOperation++;
if (buildCounterOperation < 3) {
o.done = true;
o.error = buildStatus();
o.metadata = buildUnnamed5116();
o.name = 'foo';
o.response = buildUnnamed5117();
}
buildCounterOperation--;
return o;
}
void checkOperation(api.Operation o) {
buildCounterOperation++;
if (buildCounterOperation < 3) {
unittest.expect(o.done, unittest.isTrue);
checkStatus(o.error);
checkUnnamed5116(o.metadata);
unittest.expect(o.name, unittest.equals('foo'));
checkUnnamed5117(o.response);
}
buildCounterOperation--;
}
core.int buildCounterOutputConfig = 0;
api.OutputConfig buildOutputConfig() {
var o = api.OutputConfig();
buildCounterOutputConfig++;
if (buildCounterOutputConfig < 3) {
o.gcsDestination = buildGcsDestination();
}
buildCounterOutputConfig--;
return o;
}
void checkOutputConfig(api.OutputConfig o) {
buildCounterOutputConfig++;
if (buildCounterOutputConfig < 3) {
checkGcsDestination(o.gcsDestination);
}
buildCounterOutputConfig--;
}
core.Map<core.String, core.Object> buildUnnamed5118() {
var o = <core.String, core.Object>{};
o['x'] = {
'list': [1, 2, 3],
'bool': true,
'string': 'foo'
};
o['y'] = {
'list': [1, 2, 3],
'bool': true,
'string': 'foo'
};
return o;
}
void checkUnnamed5118(core.Map<core.String, core.Object> o) {
unittest.expect(o, unittest.hasLength(2));
var casted7 = (o['x']) as core.Map;
unittest.expect(casted7, unittest.hasLength(3));
unittest.expect(casted7['list'], unittest.equals([1, 2, 3]));
unittest.expect(casted7['bool'], unittest.equals(true));
unittest.expect(casted7['string'], unittest.equals('foo'));
var casted8 = (o['y']) as core.Map;
unittest.expect(casted8, unittest.hasLength(3));
unittest.expect(casted8['list'], unittest.equals([1, 2, 3]));
unittest.expect(casted8['bool'], unittest.equals(true));
unittest.expect(casted8['string'], unittest.equals('foo'));
}
core.List<core.Map<core.String, core.Object>> buildUnnamed5119() {
var o = <core.Map<core.String, core.Object>>[];
o.add(buildUnnamed5118());
o.add(buildUnnamed5118());
return o;
}
void checkUnnamed5119(core.List<core.Map<core.String, core.Object>> o) {
unittest.expect(o, unittest.hasLength(2));
checkUnnamed5118(o[0]);
checkUnnamed5118(o[1]);
}
core.int buildCounterStatus = 0;
api.Status buildStatus() {
var o = api.Status();
buildCounterStatus++;
if (buildCounterStatus < 3) {
o.code = 42;
o.details = buildUnnamed5119();
o.message = 'foo';
}
buildCounterStatus--;
return o;
}
void checkStatus(api.Status o) {
buildCounterStatus++;
if (buildCounterStatus < 3) {
unittest.expect(o.code, unittest.equals(42));
checkUnnamed5119(o.details);
unittest.expect(o.message, unittest.equals('foo'));
}
buildCounterStatus--;
}
core.int buildCounterSupportedLanguage = 0;
api.SupportedLanguage buildSupportedLanguage() {
var o = api.SupportedLanguage();
buildCounterSupportedLanguage++;
if (buildCounterSupportedLanguage < 3) {
o.displayName = 'foo';
o.languageCode = 'foo';
o.supportSource = true;
o.supportTarget = true;
}
buildCounterSupportedLanguage--;
return o;
}
void checkSupportedLanguage(api.SupportedLanguage o) {
buildCounterSupportedLanguage++;
if (buildCounterSupportedLanguage < 3) {
unittest.expect(o.displayName, unittest.equals('foo'));
unittest.expect(o.languageCode, unittest.equals('foo'));
unittest.expect(o.supportSource, unittest.isTrue);
unittest.expect(o.supportTarget, unittest.isTrue);
}
buildCounterSupportedLanguage--;
}
core.List<api.SupportedLanguage> buildUnnamed5120() {
var o = <api.SupportedLanguage>[];
o.add(buildSupportedLanguage());
o.add(buildSupportedLanguage());
return o;
}
void checkUnnamed5120(core.List<api.SupportedLanguage> o) {
unittest.expect(o, unittest.hasLength(2));
checkSupportedLanguage(o[0]);
checkSupportedLanguage(o[1]);
}
core.int buildCounterSupportedLanguages = 0;
api.SupportedLanguages buildSupportedLanguages() {
var o = api.SupportedLanguages();
buildCounterSupportedLanguages++;
if (buildCounterSupportedLanguages < 3) {
o.languages = buildUnnamed5120();
}
buildCounterSupportedLanguages--;
return o;
}
void checkSupportedLanguages(api.SupportedLanguages o) {
buildCounterSupportedLanguages++;
if (buildCounterSupportedLanguages < 3) {
checkUnnamed5120(o.languages);
}
buildCounterSupportedLanguages--;
}
core.int buildCounterTranslateTextGlossaryConfig = 0;
api.TranslateTextGlossaryConfig buildTranslateTextGlossaryConfig() {
var o = api.TranslateTextGlossaryConfig();
buildCounterTranslateTextGlossaryConfig++;
if (buildCounterTranslateTextGlossaryConfig < 3) {
o.glossary = 'foo';
o.ignoreCase = true;
}
buildCounterTranslateTextGlossaryConfig--;
return o;
}
void checkTranslateTextGlossaryConfig(api.TranslateTextGlossaryConfig o) {
buildCounterTranslateTextGlossaryConfig++;
if (buildCounterTranslateTextGlossaryConfig < 3) {
unittest.expect(o.glossary, unittest.equals('foo'));
unittest.expect(o.ignoreCase, unittest.isTrue);
}
buildCounterTranslateTextGlossaryConfig--;
}
core.List<core.String> buildUnnamed5121() {
var o = <core.String>[];
o.add('foo');
o.add('foo');
return o;
}
void checkUnnamed5121(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.Map<core.String, core.String> buildUnnamed5122() {
var o = <core.String, core.String>{};
o['x'] = 'foo';
o['y'] = 'foo';
return o;
}
void checkUnnamed5122(core.Map<core.String, core.String> o) {
unittest.expect(o, unittest.hasLength(2));
unittest.expect(o['x'], unittest.equals('foo'));
unittest.expect(o['y'], unittest.equals('foo'));
}
core.int buildCounterTranslateTextRequest = 0;
api.TranslateTextRequest buildTranslateTextRequest() {
var o = api.TranslateTextRequest();
buildCounterTranslateTextRequest++;
if (buildCounterTranslateTextRequest < 3) {
o.contents = buildUnnamed5121();
o.glossaryConfig = buildTranslateTextGlossaryConfig();
o.labels = buildUnnamed5122();
o.mimeType = 'foo';
o.model = 'foo';
o.sourceLanguageCode = 'foo';
o.targetLanguageCode = 'foo';
}
buildCounterTranslateTextRequest--;
return o;
}
void checkTranslateTextRequest(api.TranslateTextRequest o) {
buildCounterTranslateTextRequest++;
if (buildCounterTranslateTextRequest < 3) {
checkUnnamed5121(o.contents);
checkTranslateTextGlossaryConfig(o.glossaryConfig);
checkUnnamed5122(o.labels);
unittest.expect(o.mimeType, unittest.equals('foo'));
unittest.expect(o.model, unittest.equals('foo'));
unittest.expect(o.sourceLanguageCode, unittest.equals('foo'));
unittest.expect(o.targetLanguageCode, unittest.equals('foo'));
}
buildCounterTranslateTextRequest--;
}
core.List<api.Translation> buildUnnamed5123() {
var o = <api.Translation>[];
o.add(buildTranslation());
o.add(buildTranslation());
return o;
}
void checkUnnamed5123(core.List<api.Translation> o) {
unittest.expect(o, unittest.hasLength(2));
checkTranslation(o[0]);
checkTranslation(o[1]);
}
core.List<api.Translation> buildUnnamed5124() {
var o = <api.Translation>[];
o.add(buildTranslation());
o.add(buildTranslation());
return o;
}
void checkUnnamed5124(core.List<api.Translation> o) {
unittest.expect(o, unittest.hasLength(2));
checkTranslation(o[0]);
checkTranslation(o[1]);
}
core.int buildCounterTranslateTextResponse = 0;
api.TranslateTextResponse buildTranslateTextResponse() {
var o = api.TranslateTextResponse();
buildCounterTranslateTextResponse++;
if (buildCounterTranslateTextResponse < 3) {
o.glossaryTranslations = buildUnnamed5123();
o.translations = buildUnnamed5124();
}
buildCounterTranslateTextResponse--;
return o;
}
void checkTranslateTextResponse(api.TranslateTextResponse o) {
buildCounterTranslateTextResponse++;
if (buildCounterTranslateTextResponse < 3) {
checkUnnamed5123(o.glossaryTranslations);
checkUnnamed5124(o.translations);
}
buildCounterTranslateTextResponse--;
}
core.int buildCounterTranslation = 0;
api.Translation buildTranslation() {
var o = api.Translation();
buildCounterTranslation++;
if (buildCounterTranslation < 3) {
o.detectedLanguageCode = 'foo';
o.glossaryConfig = buildTranslateTextGlossaryConfig();
o.model = 'foo';
o.translatedText = 'foo';
}
buildCounterTranslation--;
return o;
}
void checkTranslation(api.Translation o) {
buildCounterTranslation++;
if (buildCounterTranslation < 3) {
unittest.expect(o.detectedLanguageCode, unittest.equals('foo'));
checkTranslateTextGlossaryConfig(o.glossaryConfig);
unittest.expect(o.model, unittest.equals('foo'));
unittest.expect(o.translatedText, unittest.equals('foo'));
}
buildCounterTranslation--;
}
core.int buildCounterWaitOperationRequest = 0;
api.WaitOperationRequest buildWaitOperationRequest() {
var o = api.WaitOperationRequest();
buildCounterWaitOperationRequest++;
if (buildCounterWaitOperationRequest < 3) {
o.timeout = 'foo';
}
buildCounterWaitOperationRequest--;
return o;
}
void checkWaitOperationRequest(api.WaitOperationRequest o) {
buildCounterWaitOperationRequest++;
if (buildCounterWaitOperationRequest < 3) {
unittest.expect(o.timeout, unittest.equals('foo'));
}
buildCounterWaitOperationRequest--;
}
void main() {
unittest.group('obj-schema-BatchTranslateTextRequest', () {
unittest.test('to-json--from-json', () {
var o = buildBatchTranslateTextRequest();
var od = api.BatchTranslateTextRequest.fromJson(o.toJson());
checkBatchTranslateTextRequest(od);
});
});
unittest.group('obj-schema-CancelOperationRequest', () {
unittest.test('to-json--from-json', () {
var o = buildCancelOperationRequest();
var od = api.CancelOperationRequest.fromJson(o.toJson());
checkCancelOperationRequest(od);
});
});
unittest.group('obj-schema-DetectLanguageRequest', () {
unittest.test('to-json--from-json', () {
var o = buildDetectLanguageRequest();
var od = api.DetectLanguageRequest.fromJson(o.toJson());
checkDetectLanguageRequest(od);
});
});
unittest.group('obj-schema-DetectLanguageResponse', () {
unittest.test('to-json--from-json', () {
var o = buildDetectLanguageResponse();
var od = api.DetectLanguageResponse.fromJson(o.toJson());
checkDetectLanguageResponse(od);
});
});
unittest.group('obj-schema-DetectedLanguage', () {
unittest.test('to-json--from-json', () {
var o = buildDetectedLanguage();
var od = api.DetectedLanguage.fromJson(o.toJson());
checkDetectedLanguage(od);
});
});
unittest.group('obj-schema-Empty', () {
unittest.test('to-json--from-json', () {
var o = buildEmpty();
var od = api.Empty.fromJson(o.toJson());
checkEmpty(od);
});
});
unittest.group('obj-schema-GcsDestination', () {
unittest.test('to-json--from-json', () {
var o = buildGcsDestination();
var od = api.GcsDestination.fromJson(o.toJson());
checkGcsDestination(od);
});
});
unittest.group('obj-schema-GcsSource', () {
unittest.test('to-json--from-json', () {
var o = buildGcsSource();
var od = api.GcsSource.fromJson(o.toJson());
checkGcsSource(od);
});
});
unittest.group('obj-schema-Glossary', () {
unittest.test('to-json--from-json', () {
var o = buildGlossary();
var od = api.Glossary.fromJson(o.toJson());
checkGlossary(od);
});
});
unittest.group('obj-schema-GlossaryInputConfig', () {
unittest.test('to-json--from-json', () {
var o = buildGlossaryInputConfig();
var od = api.GlossaryInputConfig.fromJson(o.toJson());
checkGlossaryInputConfig(od);
});
});
unittest.group('obj-schema-InputConfig', () {
unittest.test('to-json--from-json', () {
var o = buildInputConfig();
var od = api.InputConfig.fromJson(o.toJson());
checkInputConfig(od);
});
});
unittest.group('obj-schema-LanguageCodePair', () {
unittest.test('to-json--from-json', () {
var o = buildLanguageCodePair();
var od = api.LanguageCodePair.fromJson(o.toJson());
checkLanguageCodePair(od);
});
});
unittest.group('obj-schema-LanguageCodesSet', () {
unittest.test('to-json--from-json', () {
var o = buildLanguageCodesSet();
var od = api.LanguageCodesSet.fromJson(o.toJson());
checkLanguageCodesSet(od);
});
});
unittest.group('obj-schema-ListGlossariesResponse', () {
unittest.test('to-json--from-json', () {
var o = buildListGlossariesResponse();
var od = api.ListGlossariesResponse.fromJson(o.toJson());
checkListGlossariesResponse(od);
});
});
unittest.group('obj-schema-ListLocationsResponse', () {
unittest.test('to-json--from-json', () {
var o = buildListLocationsResponse();
var od = api.ListLocationsResponse.fromJson(o.toJson());
checkListLocationsResponse(od);
});
});
unittest.group('obj-schema-ListOperationsResponse', () {
unittest.test('to-json--from-json', () {
var o = buildListOperationsResponse();
var od = api.ListOperationsResponse.fromJson(o.toJson());
checkListOperationsResponse(od);
});
});
unittest.group('obj-schema-Location', () {
unittest.test('to-json--from-json', () {
var o = buildLocation();
var od = api.Location.fromJson(o.toJson());
checkLocation(od);
});
});
unittest.group('obj-schema-Operation', () {
unittest.test('to-json--from-json', () {
var o = buildOperation();
var od = api.Operation.fromJson(o.toJson());
checkOperation(od);
});
});
unittest.group('obj-schema-OutputConfig', () {
unittest.test('to-json--from-json', () {
var o = buildOutputConfig();
var od = api.OutputConfig.fromJson(o.toJson());
checkOutputConfig(od);
});
});
unittest.group('obj-schema-Status', () {
unittest.test('to-json--from-json', () {
var o = buildStatus();
var od = api.Status.fromJson(o.toJson());
checkStatus(od);
});
});
unittest.group('obj-schema-SupportedLanguage', () {
unittest.test('to-json--from-json', () {
var o = buildSupportedLanguage();
var od = api.SupportedLanguage.fromJson(o.toJson());
checkSupportedLanguage(od);
});
});
unittest.group('obj-schema-SupportedLanguages', () {
unittest.test('to-json--from-json', () {
var o = buildSupportedLanguages();
var od = api.SupportedLanguages.fromJson(o.toJson());
checkSupportedLanguages(od);
});
});
unittest.group('obj-schema-TranslateTextGlossaryConfig', () {
unittest.test('to-json--from-json', () {
var o = buildTranslateTextGlossaryConfig();
var od = api.TranslateTextGlossaryConfig.fromJson(o.toJson());
checkTranslateTextGlossaryConfig(od);
});
});
unittest.group('obj-schema-TranslateTextRequest', () {
unittest.test('to-json--from-json', () {
var o = buildTranslateTextRequest();
var od = api.TranslateTextRequest.fromJson(o.toJson());
checkTranslateTextRequest(od);
});
});
unittest.group('obj-schema-TranslateTextResponse', () {
unittest.test('to-json--from-json', () {
var o = buildTranslateTextResponse();
var od = api.TranslateTextResponse.fromJson(o.toJson());
checkTranslateTextResponse(od);
});
});
unittest.group('obj-schema-Translation', () {
unittest.test('to-json--from-json', () {
var o = buildTranslation();
var od = api.Translation.fromJson(o.toJson());
checkTranslation(od);
});
});
unittest.group('obj-schema-WaitOperationRequest', () {
unittest.test('to-json--from-json', () {
var o = buildWaitOperationRequest();
var od = api.WaitOperationRequest.fromJson(o.toJson());
checkWaitOperationRequest(od);
});
});
unittest.group('resource-ProjectsResourceApi', () {
unittest.test('method--detectLanguage', () {
var mock = HttpServerMock();
api.ProjectsResourceApi res = api.TranslateApi(mock).projects;
var arg_request = buildDetectLanguageRequest();
var arg_parent = 'foo';
var arg_$fields = 'foo';
mock.register(unittest.expectAsync2((http.BaseRequest req, json) {
var obj = api.DetectLanguageRequest.fromJson(json);
checkDetectLanguageRequest(obj);
var path = (req.url).path;
var pathOffset = 0;
core.int index;
core.String subPart;
unittest.expect(
path.substring(pathOffset, pathOffset + 1), unittest.equals("/"));
pathOffset += 1;
unittest.expect(
path.substring(pathOffset, pathOffset + 3), unittest.equals("v3/"));
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 = <core.String, core.List<core.String>>{};
void addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
if (query.isNotEmpty) {
for (var part in query.split('&')) {
var keyValue = part.split('=');
addQueryParam(
core.Uri.decodeQueryComponent(keyValue[0]),
core.Uri.decodeQueryComponent(keyValue[1]),
);
}
}
unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields));
var h = {
'content-type': 'application/json; charset=utf-8',
};
var resp = convert.json.encode(buildDetectLanguageResponse());
return async.Future.value(stringResponse(200, h, resp));
}), true);
res
.detectLanguage(arg_request, arg_parent, $fields: arg_$fields)
.then(unittest.expectAsync1(((response) {
checkDetectLanguageResponse(response);
})));
});
unittest.test('method--getSupportedLanguages', () {
var mock = HttpServerMock();
api.ProjectsResourceApi res = api.TranslateApi(mock).projects;
var arg_parent = 'foo';
var arg_displayLanguageCode = 'foo';
var arg_model = 'foo';
var arg_$fields = 'foo';
mock.register(unittest.expectAsync2((http.BaseRequest req, json) {
var path = (req.url).path;
var pathOffset = 0;
core.int index;
core.String subPart;
unittest.expect(
path.substring(pathOffset, pathOffset + 1), unittest.equals("/"));
pathOffset += 1;
unittest.expect(
path.substring(pathOffset, pathOffset + 3), unittest.equals("v3/"));
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 = <core.String, core.List<core.String>>{};
void addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
if (query.isNotEmpty) {
for (var part in query.split('&')) {
var keyValue = part.split('=');
addQueryParam(
core.Uri.decodeQueryComponent(keyValue[0]),
core.Uri.decodeQueryComponent(keyValue[1]),
);
}
}
unittest.expect(queryMap["displayLanguageCode"].first,
unittest.equals(arg_displayLanguageCode));
unittest.expect(queryMap["model"].first, unittest.equals(arg_model));
unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields));
var h = {
'content-type': 'application/json; charset=utf-8',
};
var resp = convert.json.encode(buildSupportedLanguages());
return async.Future.value(stringResponse(200, h, resp));
}), true);
res
.getSupportedLanguages(arg_parent,
displayLanguageCode: arg_displayLanguageCode,
model: arg_model,
$fields: arg_$fields)
.then(unittest.expectAsync1(((response) {
checkSupportedLanguages(response);
})));
});
unittest.test('method--translateText', () {
var mock = HttpServerMock();
api.ProjectsResourceApi res = api.TranslateApi(mock).projects;
var arg_request = buildTranslateTextRequest();
var arg_parent = 'foo';
var arg_$fields = 'foo';
mock.register(unittest.expectAsync2((http.BaseRequest req, json) {
var obj = api.TranslateTextRequest.fromJson(json);
checkTranslateTextRequest(obj);
var path = (req.url).path;
var pathOffset = 0;
core.int index;
core.String subPart;
unittest.expect(
path.substring(pathOffset, pathOffset + 1), unittest.equals("/"));
pathOffset += 1;
unittest.expect(
path.substring(pathOffset, pathOffset + 3), unittest.equals("v3/"));
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 = <core.String, core.List<core.String>>{};
void addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
if (query.isNotEmpty) {
for (var part in query.split('&')) {
var keyValue = part.split('=');
addQueryParam(
core.Uri.decodeQueryComponent(keyValue[0]),
core.Uri.decodeQueryComponent(keyValue[1]),
);
}
}
unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields));
var h = {
'content-type': 'application/json; charset=utf-8',
};
var resp = convert.json.encode(buildTranslateTextResponse());
return async.Future.value(stringResponse(200, h, resp));
}), true);
res
.translateText(arg_request, arg_parent, $fields: arg_$fields)
.then(unittest.expectAsync1(((response) {
checkTranslateTextResponse(response);
})));
});
});
unittest.group('resource-ProjectsLocationsResourceApi', () {
unittest.test('method--batchTranslateText', () {
var mock = HttpServerMock();
api.ProjectsLocationsResourceApi res =
api.TranslateApi(mock).projects.locations;
var arg_request = buildBatchTranslateTextRequest();
var arg_parent = 'foo';
var arg_$fields = 'foo';
mock.register(unittest.expectAsync2((http.BaseRequest req, json) {
var obj = api.BatchTranslateTextRequest.fromJson(json);
checkBatchTranslateTextRequest(obj);
var path = (req.url).path;
var pathOffset = 0;
core.int index;
core.String subPart;
unittest.expect(
path.substring(pathOffset, pathOffset + 1), unittest.equals("/"));
pathOffset += 1;
unittest.expect(
path.substring(pathOffset, pathOffset + 3), unittest.equals("v3/"));
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 = <core.String, core.List<core.String>>{};
void addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
if (query.isNotEmpty) {
for (var part in query.split('&')) {
var keyValue = part.split('=');
addQueryParam(
core.Uri.decodeQueryComponent(keyValue[0]),
core.Uri.decodeQueryComponent(keyValue[1]),
);
}
}
unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields));
var h = {
'content-type': 'application/json; charset=utf-8',
};
var resp = convert.json.encode(buildOperation());
return async.Future.value(stringResponse(200, h, resp));
}), true);
res
.batchTranslateText(arg_request, arg_parent, $fields: arg_$fields)
.then(unittest.expectAsync1(((response) {
checkOperation(response);
})));
});
unittest.test('method--detectLanguage', () {
var mock = HttpServerMock();
api.ProjectsLocationsResourceApi res =
api.TranslateApi(mock).projects.locations;
var arg_request = buildDetectLanguageRequest();
var arg_parent = 'foo';
var arg_$fields = 'foo';
mock.register(unittest.expectAsync2((http.BaseRequest req, json) {
var obj = api.DetectLanguageRequest.fromJson(json);
checkDetectLanguageRequest(obj);
var path = (req.url).path;
var pathOffset = 0;
core.int index;
core.String subPart;
unittest.expect(
path.substring(pathOffset, pathOffset + 1), unittest.equals("/"));
pathOffset += 1;
unittest.expect(
path.substring(pathOffset, pathOffset + 3), unittest.equals("v3/"));
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 = <core.String, core.List<core.String>>{};
void addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
if (query.isNotEmpty) {
for (var part in query.split('&')) {
var keyValue = part.split('=');
addQueryParam(
core.Uri.decodeQueryComponent(keyValue[0]),
core.Uri.decodeQueryComponent(keyValue[1]),
);
}
}
unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields));
var h = {
'content-type': 'application/json; charset=utf-8',
};
var resp = convert.json.encode(buildDetectLanguageResponse());
return async.Future.value(stringResponse(200, h, resp));
}), true);
res
.detectLanguage(arg_request, arg_parent, $fields: arg_$fields)
.then(unittest.expectAsync1(((response) {
checkDetectLanguageResponse(response);
})));
});
unittest.test('method--get', () {
var mock = HttpServerMock();
api.ProjectsLocationsResourceApi res =
api.TranslateApi(mock).projects.locations;
var arg_name = 'foo';
var arg_$fields = 'foo';
mock.register(unittest.expectAsync2((http.BaseRequest req, json) {
var path = (req.url).path;
var pathOffset = 0;
core.int index;
core.String subPart;
unittest.expect(
path.substring(pathOffset, pathOffset + 1), unittest.equals("/"));
pathOffset += 1;
unittest.expect(
path.substring(pathOffset, pathOffset + 3), unittest.equals("v3/"));
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 = <core.String, core.List<core.String>>{};
void addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
if (query.isNotEmpty) {
for (var part in query.split('&')) {
var keyValue = part.split('=');
addQueryParam(
core.Uri.decodeQueryComponent(keyValue[0]),
core.Uri.decodeQueryComponent(keyValue[1]),
);
}
}
unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields));
var h = {
'content-type': 'application/json; charset=utf-8',
};
var resp = convert.json.encode(buildLocation());
return async.Future.value(stringResponse(200, h, resp));
}), true);
res
.get(arg_name, $fields: arg_$fields)
.then(unittest.expectAsync1(((response) {
checkLocation(response);
})));
});
unittest.test('method--getSupportedLanguages', () {
var mock = HttpServerMock();
api.ProjectsLocationsResourceApi res =
api.TranslateApi(mock).projects.locations;
var arg_parent = 'foo';
var arg_displayLanguageCode = 'foo';
var arg_model = 'foo';
var arg_$fields = 'foo';
mock.register(unittest.expectAsync2((http.BaseRequest req, json) {
var path = (req.url).path;
var pathOffset = 0;
core.int index;
core.String subPart;
unittest.expect(
path.substring(pathOffset, pathOffset + 1), unittest.equals("/"));
pathOffset += 1;
unittest.expect(
path.substring(pathOffset, pathOffset + 3), unittest.equals("v3/"));
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 = <core.String, core.List<core.String>>{};
void addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
if (query.isNotEmpty) {
for (var part in query.split('&')) {
var keyValue = part.split('=');
addQueryParam(
core.Uri.decodeQueryComponent(keyValue[0]),
core.Uri.decodeQueryComponent(keyValue[1]),
);
}
}
unittest.expect(queryMap["displayLanguageCode"].first,
unittest.equals(arg_displayLanguageCode));
unittest.expect(queryMap["model"].first, unittest.equals(arg_model));
unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields));
var h = {
'content-type': 'application/json; charset=utf-8',
};
var resp = convert.json.encode(buildSupportedLanguages());
return async.Future.value(stringResponse(200, h, resp));
}), true);
res
.getSupportedLanguages(arg_parent,
displayLanguageCode: arg_displayLanguageCode,
model: arg_model,
$fields: arg_$fields)
.then(unittest.expectAsync1(((response) {
checkSupportedLanguages(response);
})));
});
unittest.test('method--list', () {
var mock = HttpServerMock();
api.ProjectsLocationsResourceApi res =
api.TranslateApi(mock).projects.locations;
var arg_name = 'foo';
var arg_filter = 'foo';
var arg_pageSize = 42;
var arg_pageToken = 'foo';
var arg_$fields = 'foo';
mock.register(unittest.expectAsync2((http.BaseRequest req, json) {
var path = (req.url).path;
var pathOffset = 0;
core.int index;
core.String subPart;
unittest.expect(
path.substring(pathOffset, pathOffset + 1), unittest.equals("/"));
pathOffset += 1;
unittest.expect(
path.substring(pathOffset, pathOffset + 3), unittest.equals("v3/"));
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 = <core.String, core.List<core.String>>{};
void addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
if (query.isNotEmpty) {
for (var part in query.split('&')) {
var keyValue = part.split('=');
addQueryParam(
core.Uri.decodeQueryComponent(keyValue[0]),
core.Uri.decodeQueryComponent(keyValue[1]),
);
}
}
unittest.expect(queryMap["filter"].first, unittest.equals(arg_filter));
unittest.expect(core.int.parse(queryMap["pageSize"].first),
unittest.equals(arg_pageSize));
unittest.expect(
queryMap["pageToken"].first, unittest.equals(arg_pageToken));
unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields));
var h = {
'content-type': 'application/json; charset=utf-8',
};
var resp = convert.json.encode(buildListLocationsResponse());
return async.Future.value(stringResponse(200, h, resp));
}), true);
res
.list(arg_name,
filter: arg_filter,
pageSize: arg_pageSize,
pageToken: arg_pageToken,
$fields: arg_$fields)
.then(unittest.expectAsync1(((response) {
checkListLocationsResponse(response);
})));
});
unittest.test('method--translateText', () {
var mock = HttpServerMock();
api.ProjectsLocationsResourceApi res =
api.TranslateApi(mock).projects.locations;
var arg_request = buildTranslateTextRequest();
var arg_parent = 'foo';
var arg_$fields = 'foo';
mock.register(unittest.expectAsync2((http.BaseRequest req, json) {
var obj = api.TranslateTextRequest.fromJson(json);
checkTranslateTextRequest(obj);
var path = (req.url).path;
var pathOffset = 0;
core.int index;
core.String subPart;
unittest.expect(
path.substring(pathOffset, pathOffset + 1), unittest.equals("/"));
pathOffset += 1;
unittest.expect(
path.substring(pathOffset, pathOffset + 3), unittest.equals("v3/"));
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 = <core.String, core.List<core.String>>{};
void addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
if (query.isNotEmpty) {
for (var part in query.split('&')) {
var keyValue = part.split('=');
addQueryParam(
core.Uri.decodeQueryComponent(keyValue[0]),
core.Uri.decodeQueryComponent(keyValue[1]),
);
}
}
unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields));
var h = {
'content-type': 'application/json; charset=utf-8',
};
var resp = convert.json.encode(buildTranslateTextResponse());
return async.Future.value(stringResponse(200, h, resp));
}), true);
res
.translateText(arg_request, arg_parent, $fields: arg_$fields)
.then(unittest.expectAsync1(((response) {
checkTranslateTextResponse(response);
})));
});
});
unittest.group('resource-ProjectsLocationsGlossariesResourceApi', () {
unittest.test('method--create', () {
var mock = HttpServerMock();
api.ProjectsLocationsGlossariesResourceApi res =
api.TranslateApi(mock).projects.locations.glossaries;
var arg_request = buildGlossary();
var arg_parent = 'foo';
var arg_$fields = 'foo';
mock.register(unittest.expectAsync2((http.BaseRequest req, json) {
var obj = api.Glossary.fromJson(json);
checkGlossary(obj);
var path = (req.url).path;
var pathOffset = 0;
core.int index;
core.String subPart;
unittest.expect(
path.substring(pathOffset, pathOffset + 1), unittest.equals("/"));
pathOffset += 1;
unittest.expect(
path.substring(pathOffset, pathOffset + 3), unittest.equals("v3/"));
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 = <core.String, core.List<core.String>>{};
void addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
if (query.isNotEmpty) {
for (var part in query.split('&')) {
var keyValue = part.split('=');
addQueryParam(
core.Uri.decodeQueryComponent(keyValue[0]),
core.Uri.decodeQueryComponent(keyValue[1]),
);
}
}
unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields));
var h = {
'content-type': 'application/json; charset=utf-8',
};
var resp = convert.json.encode(buildOperation());
return async.Future.value(stringResponse(200, h, resp));
}), true);
res
.create(arg_request, arg_parent, $fields: arg_$fields)
.then(unittest.expectAsync1(((response) {
checkOperation(response);
})));
});
unittest.test('method--delete', () {
var mock = HttpServerMock();
api.ProjectsLocationsGlossariesResourceApi res =
api.TranslateApi(mock).projects.locations.glossaries;
var arg_name = 'foo';
var arg_$fields = 'foo';
mock.register(unittest.expectAsync2((http.BaseRequest req, json) {
var path = (req.url).path;
var pathOffset = 0;
core.int index;
core.String subPart;
unittest.expect(
path.substring(pathOffset, pathOffset + 1), unittest.equals("/"));
pathOffset += 1;
unittest.expect(
path.substring(pathOffset, pathOffset + 3), unittest.equals("v3/"));
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 = <core.String, core.List<core.String>>{};
void addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
if (query.isNotEmpty) {
for (var part in query.split('&')) {
var keyValue = part.split('=');
addQueryParam(
core.Uri.decodeQueryComponent(keyValue[0]),
core.Uri.decodeQueryComponent(keyValue[1]),
);
}
}
unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields));
var h = {
'content-type': 'application/json; charset=utf-8',
};
var resp = convert.json.encode(buildOperation());
return async.Future.value(stringResponse(200, h, resp));
}), true);
res
.delete(arg_name, $fields: arg_$fields)
.then(unittest.expectAsync1(((response) {
checkOperation(response);
})));
});
unittest.test('method--get', () {
var mock = HttpServerMock();
api.ProjectsLocationsGlossariesResourceApi res =
api.TranslateApi(mock).projects.locations.glossaries;
var arg_name = 'foo';
var arg_$fields = 'foo';
mock.register(unittest.expectAsync2((http.BaseRequest req, json) {
var path = (req.url).path;
var pathOffset = 0;
core.int index;
core.String subPart;
unittest.expect(
path.substring(pathOffset, pathOffset + 1), unittest.equals("/"));
pathOffset += 1;
unittest.expect(
path.substring(pathOffset, pathOffset + 3), unittest.equals("v3/"));
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 = <core.String, core.List<core.String>>{};
void addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
if (query.isNotEmpty) {
for (var part in query.split('&')) {
var keyValue = part.split('=');
addQueryParam(
core.Uri.decodeQueryComponent(keyValue[0]),
core.Uri.decodeQueryComponent(keyValue[1]),
);
}
}
unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields));
var h = {
'content-type': 'application/json; charset=utf-8',
};
var resp = convert.json.encode(buildGlossary());
return async.Future.value(stringResponse(200, h, resp));
}), true);
res
.get(arg_name, $fields: arg_$fields)
.then(unittest.expectAsync1(((response) {
checkGlossary(response);
})));
});
unittest.test('method--list', () {
var mock = HttpServerMock();
api.ProjectsLocationsGlossariesResourceApi res =
api.TranslateApi(mock).projects.locations.glossaries;
var arg_parent = 'foo';
var arg_filter = 'foo';
var arg_pageSize = 42;
var arg_pageToken = 'foo';
var arg_$fields = 'foo';
mock.register(unittest.expectAsync2((http.BaseRequest req, json) {
var path = (req.url).path;
var pathOffset = 0;
core.int index;
core.String subPart;
unittest.expect(
path.substring(pathOffset, pathOffset + 1), unittest.equals("/"));
pathOffset += 1;
unittest.expect(
path.substring(pathOffset, pathOffset + 3), unittest.equals("v3/"));
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 = <core.String, core.List<core.String>>{};
void addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
if (query.isNotEmpty) {
for (var part in query.split('&')) {
var keyValue = part.split('=');
addQueryParam(
core.Uri.decodeQueryComponent(keyValue[0]),
core.Uri.decodeQueryComponent(keyValue[1]),
);
}
}
unittest.expect(queryMap["filter"].first, unittest.equals(arg_filter));
unittest.expect(core.int.parse(queryMap["pageSize"].first),
unittest.equals(arg_pageSize));
unittest.expect(
queryMap["pageToken"].first, unittest.equals(arg_pageToken));
unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields));
var h = {
'content-type': 'application/json; charset=utf-8',
};
var resp = convert.json.encode(buildListGlossariesResponse());
return async.Future.value(stringResponse(200, h, resp));
}), true);
res
.list(arg_parent,
filter: arg_filter,
pageSize: arg_pageSize,
pageToken: arg_pageToken,
$fields: arg_$fields)
.then(unittest.expectAsync1(((response) {
checkListGlossariesResponse(response);
})));
});
});
unittest.group('resource-ProjectsLocationsOperationsResourceApi', () {
unittest.test('method--cancel', () {
var mock = HttpServerMock();
api.ProjectsLocationsOperationsResourceApi res =
api.TranslateApi(mock).projects.locations.operations;
var arg_request = buildCancelOperationRequest();
var arg_name = 'foo';
var arg_$fields = 'foo';
mock.register(unittest.expectAsync2((http.BaseRequest req, json) {
var obj = api.CancelOperationRequest.fromJson(json);
checkCancelOperationRequest(obj);
var path = (req.url).path;
var pathOffset = 0;
core.int index;
core.String subPart;
unittest.expect(
path.substring(pathOffset, pathOffset + 1), unittest.equals("/"));
pathOffset += 1;
unittest.expect(
path.substring(pathOffset, pathOffset + 3), unittest.equals("v3/"));
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 = <core.String, core.List<core.String>>{};
void addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
if (query.isNotEmpty) {
for (var part in query.split('&')) {
var keyValue = part.split('=');
addQueryParam(
core.Uri.decodeQueryComponent(keyValue[0]),
core.Uri.decodeQueryComponent(keyValue[1]),
);
}
}
unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields));
var h = {
'content-type': 'application/json; charset=utf-8',
};
var resp = convert.json.encode(buildEmpty());
return async.Future.value(stringResponse(200, h, resp));
}), true);
res
.cancel(arg_request, arg_name, $fields: arg_$fields)
.then(unittest.expectAsync1(((response) {
checkEmpty(response);
})));
});
unittest.test('method--delete', () {
var mock = HttpServerMock();
api.ProjectsLocationsOperationsResourceApi res =
api.TranslateApi(mock).projects.locations.operations;
var arg_name = 'foo';
var arg_$fields = 'foo';
mock.register(unittest.expectAsync2((http.BaseRequest req, json) {
var path = (req.url).path;
var pathOffset = 0;
core.int index;
core.String subPart;
unittest.expect(
path.substring(pathOffset, pathOffset + 1), unittest.equals("/"));
pathOffset += 1;
unittest.expect(
path.substring(pathOffset, pathOffset + 3), unittest.equals("v3/"));
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 = <core.String, core.List<core.String>>{};
void addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
if (query.isNotEmpty) {
for (var part in query.split('&')) {
var keyValue = part.split('=');
addQueryParam(
core.Uri.decodeQueryComponent(keyValue[0]),
core.Uri.decodeQueryComponent(keyValue[1]),
);
}
}
unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields));
var h = {
'content-type': 'application/json; charset=utf-8',
};
var resp = convert.json.encode(buildEmpty());
return async.Future.value(stringResponse(200, h, resp));
}), true);
res
.delete(arg_name, $fields: arg_$fields)
.then(unittest.expectAsync1(((response) {
checkEmpty(response);
})));
});
unittest.test('method--get', () {
var mock = HttpServerMock();
api.ProjectsLocationsOperationsResourceApi res =
api.TranslateApi(mock).projects.locations.operations;
var arg_name = 'foo';
var arg_$fields = 'foo';
mock.register(unittest.expectAsync2((http.BaseRequest req, json) {
var path = (req.url).path;
var pathOffset = 0;
core.int index;
core.String subPart;
unittest.expect(
path.substring(pathOffset, pathOffset + 1), unittest.equals("/"));
pathOffset += 1;
unittest.expect(
path.substring(pathOffset, pathOffset + 3), unittest.equals("v3/"));
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 = <core.String, core.List<core.String>>{};
void addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
if (query.isNotEmpty) {
for (var part in query.split('&')) {
var keyValue = part.split('=');
addQueryParam(
core.Uri.decodeQueryComponent(keyValue[0]),
core.Uri.decodeQueryComponent(keyValue[1]),
);
}
}
unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields));
var h = {
'content-type': 'application/json; charset=utf-8',
};
var resp = convert.json.encode(buildOperation());
return async.Future.value(stringResponse(200, h, resp));
}), true);
res
.get(arg_name, $fields: arg_$fields)
.then(unittest.expectAsync1(((response) {
checkOperation(response);
})));
});
unittest.test('method--list', () {
var mock = HttpServerMock();
api.ProjectsLocationsOperationsResourceApi res =
api.TranslateApi(mock).projects.locations.operations;
var arg_name = 'foo';
var arg_filter = 'foo';
var arg_pageSize = 42;
var arg_pageToken = 'foo';
var arg_$fields = 'foo';
mock.register(unittest.expectAsync2((http.BaseRequest req, json) {
var path = (req.url).path;
var pathOffset = 0;
core.int index;
core.String subPart;
unittest.expect(
path.substring(pathOffset, pathOffset + 1), unittest.equals("/"));
pathOffset += 1;
unittest.expect(
path.substring(pathOffset, pathOffset + 3), unittest.equals("v3/"));
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 = <core.String, core.List<core.String>>{};
void addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
if (query.isNotEmpty) {
for (var part in query.split('&')) {
var keyValue = part.split('=');
addQueryParam(
core.Uri.decodeQueryComponent(keyValue[0]),
core.Uri.decodeQueryComponent(keyValue[1]),
);
}
}
unittest.expect(queryMap["filter"].first, unittest.equals(arg_filter));
unittest.expect(core.int.parse(queryMap["pageSize"].first),
unittest.equals(arg_pageSize));
unittest.expect(
queryMap["pageToken"].first, unittest.equals(arg_pageToken));
unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields));
var h = {
'content-type': 'application/json; charset=utf-8',
};
var resp = convert.json.encode(buildListOperationsResponse());
return async.Future.value(stringResponse(200, h, resp));
}), true);
res
.list(arg_name,
filter: arg_filter,
pageSize: arg_pageSize,
pageToken: arg_pageToken,
$fields: arg_$fields)
.then(unittest.expectAsync1(((response) {
checkListOperationsResponse(response);
})));
});
unittest.test('method--wait', () {
var mock = HttpServerMock();
api.ProjectsLocationsOperationsResourceApi res =
api.TranslateApi(mock).projects.locations.operations;
var arg_request = buildWaitOperationRequest();
var arg_name = 'foo';
var arg_$fields = 'foo';
mock.register(unittest.expectAsync2((http.BaseRequest req, json) {
var obj = api.WaitOperationRequest.fromJson(json);
checkWaitOperationRequest(obj);
var path = (req.url).path;
var pathOffset = 0;
core.int index;
core.String subPart;
unittest.expect(
path.substring(pathOffset, pathOffset + 1), unittest.equals("/"));
pathOffset += 1;
unittest.expect(
path.substring(pathOffset, pathOffset + 3), unittest.equals("v3/"));
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 = <core.String, core.List<core.String>>{};
void addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
if (query.isNotEmpty) {
for (var part in query.split('&')) {
var keyValue = part.split('=');
addQueryParam(
core.Uri.decodeQueryComponent(keyValue[0]),
core.Uri.decodeQueryComponent(keyValue[1]),
);
}
}
unittest.expect(queryMap["fields"].first, unittest.equals(arg_$fields));
var h = {
'content-type': 'application/json; charset=utf-8',
};
var resp = convert.json.encode(buildOperation());
return async.Future.value(stringResponse(200, h, resp));
}), true);
res
.wait(arg_request, arg_name, $fields: arg_$fields)
.then(unittest.expectAsync1(((response) {
checkOperation(response);
})));
});
});
}