From 3003d5b6fe060274f2f289769d06845251626bc6 Mon Sep 17 00:00:00 2001 From: Pedro Alvarez <14023675+pnalvarez@users.noreply.github.com> Date: Thu, 21 Nov 2024 15:09:37 -0300 Subject: [PATCH] addressed comments --- lib/src/domain/usecases/get_backup_data.dart | 8 +- lib/src/domain/usecases/save_backup_data.dart | 8 +- ...lication_backup_repository_test.mocks.dart | 248 ++++++++++++++++++ .../domain/usecases/get_backup_data_test.dart | 4 +- .../usecases/get_backup_data_test.mocks.dart | 62 +++++ .../usecases/save_backup_data_test.dart | 4 +- .../usecases/save_backup_data_test.mocks.dart | 62 +++++ 7 files changed, 384 insertions(+), 12 deletions(-) create mode 100644 test/src/data/repository/application_backup_repository_test.mocks.dart create mode 100644 test/src/domain/usecases/get_backup_data_test.mocks.dart create mode 100644 test/src/domain/usecases/save_backup_data_test.mocks.dart diff --git a/lib/src/domain/usecases/get_backup_data.dart b/lib/src/domain/usecases/get_backup_data.dart index aa4de47..18e2924 100644 --- a/lib/src/domain/usecases/get_backup_data.dart +++ b/lib/src/domain/usecases/get_backup_data.dart @@ -1,15 +1,15 @@ import 'package:ambush_app/src/data/repositories/application_backup_repository.dart'; import 'package:injectable/injectable.dart'; -abstract class IGetBackupData { +abstract class IGetBackupDataUseCase { Future get(); } -@Injectable(as: IGetBackupData) -class GetBackupData implements IGetBackupData { +@Injectable(as: IGetBackupDataUseCase) +class GetBackupDataUseCase implements IGetBackupDataUseCase { final IApplicationBackupRepository _applicationBackupRepository; - GetBackupData(this._applicationBackupRepository); + GetBackupDataUseCase(this._applicationBackupRepository); @override Future get() async => _applicationBackupRepository.get(); diff --git a/lib/src/domain/usecases/save_backup_data.dart b/lib/src/domain/usecases/save_backup_data.dart index 1a62eeb..dffae01 100644 --- a/lib/src/domain/usecases/save_backup_data.dart +++ b/lib/src/domain/usecases/save_backup_data.dart @@ -1,15 +1,15 @@ import 'package:ambush_app/src/data/repositories/application_backup_repository.dart'; import 'package:injectable/injectable.dart'; -abstract class ISaveBackupData { +abstract class ISaveBackupDataUseCase { Future save(String backup); } -@Injectable(as: ISaveBackupData) -class SaveBackupData implements ISaveBackupData { +@Injectable(as: ISaveBackupDataUseCase) +class SaveBackupDataUseCase implements ISaveBackupDataUseCase { final IApplicationBackupRepository _applicationBackupRepository; - SaveBackupData(this._applicationBackupRepository); + SaveBackupDataUseCase(this._applicationBackupRepository); @override Future save(String backup) async => diff --git a/test/src/data/repository/application_backup_repository_test.mocks.dart b/test/src/data/repository/application_backup_repository_test.mocks.dart new file mode 100644 index 0000000..219a3a2 --- /dev/null +++ b/test/src/data/repository/application_backup_repository_test.mocks.dart @@ -0,0 +1,248 @@ +// Mocks generated by Mockito 5.4.4 from annotations +// in ambush_app/test/src/data/repository/application_backup_repository_test.dart. +// Do not manually edit this file. + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i4; + +import 'package:ambush_app/src/data/datasource/local_datasource.dart' as _i3; +import 'package:ambush_app/src/data/models/hive_bank_info.dart' as _i7; +import 'package:ambush_app/src/data/models/hive_client_info.dart' as _i2; +import 'package:ambush_app/src/data/models/hive_company_info.dart' as _i6; +import 'package:ambush_app/src/data/models/hive_service_info.dart' as _i8; +import 'package:ambush_app/src/domain/models/invoice.dart' as _i5; +import 'package:mockito/mockito.dart' as _i1; + +// ignore_for_file: type=lint +// ignore_for_file: avoid_redundant_argument_values +// ignore_for_file: avoid_setters_without_getters +// ignore_for_file: comment_references +// ignore_for_file: deprecated_member_use +// ignore_for_file: deprecated_member_use_from_same_package +// ignore_for_file: implementation_imports +// ignore_for_file: invalid_use_of_visible_for_testing_member +// ignore_for_file: prefer_const_constructors +// ignore_for_file: unnecessary_parenthesis +// ignore_for_file: camel_case_types +// ignore_for_file: subtype_of_sealed_class + +class _FakeHiveClientInfo_0 extends _i1.SmartFake + implements _i2.HiveClientInfo { + _FakeHiveClientInfo_0( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} + +/// A class which mocks [ILocalDataSource]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockILocalDataSource extends _i1.Mock implements _i3.ILocalDataSource { + @override + _i4.Future initLocalDataSource() => (super.noSuchMethod( + Invocation.method( + #initLocalDataSource, + [], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + + @override + int getDbVersion() => (super.noSuchMethod( + Invocation.method( + #getDbVersion, + [], + ), + returnValue: 0, + returnValueForMissingStub: 0, + ) as int); + + @override + _i4.Future setDbVersion(int? version) => (super.noSuchMethod( + Invocation.method( + #setDbVersion, + [version], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + + @override + _i2.HiveClientInfo getClientInfo() => (super.noSuchMethod( + Invocation.method( + #getClientInfo, + [], + ), + returnValue: _FakeHiveClientInfo_0( + this, + Invocation.method( + #getClientInfo, + [], + ), + ), + returnValueForMissingStub: _FakeHiveClientInfo_0( + this, + Invocation.method( + #getClientInfo, + [], + ), + ), + ) as _i2.HiveClientInfo); + + @override + List<_i5.Invoice> getInvoiceList() => (super.noSuchMethod( + Invocation.method( + #getInvoiceList, + [], + ), + returnValue: <_i5.Invoice>[], + returnValueForMissingStub: <_i5.Invoice>[], + ) as List<_i5.Invoice>); + + @override + bool getOnboardingStatus() => (super.noSuchMethod( + Invocation.method( + #getOnboardingStatus, + [], + ), + returnValue: false, + returnValueForMissingStub: false, + ) as bool); + + @override + bool getInfoAlertStatus() => (super.noSuchMethod( + Invocation.method( + #getInfoAlertStatus, + [], + ), + returnValue: false, + returnValueForMissingStub: false, + ) as bool); + + @override + _i4.Future deleteInvoice(_i5.Invoice? invoice) => (super.noSuchMethod( + Invocation.method( + #deleteInvoice, + [invoice], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + + @override + _i4.Future saveClientInfo(_i2.HiveClientInfo? value) => + (super.noSuchMethod( + Invocation.method( + #saveClientInfo, + [value], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + + @override + _i4.Future saveCompanyInfo(_i6.HiveCompanyInfo? value) => + (super.noSuchMethod( + Invocation.method( + #saveCompanyInfo, + [value], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + + @override + _i4.Future saveBankInfo(_i7.HiveBankInfo? value) => (super.noSuchMethod( + Invocation.method( + #saveBankInfo, + [value], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + + @override + _i4.Future saveServiceInfo(_i8.HiveServiceInfo? value) => + (super.noSuchMethod( + Invocation.method( + #saveServiceInfo, + [value], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + + @override + _i4.Future saveInvoice(_i5.Invoice? invoice) => (super.noSuchMethod( + Invocation.method( + #saveInvoice, + [invoice], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + + @override + _i4.Future saveOnboardingStatus(bool? status) => (super.noSuchMethod( + Invocation.method( + #saveOnboardingStatus, + [status], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + + @override + _i4.Future saveInfoAlertStatus(bool? status) => (super.noSuchMethod( + Invocation.method( + #saveInfoAlertStatus, + [status], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + + @override + _i4.Future get(String? key) => (super.noSuchMethod( + Invocation.method( + #get, + [key], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + + @override + _i4.Future clearDB() => (super.noSuchMethod( + Invocation.method( + #clearDB, + [], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); + + @override + _i4.Stream> observeInvoiceList() => (super.noSuchMethod( + Invocation.method( + #observeInvoiceList, + [], + ), + returnValue: _i4.Stream>.empty(), + returnValueForMissingStub: _i4.Stream>.empty(), + ) as _i4.Stream>); + + @override + _i4.Stream<_i6.HiveCompanyInfo?> observeCompanyInfo() => (super.noSuchMethod( + Invocation.method( + #observeCompanyInfo, + [], + ), + returnValue: _i4.Stream<_i6.HiveCompanyInfo?>.empty(), + returnValueForMissingStub: _i4.Stream<_i6.HiveCompanyInfo?>.empty(), + ) as _i4.Stream<_i6.HiveCompanyInfo?>); +} diff --git a/test/src/domain/usecases/get_backup_data_test.dart b/test/src/domain/usecases/get_backup_data_test.dart index 36511f9..7d5d9a7 100644 --- a/test/src/domain/usecases/get_backup_data_test.dart +++ b/test/src/domain/usecases/get_backup_data_test.dart @@ -9,11 +9,11 @@ import 'get_backup_data_test.mocks.dart'; @GenerateNiceMocks([MockSpec()]) void main() { late IApplicationBackupRepository mockApplicationBackupRepository; - late GetBackupData sut; + late GetBackupDataUseCase sut; setUp() { mockApplicationBackupRepository = MockIApplicationBackupRepository(); - sut = GetBackupData(mockApplicationBackupRepository); + sut = GetBackupDataUseCase(mockApplicationBackupRepository); } group('GetBackupData', () { diff --git a/test/src/domain/usecases/get_backup_data_test.mocks.dart b/test/src/domain/usecases/get_backup_data_test.mocks.dart new file mode 100644 index 0000000..2920416 --- /dev/null +++ b/test/src/domain/usecases/get_backup_data_test.mocks.dart @@ -0,0 +1,62 @@ +// Mocks generated by Mockito 5.4.4 from annotations +// in ambush_app/test/src/domain/usecases/get_backup_data_test.dart. +// Do not manually edit this file. + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i4; + +import 'package:ambush_app/src/data/repositories/application_backup_repository.dart' + as _i2; +import 'package:mockito/mockito.dart' as _i1; +import 'package:mockito/src/dummies.dart' as _i3; + +// ignore_for_file: type=lint +// ignore_for_file: avoid_redundant_argument_values +// ignore_for_file: avoid_setters_without_getters +// ignore_for_file: comment_references +// ignore_for_file: deprecated_member_use +// ignore_for_file: deprecated_member_use_from_same_package +// ignore_for_file: implementation_imports +// ignore_for_file: invalid_use_of_visible_for_testing_member +// ignore_for_file: prefer_const_constructors +// ignore_for_file: unnecessary_parenthesis +// ignore_for_file: camel_case_types +// ignore_for_file: subtype_of_sealed_class + +/// A class which mocks [IApplicationBackupRepository]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockIApplicationBackupRepository extends _i1.Mock + implements _i2.IApplicationBackupRepository { + @override + String get() => (super.noSuchMethod( + Invocation.method( + #get, + [], + ), + returnValue: _i3.dummyValue( + this, + Invocation.method( + #get, + [], + ), + ), + returnValueForMissingStub: _i3.dummyValue( + this, + Invocation.method( + #get, + [], + ), + ), + ) as String); + + @override + _i4.Future save(String? backup) => (super.noSuchMethod( + Invocation.method( + #save, + [backup], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); +} diff --git a/test/src/domain/usecases/save_backup_data_test.dart b/test/src/domain/usecases/save_backup_data_test.dart index cc0d99b..0e344f5 100644 --- a/test/src/domain/usecases/save_backup_data_test.dart +++ b/test/src/domain/usecases/save_backup_data_test.dart @@ -9,11 +9,11 @@ import 'get_backup_data_test.mocks.dart'; @GenerateNiceMocks([MockSpec()]) void main() { late IApplicationBackupRepository mockApplicationDataRepository; - late SaveBackupData sut; + late SaveBackupDataUseCase sut; setUp() { mockApplicationDataRepository = MockIApplicationBackupRepository(); - sut = SaveBackupData(mockApplicationDataRepository); + sut = SaveBackupDataUseCase(mockApplicationDataRepository); } group('SaveBackupData', () { diff --git a/test/src/domain/usecases/save_backup_data_test.mocks.dart b/test/src/domain/usecases/save_backup_data_test.mocks.dart new file mode 100644 index 0000000..8ac326c --- /dev/null +++ b/test/src/domain/usecases/save_backup_data_test.mocks.dart @@ -0,0 +1,62 @@ +// Mocks generated by Mockito 5.4.4 from annotations +// in ambush_app/test/src/domain/usecases/save_backup_data_test.dart. +// Do not manually edit this file. + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i4; + +import 'package:ambush_app/src/data/repositories/application_backup_repository.dart' + as _i2; +import 'package:mockito/mockito.dart' as _i1; +import 'package:mockito/src/dummies.dart' as _i3; + +// ignore_for_file: type=lint +// ignore_for_file: avoid_redundant_argument_values +// ignore_for_file: avoid_setters_without_getters +// ignore_for_file: comment_references +// ignore_for_file: deprecated_member_use +// ignore_for_file: deprecated_member_use_from_same_package +// ignore_for_file: implementation_imports +// ignore_for_file: invalid_use_of_visible_for_testing_member +// ignore_for_file: prefer_const_constructors +// ignore_for_file: unnecessary_parenthesis +// ignore_for_file: camel_case_types +// ignore_for_file: subtype_of_sealed_class + +/// A class which mocks [IApplicationBackupRepository]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockIApplicationBackupRepository extends _i1.Mock + implements _i2.IApplicationBackupRepository { + @override + String get() => (super.noSuchMethod( + Invocation.method( + #get, + [], + ), + returnValue: _i3.dummyValue( + this, + Invocation.method( + #get, + [], + ), + ), + returnValueForMissingStub: _i3.dummyValue( + this, + Invocation.method( + #get, + [], + ), + ), + ) as String); + + @override + _i4.Future save(String? backup) => (super.noSuchMethod( + Invocation.method( + #save, + [backup], + ), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) as _i4.Future); +}