Skip to content

Commit fb001b4

Browse files
authored
chore(datastore): cleaned up generic types shadowing the keyword String (#5022)
1 parent 9cbfe72 commit fb001b4

File tree

1 file changed

+60
-60
lines changed

1 file changed

+60
-60
lines changed

packages/amplify_datastore/test/native_amplify_api_test.dart

Lines changed: 60 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ void main() async {
4545
Map<String, dynamic> emptyMap = {};
4646
String payloadJson = '{"data":{},"errors":[]}';
4747

48-
mockAPIPlugin.queryMethod = <String>(GraphQLRequest mockRequest) {
48+
mockAPIPlugin.queryMethod = <T>(GraphQLRequest mockRequest) {
4949
expect(mockRequest.document, document);
5050
expect(mockRequest.variables, emptyMap);
5151
expect(mockRequest.apiName, null);
@@ -54,10 +54,10 @@ void main() async {
5454
expect(mockRequest.decodePath, null);
5555
expect(mockRequest.modelType, null);
5656

57-
return GraphQLOperation<String>(
58-
CancelableOperation<GraphQLResponse<String>>.fromValue(
59-
GraphQLResponse<String>(
60-
data: null as String?,
57+
return GraphQLOperation<T>(
58+
CancelableOperation<GraphQLResponse<T>>.fromValue(
59+
GraphQLResponse<T>(
60+
data: null as T?,
6161
errors: [],
6262
),
6363
),
@@ -91,7 +91,7 @@ void main() async {
9191
'{"data":$data,"errors":[{"message":"$errorMessage1"},{"message":"$errorMessage2"}]}';
9292
String authMode = 'apiKey';
9393

94-
mockAPIPlugin.queryMethod = <String>(GraphQLRequest mockRequest) {
94+
mockAPIPlugin.queryMethod = <T>(GraphQLRequest mockRequest) {
9595
expect(mockRequest.id.length, greaterThan(0));
9696
expect(mockRequest.document, document);
9797
expect(mockRequest.variables[variable1Key], variable1Value);
@@ -102,10 +102,10 @@ void main() async {
102102
expect(mockRequest.decodePath, null);
103103
expect(mockRequest.modelType, null);
104104

105-
return GraphQLOperation<String>(
106-
CancelableOperation<GraphQLResponse<String>>.fromValue(
107-
GraphQLResponse<String>(
108-
data: data as String?,
105+
return GraphQLOperation<T>(
106+
CancelableOperation<GraphQLResponse<T>>.fromValue(
107+
GraphQLResponse<T>(
108+
data: data as T?,
109109
errors: [
110110
GraphQLResponseError(message: errorMessage1),
111111
GraphQLResponseError(message: errorMessage2),
@@ -137,7 +137,7 @@ void main() async {
137137
String payloadJson =
138138
'{"data":{},"errors":[{"message":"Error parsing payload json: FormatException: Unexpected character (at character 1)\\nInvalid Json\\n^\\n"}]}';
139139

140-
mockAPIPlugin.queryMethod = <String>(GraphQLRequest mockRequest) {
140+
mockAPIPlugin.queryMethod = <T>(GraphQLRequest mockRequest) {
141141
expect(mockRequest.document, document);
142142
expect(mockRequest.variables, emptyMap);
143143
expect(mockRequest.apiName, null);
@@ -146,10 +146,10 @@ void main() async {
146146
expect(mockRequest.decodePath, null);
147147
expect(mockRequest.modelType, null);
148148

149-
return GraphQLOperation<String>(
150-
CancelableOperation<GraphQLResponse<String>>.fromValue(
151-
GraphQLResponse<String>(
152-
data: data as String?,
149+
return GraphQLOperation<T>(
150+
CancelableOperation<GraphQLResponse<T>>.fromValue(
151+
GraphQLResponse<T>(
152+
data: data as T?,
153153
errors: [],
154154
),
155155
),
@@ -168,13 +168,13 @@ void main() async {
168168
String? authMode,
169169
APIAuthorizationType? expected,
170170
) async {
171-
mockAPIPlugin.queryMethod = <String>(GraphQLRequest mockRequest) {
171+
mockAPIPlugin.queryMethod = <T>(GraphQLRequest mockRequest) {
172172
expect(mockRequest.authorizationMode, expected);
173173

174-
return GraphQLOperation<String>(
175-
CancelableOperation<GraphQLResponse<String>>.fromValue(
176-
GraphQLResponse<String>(
177-
data: null as String?,
174+
return GraphQLOperation<T>(
175+
CancelableOperation<GraphQLResponse<T>>.fromValue(
176+
GraphQLResponse<T>(
177+
data: null as T?,
178178
errors: [],
179179
),
180180
),
@@ -223,7 +223,7 @@ void main() async {
223223
String payloadJson =
224224
'{"errors":[{"message":"NetworkException {\\n \\"message\\": \\"API Exception\\"\\n}"}]}';
225225

226-
mockAPIPlugin.queryMethod = <String>(GraphQLRequest mockRequest) {
226+
mockAPIPlugin.queryMethod = <T>(GraphQLRequest mockRequest) {
227227
throw NetworkException(exceptionMessage);
228228
};
229229

@@ -243,7 +243,7 @@ void main() async {
243243
String payloadJson =
244244
'{"errors":[{"message":"Unauthorized - API Exception - SignedOutException"}]}';
245245

246-
mockAPIPlugin.queryMethod = <String>(GraphQLRequest mockRequest) {
246+
mockAPIPlugin.queryMethod = <T>(GraphQLRequest mockRequest) {
247247
throw NetworkException(
248248
exceptionMessage,
249249
underlyingException: 'SignedOutException',
@@ -267,7 +267,7 @@ void main() async {
267267
String payloadJson =
268268
'{"errors":[{"message":"NetworkException {\\n \\"message\\": \\"$exceptionMessage\\",\\n \\"underlyingException\\": \\"Unauthrorized\\"\\n}"}]}';
269269

270-
mockAPIPlugin.queryMethod = <String>(GraphQLRequest mockRequest) {
270+
mockAPIPlugin.queryMethod = <T>(GraphQLRequest mockRequest) {
271271
throw NetworkException(
272272
exceptionMessage,
273273
underlyingException: 'Unauthrorized',
@@ -291,7 +291,7 @@ void main() async {
291291
Map<String, dynamic> emptyMap = {};
292292
String payloadJson = '{"data":{},"errors":[]}';
293293

294-
mockAPIPlugin.mutateMethod = <String>(GraphQLRequest mockRequest) {
294+
mockAPIPlugin.mutateMethod = <T>(GraphQLRequest mockRequest) {
295295
expect(mockRequest.document, document);
296296
expect(mockRequest.variables, emptyMap);
297297
expect(mockRequest.apiName, null);
@@ -300,10 +300,10 @@ void main() async {
300300
expect(mockRequest.decodePath, null);
301301
expect(mockRequest.modelType, null);
302302

303-
return GraphQLOperation<String>(
304-
CancelableOperation<GraphQLResponse<String>>.fromValue(
305-
GraphQLResponse<String>(
306-
data: null as String?,
303+
return GraphQLOperation<T>(
304+
CancelableOperation<GraphQLResponse<T>>.fromValue(
305+
GraphQLResponse<T>(
306+
data: null as T?,
307307
errors: [],
308308
),
309309
),
@@ -337,7 +337,7 @@ void main() async {
337337
String payloadJson =
338338
'{"data":$data,"errors":[{"message":"$errorMessage1"},{"message":"$errorMessage2"}]}';
339339

340-
mockAPIPlugin.mutateMethod = <String>(GraphQLRequest mockRequest) {
340+
mockAPIPlugin.mutateMethod = <T>(GraphQLRequest mockRequest) {
341341
expect(mockRequest.id.length, greaterThan(0));
342342
expect(mockRequest.document, document);
343343
expect(mockRequest.variables[variable1Key], variable1Value);
@@ -348,10 +348,10 @@ void main() async {
348348
expect(mockRequest.decodePath, null);
349349
expect(mockRequest.modelType, null);
350350

351-
return GraphQLOperation<String>(
352-
CancelableOperation<GraphQLResponse<String>>.fromValue(
353-
GraphQLResponse<String>(
354-
data: data as String?,
351+
return GraphQLOperation<T>(
352+
CancelableOperation<GraphQLResponse<T>>.fromValue(
353+
GraphQLResponse<T>(
354+
data: data as T?,
355355
errors: [
356356
GraphQLResponseError(message: errorMessage1),
357357
GraphQLResponseError(message: errorMessage2),
@@ -384,7 +384,7 @@ void main() async {
384384
String payloadJson =
385385
'{"data":{},"errors":[{"message":"Error parsing payload json: FormatException: Unexpected character (at character 1)\\nInvalid Json\\n^\\n"}]}';
386386

387-
mockAPIPlugin.mutateMethod = <String>(GraphQLRequest mockRequest) {
387+
mockAPIPlugin.mutateMethod = <T>(GraphQLRequest mockRequest) {
388388
expect(mockRequest.document, document);
389389
expect(mockRequest.variables, emptyMap);
390390
expect(mockRequest.apiName, null);
@@ -393,10 +393,10 @@ void main() async {
393393
expect(mockRequest.decodePath, null);
394394
expect(mockRequest.modelType, null);
395395

396-
return GraphQLOperation<String>(
397-
CancelableOperation<GraphQLResponse<String>>.fromValue(
398-
GraphQLResponse<String>(
399-
data: data as String?,
396+
return GraphQLOperation<T>(
397+
CancelableOperation<GraphQLResponse<T>>.fromValue(
398+
GraphQLResponse<T>(
399+
data: data as T?,
400400
errors: [],
401401
),
402402
),
@@ -416,7 +416,7 @@ void main() async {
416416
String payloadJson =
417417
'{"errors":[{"message":"NetworkException {\\n \\"message\\": \\"API Exception\\"\\n}"}]}';
418418

419-
mockAPIPlugin.mutateMethod = <String>(GraphQLRequest mockRequest) {
419+
mockAPIPlugin.mutateMethod = <T>(GraphQLRequest mockRequest) {
420420
throw NetworkException(exceptionMessage);
421421
};
422422

@@ -436,7 +436,7 @@ void main() async {
436436
String payloadJson =
437437
'{"errors":[{"message":"Unauthorized - API Exception - SignedOutException"}]}';
438438

439-
mockAPIPlugin.mutateMethod = <String>(GraphQLRequest mockRequest) {
439+
mockAPIPlugin.mutateMethod = <T>(GraphQLRequest mockRequest) {
440440
throw NetworkException(
441441
exceptionMessage,
442442
underlyingException: 'SignedOutException',
@@ -460,7 +460,7 @@ void main() async {
460460
String payloadJson =
461461
'{"errors":[{"message":"NetworkException {\\n \\"message\\": \\"$exceptionMessage\\",\\n \\"underlyingException\\": \\"Unauthrorized\\"\\n}"}]}';
462462

463-
mockAPIPlugin.mutateMethod = <String>(GraphQLRequest mockRequest) {
463+
mockAPIPlugin.mutateMethod = <T>(GraphQLRequest mockRequest) {
464464
throw NetworkException(
465465
exceptionMessage,
466466
underlyingException: 'Unauthrorized',
@@ -484,7 +484,7 @@ void main() async {
484484
String document = '';
485485
Map<String, dynamic> emptyMap = {};
486486

487-
mockAPIPlugin.subscribeMethod = <String>(
487+
mockAPIPlugin.subscribeMethod = <T>(
488488
GraphQLRequest mockRequest,
489489
void Function()? onEstablished,
490490
) {
@@ -496,7 +496,7 @@ void main() async {
496496
expect(mockRequest.decodePath, null);
497497
expect(mockRequest.modelType, null);
498498

499-
var controller = StreamController<GraphQLResponse<String>>();
499+
var controller = StreamController<GraphQLResponse<T>>();
500500
return controller.stream;
501501
};
502502

@@ -525,7 +525,7 @@ void main() async {
525525
String decodePath = 'decodePath';
526526
String options = 'options';
527527

528-
mockAPIPlugin.subscribeMethod = <String>(
528+
mockAPIPlugin.subscribeMethod = <T>(
529529
GraphQLRequest mockRequest,
530530
void Function()? onEstablished,
531531
) {
@@ -539,7 +539,7 @@ void main() async {
539539
expect(mockRequest.decodePath, null);
540540
expect(mockRequest.modelType, null);
541541

542-
var controller = StreamController<GraphQLResponse<String>>();
542+
var controller = StreamController<GraphQLResponse<T>>();
543543
return controller.stream;
544544
};
545545

@@ -580,7 +580,7 @@ void main() async {
580580
test('Should handle API exception', () async {
581581
String exceptionMessage = 'API Exception';
582582

583-
mockAPIPlugin.subscribeMethod = <String>(
583+
mockAPIPlugin.subscribeMethod = <T>(
584584
GraphQLRequest mockRequest,
585585
void Function()? onEstablished,
586586
) {
@@ -605,12 +605,12 @@ void main() async {
605605
test('Should handle established/connected callback', () async {
606606
void Function()? onEstablishedCallback;
607607

608-
mockAPIPlugin.subscribeMethod = <String>(
608+
mockAPIPlugin.subscribeMethod = <T>(
609609
GraphQLRequest mockRequest,
610610
void Function()? onEstablished,
611611
) {
612612
onEstablishedCallback = onEstablished;
613-
var controller = StreamController<GraphQLResponse<String>>();
613+
var controller = StreamController<GraphQLResponse<T>>();
614614
return controller.stream;
615615
};
616616

@@ -649,11 +649,11 @@ void main() async {
649649
String payloadJson = '{"data":$data,"errors":[]}';
650650
StreamController? responseController;
651651

652-
mockAPIPlugin.subscribeMethod = <String>(
652+
mockAPIPlugin.subscribeMethod = <T>(
653653
GraphQLRequest mockRequest,
654654
void Function()? onEstablished,
655655
) {
656-
var controller = StreamController<GraphQLResponse<String>>();
656+
var controller = StreamController<GraphQLResponse<T>>();
657657
responseController = controller;
658658
return controller.stream;
659659
};
@@ -703,11 +703,11 @@ void main() async {
703703

704704
StreamController? responseController;
705705

706-
mockAPIPlugin.subscribeMethod = <String>(
706+
mockAPIPlugin.subscribeMethod = <T>(
707707
GraphQLRequest mockRequest,
708708
void Function()? onEstablished,
709709
) {
710-
var controller = StreamController<GraphQLResponse<String>>();
710+
var controller = StreamController<GraphQLResponse<T>>();
711711
responseController = controller;
712712
return controller.stream;
713713
};
@@ -757,11 +757,11 @@ void main() async {
757757
'{"data":{},"errors":[{"message":"Error parsing payload json: FormatException: Unexpected character (at character 1)\\nInvalid Json\\n^\\n"}]}';
758758
StreamController? responseController;
759759

760-
mockAPIPlugin.subscribeMethod = <String>(
760+
mockAPIPlugin.subscribeMethod = <T>(
761761
GraphQLRequest mockRequest,
762762
void Function()? onEstablished,
763763
) {
764-
var controller = StreamController<GraphQLResponse<String>>();
764+
var controller = StreamController<GraphQLResponse<T>>();
765765
responseController = controller;
766766
return controller.stream;
767767
};
@@ -809,11 +809,11 @@ void main() async {
809809

810810
StreamController? responseController;
811811

812-
mockAPIPlugin.subscribeMethod = <String>(
812+
mockAPIPlugin.subscribeMethod = <T>(
813813
GraphQLRequest mockRequest,
814814
void Function()? onEstablished,
815815
) {
816-
var controller = StreamController<GraphQLResponse<String>>();
816+
var controller = StreamController<GraphQLResponse<T>>();
817817
responseController = controller;
818818
return controller.stream;
819819
};
@@ -852,11 +852,11 @@ void main() async {
852852
test('Should handle send done event', () async {
853853
StreamController? responseController;
854854

855-
mockAPIPlugin.subscribeMethod = <String>(
855+
mockAPIPlugin.subscribeMethod = <T>(
856856
GraphQLRequest mockRequest,
857857
void Function()? onEstablished,
858858
) {
859-
var controller = StreamController<GraphQLResponse<String>>();
859+
var controller = StreamController<GraphQLResponse<T>>();
860860
responseController = controller;
861861
return controller.stream;
862862
};
@@ -894,11 +894,11 @@ void main() async {
894894

895895
group('Unubscribe', () {
896896
test('Should handle existing subscription', () async {
897-
mockAPIPlugin.subscribeMethod = <String>(
897+
mockAPIPlugin.subscribeMethod = <T>(
898898
GraphQLRequest mockRequest,
899899
void Function()? onEstablished,
900900
) {
901-
var controller = StreamController<GraphQLResponse<String>>();
901+
var controller = StreamController<GraphQLResponse<T>>();
902902
return controller.stream;
903903
};
904904

0 commit comments

Comments
 (0)