| library googleapis.datastore.v1.test; |
| |
| import "dart:core" as core; |
| import "dart:collection" as collection; |
| import "dart:async" as async; |
| import "dart:convert" as convert; |
| |
| import 'package:http/http.dart' as http; |
| import 'package:http/testing.dart' as http_testing; |
| import 'package:unittest/unittest.dart' as unittest; |
| |
| import 'package:googleapis/datastore/v1.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; |
| } |
| |
| async.Future<http.StreamedResponse> send(http.BaseRequest request) { |
| if (_expectJson) { |
| return request.finalize() |
| .transform(convert.UTF8.decoder) |
| .join('') |
| .then((core.String jsonString) { |
| 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 { |
| return stream.toBytes().then((data) { |
| return _callback(request, data); |
| }); |
| } |
| } |
| } |
| } |
| |
| http.StreamedResponse stringResponse( |
| core.int status, core.Map headers, core.String body) { |
| var stream = new async.Stream.fromIterable([convert.UTF8.encode(body)]); |
| return new http.StreamedResponse(stream, status, headers: headers); |
| } |
| |
| buildUnnamed573() { |
| var o = new core.List<api.Key>(); |
| o.add(buildKey()); |
| o.add(buildKey()); |
| return o; |
| } |
| |
| checkUnnamed573(core.List<api.Key> o) { |
| unittest.expect(o, unittest.hasLength(2)); |
| checkKey(o[0]); |
| checkKey(o[1]); |
| } |
| |
| core.int buildCounterAllocateIdsRequest = 0; |
| buildAllocateIdsRequest() { |
| var o = new api.AllocateIdsRequest(); |
| buildCounterAllocateIdsRequest++; |
| if (buildCounterAllocateIdsRequest < 3) { |
| o.keys = buildUnnamed573(); |
| } |
| buildCounterAllocateIdsRequest--; |
| return o; |
| } |
| |
| checkAllocateIdsRequest(api.AllocateIdsRequest o) { |
| buildCounterAllocateIdsRequest++; |
| if (buildCounterAllocateIdsRequest < 3) { |
| checkUnnamed573(o.keys); |
| } |
| buildCounterAllocateIdsRequest--; |
| } |
| |
| buildUnnamed574() { |
| var o = new core.List<api.Key>(); |
| o.add(buildKey()); |
| o.add(buildKey()); |
| return o; |
| } |
| |
| checkUnnamed574(core.List<api.Key> o) { |
| unittest.expect(o, unittest.hasLength(2)); |
| checkKey(o[0]); |
| checkKey(o[1]); |
| } |
| |
| core.int buildCounterAllocateIdsResponse = 0; |
| buildAllocateIdsResponse() { |
| var o = new api.AllocateIdsResponse(); |
| buildCounterAllocateIdsResponse++; |
| if (buildCounterAllocateIdsResponse < 3) { |
| o.keys = buildUnnamed574(); |
| } |
| buildCounterAllocateIdsResponse--; |
| return o; |
| } |
| |
| checkAllocateIdsResponse(api.AllocateIdsResponse o) { |
| buildCounterAllocateIdsResponse++; |
| if (buildCounterAllocateIdsResponse < 3) { |
| checkUnnamed574(o.keys); |
| } |
| buildCounterAllocateIdsResponse--; |
| } |
| |
| buildUnnamed575() { |
| var o = new core.List<api.Value>(); |
| o.add(buildValue()); |
| o.add(buildValue()); |
| return o; |
| } |
| |
| checkUnnamed575(core.List<api.Value> o) { |
| unittest.expect(o, unittest.hasLength(2)); |
| checkValue(o[0]); |
| checkValue(o[1]); |
| } |
| |
| core.int buildCounterArrayValue = 0; |
| buildArrayValue() { |
| var o = new api.ArrayValue(); |
| buildCounterArrayValue++; |
| if (buildCounterArrayValue < 3) { |
| o.values = buildUnnamed575(); |
| } |
| buildCounterArrayValue--; |
| return o; |
| } |
| |
| checkArrayValue(api.ArrayValue o) { |
| buildCounterArrayValue++; |
| if (buildCounterArrayValue < 3) { |
| checkUnnamed575(o.values); |
| } |
| buildCounterArrayValue--; |
| } |
| |
| core.int buildCounterBeginTransactionRequest = 0; |
| buildBeginTransactionRequest() { |
| var o = new api.BeginTransactionRequest(); |
| buildCounterBeginTransactionRequest++; |
| if (buildCounterBeginTransactionRequest < 3) { |
| } |
| buildCounterBeginTransactionRequest--; |
| return o; |
| } |
| |
| checkBeginTransactionRequest(api.BeginTransactionRequest o) { |
| buildCounterBeginTransactionRequest++; |
| if (buildCounterBeginTransactionRequest < 3) { |
| } |
| buildCounterBeginTransactionRequest--; |
| } |
| |
| core.int buildCounterBeginTransactionResponse = 0; |
| buildBeginTransactionResponse() { |
| var o = new api.BeginTransactionResponse(); |
| buildCounterBeginTransactionResponse++; |
| if (buildCounterBeginTransactionResponse < 3) { |
| o.transaction = "foo"; |
| } |
| buildCounterBeginTransactionResponse--; |
| return o; |
| } |
| |
| checkBeginTransactionResponse(api.BeginTransactionResponse o) { |
| buildCounterBeginTransactionResponse++; |
| if (buildCounterBeginTransactionResponse < 3) { |
| unittest.expect(o.transaction, unittest.equals('foo')); |
| } |
| buildCounterBeginTransactionResponse--; |
| } |
| |
| buildUnnamed576() { |
| var o = new core.List<api.Mutation>(); |
| o.add(buildMutation()); |
| o.add(buildMutation()); |
| return o; |
| } |
| |
| checkUnnamed576(core.List<api.Mutation> o) { |
| unittest.expect(o, unittest.hasLength(2)); |
| checkMutation(o[0]); |
| checkMutation(o[1]); |
| } |
| |
| core.int buildCounterCommitRequest = 0; |
| buildCommitRequest() { |
| var o = new api.CommitRequest(); |
| buildCounterCommitRequest++; |
| if (buildCounterCommitRequest < 3) { |
| o.mode = "foo"; |
| o.mutations = buildUnnamed576(); |
| o.transaction = "foo"; |
| } |
| buildCounterCommitRequest--; |
| return o; |
| } |
| |
| checkCommitRequest(api.CommitRequest o) { |
| buildCounterCommitRequest++; |
| if (buildCounterCommitRequest < 3) { |
| unittest.expect(o.mode, unittest.equals('foo')); |
| checkUnnamed576(o.mutations); |
| unittest.expect(o.transaction, unittest.equals('foo')); |
| } |
| buildCounterCommitRequest--; |
| } |
| |
| buildUnnamed577() { |
| var o = new core.List<api.MutationResult>(); |
| o.add(buildMutationResult()); |
| o.add(buildMutationResult()); |
| return o; |
| } |
| |
| checkUnnamed577(core.List<api.MutationResult> o) { |
| unittest.expect(o, unittest.hasLength(2)); |
| checkMutationResult(o[0]); |
| checkMutationResult(o[1]); |
| } |
| |
| core.int buildCounterCommitResponse = 0; |
| buildCommitResponse() { |
| var o = new api.CommitResponse(); |
| buildCounterCommitResponse++; |
| if (buildCounterCommitResponse < 3) { |
| o.indexUpdates = 42; |
| o.mutationResults = buildUnnamed577(); |
| } |
| buildCounterCommitResponse--; |
| return o; |
| } |
| |
| checkCommitResponse(api.CommitResponse o) { |
| buildCounterCommitResponse++; |
| if (buildCounterCommitResponse < 3) { |
| unittest.expect(o.indexUpdates, unittest.equals(42)); |
| checkUnnamed577(o.mutationResults); |
| } |
| buildCounterCommitResponse--; |
| } |
| |
| buildUnnamed578() { |
| var o = new core.List<api.Filter>(); |
| o.add(buildFilter()); |
| o.add(buildFilter()); |
| return o; |
| } |
| |
| checkUnnamed578(core.List<api.Filter> o) { |
| unittest.expect(o, unittest.hasLength(2)); |
| checkFilter(o[0]); |
| checkFilter(o[1]); |
| } |
| |
| core.int buildCounterCompositeFilter = 0; |
| buildCompositeFilter() { |
| var o = new api.CompositeFilter(); |
| buildCounterCompositeFilter++; |
| if (buildCounterCompositeFilter < 3) { |
| o.filters = buildUnnamed578(); |
| o.op = "foo"; |
| } |
| buildCounterCompositeFilter--; |
| return o; |
| } |
| |
| checkCompositeFilter(api.CompositeFilter o) { |
| buildCounterCompositeFilter++; |
| if (buildCounterCompositeFilter < 3) { |
| checkUnnamed578(o.filters); |
| unittest.expect(o.op, unittest.equals('foo')); |
| } |
| buildCounterCompositeFilter--; |
| } |
| |
| buildUnnamed579() { |
| var o = new core.Map<core.String, api.Value>(); |
| o["x"] = buildValue(); |
| o["y"] = buildValue(); |
| return o; |
| } |
| |
| checkUnnamed579(core.Map<core.String, api.Value> o) { |
| unittest.expect(o, unittest.hasLength(2)); |
| checkValue(o["x"]); |
| checkValue(o["y"]); |
| } |
| |
| core.int buildCounterEntity = 0; |
| buildEntity() { |
| var o = new api.Entity(); |
| buildCounterEntity++; |
| if (buildCounterEntity < 3) { |
| o.key = buildKey(); |
| o.properties = buildUnnamed579(); |
| } |
| buildCounterEntity--; |
| return o; |
| } |
| |
| checkEntity(api.Entity o) { |
| buildCounterEntity++; |
| if (buildCounterEntity < 3) { |
| checkKey(o.key); |
| checkUnnamed579(o.properties); |
| } |
| buildCounterEntity--; |
| } |
| |
| core.int buildCounterEntityResult = 0; |
| buildEntityResult() { |
| var o = new api.EntityResult(); |
| buildCounterEntityResult++; |
| if (buildCounterEntityResult < 3) { |
| o.cursor = "foo"; |
| o.entity = buildEntity(); |
| o.version = "foo"; |
| } |
| buildCounterEntityResult--; |
| return o; |
| } |
| |
| checkEntityResult(api.EntityResult o) { |
| buildCounterEntityResult++; |
| if (buildCounterEntityResult < 3) { |
| unittest.expect(o.cursor, unittest.equals('foo')); |
| checkEntity(o.entity); |
| unittest.expect(o.version, unittest.equals('foo')); |
| } |
| buildCounterEntityResult--; |
| } |
| |
| core.int buildCounterFilter = 0; |
| buildFilter() { |
| var o = new api.Filter(); |
| buildCounterFilter++; |
| if (buildCounterFilter < 3) { |
| o.compositeFilter = buildCompositeFilter(); |
| o.propertyFilter = buildPropertyFilter(); |
| } |
| buildCounterFilter--; |
| return o; |
| } |
| |
| checkFilter(api.Filter o) { |
| buildCounterFilter++; |
| if (buildCounterFilter < 3) { |
| checkCompositeFilter(o.compositeFilter); |
| checkPropertyFilter(o.propertyFilter); |
| } |
| buildCounterFilter--; |
| } |
| |
| buildUnnamed580() { |
| var o = new core.Map<core.String, api.GqlQueryParameter>(); |
| o["x"] = buildGqlQueryParameter(); |
| o["y"] = buildGqlQueryParameter(); |
| return o; |
| } |
| |
| checkUnnamed580(core.Map<core.String, api.GqlQueryParameter> o) { |
| unittest.expect(o, unittest.hasLength(2)); |
| checkGqlQueryParameter(o["x"]); |
| checkGqlQueryParameter(o["y"]); |
| } |
| |
| buildUnnamed581() { |
| var o = new core.List<api.GqlQueryParameter>(); |
| o.add(buildGqlQueryParameter()); |
| o.add(buildGqlQueryParameter()); |
| return o; |
| } |
| |
| checkUnnamed581(core.List<api.GqlQueryParameter> o) { |
| unittest.expect(o, unittest.hasLength(2)); |
| checkGqlQueryParameter(o[0]); |
| checkGqlQueryParameter(o[1]); |
| } |
| |
| core.int buildCounterGqlQuery = 0; |
| buildGqlQuery() { |
| var o = new api.GqlQuery(); |
| buildCounterGqlQuery++; |
| if (buildCounterGqlQuery < 3) { |
| o.allowLiterals = true; |
| o.namedBindings = buildUnnamed580(); |
| o.positionalBindings = buildUnnamed581(); |
| o.queryString = "foo"; |
| } |
| buildCounterGqlQuery--; |
| return o; |
| } |
| |
| checkGqlQuery(api.GqlQuery o) { |
| buildCounterGqlQuery++; |
| if (buildCounterGqlQuery < 3) { |
| unittest.expect(o.allowLiterals, unittest.isTrue); |
| checkUnnamed580(o.namedBindings); |
| checkUnnamed581(o.positionalBindings); |
| unittest.expect(o.queryString, unittest.equals('foo')); |
| } |
| buildCounterGqlQuery--; |
| } |
| |
| core.int buildCounterGqlQueryParameter = 0; |
| buildGqlQueryParameter() { |
| var o = new api.GqlQueryParameter(); |
| buildCounterGqlQueryParameter++; |
| if (buildCounterGqlQueryParameter < 3) { |
| o.cursor = "foo"; |
| o.value = buildValue(); |
| } |
| buildCounterGqlQueryParameter--; |
| return o; |
| } |
| |
| checkGqlQueryParameter(api.GqlQueryParameter o) { |
| buildCounterGqlQueryParameter++; |
| if (buildCounterGqlQueryParameter < 3) { |
| unittest.expect(o.cursor, unittest.equals('foo')); |
| checkValue(o.value); |
| } |
| buildCounterGqlQueryParameter--; |
| } |
| |
| buildUnnamed582() { |
| var o = new core.List<api.PathElement>(); |
| o.add(buildPathElement()); |
| o.add(buildPathElement()); |
| return o; |
| } |
| |
| checkUnnamed582(core.List<api.PathElement> o) { |
| unittest.expect(o, unittest.hasLength(2)); |
| checkPathElement(o[0]); |
| checkPathElement(o[1]); |
| } |
| |
| core.int buildCounterKey = 0; |
| buildKey() { |
| var o = new api.Key(); |
| buildCounterKey++; |
| if (buildCounterKey < 3) { |
| o.partitionId = buildPartitionId(); |
| o.path = buildUnnamed582(); |
| } |
| buildCounterKey--; |
| return o; |
| } |
| |
| checkKey(api.Key o) { |
| buildCounterKey++; |
| if (buildCounterKey < 3) { |
| checkPartitionId(o.partitionId); |
| checkUnnamed582(o.path); |
| } |
| buildCounterKey--; |
| } |
| |
| core.int buildCounterKindExpression = 0; |
| buildKindExpression() { |
| var o = new api.KindExpression(); |
| buildCounterKindExpression++; |
| if (buildCounterKindExpression < 3) { |
| o.name = "foo"; |
| } |
| buildCounterKindExpression--; |
| return o; |
| } |
| |
| checkKindExpression(api.KindExpression o) { |
| buildCounterKindExpression++; |
| if (buildCounterKindExpression < 3) { |
| unittest.expect(o.name, unittest.equals('foo')); |
| } |
| buildCounterKindExpression--; |
| } |
| |
| core.int buildCounterLatLng = 0; |
| buildLatLng() { |
| var o = new api.LatLng(); |
| buildCounterLatLng++; |
| if (buildCounterLatLng < 3) { |
| o.latitude = 42.0; |
| o.longitude = 42.0; |
| } |
| buildCounterLatLng--; |
| return o; |
| } |
| |
| checkLatLng(api.LatLng o) { |
| buildCounterLatLng++; |
| if (buildCounterLatLng < 3) { |
| unittest.expect(o.latitude, unittest.equals(42.0)); |
| unittest.expect(o.longitude, unittest.equals(42.0)); |
| } |
| buildCounterLatLng--; |
| } |
| |
| buildUnnamed583() { |
| var o = new core.List<api.Key>(); |
| o.add(buildKey()); |
| o.add(buildKey()); |
| return o; |
| } |
| |
| checkUnnamed583(core.List<api.Key> o) { |
| unittest.expect(o, unittest.hasLength(2)); |
| checkKey(o[0]); |
| checkKey(o[1]); |
| } |
| |
| core.int buildCounterLookupRequest = 0; |
| buildLookupRequest() { |
| var o = new api.LookupRequest(); |
| buildCounterLookupRequest++; |
| if (buildCounterLookupRequest < 3) { |
| o.keys = buildUnnamed583(); |
| o.readOptions = buildReadOptions(); |
| } |
| buildCounterLookupRequest--; |
| return o; |
| } |
| |
| checkLookupRequest(api.LookupRequest o) { |
| buildCounterLookupRequest++; |
| if (buildCounterLookupRequest < 3) { |
| checkUnnamed583(o.keys); |
| checkReadOptions(o.readOptions); |
| } |
| buildCounterLookupRequest--; |
| } |
| |
| buildUnnamed584() { |
| var o = new core.List<api.Key>(); |
| o.add(buildKey()); |
| o.add(buildKey()); |
| return o; |
| } |
| |
| checkUnnamed584(core.List<api.Key> o) { |
| unittest.expect(o, unittest.hasLength(2)); |
| checkKey(o[0]); |
| checkKey(o[1]); |
| } |
| |
| buildUnnamed585() { |
| var o = new core.List<api.EntityResult>(); |
| o.add(buildEntityResult()); |
| o.add(buildEntityResult()); |
| return o; |
| } |
| |
| checkUnnamed585(core.List<api.EntityResult> o) { |
| unittest.expect(o, unittest.hasLength(2)); |
| checkEntityResult(o[0]); |
| checkEntityResult(o[1]); |
| } |
| |
| buildUnnamed586() { |
| var o = new core.List<api.EntityResult>(); |
| o.add(buildEntityResult()); |
| o.add(buildEntityResult()); |
| return o; |
| } |
| |
| checkUnnamed586(core.List<api.EntityResult> o) { |
| unittest.expect(o, unittest.hasLength(2)); |
| checkEntityResult(o[0]); |
| checkEntityResult(o[1]); |
| } |
| |
| core.int buildCounterLookupResponse = 0; |
| buildLookupResponse() { |
| var o = new api.LookupResponse(); |
| buildCounterLookupResponse++; |
| if (buildCounterLookupResponse < 3) { |
| o.deferred = buildUnnamed584(); |
| o.found = buildUnnamed585(); |
| o.missing = buildUnnamed586(); |
| } |
| buildCounterLookupResponse--; |
| return o; |
| } |
| |
| checkLookupResponse(api.LookupResponse o) { |
| buildCounterLookupResponse++; |
| if (buildCounterLookupResponse < 3) { |
| checkUnnamed584(o.deferred); |
| checkUnnamed585(o.found); |
| checkUnnamed586(o.missing); |
| } |
| buildCounterLookupResponse--; |
| } |
| |
| core.int buildCounterMutation = 0; |
| buildMutation() { |
| var o = new api.Mutation(); |
| buildCounterMutation++; |
| if (buildCounterMutation < 3) { |
| o.baseVersion = "foo"; |
| o.delete = buildKey(); |
| o.insert = buildEntity(); |
| o.update = buildEntity(); |
| o.upsert = buildEntity(); |
| } |
| buildCounterMutation--; |
| return o; |
| } |
| |
| checkMutation(api.Mutation o) { |
| buildCounterMutation++; |
| if (buildCounterMutation < 3) { |
| unittest.expect(o.baseVersion, unittest.equals('foo')); |
| checkKey(o.delete); |
| checkEntity(o.insert); |
| checkEntity(o.update); |
| checkEntity(o.upsert); |
| } |
| buildCounterMutation--; |
| } |
| |
| core.int buildCounterMutationResult = 0; |
| buildMutationResult() { |
| var o = new api.MutationResult(); |
| buildCounterMutationResult++; |
| if (buildCounterMutationResult < 3) { |
| o.conflictDetected = true; |
| o.key = buildKey(); |
| o.version = "foo"; |
| } |
| buildCounterMutationResult--; |
| return o; |
| } |
| |
| checkMutationResult(api.MutationResult o) { |
| buildCounterMutationResult++; |
| if (buildCounterMutationResult < 3) { |
| unittest.expect(o.conflictDetected, unittest.isTrue); |
| checkKey(o.key); |
| unittest.expect(o.version, unittest.equals('foo')); |
| } |
| buildCounterMutationResult--; |
| } |
| |
| core.int buildCounterPartitionId = 0; |
| buildPartitionId() { |
| var o = new api.PartitionId(); |
| buildCounterPartitionId++; |
| if (buildCounterPartitionId < 3) { |
| o.namespaceId = "foo"; |
| o.projectId = "foo"; |
| } |
| buildCounterPartitionId--; |
| return o; |
| } |
| |
| checkPartitionId(api.PartitionId o) { |
| buildCounterPartitionId++; |
| if (buildCounterPartitionId < 3) { |
| unittest.expect(o.namespaceId, unittest.equals('foo')); |
| unittest.expect(o.projectId, unittest.equals('foo')); |
| } |
| buildCounterPartitionId--; |
| } |
| |
| core.int buildCounterPathElement = 0; |
| buildPathElement() { |
| var o = new api.PathElement(); |
| buildCounterPathElement++; |
| if (buildCounterPathElement < 3) { |
| o.id = "foo"; |
| o.kind = "foo"; |
| o.name = "foo"; |
| } |
| buildCounterPathElement--; |
| return o; |
| } |
| |
| checkPathElement(api.PathElement o) { |
| buildCounterPathElement++; |
| if (buildCounterPathElement < 3) { |
| unittest.expect(o.id, unittest.equals('foo')); |
| unittest.expect(o.kind, unittest.equals('foo')); |
| unittest.expect(o.name, unittest.equals('foo')); |
| } |
| buildCounterPathElement--; |
| } |
| |
| core.int buildCounterProjection = 0; |
| buildProjection() { |
| var o = new api.Projection(); |
| buildCounterProjection++; |
| if (buildCounterProjection < 3) { |
| o.property = buildPropertyReference(); |
| } |
| buildCounterProjection--; |
| return o; |
| } |
| |
| checkProjection(api.Projection o) { |
| buildCounterProjection++; |
| if (buildCounterProjection < 3) { |
| checkPropertyReference(o.property); |
| } |
| buildCounterProjection--; |
| } |
| |
| core.int buildCounterPropertyFilter = 0; |
| buildPropertyFilter() { |
| var o = new api.PropertyFilter(); |
| buildCounterPropertyFilter++; |
| if (buildCounterPropertyFilter < 3) { |
| o.op = "foo"; |
| o.property = buildPropertyReference(); |
| o.value = buildValue(); |
| } |
| buildCounterPropertyFilter--; |
| return o; |
| } |
| |
| checkPropertyFilter(api.PropertyFilter o) { |
| buildCounterPropertyFilter++; |
| if (buildCounterPropertyFilter < 3) { |
| unittest.expect(o.op, unittest.equals('foo')); |
| checkPropertyReference(o.property); |
| checkValue(o.value); |
| } |
| buildCounterPropertyFilter--; |
| } |
| |
| core.int buildCounterPropertyOrder = 0; |
| buildPropertyOrder() { |
| var o = new api.PropertyOrder(); |
| buildCounterPropertyOrder++; |
| if (buildCounterPropertyOrder < 3) { |
| o.direction = "foo"; |
| o.property = buildPropertyReference(); |
| } |
| buildCounterPropertyOrder--; |
| return o; |
| } |
| |
| checkPropertyOrder(api.PropertyOrder o) { |
| buildCounterPropertyOrder++; |
| if (buildCounterPropertyOrder < 3) { |
| unittest.expect(o.direction, unittest.equals('foo')); |
| checkPropertyReference(o.property); |
| } |
| buildCounterPropertyOrder--; |
| } |
| |
| core.int buildCounterPropertyReference = 0; |
| buildPropertyReference() { |
| var o = new api.PropertyReference(); |
| buildCounterPropertyReference++; |
| if (buildCounterPropertyReference < 3) { |
| o.name = "foo"; |
| } |
| buildCounterPropertyReference--; |
| return o; |
| } |
| |
| checkPropertyReference(api.PropertyReference o) { |
| buildCounterPropertyReference++; |
| if (buildCounterPropertyReference < 3) { |
| unittest.expect(o.name, unittest.equals('foo')); |
| } |
| buildCounterPropertyReference--; |
| } |
| |
| buildUnnamed587() { |
| var o = new core.List<api.PropertyReference>(); |
| o.add(buildPropertyReference()); |
| o.add(buildPropertyReference()); |
| return o; |
| } |
| |
| checkUnnamed587(core.List<api.PropertyReference> o) { |
| unittest.expect(o, unittest.hasLength(2)); |
| checkPropertyReference(o[0]); |
| checkPropertyReference(o[1]); |
| } |
| |
| buildUnnamed588() { |
| var o = new core.List<api.KindExpression>(); |
| o.add(buildKindExpression()); |
| o.add(buildKindExpression()); |
| return o; |
| } |
| |
| checkUnnamed588(core.List<api.KindExpression> o) { |
| unittest.expect(o, unittest.hasLength(2)); |
| checkKindExpression(o[0]); |
| checkKindExpression(o[1]); |
| } |
| |
| buildUnnamed589() { |
| var o = new core.List<api.PropertyOrder>(); |
| o.add(buildPropertyOrder()); |
| o.add(buildPropertyOrder()); |
| return o; |
| } |
| |
| checkUnnamed589(core.List<api.PropertyOrder> o) { |
| unittest.expect(o, unittest.hasLength(2)); |
| checkPropertyOrder(o[0]); |
| checkPropertyOrder(o[1]); |
| } |
| |
| buildUnnamed590() { |
| var o = new core.List<api.Projection>(); |
| o.add(buildProjection()); |
| o.add(buildProjection()); |
| return o; |
| } |
| |
| checkUnnamed590(core.List<api.Projection> o) { |
| unittest.expect(o, unittest.hasLength(2)); |
| checkProjection(o[0]); |
| checkProjection(o[1]); |
| } |
| |
| core.int buildCounterQuery = 0; |
| buildQuery() { |
| var o = new api.Query(); |
| buildCounterQuery++; |
| if (buildCounterQuery < 3) { |
| o.distinctOn = buildUnnamed587(); |
| o.endCursor = "foo"; |
| o.filter = buildFilter(); |
| o.kind = buildUnnamed588(); |
| o.limit = 42; |
| o.offset = 42; |
| o.order = buildUnnamed589(); |
| o.projection = buildUnnamed590(); |
| o.startCursor = "foo"; |
| } |
| buildCounterQuery--; |
| return o; |
| } |
| |
| checkQuery(api.Query o) { |
| buildCounterQuery++; |
| if (buildCounterQuery < 3) { |
| checkUnnamed587(o.distinctOn); |
| unittest.expect(o.endCursor, unittest.equals('foo')); |
| checkFilter(o.filter); |
| checkUnnamed588(o.kind); |
| unittest.expect(o.limit, unittest.equals(42)); |
| unittest.expect(o.offset, unittest.equals(42)); |
| checkUnnamed589(o.order); |
| checkUnnamed590(o.projection); |
| unittest.expect(o.startCursor, unittest.equals('foo')); |
| } |
| buildCounterQuery--; |
| } |
| |
| buildUnnamed591() { |
| var o = new core.List<api.EntityResult>(); |
| o.add(buildEntityResult()); |
| o.add(buildEntityResult()); |
| return o; |
| } |
| |
| checkUnnamed591(core.List<api.EntityResult> o) { |
| unittest.expect(o, unittest.hasLength(2)); |
| checkEntityResult(o[0]); |
| checkEntityResult(o[1]); |
| } |
| |
| core.int buildCounterQueryResultBatch = 0; |
| buildQueryResultBatch() { |
| var o = new api.QueryResultBatch(); |
| buildCounterQueryResultBatch++; |
| if (buildCounterQueryResultBatch < 3) { |
| o.endCursor = "foo"; |
| o.entityResultType = "foo"; |
| o.entityResults = buildUnnamed591(); |
| o.moreResults = "foo"; |
| o.skippedCursor = "foo"; |
| o.skippedResults = 42; |
| o.snapshotVersion = "foo"; |
| } |
| buildCounterQueryResultBatch--; |
| return o; |
| } |
| |
| checkQueryResultBatch(api.QueryResultBatch o) { |
| buildCounterQueryResultBatch++; |
| if (buildCounterQueryResultBatch < 3) { |
| unittest.expect(o.endCursor, unittest.equals('foo')); |
| unittest.expect(o.entityResultType, unittest.equals('foo')); |
| checkUnnamed591(o.entityResults); |
| unittest.expect(o.moreResults, unittest.equals('foo')); |
| unittest.expect(o.skippedCursor, unittest.equals('foo')); |
| unittest.expect(o.skippedResults, unittest.equals(42)); |
| unittest.expect(o.snapshotVersion, unittest.equals('foo')); |
| } |
| buildCounterQueryResultBatch--; |
| } |
| |
| core.int buildCounterReadOptions = 0; |
| buildReadOptions() { |
| var o = new api.ReadOptions(); |
| buildCounterReadOptions++; |
| if (buildCounterReadOptions < 3) { |
| o.readConsistency = "foo"; |
| o.transaction = "foo"; |
| } |
| buildCounterReadOptions--; |
| return o; |
| } |
| |
| checkReadOptions(api.ReadOptions o) { |
| buildCounterReadOptions++; |
| if (buildCounterReadOptions < 3) { |
| unittest.expect(o.readConsistency, unittest.equals('foo')); |
| unittest.expect(o.transaction, unittest.equals('foo')); |
| } |
| buildCounterReadOptions--; |
| } |
| |
| core.int buildCounterRollbackRequest = 0; |
| buildRollbackRequest() { |
| var o = new api.RollbackRequest(); |
| buildCounterRollbackRequest++; |
| if (buildCounterRollbackRequest < 3) { |
| o.transaction = "foo"; |
| } |
| buildCounterRollbackRequest--; |
| return o; |
| } |
| |
| checkRollbackRequest(api.RollbackRequest o) { |
| buildCounterRollbackRequest++; |
| if (buildCounterRollbackRequest < 3) { |
| unittest.expect(o.transaction, unittest.equals('foo')); |
| } |
| buildCounterRollbackRequest--; |
| } |
| |
| core.int buildCounterRollbackResponse = 0; |
| buildRollbackResponse() { |
| var o = new api.RollbackResponse(); |
| buildCounterRollbackResponse++; |
| if (buildCounterRollbackResponse < 3) { |
| } |
| buildCounterRollbackResponse--; |
| return o; |
| } |
| |
| checkRollbackResponse(api.RollbackResponse o) { |
| buildCounterRollbackResponse++; |
| if (buildCounterRollbackResponse < 3) { |
| } |
| buildCounterRollbackResponse--; |
| } |
| |
| core.int buildCounterRunQueryRequest = 0; |
| buildRunQueryRequest() { |
| var o = new api.RunQueryRequest(); |
| buildCounterRunQueryRequest++; |
| if (buildCounterRunQueryRequest < 3) { |
| o.gqlQuery = buildGqlQuery(); |
| o.partitionId = buildPartitionId(); |
| o.query = buildQuery(); |
| o.readOptions = buildReadOptions(); |
| } |
| buildCounterRunQueryRequest--; |
| return o; |
| } |
| |
| checkRunQueryRequest(api.RunQueryRequest o) { |
| buildCounterRunQueryRequest++; |
| if (buildCounterRunQueryRequest < 3) { |
| checkGqlQuery(o.gqlQuery); |
| checkPartitionId(o.partitionId); |
| checkQuery(o.query); |
| checkReadOptions(o.readOptions); |
| } |
| buildCounterRunQueryRequest--; |
| } |
| |
| core.int buildCounterRunQueryResponse = 0; |
| buildRunQueryResponse() { |
| var o = new api.RunQueryResponse(); |
| buildCounterRunQueryResponse++; |
| if (buildCounterRunQueryResponse < 3) { |
| o.batch = buildQueryResultBatch(); |
| o.query = buildQuery(); |
| } |
| buildCounterRunQueryResponse--; |
| return o; |
| } |
| |
| checkRunQueryResponse(api.RunQueryResponse o) { |
| buildCounterRunQueryResponse++; |
| if (buildCounterRunQueryResponse < 3) { |
| checkQueryResultBatch(o.batch); |
| checkQuery(o.query); |
| } |
| buildCounterRunQueryResponse--; |
| } |
| |
| core.int buildCounterValue = 0; |
| buildValue() { |
| var o = new api.Value(); |
| buildCounterValue++; |
| if (buildCounterValue < 3) { |
| o.arrayValue = buildArrayValue(); |
| o.blobValue = "foo"; |
| o.booleanValue = true; |
| o.doubleValue = 42.0; |
| o.entityValue = buildEntity(); |
| o.excludeFromIndexes = true; |
| o.geoPointValue = buildLatLng(); |
| o.integerValue = "foo"; |
| o.keyValue = buildKey(); |
| o.meaning = 42; |
| o.nullValue = "foo"; |
| o.stringValue = "foo"; |
| o.timestampValue = "foo"; |
| } |
| buildCounterValue--; |
| return o; |
| } |
| |
| checkValue(api.Value o) { |
| buildCounterValue++; |
| if (buildCounterValue < 3) { |
| checkArrayValue(o.arrayValue); |
| unittest.expect(o.blobValue, unittest.equals('foo')); |
| unittest.expect(o.booleanValue, unittest.isTrue); |
| unittest.expect(o.doubleValue, unittest.equals(42.0)); |
| checkEntity(o.entityValue); |
| unittest.expect(o.excludeFromIndexes, unittest.isTrue); |
| checkLatLng(o.geoPointValue); |
| unittest.expect(o.integerValue, unittest.equals('foo')); |
| checkKey(o.keyValue); |
| unittest.expect(o.meaning, unittest.equals(42)); |
| unittest.expect(o.nullValue, unittest.equals('foo')); |
| unittest.expect(o.stringValue, unittest.equals('foo')); |
| unittest.expect(o.timestampValue, unittest.equals('foo')); |
| } |
| buildCounterValue--; |
| } |
| |
| |
| main() { |
| unittest.group("obj-schema-AllocateIdsRequest", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildAllocateIdsRequest(); |
| var od = new api.AllocateIdsRequest.fromJson(o.toJson()); |
| checkAllocateIdsRequest(od); |
| }); |
| }); |
| |
| |
| unittest.group("obj-schema-AllocateIdsResponse", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildAllocateIdsResponse(); |
| var od = new api.AllocateIdsResponse.fromJson(o.toJson()); |
| checkAllocateIdsResponse(od); |
| }); |
| }); |
| |
| |
| unittest.group("obj-schema-ArrayValue", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildArrayValue(); |
| var od = new api.ArrayValue.fromJson(o.toJson()); |
| checkArrayValue(od); |
| }); |
| }); |
| |
| |
| unittest.group("obj-schema-BeginTransactionRequest", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildBeginTransactionRequest(); |
| var od = new api.BeginTransactionRequest.fromJson(o.toJson()); |
| checkBeginTransactionRequest(od); |
| }); |
| }); |
| |
| |
| unittest.group("obj-schema-BeginTransactionResponse", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildBeginTransactionResponse(); |
| var od = new api.BeginTransactionResponse.fromJson(o.toJson()); |
| checkBeginTransactionResponse(od); |
| }); |
| }); |
| |
| |
| unittest.group("obj-schema-CommitRequest", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildCommitRequest(); |
| var od = new api.CommitRequest.fromJson(o.toJson()); |
| checkCommitRequest(od); |
| }); |
| }); |
| |
| |
| unittest.group("obj-schema-CommitResponse", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildCommitResponse(); |
| var od = new api.CommitResponse.fromJson(o.toJson()); |
| checkCommitResponse(od); |
| }); |
| }); |
| |
| |
| unittest.group("obj-schema-CompositeFilter", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildCompositeFilter(); |
| var od = new api.CompositeFilter.fromJson(o.toJson()); |
| checkCompositeFilter(od); |
| }); |
| }); |
| |
| |
| unittest.group("obj-schema-Entity", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildEntity(); |
| var od = new api.Entity.fromJson(o.toJson()); |
| checkEntity(od); |
| }); |
| }); |
| |
| |
| unittest.group("obj-schema-EntityResult", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildEntityResult(); |
| var od = new api.EntityResult.fromJson(o.toJson()); |
| checkEntityResult(od); |
| }); |
| }); |
| |
| |
| unittest.group("obj-schema-Filter", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildFilter(); |
| var od = new api.Filter.fromJson(o.toJson()); |
| checkFilter(od); |
| }); |
| }); |
| |
| |
| unittest.group("obj-schema-GqlQuery", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildGqlQuery(); |
| var od = new api.GqlQuery.fromJson(o.toJson()); |
| checkGqlQuery(od); |
| }); |
| }); |
| |
| |
| unittest.group("obj-schema-GqlQueryParameter", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildGqlQueryParameter(); |
| var od = new api.GqlQueryParameter.fromJson(o.toJson()); |
| checkGqlQueryParameter(od); |
| }); |
| }); |
| |
| |
| unittest.group("obj-schema-Key", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildKey(); |
| var od = new api.Key.fromJson(o.toJson()); |
| checkKey(od); |
| }); |
| }); |
| |
| |
| unittest.group("obj-schema-KindExpression", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildKindExpression(); |
| var od = new api.KindExpression.fromJson(o.toJson()); |
| checkKindExpression(od); |
| }); |
| }); |
| |
| |
| unittest.group("obj-schema-LatLng", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildLatLng(); |
| var od = new api.LatLng.fromJson(o.toJson()); |
| checkLatLng(od); |
| }); |
| }); |
| |
| |
| unittest.group("obj-schema-LookupRequest", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildLookupRequest(); |
| var od = new api.LookupRequest.fromJson(o.toJson()); |
| checkLookupRequest(od); |
| }); |
| }); |
| |
| |
| unittest.group("obj-schema-LookupResponse", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildLookupResponse(); |
| var od = new api.LookupResponse.fromJson(o.toJson()); |
| checkLookupResponse(od); |
| }); |
| }); |
| |
| |
| unittest.group("obj-schema-Mutation", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildMutation(); |
| var od = new api.Mutation.fromJson(o.toJson()); |
| checkMutation(od); |
| }); |
| }); |
| |
| |
| unittest.group("obj-schema-MutationResult", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildMutationResult(); |
| var od = new api.MutationResult.fromJson(o.toJson()); |
| checkMutationResult(od); |
| }); |
| }); |
| |
| |
| unittest.group("obj-schema-PartitionId", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildPartitionId(); |
| var od = new api.PartitionId.fromJson(o.toJson()); |
| checkPartitionId(od); |
| }); |
| }); |
| |
| |
| unittest.group("obj-schema-PathElement", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildPathElement(); |
| var od = new api.PathElement.fromJson(o.toJson()); |
| checkPathElement(od); |
| }); |
| }); |
| |
| |
| unittest.group("obj-schema-Projection", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildProjection(); |
| var od = new api.Projection.fromJson(o.toJson()); |
| checkProjection(od); |
| }); |
| }); |
| |
| |
| unittest.group("obj-schema-PropertyFilter", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildPropertyFilter(); |
| var od = new api.PropertyFilter.fromJson(o.toJson()); |
| checkPropertyFilter(od); |
| }); |
| }); |
| |
| |
| unittest.group("obj-schema-PropertyOrder", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildPropertyOrder(); |
| var od = new api.PropertyOrder.fromJson(o.toJson()); |
| checkPropertyOrder(od); |
| }); |
| }); |
| |
| |
| unittest.group("obj-schema-PropertyReference", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildPropertyReference(); |
| var od = new api.PropertyReference.fromJson(o.toJson()); |
| checkPropertyReference(od); |
| }); |
| }); |
| |
| |
| unittest.group("obj-schema-Query", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildQuery(); |
| var od = new api.Query.fromJson(o.toJson()); |
| checkQuery(od); |
| }); |
| }); |
| |
| |
| unittest.group("obj-schema-QueryResultBatch", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildQueryResultBatch(); |
| var od = new api.QueryResultBatch.fromJson(o.toJson()); |
| checkQueryResultBatch(od); |
| }); |
| }); |
| |
| |
| unittest.group("obj-schema-ReadOptions", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildReadOptions(); |
| var od = new api.ReadOptions.fromJson(o.toJson()); |
| checkReadOptions(od); |
| }); |
| }); |
| |
| |
| unittest.group("obj-schema-RollbackRequest", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildRollbackRequest(); |
| var od = new api.RollbackRequest.fromJson(o.toJson()); |
| checkRollbackRequest(od); |
| }); |
| }); |
| |
| |
| unittest.group("obj-schema-RollbackResponse", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildRollbackResponse(); |
| var od = new api.RollbackResponse.fromJson(o.toJson()); |
| checkRollbackResponse(od); |
| }); |
| }); |
| |
| |
| unittest.group("obj-schema-RunQueryRequest", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildRunQueryRequest(); |
| var od = new api.RunQueryRequest.fromJson(o.toJson()); |
| checkRunQueryRequest(od); |
| }); |
| }); |
| |
| |
| unittest.group("obj-schema-RunQueryResponse", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildRunQueryResponse(); |
| var od = new api.RunQueryResponse.fromJson(o.toJson()); |
| checkRunQueryResponse(od); |
| }); |
| }); |
| |
| |
| unittest.group("obj-schema-Value", () { |
| unittest.test("to-json--from-json", () { |
| var o = buildValue(); |
| var od = new api.Value.fromJson(o.toJson()); |
| checkValue(od); |
| }); |
| }); |
| |
| |
| unittest.group("resource-ProjectsResourceApi", () { |
| unittest.test("method--allocateIds", () { |
| |
| var mock = new HttpServerMock(); |
| api.ProjectsResourceApi res = new api.DatastoreApi(mock).projects; |
| var arg_request = buildAllocateIdsRequest(); |
| var arg_projectId = "foo"; |
| mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
| var obj = new api.AllocateIdsRequest.fromJson(json); |
| checkAllocateIdsRequest(obj); |
| |
| var path = (req.url).path; |
| var pathOffset = 0; |
| var index; |
| var subPart; |
| unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
| pathOffset += 1; |
| unittest.expect(path.substring(pathOffset, pathOffset + 12), unittest.equals("v1/projects/")); |
| pathOffset += 12; |
| index = path.indexOf(":allocateIds", pathOffset); |
| unittest.expect(index >= 0, unittest.isTrue); |
| subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index)); |
| pathOffset = index; |
| unittest.expect(subPart, unittest.equals("$arg_projectId")); |
| unittest.expect(path.substring(pathOffset, pathOffset + 12), unittest.equals(":allocateIds")); |
| pathOffset += 12; |
| |
| var query = (req.url).query; |
| var queryOffset = 0; |
| var queryMap = {}; |
| addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| parseBool(n) { |
| if (n == "true") return true; |
| if (n == "false") return false; |
| if (n == null) return null; |
| throw new core.ArgumentError("Invalid boolean: $n"); |
| } |
| if (query.length > 0) { |
| for (var part in query.split("&")) { |
| var keyvalue = part.split("="); |
| addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.decodeQueryComponent(keyvalue[1])); |
| } |
| } |
| |
| |
| var h = { |
| "content-type" : "application/json; charset=utf-8", |
| }; |
| var resp = convert.JSON.encode(buildAllocateIdsResponse()); |
| return new async.Future.value(stringResponse(200, h, resp)); |
| }), true); |
| res.allocateIds(arg_request, arg_projectId).then(unittest.expectAsync(((api.AllocateIdsResponse response) { |
| checkAllocateIdsResponse(response); |
| }))); |
| }); |
| |
| unittest.test("method--beginTransaction", () { |
| |
| var mock = new HttpServerMock(); |
| api.ProjectsResourceApi res = new api.DatastoreApi(mock).projects; |
| var arg_request = buildBeginTransactionRequest(); |
| var arg_projectId = "foo"; |
| mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
| var obj = new api.BeginTransactionRequest.fromJson(json); |
| checkBeginTransactionRequest(obj); |
| |
| var path = (req.url).path; |
| var pathOffset = 0; |
| var index; |
| var subPart; |
| unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
| pathOffset += 1; |
| unittest.expect(path.substring(pathOffset, pathOffset + 12), unittest.equals("v1/projects/")); |
| pathOffset += 12; |
| index = path.indexOf(":beginTransaction", pathOffset); |
| unittest.expect(index >= 0, unittest.isTrue); |
| subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index)); |
| pathOffset = index; |
| unittest.expect(subPart, unittest.equals("$arg_projectId")); |
| unittest.expect(path.substring(pathOffset, pathOffset + 17), unittest.equals(":beginTransaction")); |
| pathOffset += 17; |
| |
| var query = (req.url).query; |
| var queryOffset = 0; |
| var queryMap = {}; |
| addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| parseBool(n) { |
| if (n == "true") return true; |
| if (n == "false") return false; |
| if (n == null) return null; |
| throw new core.ArgumentError("Invalid boolean: $n"); |
| } |
| if (query.length > 0) { |
| for (var part in query.split("&")) { |
| var keyvalue = part.split("="); |
| addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.decodeQueryComponent(keyvalue[1])); |
| } |
| } |
| |
| |
| var h = { |
| "content-type" : "application/json; charset=utf-8", |
| }; |
| var resp = convert.JSON.encode(buildBeginTransactionResponse()); |
| return new async.Future.value(stringResponse(200, h, resp)); |
| }), true); |
| res.beginTransaction(arg_request, arg_projectId).then(unittest.expectAsync(((api.BeginTransactionResponse response) { |
| checkBeginTransactionResponse(response); |
| }))); |
| }); |
| |
| unittest.test("method--commit", () { |
| |
| var mock = new HttpServerMock(); |
| api.ProjectsResourceApi res = new api.DatastoreApi(mock).projects; |
| var arg_request = buildCommitRequest(); |
| var arg_projectId = "foo"; |
| mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
| var obj = new api.CommitRequest.fromJson(json); |
| checkCommitRequest(obj); |
| |
| var path = (req.url).path; |
| var pathOffset = 0; |
| var index; |
| var subPart; |
| unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
| pathOffset += 1; |
| unittest.expect(path.substring(pathOffset, pathOffset + 12), unittest.equals("v1/projects/")); |
| pathOffset += 12; |
| index = path.indexOf(":commit", pathOffset); |
| unittest.expect(index >= 0, unittest.isTrue); |
| subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index)); |
| pathOffset = index; |
| unittest.expect(subPart, unittest.equals("$arg_projectId")); |
| unittest.expect(path.substring(pathOffset, pathOffset + 7), unittest.equals(":commit")); |
| pathOffset += 7; |
| |
| var query = (req.url).query; |
| var queryOffset = 0; |
| var queryMap = {}; |
| addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| parseBool(n) { |
| if (n == "true") return true; |
| if (n == "false") return false; |
| if (n == null) return null; |
| throw new core.ArgumentError("Invalid boolean: $n"); |
| } |
| if (query.length > 0) { |
| for (var part in query.split("&")) { |
| var keyvalue = part.split("="); |
| addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.decodeQueryComponent(keyvalue[1])); |
| } |
| } |
| |
| |
| var h = { |
| "content-type" : "application/json; charset=utf-8", |
| }; |
| var resp = convert.JSON.encode(buildCommitResponse()); |
| return new async.Future.value(stringResponse(200, h, resp)); |
| }), true); |
| res.commit(arg_request, arg_projectId).then(unittest.expectAsync(((api.CommitResponse response) { |
| checkCommitResponse(response); |
| }))); |
| }); |
| |
| unittest.test("method--lookup", () { |
| |
| var mock = new HttpServerMock(); |
| api.ProjectsResourceApi res = new api.DatastoreApi(mock).projects; |
| var arg_request = buildLookupRequest(); |
| var arg_projectId = "foo"; |
| mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
| var obj = new api.LookupRequest.fromJson(json); |
| checkLookupRequest(obj); |
| |
| var path = (req.url).path; |
| var pathOffset = 0; |
| var index; |
| var subPart; |
| unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
| pathOffset += 1; |
| unittest.expect(path.substring(pathOffset, pathOffset + 12), unittest.equals("v1/projects/")); |
| pathOffset += 12; |
| index = path.indexOf(":lookup", pathOffset); |
| unittest.expect(index >= 0, unittest.isTrue); |
| subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index)); |
| pathOffset = index; |
| unittest.expect(subPart, unittest.equals("$arg_projectId")); |
| unittest.expect(path.substring(pathOffset, pathOffset + 7), unittest.equals(":lookup")); |
| pathOffset += 7; |
| |
| var query = (req.url).query; |
| var queryOffset = 0; |
| var queryMap = {}; |
| addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| parseBool(n) { |
| if (n == "true") return true; |
| if (n == "false") return false; |
| if (n == null) return null; |
| throw new core.ArgumentError("Invalid boolean: $n"); |
| } |
| if (query.length > 0) { |
| for (var part in query.split("&")) { |
| var keyvalue = part.split("="); |
| addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.decodeQueryComponent(keyvalue[1])); |
| } |
| } |
| |
| |
| var h = { |
| "content-type" : "application/json; charset=utf-8", |
| }; |
| var resp = convert.JSON.encode(buildLookupResponse()); |
| return new async.Future.value(stringResponse(200, h, resp)); |
| }), true); |
| res.lookup(arg_request, arg_projectId).then(unittest.expectAsync(((api.LookupResponse response) { |
| checkLookupResponse(response); |
| }))); |
| }); |
| |
| unittest.test("method--rollback", () { |
| |
| var mock = new HttpServerMock(); |
| api.ProjectsResourceApi res = new api.DatastoreApi(mock).projects; |
| var arg_request = buildRollbackRequest(); |
| var arg_projectId = "foo"; |
| mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
| var obj = new api.RollbackRequest.fromJson(json); |
| checkRollbackRequest(obj); |
| |
| var path = (req.url).path; |
| var pathOffset = 0; |
| var index; |
| var subPart; |
| unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
| pathOffset += 1; |
| unittest.expect(path.substring(pathOffset, pathOffset + 12), unittest.equals("v1/projects/")); |
| pathOffset += 12; |
| index = path.indexOf(":rollback", pathOffset); |
| unittest.expect(index >= 0, unittest.isTrue); |
| subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index)); |
| pathOffset = index; |
| unittest.expect(subPart, unittest.equals("$arg_projectId")); |
| unittest.expect(path.substring(pathOffset, pathOffset + 9), unittest.equals(":rollback")); |
| pathOffset += 9; |
| |
| var query = (req.url).query; |
| var queryOffset = 0; |
| var queryMap = {}; |
| addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| parseBool(n) { |
| if (n == "true") return true; |
| if (n == "false") return false; |
| if (n == null) return null; |
| throw new core.ArgumentError("Invalid boolean: $n"); |
| } |
| if (query.length > 0) { |
| for (var part in query.split("&")) { |
| var keyvalue = part.split("="); |
| addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.decodeQueryComponent(keyvalue[1])); |
| } |
| } |
| |
| |
| var h = { |
| "content-type" : "application/json; charset=utf-8", |
| }; |
| var resp = convert.JSON.encode(buildRollbackResponse()); |
| return new async.Future.value(stringResponse(200, h, resp)); |
| }), true); |
| res.rollback(arg_request, arg_projectId).then(unittest.expectAsync(((api.RollbackResponse response) { |
| checkRollbackResponse(response); |
| }))); |
| }); |
| |
| unittest.test("method--runQuery", () { |
| |
| var mock = new HttpServerMock(); |
| api.ProjectsResourceApi res = new api.DatastoreApi(mock).projects; |
| var arg_request = buildRunQueryRequest(); |
| var arg_projectId = "foo"; |
| mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
| var obj = new api.RunQueryRequest.fromJson(json); |
| checkRunQueryRequest(obj); |
| |
| var path = (req.url).path; |
| var pathOffset = 0; |
| var index; |
| var subPart; |
| unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equals("/")); |
| pathOffset += 1; |
| unittest.expect(path.substring(pathOffset, pathOffset + 12), unittest.equals("v1/projects/")); |
| pathOffset += 12; |
| index = path.indexOf(":runQuery", pathOffset); |
| unittest.expect(index >= 0, unittest.isTrue); |
| subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index)); |
| pathOffset = index; |
| unittest.expect(subPart, unittest.equals("$arg_projectId")); |
| unittest.expect(path.substring(pathOffset, pathOffset + 9), unittest.equals(":runQuery")); |
| pathOffset += 9; |
| |
| var query = (req.url).query; |
| var queryOffset = 0; |
| var queryMap = {}; |
| addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| parseBool(n) { |
| if (n == "true") return true; |
| if (n == "false") return false; |
| if (n == null) return null; |
| throw new core.ArgumentError("Invalid boolean: $n"); |
| } |
| if (query.length > 0) { |
| for (var part in query.split("&")) { |
| var keyvalue = part.split("="); |
| addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.decodeQueryComponent(keyvalue[1])); |
| } |
| } |
| |
| |
| var h = { |
| "content-type" : "application/json; charset=utf-8", |
| }; |
| var resp = convert.JSON.encode(buildRunQueryResponse()); |
| return new async.Future.value(stringResponse(200, h, resp)); |
| }), true); |
| res.runQuery(arg_request, arg_projectId).then(unittest.expectAsync(((api.RunQueryResponse response) { |
| checkRunQueryResponse(response); |
| }))); |
| }); |
| |
| }); |
| |
| |
| } |
| |