cleanup and added unit tests

This commit is contained in:
verboomp
2026-01-27 14:09:12 +01:00
parent 3d456128b1
commit e4b2dd0462
42 changed files with 1467 additions and 977 deletions

View File

@@ -33,14 +33,6 @@ public class QueryService {
@PersistenceContext @PersistenceContext
private EntityManager eManager; private EntityManager eManager;
public int count(String namedQuery, Param... params) {
Query query = eManager.createNamedQuery(namedQuery);
for (Param param : params) {
query.setParameter(param.name(), param.value());
}
return ((Number) query.getSingleResult()).intValue();
}
public <T> Optional<T> callNamedQuerySingleResult(String namedQuery, Param... params) { public <T> Optional<T> callNamedQuerySingleResult(String namedQuery, Param... params) {
return singleResult(eManager.createNamedQuery(namedQuery), Arrays.asList(params)); return singleResult(eManager.createNamedQuery(namedQuery), Arrays.asList(params));
} }
@@ -66,30 +58,6 @@ public class QueryService {
return (T) query.getResultList(); return (T) query.getResultList();
} }
public <T> Optional<T> callQuerySingleResult(String sql, Param... objects) {
Query query = eManager.createQuery(sql);
for (Param param : objects) {
query.setParameter(param.name(), param.value());
}
return Optional.of((T) query.getSingleResult());
}
public <T> T callNativeQuery(String sql, Param... objects) {
Query query = eManager.createNativeQuery(sql);
for (Param param : objects) {
query.setParameter(param.name(), param.value());
}
return (T) query.getResultList();
}
public int callNativeQueryUpdate(String sql, Param... objects) {
Query query = eManager.createNativeQuery(sql);
for (Param param : objects) {
query.setParameter(param.name(), param.value());
}
return query.executeUpdate();
}
public int callNamedQueryUpdate(String namedQuery, Param... objects) { public int callNamedQueryUpdate(String namedQuery, Param... objects) {
Query query = eManager.createNamedQuery(namedQuery); Query query = eManager.createNamedQuery(namedQuery);
for (Param param : objects) { for (Param param : objects) {

View File

@@ -52,7 +52,7 @@ public class CustomerPictureService extends AbstractService {
// query = search for name, number and date // query = search for name, number and date
public List<CustomerListValue> getAll(String queryStr, String startsWith) { public List<CustomerListValue> getAll(String queryStr, String startsWith) {
// FIXME: do query // FIXME: do query on date
CriteriaBuilder builder = entityManager.getCriteriaBuilder(); CriteriaBuilder builder = entityManager.getCriteriaBuilder();
CriteriaQuery<Customer> criteriaQuery = builder.createQuery(Customer.class); CriteriaQuery<Customer> criteriaQuery = builder.createQuery(Customer.class);

View File

@@ -55,7 +55,7 @@ public class JwtTokenService extends AbstractService {
return new TokenPairValue(accessToken, refreshToken); return new TokenPairValue(accessToken, refreshToken);
} }
public String refreshAccessToken(String refreshToken) throws Exception { public String refreshAccessToken(String refreshToken) {
Claims claims = jwtTokenUtil.validateAndExtractClaims(refreshToken); Claims claims = jwtTokenUtil.validateAndExtractClaims(refreshToken);
Long userId = Long.parseLong(claims.getSubject()); Long userId = Long.parseLong(claims.getSubject());

View File

@@ -29,19 +29,11 @@ public class LoginService extends AbstractService{
// Get logged-in user from database // Get logged-in user from database
Optional<User> userOpt = queryService.callNamedQuerySingleResult(User.BY_USERNAME, new Param(User.PARAM_USERNAME, username)); Optional<User> userOpt = queryService.callNamedQuerySingleResult(User.BY_USERNAME, new Param(User.PARAM_USERNAME, username));
if (userOpt.isEmpty()) { if (userOpt.isEmpty()) {
// FIXME: implement me // Should never happen
return null;
} }
User user = userOpt.get(); User user = userOpt.get();
// Verify user is active return jwtTokenService.generateTokenPair(user, deviceInfo, ipAddress);
if (!user.isActive()) {
throw new IllegalArgumentException("User account is inactive");
}
TokenPairValue tokens = jwtTokenService.generateTokenPair(user, deviceInfo, ipAddress);
// Logout from the temporary login (we're using tokens now, not session)
return tokens;
} }
} }

View File

@@ -67,10 +67,7 @@ public class LoginResource {
String deviceInfo = loginUtils.extractDeviceInfo(httpServletRequest); String deviceInfo = loginUtils.extractDeviceInfo(httpServletRequest);
String ipAddress = loginUtils.extractIpAddress(httpServletRequest); String ipAddress = loginUtils.extractIpAddress(httpServletRequest);
TokenPairValue tokenPairValue = loginService.authenticateUser(username, deviceInfo, ipAddress); var tokenPairValue = loginService.authenticateUser(username, deviceInfo, ipAddress);
//FIXME: check if we can do a logout to free user from WildFly httpServletRequest.logout();
return Response.ok(tokenPairValue).build(); return Response.ok(tokenPairValue).build();
} }
} }

View File

@@ -48,9 +48,7 @@ public class PictureResource {
protected ResponseBuilder deleteResponse(StorageState state) { protected ResponseBuilder deleteResponse(StorageState state) {
return switch(state) { return switch(state) {
case OK -> Response.status(Status.OK); case OK -> Response.status(Status.OK);
case DUPLICATE -> Response.status(Status.CONFLICT);
case NOT_FOUND -> Response.status(Status.NOT_FOUND); case NOT_FOUND -> Response.status(Status.NOT_FOUND);
case FORBIDDEN -> Response.status(Status.FORBIDDEN);
default -> Response.status(Status.INTERNAL_SERVER_ERROR); default -> Response.status(Status.INTERNAL_SERVER_ERROR);
}; };
} }

View File

@@ -37,7 +37,8 @@ import com.networknt.schema.ValidationMessage;
*/ */
@Provider @Provider
@Consumes(value = { @Consumes(value = {
MediaType.APPLICATION_JSON, "application/json; charset=utf-8" MediaType.APPLICATION_JSON, "application/json",
MediaType.APPLICATION_JSON, "application/json; charset=utf-8",
}) })
public class ValidatedMessageBodyReader implements MessageBodyReader<SchemaValidated> { public class ValidatedMessageBodyReader implements MessageBodyReader<SchemaValidated> {
private static final Log LOG = LogFactory.getLog(ValidatedMessageBodyReader.class); private static final Log LOG = LogFactory.getLog(ValidatedMessageBodyReader.class);

View File

@@ -54,4 +54,25 @@ public class CustomerResourceTest extends AbstractRestTest {
String expected = fileToString(BASE_DOWNLOAD + "doGetAll.json"); String expected = fileToString(BASE_DOWNLOAD + "doGetAll.json");
jsonAssert(expected, text); jsonAssert(expected, text);
} }
@Test
@Order(1)
public void doGetCustomer() throws IOException {
LOG.info("doGetCustomer");
String authorization = getAuthorization();
LOG.info("authorization: " + authorization);
String path = deploymentURL + PATH +"/1";
Request request = Request.Get(path).addHeader("Accept", "application/json; charset=utf-8")
.addHeader("Authorization", authorization);
HttpResponse httpResponse = executeRequest(request);
int code = httpResponse.getStatusLine().getStatusCode();
assertEquals(200, code);
String text = getResponseText(httpResponse, "doGetCustomer");
String expected = fileToString(BASE_DOWNLOAD + "doGetCustomer.json");
jsonAssert(expected, text);
}
} }

View File

@@ -27,13 +27,11 @@ public class LoginResourceTest extends AbstractRestTest {
@Order(2) @Order(2)
public void doTestLogin() { public void doTestLogin() {
LOG.info("doTestLogin"); LOG.info("doTestLogin");
String token = getBasicHeader(); String token = getBasicHeader();
assertNotNull(token); assertNotNull(token);
} }
public static void main(String[] args) { public static void main(String[] args) {
var test = new LoginResourceTest(); var test = new LoginResourceTest();
test.deploymentURL = "http://localhost:8080/"; test.deploymentURL = "http://localhost:8080/";
String token = test.getAuthorization("hartmann", "nvlev4YnTi"); String token = test.getAuthorization("hartmann", "nvlev4YnTi");

File diff suppressed because one or more lines are too long

View File

@@ -1,14 +1,13 @@
import 'dart:convert' show jsonDecode, jsonEncode; import 'dart:convert' show jsonDecode;
import 'package:fotodocumentation/dto/base_dto.dart';
import 'package:fotodocumentation/utils/di_container.dart';
import 'package:fotodocumentation/utils/http_client_utils.dart';
import 'package:fotodocumentation/utils/jwt_token_storage.dart';
import 'package:fotodocumentation/utils/url_utils.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'package:http/http.dart' show Response; import 'package:http/http.dart' show Response;
import 'package:fotodocumentation/main.dart' show logger; import 'package:fotodocumentation/main.dart' show logger;
import 'package:fotodocumentation/utils/di_container.dart';
import 'package:fotodocumentation/utils/http_client_utils.dart';
import 'package:fotodocumentation/utils/jwt_token_storage.dart';
import 'package:fotodocumentation/utils/url_utils.dart';
abstract class BaseController { abstract class BaseController {
UrlUtils get uriUtils => DiContainer.get(); UrlUtils get uriUtils => DiContainer.get();
@@ -75,68 +74,6 @@ abstract class BaseController {
var response = await client.delete(uri, headers: {cred.name: cred.value}); var response = await client.delete(uri, headers: {cred.name: cred.value});
return response.statusCode == 200; return response.statusCode == 200;
} }
Future<bool> runPutWithAuth(String uriStr) async {
http.Client client = httpClientUtils.client;
Header cred = await getAuthHeader();
Uri uri = Uri.parse(uriStr);
var response = await client.put(uri, headers: {cred.name: cred.value});
return response.statusCode == 200;
}
Future<ServerReply<T>> runSaveNew<T extends DtoMapAble>(String uriStr, T dtoObj, Function(http.Response response, T dto) processReply) async {
http.Client client = httpClientUtils.client;
try {
Header cred = await getAuthHeader();
String body = jsonEncode(dtoObj.toMap());
Uri uri = Uri.parse(uriStr);
var response = await client.post(uri, headers: {cred.name: cred.value, "Accept": "application/json", "Content-Type": "application/json"}, body: body);
return processReply(response, dtoObj);
} catch (e) {
logger.e("exception $e");
}
return ServerReply(ServerState.error, dtoObj);
}
Future<ServerReply<T>> runSaveUpdate<T extends DtoMapAble>(String uriStr, T dtoObj, Function(http.Response response, T dto) processReply) async {
http.Client client = httpClientUtils.client;
try {
Header cred = await getAuthHeader();
String body = jsonEncode(dtoObj.toMap());
Uri uri = Uri.parse(uriStr);
var response = await client.put(uri, headers: {cred.name: cred.value, "Accept": "application/json", "Content-Type": "application/json"}, body: body);
return processReply(response, dtoObj);
} catch (e) {
logger.e("exception $e");
}
return ServerReply(ServerState.error, dtoObj);
}
ServerReply<T> processServerResponse<T>(Response response, T dto, T Function(Map<String, dynamic> json) fromJson) {
if (response.statusCode == 200) {
String text = response.body;
var json = jsonDecode(text);
var dto = fromJson(json);
return ServerReply(ServerState.ok, dto);
} else if (response.statusCode == 400 || response.statusCode == 409) {
String text = response.body;
try {
var json = jsonDecode(text);
var error = ErrorDto.fromJson(json);
return ServerReply(ServerState.duplicate, dto, error: error);
} catch (e) {
return ServerReply(ServerState.error, dto, error: ErrorDto(response.statusCode, text));
}
} else if (response.statusCode == 403) {
var error = ErrorDto(403, "Not allowed.");
return ServerReply(ServerState.error, dto, error: error);
}
return ServerReply(ServerState.error, dto, error: ErrorDto(response.statusCode, "Internal server error"));
}
} }
class Header { class Header {
@@ -149,26 +86,8 @@ class Header {
String toString() => '$runtimeType: $name, $value'; String toString() => '$runtimeType: $name, $value';
} }
class ServerReply<T> {
ServerState state;
T entity;
ErrorDto? error;
ServerReply(this.state, this.entity, {this.error});
@override
String toString() => '$runtimeType: $state, $entity, $error';
}
class ServerError { class ServerError {
int statusCode; int statusCode;
ServerError(this.statusCode); ServerError(this.statusCode);
} }
enum ServerState {
ok,
duplicate,
error,
;
}

View File

@@ -1,5 +1,5 @@
import 'package:fotodocumentation/controller/base_controller.dart'; import 'package:fotodocumentation/controller/base_controller.dart';
import 'package:fotodocumentation/dto/customer_dto.dart'; import 'package:fotodocumentation/dto/picture_dto.dart';
abstract interface class PictureController { abstract interface class PictureController {
Future<bool> delete(PictureDto dto); Future<bool> delete(PictureDto dto);

View File

@@ -8,8 +8,3 @@ final class ErrorDto {
: error = json['error'] as int, : error = json['error'] as int,
message = json['message']; message = json['message'];
} }
abstract interface class DtoMapAble {
Map<String, dynamic> toMap();
}

View File

@@ -1,3 +1,4 @@
import 'package:fotodocumentation/dto/picture_dto.dart';
import 'package:fotodocumentation/utils/date_time_utils.dart'; import 'package:fotodocumentation/utils/date_time_utils.dart';
class CustomerListDto { class CustomerListDto {
@@ -38,28 +39,4 @@ class CustomerDto {
} }
} }
class PictureDto {
final int id;
final String? comment;
final String? category;
final String image;
final DateTime pictureDate;
final String? username;
final CustomerListDto customerListDto;
PictureDto(
{required this.id, required this.comment, required this.category, required this.image, required this.pictureDate, required this.username, required this.customerListDto});
/// Create from JSON response
factory PictureDto.fromJson(Map<String, dynamic> json) {
return PictureDto(
id: json['id'] as int,
comment: json['comment'] as String?,
category: json['category'] as String?,
image: json['image'] as String,
pictureDate: DateTimeUtils.toDateTime(json['pictureDate']) ?? DateTime.now(),
username: json['username'] as String?,
customerListDto: CustomerListDto.fromJson(json['customer']),
);
}
}

View File

@@ -1,21 +1,3 @@
/// DTO representing a failes login attempt request for 2fa token.
class TokenRequiredDto {
final bool? tokenRequired;
final bool? tokenInValid;
TokenRequiredDto({
required this.tokenRequired,
required this.tokenInValid,
});
/// Create from JSON response
factory TokenRequiredDto.fromJson(Map<String, dynamic> json) {
return TokenRequiredDto(
tokenRequired: json['tokenRequired'] as bool,
tokenInValid: json['tokenInValid'] as bool,
);
}
}
/// DTO representing a pair of JWT tokens from the backend. /// DTO representing a pair of JWT tokens from the backend.
class JwtTokenPairDto { class JwtTokenPairDto {
@@ -35,14 +17,6 @@ class JwtTokenPairDto {
); );
} }
/// Convert to JSON (for serialization if needed)
Map<String, dynamic> toJson() {
return {
'accessToken': accessToken,
'refreshToken': refreshToken,
};
}
@override @override
String toString() { String toString() {
return 'JwtTokenPairDto{accessToken: [REDACTED], refreshToken: [REDACTED]}'; return 'JwtTokenPairDto{accessToken: [REDACTED], refreshToken: [REDACTED]}';

View File

@@ -0,0 +1,25 @@
import 'package:fotodocumentation/utils/date_time_utils.dart';
class PictureDto {
final int id;
final String? comment;
final String? category;
final String image;
final DateTime pictureDate;
final String? username;
PictureDto(
{required this.id, required this.comment, required this.category, required this.image, required this.pictureDate, required this.username});
/// Create from JSON response
factory PictureDto.fromJson(Map<String, dynamic> json) {
return PictureDto(
id: json['id'] as int,
comment: json['comment'] as String?,
category: json['category'] as String?,
image: json['image'] as String,
pictureDate: DateTimeUtils.toDateTime(json['pictureDate']) ?? DateTime.now(),
username: json['username'] as String?
);
}
}

View File

@@ -22,7 +22,7 @@ void main() async {
await initializeDateFormatting('de_DE', null); await initializeDateFormatting('de_DE', null);
LoginController loginController = DiContainer.get(); LoginController loginController = DiContainer.get();
//await loginController.isLoggedIn(); await loginController.isUsingJwtAuth();
runApp(FotoDocumentationApp(theme: theme)); runApp(FotoDocumentationApp(theme: theme));
} }

View File

@@ -1,40 +0,0 @@
import 'package:flutter/material.dart';
import 'package:fotodocumentation/dto/customer_dto.dart';
import 'package:fotodocumentation/pages/ui_utils/dialog/delete_dialog.dart';
class CustomerRowItem extends StatelessWidget {
final CustomerListDto dto;
final Future<DeleteDialogResult> Function(CustomerListDto) doDelete;
final Future<void> Function(CustomerListDto)? doSelect;
const CustomerRowItem({super.key, required this.dto, required this.doDelete, this.doSelect});
@override
Widget build(BuildContext context) {
return ListTile(
leading: CircleAvatar(
backgroundColor: Colors.grey[300],
child: Text(
dto.name.isNotEmpty ? dto.name[0].toUpperCase() : '?',
style: TextStyle(
color: Colors.grey[700],
fontWeight: FontWeight.bold,
),
),
),
title: Text(dto.name),
subtitle: Text('CustomerNumber: ${dto.customerNumber}'),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
onTap: () async => await _doSelect(context),
);
}
Future<void> _doSelect(BuildContext context) async {
if (doSelect != null) {
await doSelect!(dto);
}
}
}

View File

@@ -2,6 +2,7 @@ import 'dart:convert' show base64Decode;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:fotodocumentation/controller/picture_controller.dart'; import 'package:fotodocumentation/controller/picture_controller.dart';
import 'package:fotodocumentation/dto/picture_dto.dart';
import 'package:fotodocumentation/pages/customer/picture_delete_dialog.dart'; import 'package:fotodocumentation/pages/customer/picture_delete_dialog.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
@@ -194,6 +195,7 @@ class _CustomerWidgetState extends State<CustomerWidget> {
final dateStr = _dateFormat.format(pictureDto.pictureDate); final dateStr = _dateFormat.format(pictureDto.pictureDate);
return InkWell( return InkWell(
key: Key("table_row_${customerDto.id}"),
onTap: () => _actionSelect(context, customerDto, pictureDto), onTap: () => _actionSelect(context, customerDto, pictureDto),
child: Padding( child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0), padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
@@ -231,6 +233,7 @@ class _CustomerWidgetState extends State<CustomerWidget> {
SizedBox( SizedBox(
width: 48, width: 48,
child: IconButton( child: IconButton(
key: Key("table_row_delete_${customerDto.id}"),
icon: Icon( icon: Icon(
Icons.delete_outline, Icons.delete_outline,
color: _generalStyle.errorColor, color: _generalStyle.errorColor,

View File

@@ -28,6 +28,7 @@ class PictureDeleteDialog extends StatelessWidget {
), ),
actions: [ actions: [
TextButton( TextButton(
key: Key("picture_delete_no"),
onPressed: () => Navigator.of(context).pop(false), onPressed: () => Navigator.of(context).pop(false),
child: Text( child: Text(
AppLocalizations.of(context)!.deleteDialogButtonCancel, AppLocalizations.of(context)!.deleteDialogButtonCancel,
@@ -38,6 +39,7 @@ class PictureDeleteDialog extends StatelessWidget {
), ),
), ),
TextButton( TextButton(
key: Key("picture_delete_yes"),
onPressed: () => Navigator.of(context).pop(true), onPressed: () => Navigator.of(context).pop(true),
child: Text( child: Text(
AppLocalizations.of(context)!.deleteDialogButtonApprove, AppLocalizations.of(context)!.deleteDialogButtonApprove,

View File

@@ -1,7 +1,7 @@
import 'dart:convert' show base64Decode; import 'dart:convert' show base64Decode;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:fotodocumentation/dto/customer_dto.dart'; import 'package:fotodocumentation/dto/picture_dto.dart';
import 'package:fotodocumentation/pages/ui_utils/general_style.dart'; import 'package:fotodocumentation/pages/ui_utils/general_style.dart';
import 'package:fotodocumentation/utils/di_container.dart'; import 'package:fotodocumentation/utils/di_container.dart';

View File

@@ -2,6 +2,7 @@ import 'dart:convert' show base64Decode;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:fotodocumentation/dto/customer_dto.dart'; import 'package:fotodocumentation/dto/customer_dto.dart';
import 'package:fotodocumentation/dto/picture_dto.dart';
import 'package:fotodocumentation/pages/customer/picture_fullscreen_dialog.dart'; import 'package:fotodocumentation/pages/customer/picture_fullscreen_dialog.dart';
import 'package:fotodocumentation/pages/ui_utils/general_style.dart'; import 'package:fotodocumentation/pages/ui_utils/general_style.dart';
import 'package:fotodocumentation/utils/di_container.dart'; import 'package:fotodocumentation/utils/di_container.dart';
@@ -179,12 +180,17 @@ class _PictureWidgetState extends State<PictureWidget> {
Widget _imageWidget(PictureDto dto) { Widget _imageWidget(PictureDto dto) {
return GestureDetector( return GestureDetector(
key: const Key("image"),
behavior: HitTestBehavior.opaque,
onTap: () => _showFullscreenImage(dto), onTap: () => _showFullscreenImage(dto),
child: MouseRegion( child: MouseRegion(
cursor: SystemMouseCursors.click, cursor: SystemMouseCursors.click,
child: Image.memory( child: ConstrainedBox(
base64Decode(dto.image), constraints: const BoxConstraints(minWidth: 100, minHeight: 100),
fit: BoxFit.contain, child: Image.memory(
base64Decode(dto.image),
fit: BoxFit.contain,
),
), ),
), ),
); );
@@ -234,7 +240,7 @@ class _PictureWidgetState extends State<PictureWidget> {
Padding( Padding(
padding: const EdgeInsets.only(top: 4.0), padding: const EdgeInsets.only(top: 4.0),
child: Text( child: Text(
dto.customerListDto.name, widget.customerDto.name,
style: contentStyle, style: contentStyle,
), ),
), ),
@@ -248,7 +254,7 @@ class _PictureWidgetState extends State<PictureWidget> {
Padding( Padding(
padding: const EdgeInsets.only(top: 4.0), padding: const EdgeInsets.only(top: 4.0),
child: Text( child: Text(
dto.customerListDto.customerNumber, widget.customerDto.customerNumber,
style: contentStyle, style: contentStyle,
), ),
), ),

View File

@@ -1,23 +0,0 @@
import 'package:flutter/material.dart';
class LandingPageWidget extends StatefulWidget {
final Widget child;
const LandingPageWidget({super.key, required this.child});
@override
State<LandingPageWidget> createState() => _LandingPageWidgetState();
}
class _LandingPageWidgetState extends State<LandingPageWidget> {
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: widget.child,
);
}
}

View File

@@ -1,32 +0,0 @@
import 'package:flutter/material.dart';
import 'package:fotodocumentation/l10n/app_localizations.dart';
import 'package:fotodocumentation/pages/ui_utils/general_style.dart';
import 'package:fotodocumentation/utils/di_container.dart';
typedef SubmitCallback = void Function();
class GeneralSubmitWidget extends StatelessWidget {
GeneralStyle get _generalStyle => DiContainer.get();
final SubmitCallback onSelect;
final String? title;
const GeneralSubmitWidget({super.key, required this.onSelect, this.title});
@override
Widget build(BuildContext context) {
String text = title ?? AppLocalizations.of(context)!.submitWidget;
return Row(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
ElevatedButton(
key: Key("SubmitWidgetButton"),
style: _generalStyle.elevatedButtonStyle,
onPressed: onSelect,
child: Text(text),
),
],
);
}
}

View File

@@ -1,173 +0,0 @@
import 'package:flutter/material.dart';
import 'package:fotodocumentation/main.dart' show logger;
import 'package:fotodocumentation/l10n/app_localizations.dart';
import 'package:fotodocumentation/pages/ui_utils/dialog/snackbar_utils.dart';
import 'package:fotodocumentation/utils/di_container.dart';
class DeleteDialog extends StatelessWidget {
static SnackbarUtils get _snackbarUtils => DiContainer.get();
const DeleteDialog({super.key});
static Future<void> show(BuildContext context, Future<DeleteDialogResult> Function() doDelete) async {
await _openDialog(context).then((value) async {
if (value != null && value && context.mounted) {
logger.d("Delete popup result $value");
var result = await doDelete();
if (context.mounted && result.msg.isNotEmpty) {
_snackbarUtils.showSnackbar(context, result.msg, result.warning);
}
}
});
}
static Future<bool?> _openDialog(BuildContext context) async {
return showDialog<bool>(
context: context,
barrierDismissible: false, // user must tap button!
builder: (BuildContext context) {
return const DeleteDialog(
key: Key("delete_dialog"),
);
},
);
}
@override
Widget build(BuildContext context) {
final loc = AppLocalizations.of(context)!;
return AlertDialog(
backgroundColor: Colors.white,
scrollable: false,
titlePadding: const EdgeInsets.all(16.0),
contentPadding: const EdgeInsets.fromLTRB(16.0, 0, 16.0, 16.0),
title: _titleWidget(context, loc),
content: _content(context, loc),
);
}
Widget _titleWidget(BuildContext context, AppLocalizations loc) {
return Card(
elevation: 4,
margin: EdgeInsets.zero,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
side: BorderSide(
color: Colors.grey[300]!,
width: 1,
),
),
child: Padding(
padding: const EdgeInsets.all(12.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
Icon(
Icons.warning_amber_rounded,
size: 32,
color: Colors.orange[700],
),
const SizedBox(width: 16),
Text(
loc.deleteDialogTitle,
style: Theme.of(context).textTheme.headlineSmall?.copyWith(
fontWeight: FontWeight.bold,
),
),
],
),
IconButton(
key: const Key("close_button"),
icon: const Icon(Icons.close),
onPressed: () => Navigator.pop(context, false),
),
],
),
),
);
}
Widget _content(BuildContext context, AppLocalizations loc) {
return SizedBox(
width: 400,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Card(
elevation: 2,
margin: EdgeInsets.zero,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
side: BorderSide(
color: Colors.grey[300]!,
width: 1,
),
),
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Row(
children: [
Icon(
Icons.warning_amber_rounded,
size: 48,
color: Colors.orange[700],
),
const SizedBox(width: 16),
Expanded(
child: Text(
loc.deleteDialogText,
style: Theme.of(context).textTheme.bodyLarge,
),
),
],
),
),
),
const SizedBox(height: 16),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
TextButton(
key: const Key("delete_dialog:cancel"),
style: TextButton.styleFrom(
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
),
onPressed: () => Navigator.pop(context, false),
child: Text(loc.deleteDialogButtonCancel),
),
const SizedBox(width: 8),
ElevatedButton.icon(
key: const Key("delete_dialog:approve"),
style: ElevatedButton.styleFrom(
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12),
backgroundColor: Colors.red[600],
foregroundColor: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
),
onPressed: () => Navigator.pop(context, true),
icon: const Icon(Icons.delete, size: 20),
label: Text(loc.deleteDialogButtonApprove),
),
],
),
],
),
);
}
}
class DeleteDialogResult {
final String msg;
final bool warning;
DeleteDialogResult({required this.msg, required this.warning});
}

View File

@@ -1,85 +0,0 @@
import 'package:flutter/material.dart';
abstract interface class SnackbarUtils {
void showSnackbar(BuildContext context, String msg, bool warning);
void showSnackbarPopup(BuildContext context, String msg, bool warning);
}
class SnackbarUtilsImpl implements SnackbarUtils {
@override
void showSnackbar(BuildContext context, String msg, bool warning) {
var snackBar = SnackBar(
content: _contentFor(context, msg, warning),
backgroundColor: Colors.white,
behavior: SnackBarBehavior.floating,
showCloseIcon: true,
closeIconColor: Theme.of(context).colorScheme.inversePrimary,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(6),
side: BorderSide(width: 2.0, style: BorderStyle.solid, color: Theme.of(context).colorScheme.inversePrimary),
),
margin: EdgeInsets.only(bottom: MediaQuery.of(context).size.height - 130, left: MediaQuery.of(context).size.width - 400, right: 10),
);
ScaffoldMessenger.of(context).showSnackBar(snackBar);
}
@override
void showSnackbarPopup(BuildContext context, String msg, bool warning) {
var snackBar = SnackBar(
content: _contentFor(context, msg, warning),
backgroundColor: Colors.white,
behavior: SnackBarBehavior.floating,
showCloseIcon: true,
closeIconColor: Theme.of(context).colorScheme.inversePrimary,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(6),
side: BorderSide(width: 2.0, style: BorderStyle.solid, color: Theme.of(context).colorScheme.inversePrimary),
),
width: 350,
//margin: EdgeInsets.only(bottom: MediaQuery.of(context).size.height - 100, left: MediaQuery.of(context).size.width - 350, right: 10),
);
ScaffoldMessenger.of(context).showSnackBar(snackBar);
}
Widget _contentFor(BuildContext context, String msg, bool warning) {
var icon = _iconFor(context, warning);
var style = _textStyleFor(context, warning);
return Wrap(
alignment: WrapAlignment.start,
crossAxisAlignment: WrapCrossAlignment.center,
children: [
icon,
Text(
msg,
style: style,
),
],
);
}
Icon _iconFor(BuildContext context, bool warning) {
var color = _contentColor(context, warning);
return warning ? Icon(Icons.error, color: color) : Icon(Icons.check_circle_outline, color: color);
}
TextStyle _textStyleFor(BuildContext context, bool warning) {
var color = _contentColor(context, warning);
var bodyLarge = Theme.of(context).primaryTextTheme.bodyLarge!;
var style = TextStyle(
color: color,
decoration: bodyLarge.decoration,
fontFamily: bodyLarge.fontFamily,
fontSize: bodyLarge.fontSize,
fontWeight: bodyLarge.fontWeight,
letterSpacing: bodyLarge.letterSpacing,
textBaseline: bodyLarge.textBaseline);
return style;
}
Color _contentColor(BuildContext context, bool warning) {
return warning ? Theme.of(context).colorScheme.error : Theme.of(context).colorScheme.inversePrimary;
}
}

View File

@@ -1,9 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
abstract interface class GeneralStyle { abstract interface class GeneralStyle {
ButtonStyle get elevatedButtonStyle;
ButtonStyle get roundedButtonStyle;
Color get primaryTextLabelColor; Color get primaryTextLabelColor;
Color get secondaryTextLabelColor; Color get secondaryTextLabelColor;
@@ -14,23 +12,12 @@ abstract interface class GeneralStyle {
Color get pageBackgroundColor; Color get pageBackgroundColor;
Color get primaryCardColor;
Color get errorColor; Color get errorColor;
String get fontFamily; String get fontFamily;
} }
class GeneralStyleImpl implements GeneralStyle { class GeneralStyleImpl implements GeneralStyle {
static final ButtonStyle _elevatedButtonStyle = ElevatedButton.styleFrom(textStyle: const TextStyle(fontSize: 20));
static final ButtonStyle _roundedButtonStyle = ElevatedButton.styleFrom(shape: const CircleBorder(), padding: const EdgeInsets.all(8));
@override
ButtonStyle get elevatedButtonStyle => _elevatedButtonStyle;
@override
ButtonStyle get roundedButtonStyle => _roundedButtonStyle;
@override @override
Color get primaryTextLabelColor => const Color(0xFF0045FF); Color get primaryTextLabelColor => const Color(0xFF0045FF);
@@ -45,10 +32,7 @@ class GeneralStyleImpl implements GeneralStyle {
@override @override
Color get primaryButtonTextColor => Colors.white; Color get primaryButtonTextColor => Colors.white;
@override
Color get primaryCardColor => Colors.white;
@override @override
Color get pageBackgroundColor => const Color(0xFFF5F5F5); Color get pageBackgroundColor => const Color(0xFFF5F5F5);

View File

@@ -1,89 +0,0 @@
import 'package:flutter/material.dart';
class HeaderButtonWrapper extends StatefulWidget {
final IconData icon;
final String tooltip;
final VoidCallback onPressed;
final Color? iconColor;
final int? badgeCount;
const HeaderButtonWrapper({
super.key,
required this.icon,
required this.tooltip,
required this.onPressed,
this.iconColor,
this.badgeCount,
});
@override
State<HeaderButtonWrapper> createState() => _HeaderButtonWrapperState();
}
class _HeaderButtonWrapperState extends State<HeaderButtonWrapper> {
bool _isHovered = false;
@override
Widget build(BuildContext context) {
return MouseRegion(
onEnter: (_) => setState(() => _isHovered = true),
onExit: (_) => setState(() => _isHovered = false),
child: Tooltip(
message: widget.tooltip,
child: Stack(
clipBehavior: Clip.none,
children: [
Container(
decoration: BoxDecoration(
color: _isHovered ? Colors.blue[50] : Colors.transparent,
borderRadius: BorderRadius.circular(12),
border: Border.all(
color: _isHovered ? Colors.blue[200]! : Colors.transparent,
width: 1,
),
),
child: IconButton(
icon: Icon(
widget.icon,
size: 24,
color: widget.iconColor ?? Colors.grey[700],
),
onPressed: widget.onPressed,
splashRadius: 24,
),
),
if (widget.badgeCount != null && widget.badgeCount! > 0)
Positioned(
right: 4,
top: 4,
child: Container(
padding: const EdgeInsets.all(4),
decoration: BoxDecoration(
color: Colors.red[600],
shape: BoxShape.circle,
border: Border.all(
color: Colors.white,
width: 2,
),
),
constraints: const BoxConstraints(
minWidth: 20,
minHeight: 20,
),
child: Text(
widget.badgeCount! > 99 ? '99+' : widget.badgeCount.toString(),
style: const TextStyle(
color: Colors.white,
fontSize: 10,
fontWeight: FontWeight.bold,
),
textAlign: TextAlign.center,
),
),
),
],
),
),
);
}
}

View File

@@ -1,75 +0,0 @@
import 'package:flutter/material.dart';
import 'package:fotodocumentation/utils/di_container.dart';
import 'package:fotodocumentation/utils/login_credentials.dart';
abstract interface class HeaderUtils {
Widget titleWidget(String text);
}
class HeaderUtilsImpl extends HeaderUtils {
LoginCredentials get _loginCredentials => DiContainer.get();
@override
Widget titleWidget(String text) {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Icon(
Icons.school,
size: 28,
color: Colors.blue[700],
),
const SizedBox(width: 12),
Text(
text,
style: const TextStyle(
fontSize: 22,
fontWeight: FontWeight.bold,
color: Colors.black87,
),
),
],
),
const SizedBox(height: 4),
if (_loginCredentials.fullname.isNotEmpty) ...[
Padding(
padding: const EdgeInsets.only(left: 40.0),
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 4),
decoration: BoxDecoration(
color: Colors.blue[50],
borderRadius: BorderRadius.circular(12),
border: Border.all(
color: Colors.blue[200]!,
width: 1,
),
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
Icons.person_outline,
size: 14,
color: Colors.blue[700],
),
const SizedBox(width: 6),
Text(
_loginCredentials.fullname,
style: TextStyle(
fontSize: 12,
color: Colors.blue[900],
fontWeight: FontWeight.w500,
),
),
],
),
),
),
],
],
);
}
}

View File

@@ -1,99 +0,0 @@
import 'package:flutter/material.dart';
import 'package:fotodocumentation/pages/ui_utils/header_button_wrapper.dart';
class ModernAppBar extends StatelessWidget implements PreferredSizeWidget {
final Widget title;
final List<Widget> actions;
final Widget? leading;
final bool automaticallyImplyLeading;
const ModernAppBar({
super.key,
required this.title,
this.actions = const [],
this.leading,
this.automaticallyImplyLeading = true,
});
@override
Widget build(BuildContext context) {
Widget? effectiveLeading = _effectiveLeading(context);
return Container(
decoration: BoxDecoration(
color: Colors.grey[50],
border: Border(
bottom: BorderSide(
color: Colors.grey[300]!,
width: 1,
),
),
),
child: SafeArea(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
child: Row(
children: [
if (effectiveLeading != null) ...[
effectiveLeading,
const SizedBox(width: 16),
],
Expanded(child: title),
const SizedBox(width: 16),
...actions.map((action) => Padding(
padding: const EdgeInsets.only(left: 8.0),
child: action,
)),
],
),
),
),
);
}
Widget? _effectiveLeading(BuildContext context) {
// Determine if we should show a back button
final ScaffoldState? scaffold = Scaffold.maybeOf(context);
final ModalRoute<dynamic>? parentRoute = ModalRoute.of(context);
final bool hasDrawer = scaffold?.hasDrawer ?? false;
final bool canPop = parentRoute?.canPop ?? false;
final bool useCloseButton = parentRoute is PageRoute<dynamic> && parentRoute.fullscreenDialog;
Widget? effectiveLeading = leading;
if (effectiveLeading == null && automaticallyImplyLeading) {
if (hasDrawer) {
effectiveLeading = HeaderButtonWrapper(
icon: Icons.menu,
onPressed: () {
Scaffold.of(context).openDrawer();
},
tooltip: MaterialLocalizations.of(context).openAppDrawerTooltip,
iconColor: Colors.grey[700],
);
} else if (canPop) {
if (useCloseButton) {
effectiveLeading = HeaderButtonWrapper(
icon: Icons.close,
onPressed: () {
Navigator.of(context).pop();
},
tooltip: MaterialLocalizations.of(context).closeButtonTooltip,
iconColor: Colors.grey[700],
);
} else {
effectiveLeading = HeaderButtonWrapper(
icon: Icons.arrow_back,
onPressed: () {
Navigator.of(context).pop();
},
tooltip: MaterialLocalizations.of(context).backButtonTooltip,
iconColor: Colors.grey[700],
);
}
}
}
return effectiveLeading;
}
@override
Size get preferredSize => const Size.fromHeight(80);
}

View File

@@ -1,9 +1,7 @@
import 'package:fotodocumentation/controller/customer_controller.dart'; import 'package:fotodocumentation/controller/customer_controller.dart';
import 'package:fotodocumentation/controller/login_controller.dart'; import 'package:fotodocumentation/controller/login_controller.dart';
import 'package:fotodocumentation/controller/picture_controller.dart'; import 'package:fotodocumentation/controller/picture_controller.dart';
import 'package:fotodocumentation/pages/ui_utils/dialog/snackbar_utils.dart';
import 'package:fotodocumentation/pages/ui_utils/general_style.dart'; import 'package:fotodocumentation/pages/ui_utils/general_style.dart';
import 'package:fotodocumentation/pages/ui_utils/header_utils.dart';
import 'package:fotodocumentation/utils/http_client_utils.dart'; import 'package:fotodocumentation/utils/http_client_utils.dart';
import 'package:fotodocumentation/utils/jwt_token_storage.dart'; import 'package:fotodocumentation/utils/jwt_token_storage.dart';
import 'package:fotodocumentation/utils/login_credentials.dart'; import 'package:fotodocumentation/utils/login_credentials.dart';
@@ -24,9 +22,7 @@ class DiContainer {
DiContainer.instance.put(GeneralStyle, GeneralStyleImpl()); DiContainer.instance.put(GeneralStyle, GeneralStyleImpl());
DiContainer.instance.put(JwtTokenStorage, JwtTokenStorageImpl()); DiContainer.instance.put(JwtTokenStorage, JwtTokenStorageImpl());
DiContainer.instance.put(HttpClientUtils, HttpCLientUtilsImpl()); DiContainer.instance.put(HttpClientUtils, HttpCLientUtilsImpl());
DiContainer.instance.put(HeaderUtils, HeaderUtilsImpl());
DiContainer.instance.put(UrlUtils, UrlUtilsImpl()); DiContainer.instance.put(UrlUtils, UrlUtilsImpl());
DiContainer.instance.put(SnackbarUtils, SnackbarUtilsImpl());
DiContainer.instance.put(LoginController, LoginControllerImpl()); DiContainer.instance.put(LoginController, LoginControllerImpl());
DiContainer.instance.put(CustomerController, CustomerControllerImpl()); DiContainer.instance.put(CustomerController, CustomerControllerImpl());
DiContainer.instance.put(PictureController, PictureControllerImpl()); DiContainer.instance.put(PictureController, PictureControllerImpl());

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,80 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:fotodocumentation/controller/login_controller.dart';
import 'package:fotodocumentation/utils/di_container.dart';
import 'package:fotodocumentation/utils/http_client_utils.dart';
import 'package:fotodocumentation/utils/jwt_token_storage.dart';
import 'package:http/http.dart' as http;
import 'package:mockito/mockito.dart';
import '../testing/test_http_client_utils.dart';
import '../testing/test_utils.mocks.dart';
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
DiContainer.instance.initState();
var jwtTokenStorage = MockJwtTokenStorage();
when(jwtTokenStorage.getAccessToken()).thenAnswer((_) async => null);
DiContainer.instance.put(JwtTokenStorage, jwtTokenStorage);
LoginController controller = LoginControllerImpl();
group('LoginController', () {
test('authenticate returns JwtTokenPairDto on successful login', () async {
final client = MockClient();
DiContainer.instance.put(HttpClientUtils, TestHttpCLientUtilsImpl(client));
when(jwtTokenStorage.saveTokens(any, any)).thenAnswer((_) async => {});
when(client.get(Uri.parse('http://localhost:8080/api/login'), headers: anyNamed('headers')))
.thenAnswer((_) async => http.Response(_jwtTokenPairJson, 200));
var reply = await controller.authenticate("testuser", "testpass");
expect(reply.jwtTokenPairDto, isNotNull);
expect(reply.jwtTokenPairDto?.accessToken, "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.access");
expect(reply.jwtTokenPairDto?.refreshToken, "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.refresh");
verify(jwtTokenStorage.saveTokens(any, any)).called(1);
});
test('authenticate returns null on authentication failure (401)', () async {
final client = MockClient();
DiContainer.instance.put(HttpClientUtils, TestHttpCLientUtilsImpl(client));
when(client.get(Uri.parse('http://localhost:8080/api/login'), headers: anyNamed('headers')))
.thenAnswer((_) async => http.Response('Unauthorized', 401));
var reply = await controller.authenticate("wronguser", "wrongpass");
expect(reply.jwtTokenPairDto, isNull);
verifyNever(jwtTokenStorage.saveTokens(any, any));
});
test('authenticate returns null on server error (500)', () async {
final client = MockClient();
DiContainer.instance.put(HttpClientUtils, TestHttpCLientUtilsImpl(client));
when(client.get(Uri.parse('http://localhost:8080/api/login'), headers: anyNamed('headers')))
.thenAnswer((_) async => http.Response('Internal Server Error', 500));
var reply = await controller.authenticate("testuser", "testpass");
expect(reply.jwtTokenPairDto, isNull);
verifyNever(jwtTokenStorage.saveTokens(any, any));
});
test('authenticate returns null on exception', () async {
final client = MockClient();
DiContainer.instance.put(HttpClientUtils, TestHttpCLientUtilsImpl(client));
when(client.get(Uri.parse('http://localhost:8080/api/login'), headers: anyNamed('headers')))
.thenThrow(Exception('Network error'));
var reply = await controller.authenticate("testuser", "testpass");
expect(reply.jwtTokenPairDto, isNull);
verifyNever(jwtTokenStorage.saveTokens(any, any));
});
});
}
String _jwtTokenPairJson = '''{
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.access",
"refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.refresh"
}''';

View File

@@ -0,0 +1,41 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:fotodocumentation/controller/picture_controller.dart';
import 'package:fotodocumentation/dto/picture_dto.dart';
import 'package:fotodocumentation/utils/di_container.dart';
import 'package:fotodocumentation/utils/http_client_utils.dart';
import 'package:fotodocumentation/utils/jwt_token_storage.dart';
import 'package:http/http.dart' as http;
import 'package:mockito/mockito.dart';
import '../testing/test_http_client_utils.dart';
import '../testing/test_utils.mocks.dart';
void main() {
DiContainer.instance.initState();
var jwtTokenStorage = MockJwtTokenStorage();
when(jwtTokenStorage.getAccessToken()).thenAnswer((_) async => null);
DiContainer.instance.put(JwtTokenStorage, jwtTokenStorage);
PictureController controller = PictureControllerImpl();
group('PictureControllerTest', () {
test('returns true if delete success', () async {
_testDelete(controller, 200, true);
});
test('returns false if delete failed', () async {
_testDelete(controller, 404, false);
});
});
}
void _testDelete(PictureController controller, int response, bool expected) async {
final client = MockClient();
DiContainer.instance.put(HttpClientUtils, TestHttpCLientUtilsImpl(client));
when(client.delete(Uri.parse('http://localhost:8080/api/picture/4'), headers: {"Accept-Language": "en-US"})).thenAnswer((_) async => http.Response("", response));
var dto = await controller.delete(PictureDto(id: 4, image: "", pictureDate: DateTime.now(), category: "", comment: "", username: ""));
expect(dto, expected);
}

View File

@@ -0,0 +1,146 @@
import 'dart:ui' show PointerDeviceKind;
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:fotodocumentation/main.dart';
import 'package:fotodocumentation/utils/di_container.dart';
import 'package:fotodocumentation/utils/login_credentials.dart';
import 'package:fotodocumentation/utils/main_utils.dart';
import 'testing/test_utils.dart';
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
DiContainer.instance.initState();
DiContainer.instance.put(LoginCredentials, getDefaultLoginCredentials());
group('FotoDocumentationApp', () {
testWidgets('renders MaterialApp with router', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await tester.pumpWidget(
FotoDocumentationApp(theme: ThemeData.light()),
);
await tester.pumpAndSettle();
// Verify MaterialApp.router is used
expect(find.byType(MaterialApp), findsOneWidget);
});
testWidgets('has correct app title', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await tester.pumpWidget(
FotoDocumentationApp(theme: ThemeData.light()),
);
await tester.pumpAndSettle();
// Find the MaterialApp and verify its title
final materialApp = tester.widget<MaterialApp>(find.byType(MaterialApp));
expect(materialApp.title, equals('Hartmann Foto App'));
});
testWidgets('uses custom scroll behavior', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await tester.pumpWidget(
FotoDocumentationApp(theme: ThemeData.light()),
);
await tester.pumpAndSettle();
// Find the MaterialApp and verify its scrollBehavior type
final materialApp = tester.widget<MaterialApp>(find.byType(MaterialApp));
expect(materialApp.scrollBehavior, isA<MyCustomScrollBehavior>());
});
testWidgets('supports German locale', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await tester.pumpWidget(
FotoDocumentationApp(theme: ThemeData.light()),
);
await tester.pumpAndSettle();
// Find the MaterialApp and verify German is in supported locales
final materialApp = tester.widget<MaterialApp>(find.byType(MaterialApp));
expect(materialApp.supportedLocales, contains(const Locale('de')));
});
testWidgets('has localization delegates configured', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await tester.pumpWidget(
FotoDocumentationApp(theme: ThemeData.light()),
);
await tester.pumpAndSettle();
// Find the MaterialApp and verify localization delegates are set
final materialApp = tester.widget<MaterialApp>(find.byType(MaterialApp));
expect(materialApp.localizationsDelegates, isNotNull);
expect(materialApp.localizationsDelegates!.length, equals(4));
});
testWidgets('applies provided theme', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
final customTheme = ThemeData(
primarySwatch: Colors.blue,
brightness: Brightness.light,
);
await tester.pumpWidget(
FotoDocumentationApp(theme: customTheme),
);
await tester.pumpAndSettle();
// Find the MaterialApp and verify the theme is applied
final materialApp = tester.widget<MaterialApp>(find.byType(MaterialApp));
expect(materialApp.theme, equals(customTheme));
});
testWidgets('applies dark theme when provided', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
final darkTheme = ThemeData.dark();
await tester.pumpWidget(
FotoDocumentationApp(theme: darkTheme),
);
await tester.pumpAndSettle();
// Find the MaterialApp and verify the dark theme is applied
final materialApp = tester.widget<MaterialApp>(find.byType(MaterialApp));
expect(materialApp.theme, equals(darkTheme));
});
testWidgets('uses router config', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await tester.pumpWidget(
FotoDocumentationApp(theme: ThemeData.light()),
);
await tester.pumpAndSettle();
// Find the MaterialApp and verify routerConfig is set
final materialApp = tester.widget<MaterialApp>(find.byType(MaterialApp));
expect(materialApp.routerConfig, isNotNull);
});
});
group('MyCustomScrollBehavior', () {
test('includes touch pointer device', () {
final scrollBehavior = MyCustomScrollBehavior();
expect(scrollBehavior.dragDevices, contains(PointerDeviceKind.touch));
});
test('includes mouse pointer device', () {
final scrollBehavior = MyCustomScrollBehavior();
expect(scrollBehavior.dragDevices, contains(PointerDeviceKind.mouse));
});
test('extends MaterialScrollBehavior', () {
final scrollBehavior = MyCustomScrollBehavior();
expect(scrollBehavior, isA<MaterialScrollBehavior>());
});
});
}

View File

@@ -0,0 +1,48 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:fotodocumentation/utils/global_router.dart';
import 'package:fotodocumentation/utils/login_credentials.dart';
import 'package:mockito/mockito.dart';
import 'package:fotodocumentation/controller/customer_controller.dart';
import 'package:fotodocumentation/dto/customer_dto.dart';
import 'package:fotodocumentation/utils/di_container.dart';
import '../testing/test_utils.dart';
import '../testing/test_utils.mocks.dart';
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
DiContainer.instance.initState();
DiContainer.instance.put(LoginCredentials, getDefaultLoginCredentials());
group('Customer List Test', () {
testWidgets('Customer list screen search test', (WidgetTester tester) async {
await _searchtest(tester);
});
});
}
List<CustomerListDto> _list = [CustomerListDto(id: 1, customerNumber: "CODE1", name: "Customer 1"), CustomerListDto(id: 2, customerNumber: "CODE2", name: "Customer 2")];
Future<void> _searchtest(WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
String searchText = 'Henk';
var controller = MockCustomerController();
DiContainer.instance.put(CustomerController, controller);
when(controller.getAll("", "")).thenAnswer((_) async => _list);
when(controller.getAll(searchText, "")).thenAnswer((_) async => [_list.first]);
await pumpAppConfig(tester, GlobalRouter.pathHome);
verify(controller.getAll(argThat(equals("")), argThat(equals("")))).called(1);
await tester.enterText(find.byKey(Key("Search_text_field")), searchText);
await tester.testTextInput.receiveAction(TextInputAction.done);
await tester.pumpAndSettle();
verify(controller.getAll(searchText, "")).called(1);
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,200 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:fotodocumentation/controller/login_controller.dart';
import 'package:fotodocumentation/dto/jwt_token_pair_dto.dart';
import 'package:fotodocumentation/pages/login/login_widget.dart';
import 'package:fotodocumentation/utils/di_container.dart';
import 'package:fotodocumentation/utils/global_router.dart';
import 'package:fotodocumentation/utils/login_credentials.dart';
import 'package:mockito/mockito.dart';
import '../testing/test_utils.dart';
import '../testing/test_utils.mocks.dart';
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
DiContainer.instance.initState();
late MockLoginController mockLoginController;
late MockLoginCredentials mockLoginCredentials;
setUp(() {
mockLoginController = MockLoginController();
mockLoginCredentials = MockLoginCredentials();
when(mockLoginCredentials.isLoggedIn).thenReturn(false);
DiContainer.instance.put(LoginController, mockLoginController);
DiContainer.instance.put(LoginCredentials, mockLoginCredentials);
});
group('LoginWidget', () {
testWidgets('displays login title', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await pumpApp(tester, const LoginWidget());
await tester.pumpAndSettle();
// Verify the login title is displayed (German localization)
expect(find.text('BILDERUPLOAD'), findsOneWidget);
});
testWidgets('displays username and password fields', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await pumpApp(tester, const LoginWidget());
await tester.pumpAndSettle();
// Verify username field exists
expect(find.byKey(const Key("username")), findsOneWidget);
// Verify password field exists
expect(find.byKey(const Key("password")), findsOneWidget);
});
testWidgets('displays login button', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await pumpApp(tester, const LoginWidget());
await tester.pumpAndSettle();
// Verify login button exists
expect(find.byKey(const Key("SubmitWidgetButton")), findsOneWidget);
});
testWidgets('can enter username and password', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await pumpApp(tester, const LoginWidget());
await tester.pumpAndSettle();
// Enter username
await tester.enterText(find.byKey(const Key("username")), 'testuser');
await tester.pumpAndSettle();
// Enter password
await tester.enterText(find.byKey(const Key("password")), 'testpassword');
await tester.pumpAndSettle();
// Verify text was entered
expect(find.text('testuser'), findsOneWidget);
});
testWidgets('calls authenticate on login button tap', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
final jwtTokenPairDto = JwtTokenPairDto(
accessToken: 'test_access_token',
refreshToken: 'test_refresh_token',
);
when(mockLoginController.authenticate('testuser', 'testpassword'))
.thenAnswer((_) async => (jwtTokenPairDto: jwtTokenPairDto));
await pumpAppConfig(tester, GlobalRouter.pathLogin);
await tester.pumpAndSettle();
// Enter credentials
await tester.enterText(find.byKey(const Key("username")), 'testuser');
await tester.enterText(find.byKey(const Key("password")), 'testpassword');
await tester.pumpAndSettle();
// Tap login button
await tester.tap(find.byKey(const Key("SubmitWidgetButton")));
await tester.pumpAndSettle();
// Verify authenticate was called with correct credentials
verify(mockLoginController.authenticate('testuser', 'testpassword')).called(1);
});
testWidgets('sets logged in on successful authentication', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
final jwtTokenPairDto = JwtTokenPairDto(
accessToken: 'test_access_token',
refreshToken: 'test_refresh_token',
);
when(mockLoginController.authenticate('testuser', 'testpassword'))
.thenAnswer((_) async => (jwtTokenPairDto: jwtTokenPairDto));
await pumpAppConfig(tester, GlobalRouter.pathLogin);
await tester.pumpAndSettle();
// Enter credentials
await tester.enterText(find.byKey(const Key("username")), 'testuser');
await tester.enterText(find.byKey(const Key("password")), 'testpassword');
await tester.pumpAndSettle();
// Tap login button
await tester.tap(find.byKey(const Key("SubmitWidgetButton")));
await tester.pumpAndSettle();
// Verify setLoggedIn was called
verify(mockLoginCredentials.setLoggedIn(true)).called(1);
});
testWidgets('displays error message on failed authentication', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
when(mockLoginController.authenticate('testuser', 'wrongpassword'))
.thenAnswer((_) async => (jwtTokenPairDto: null));
await pumpAppConfig(tester, GlobalRouter.pathLogin);
await tester.pumpAndSettle();
// Enter credentials
await tester.enterText(find.byKey(const Key("username")), 'testuser');
await tester.enterText(find.byKey(const Key("password")), 'wrongpassword');
await tester.pumpAndSettle();
// Tap login button
await tester.tap(find.byKey(const Key("SubmitWidgetButton")));
await tester.pumpAndSettle();
// Verify error message is displayed (German localization)
expect(find.text('Falscher Benutzername oder Passwort'), findsOneWidget);
});
testWidgets('does not call setLoggedIn on failed authentication', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
when(mockLoginController.authenticate('testuser', 'wrongpassword'))
.thenAnswer((_) async => (jwtTokenPairDto: null));
await pumpAppConfig(tester, GlobalRouter.pathLogin);
await tester.pumpAndSettle();
// Enter credentials
await tester.enterText(find.byKey(const Key("username")), 'testuser');
await tester.enterText(find.byKey(const Key("password")), 'wrongpassword');
await tester.pumpAndSettle();
// Tap login button
await tester.tap(find.byKey(const Key("SubmitWidgetButton")));
await tester.pumpAndSettle();
// Verify setLoggedIn was NOT called
verifyNever(mockLoginCredentials.setLoggedIn(any));
});
testWidgets('password field obscures text', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await pumpApp(tester, const LoginWidget());
await tester.pumpAndSettle();
// Find the EditableText descendant of the password field
// TextFormField wraps TextField which contains EditableText
final passwordFieldFinder = find.byKey(const Key("password"));
final editableTextFinder = find.descendant(
of: passwordFieldFinder,
matching: find.byType(EditableText),
);
final editableText = tester.widget<EditableText>(editableTextFinder);
// Verify obscureText is true
expect(editableText.obscureText, isTrue);
});
});
}

View File

@@ -0,0 +1,258 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:fotodocumentation/dto/customer_dto.dart' show CustomerDto;
import 'package:fotodocumentation/dto/picture_dto.dart';
import 'package:fotodocumentation/pages/customer/picture_widget.dart';
import 'package:fotodocumentation/pages/customer/picture_fullscreen_dialog.dart';
import 'package:fotodocumentation/utils/di_container.dart';
import 'package:fotodocumentation/utils/login_credentials.dart';
import '../testing/test_utils.dart';
// Minimal valid base64 encoded 1x1 pixel PNG image
const String _testImage =
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==';
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
DiContainer.instance.initState();
DiContainer.instance.put(LoginCredentials, getDefaultLoginCredentials());
late CustomerDto customerDto;
late PictureDto pictureDto1;
late PictureDto pictureDto2;
late PictureDto pictureDto3;
setUp(() {
pictureDto1 = PictureDto(
id: 1,
comment: 'First picture comment',
category: 'category1',
image: _testImage,
pictureDate: DateTime(2024, 1, 15),
username: 'user1',
);
pictureDto2 = PictureDto(
id: 2,
comment: 'Second picture comment',
category: 'category2',
image: _testImage,
pictureDate: DateTime(2024, 2, 20),
username: 'user2',
);
pictureDto3 = PictureDto(
id: 3,
comment: null,
category: 'category3',
image: _testImage,
pictureDate: DateTime(2024, 3, 25),
username: 'user3',
);
customerDto = CustomerDto(
id: 1,
name: 'Test Apotheke',
customerNumber: 'CUST001',
pictures: [pictureDto1, pictureDto2, pictureDto3],
);
});
group('PictureWidget', () {
testWidgets('displays customer information correctly', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await pumpApp(
tester,
PictureWidget(customerDto: customerDto, pictureDto: pictureDto1),
);
await tester.pumpAndSettle();
// Verify that the header is displayed
expect(find.text('INFORMATIONEN'), findsOneWidget);
// Verify customer name is displayed
expect(find.text('Test Apotheke'), findsOneWidget);
// Verify customer number is displayed
expect(find.text('CUST001'), findsOneWidget);
// Verify labels are displayed
expect(find.text('APOTHEKE'), findsOneWidget);
expect(find.text('KUNDENNUMMER'), findsOneWidget);
expect(find.text('DATUM'), findsOneWidget);
expect(find.text('KOMMENTAR'), findsOneWidget);
});
testWidgets('displays picture comment', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await pumpApp(
tester,
PictureWidget(customerDto: customerDto, pictureDto: pictureDto1),
);
await tester.pumpAndSettle();
// Verify the comment is displayed
expect(find.text('First picture comment'), findsOneWidget);
});
testWidgets('displays empty string when comment is null', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await pumpApp(
tester,
PictureWidget(customerDto: customerDto, pictureDto: pictureDto3),
);
await tester.pumpAndSettle();
// The comment field should be empty but the label should exist
expect(find.text('KOMMENTAR'), findsOneWidget);
});
testWidgets('shows close button', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await pumpApp(
tester,
PictureWidget(customerDto: customerDto, pictureDto: pictureDto1),
);
await tester.pumpAndSettle();
// Verify close button icon exists
expect(find.byIcon(Icons.close), findsOneWidget);
});
testWidgets('shows right navigation button when there are more pictures', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await pumpApp(
tester,
PictureWidget(customerDto: customerDto, pictureDto: pictureDto1),
);
await tester.pumpAndSettle();
// First picture should have right navigation (chevron_right), no left navigation
expect(find.byIcon(Icons.chevron_right), findsOneWidget);
expect(find.byIcon(Icons.chevron_left), findsNothing);
});
testWidgets('shows left navigation button when not on first picture', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await pumpApp(
tester,
PictureWidget(customerDto: customerDto, pictureDto: pictureDto2),
);
await tester.pumpAndSettle();
// Middle picture should have both navigation buttons
expect(find.byIcon(Icons.chevron_left), findsOneWidget);
expect(find.byIcon(Icons.chevron_right), findsOneWidget);
});
testWidgets('shows only left navigation on last picture', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await pumpApp(
tester,
PictureWidget(customerDto: customerDto, pictureDto: pictureDto3),
);
await tester.pumpAndSettle();
// Last picture should have left navigation, no right navigation
expect(find.byIcon(Icons.chevron_left), findsOneWidget);
expect(find.byIcon(Icons.chevron_right), findsNothing);
});
testWidgets('navigates to next picture when right button is tapped', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await pumpApp(
tester,
PictureWidget(customerDto: customerDto, pictureDto: pictureDto1),
);
await tester.pumpAndSettle();
// Verify first picture comment is shown
expect(find.text('First picture comment'), findsOneWidget);
// Tap right navigation button
await tester.tap(find.byIcon(Icons.chevron_right));
await tester.pumpAndSettle();
// Verify second picture comment is now shown
expect(find.text('Second picture comment'), findsOneWidget);
expect(find.text('First picture comment'), findsNothing);
});
testWidgets('navigates to previous picture when left button is tapped', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await pumpApp(
tester,
PictureWidget(customerDto: customerDto, pictureDto: pictureDto2),
);
await tester.pumpAndSettle();
// Verify second picture comment is shown
expect(find.text('Second picture comment'), findsOneWidget);
// Tap left navigation button
await tester.tap(find.byIcon(Icons.chevron_left));
await tester.pumpAndSettle();
// Verify first picture comment is now shown
expect(find.text('First picture comment'), findsOneWidget);
expect(find.text('Second picture comment'), findsNothing);
});
testWidgets('shows no navigation buttons when only one picture', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
final singlePictureCustomer = CustomerDto(
id: 1,
name: 'Test Apotheke',
customerNumber: 'CUST001',
pictures: [pictureDto1],
);
await pumpApp(
tester,
PictureWidget(customerDto: singlePictureCustomer, pictureDto: pictureDto1),
);
await tester.pumpAndSettle();
// No navigation buttons should be shown
expect(find.byIcon(Icons.chevron_left), findsNothing);
expect(find.byIcon(Icons.chevron_right), findsNothing);
});
testWidgets('opens fullscreen dialog when image is tapped', (WidgetTester tester) async {
setScreenSize(tester, 2048, 2048);
await pumpApp(
tester,
PictureWidget(customerDto: customerDto, pictureDto: pictureDto1),
);
await tester.pumpAndSettle();
// Find the GestureDetector with the image key
final imageFinder = find.byKey(const Key("image"));
expect(imageFinder, findsOneWidget);
// Ensure the widget is visible first
await tester.ensureVisible(imageFinder);
await tester.pumpAndSettle();
// Tap the image - use warnIfMissed: false since the Image.memory may have
// rendering issues in test environment but the GestureDetector should still work
await tester.tap(imageFinder, warnIfMissed: false);
await tester.pumpAndSettle();
// Verify fullscreen dialog is shown
expect(find.byType(PictureFullscreenDialog), findsOneWidget);
});
});
}

View File

@@ -0,0 +1,211 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:fotodocumentation/controller/base_controller.dart';
import 'package:fotodocumentation/pages/ui_utils/component/general_error_widget.dart';
import 'package:fotodocumentation/utils/di_container.dart';
import 'package:fotodocumentation/utils/login_credentials.dart';
import '../../testing/test_utils.dart';
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
DiContainer.instance.initState();
DiContainer.instance.put(LoginCredentials, getDefaultLoginCredentials());
group('GeneralErrorWidget', () {
testWidgets('displays error icon', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await pumpApp(
tester,
const GeneralErrorWidget(error: 'Test error'),
);
await tester.pumpAndSettle();
// Verify error icon is displayed
expect(find.byIcon(Icons.error_outline), findsOneWidget);
});
testWidgets('displays error message with error text', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await pumpApp(
tester,
const GeneralErrorWidget(error: 'Something went wrong'),
);
await tester.pumpAndSettle();
// Verify error message is displayed (German localization: "Fehler: {name}")
expect(find.text('Fehler: Something went wrong'), findsOneWidget);
});
testWidgets('displays status code message when statusCode is provided', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await pumpApp(
tester,
const GeneralErrorWidget(error: '', statusCode: 404),
);
await tester.pumpAndSettle();
// Verify status code message is displayed (German localization: "Statuscode {statusCode}")
expect(find.text('Statuscode 404'), findsOneWidget);
});
testWidgets('displays status code message for 500 error', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await pumpApp(
tester,
const GeneralErrorWidget(error: '', statusCode: 500),
);
await tester.pumpAndSettle();
// Verify status code message is displayed
expect(find.text('Statuscode 500'), findsOneWidget);
});
testWidgets('does not display retry button when reload is null', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await pumpApp(
tester,
const GeneralErrorWidget(error: 'Test error'),
);
await tester.pumpAndSettle();
// Verify retry button is not displayed
expect(find.byType(ElevatedButton), findsNothing);
expect(find.text('Wiederholen'), findsNothing);
});
testWidgets('displays retry button when reload is provided', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await pumpApp(
tester,
GeneralErrorWidget(error: 'Test error', reload: () {}),
);
await tester.pumpAndSettle();
// Verify retry button is displayed (German localization: "Wiederholen")
expect(find.byType(ElevatedButton), findsOneWidget);
expect(find.text('Wiederholen'), findsOneWidget);
});
testWidgets('calls reload callback when retry button is tapped', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
bool reloadCalled = false;
await pumpApp(
tester,
GeneralErrorWidget(
error: 'Test error',
reload: () {
reloadCalled = true;
},
),
);
await tester.pumpAndSettle();
// Tap retry button
await tester.tap(find.byType(ElevatedButton));
await tester.pumpAndSettle();
// Verify reload was called
expect(reloadCalled, isTrue);
});
testWidgets('fromServerError factory creates widget with status code', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
final serverError = ServerError(403);
await pumpApp(
tester,
GeneralErrorWidget.fromServerError(serverError),
);
await tester.pumpAndSettle();
// Verify status code message is displayed
expect(find.text('Statuscode 403'), findsOneWidget);
});
testWidgets('fromServerError factory with reload callback', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
bool reloadCalled = false;
final serverError = ServerError(401);
await pumpApp(
tester,
GeneralErrorWidget.fromServerError(
serverError,
reload: () {
reloadCalled = true;
},
),
);
await tester.pumpAndSettle();
// Verify status code is displayed
expect(find.text('Statuscode 401'), findsOneWidget);
// Verify retry button is displayed and functional
expect(find.text('Wiederholen'), findsOneWidget);
await tester.tap(find.byType(ElevatedButton));
await tester.pumpAndSettle();
expect(reloadCalled, isTrue);
});
testWidgets('widget renders correctly', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await pumpApp(
tester,
const GeneralErrorWidget(error: 'Test error'),
);
await tester.pumpAndSettle();
// Verify GeneralErrorWidget is rendered
expect(find.byType(GeneralErrorWidget), findsOneWidget);
// Verify it contains a Column for layout
final columnFinder = find.descendant(
of: find.byType(GeneralErrorWidget),
matching: find.byType(Column),
);
expect(columnFinder, findsOneWidget);
});
testWidgets('error icon has correct color', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await pumpApp(
tester,
const GeneralErrorWidget(error: 'Test error'),
);
await tester.pumpAndSettle();
// Find the Icon widget and verify its color
final icon = tester.widget<Icon>(find.byIcon(Icons.error_outline));
expect(icon.color, equals(Colors.red[300]));
});
testWidgets('error icon has correct size', (WidgetTester tester) async {
setScreenSize(tester, 1024, 1024);
await pumpApp(
tester,
const GeneralErrorWidget(error: 'Test error'),
);
await tester.pumpAndSettle();
// Find the Icon widget and verify its size
final icon = tester.widget<Icon>(find.byIcon(Icons.error_outline));
expect(icon.size, equals(60));
});
});
}

View File

@@ -1,14 +1,17 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:fotodocumentation/controller/customer_controller.dart'; import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'package:mockito/annotations.dart'; import 'package:mockito/annotations.dart';
import 'package:mockito/mockito.dart';
import 'package:fotodocumentation/controller/customer_controller.dart';
import 'package:fotodocumentation/controller/login_controller.dart';
import 'package:fotodocumentation/controller/picture_controller.dart';
import 'package:fotodocumentation/l10n/app_localizations.dart'; import 'package:fotodocumentation/l10n/app_localizations.dart';
import 'package:fotodocumentation/pages/ui_utils/dialog/snackbar_utils.dart';
import 'package:fotodocumentation/pages/ui_utils/header_utils.dart';
import 'package:fotodocumentation/utils/login_credentials.dart'; import 'package:fotodocumentation/utils/login_credentials.dart';
import 'package:fotodocumentation/utils/jwt_token_storage.dart'; import 'package:fotodocumentation/utils/jwt_token_storage.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:fotodocumentation/utils/global_router.dart'; import 'package:fotodocumentation/utils/global_router.dart';
import 'test_utils.mocks.dart'; import 'test_utils.mocks.dart';
@@ -20,6 +23,7 @@ void setScreenSize(WidgetTester tester, int width, int height) {
MockLoginCredentials getDefaultLoginCredentials() { MockLoginCredentials getDefaultLoginCredentials() {
var mockLoginCredentials = MockLoginCredentials(); var mockLoginCredentials = MockLoginCredentials();
when(mockLoginCredentials.isLoggedIn).thenReturn(true);
return mockLoginCredentials; return mockLoginCredentials;
} }
@@ -58,9 +62,9 @@ Future<void> pumpAppConfig(WidgetTester tester, String initialLocation) async {
// dart run build_runner build // dart run build_runner build
@GenerateMocks([ @GenerateMocks([
LoginCredentials, LoginCredentials,
LoginController,
CustomerController, CustomerController,
HeaderUtils, PictureController,
SnackbarUtils,
JwtTokenStorage, JwtTokenStorage,
http.Client, http.Client,
]) ])

View File

@@ -3,20 +3,22 @@
// Do not manually edit this file. // Do not manually edit this file.
// ignore_for_file: no_leading_underscores_for_library_prefixes // ignore_for_file: no_leading_underscores_for_library_prefixes
import 'dart:async' as _i11; import 'dart:async' as _i7;
import 'dart:convert' as _i12; import 'dart:convert' as _i14;
import 'dart:typed_data' as _i13; import 'dart:typed_data' as _i15;
import 'dart:ui' as _i6; import 'dart:ui' as _i5;
import 'package:flutter/material.dart' as _i2; import 'package:fotodocumentation/controller/customer_controller.dart' as _i9;
import 'package:fotodocumentation/pages/ui_utils/dialog/snackbar_utils.dart' import 'package:fotodocumentation/controller/login_controller.dart' as _i6;
as _i9; import 'package:fotodocumentation/controller/picture_controller.dart' as _i11;
import 'package:fotodocumentation/pages/ui_utils/header_utils.dart' as _i7; import 'package:fotodocumentation/dto/customer_dto.dart' as _i10;
import 'package:fotodocumentation/utils/jwt_token_storage.dart' as _i10; import 'package:fotodocumentation/dto/jwt_token_pair_dto.dart' as _i8;
import 'package:fotodocumentation/utils/login_credentials.dart' as _i4; import 'package:fotodocumentation/dto/picture_dto.dart' as _i12;
import 'package:http/http.dart' as _i3; import 'package:fotodocumentation/utils/jwt_token_storage.dart' as _i13;
import 'package:fotodocumentation/utils/login_credentials.dart' as _i3;
import 'package:http/http.dart' as _i2;
import 'package:mockito/mockito.dart' as _i1; import 'package:mockito/mockito.dart' as _i1;
import 'package:mockito/src/dummies.dart' as _i5; import 'package:mockito/src/dummies.dart' as _i4;
// ignore_for_file: type=lint // ignore_for_file: type=lint
// ignore_for_file: avoid_redundant_argument_values // ignore_for_file: avoid_redundant_argument_values
@@ -33,22 +35,8 @@ import 'package:mockito/src/dummies.dart' as _i5;
// ignore_for_file: subtype_of_sealed_class // ignore_for_file: subtype_of_sealed_class
// ignore_for_file: invalid_use_of_internal_member // ignore_for_file: invalid_use_of_internal_member
class _FakeWidget_0 extends _i1.SmartFake implements _i2.Widget { class _FakeResponse_0 extends _i1.SmartFake implements _i2.Response {
_FakeWidget_0( _FakeResponse_0(
Object parent,
Invocation parentInvocation,
) : super(
parent,
parentInvocation,
);
@override
String toString({_i2.DiagnosticLevel? minLevel = _i2.DiagnosticLevel.info}) =>
super.toString();
}
class _FakeResponse_1 extends _i1.SmartFake implements _i3.Response {
_FakeResponse_1(
Object parent, Object parent,
Invocation parentInvocation, Invocation parentInvocation,
) : super( ) : super(
@@ -57,9 +45,9 @@ class _FakeResponse_1 extends _i1.SmartFake implements _i3.Response {
); );
} }
class _FakeStreamedResponse_2 extends _i1.SmartFake class _FakeStreamedResponse_1 extends _i1.SmartFake
implements _i3.StreamedResponse { implements _i2.StreamedResponse {
_FakeStreamedResponse_2( _FakeStreamedResponse_1(
Object parent, Object parent,
Invocation parentInvocation, Invocation parentInvocation,
) : super( ) : super(
@@ -71,7 +59,7 @@ class _FakeStreamedResponse_2 extends _i1.SmartFake
/// A class which mocks [LoginCredentials]. /// A class which mocks [LoginCredentials].
/// ///
/// See the documentation for Mockito's code generation for more information. /// See the documentation for Mockito's code generation for more information.
class MockLoginCredentials extends _i1.Mock implements _i4.LoginCredentials { class MockLoginCredentials extends _i1.Mock implements _i3.LoginCredentials {
MockLoginCredentials() { MockLoginCredentials() {
_i1.throwOnMissingStub(this); _i1.throwOnMissingStub(this);
} }
@@ -79,18 +67,33 @@ class MockLoginCredentials extends _i1.Mock implements _i4.LoginCredentials {
@override @override
String get fullname => (super.noSuchMethod( String get fullname => (super.noSuchMethod(
Invocation.getter(#fullname), Invocation.getter(#fullname),
returnValue: _i5.dummyValue<String>( returnValue: _i4.dummyValue<String>(
this, this,
Invocation.getter(#fullname), Invocation.getter(#fullname),
), ),
) as String); ) as String);
@override
bool get isLoggedIn => (super.noSuchMethod(
Invocation.getter(#isLoggedIn),
returnValue: false,
) as bool);
@override @override
bool get hasListeners => (super.noSuchMethod( bool get hasListeners => (super.noSuchMethod(
Invocation.getter(#hasListeners), Invocation.getter(#hasListeners),
returnValue: false, returnValue: false,
) as bool); ) as bool);
@override
void setLoggedIn(bool? loggedIn) => super.noSuchMethod(
Invocation.method(
#setLoggedIn,
[loggedIn],
),
returnValueForMissingStub: null,
);
@override @override
void logout() => super.noSuchMethod( void logout() => super.noSuchMethod(
Invocation.method( Invocation.method(
@@ -101,7 +104,7 @@ class MockLoginCredentials extends _i1.Mock implements _i4.LoginCredentials {
); );
@override @override
void addListener(_i6.VoidCallback? listener) => super.noSuchMethod( void addListener(_i5.VoidCallback? listener) => super.noSuchMethod(
Invocation.method( Invocation.method(
#addListener, #addListener,
[listener], [listener],
@@ -110,7 +113,7 @@ class MockLoginCredentials extends _i1.Mock implements _i4.LoginCredentials {
); );
@override @override
void removeListener(_i6.VoidCallback? listener) => super.noSuchMethod( void removeListener(_i5.VoidCallback? listener) => super.noSuchMethod(
Invocation.method( Invocation.method(
#removeListener, #removeListener,
[listener], [listener],
@@ -137,85 +140,115 @@ class MockLoginCredentials extends _i1.Mock implements _i4.LoginCredentials {
); );
} }
/// A class which mocks [HeaderUtils]. /// A class which mocks [LoginController].
/// ///
/// See the documentation for Mockito's code generation for more information. /// See the documentation for Mockito's code generation for more information.
class MockHeaderUtils extends _i1.Mock implements _i7.HeaderUtils { class MockLoginController extends _i1.Mock implements _i6.LoginController {
MockHeaderUtils() { MockLoginController() {
_i1.throwOnMissingStub(this); _i1.throwOnMissingStub(this);
} }
@override @override
_i2.Widget titleWidget(String? text) => (super.noSuchMethod( _i7.Future<({_i8.JwtTokenPairDto? jwtTokenPairDto})> authenticate(
String? username,
String? password,
) =>
(super.noSuchMethod(
Invocation.method( Invocation.method(
#titleWidget, #authenticate,
[text], [
username,
password,
],
), ),
returnValue: _FakeWidget_0( returnValue: _i7.Future<({_i8.JwtTokenPairDto? jwtTokenPairDto})>.value(
this, (jwtTokenPairDto: null)),
Invocation.method( ) as _i7.Future<({_i8.JwtTokenPairDto? jwtTokenPairDto})>);
#titleWidget,
[text], @override
), _i7.Future<bool> refreshAccessToken() => (super.noSuchMethod(
Invocation.method(
#refreshAccessToken,
[],
), ),
) as _i2.Widget); returnValue: _i7.Future<bool>.value(false),
) as _i7.Future<bool>);
@override
_i7.Future<bool> isUsingJwtAuth() => (super.noSuchMethod(
Invocation.method(
#isUsingJwtAuth,
[],
),
returnValue: _i7.Future<bool>.value(false),
) as _i7.Future<bool>);
} }
/// A class which mocks [SnackbarUtils]. /// A class which mocks [CustomerController].
/// ///
/// See the documentation for Mockito's code generation for more information. /// See the documentation for Mockito's code generation for more information.
class MockSnackbarUtils extends _i1.Mock implements _i9.SnackbarUtils { class MockCustomerController extends _i1.Mock
MockSnackbarUtils() { implements _i9.CustomerController {
MockCustomerController() {
_i1.throwOnMissingStub(this); _i1.throwOnMissingStub(this);
} }
@override @override
void showSnackbar( _i7.Future<List<_i10.CustomerListDto>> getAll(
_i2.BuildContext? context, String? query,
String? msg, String? startsWith,
bool? warning,
) => ) =>
super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(
#showSnackbar, #getAll,
[ [
context, query,
msg, startsWith,
warning,
], ],
), ),
returnValueForMissingStub: null, returnValue: _i7.Future<List<_i10.CustomerListDto>>.value(
); <_i10.CustomerListDto>[]),
) as _i7.Future<List<_i10.CustomerListDto>>);
@override @override
void showSnackbarPopup( _i7.Future<_i10.CustomerDto?> get({required int? id}) => (super.noSuchMethod(
_i2.BuildContext? context,
String? msg,
bool? warning,
) =>
super.noSuchMethod(
Invocation.method( Invocation.method(
#showSnackbarPopup, #get,
[ [],
context, {#id: id},
msg,
warning,
],
), ),
returnValueForMissingStub: null, returnValue: _i7.Future<_i10.CustomerDto?>.value(),
); ) as _i7.Future<_i10.CustomerDto?>);
}
/// A class which mocks [PictureController].
///
/// See the documentation for Mockito's code generation for more information.
class MockPictureController extends _i1.Mock implements _i11.PictureController {
MockPictureController() {
_i1.throwOnMissingStub(this);
}
@override
_i7.Future<bool> delete(_i12.PictureDto? dto) => (super.noSuchMethod(
Invocation.method(
#delete,
[dto],
),
returnValue: _i7.Future<bool>.value(false),
) as _i7.Future<bool>);
} }
/// A class which mocks [JwtTokenStorage]. /// A class which mocks [JwtTokenStorage].
/// ///
/// See the documentation for Mockito's code generation for more information. /// See the documentation for Mockito's code generation for more information.
class MockJwtTokenStorage extends _i1.Mock implements _i10.JwtTokenStorage { class MockJwtTokenStorage extends _i1.Mock implements _i13.JwtTokenStorage {
MockJwtTokenStorage() { MockJwtTokenStorage() {
_i1.throwOnMissingStub(this); _i1.throwOnMissingStub(this);
} }
@override @override
_i11.Future<void> saveTokens( _i7.Future<void> saveTokens(
String? accessToken, String? accessToken,
String? refreshToken, String? refreshToken,
) => ) =>
@@ -227,69 +260,69 @@ class MockJwtTokenStorage extends _i1.Mock implements _i10.JwtTokenStorage {
refreshToken, refreshToken,
], ],
), ),
returnValue: _i11.Future<void>.value(), returnValue: _i7.Future<void>.value(),
returnValueForMissingStub: _i11.Future<void>.value(), returnValueForMissingStub: _i7.Future<void>.value(),
) as _i11.Future<void>); ) as _i7.Future<void>);
@override @override
_i11.Future<String?> getAccessToken() => (super.noSuchMethod( _i7.Future<String?> getAccessToken() => (super.noSuchMethod(
Invocation.method( Invocation.method(
#getAccessToken, #getAccessToken,
[], [],
), ),
returnValue: _i11.Future<String?>.value(), returnValue: _i7.Future<String?>.value(),
) as _i11.Future<String?>); ) as _i7.Future<String?>);
@override @override
_i11.Future<String?> getRefreshToken() => (super.noSuchMethod( _i7.Future<String?> getRefreshToken() => (super.noSuchMethod(
Invocation.method( Invocation.method(
#getRefreshToken, #getRefreshToken,
[], [],
), ),
returnValue: _i11.Future<String?>.value(), returnValue: _i7.Future<String?>.value(),
) as _i11.Future<String?>); ) as _i7.Future<String?>);
@override @override
_i11.Future<void> clearTokens() => (super.noSuchMethod( _i7.Future<void> clearTokens() => (super.noSuchMethod(
Invocation.method( Invocation.method(
#clearTokens, #clearTokens,
[], [],
), ),
returnValue: _i11.Future<void>.value(), returnValue: _i7.Future<void>.value(),
returnValueForMissingStub: _i11.Future<void>.value(), returnValueForMissingStub: _i7.Future<void>.value(),
) as _i11.Future<void>); ) as _i7.Future<void>);
@override @override
_i11.Future<bool> hasTokens() => (super.noSuchMethod( _i7.Future<bool> hasTokens() => (super.noSuchMethod(
Invocation.method( Invocation.method(
#hasTokens, #hasTokens,
[], [],
), ),
returnValue: _i11.Future<bool>.value(false), returnValue: _i7.Future<bool>.value(false),
) as _i11.Future<bool>); ) as _i7.Future<bool>);
@override @override
_i11.Future<void> updateAccessToken(String? accessToken) => _i7.Future<void> updateAccessToken(String? accessToken) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(
#updateAccessToken, #updateAccessToken,
[accessToken], [accessToken],
), ),
returnValue: _i11.Future<void>.value(), returnValue: _i7.Future<void>.value(),
returnValueForMissingStub: _i11.Future<void>.value(), returnValueForMissingStub: _i7.Future<void>.value(),
) as _i11.Future<void>); ) as _i7.Future<void>);
} }
/// A class which mocks [Client]. /// A class which mocks [Client].
/// ///
/// See the documentation for Mockito's code generation for more information. /// See the documentation for Mockito's code generation for more information.
class MockClient extends _i1.Mock implements _i3.Client { class MockClient extends _i1.Mock implements _i2.Client {
MockClient() { MockClient() {
_i1.throwOnMissingStub(this); _i1.throwOnMissingStub(this);
} }
@override @override
_i11.Future<_i3.Response> head( _i7.Future<_i2.Response> head(
Uri? url, { Uri? url, {
Map<String, String>? headers, Map<String, String>? headers,
}) => }) =>
@@ -299,7 +332,7 @@ class MockClient extends _i1.Mock implements _i3.Client {
[url], [url],
{#headers: headers}, {#headers: headers},
), ),
returnValue: _i11.Future<_i3.Response>.value(_FakeResponse_1( returnValue: _i7.Future<_i2.Response>.value(_FakeResponse_0(
this, this,
Invocation.method( Invocation.method(
#head, #head,
@@ -307,10 +340,10 @@ class MockClient extends _i1.Mock implements _i3.Client {
{#headers: headers}, {#headers: headers},
), ),
)), )),
) as _i11.Future<_i3.Response>); ) as _i7.Future<_i2.Response>);
@override @override
_i11.Future<_i3.Response> get( _i7.Future<_i2.Response> get(
Uri? url, { Uri? url, {
Map<String, String>? headers, Map<String, String>? headers,
}) => }) =>
@@ -320,7 +353,7 @@ class MockClient extends _i1.Mock implements _i3.Client {
[url], [url],
{#headers: headers}, {#headers: headers},
), ),
returnValue: _i11.Future<_i3.Response>.value(_FakeResponse_1( returnValue: _i7.Future<_i2.Response>.value(_FakeResponse_0(
this, this,
Invocation.method( Invocation.method(
#get, #get,
@@ -328,14 +361,14 @@ class MockClient extends _i1.Mock implements _i3.Client {
{#headers: headers}, {#headers: headers},
), ),
)), )),
) as _i11.Future<_i3.Response>); ) as _i7.Future<_i2.Response>);
@override @override
_i11.Future<_i3.Response> post( _i7.Future<_i2.Response> post(
Uri? url, { Uri? url, {
Map<String, String>? headers, Map<String, String>? headers,
Object? body, Object? body,
_i12.Encoding? encoding, _i14.Encoding? encoding,
}) => }) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(
@@ -347,7 +380,7 @@ class MockClient extends _i1.Mock implements _i3.Client {
#encoding: encoding, #encoding: encoding,
}, },
), ),
returnValue: _i11.Future<_i3.Response>.value(_FakeResponse_1( returnValue: _i7.Future<_i2.Response>.value(_FakeResponse_0(
this, this,
Invocation.method( Invocation.method(
#post, #post,
@@ -359,14 +392,14 @@ class MockClient extends _i1.Mock implements _i3.Client {
}, },
), ),
)), )),
) as _i11.Future<_i3.Response>); ) as _i7.Future<_i2.Response>);
@override @override
_i11.Future<_i3.Response> put( _i7.Future<_i2.Response> put(
Uri? url, { Uri? url, {
Map<String, String>? headers, Map<String, String>? headers,
Object? body, Object? body,
_i12.Encoding? encoding, _i14.Encoding? encoding,
}) => }) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(
@@ -378,7 +411,7 @@ class MockClient extends _i1.Mock implements _i3.Client {
#encoding: encoding, #encoding: encoding,
}, },
), ),
returnValue: _i11.Future<_i3.Response>.value(_FakeResponse_1( returnValue: _i7.Future<_i2.Response>.value(_FakeResponse_0(
this, this,
Invocation.method( Invocation.method(
#put, #put,
@@ -390,14 +423,14 @@ class MockClient extends _i1.Mock implements _i3.Client {
}, },
), ),
)), )),
) as _i11.Future<_i3.Response>); ) as _i7.Future<_i2.Response>);
@override @override
_i11.Future<_i3.Response> patch( _i7.Future<_i2.Response> patch(
Uri? url, { Uri? url, {
Map<String, String>? headers, Map<String, String>? headers,
Object? body, Object? body,
_i12.Encoding? encoding, _i14.Encoding? encoding,
}) => }) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(
@@ -409,7 +442,7 @@ class MockClient extends _i1.Mock implements _i3.Client {
#encoding: encoding, #encoding: encoding,
}, },
), ),
returnValue: _i11.Future<_i3.Response>.value(_FakeResponse_1( returnValue: _i7.Future<_i2.Response>.value(_FakeResponse_0(
this, this,
Invocation.method( Invocation.method(
#patch, #patch,
@@ -421,14 +454,14 @@ class MockClient extends _i1.Mock implements _i3.Client {
}, },
), ),
)), )),
) as _i11.Future<_i3.Response>); ) as _i7.Future<_i2.Response>);
@override @override
_i11.Future<_i3.Response> delete( _i7.Future<_i2.Response> delete(
Uri? url, { Uri? url, {
Map<String, String>? headers, Map<String, String>? headers,
Object? body, Object? body,
_i12.Encoding? encoding, _i14.Encoding? encoding,
}) => }) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(
@@ -440,7 +473,7 @@ class MockClient extends _i1.Mock implements _i3.Client {
#encoding: encoding, #encoding: encoding,
}, },
), ),
returnValue: _i11.Future<_i3.Response>.value(_FakeResponse_1( returnValue: _i7.Future<_i2.Response>.value(_FakeResponse_0(
this, this,
Invocation.method( Invocation.method(
#delete, #delete,
@@ -452,10 +485,10 @@ class MockClient extends _i1.Mock implements _i3.Client {
}, },
), ),
)), )),
) as _i11.Future<_i3.Response>); ) as _i7.Future<_i2.Response>);
@override @override
_i11.Future<String> read( _i7.Future<String> read(
Uri? url, { Uri? url, {
Map<String, String>? headers, Map<String, String>? headers,
}) => }) =>
@@ -465,7 +498,7 @@ class MockClient extends _i1.Mock implements _i3.Client {
[url], [url],
{#headers: headers}, {#headers: headers},
), ),
returnValue: _i11.Future<String>.value(_i5.dummyValue<String>( returnValue: _i7.Future<String>.value(_i4.dummyValue<String>(
this, this,
Invocation.method( Invocation.method(
#read, #read,
@@ -473,10 +506,10 @@ class MockClient extends _i1.Mock implements _i3.Client {
{#headers: headers}, {#headers: headers},
), ),
)), )),
) as _i11.Future<String>); ) as _i7.Future<String>);
@override @override
_i11.Future<_i13.Uint8List> readBytes( _i7.Future<_i15.Uint8List> readBytes(
Uri? url, { Uri? url, {
Map<String, String>? headers, Map<String, String>? headers,
}) => }) =>
@@ -486,25 +519,25 @@ class MockClient extends _i1.Mock implements _i3.Client {
[url], [url],
{#headers: headers}, {#headers: headers},
), ),
returnValue: _i11.Future<_i13.Uint8List>.value(_i13.Uint8List(0)), returnValue: _i7.Future<_i15.Uint8List>.value(_i15.Uint8List(0)),
) as _i11.Future<_i13.Uint8List>); ) as _i7.Future<_i15.Uint8List>);
@override @override
_i11.Future<_i3.StreamedResponse> send(_i3.BaseRequest? request) => _i7.Future<_i2.StreamedResponse> send(_i2.BaseRequest? request) =>
(super.noSuchMethod( (super.noSuchMethod(
Invocation.method( Invocation.method(
#send, #send,
[request], [request],
), ),
returnValue: returnValue:
_i11.Future<_i3.StreamedResponse>.value(_FakeStreamedResponse_2( _i7.Future<_i2.StreamedResponse>.value(_FakeStreamedResponse_1(
this, this,
Invocation.method( Invocation.method(
#send, #send,
[request], [request],
), ),
)), )),
) as _i11.Future<_i3.StreamedResponse>); ) as _i7.Future<_i2.StreamedResponse>);
@override @override
void close() => super.noSuchMethod( void close() => super.noSuchMethod(