diff --git a/packages/logging_cloudwatch/aws_logging_cloudwatch/lib/src/plugin_config.dart b/packages/logging_cloudwatch/aws_logging_cloudwatch/lib/src/plugin_config.dart index e1b6bac485..3367eb505c 100644 --- a/packages/logging_cloudwatch/aws_logging_cloudwatch/lib/src/plugin_config.dart +++ b/packages/logging_cloudwatch/aws_logging_cloudwatch/lib/src/plugin_config.dart @@ -50,7 +50,7 @@ class CloudWatchLoggerPluginConfiguration with AWSDebuggable { /// The logging constraint for sending logs to CloudWatch. /// {@endtemplate} @zAmplifySerializable -class LoggingConstraint with AWSDebuggable { +class LoggingConstraint with AWSDebuggable, AWSSerializable { /// {@macro aws_logging_cloudwatch.logging_constraint} const LoggingConstraint({ this.defaultLogLevel = LogLevel.error, @@ -63,6 +63,7 @@ class LoggingConstraint with AWSDebuggable { _$LoggingConstraintFromJson(json); /// Converts an [LoggingConstraint] instance to a [Map]. + @override Map toJson() => _$LoggingConstraintToJson(this); /// The default [LogLevel] for sending logs to CloudWatch. @@ -80,7 +81,7 @@ class LoggingConstraint with AWSDebuggable { /// The logging constraint for user specific log level. @zAmplifySerializable -class UserLogLevel { +class UserLogLevel with AWSDebuggable, AWSSerializable { /// The logging constraint for user specific log level. const UserLogLevel({ this.defaultLogLevel, @@ -92,6 +93,7 @@ class UserLogLevel { _$UserLogLevelFromJson(json); /// Converts a [UserLogLevel] instance to a [Map]. + @override Map toJson() => _$UserLogLevelToJson(this); /// The default [LogLevel] for sending logs to CloudWatch. @@ -99,4 +101,7 @@ class UserLogLevel { /// The [LogLevel] for different categories. final Map? categoryLogLevel; + + @override + String get runtimeTypeName => 'UserLogLevel'; } diff --git a/packages/logging_cloudwatch/aws_logging_cloudwatch/test/remote_constraint_provider_test.dart b/packages/logging_cloudwatch/aws_logging_cloudwatch/test/remote_constraint_provider_test.dart index 20cafc87ba..78b3064a28 100644 --- a/packages/logging_cloudwatch/aws_logging_cloudwatch/test/remote_constraint_provider_test.dart +++ b/packages/logging_cloudwatch/aws_logging_cloudwatch/test/remote_constraint_provider_test.dart @@ -127,7 +127,7 @@ void main() { await provider.ready; - // Verify that _loggingConstraint uses local storage + // Verify that _loggingConstraint uses local storage expect( provider.loggingConstraint!.toJson(), equals(json.decode(sampleJson)), @@ -190,11 +190,12 @@ void main() { awsHttpClient: mockAWSHttpClient, ); + // Wait for the provider to refresh the constraints and make the second call to the endpoint await Future.delayed(const Duration(seconds: 2)); await provider.ready; - // Verify that _loggingConstraint got updated + // Verify that _loggingConstraint got updated expect( provider.loggingConstraint!.toJson(), equals(json.decode(updatedJson)), @@ -225,7 +226,7 @@ void main() { await provider.ready; - // Verify that _loggingConstraint is set + // Verify that _loggingConstraint is set expect(provider.loggingConstraint, equals(null)); }); });