Skip to content

Commit

Permalink
addressed comments
Browse files Browse the repository at this point in the history
  • Loading branch information
pnalvarez committed Nov 21, 2024
1 parent 6306366 commit 3003d5b
Show file tree
Hide file tree
Showing 7 changed files with 384 additions and 12 deletions.
8 changes: 4 additions & 4 deletions lib/src/domain/usecases/get_backup_data.dart
Original file line number Diff line number Diff line change
@@ -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<String> 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<String> get() async => _applicationBackupRepository.get();
Expand Down
8 changes: 4 additions & 4 deletions lib/src/domain/usecases/save_backup_data.dart
Original file line number Diff line number Diff line change
@@ -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<void> 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<void> save(String backup) async =>
Expand Down
248 changes: 248 additions & 0 deletions test/src/data/repository/application_backup_repository_test.mocks.dart
Original file line number Diff line number Diff line change
@@ -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<dynamic> initLocalDataSource() => (super.noSuchMethod(
Invocation.method(
#initLocalDataSource,
[],
),
returnValue: _i4.Future<dynamic>.value(),
returnValueForMissingStub: _i4.Future<dynamic>.value(),
) as _i4.Future<dynamic>);

@override
int getDbVersion() => (super.noSuchMethod(
Invocation.method(
#getDbVersion,
[],
),
returnValue: 0,
returnValueForMissingStub: 0,
) as int);

@override
_i4.Future<dynamic> setDbVersion(int? version) => (super.noSuchMethod(
Invocation.method(
#setDbVersion,
[version],
),
returnValue: _i4.Future<dynamic>.value(),
returnValueForMissingStub: _i4.Future<dynamic>.value(),
) as _i4.Future<dynamic>);

@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<void> deleteInvoice(_i5.Invoice? invoice) => (super.noSuchMethod(
Invocation.method(
#deleteInvoice,
[invoice],
),
returnValue: _i4.Future<void>.value(),
returnValueForMissingStub: _i4.Future<void>.value(),
) as _i4.Future<void>);

@override
_i4.Future<void> saveClientInfo(_i2.HiveClientInfo? value) =>
(super.noSuchMethod(
Invocation.method(
#saveClientInfo,
[value],
),
returnValue: _i4.Future<void>.value(),
returnValueForMissingStub: _i4.Future<void>.value(),
) as _i4.Future<void>);

@override
_i4.Future<void> saveCompanyInfo(_i6.HiveCompanyInfo? value) =>
(super.noSuchMethod(
Invocation.method(
#saveCompanyInfo,
[value],
),
returnValue: _i4.Future<void>.value(),
returnValueForMissingStub: _i4.Future<void>.value(),
) as _i4.Future<void>);

@override
_i4.Future<void> saveBankInfo(_i7.HiveBankInfo? value) => (super.noSuchMethod(
Invocation.method(
#saveBankInfo,
[value],
),
returnValue: _i4.Future<void>.value(),
returnValueForMissingStub: _i4.Future<void>.value(),
) as _i4.Future<void>);

@override
_i4.Future<void> saveServiceInfo(_i8.HiveServiceInfo? value) =>
(super.noSuchMethod(
Invocation.method(
#saveServiceInfo,
[value],
),
returnValue: _i4.Future<void>.value(),
returnValueForMissingStub: _i4.Future<void>.value(),
) as _i4.Future<void>);

@override
_i4.Future<void> saveInvoice(_i5.Invoice? invoice) => (super.noSuchMethod(
Invocation.method(
#saveInvoice,
[invoice],
),
returnValue: _i4.Future<void>.value(),
returnValueForMissingStub: _i4.Future<void>.value(),
) as _i4.Future<void>);

@override
_i4.Future<void> saveOnboardingStatus(bool? status) => (super.noSuchMethod(
Invocation.method(
#saveOnboardingStatus,
[status],
),
returnValue: _i4.Future<void>.value(),
returnValueForMissingStub: _i4.Future<void>.value(),
) as _i4.Future<void>);

@override
_i4.Future<void> saveInfoAlertStatus(bool? status) => (super.noSuchMethod(
Invocation.method(
#saveInfoAlertStatus,
[status],
),
returnValue: _i4.Future<void>.value(),
returnValueForMissingStub: _i4.Future<void>.value(),
) as _i4.Future<void>);

@override
_i4.Future<dynamic> get(String? key) => (super.noSuchMethod(
Invocation.method(
#get,
[key],
),
returnValue: _i4.Future<dynamic>.value(),
returnValueForMissingStub: _i4.Future<dynamic>.value(),
) as _i4.Future<dynamic>);

@override
_i4.Future<void> clearDB() => (super.noSuchMethod(
Invocation.method(
#clearDB,
[],
),
returnValue: _i4.Future<void>.value(),
returnValueForMissingStub: _i4.Future<void>.value(),
) as _i4.Future<void>);

@override
_i4.Stream<List<_i5.Invoice>> observeInvoiceList() => (super.noSuchMethod(
Invocation.method(
#observeInvoiceList,
[],
),
returnValue: _i4.Stream<List<_i5.Invoice>>.empty(),
returnValueForMissingStub: _i4.Stream<List<_i5.Invoice>>.empty(),
) as _i4.Stream<List<_i5.Invoice>>);

@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?>);
}
4 changes: 2 additions & 2 deletions test/src/domain/usecases/get_backup_data_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import 'get_backup_data_test.mocks.dart';
@GenerateNiceMocks([MockSpec<IApplicationBackupRepository>()])
void main() {
late IApplicationBackupRepository mockApplicationBackupRepository;
late GetBackupData sut;
late GetBackupDataUseCase sut;

setUp() {
mockApplicationBackupRepository = MockIApplicationBackupRepository();
sut = GetBackupData(mockApplicationBackupRepository);
sut = GetBackupDataUseCase(mockApplicationBackupRepository);
}

group('GetBackupData', () {
Expand Down
62 changes: 62 additions & 0 deletions test/src/domain/usecases/get_backup_data_test.mocks.dart
Original file line number Diff line number Diff line change
@@ -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<String>(
this,
Invocation.method(
#get,
[],
),
),
returnValueForMissingStub: _i3.dummyValue<String>(
this,
Invocation.method(
#get,
[],
),
),
) as String);

@override
_i4.Future<void> save(String? backup) => (super.noSuchMethod(
Invocation.method(
#save,
[backup],
),
returnValue: _i4.Future<void>.value(),
returnValueForMissingStub: _i4.Future<void>.value(),
) as _i4.Future<void>);
}
4 changes: 2 additions & 2 deletions test/src/domain/usecases/save_backup_data_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import 'get_backup_data_test.mocks.dart';
@GenerateNiceMocks([MockSpec<IApplicationBackupRepository>()])
void main() {
late IApplicationBackupRepository mockApplicationDataRepository;
late SaveBackupData sut;
late SaveBackupDataUseCase sut;

setUp() {
mockApplicationDataRepository = MockIApplicationBackupRepository();
sut = SaveBackupData(mockApplicationDataRepository);
sut = SaveBackupDataUseCase(mockApplicationDataRepository);
}

group('SaveBackupData', () {
Expand Down
Loading

0 comments on commit 3003d5b

Please sign in to comment.