From 2077a05788a740eea7d804c293c7d5313169b5ed Mon Sep 17 00:00:00 2001 From: Matias Pequeno Date: Fri, 25 Oct 2024 12:19:29 -0300 Subject: [PATCH] Bumped version to 3.3.3 (#359) --- CHANGELOG.md | 2 +- Examples/Integration/CocoapodsApp/Podfile | 2 +- .../Integration/CocoapodsFramework/Podfile | 2 +- Rollbar.podspec | 2 +- RollbarAUL.podspec | 2 +- RollbarCocoaLumberjack.podspec | 2 +- RollbarCommon.podspec | 2 +- RollbarCrash.podspec | 2 +- RollbarDeploys.podspec | 2 +- RollbarNotifier.podspec | 2 +- .../Recording/RollbarCrashReportVersion.h | 2 +- .../RollbarNotifier/DTOs/RollbarConfig.m | 398 ++-- .../RollbarNotifierTests-ObjC/DTOsTests.m | 1652 ++++++++--------- .../RollbarNotifierDTOsTests.swift | 4 +- RollbarReport.podspec | 2 +- 15 files changed, 1011 insertions(+), 1067 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 35b0adbc..84364b45 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Release Notes -### Unreleased +### 3.3.3 - Be more explicit about overloaded usage of `URL.init` that cannot be resolved in certain configurations when using the Rollbar React Native SDK. - Updated Cocoapods examples to use the latest SDK version, 3.3.2. diff --git a/Examples/Integration/CocoapodsApp/Podfile b/Examples/Integration/CocoapodsApp/Podfile index cefbe08b..c9c91aa9 100644 --- a/Examples/Integration/CocoapodsApp/Podfile +++ b/Examples/Integration/CocoapodsApp/Podfile @@ -2,5 +2,5 @@ platform :ios, '14.0' use_frameworks! target 'CocoapodsApp' do - pod 'RollbarNotifier', '~> 3.3.2' + pod 'RollbarNotifier', '~> 3.3.3' end diff --git a/Examples/Integration/CocoapodsFramework/Podfile b/Examples/Integration/CocoapodsFramework/Podfile index 8ba62e71..4ab1d4ca 100644 --- a/Examples/Integration/CocoapodsFramework/Podfile +++ b/Examples/Integration/CocoapodsFramework/Podfile @@ -2,5 +2,5 @@ platform :ios, '14.0' use_frameworks! target 'CocoapodsFramework' do - pod 'RollbarNotifier', '~> 3.3.2' + pod 'RollbarNotifier', '~> 3.3.3' end diff --git a/Rollbar.podspec b/Rollbar.podspec index f565c156..a279d996 100644 --- a/Rollbar.podspec +++ b/Rollbar.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "Rollbar" - s.version = "3.3.2" + s.version = "3.3.3" s.summary = "Application or client side SDK for interacting with the Rollbar API Server." s.description = <<-DESC Find, fix, and resolve errors with Rollbar. diff --git a/RollbarAUL.podspec b/RollbarAUL.podspec index 89330c8a..75f9db99 100644 --- a/RollbarAUL.podspec +++ b/RollbarAUL.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "RollbarAUL" - s.version = "3.3.2" + s.version = "3.3.3" s.summary = "Application or client side SDK for interacting with the Rollbar API Server." s.description = <<-DESC Find, fix, and resolve errors with Rollbar. diff --git a/RollbarCocoaLumberjack.podspec b/RollbarCocoaLumberjack.podspec index b9d13d7f..e099c513 100644 --- a/RollbarCocoaLumberjack.podspec +++ b/RollbarCocoaLumberjack.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "RollbarCocoaLumberjack" - s.version = "3.3.2" + s.version = "3.3.3" s.summary = "Application or client side SDK for interacting with the Rollbar API Server." s.description = <<-DESC Find, fix, and resolve errors with Rollbar. diff --git a/RollbarCommon.podspec b/RollbarCommon.podspec index be00c331..faf95a06 100644 --- a/RollbarCommon.podspec +++ b/RollbarCommon.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "RollbarCommon" - s.version = "3.3.2" + s.version = "3.3.3" s.summary = "Application or client side SDK for interacting with the Rollbar API Server." s.description = <<-DESC Find, fix, and resolve errors with Rollbar. diff --git a/RollbarCrash.podspec b/RollbarCrash.podspec index 13b1c358..2d63a3f8 100644 --- a/RollbarCrash.podspec +++ b/RollbarCrash.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "RollbarCrash" - s.version = "3.3.2" + s.version = "3.3.3" s.summary = "Application or client side SDK for interacting with the Rollbar API Server." s.description = <<-DESC Find, fix, and resolve errors with Rollbar. diff --git a/RollbarDeploys.podspec b/RollbarDeploys.podspec index 46114efd..4a4e8aa6 100644 --- a/RollbarDeploys.podspec +++ b/RollbarDeploys.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "RollbarDeploys" - s.version = "3.3.2" + s.version = "3.3.3" s.summary = "Application or client side SDK for interacting with the Rollbar API Server." s.description = <<-DESC Find, fix, and resolve errors with Rollbar. diff --git a/RollbarNotifier.podspec b/RollbarNotifier.podspec index bc3c2645..95d11ec2 100644 --- a/RollbarNotifier.podspec +++ b/RollbarNotifier.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "RollbarNotifier" - s.version = "3.3.2" + s.version = "3.3.3" s.summary = "Application or client side SDK for interacting with the Rollbar API Server." s.description = <<-DESC Find, fix, and resolve errors with Rollbar. diff --git a/RollbarNotifier/Sources/RollbarCrash/Recording/RollbarCrashReportVersion.h b/RollbarNotifier/Sources/RollbarCrash/Recording/RollbarCrashReportVersion.h index 9743d300..684b4ae0 100644 --- a/RollbarNotifier/Sources/RollbarCrash/Recording/RollbarCrashReportVersion.h +++ b/RollbarNotifier/Sources/RollbarCrash/Recording/RollbarCrashReportVersion.h @@ -27,6 +27,6 @@ #ifndef HDR_RollbarCrashReportVersion_h #define HDR_RollbarCrashReportVersion_h -#define RollbarCrashCRASH_REPORT_VERSION "3.3.2" +#define RollbarCrashCRASH_REPORT_VERSION "3.3.3" #endif /* HDR_RollbarCrashReportVersion_h */ diff --git a/RollbarNotifier/Sources/RollbarNotifier/DTOs/RollbarConfig.m b/RollbarNotifier/Sources/RollbarNotifier/DTOs/RollbarConfig.m index c4f453d0..e77780b3 100644 --- a/RollbarNotifier/Sources/RollbarNotifier/DTOs/RollbarConfig.m +++ b/RollbarNotifier/Sources/RollbarNotifier/DTOs/RollbarConfig.m @@ -2,51 +2,50 @@ #import "RollbarCachesDirectory.h" #import "RollbarDestination.h" #import "RollbarDeveloperOptions.h" +#import "RollbarLoggingOptions.h" +#import "RollbarModule.h" +#import "RollbarPerson.h" #import "RollbarProxy.h" #import "RollbarScrubbingOptions.h" #import "RollbarServerConfig.h" -#import "RollbarPerson.h" -#import "RollbarModule.h" -#import "RollbarTelemetryOptions.h" #import "RollbarTelemetryOptions.h" -#import "RollbarLoggingOptions.h" #import #pragma mark - constants -static NSString * const NOTIFIER_VERSION = @"3.3.2"; +static NSString *const NOTIFIER_VERSION = @"3.3.3"; -static NSString * const NOTIFIER_NAME = @"rollbar-apple"; +static NSString *const NOTIFIER_NAME = @"rollbar-apple"; #define NOTIFIER_NAME_PREFIX = @"rollbar-"; #if TARGET_OS_IPHONE | TARGET_OS_IOS -static NSString * const OPERATING_SYSTEM = @"ios"; +static NSString *const OPERATING_SYSTEM = @"ios"; #elif TARGET_OS_OSX -static NSString * const OPERATING_SYSTEM = @"macos"; +static NSString *const OPERATING_SYSTEM = @"macos"; #elif TARGET_OS_TV -static NSString * const OPERATING_SYSTEM = @"tvos"; +static NSString *const OPERATING_SYSTEM = @"tvos"; #elif TARGET_OS_WATCH -static NSString * const OPERATING_SYSTEM = @"watchos"; +static NSString *const OPERATING_SYSTEM = @"watchos"; #else -static NSString * const OPERATING_SYSTEM = @"*os"; +static NSString *const OPERATING_SYSTEM = @"*os"; #endif #pragma mark - static data #pragma mark - data fields -static NSString * const DFK_DESTINATION = @"destination"; -static NSString * const DFK_DEVELOPER_OPTIONS = @"developerOptions"; -static NSString * const DFK_LOGGING_OPTIONS = @"loggingOptions"; -static NSString * const DFK_DATA_SCRUBBER = @"dataScrubber"; -static NSString * const DFK_HTTP_PROXY = @"httpProxy"; -static NSString * const DFK_HTTPS_PROXY = @"httpsProxy"; -static NSString * const DFK_SERVER = @"server"; -static NSString * const DFK_PERSON = @"person"; -static NSString * const DFK_NOTIFIER = @"notifier"; -static NSString * const DFK_TELEMETRY = @"telemetry"; -static NSString * const DFK_CUSTOM = @"custom"; +static NSString *const DFK_DESTINATION = @"destination"; +static NSString *const DFK_DEVELOPER_OPTIONS = @"developerOptions"; +static NSString *const DFK_LOGGING_OPTIONS = @"loggingOptions"; +static NSString *const DFK_DATA_SCRUBBER = @"dataScrubber"; +static NSString *const DFK_HTTP_PROXY = @"httpProxy"; +static NSString *const DFK_HTTPS_PROXY = @"httpsProxy"; +static NSString *const DFK_SERVER = @"server"; +static NSString *const DFK_PERSON = @"person"; +static NSString *const DFK_NOTIFIER = @"notifier"; +static NSString *const DFK_TELEMETRY = @"telemetry"; +static NSString *const DFK_CUSTOM = @"custom"; #pragma mark - class implementation @@ -56,184 +55,189 @@ @implementation RollbarConfig + (nonnull RollbarConfig *)configWithAccessToken:(nonnull NSString *)token { - NSAssert(token, @"Access token must be initialized!"); - NSAssert(token.length > 0, @"Access token must not be empty string!"); + NSAssert(token, @"Access token must be initialized!"); + NSAssert(token.length > 0, @"Access token must not be empty string!"); - RollbarConfig *config = [[RollbarConfig alloc] initWithAccessToken:token - environment:nil]; + RollbarConfig *config = [[RollbarConfig alloc] initWithAccessToken:token + environment:nil]; - return config; + return config; } + (nonnull RollbarConfig *)configWithAccessToken:(nonnull NSString *)token environment:(nonnull NSString *)env { - NSAssert(env, @"Environment must be initialized!"); - NSAssert(env.length > 0, @"Environment must not be empty string!"); + NSAssert(env, @"Environment must be initialized!"); + NSAssert(env.length > 0, @"Environment must not be empty string!"); - RollbarConfig *config = [[RollbarConfig alloc] initWithAccessToken:token - environment:env]; + RollbarConfig *config = [[RollbarConfig alloc] initWithAccessToken:token + environment:env]; - return config; + return config; } -+ (nonnull RollbarMutableConfig *)mutableConfigWithAccessToken:(nonnull NSString *)token { ++ (nonnull RollbarMutableConfig *)mutableConfigWithAccessToken: + (nonnull NSString *)token { - NSAssert(token, @"Access token must be initialized!"); - NSAssert(token.length > 0, @"Access token must not be empty string!"); + NSAssert(token, @"Access token must be initialized!"); + NSAssert(token.length > 0, @"Access token must not be empty string!"); - RollbarMutableConfig *config = [[RollbarMutableConfig alloc] initWithAccessToken:token - environment:nil]; + RollbarMutableConfig *config = + [[RollbarMutableConfig alloc] initWithAccessToken:token environment:nil]; - return config; + return config; } -+ (nonnull RollbarMutableConfig *)mutableConfigWithAccessToken:(nonnull NSString *)token - environment:(nonnull NSString *)env { ++ (nonnull RollbarMutableConfig *) + mutableConfigWithAccessToken:(nonnull NSString *)token + environment:(nonnull NSString *)env { - NSAssert(env, @"Environment must be initialized!"); - NSAssert(env.length > 0, @"Environment must not be empty string!"); + NSAssert(env, @"Environment must be initialized!"); + NSAssert(env.length > 0, @"Environment must not be empty string!"); - RollbarMutableConfig *config = [[RollbarMutableConfig alloc] initWithAccessToken:token - environment:env]; + RollbarMutableConfig *config = + [[RollbarMutableConfig alloc] initWithAccessToken:token environment:env]; - return config; + return config; } #pragma mark - initializers +- (instancetype)initWithAccessToken:(nullable NSString *)token + environment:(nullable NSString *)env { -- (instancetype)initWithAccessToken:(nullable NSString *)token environment:(nullable NSString *)env { - - RollbarDestination *destination = nil; - if (token && env) { - destination = [[RollbarDestination alloc] initWithAccessToken:token environment:env]; - } - else if (token) { - destination = [[RollbarDestination alloc] initWithAccessToken:token]; - } - else { - destination = [[RollbarMutableDestination alloc] init]; - } - - if (!destination) { - return nil; - } - - if (self = [super initWithDictionary:@{ - DFK_DESTINATION:destination.jsonFriendlyData, - DFK_DEVELOPER_OPTIONS:[RollbarDeveloperOptions new].jsonFriendlyData, - DFK_LOGGING_OPTIONS:[RollbarLoggingOptions new].jsonFriendlyData, - DFK_HTTP_PROXY:[RollbarProxy new].jsonFriendlyData, - DFK_HTTPS_PROXY:[RollbarProxy new].jsonFriendlyData, - DFK_DATA_SCRUBBER:[RollbarScrubbingOptions new].jsonFriendlyData, - DFK_TELEMETRY:[RollbarTelemetryOptions new].jsonFriendlyData, - DFK_NOTIFIER:[[RollbarModule alloc] initWithName:NOTIFIER_NAME version:NOTIFIER_VERSION].jsonFriendlyData, - DFK_SERVER:[RollbarServerConfig new].jsonFriendlyData, - DFK_PERSON: [NSMutableDictionary new], - DFK_CUSTOM: [NSMutableDictionary new] - }]) { - - return self; - } + RollbarDestination *destination = nil; + if (token && env) { + destination = [[RollbarDestination alloc] initWithAccessToken:token + environment:env]; + } else if (token) { + destination = [[RollbarDestination alloc] initWithAccessToken:token]; + } else { + destination = [[RollbarMutableDestination alloc] init]; + } + if (!destination) { return nil; + } + + if (self = [super initWithDictionary:@{ + DFK_DESTINATION : destination.jsonFriendlyData, + DFK_DEVELOPER_OPTIONS : [RollbarDeveloperOptions new].jsonFriendlyData, + DFK_LOGGING_OPTIONS : [RollbarLoggingOptions new].jsonFriendlyData, + DFK_HTTP_PROXY : [RollbarProxy new].jsonFriendlyData, + DFK_HTTPS_PROXY : [RollbarProxy new].jsonFriendlyData, + DFK_DATA_SCRUBBER : [RollbarScrubbingOptions new].jsonFriendlyData, + DFK_TELEMETRY : [RollbarTelemetryOptions new].jsonFriendlyData, + DFK_NOTIFIER : [[RollbarModule alloc] initWithName:NOTIFIER_NAME + version:NOTIFIER_VERSION] + .jsonFriendlyData, + DFK_SERVER : [RollbarServerConfig new].jsonFriendlyData, + DFK_PERSON : [NSMutableDictionary new], + DFK_CUSTOM : [NSMutableDictionary new] + }]) { + + return self; + } + + return nil; } - (instancetype)init { - self = [super initWithDictionary:@{ - DFK_DESTINATION:[RollbarDestination new].jsonFriendlyData, - DFK_DEVELOPER_OPTIONS:[RollbarDeveloperOptions new].jsonFriendlyData, - DFK_LOGGING_OPTIONS:[RollbarLoggingOptions new].jsonFriendlyData, - DFK_HTTP_PROXY:[RollbarProxy new].jsonFriendlyData, - DFK_HTTPS_PROXY:[RollbarProxy new].jsonFriendlyData, - DFK_DATA_SCRUBBER:[RollbarScrubbingOptions new].jsonFriendlyData, - DFK_TELEMETRY:[RollbarTelemetryOptions new].jsonFriendlyData, - DFK_NOTIFIER:[[RollbarModule alloc] initWithName:NOTIFIER_NAME version:NOTIFIER_VERSION].jsonFriendlyData, - DFK_SERVER:[RollbarServerConfig new].jsonFriendlyData, - DFK_PERSON: [NSMutableDictionary new], - DFK_CUSTOM: [NSMutableDictionary new] - }]; - return self; + self = [super initWithDictionary:@{ + DFK_DESTINATION : [RollbarDestination new].jsonFriendlyData, + DFK_DEVELOPER_OPTIONS : [RollbarDeveloperOptions new].jsonFriendlyData, + DFK_LOGGING_OPTIONS : [RollbarLoggingOptions new].jsonFriendlyData, + DFK_HTTP_PROXY : [RollbarProxy new].jsonFriendlyData, + DFK_HTTPS_PROXY : [RollbarProxy new].jsonFriendlyData, + DFK_DATA_SCRUBBER : [RollbarScrubbingOptions new].jsonFriendlyData, + DFK_TELEMETRY : [RollbarTelemetryOptions new].jsonFriendlyData, + DFK_NOTIFIER : [[RollbarModule alloc] initWithName:NOTIFIER_NAME + version:NOTIFIER_VERSION] + .jsonFriendlyData, + DFK_SERVER : [RollbarServerConfig new].jsonFriendlyData, + DFK_PERSON : [NSMutableDictionary new], + DFK_CUSTOM : [NSMutableDictionary new] + }]; + return self; } #pragma mark - Rollbar destination - (RollbarDestination *)destination { - id data = [self safelyGetDictionaryByKey:DFK_DESTINATION]; - id dto = [[RollbarDestination alloc] initWithDictionary:data]; - return dto; + id data = [self safelyGetDictionaryByKey:DFK_DESTINATION]; + id dto = [[RollbarDestination alloc] initWithDictionary:data]; + return dto; } #pragma mark - Developer options - (RollbarDeveloperOptions *)developerOptions { - id data = [self safelyGetDictionaryByKey:DFK_DEVELOPER_OPTIONS]; - return [[RollbarDeveloperOptions alloc] initWithDictionary:data]; + id data = [self safelyGetDictionaryByKey:DFK_DEVELOPER_OPTIONS]; + return [[RollbarDeveloperOptions alloc] initWithDictionary:data]; } #pragma mark - Logging options - (RollbarLoggingOptions *)loggingOptions { - id data = [self safelyGetDictionaryByKey:DFK_LOGGING_OPTIONS]; - return [[RollbarLoggingOptions alloc] initWithDictionary:data]; + id data = [self safelyGetDictionaryByKey:DFK_LOGGING_OPTIONS]; + return [[RollbarLoggingOptions alloc] initWithDictionary:data]; } #pragma mark - Notifier - (RollbarModule *)notifier { - id data = [self safelyGetDictionaryByKey:DFK_NOTIFIER]; - return [[RollbarModule alloc] initWithDictionary:data]; + id data = [self safelyGetDictionaryByKey:DFK_NOTIFIER]; + return [[RollbarModule alloc] initWithDictionary:data]; } #pragma mark - Data scrubber - (RollbarScrubbingOptions *)dataScrubber { - id data = [self safelyGetDictionaryByKey:DFK_DATA_SCRUBBER]; - return [[RollbarScrubbingOptions alloc] initWithDictionary:data]; + id data = [self safelyGetDictionaryByKey:DFK_DATA_SCRUBBER]; + return [[RollbarScrubbingOptions alloc] initWithDictionary:data]; } #pragma mark - Server - (RollbarServerConfig *)server { - id data = [self safelyGetDictionaryByKey:DFK_SERVER]; - return [[RollbarServerConfig alloc] initWithDictionary:data]; + id data = [self safelyGetDictionaryByKey:DFK_SERVER]; + return [[RollbarServerConfig alloc] initWithDictionary:data]; } #pragma mark - Person - (RollbarPerson *)person { - id data = [self safelyGetDictionaryByKey:DFK_PERSON]; - return [[RollbarPerson alloc] initWithDictionary:data]; + id data = [self safelyGetDictionaryByKey:DFK_PERSON]; + return [[RollbarPerson alloc] initWithDictionary:data]; } #pragma mark - HTTP Proxy Settings - (RollbarProxy *)httpProxy { - id data = [self safelyGetDictionaryByKey:DFK_HTTP_PROXY]; - return [[RollbarProxy alloc] initWithDictionary:data]; + id data = [self safelyGetDictionaryByKey:DFK_HTTP_PROXY]; + return [[RollbarProxy alloc] initWithDictionary:data]; } #pragma mark - HTTPS Proxy Settings - (RollbarProxy *)httpsProxy { - id data = [self safelyGetDictionaryByKey:DFK_HTTPS_PROXY]; - return [[RollbarProxy alloc] initWithDictionary:data]; + id data = [self safelyGetDictionaryByKey:DFK_HTTPS_PROXY]; + return [[RollbarProxy alloc] initWithDictionary:data]; } #pragma mark - Telemetry - (RollbarTelemetryOptions *)telemetry { - id data = [self safelyGetDictionaryByKey:DFK_TELEMETRY]; - return [[RollbarTelemetryOptions alloc] initWithDictionary:data]; + id data = [self safelyGetDictionaryByKey:DFK_TELEMETRY]; + return [[RollbarTelemetryOptions alloc] initWithDictionary:data]; } #pragma mark - Custom data - (NSDictionary *)customData { - NSMutableDictionary *result = [self safelyGetDictionaryByKey:DFK_CUSTOM]; - return result; + NSMutableDictionary *result = [self safelyGetDictionaryByKey:DFK_CUSTOM]; + return result; } #pragma mark - Payload Content Related @@ -244,42 +248,41 @@ - (RollbarTelemetryOptions *)telemetry { #pragma mark - overrides -- (nonnull RollbarMutableConfig *) mutableCopy { +- (nonnull RollbarMutableConfig *)mutableCopy { - return [self mutableCopyWithZone:nil]; + return [self mutableCopyWithZone:nil]; } -//#pragma mark - RollbarPersistent protocol +// #pragma mark - RollbarPersistent protocol // //- (BOOL)loadFromFile:(nonnull NSString *)filePath { -//} +// } // //- (BOOL)saveToFile:(nonnull NSString *)filePath { -//} - +// } #pragma mark - NSCopying protocol --(id) copyWithZone: (NSZone *) zone { +- (id)copyWithZone:(NSZone *)zone { - RollbarConfig *clone = [super copyWithZone:zone]; - if (clone != self) { - clone->_checkIgnoreRollbarData = self->_checkIgnoreRollbarData; - clone->_modifyRollbarData = self->_modifyRollbarData; - } - return clone; + RollbarConfig *clone = [super copyWithZone:zone]; + if (clone != self) { + clone->_checkIgnoreRollbarData = self->_checkIgnoreRollbarData; + clone->_modifyRollbarData = self->_modifyRollbarData; + } + return clone; } #pragma mark - NSMutableCopying protocol --(id) mutableCopyWithZone: (NSZone *) zone { +- (id)mutableCopyWithZone:(NSZone *)zone { - RollbarConfig *clone = [super mutableCopyWithZone:zone]; - if (clone != self) { - clone->_checkIgnoreRollbarData = self->_checkIgnoreRollbarData; - clone->_modifyRollbarData = self->_modifyRollbarData; - } - return clone; + RollbarConfig *clone = [super mutableCopyWithZone:zone]; + if (clone != self) { + clone->_checkIgnoreRollbarData = self->_checkIgnoreRollbarData; + clone->_modifyRollbarData = self->_modifyRollbarData; + } + return clone; } @end @@ -288,12 +291,12 @@ @implementation RollbarMutableConfig #pragma mark - initializers --(instancetype)init { +- (instancetype)init { - if (self = [super init]) { - return self; - } - return nil; + if (self = [super init]) { + return self; + } + return nil; } #pragma mark - Payload Content Related @@ -301,168 +304,171 @@ -(instancetype)init { @dynamic checkIgnoreRollbarData; @dynamic modifyRollbarData; -- (void)setCheckIgnoreRollbarData:(BOOL (^)(RollbarData * _Nonnull))checkIgnoreRollbarData { - self->_checkIgnoreRollbarData = checkIgnoreRollbarData; +- (void)setCheckIgnoreRollbarData: + (BOOL (^)(RollbarData *_Nonnull))checkIgnoreRollbarData { + self->_checkIgnoreRollbarData = checkIgnoreRollbarData; } -- (void)setModifyRollbarData:(RollbarData * _Nonnull (^)(RollbarData * _Nonnull))modifyRollbarData { - self->_modifyRollbarData = modifyRollbarData; +- (void)setModifyRollbarData: + (RollbarData *_Nonnull (^)(RollbarData *_Nonnull))modifyRollbarData { + self->_modifyRollbarData = modifyRollbarData; } #pragma mark - Rollbar destination - (RollbarMutableDestination *)destination { - id data = [self safelyGetDictionaryByKey:DFK_DESTINATION]; - id dto = [[RollbarMutableDestination alloc] initWithDictionary:data]; - return dto; + id data = [self safelyGetDictionaryByKey:DFK_DESTINATION]; + id dto = [[RollbarMutableDestination alloc] initWithDictionary:data]; + return dto; } - (void)setDestination:(RollbarDestination *)destination { - [self setDataTransferObject:[destination mutableCopy] forKey:DFK_DESTINATION]; + [self setDataTransferObject:[destination mutableCopy] forKey:DFK_DESTINATION]; } #pragma mark - Developer options - (RollbarMutableDeveloperOptions *)developerOptions { - id data = [self safelyGetDictionaryByKey:DFK_DEVELOPER_OPTIONS]; - return [[RollbarMutableDeveloperOptions alloc] initWithDictionary:data]; + id data = [self safelyGetDictionaryByKey:DFK_DEVELOPER_OPTIONS]; + return [[RollbarMutableDeveloperOptions alloc] initWithDictionary:data]; } - (void)setDeveloperOptions:(RollbarDeveloperOptions *)developerOptions { - [self setDataTransferObject:[developerOptions mutableCopy] forKey:DFK_DEVELOPER_OPTIONS]; + [self setDataTransferObject:[developerOptions mutableCopy] + forKey:DFK_DEVELOPER_OPTIONS]; } #pragma mark - Logging options - (RollbarMutableLoggingOptions *)loggingOptions { - id data = [self safelyGetDictionaryByKey:DFK_LOGGING_OPTIONS]; - return [[RollbarMutableLoggingOptions alloc] initWithDictionary:data]; + id data = [self safelyGetDictionaryByKey:DFK_LOGGING_OPTIONS]; + return [[RollbarMutableLoggingOptions alloc] initWithDictionary:data]; } - (void)setLoggingOptions:(RollbarLoggingOptions *)loggingOptions { - [self setDataTransferObject:[loggingOptions mutableCopy] forKey:DFK_LOGGING_OPTIONS]; + [self setDataTransferObject:[loggingOptions mutableCopy] + forKey:DFK_LOGGING_OPTIONS]; } #pragma mark - Notifier - (RollbarMutableModule *)notifier { - id data = [self safelyGetDictionaryByKey:DFK_NOTIFIER]; - return [[RollbarMutableModule alloc] initWithDictionary:data]; + id data = [self safelyGetDictionaryByKey:DFK_NOTIFIER]; + return [[RollbarMutableModule alloc] initWithDictionary:data]; } - (void)setNotifier:(RollbarModule *)developerOptions { - [self setDataTransferObject:developerOptions forKey:DFK_NOTIFIER]; + [self setDataTransferObject:developerOptions forKey:DFK_NOTIFIER]; } #pragma mark - Data scrubber - (RollbarMutableScrubbingOptions *)dataScrubber { - id data = [self safelyGetDictionaryByKey:DFK_DATA_SCRUBBER]; - return [[RollbarMutableScrubbingOptions alloc] initWithDictionary:data]; + id data = [self safelyGetDictionaryByKey:DFK_DATA_SCRUBBER]; + return [[RollbarMutableScrubbingOptions alloc] initWithDictionary:data]; } - (void)setDataScrubber:(RollbarScrubbingOptions *)value { - [self setDataTransferObject:[value mutableCopy] forKey:DFK_DATA_SCRUBBER]; + [self setDataTransferObject:[value mutableCopy] forKey:DFK_DATA_SCRUBBER]; } #pragma mark - Server - (RollbarMutableServerConfig *)server { - id data = [self safelyGetDictionaryByKey:DFK_SERVER]; - return [[RollbarMutableServerConfig alloc] initWithDictionary:data]; + id data = [self safelyGetDictionaryByKey:DFK_SERVER]; + return [[RollbarMutableServerConfig alloc] initWithDictionary:data]; } - (void)setServer:(RollbarServerConfig *)value { - [self setDataTransferObject:[value mutableCopy] forKey:DFK_SERVER]; + [self setDataTransferObject:[value mutableCopy] forKey:DFK_SERVER]; } #pragma mark - Person - (RollbarMutablePerson *)person { - id data = [self safelyGetDictionaryByKey:DFK_PERSON]; - return [[RollbarMutablePerson alloc] initWithDictionary:data]; + id data = [self safelyGetDictionaryByKey:DFK_PERSON]; + return [[RollbarMutablePerson alloc] initWithDictionary:data]; } - (void)setPerson:(RollbarPerson *)value { - [self setDataTransferObject:value forKey:DFK_PERSON]; + [self setDataTransferObject:value forKey:DFK_PERSON]; } #pragma mark - HTTP Proxy Settings - (RollbarMutableProxy *)httpProxy { - id data = [self safelyGetDictionaryByKey:DFK_HTTP_PROXY]; - return [[RollbarMutableProxy alloc] initWithDictionary:data]; + id data = [self safelyGetDictionaryByKey:DFK_HTTP_PROXY]; + return [[RollbarMutableProxy alloc] initWithDictionary:data]; } - (void)setHttpProxy:(RollbarProxy *)value { - [self setDataTransferObject:[value mutableCopy] forKey:DFK_HTTP_PROXY]; + [self setDataTransferObject:[value mutableCopy] forKey:DFK_HTTP_PROXY]; } #pragma mark - HTTPS Proxy Settings - (RollbarMutableProxy *)httpsProxy { - id data = [self safelyGetDictionaryByKey:DFK_HTTPS_PROXY]; - return [[RollbarMutableProxy alloc] initWithDictionary:data]; + id data = [self safelyGetDictionaryByKey:DFK_HTTPS_PROXY]; + return [[RollbarMutableProxy alloc] initWithDictionary:data]; } - (void)setHttpsProxy:(RollbarProxy *)value { - [self setDataTransferObject:[value mutableCopy] forKey:DFK_HTTPS_PROXY]; + [self setDataTransferObject:[value mutableCopy] forKey:DFK_HTTPS_PROXY]; } #pragma mark - Telemetry - (RollbarMutableTelemetryOptions *)telemetry { - id data = [self safelyGetDictionaryByKey:DFK_TELEMETRY]; - return [[RollbarMutableTelemetryOptions alloc] initWithDictionary:data]; + id data = [self safelyGetDictionaryByKey:DFK_TELEMETRY]; + return [[RollbarMutableTelemetryOptions alloc] initWithDictionary:data]; } - (void)setTelemetry:(RollbarTelemetryOptions *)value { - [self setDataTransferObject:[value mutableCopy] forKey:DFK_TELEMETRY]; + [self setDataTransferObject:[value mutableCopy] forKey:DFK_TELEMETRY]; } #pragma mark - Convenience Methods -- (void)setPersonId:(nonnull NSString*)personId - username:(nullable NSString*)username - email:(nullable NSString*)email { - self.person.ID = personId; - self.person.username = username; - self.person.email = email; +- (void)setPersonId:(nonnull NSString *)personId + username:(nullable NSString *)username + email:(nullable NSString *)email { + self.person.ID = personId; + self.person.username = username; + self.person.email = email; } - (void)setServerHost:(nullable NSString *)host - root:(nullable NSString*)root - branch:(nullable NSString*)branch - codeVersion:(nullable NSString*)codeVersion { - self.server.host = host; - self.server.root = root; - self.server.branch = branch; - self.server.codeVersion = codeVersion; + root:(nullable NSString *)root + branch:(nullable NSString *)branch + codeVersion:(nullable NSString *)codeVersion { + self.server.host = host; + self.server.root = root; + self.server.branch = branch; + self.server.codeVersion = codeVersion; } - (void)setNotifierName:(nullable NSString *)name version:(nullable NSString *)version { - self.notifier.name = name; - self.notifier.version = version; + self.notifier.name = name; + self.notifier.version = version; } #pragma mark - Custom data - (NSMutableDictionary *)customData { - NSMutableDictionary *result = [self safelyGetDictionaryByKey:DFK_CUSTOM]; - return result; + NSMutableDictionary *result = [self safelyGetDictionaryByKey:DFK_CUSTOM]; + return result; } - (void)setCustomData:(NSMutableDictionary *)value { - [self setDictionary:value forKey:DFK_CUSTOM]; + [self setDictionary:value forKey:DFK_CUSTOM]; } #pragma mark - overrides -- (nonnull RollbarConfig *) copy { +- (nonnull RollbarConfig *)copy { - return [self copyWithZone:nil]; + return [self copyWithZone:nil]; } - @end diff --git a/RollbarNotifier/Tests/RollbarNotifierTests-ObjC/DTOsTests.m b/RollbarNotifier/Tests/RollbarNotifierTests-ObjC/DTOsTests.m index 3cd7622e..13042f42 100644 --- a/RollbarNotifier/Tests/RollbarNotifierTests-ObjC/DTOsTests.m +++ b/RollbarNotifier/Tests/RollbarNotifierTests-ObjC/DTOsTests.m @@ -12,662 +12,589 @@ @interface DTOsTests : XCTestCase @implementation DTOsTests - (void)setUp { - // Put setup code here. This method is called before the invocation of each test method in the class. + // Put setup code here. This method is called before the invocation of each + // test method in the class. } - (void)tearDown { - // Put teardown code here. This method is called after the invocation of each test method in the class. + // Put teardown code here. This method is called after the invocation of each + // test method in the class. } - (void)testBasicDTOInitializationWithJSONString { - NSString *jsonString = @"{\"access_token\":\"ACCESS_TOKEN\", \"data\":{\"environment\":\"ENV\"}}"; - NSString *jsonPayload = @"{\"access_token\":\"ACCESS_TOKEN\"}"; - NSString *jsonData = @"{\"environment\":\"ENV\"}"; - - RollbarPayload *payloadAtOnce = [[RollbarPayload alloc] initWithJSONString:jsonString]; - XCTAssertNotNil(payloadAtOnce, - @"Payload instance" - ); - XCTAssertTrue([payloadAtOnce.accessToken isEqualToString:@"ACCESS_TOKEN"], - @"Access token field [%@] of payload: %@.", payloadAtOnce.accessToken, [payloadAtOnce serializeToJSONString] - ); - XCTAssertNotNil(payloadAtOnce.data, - @"Data field of payload: %@.", [payloadAtOnce serializeToJSONString] - ); - XCTAssertTrue([payloadAtOnce.data.environment isEqualToString:@"ENV"], - @"Environment field [%@] of payload: %@.", payloadAtOnce.data.environment, [payloadAtOnce serializeToJSONString] - ); - - RollbarPayload *payload = [[RollbarPayload alloc] initWithJSONString:jsonPayload]; - RollbarData *payloadData = [[RollbarData alloc] initWithJSONString:jsonData]; - payload.data = payloadData; - XCTAssertTrue([[payloadAtOnce serializeToJSONString] isEqualToString:[payload serializeToJSONString]], - @"payloadAtOnce [%@] must match payload: [%@].", - [payloadAtOnce serializeToJSONString], - [payload serializeToJSONString] - ); - - XCTAssertTrue(![payload hasSameDefinedPropertiesAs:payloadData], - @"RollbarPayload and RollbarData DTOs do not have same defined properties" - ); - XCTAssertTrue([payload hasSameDefinedPropertiesAs:payloadAtOnce], - @"Two RollbarPayload DTOs do not have same defined properties" - ); - - XCTAssertTrue([payloadAtOnce isEqual:payload], - @"Two RollbarPayload DTOs are expected to be equal" - ); - - payload.accessToken = @"SOME_OTHER_ONE"; - XCTAssertTrue(![payloadAtOnce isEqual:payload], - @"Two RollbarPayload DTOs are NOT expected to be equal" - ); - - //id result = [payload getDefinedProperties]; + NSString *jsonString = @"{\"access_token\":\"ACCESS_TOKEN\", " + @"\"data\":{\"environment\":\"ENV\"}}"; + NSString *jsonPayload = @"{\"access_token\":\"ACCESS_TOKEN\"}"; + NSString *jsonData = @"{\"environment\":\"ENV\"}"; + + RollbarPayload *payloadAtOnce = + [[RollbarPayload alloc] initWithJSONString:jsonString]; + XCTAssertNotNil(payloadAtOnce, @"Payload instance"); + XCTAssertTrue([payloadAtOnce.accessToken isEqualToString:@"ACCESS_TOKEN"], + @"Access token field [%@] of payload: %@.", + payloadAtOnce.accessToken, + [payloadAtOnce serializeToJSONString]); + XCTAssertNotNil(payloadAtOnce.data, @"Data field of payload: %@.", + [payloadAtOnce serializeToJSONString]); + XCTAssertTrue([payloadAtOnce.data.environment isEqualToString:@"ENV"], + @"Environment field [%@] of payload: %@.", + payloadAtOnce.data.environment, + [payloadAtOnce serializeToJSONString]); + + RollbarPayload *payload = + [[RollbarPayload alloc] initWithJSONString:jsonPayload]; + RollbarData *payloadData = [[RollbarData alloc] initWithJSONString:jsonData]; + payload.data = payloadData; + XCTAssertTrue([[payloadAtOnce serializeToJSONString] + isEqualToString:[payload serializeToJSONString]], + @"payloadAtOnce [%@] must match payload: [%@].", + [payloadAtOnce serializeToJSONString], + [payload serializeToJSONString]); + + XCTAssertTrue(![payload hasSameDefinedPropertiesAs:payloadData], + @"RollbarPayload and RollbarData DTOs do not have same defined " + @"properties"); + XCTAssertTrue([payload hasSameDefinedPropertiesAs:payloadAtOnce], + @"Two RollbarPayload DTOs do not have same defined properties"); + + XCTAssertTrue([payloadAtOnce isEqual:payload], + @"Two RollbarPayload DTOs are expected to be equal"); + + payload.accessToken = @"SOME_OTHER_ONE"; + XCTAssertTrue(![payloadAtOnce isEqual:payload], + @"Two RollbarPayload DTOs are NOT expected to be equal"); + + // id result = [payload getDefinedProperties]; } --(void)testRollbarProxyDTO { - BOOL proxyEnabled = NO; - NSUInteger proxyPort = 3000; - NSString *proxyUrl = @"PROXY_URL"; - RollbarProxy *dto = [[RollbarProxy alloc] initWithEnabled:proxyEnabled proxyUrl:proxyUrl proxyPort:proxyPort]; - XCTAssertTrue(dto.enabled == proxyEnabled, - @"Enabled." - ); - XCTAssertTrue(dto.proxyPort == proxyPort, - @"Enabled." - ); - XCTAssertTrue(dto.proxyUrl == proxyUrl, - @"Enabled." - ); +- (void)testRollbarProxyDTO { + BOOL proxyEnabled = NO; + NSUInteger proxyPort = 3000; + NSString *proxyUrl = @"PROXY_URL"; + RollbarProxy *dto = [[RollbarProxy alloc] initWithEnabled:proxyEnabled + proxyUrl:proxyUrl + proxyPort:proxyPort]; + XCTAssertTrue(dto.enabled == proxyEnabled, @"Enabled."); + XCTAssertTrue(dto.proxyPort == proxyPort, @"Enabled."); + XCTAssertTrue(dto.proxyUrl == proxyUrl, @"Enabled."); } - (void)testRollbarScrubbingOptionsDTO { - RollbarMutableScrubbingOptions *dto = [[RollbarMutableScrubbingOptions alloc] initWithScrubFields:@[@"field1", @"field2"]]; - XCTAssertTrue(dto.enabled, - @"Enabled by default" - ); - XCTAssertTrue(dto.scrubFields.count == 2, - @"Has some scrub fields" - ); - XCTAssertTrue(dto.safeListFields.count == 0, - @"Has NO whitelist fields" - ); - - dto.safeListFields = [@[@"tf1", @"tf2", @"tf3"] mutableCopy]; - XCTAssertTrue(dto.safeListFields.count == 3, - @"Has some whitelist fields" - ); - - dto.enabled = NO; - XCTAssertTrue(!dto.enabled, - @"Expected to be disabled" - ); + RollbarMutableScrubbingOptions *dto = [[RollbarMutableScrubbingOptions alloc] + initWithScrubFields:@[ @"field1", @"field2" ]]; + XCTAssertTrue(dto.enabled, @"Enabled by default"); + XCTAssertTrue(dto.scrubFields.count == 2, @"Has some scrub fields"); + XCTAssertTrue(dto.safeListFields.count == 0, @"Has NO whitelist fields"); + + dto.safeListFields = [@[ @"tf1", @"tf2", @"tf3" ] mutableCopy]; + XCTAssertTrue(dto.safeListFields.count == 3, @"Has some whitelist fields"); + + dto.enabled = NO; + XCTAssertTrue(!dto.enabled, @"Expected to be disabled"); } - (void)testRollbarServerConfigDTO { - RollbarMutableServerConfig *dto = [[RollbarMutableServerConfig alloc] initWithHost:@"HOST" - root:@"ROOT" - branch:@"BRANCH" - codeVersion:@"1.2.3" - ]; - XCTAssertTrue(NSOrderedSame == [dto.host compare:@"HOST"], - @"Proper host" - ); - XCTAssertTrue(NSOrderedSame == [dto.root compare:@"ROOT"], - @"Proper root" - ); - XCTAssertTrue(NSOrderedSame == [dto.branch compare:@"BRANCH"], - @"Proper branch" - ); - XCTAssertTrue(NSOrderedSame == [dto.codeVersion compare:@"1.2.3"], - @"Proper code version" - ); - - dto.host = @"h1"; - XCTAssertTrue(NSOrderedSame == [dto.host compare:@"h1"], - @"Proper new host" - ); - dto.root = @"r1"; - XCTAssertTrue(NSOrderedSame == [dto.root compare:@"r1"], - @"Proper new root" - ); - dto.branch = @"b1"; - XCTAssertTrue(NSOrderedSame == [dto.branch compare:@"b1"], - @"Proper new branch" - ); - dto.codeVersion = @"3.2.5"; - XCTAssertTrue(NSOrderedSame == [dto.codeVersion compare:@"3.2.5"], - @"Proper new code version" - ); - - - RollbarMutableConfig *rc = [RollbarMutableConfig new]; - rc.destination.accessToken = @"ACCESSTOKEN"; - rc.destination.environment = @"ENVIRONMENT"; - rc.destination.endpoint = @"ENDPOINT"; - - dto = rc.server; - NSString *branchValue = dto.branch; - XCTAssertNil(branchValue, - @"Uninitialized branch" - ); - dto.branch = @"ANOTHER_BRANCH"; - XCTAssertTrue(NSOrderedSame == [dto.branch compare:@"ANOTHER_BRANCH"], - @"Proper branch" - ); + RollbarMutableServerConfig *dto = + [[RollbarMutableServerConfig alloc] initWithHost:@"HOST" + root:@"ROOT" + branch:@"BRANCH" + codeVersion:@"1.2.3"]; + XCTAssertTrue(NSOrderedSame == [dto.host compare:@"HOST"], @"Proper host"); + XCTAssertTrue(NSOrderedSame == [dto.root compare:@"ROOT"], @"Proper root"); + XCTAssertTrue(NSOrderedSame == [dto.branch compare:@"BRANCH"], + @"Proper branch"); + XCTAssertTrue(NSOrderedSame == [dto.codeVersion compare:@"1.2.3"], + @"Proper code version"); + + dto.host = @"h1"; + XCTAssertTrue(NSOrderedSame == [dto.host compare:@"h1"], @"Proper new host"); + dto.root = @"r1"; + XCTAssertTrue(NSOrderedSame == [dto.root compare:@"r1"], @"Proper new root"); + dto.branch = @"b1"; + XCTAssertTrue(NSOrderedSame == [dto.branch compare:@"b1"], + @"Proper new branch"); + dto.codeVersion = @"3.2.5"; + XCTAssertTrue(NSOrderedSame == [dto.codeVersion compare:@"3.2.5"], + @"Proper new code version"); + + RollbarMutableConfig *rc = [RollbarMutableConfig new]; + rc.destination.accessToken = @"ACCESSTOKEN"; + rc.destination.environment = @"ENVIRONMENT"; + rc.destination.endpoint = @"ENDPOINT"; + + dto = rc.server; + NSString *branchValue = dto.branch; + XCTAssertNil(branchValue, @"Uninitialized branch"); + dto.branch = @"ANOTHER_BRANCH"; + XCTAssertTrue(NSOrderedSame == [dto.branch compare:@"ANOTHER_BRANCH"], + @"Proper branch"); } - (void)testRollbarPersonDTO { - RollbarMutablePerson *dto = [[RollbarMutablePerson alloc] initWithID:@"ID" - username:@"USERNAME" - email:@"EMAIL" - ]; - XCTAssertTrue(NSOrderedSame == [dto.ID compare:@"ID"], - @"Proper ID" - ); - XCTAssertTrue(NSOrderedSame == [dto.username compare:@"USERNAME"], - @"Proper username" - ); - XCTAssertTrue(NSOrderedSame == [dto.email compare:@"EMAIL"], - @"Proper email" - ); - - dto.ID = @"ID1"; - XCTAssertTrue(NSOrderedSame == [dto.ID compare:@"ID1"], - @"Proper ID" - ); - dto.username = @"USERNAME1"; - XCTAssertTrue(NSOrderedSame == [dto.username compare:@"USERNAME1"], - @"Proper username" - ); - dto.email = @"EMAIL1"; - XCTAssertTrue(NSOrderedSame == [dto.email compare:@"EMAIL1"], - @"Proper email" - ); - - dto = [[RollbarMutablePerson alloc] initWithID:@"ID007"]; - XCTAssertTrue(NSOrderedSame == [dto.ID compare:@"ID007"], - @"Proper ID" - ); - XCTAssertNil(dto.username, - @"Proper default username" - ); - XCTAssertNil(dto.email, - @"Proper default email" - ); + RollbarMutablePerson *dto = + [[RollbarMutablePerson alloc] initWithID:@"ID" + username:@"USERNAME" + email:@"EMAIL"]; + XCTAssertTrue(NSOrderedSame == [dto.ID compare:@"ID"], @"Proper ID"); + XCTAssertTrue(NSOrderedSame == [dto.username compare:@"USERNAME"], + @"Proper username"); + XCTAssertTrue(NSOrderedSame == [dto.email compare:@"EMAIL"], @"Proper email"); + + dto.ID = @"ID1"; + XCTAssertTrue(NSOrderedSame == [dto.ID compare:@"ID1"], @"Proper ID"); + dto.username = @"USERNAME1"; + XCTAssertTrue(NSOrderedSame == [dto.username compare:@"USERNAME1"], + @"Proper username"); + dto.email = @"EMAIL1"; + XCTAssertTrue(NSOrderedSame == [dto.email compare:@"EMAIL1"], + @"Proper email"); + + dto = [[RollbarMutablePerson alloc] initWithID:@"ID007"]; + XCTAssertTrue(NSOrderedSame == [dto.ID compare:@"ID007"], @"Proper ID"); + XCTAssertNil(dto.username, @"Proper default username"); + XCTAssertNil(dto.email, @"Proper default email"); } - (void)testRollbarModuleDTO { - RollbarMutableModule *dto = [[RollbarMutableModule alloc] initWithName:@"ModuleName" - version:@"v1.2.3" - ]; - XCTAssertTrue([dto.name isEqualToString:@"ModuleName"], - @"Proper name" - ); - XCTAssertTrue([dto.version isEqualToString:@"v1.2.3"], - @"Proper version" - ); - - dto.name = @"MN1"; - XCTAssertTrue([dto.name isEqualToString:@"MN1"], - @"Proper name" - ); - dto.version = @"v3.3.2"; - XCTAssertTrue([dto.version isEqualToString:@"v3.3.2"], - @"Proper version" - ); - - dto = [[RollbarMutableModule alloc] initWithName:@"Module"]; - XCTAssertTrue([dto.name isEqualToString:@"Module"], - @"Proper name" - ); - XCTAssertNil(dto.version, - @"Proper version" - ); + RollbarMutableModule *dto = + [[RollbarMutableModule alloc] initWithName:@"ModuleName" + version:@"v1.2.3"]; + XCTAssertTrue([dto.name isEqualToString:@"ModuleName"], @"Proper name"); + XCTAssertTrue([dto.version isEqualToString:@"v1.2.3"], @"Proper version"); + + dto.name = @"MN1"; + XCTAssertTrue([dto.name isEqualToString:@"MN1"], @"Proper name"); + dto.version = @"v3.3.3"; + XCTAssertTrue([dto.version isEqualToString:@"v3.3.3"], @"Proper version"); + + dto = [[RollbarMutableModule alloc] initWithName:@"Module"]; + XCTAssertTrue([dto.name isEqualToString:@"Module"], @"Proper name"); + XCTAssertNil(dto.version, @"Proper version"); } - (void)testRollbarTelemetryOptionsDTO { - RollbarScrubbingOptions *scrubber = - [[RollbarScrubbingOptions alloc] initWithEnabled:YES - scrubFields:@[@"one", @"two"] - safeListFields:@[@"two", @"three", @"four"] - ]; - RollbarTelemetryOptions *dto = [[RollbarTelemetryOptions alloc] initWithEnabled:YES - captureLog:YES - captureConnectivity:YES - viewInputsScrubber:scrubber - ]; - XCTAssertTrue(dto.enabled, - @"Proper enabled" - ); - XCTAssertTrue(dto.captureLog, - @"Proper capture log" - ); - XCTAssertTrue(dto.captureConnectivity, - @"Proper capture connectivity" - ); - XCTAssertTrue(dto.viewInputsScrubber.enabled, - @"Proper view inputs scrubber enabled" - ); - XCTAssertTrue(dto.viewInputsScrubber.scrubFields.count == 2, - @"Proper view inputs scrubber scrub fields count" - ); - XCTAssertTrue(dto.viewInputsScrubber.safeListFields.count == 3, - @"Proper view inputs scrubber white list fields count" - ); - - dto = [[RollbarMutableTelemetryOptions alloc] init]; - XCTAssertTrue(!dto.enabled, - @"Proper enabled" - ); - XCTAssertTrue(!dto.captureLog, - @"Proper capture log" - ); - XCTAssertTrue(!dto.captureConnectivity, - @"Proper capture connectivity" - ); - XCTAssertTrue(dto.viewInputsScrubber.enabled, - @"Proper view inputs scrubber enabled" - ); - XCTAssertTrue(dto.viewInputsScrubber.scrubFields.count == [RollbarScrubbingOptions new].scrubFields.count, - @"Proper view inputs scrubber scrub fields count" - ); - XCTAssertTrue(dto.viewInputsScrubber.safeListFields.count == [RollbarScrubbingOptions new].safeListFields.count, - @"Proper view inputs scrubber white list fields count" - ); - + RollbarScrubbingOptions *scrubber = [[RollbarScrubbingOptions alloc] + initWithEnabled:YES + scrubFields:@[ @"one", @"two" ] + safeListFields:@[ @"two", @"three", @"four" ]]; + RollbarTelemetryOptions *dto = + [[RollbarTelemetryOptions alloc] initWithEnabled:YES + captureLog:YES + captureConnectivity:YES + viewInputsScrubber:scrubber]; + XCTAssertTrue(dto.enabled, @"Proper enabled"); + XCTAssertTrue(dto.captureLog, @"Proper capture log"); + XCTAssertTrue(dto.captureConnectivity, @"Proper capture connectivity"); + XCTAssertTrue(dto.viewInputsScrubber.enabled, + @"Proper view inputs scrubber enabled"); + XCTAssertTrue(dto.viewInputsScrubber.scrubFields.count == 2, + @"Proper view inputs scrubber scrub fields count"); + XCTAssertTrue(dto.viewInputsScrubber.safeListFields.count == 3, + @"Proper view inputs scrubber white list fields count"); + + dto = [[RollbarMutableTelemetryOptions alloc] init]; + XCTAssertTrue(!dto.enabled, @"Proper enabled"); + XCTAssertTrue(!dto.captureLog, @"Proper capture log"); + XCTAssertTrue(!dto.captureConnectivity, @"Proper capture connectivity"); + XCTAssertTrue(dto.viewInputsScrubber.enabled, + @"Proper view inputs scrubber enabled"); + XCTAssertTrue(dto.viewInputsScrubber.scrubFields.count == + [RollbarScrubbingOptions new].scrubFields.count, + @"Proper view inputs scrubber scrub fields count"); + XCTAssertTrue(dto.viewInputsScrubber.safeListFields.count == + [RollbarScrubbingOptions new].safeListFields.count, + @"Proper view inputs scrubber white list fields count"); } - (void)testRollbarLoggingOptionsDTO { - RollbarMutableLoggingOptions *dto = [[RollbarMutableLoggingOptions alloc] initWithLogLevel:RollbarLevel_Error - crashLevel:RollbarLevel_Info - maximumReportsPerMinute:45 - rateLimitBehavior:RollbarRateLimitBehavior_Queue]; - dto.captureIp = RollbarCaptureIpType_Anonymize; - dto.codeVersion = @"CODEVERSION"; - dto.framework = @"FRAMEWORK"; - dto.requestId = @"REQUESTID"; - - XCTAssertTrue(dto.logLevel == RollbarLevel_Error, - @"Proper log level" - ); - XCTAssertTrue(dto.crashLevel == RollbarLevel_Info, - @"Proper crash level" - ); - XCTAssertTrue(dto.maximumReportsPerMinute == 45, - @"Proper max reports per minute" - ); - XCTAssertTrue(dto.captureIp == RollbarCaptureIpType_Anonymize, - @"Proper capture IP" - ); - XCTAssertTrue([dto.codeVersion isEqualToString:@"CODEVERSION"], - @"Proper code version" - ); - XCTAssertTrue([dto.framework isEqualToString:@"FRAMEWORK"], - @"Proper framework" - ); - XCTAssertTrue([dto.requestId isEqualToString:@"REQUESTID"], - @"Proper request ID" - ); - - dto = [[RollbarMutableLoggingOptions alloc] init]; - XCTAssertTrue(dto.logLevel == RollbarLevel_Debug, - @"Proper default log level" - ); - XCTAssertTrue(dto.crashLevel == RollbarLevel_Error, - @"Proper default crash level" - ); - XCTAssertTrue(dto.maximumReportsPerMinute == 60, - @"Proper default max reports per minute" - ); - XCTAssertTrue(dto.captureIp == RollbarCaptureIpType_Full, - @"Proper default capture IP" - ); - XCTAssertNil(dto.codeVersion, - @"Proper default code version" - ); - XCTAssertTrue([dto.framework isEqualToString:@"macos"] || [dto.framework isEqualToString:@"ios"], - @"Proper default framework" - ); - XCTAssertNil(dto.requestId, - @"Proper request ID" - ); + RollbarMutableLoggingOptions *dto = [[RollbarMutableLoggingOptions alloc] + initWithLogLevel:RollbarLevel_Error + crashLevel:RollbarLevel_Info + maximumReportsPerMinute:45 + rateLimitBehavior:RollbarRateLimitBehavior_Queue]; + dto.captureIp = RollbarCaptureIpType_Anonymize; + dto.codeVersion = @"CODEVERSION"; + dto.framework = @"FRAMEWORK"; + dto.requestId = @"REQUESTID"; + + XCTAssertTrue(dto.logLevel == RollbarLevel_Error, @"Proper log level"); + XCTAssertTrue(dto.crashLevel == RollbarLevel_Info, @"Proper crash level"); + XCTAssertTrue(dto.maximumReportsPerMinute == 45, + @"Proper max reports per minute"); + XCTAssertTrue(dto.captureIp == RollbarCaptureIpType_Anonymize, + @"Proper capture IP"); + XCTAssertTrue([dto.codeVersion isEqualToString:@"CODEVERSION"], + @"Proper code version"); + XCTAssertTrue([dto.framework isEqualToString:@"FRAMEWORK"], + @"Proper framework"); + XCTAssertTrue([dto.requestId isEqualToString:@"REQUESTID"], + @"Proper request ID"); + + dto = [[RollbarMutableLoggingOptions alloc] init]; + XCTAssertTrue(dto.logLevel == RollbarLevel_Debug, + @"Proper default log level"); + XCTAssertTrue(dto.crashLevel == RollbarLevel_Error, + @"Proper default crash level"); + XCTAssertTrue(dto.maximumReportsPerMinute == 60, + @"Proper default max reports per minute"); + XCTAssertTrue(dto.captureIp == RollbarCaptureIpType_Full, + @"Proper default capture IP"); + XCTAssertNil(dto.codeVersion, @"Proper default code version"); + XCTAssertTrue([dto.framework isEqualToString:@"macos"] || + [dto.framework isEqualToString:@"ios"], + @"Proper default framework"); + XCTAssertNil(dto.requestId, @"Proper request ID"); } - - (void)testRollbarConfigDTO { - RollbarMutableConfig *rc = [RollbarMutableConfig new]; - //id destination = rc.destination; - rc.destination.accessToken = @"ACCESSTOKEN"; - rc.destination.environment = @"ENVIRONMENT"; - rc.destination.endpoint = @"ENDPOINT"; - //rc.logLevel = RollbarDebug; - - [rc setPersonId:@"PERSONID" username:@"PERSONUSERNAME" email:@"PERSONEMAIL"]; - [rc setServerHost:@"SERVERHOST" root:@"SERVERROOT" branch:@"SERVERBRANCH" codeVersion:@"SERVERCODEVERSION"]; - [rc setNotifierName:@"NOTIFIERNAME" version:@"NOTIFIERVERSION"]; - - RollbarMutableConfig *rcClone = [[RollbarMutableConfig alloc] initWithJSONString:[rc serializeToJSONString]]; - -// id scrubList = rc.scrubFields; -// id scrubListClone = rcClone.scrubFields; - - XCTAssertTrue([rc isEqual:rcClone], - @"Two DTOs are expected to be equal" - ); -// XCTAssertTrue([[rc serializeToJSONString] isEqualToString:[rcClone serializeToJSONString]], -// @"DTO [%@] must match DTO: [%@].", -// [rc serializeToJSONString], -// [rcClone serializeToJSONString] -// ); - - rcClone.destination.accessToken = @"SOME_OTHER_ONE"; - XCTAssertTrue(![rc isEqual:rcClone], - @"Two DTOs are NOT expected to be equal" - ); -// XCTAssertTrue(![[rc serializeToJSONString] isEqualToString:[rcClone serializeToJSONString]], -// @"DTO [%@] must NOT match DTO: [%@].", -// [rc serializeToJSONString], -// [rcClone serializeToJSONString] -// ); - - rcClone = [[RollbarMutableConfig alloc] initWithJSONString:[rc serializeToJSONString]]; - rcClone.httpProxy.proxyUrl = @"SOME_OTHER_ONE"; - XCTAssertTrue(![rc isEqual:rcClone], - @"Two DTOs are NOT expected to be equal" - ); - XCTAssertTrue([rcClone isEqual:[[RollbarConfig alloc] initWithJSONString:[rcClone serializeToJSONString]]], - @"Two DTOs (clone and its clone) are expected to be equal" - ); + RollbarMutableConfig *rc = [RollbarMutableConfig new]; + // id destination = rc.destination; + rc.destination.accessToken = @"ACCESSTOKEN"; + rc.destination.environment = @"ENVIRONMENT"; + rc.destination.endpoint = @"ENDPOINT"; + // rc.logLevel = RollbarDebug; + + [rc setPersonId:@"PERSONID" username:@"PERSONUSERNAME" email:@"PERSONEMAIL"]; + [rc setServerHost:@"SERVERHOST" + root:@"SERVERROOT" + branch:@"SERVERBRANCH" + codeVersion:@"SERVERCODEVERSION"]; + [rc setNotifierName:@"NOTIFIERNAME" version:@"NOTIFIERVERSION"]; + + RollbarMutableConfig *rcClone = [[RollbarMutableConfig alloc] + initWithJSONString:[rc serializeToJSONString]]; + + // id scrubList = rc.scrubFields; + // id scrubListClone = rcClone.scrubFields; + + XCTAssertTrue([rc isEqual:rcClone], @"Two DTOs are expected to be equal"); + // XCTAssertTrue([[rc serializeToJSONString] isEqualToString:[rcClone + // serializeToJSONString]], + // @"DTO [%@] must match DTO: [%@].", + // [rc serializeToJSONString], + // [rcClone serializeToJSONString] + // ); + + rcClone.destination.accessToken = @"SOME_OTHER_ONE"; + XCTAssertTrue(![rc isEqual:rcClone], + @"Two DTOs are NOT expected to be equal"); + // XCTAssertTrue(![[rc serializeToJSONString] isEqualToString:[rcClone + // serializeToJSONString]], + // @"DTO [%@] must NOT match DTO: [%@].", + // [rc serializeToJSONString], + // [rcClone serializeToJSONString] + // ); + + rcClone = [[RollbarMutableConfig alloc] + initWithJSONString:[rc serializeToJSONString]]; + rcClone.httpProxy.proxyUrl = @"SOME_OTHER_ONE"; + XCTAssertTrue(![rc isEqual:rcClone], + @"Two DTOs are NOT expected to be equal"); + XCTAssertTrue( + [rcClone isEqual:[[RollbarConfig alloc] + initWithJSONString:[rcClone serializeToJSONString]]], + @"Two DTOs (clone and its clone) are expected to be equal"); } - (void)testRollbarMessageDTO { - NSString *messageBody = @"Test message"; - RollbarMessage *dto = [[RollbarMessage alloc] initWithBody:messageBody]; - XCTAssertEqual(messageBody, dto.body); - - NSError *error = [NSError errorWithDomain:@"ERROR_DOMAIN" code:100 userInfo:nil]; - dto = [[RollbarMessage alloc] initWithNSError:error]; - XCTAssertNotNil(dto); - XCTAssertTrue([dto.body containsString:@"ERROR_DOMAIN"]); - XCTAssertTrue([dto.body containsString:@"100"]); + NSString *messageBody = @"Test message"; + RollbarMessage *dto = [[RollbarMessage alloc] initWithBody:messageBody]; + XCTAssertEqual(messageBody, dto.body); + + NSError *error = [NSError errorWithDomain:@"ERROR_DOMAIN" + code:100 + userInfo:nil]; + dto = [[RollbarMessage alloc] initWithNSError:error]; + XCTAssertNotNil(dto); + XCTAssertTrue([dto.body containsString:@"ERROR_DOMAIN"]); + XCTAssertTrue([dto.body containsString:@"100"]); } - (void)testMessageRollbarBodyDTO { - NSString *message = @"Test message"; - RollbarBody *dto = [[RollbarBody alloc] initWithMessage:message]; - XCTAssertNotNil(dto); - XCTAssertNotNil(dto.message); - XCTAssertNotNil(dto.message.body); - XCTAssertEqual(message, dto.message.body); - XCTAssertNil(dto.crashReport); - XCTAssertNil(dto.trace); - XCTAssertNil(dto.traceChain); + NSString *message = @"Test message"; + RollbarBody *dto = [[RollbarBody alloc] initWithMessage:message]; + XCTAssertNotNil(dto); + XCTAssertNotNil(dto.message); + XCTAssertNotNil(dto.message.body); + XCTAssertEqual(message, dto.message.body); + XCTAssertNil(dto.crashReport); + XCTAssertNil(dto.trace); + XCTAssertNil(dto.traceChain); } - (void)testCrashReportRollbarBodyDTO { - NSString *data = @"RAW_CRASH_REPORT_CONTENT"; - RollbarBody *dto = [[RollbarBody alloc] initWithCrashReport:data]; - XCTAssertNotNil(dto); - XCTAssertNotNil(dto.crashReport); - XCTAssertNotNil(dto.crashReport.rawCrashReport); - XCTAssertEqual(data, dto.crashReport.rawCrashReport); - XCTAssertNil(dto.message); - XCTAssertNil(dto.trace); - XCTAssertNil(dto.traceChain); + NSString *data = @"RAW_CRASH_REPORT_CONTENT"; + RollbarBody *dto = [[RollbarBody alloc] initWithCrashReport:data]; + XCTAssertNotNil(dto); + XCTAssertNotNil(dto.crashReport); + XCTAssertNotNil(dto.crashReport.rawCrashReport); + XCTAssertEqual(data, dto.crashReport.rawCrashReport); + XCTAssertNil(dto.message); + XCTAssertNil(dto.trace); + XCTAssertNil(dto.traceChain); } - (void)testRollbarServerDTO { - NSString *cpu = @"CPU"; - NSString *host = @"HOST"; - NSString *root = @"ROOT"; - NSString *branch = @"BRANCH"; - NSString *codeVersion = nil; - - RollbarServer *dto = [[RollbarServer alloc] initWithCpu:cpu - host:host - root:root - branch:branch - codeVersion:codeVersion]; - - XCTAssertNotNil(dto); - - XCTAssertNotNil(dto.cpu); - XCTAssertNotNil(dto.host); - XCTAssertNotNil(dto.root); - XCTAssertNotNil(dto.branch); - XCTAssertNil(dto.codeVersion); - - XCTAssertEqual(cpu, dto.cpu); - XCTAssertEqual(host, dto.host); - XCTAssertEqual(root, dto.root); - XCTAssertEqual(branch, dto.branch); - XCTAssertEqual(codeVersion, dto.codeVersion); + NSString *cpu = @"CPU"; + NSString *host = @"HOST"; + NSString *root = @"ROOT"; + NSString *branch = @"BRANCH"; + NSString *codeVersion = nil; + + RollbarServer *dto = [[RollbarServer alloc] initWithCpu:cpu + host:host + root:root + branch:branch + codeVersion:codeVersion]; + + XCTAssertNotNil(dto); + + XCTAssertNotNil(dto.cpu); + XCTAssertNotNil(dto.host); + XCTAssertNotNil(dto.root); + XCTAssertNotNil(dto.branch); + XCTAssertNil(dto.codeVersion); + + XCTAssertEqual(cpu, dto.cpu); + XCTAssertEqual(host, dto.host); + XCTAssertEqual(root, dto.root); + XCTAssertEqual(branch, dto.branch); + XCTAssertEqual(codeVersion, dto.codeVersion); } - (void)testRollbarRequestDTO { - RollbarHttpMethod method = RollbarHttpMethod_Get; - NSDictionary *headers = @{@"HEADER_1":@"HEADER1", @"HEADER_2":@"HEADER2"}; - NSDictionary *params = @{@"PARAM_1":@"PARAM1", @"PARAM_2":@"PARAM2"}; - NSDictionary *getParams = @{@"GET_PARAM_1":@"GETPARAM1", @"GET_PARAM_2":@"GETPARAM2"}; - NSDictionary *postParams = nil; - NSString *url = @"URL"; - NSString *queryString = @"QUERYSTRING"; - NSString *postBody = nil; - NSString *userIP = @"USERIP"; - - RollbarRequest *dto = [[RollbarRequest alloc] initWithHttpMethod:method - url:url - headers:headers - params:params - queryString:queryString - getParams:getParams - postParams:postParams - postBody:postBody - userIP:userIP]; - - XCTAssertNotNil(dto); - - XCTAssertNotNil(dto.headers); - XCTAssertNotNil(dto.params); - XCTAssertNotNil(dto.getParams); - XCTAssertNil(dto.postParams); - XCTAssertNotNil(dto.url); - XCTAssertNotNil(dto.queryString); - XCTAssertNil(dto.postBody); - XCTAssertNotNil(dto.userIP); - - XCTAssertEqual(dto.method, method); - XCTAssertEqual(dto.headers, headers); - XCTAssertEqual(dto.params, params); - XCTAssertEqual(dto.getParams, getParams); - XCTAssertEqual(dto.postParams, postParams); - XCTAssertEqual(dto.url, url); - XCTAssertEqual(dto.queryString, queryString); - XCTAssertEqual(dto.postBody, postBody); - XCTAssertEqual(dto.userIP, userIP); + RollbarHttpMethod method = RollbarHttpMethod_Get; + NSDictionary *headers = @{@"HEADER_1" : @"HEADER1", @"HEADER_2" : @"HEADER2"}; + NSDictionary *params = @{@"PARAM_1" : @"PARAM1", @"PARAM_2" : @"PARAM2"}; + NSDictionary *getParams = + @{@"GET_PARAM_1" : @"GETPARAM1", @"GET_PARAM_2" : @"GETPARAM2"}; + NSDictionary *postParams = nil; + NSString *url = @"URL"; + NSString *queryString = @"QUERYSTRING"; + NSString *postBody = nil; + NSString *userIP = @"USERIP"; + + RollbarRequest *dto = [[RollbarRequest alloc] initWithHttpMethod:method + url:url + headers:headers + params:params + queryString:queryString + getParams:getParams + postParams:postParams + postBody:postBody + userIP:userIP]; + + XCTAssertNotNil(dto); + + XCTAssertNotNil(dto.headers); + XCTAssertNotNil(dto.params); + XCTAssertNotNil(dto.getParams); + XCTAssertNil(dto.postParams); + XCTAssertNotNil(dto.url); + XCTAssertNotNil(dto.queryString); + XCTAssertNil(dto.postBody); + XCTAssertNotNil(dto.userIP); + + XCTAssertEqual(dto.method, method); + XCTAssertEqual(dto.headers, headers); + XCTAssertEqual(dto.params, params); + XCTAssertEqual(dto.getParams, getParams); + XCTAssertEqual(dto.postParams, postParams); + XCTAssertEqual(dto.url, url); + XCTAssertEqual(dto.queryString, queryString); + XCTAssertEqual(dto.postBody, postBody); + XCTAssertEqual(dto.userIP, userIP); } - (void)testRollbarExceptionDTO { - NSString *exceptionClass = @"EXCEPTION_CLASS"; - NSString *exceptionMessage = @"EXCEPTIION_MESSAGE"; - NSString *exceptionDescription = nil; + NSString *exceptionClass = @"EXCEPTION_CLASS"; + NSString *exceptionMessage = @"EXCEPTIION_MESSAGE"; + NSString *exceptionDescription = nil; - RollbarException *dto = [[RollbarException alloc] initWithExceptionClass:exceptionClass - exceptionMessage:exceptionMessage - exceptionDescription:exceptionDescription]; + RollbarException *dto = + [[RollbarException alloc] initWithExceptionClass:exceptionClass + exceptionMessage:exceptionMessage + exceptionDescription:exceptionDescription]; - XCTAssertNotNil(dto); + XCTAssertNotNil(dto); - XCTAssertNotNil(dto.exceptionClass); - XCTAssertNotNil(dto.exceptionMessage); - XCTAssertNil(dto.exceptionDescription); + XCTAssertNotNil(dto.exceptionClass); + XCTAssertNotNil(dto.exceptionMessage); + XCTAssertNil(dto.exceptionDescription); - XCTAssertEqual(dto.exceptionClass, exceptionClass); - XCTAssertEqual(dto.exceptionMessage, exceptionMessage); - XCTAssertEqual(dto.exceptionDescription, exceptionDescription); + XCTAssertEqual(dto.exceptionClass, exceptionClass); + XCTAssertEqual(dto.exceptionMessage, exceptionMessage); + XCTAssertEqual(dto.exceptionDescription, exceptionDescription); } - (void)testRollbarCallStackFrameContextDTO { - NSArray *pre = @[@"CODE_PR1", @"CODE_PR2"]; - NSArray *post = nil; + NSArray *pre = @[ @"CODE_PR1", @"CODE_PR2" ]; + NSArray *post = nil; - RollbarCallStackFrameContext *dto = [[RollbarCallStackFrameContext alloc] initWithPreCodeLines:pre - postCodeLines:post]; + RollbarCallStackFrameContext *dto = + [[RollbarCallStackFrameContext alloc] initWithPreCodeLines:pre + postCodeLines:post]; - XCTAssertNotNil(dto); + XCTAssertNotNil(dto); - XCTAssertNotNil(dto.preCodeLines); - XCTAssertNil(dto.postCodeLines); + XCTAssertNotNil(dto.preCodeLines); + XCTAssertNil(dto.postCodeLines); - XCTAssertEqual(dto.preCodeLines.count, 2); - XCTAssertTrue([dto.preCodeLines containsObject:pre[0]]); - XCTAssertTrue([dto.preCodeLines containsObject:pre[1]]); + XCTAssertEqual(dto.preCodeLines.count, 2); + XCTAssertTrue([dto.preCodeLines containsObject:pre[0]]); + XCTAssertTrue([dto.preCodeLines containsObject:pre[1]]); } - (void)testRollbarCallStackFrameDTO { - NSString *filename = @"FILENAME"; - - NSString *className = @"CLASSNAME"; - NSString *code = @"CODE"; - NSString *method = @"METHOD"; - - NSNumber *colno = @111; - NSNumber *lineno = @222; - - NSArray *pre = @[@"CODE_PR1", @"CODE_PR2"]; - NSArray *post = nil; - RollbarCallStackFrameContext *codeContext = [[RollbarCallStackFrameContext alloc] initWithPreCodeLines:pre - postCodeLines:post]; - XCTAssertNotNil(codeContext); - XCTAssertNotNil(codeContext.preCodeLines); - XCTAssertNil(codeContext.postCodeLines); - XCTAssertEqual(codeContext.preCodeLines.count, 2); - XCTAssertTrue([codeContext.preCodeLines containsObject:pre[0]]); - XCTAssertTrue([codeContext.preCodeLines containsObject:pre[1]]); - - NSDictionary *locals = @{ - @"VAR1": @"VAL1", - @"VAR2": @"VAL2", - }; - - NSArray *argspec = @[]; - NSArray *varargspec = @[@"VARARG1"]; - NSArray *keywordspec = @[@"KW1", @"KW2"]; - - RollbarCallStackFrame *dto = [[RollbarCallStackFrame alloc] initWithFileName:filename]; - XCTAssertNotNil(dto); - XCTAssertNotNil(dto.filename); - XCTAssertEqual(dto.filename, filename); - - XCTAssertNil(dto.className); - XCTAssertNil(dto.code); - XCTAssertNil(dto.method); - dto.className = className; - dto.code = code; - dto.method = method; - XCTAssertNotNil(dto.className); - XCTAssertNotNil(dto.code); - XCTAssertNotNil(dto.method); - XCTAssertEqual(dto.className, className); - XCTAssertEqual(dto.code, code); - XCTAssertEqual(dto.method, method); - - XCTAssertNil(dto.colno); - XCTAssertNil(dto.lineno); - dto.colno = colno; - dto.lineno = lineno; - XCTAssertNotNil(dto.colno); - XCTAssertNotNil(dto.lineno); - XCTAssertEqual(dto.colno, colno); - XCTAssertEqual(dto.lineno, lineno); - - XCTAssertNil(dto.context); - dto.context = codeContext; - XCTAssertNotNil(dto.context); - XCTAssertEqual(dto.context.preCodeLines.count, codeContext.preCodeLines.count); - XCTAssertTrue([dto.context.preCodeLines containsObject:pre[0]]); - XCTAssertTrue([dto.context.preCodeLines containsObject:pre[1]]); - XCTAssertNil(dto.context.postCodeLines); - - XCTAssertNil(dto.locals); - dto.locals = locals; - XCTAssertNotNil(dto.locals); - XCTAssertEqual(dto.locals.count, locals.count); - - XCTAssertNil(dto.argspec); - dto.argspec = argspec; - XCTAssertNotNil(dto.argspec); - XCTAssertEqual(dto.argspec.count, argspec.count); - - XCTAssertNil(dto.varargspec); - dto.varargspec = varargspec; - XCTAssertNotNil(dto.varargspec); - XCTAssertEqual(dto.varargspec.count, varargspec.count); - - XCTAssertNil(dto.keywordspec); - dto.keywordspec = keywordspec; - XCTAssertNotNil(dto.keywordspec); - XCTAssertEqual(dto.keywordspec.count, keywordspec.count); - + NSString *filename = @"FILENAME"; + + NSString *className = @"CLASSNAME"; + NSString *code = @"CODE"; + NSString *method = @"METHOD"; + + NSNumber *colno = @111; + NSNumber *lineno = @222; + + NSArray *pre = @[ @"CODE_PR1", @"CODE_PR2" ]; + NSArray *post = nil; + RollbarCallStackFrameContext *codeContext = + [[RollbarCallStackFrameContext alloc] initWithPreCodeLines:pre + postCodeLines:post]; + XCTAssertNotNil(codeContext); + XCTAssertNotNil(codeContext.preCodeLines); + XCTAssertNil(codeContext.postCodeLines); + XCTAssertEqual(codeContext.preCodeLines.count, 2); + XCTAssertTrue([codeContext.preCodeLines containsObject:pre[0]]); + XCTAssertTrue([codeContext.preCodeLines containsObject:pre[1]]); + + NSDictionary *locals = @{ + @"VAR1" : @"VAL1", + @"VAR2" : @"VAL2", + }; + + NSArray *argspec = @[]; + NSArray *varargspec = @[ @"VARARG1" ]; + NSArray *keywordspec = @[ @"KW1", @"KW2" ]; + + RollbarCallStackFrame *dto = + [[RollbarCallStackFrame alloc] initWithFileName:filename]; + XCTAssertNotNil(dto); + XCTAssertNotNil(dto.filename); + XCTAssertEqual(dto.filename, filename); + + XCTAssertNil(dto.className); + XCTAssertNil(dto.code); + XCTAssertNil(dto.method); + dto.className = className; + dto.code = code; + dto.method = method; + XCTAssertNotNil(dto.className); + XCTAssertNotNil(dto.code); + XCTAssertNotNil(dto.method); + XCTAssertEqual(dto.className, className); + XCTAssertEqual(dto.code, code); + XCTAssertEqual(dto.method, method); + + XCTAssertNil(dto.colno); + XCTAssertNil(dto.lineno); + dto.colno = colno; + dto.lineno = lineno; + XCTAssertNotNil(dto.colno); + XCTAssertNotNil(dto.lineno); + XCTAssertEqual(dto.colno, colno); + XCTAssertEqual(dto.lineno, lineno); + + XCTAssertNil(dto.context); + dto.context = codeContext; + XCTAssertNotNil(dto.context); + XCTAssertEqual(dto.context.preCodeLines.count, + codeContext.preCodeLines.count); + XCTAssertTrue([dto.context.preCodeLines containsObject:pre[0]]); + XCTAssertTrue([dto.context.preCodeLines containsObject:pre[1]]); + XCTAssertNil(dto.context.postCodeLines); + + XCTAssertNil(dto.locals); + dto.locals = locals; + XCTAssertNotNil(dto.locals); + XCTAssertEqual(dto.locals.count, locals.count); + + XCTAssertNil(dto.argspec); + dto.argspec = argspec; + XCTAssertNotNil(dto.argspec); + XCTAssertEqual(dto.argspec.count, argspec.count); + + XCTAssertNil(dto.varargspec); + dto.varargspec = varargspec; + XCTAssertNotNil(dto.varargspec); + XCTAssertEqual(dto.varargspec.count, varargspec.count); + + XCTAssertNil(dto.keywordspec); + dto.keywordspec = keywordspec; + XCTAssertNotNil(dto.keywordspec); + XCTAssertEqual(dto.keywordspec.count, keywordspec.count); } - (void)testRollbarTraceDTO { - NSString *exceptionClass = @"EXCEPTION_CLASS"; - NSString *exceptionMessage = @"EXCEPTIION_MESSAGE"; - NSString *exceptionDescription = nil; - - RollbarException *exceptionDto = [[RollbarException alloc] initWithExceptionClass:exceptionClass - exceptionMessage:exceptionMessage - exceptionDescription:exceptionDescription]; - - NSString *filename = @"FILENAME"; - NSString *className = @"CLASSNAME"; - NSString *code = @"CODE"; - NSString *method = @"METHOD"; - NSNumber *colno = @111; - NSNumber *lineno = @222; - NSArray *pre = @[@"CODE_PR1", @"CODE_PR2"]; - NSArray *post = nil; - RollbarCallStackFrameContext *codeContext = [[RollbarCallStackFrameContext alloc] initWithPreCodeLines:pre - postCodeLines:post]; - NSDictionary *locals = @{ - @"VAR1": @"VAL1", - @"VAR2": @"VAL2", - }; - NSArray *argspec = @[]; - NSArray *varargspec = @[@"VARARG1"]; - NSArray *keywordspec = @[@"KW1", @"KW2"]; - - RollbarCallStackFrame *frameDto = [[RollbarCallStackFrame alloc] initWithFileName:filename]; - frameDto.className = className; - frameDto.code = code; - frameDto.method = method; - frameDto.colno = colno; - frameDto.lineno = lineno; - frameDto.context = codeContext; - frameDto.locals = locals; - frameDto.argspec = argspec; - frameDto.varargspec = varargspec; - frameDto.keywordspec = keywordspec; - - RollbarTrace *dto = [[RollbarTrace alloc] initWithRollbarException:exceptionDto - rollbarCallStackFrames:@[frameDto, frameDto]]; - XCTAssertNotNil(dto); - XCTAssertNotNil(dto.exception); - XCTAssertNotNil(dto.frames); - XCTAssertEqual(dto.exception.exceptionClass, exceptionClass); - XCTAssertEqual(dto.frames.count, 2); - XCTAssertEqual(dto.frames[0].filename, filename); - XCTAssertEqual(dto.frames[1].filename, filename); + NSString *exceptionClass = @"EXCEPTION_CLASS"; + NSString *exceptionMessage = @"EXCEPTIION_MESSAGE"; + NSString *exceptionDescription = nil; + + RollbarException *exceptionDto = + [[RollbarException alloc] initWithExceptionClass:exceptionClass + exceptionMessage:exceptionMessage + exceptionDescription:exceptionDescription]; + + NSString *filename = @"FILENAME"; + NSString *className = @"CLASSNAME"; + NSString *code = @"CODE"; + NSString *method = @"METHOD"; + NSNumber *colno = @111; + NSNumber *lineno = @222; + NSArray *pre = @[ @"CODE_PR1", @"CODE_PR2" ]; + NSArray *post = nil; + RollbarCallStackFrameContext *codeContext = + [[RollbarCallStackFrameContext alloc] initWithPreCodeLines:pre + postCodeLines:post]; + NSDictionary *locals = @{ + @"VAR1" : @"VAL1", + @"VAR2" : @"VAL2", + }; + NSArray *argspec = @[]; + NSArray *varargspec = @[ @"VARARG1" ]; + NSArray *keywordspec = @[ @"KW1", @"KW2" ]; + + RollbarCallStackFrame *frameDto = + [[RollbarCallStackFrame alloc] initWithFileName:filename]; + frameDto.className = className; + frameDto.code = code; + frameDto.method = method; + frameDto.colno = colno; + frameDto.lineno = lineno; + frameDto.context = codeContext; + frameDto.locals = locals; + frameDto.argspec = argspec; + frameDto.varargspec = varargspec; + frameDto.keywordspec = keywordspec; + + RollbarTrace *dto = + [[RollbarTrace alloc] initWithRollbarException:exceptionDto + rollbarCallStackFrames:@[ frameDto, frameDto ]]; + XCTAssertNotNil(dto); + XCTAssertNotNil(dto.exception); + XCTAssertNotNil(dto.frames); + XCTAssertEqual(dto.exception.exceptionClass, exceptionClass); + XCTAssertEqual(dto.frames.count, 2); + XCTAssertEqual(dto.frames[0].filename, filename); + XCTAssertEqual(dto.frames[1].filename, filename); } -// if/when we do allow a trace side-by-side with the crash report uncomment this test: +// if/when we do allow a trace side-by-side with the crash report uncomment this +// test: //-(void)testRollbarBodyDTO { // -// RollbarBody *body = [[RollbarBody alloc] initWithCrashReport:CRASH_REPORT_PLCRASH_SYMBOLICATED]; +// RollbarBody *body = [[RollbarBody alloc] +// initWithCrashReport:CRASH_REPORT_PLCRASH_SYMBOLICATED]; // // XCTAssertNotNil(body.crashReport); // XCTAssertNotNil(body.trace); @@ -686,290 +613,301 @@ - (void)testRollbarTraceDTO { // XCTAssertTrue(body.trace.frames.count > 0); //} --(void)testRollbarTelemetryEventDTO_properBodyBasedOnType { - - RollbarLevel level = RollbarLevel_Warning; - RollbarSource source = RollbarSource_Server; - RollbarTelemetryType type; - RollbarTelemetryEvent *event = nil; - - type = RollbarTelemetryType_Log; - event = [[RollbarTelemetryEvent alloc] initWithLevel:level - telemetryType:type - source:source]; - XCTAssertEqual(event.level, level); - XCTAssertEqual(event.source, source); - XCTAssertEqual(event.type, type); - XCTAssertNotNil(event.body); - XCTAssertTrue([event.body isKindOfClass:[RollbarTelemetryLogBody class]]); - - type = RollbarTelemetryType_View; - event = [[RollbarTelemetryEvent alloc] initWithLevel:level - telemetryType:type - source:source]; - XCTAssertEqual(event.level, level); - XCTAssertEqual(event.source, source); - XCTAssertEqual(event.type, type); - XCTAssertNotNil(event.body); - XCTAssertTrue([event.body isKindOfClass:[RollbarTelemetryViewBody class]]); - - type = RollbarTelemetryType_Error; - event = [[RollbarTelemetryEvent alloc] initWithLevel:level - telemetryType:type - source:source]; - XCTAssertEqual(event.level, level); - XCTAssertEqual(event.source, source); - XCTAssertEqual(event.type, type); - XCTAssertNotNil(event.body); - XCTAssertTrue([event.body isKindOfClass:[RollbarTelemetryErrorBody class]]); - - type = RollbarTelemetryType_Navigation; - event = [[RollbarTelemetryEvent alloc] initWithLevel:level - telemetryType:type - source:source]; - XCTAssertEqual(event.level, level); - XCTAssertEqual(event.source, source); - XCTAssertEqual(event.type, type); - XCTAssertNotNil(event.body); - XCTAssertTrue([event.body isKindOfClass:[RollbarTelemetryNavigationBody class]]); - - type = RollbarTelemetryType_Network; - event = [[RollbarTelemetryEvent alloc] initWithLevel:level - telemetryType:type - source:source]; - XCTAssertEqual(event.level, level); - XCTAssertEqual(event.source, source); - XCTAssertEqual(event.type, type); - XCTAssertNotNil(event.body); - XCTAssertTrue([event.body isKindOfClass:[RollbarTelemetryNetworkBody class]]); - - type = RollbarTelemetryType_Connectivity; - event = [[RollbarTelemetryEvent alloc] initWithLevel:level - telemetryType:type - source:source]; - XCTAssertEqual(event.level, level); - XCTAssertEqual(event.source, source); - XCTAssertEqual(event.type, type); - XCTAssertNotNil(event.body); - XCTAssertTrue([event.body isKindOfClass:[RollbarTelemetryConnectivityBody class]]); - - type = RollbarTelemetryType_Manual; - event = [[RollbarTelemetryEvent alloc] initWithLevel:level - telemetryType:type - source:source]; - XCTAssertEqual(event.level, level); - XCTAssertEqual(event.source, source); - XCTAssertEqual(event.type, type); - XCTAssertNotNil(event.body); - XCTAssertTrue([event.body isKindOfClass:[RollbarTelemetryManualBody class]]); +- (void)testRollbarTelemetryEventDTO_properBodyBasedOnType { + + RollbarLevel level = RollbarLevel_Warning; + RollbarSource source = RollbarSource_Server; + RollbarTelemetryType type; + RollbarTelemetryEvent *event = nil; + + type = RollbarTelemetryType_Log; + event = [[RollbarTelemetryEvent alloc] initWithLevel:level + telemetryType:type + source:source]; + XCTAssertEqual(event.level, level); + XCTAssertEqual(event.source, source); + XCTAssertEqual(event.type, type); + XCTAssertNotNil(event.body); + XCTAssertTrue([event.body isKindOfClass:[RollbarTelemetryLogBody class]]); + + type = RollbarTelemetryType_View; + event = [[RollbarTelemetryEvent alloc] initWithLevel:level + telemetryType:type + source:source]; + XCTAssertEqual(event.level, level); + XCTAssertEqual(event.source, source); + XCTAssertEqual(event.type, type); + XCTAssertNotNil(event.body); + XCTAssertTrue([event.body isKindOfClass:[RollbarTelemetryViewBody class]]); + + type = RollbarTelemetryType_Error; + event = [[RollbarTelemetryEvent alloc] initWithLevel:level + telemetryType:type + source:source]; + XCTAssertEqual(event.level, level); + XCTAssertEqual(event.source, source); + XCTAssertEqual(event.type, type); + XCTAssertNotNil(event.body); + XCTAssertTrue([event.body isKindOfClass:[RollbarTelemetryErrorBody class]]); + + type = RollbarTelemetryType_Navigation; + event = [[RollbarTelemetryEvent alloc] initWithLevel:level + telemetryType:type + source:source]; + XCTAssertEqual(event.level, level); + XCTAssertEqual(event.source, source); + XCTAssertEqual(event.type, type); + XCTAssertNotNil(event.body); + XCTAssertTrue( + [event.body isKindOfClass:[RollbarTelemetryNavigationBody class]]); + + type = RollbarTelemetryType_Network; + event = [[RollbarTelemetryEvent alloc] initWithLevel:level + telemetryType:type + source:source]; + XCTAssertEqual(event.level, level); + XCTAssertEqual(event.source, source); + XCTAssertEqual(event.type, type); + XCTAssertNotNil(event.body); + XCTAssertTrue([event.body isKindOfClass:[RollbarTelemetryNetworkBody class]]); + + type = RollbarTelemetryType_Connectivity; + event = [[RollbarTelemetryEvent alloc] initWithLevel:level + telemetryType:type + source:source]; + XCTAssertEqual(event.level, level); + XCTAssertEqual(event.source, source); + XCTAssertEqual(event.type, type); + XCTAssertNotNil(event.body); + XCTAssertTrue( + [event.body isKindOfClass:[RollbarTelemetryConnectivityBody class]]); + + type = RollbarTelemetryType_Manual; + event = [[RollbarTelemetryEvent alloc] initWithLevel:level + telemetryType:type + source:source]; + XCTAssertEqual(event.level, level); + XCTAssertEqual(event.source, source); + XCTAssertEqual(event.type, type); + XCTAssertNotNil(event.body); + XCTAssertTrue([event.body isKindOfClass:[RollbarTelemetryManualBody class]]); } --(void)testRollbarTelemetryEventDTO_Log { - - RollbarLevel level = RollbarLevel_Warning; - RollbarSource source = RollbarSource_Server; - NSDictionary *extra = @{ - @"EXTRA1":@"extra_1", - @"EXTRA2":@"extra_2", - }; - RollbarTelemetryEvent *event = nil; - - NSString *logMessage = @"log message"; - RollbarTelemetryBody *body = [[RollbarTelemetryLogBody alloc] initWithMessage:logMessage - extraData:extra]; - - event = [[RollbarTelemetryEvent alloc] initWithLevel:level - source:source - body:body]; - XCTAssertEqual(event.level, level); - XCTAssertEqual(event.source, source); - XCTAssertEqual(event.type, RollbarTelemetryType_Log); - XCTAssertNotNil(event.body); - XCTAssertTrue([event.body isKindOfClass:[body class]]); - for (NSString *key in extra) { - XCTAssertEqual(event.body.jsonFriendlyData[key], extra[key]); - } - - XCTAssertEqual(((RollbarTelemetryLogBody *) event.body).message, logMessage); +- (void)testRollbarTelemetryEventDTO_Log { + + RollbarLevel level = RollbarLevel_Warning; + RollbarSource source = RollbarSource_Server; + NSDictionary *extra = @{ + @"EXTRA1" : @"extra_1", + @"EXTRA2" : @"extra_2", + }; + RollbarTelemetryEvent *event = nil; + + NSString *logMessage = @"log message"; + RollbarTelemetryBody *body = + [[RollbarTelemetryLogBody alloc] initWithMessage:logMessage + extraData:extra]; + + event = [[RollbarTelemetryEvent alloc] initWithLevel:level + source:source + body:body]; + XCTAssertEqual(event.level, level); + XCTAssertEqual(event.source, source); + XCTAssertEqual(event.type, RollbarTelemetryType_Log); + XCTAssertNotNil(event.body); + XCTAssertTrue([event.body isKindOfClass:[body class]]); + for (NSString *key in extra) { + XCTAssertEqual(event.body.jsonFriendlyData[key], extra[key]); + } + + XCTAssertEqual(((RollbarTelemetryLogBody *)event.body).message, logMessage); } --(void)testRollbarTelemetryEventDTO_View { - - RollbarLevel level = RollbarLevel_Warning; - RollbarSource source = RollbarSource_Server; - NSDictionary *extra = @{ - @"EXTRA1":@"extra_1", - @"EXTRA2":@"extra_2", - }; - RollbarTelemetryEvent *event = nil; - - NSString *viewElement = @"The element"; - RollbarTelemetryBody *body = [[RollbarTelemetryViewBody alloc] initWithElement:viewElement - extraData:extra]; - - event = [[RollbarTelemetryEvent alloc] initWithLevel:level - source:source - body:body]; - XCTAssertEqual(event.level, level); - XCTAssertEqual(event.source, source); - XCTAssertEqual(event.type, RollbarTelemetryType_View); - XCTAssertNotNil(event.body); - XCTAssertTrue([event.body isKindOfClass:[body class]]); - for (NSString *key in extra) { - XCTAssertEqual(event.body.jsonFriendlyData[key], extra[key]); - } - - XCTAssertEqual(((RollbarTelemetryViewBody *) event.body).element, viewElement); +- (void)testRollbarTelemetryEventDTO_View { + + RollbarLevel level = RollbarLevel_Warning; + RollbarSource source = RollbarSource_Server; + NSDictionary *extra = @{ + @"EXTRA1" : @"extra_1", + @"EXTRA2" : @"extra_2", + }; + RollbarTelemetryEvent *event = nil; + + NSString *viewElement = @"The element"; + RollbarTelemetryBody *body = + [[RollbarTelemetryViewBody alloc] initWithElement:viewElement + extraData:extra]; + + event = [[RollbarTelemetryEvent alloc] initWithLevel:level + source:source + body:body]; + XCTAssertEqual(event.level, level); + XCTAssertEqual(event.source, source); + XCTAssertEqual(event.type, RollbarTelemetryType_View); + XCTAssertNotNil(event.body); + XCTAssertTrue([event.body isKindOfClass:[body class]]); + for (NSString *key in extra) { + XCTAssertEqual(event.body.jsonFriendlyData[key], extra[key]); + } + + XCTAssertEqual(((RollbarTelemetryViewBody *)event.body).element, viewElement); } --(void)testRollbarTelemetryEventDTO_Error { - - RollbarLevel level = RollbarLevel_Warning; - RollbarSource source = RollbarSource_Server; - NSDictionary *extra = @{ - @"EXTRA1":@"extra_1", - @"EXTRA2":@"extra_2", - }; - RollbarTelemetryEvent *event = nil; - - NSString *logMessage = @"error message"; - RollbarTelemetryBody *body = [[RollbarTelemetryErrorBody alloc] initWithMessage:logMessage - extraData:extra]; - - event = [[RollbarTelemetryEvent alloc] initWithLevel:level - source:source - body:body]; - XCTAssertEqual(event.level, level); - XCTAssertEqual(event.source, source); - XCTAssertEqual(event.type, RollbarTelemetryType_Error); - XCTAssertNotNil(event.body); - XCTAssertTrue([event.body isKindOfClass:[body class]]); - for (NSString *key in extra) { - XCTAssertEqual(event.body.jsonFriendlyData[key], extra[key]); - } - - XCTAssertEqual(((RollbarTelemetryErrorBody *) event.body).message, logMessage); +- (void)testRollbarTelemetryEventDTO_Error { + + RollbarLevel level = RollbarLevel_Warning; + RollbarSource source = RollbarSource_Server; + NSDictionary *extra = @{ + @"EXTRA1" : @"extra_1", + @"EXTRA2" : @"extra_2", + }; + RollbarTelemetryEvent *event = nil; + + NSString *logMessage = @"error message"; + RollbarTelemetryBody *body = + [[RollbarTelemetryErrorBody alloc] initWithMessage:logMessage + extraData:extra]; + + event = [[RollbarTelemetryEvent alloc] initWithLevel:level + source:source + body:body]; + XCTAssertEqual(event.level, level); + XCTAssertEqual(event.source, source); + XCTAssertEqual(event.type, RollbarTelemetryType_Error); + XCTAssertNotNil(event.body); + XCTAssertTrue([event.body isKindOfClass:[body class]]); + for (NSString *key in extra) { + XCTAssertEqual(event.body.jsonFriendlyData[key], extra[key]); + } + + XCTAssertEqual(((RollbarTelemetryErrorBody *)event.body).message, logMessage); } --(void)testRollbarTelemetryEventDTO_Navigation { - - RollbarLevel level = RollbarLevel_Warning; - RollbarSource source = RollbarSource_Server; - NSDictionary *extra = @{ - @"EXTRA1":@"extra_1", - @"EXTRA2":@"extra_2", - }; - RollbarTelemetryEvent *event = nil; - - NSString *from = @"FROM"; - NSString *to = @"TO"; - RollbarTelemetryBody *body = [[RollbarTelemetryNavigationBody alloc] initWithFromLocation:from - toLocation:to - extraData:extra]; - - event = [[RollbarTelemetryEvent alloc] initWithLevel:level - source:source - body:body]; - XCTAssertEqual(event.level, level); - XCTAssertEqual(event.source, source); - XCTAssertEqual(event.type, RollbarTelemetryType_Navigation); - XCTAssertNotNil(event.body); - XCTAssertTrue([event.body isKindOfClass:[body class]]); - for (NSString *key in extra) { - XCTAssertEqual(event.body.jsonFriendlyData[key], extra[key]); - } - - XCTAssertEqual(((RollbarTelemetryNavigationBody *) event.body).from, from); - XCTAssertEqual(((RollbarTelemetryNavigationBody *) event.body).to, to); +- (void)testRollbarTelemetryEventDTO_Navigation { + + RollbarLevel level = RollbarLevel_Warning; + RollbarSource source = RollbarSource_Server; + NSDictionary *extra = @{ + @"EXTRA1" : @"extra_1", + @"EXTRA2" : @"extra_2", + }; + RollbarTelemetryEvent *event = nil; + + NSString *from = @"FROM"; + NSString *to = @"TO"; + RollbarTelemetryBody *body = + [[RollbarTelemetryNavigationBody alloc] initWithFromLocation:from + toLocation:to + extraData:extra]; + + event = [[RollbarTelemetryEvent alloc] initWithLevel:level + source:source + body:body]; + XCTAssertEqual(event.level, level); + XCTAssertEqual(event.source, source); + XCTAssertEqual(event.type, RollbarTelemetryType_Navigation); + XCTAssertNotNil(event.body); + XCTAssertTrue([event.body isKindOfClass:[body class]]); + for (NSString *key in extra) { + XCTAssertEqual(event.body.jsonFriendlyData[key], extra[key]); + } + + XCTAssertEqual(((RollbarTelemetryNavigationBody *)event.body).from, from); + XCTAssertEqual(((RollbarTelemetryNavigationBody *)event.body).to, to); } --(void)testRollbarTelemetryEventDTO_Network { - - RollbarLevel level = RollbarLevel_Warning; - RollbarSource source = RollbarSource_Server; - NSDictionary *extra = @{ - @"EXTRA1":@"extra_1", - @"EXTRA2":@"extra_2", - }; - RollbarTelemetryEvent *event = nil; - - RollbarHttpMethod method = RollbarHttpMethod_Patch; - NSString *url = @"URL"; - NSString *statusCode = @"STATUS_CODE"; - RollbarTelemetryBody *body = [[RollbarTelemetryNetworkBody alloc] initWithMethod:method - url:url - statusCode:statusCode - extraData:extra]; - - event = [[RollbarTelemetryEvent alloc] initWithLevel:level - source:source - body:body]; - XCTAssertEqual(event.level, level); - XCTAssertEqual(event.source, source); - XCTAssertEqual(event.type, RollbarTelemetryType_Network); - XCTAssertNotNil(event.body); - XCTAssertTrue([event.body isKindOfClass:[body class]]); - for (NSString *key in extra) { - XCTAssertEqual(event.body.jsonFriendlyData[key], extra[key]); - } - - XCTAssertEqual(((RollbarTelemetryNetworkBody *) event.body).method, method); - XCTAssertEqual(((RollbarTelemetryNetworkBody *) event.body).url, url); - XCTAssertEqual(((RollbarTelemetryNetworkBody *) event.body).statusCode, statusCode); +- (void)testRollbarTelemetryEventDTO_Network { + + RollbarLevel level = RollbarLevel_Warning; + RollbarSource source = RollbarSource_Server; + NSDictionary *extra = @{ + @"EXTRA1" : @"extra_1", + @"EXTRA2" : @"extra_2", + }; + RollbarTelemetryEvent *event = nil; + + RollbarHttpMethod method = RollbarHttpMethod_Patch; + NSString *url = @"URL"; + NSString *statusCode = @"STATUS_CODE"; + RollbarTelemetryBody *body = + [[RollbarTelemetryNetworkBody alloc] initWithMethod:method + url:url + statusCode:statusCode + extraData:extra]; + + event = [[RollbarTelemetryEvent alloc] initWithLevel:level + source:source + body:body]; + XCTAssertEqual(event.level, level); + XCTAssertEqual(event.source, source); + XCTAssertEqual(event.type, RollbarTelemetryType_Network); + XCTAssertNotNil(event.body); + XCTAssertTrue([event.body isKindOfClass:[body class]]); + for (NSString *key in extra) { + XCTAssertEqual(event.body.jsonFriendlyData[key], extra[key]); + } + + XCTAssertEqual(((RollbarTelemetryNetworkBody *)event.body).method, method); + XCTAssertEqual(((RollbarTelemetryNetworkBody *)event.body).url, url); + XCTAssertEqual(((RollbarTelemetryNetworkBody *)event.body).statusCode, + statusCode); } --(void)testRollbarTelemetryEventDTO_Connectivity { - - RollbarLevel level = RollbarLevel_Warning; - RollbarSource source = RollbarSource_Server; - NSDictionary *extra = @{ - @"EXTRA1":@"extra_1", - @"EXTRA2":@"extra_2", - }; - RollbarTelemetryEvent *event = nil; - - NSString *status = @"STATUS_GOOD"; - RollbarTelemetryBody *body = [[RollbarTelemetryConnectivityBody alloc] initWithStatus:status - extraData:extra]; - - event = [[RollbarTelemetryEvent alloc] initWithLevel:level - source:source - body:body]; - XCTAssertEqual(event.level, level); - XCTAssertEqual(event.source, source); - XCTAssertEqual(event.type, RollbarTelemetryType_Connectivity); - XCTAssertNotNil(event.body); - XCTAssertTrue([event.body isKindOfClass:[body class]]); - for (NSString *key in extra) { - XCTAssertEqual(event.body.jsonFriendlyData[key], extra[key]); - } - - XCTAssertEqual(((RollbarTelemetryConnectivityBody *) event.body).status, status); +- (void)testRollbarTelemetryEventDTO_Connectivity { + + RollbarLevel level = RollbarLevel_Warning; + RollbarSource source = RollbarSource_Server; + NSDictionary *extra = @{ + @"EXTRA1" : @"extra_1", + @"EXTRA2" : @"extra_2", + }; + RollbarTelemetryEvent *event = nil; + + NSString *status = @"STATUS_GOOD"; + RollbarTelemetryBody *body = + [[RollbarTelemetryConnectivityBody alloc] initWithStatus:status + extraData:extra]; + + event = [[RollbarTelemetryEvent alloc] initWithLevel:level + source:source + body:body]; + XCTAssertEqual(event.level, level); + XCTAssertEqual(event.source, source); + XCTAssertEqual(event.type, RollbarTelemetryType_Connectivity); + XCTAssertNotNil(event.body); + XCTAssertTrue([event.body isKindOfClass:[body class]]); + for (NSString *key in extra) { + XCTAssertEqual(event.body.jsonFriendlyData[key], extra[key]); + } + + XCTAssertEqual(((RollbarTelemetryConnectivityBody *)event.body).status, + status); } --(void)testRollbarTelemetryEventDTO_Manual { - - RollbarLevel level = RollbarLevel_Warning; - RollbarSource source = RollbarSource_Server; - NSDictionary *extra = @{ - @"EXTRA1":@"extra_1", - @"EXTRA2":@"extra_2", - }; - RollbarTelemetryEvent *event = nil; - - RollbarTelemetryBody *body = [[RollbarTelemetryManualBody alloc] initWithDictionary:extra]; - - event = [[RollbarTelemetryEvent alloc] initWithLevel:level - source:source - body:body]; - XCTAssertEqual(event.level, level); - XCTAssertEqual(event.source, source); - XCTAssertEqual(event.type, RollbarTelemetryType_Manual); - XCTAssertNotNil(event.body); - XCTAssertTrue([event.body isKindOfClass:[body class]]); - for (NSString *key in extra) { - XCTAssertEqual(event.body.jsonFriendlyData[key], extra[key]); - } +- (void)testRollbarTelemetryEventDTO_Manual { + + RollbarLevel level = RollbarLevel_Warning; + RollbarSource source = RollbarSource_Server; + NSDictionary *extra = @{ + @"EXTRA1" : @"extra_1", + @"EXTRA2" : @"extra_2", + }; + RollbarTelemetryEvent *event = nil; + + RollbarTelemetryBody *body = + [[RollbarTelemetryManualBody alloc] initWithDictionary:extra]; + + event = [[RollbarTelemetryEvent alloc] initWithLevel:level + source:source + body:body]; + XCTAssertEqual(event.level, level); + XCTAssertEqual(event.source, source); + XCTAssertEqual(event.type, RollbarTelemetryType_Manual); + XCTAssertNotNil(event.body); + XCTAssertTrue([event.body isKindOfClass:[body class]]); + for (NSString *key in extra) { + XCTAssertEqual(event.body.jsonFriendlyData[key], extra[key]); + } } @end diff --git a/RollbarNotifier/Tests/RollbarNotifierTests/RollbarNotifierDTOsTests.swift b/RollbarNotifier/Tests/RollbarNotifierTests/RollbarNotifierDTOsTests.swift index 6e9e2306..719f3033 100644 --- a/RollbarNotifier/Tests/RollbarNotifierTests/RollbarNotifierDTOsTests.swift +++ b/RollbarNotifier/Tests/RollbarNotifierTests/RollbarNotifierDTOsTests.swift @@ -218,8 +218,8 @@ final class RollbarNotifierDTOsTests: XCTestCase { XCTAssertTrue(.orderedSame == dto.name!.compare("MN1"), "Proper name" ); - dto.version = "v3.3.2"; - XCTAssertTrue(.orderedSame == dto.version!.compare("v3.3.2"), + dto.version = "v3.3.3"; + XCTAssertTrue(.orderedSame == dto.version!.compare("v3.3.3"), "Proper version" ); diff --git a/RollbarReport.podspec b/RollbarReport.podspec index 0c4d8682..38fe897c 100644 --- a/RollbarReport.podspec +++ b/RollbarReport.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "RollbarReport" - s.version = "3.3.2" + s.version = "3.3.3" s.summary = "Application or client side SDK for interacting with the Rollbar API Server." s.description = <<-DESC Find, fix, and resolve errors with Rollbar.