diff --git a/at_commons/test/at_exception_stack_test.dart b/at_commons/test/at_exception_stack_test.dart index ccb35072..a150a7dc 100644 --- a/at_commons/test/at_exception_stack_test.dart +++ b/at_commons/test/at_exception_stack_test.dart @@ -14,11 +14,6 @@ void main() { startsWith('Failed to syncData caused by')); }); - test('chained exception list size is zero', () { - final exceptionStack = AtExceptionStack(); - expect(exceptionStack.getTraceMessage(), isEmpty); - }); - test('check intent message', () { final atChainedException = AtChainedException( Intent.syncData, ExceptionScenario.invalidKeyFormed, 'sync issue'); @@ -28,5 +23,64 @@ void main() { expect(exceptionStack.getIntentMessage(Intent.syncData), equals('Failed to syncData')); }); + + test('chained exception list size is zero', () { + final exceptionStack = AtExceptionStack(); + expect(exceptionStack.getTraceMessage(), isEmpty); + }); + + test('no namespace provided - check trace message', () { + final atChainedException = AtChainedException(Intent.validateKey, + ExceptionScenario.noNamespaceProvided, 'name space is not provided'); + final exceptionStack = AtExceptionStack(); + exceptionStack.add(atChainedException); + expect(exceptionStack.getTraceMessage(), isNotEmpty); + expect(exceptionStack.getTraceMessage(), + startsWith('Failed to validateKey caused by')); + }); + + test('atsign does not exist - check trace message', () { + final atChainedException = AtChainedException(Intent.shareData, + ExceptionScenario.atSignDoesNotExist, 'atsign does not exist'); + final exceptionStack = AtExceptionStack(); + exceptionStack.add(atChainedException); + expect(exceptionStack.getTraceMessage(), isNotEmpty); + expect(exceptionStack.getTraceMessage(), + startsWith('Failed to shareData caused by')); + }); + + test('Decryption failed - check trace message', () { + final atChainedException = AtChainedException(Intent.decryptData, + ExceptionScenario.decryptionFailed, 'Decryption failed'); + final exceptionStack = AtExceptionStack(); + exceptionStack.add(atChainedException); + expect(exceptionStack.getTraceMessage(), isNotEmpty); + expect(exceptionStack.getTraceMessage(), + startsWith('Failed to decryptData caused by')); + }); + + test('Encryption private key not found - check trace message', () { + final atChainedException = AtChainedException( + Intent.fetchEncryptionPrivateKey, + ExceptionScenario.fetchEncryptionKeys, + 'Encryption keys not found'); + final exceptionStack = AtExceptionStack(); + exceptionStack.add(atChainedException); + expect(exceptionStack.getTraceMessage(), isNotEmpty); + expect(exceptionStack.getTraceMessage(), + startsWith('Failed to fetchEncryptionPrivateKey caused by')); + }); + + test('Notification failed - check trace message', () { + final atChainedException = AtChainedException( + Intent.notifyData, + ExceptionScenario.secondaryServerNotReachable, + 'Secondary server not reachable'); + final exceptionStack = AtExceptionStack(); + exceptionStack.add(atChainedException); + expect(exceptionStack.getTraceMessage(), isNotEmpty); + expect(exceptionStack.getTraceMessage(), + startsWith('Failed to notifyData caused by')); + }); }); }