Skip to content

Commit

Permalink
chore(datastore): cleaned up generic types shadowing the keyword Stri…
Browse files Browse the repository at this point in the history
…ng (#5022)
  • Loading branch information
tyllark authored Jun 14, 2024
1 parent 9cbfe72 commit fb001b4
Showing 1 changed file with 60 additions and 60 deletions.
120 changes: 60 additions & 60 deletions packages/amplify_datastore/test/native_amplify_api_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void main() async {
Map<String, dynamic> emptyMap = {};
String payloadJson = '{"data":{},"errors":[]}';

mockAPIPlugin.queryMethod = <String>(GraphQLRequest mockRequest) {
mockAPIPlugin.queryMethod = <T>(GraphQLRequest mockRequest) {
expect(mockRequest.document, document);
expect(mockRequest.variables, emptyMap);
expect(mockRequest.apiName, null);
Expand All @@ -54,10 +54,10 @@ void main() async {
expect(mockRequest.decodePath, null);
expect(mockRequest.modelType, null);

return GraphQLOperation<String>(
CancelableOperation<GraphQLResponse<String>>.fromValue(
GraphQLResponse<String>(
data: null as String?,
return GraphQLOperation<T>(
CancelableOperation<GraphQLResponse<T>>.fromValue(
GraphQLResponse<T>(
data: null as T?,
errors: [],
),
),
Expand Down Expand Up @@ -91,7 +91,7 @@ void main() async {
'{"data":$data,"errors":[{"message":"$errorMessage1"},{"message":"$errorMessage2"}]}';
String authMode = 'apiKey';

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

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

mockAPIPlugin.queryMethod = <String>(GraphQLRequest mockRequest) {
mockAPIPlugin.queryMethod = <T>(GraphQLRequest mockRequest) {
expect(mockRequest.document, document);
expect(mockRequest.variables, emptyMap);
expect(mockRequest.apiName, null);
Expand All @@ -146,10 +146,10 @@ void main() async {
expect(mockRequest.decodePath, null);
expect(mockRequest.modelType, null);

return GraphQLOperation<String>(
CancelableOperation<GraphQLResponse<String>>.fromValue(
GraphQLResponse<String>(
data: data as String?,
return GraphQLOperation<T>(
CancelableOperation<GraphQLResponse<T>>.fromValue(
GraphQLResponse<T>(
data: data as T?,
errors: [],
),
),
Expand All @@ -168,13 +168,13 @@ void main() async {
String? authMode,
APIAuthorizationType? expected,
) async {
mockAPIPlugin.queryMethod = <String>(GraphQLRequest mockRequest) {
mockAPIPlugin.queryMethod = <T>(GraphQLRequest mockRequest) {
expect(mockRequest.authorizationMode, expected);

return GraphQLOperation<String>(
CancelableOperation<GraphQLResponse<String>>.fromValue(
GraphQLResponse<String>(
data: null as String?,
return GraphQLOperation<T>(
CancelableOperation<GraphQLResponse<T>>.fromValue(
GraphQLResponse<T>(
data: null as T?,
errors: [],
),
),
Expand Down Expand Up @@ -223,7 +223,7 @@ void main() async {
String payloadJson =
'{"errors":[{"message":"NetworkException {\\n \\"message\\": \\"API Exception\\"\\n}"}]}';

mockAPIPlugin.queryMethod = <String>(GraphQLRequest mockRequest) {
mockAPIPlugin.queryMethod = <T>(GraphQLRequest mockRequest) {
throw NetworkException(exceptionMessage);
};

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

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

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

mockAPIPlugin.mutateMethod = <String>(GraphQLRequest mockRequest) {
mockAPIPlugin.mutateMethod = <T>(GraphQLRequest mockRequest) {
expect(mockRequest.document, document);
expect(mockRequest.variables, emptyMap);
expect(mockRequest.apiName, null);
Expand All @@ -300,10 +300,10 @@ void main() async {
expect(mockRequest.decodePath, null);
expect(mockRequest.modelType, null);

return GraphQLOperation<String>(
CancelableOperation<GraphQLResponse<String>>.fromValue(
GraphQLResponse<String>(
data: null as String?,
return GraphQLOperation<T>(
CancelableOperation<GraphQLResponse<T>>.fromValue(
GraphQLResponse<T>(
data: null as T?,
errors: [],
),
),
Expand Down Expand Up @@ -337,7 +337,7 @@ void main() async {
String payloadJson =
'{"data":$data,"errors":[{"message":"$errorMessage1"},{"message":"$errorMessage2"}]}';

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

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

mockAPIPlugin.mutateMethod = <String>(GraphQLRequest mockRequest) {
mockAPIPlugin.mutateMethod = <T>(GraphQLRequest mockRequest) {
expect(mockRequest.document, document);
expect(mockRequest.variables, emptyMap);
expect(mockRequest.apiName, null);
Expand All @@ -393,10 +393,10 @@ void main() async {
expect(mockRequest.decodePath, null);
expect(mockRequest.modelType, null);

return GraphQLOperation<String>(
CancelableOperation<GraphQLResponse<String>>.fromValue(
GraphQLResponse<String>(
data: data as String?,
return GraphQLOperation<T>(
CancelableOperation<GraphQLResponse<T>>.fromValue(
GraphQLResponse<T>(
data: data as T?,
errors: [],
),
),
Expand All @@ -416,7 +416,7 @@ void main() async {
String payloadJson =
'{"errors":[{"message":"NetworkException {\\n \\"message\\": \\"API Exception\\"\\n}"}]}';

mockAPIPlugin.mutateMethod = <String>(GraphQLRequest mockRequest) {
mockAPIPlugin.mutateMethod = <T>(GraphQLRequest mockRequest) {
throw NetworkException(exceptionMessage);
};

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

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

mockAPIPlugin.mutateMethod = <String>(GraphQLRequest mockRequest) {
mockAPIPlugin.mutateMethod = <T>(GraphQLRequest mockRequest) {
throw NetworkException(
exceptionMessage,
underlyingException: 'Unauthrorized',
Expand All @@ -484,7 +484,7 @@ void main() async {
String document = '';
Map<String, dynamic> emptyMap = {};

mockAPIPlugin.subscribeMethod = <String>(
mockAPIPlugin.subscribeMethod = <T>(
GraphQLRequest mockRequest,
void Function()? onEstablished,
) {
Expand All @@ -496,7 +496,7 @@ void main() async {
expect(mockRequest.decodePath, null);
expect(mockRequest.modelType, null);

var controller = StreamController<GraphQLResponse<String>>();
var controller = StreamController<GraphQLResponse<T>>();
return controller.stream;
};

Expand Down Expand Up @@ -525,7 +525,7 @@ void main() async {
String decodePath = 'decodePath';
String options = 'options';

mockAPIPlugin.subscribeMethod = <String>(
mockAPIPlugin.subscribeMethod = <T>(
GraphQLRequest mockRequest,
void Function()? onEstablished,
) {
Expand All @@ -539,7 +539,7 @@ void main() async {
expect(mockRequest.decodePath, null);
expect(mockRequest.modelType, null);

var controller = StreamController<GraphQLResponse<String>>();
var controller = StreamController<GraphQLResponse<T>>();
return controller.stream;
};

Expand Down Expand Up @@ -580,7 +580,7 @@ void main() async {
test('Should handle API exception', () async {
String exceptionMessage = 'API Exception';

mockAPIPlugin.subscribeMethod = <String>(
mockAPIPlugin.subscribeMethod = <T>(
GraphQLRequest mockRequest,
void Function()? onEstablished,
) {
Expand All @@ -605,12 +605,12 @@ void main() async {
test('Should handle established/connected callback', () async {
void Function()? onEstablishedCallback;

mockAPIPlugin.subscribeMethod = <String>(
mockAPIPlugin.subscribeMethod = <T>(
GraphQLRequest mockRequest,
void Function()? onEstablished,
) {
onEstablishedCallback = onEstablished;
var controller = StreamController<GraphQLResponse<String>>();
var controller = StreamController<GraphQLResponse<T>>();
return controller.stream;
};

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

mockAPIPlugin.subscribeMethod = <String>(
mockAPIPlugin.subscribeMethod = <T>(
GraphQLRequest mockRequest,
void Function()? onEstablished,
) {
var controller = StreamController<GraphQLResponse<String>>();
var controller = StreamController<GraphQLResponse<T>>();
responseController = controller;
return controller.stream;
};
Expand Down Expand Up @@ -703,11 +703,11 @@ void main() async {

StreamController? responseController;

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

mockAPIPlugin.subscribeMethod = <String>(
mockAPIPlugin.subscribeMethod = <T>(
GraphQLRequest mockRequest,
void Function()? onEstablished,
) {
var controller = StreamController<GraphQLResponse<String>>();
var controller = StreamController<GraphQLResponse<T>>();
responseController = controller;
return controller.stream;
};
Expand Down Expand Up @@ -809,11 +809,11 @@ void main() async {

StreamController? responseController;

mockAPIPlugin.subscribeMethod = <String>(
mockAPIPlugin.subscribeMethod = <T>(
GraphQLRequest mockRequest,
void Function()? onEstablished,
) {
var controller = StreamController<GraphQLResponse<String>>();
var controller = StreamController<GraphQLResponse<T>>();
responseController = controller;
return controller.stream;
};
Expand Down Expand Up @@ -852,11 +852,11 @@ void main() async {
test('Should handle send done event', () async {
StreamController? responseController;

mockAPIPlugin.subscribeMethod = <String>(
mockAPIPlugin.subscribeMethod = <T>(
GraphQLRequest mockRequest,
void Function()? onEstablished,
) {
var controller = StreamController<GraphQLResponse<String>>();
var controller = StreamController<GraphQLResponse<T>>();
responseController = controller;
return controller.stream;
};
Expand Down Expand Up @@ -894,11 +894,11 @@ void main() async {

group('Unubscribe', () {
test('Should handle existing subscription', () async {
mockAPIPlugin.subscribeMethod = <String>(
mockAPIPlugin.subscribeMethod = <T>(
GraphQLRequest mockRequest,
void Function()? onEstablished,
) {
var controller = StreamController<GraphQLResponse<String>>();
var controller = StreamController<GraphQLResponse<T>>();
return controller.stream;
};

Expand Down

0 comments on commit fb001b4

Please sign in to comment.