Skip to content

Commit

Permalink
Merge pull request #834 from urbanairship/MB-1257
Browse files Browse the repository at this point in the history
[MB-1257] iOS: Fix Nullability Warnings
  • Loading branch information
crow committed Jul 2, 2015
2 parents 45029d3 + 476e88c commit ff45334
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 33 deletions.
22 changes: 11 additions & 11 deletions AirshipLib/AirshipLogicTests/UAChannelAPIClientTest.m
Expand Up @@ -76,7 +76,7 @@ - (void)testCreateChannelRetriesFailedRequests {

for (NSInteger i = 500; i < 600; i++) {
UAHTTPRequest *request = [[UAHTTPRequest alloc] init];
request.response = [[NSHTTPURLResponse alloc] initWithURL:nil statusCode:i HTTPVersion:nil headerFields:nil];
request.response = [[NSHTTPURLResponse alloc] initWithURL:[NSURL URLWithString:@""] statusCode:i HTTPVersion:nil headerFields:nil];

// If shouldRetryOnConnection is NO, never retry
self.client.shouldRetryOnConnectionError = NO;
Expand All @@ -98,7 +98,7 @@ - (void)testCreateChannelRetriesFailedRequests {

// Check that it returns NO for 400 status codes
UAHTTPRequest *request = [[UAHTTPRequest alloc] init];
request.response = [[NSHTTPURLResponse alloc] initWithURL:nil statusCode:400 HTTPVersion:nil headerFields:nil];
request.response = [[NSHTTPURLResponse alloc] initWithURL:[NSURL URLWithString:@""] statusCode:400 HTTPVersion:nil headerFields:nil];
if (retryBlock(request)) {
return NO;
}
Expand All @@ -125,17 +125,17 @@ - (void)testCreateChannelSucceedsRequest {
UAHTTPRequestEngineWhereBlock whereBlock = obj;
UAHTTPRequest *request = [[UAHTTPRequest alloc] init];

request.response = [[NSHTTPURLResponse alloc] initWithURL:nil statusCode:200 HTTPVersion:nil headerFields:nil];
request.response = [[NSHTTPURLResponse alloc] initWithURL:[NSURL URLWithString:@""] statusCode:200 HTTPVersion:nil headerFields:nil];
if (!whereBlock(request)) {
return NO;
}

request.response = [[NSHTTPURLResponse alloc] initWithURL:nil statusCode:201 HTTPVersion:nil headerFields:nil];
request.response = [[NSHTTPURLResponse alloc] initWithURL:[NSURL URLWithString:@""] statusCode:201 HTTPVersion:nil headerFields:nil];
if (!whereBlock(request)) {
return NO;
}

request.response = [[NSHTTPURLResponse alloc] initWithURL:nil statusCode:400 HTTPVersion:nil headerFields:nil];
request.response = [[NSHTTPURLResponse alloc] initWithURL:[NSURL URLWithString:@""] statusCode:400 HTTPVersion:nil headerFields:nil];
if (whereBlock(request)) {
return NO;
}
Expand Down Expand Up @@ -166,7 +166,7 @@ - (void)testCreateChannelOnSuccess {
NSString *response = @"{ \"ok\":true, \"channel_id\": \"someChannelID\"}";
request.responseData = [response dataUsingEncoding:NSUTF8StringEncoding];

request.response = [[NSHTTPURLResponse alloc] initWithURL:nil statusCode:200 HTTPVersion:nil headerFields:@{@"Location":@"someChannelLocation"}];
request.response = [[NSHTTPURLResponse alloc] initWithURL:[NSURL URLWithString:@""] statusCode:200 HTTPVersion:nil headerFields:@{@"Location":@"someChannelLocation"}];

// Expect the run request and call the success block
[[[self.mockRequestEngine stub] andDo:^(NSInvocation *invocation) {
Expand Down Expand Up @@ -271,7 +271,7 @@ - (void)testUpdateChannelRetriesFailedRequests {

for (NSInteger i = 500; i < 600; i++) {
UAHTTPRequest *request = [[UAHTTPRequest alloc] init];
request.response = [[NSHTTPURLResponse alloc] initWithURL:nil statusCode:i HTTPVersion:nil headerFields:nil];
request.response = [[NSHTTPURLResponse alloc] initWithURL:[NSURL URLWithString:@""] statusCode:i HTTPVersion:nil headerFields:nil];

// If shouldRetryOnConnection is NO, never retry
self.client.shouldRetryOnConnectionError = NO;
Expand All @@ -288,7 +288,7 @@ - (void)testUpdateChannelRetriesFailedRequests {

// Check that it returns NO for 400 status codes
UAHTTPRequest *request = [[UAHTTPRequest alloc] init];
request.response = [[NSHTTPURLResponse alloc] initWithURL:nil statusCode:400 HTTPVersion:nil headerFields:nil];
request.response = [[NSHTTPURLResponse alloc] initWithURL:[NSURL URLWithString:@""] statusCode:400 HTTPVersion:nil headerFields:nil];
if (retryBlock(request)) {
return NO;
}
Expand All @@ -315,17 +315,17 @@ - (void)testUpdateChannelSucceedsRequest {
UAHTTPRequestEngineWhereBlock whereBlock = obj;
UAHTTPRequest *request = [[UAHTTPRequest alloc] init];

request.response = [[NSHTTPURLResponse alloc] initWithURL:nil statusCode:200 HTTPVersion:nil headerFields:nil];
request.response = [[NSHTTPURLResponse alloc] initWithURL:[NSURL URLWithString:@""] statusCode:200 HTTPVersion:nil headerFields:nil];
if (!whereBlock(request)) {
return NO;
}

request.response = [[NSHTTPURLResponse alloc] initWithURL:nil statusCode:201 HTTPVersion:nil headerFields:nil];
request.response = [[NSHTTPURLResponse alloc] initWithURL:[NSURL URLWithString:@""] statusCode:201 HTTPVersion:nil headerFields:nil];
if (!whereBlock(request)) {
return NO;
}

request.response = [[NSHTTPURLResponse alloc] initWithURL:nil statusCode:400 HTTPVersion:nil headerFields:nil];
request.response = [[NSHTTPURLResponse alloc] initWithURL:[NSURL URLWithString:@""] statusCode:400 HTTPVersion:nil headerFields:nil];
if (whereBlock(request)) {
return NO;
}
Expand Down
4 changes: 2 additions & 2 deletions AirshipLib/AirshipLogicTests/UAChannelRegistrarTest.m
Expand Up @@ -311,7 +311,7 @@ - (void)testCancelAllRequests {
* create a new channel ID.
*/
- (void)testChannelConflictNewChannel {
self.channelFailureRequest.response = [[NSHTTPURLResponse alloc] initWithURL:nil statusCode:409 HTTPVersion:nil headerFields:nil];
self.channelFailureRequest.response = [[NSHTTPURLResponse alloc] initWithURL:[NSURL URLWithString:@""] statusCode:409 HTTPVersion:nil headerFields:nil];

//Expect the channel client to update channel and call the update block
[[[self.mockedChannelClient expect] andDo:channelUpdateFailureDoBlock] updateChannelWithLocation:@"someLocation"
Expand Down Expand Up @@ -341,7 +341,7 @@ - (void)testChannelConflictNewChannel {
* channel.
*/
- (void)testChannelConflictFailed {
self.channelFailureRequest.response = [[NSHTTPURLResponse alloc] initWithURL:nil statusCode:409 HTTPVersion:nil headerFields:nil];
self.channelFailureRequest.response = [[NSHTTPURLResponse alloc] initWithURL:[NSURL URLWithString:@""] statusCode:409 HTTPVersion:nil headerFields:nil];

//Expect the channel client to update channel and call the update block
[[[self.mockedChannelClient expect] andDo:channelUpdateFailureDoBlock] updateChannelWithLocation:@"someLocation"
Expand Down
12 changes: 6 additions & 6 deletions AirshipLib/AirshipLogicTests/UANamedUserAPIClientTest.m
Expand Up @@ -74,7 +74,7 @@ - (void)testAssociateRetriesFailedRequests {

for (NSInteger i = 500; i < 600; i++) {
UAHTTPRequest *request = [[UAHTTPRequest alloc] init];
request.response = [[NSHTTPURLResponse alloc] initWithURL:nil statusCode:i HTTPVersion:nil headerFields:nil];
request.response = [[NSHTTPURLResponse alloc] initWithURL:[NSURL URLWithString:@""] statusCode:i HTTPVersion:nil headerFields:nil];

// If shouldRetryOnConnection is NO, never retry
self.client.shouldRetryOnConnectionError = NO;
Expand All @@ -95,7 +95,7 @@ - (void)testAssociateRetriesFailedRequests {

// Check that it returns NO for 400 status codes
UAHTTPRequest *request = [[UAHTTPRequest alloc] init];
request.response = [[NSHTTPURLResponse alloc] initWithURL:nil statusCode:400 HTTPVersion:nil headerFields:nil];
request.response = [[NSHTTPURLResponse alloc] initWithURL:[NSURL URLWithString:@""] statusCode:400 HTTPVersion:nil headerFields:nil];
if (retryBlock(request)) {
return NO;
}
Expand Down Expand Up @@ -123,7 +123,7 @@ -(void)testAssociateSucceedsRequest {

for (NSInteger i = 200; i < 300; i++) {
UAHTTPRequest *request = [[UAHTTPRequest alloc] init];
request.response = [[NSHTTPURLResponse alloc] initWithURL:nil statusCode:i HTTPVersion:nil headerFields:nil];
request.response = [[NSHTTPURLResponse alloc] initWithURL:[NSURL URLWithString:@""] statusCode:i HTTPVersion:nil headerFields:nil];
if (!whereBlock(request)) {
return NO;
}
Expand Down Expand Up @@ -205,7 +205,7 @@ - (void)testDisassociateRetriesFailedRequests {

for (NSInteger i = 500; i < 600; i++) {
UAHTTPRequest *request = [[UAHTTPRequest alloc] init];
request.response = [[NSHTTPURLResponse alloc] initWithURL:nil statusCode:i HTTPVersion:nil headerFields:nil];
request.response = [[NSHTTPURLResponse alloc] initWithURL:[NSURL URLWithString:@""] statusCode:i HTTPVersion:nil headerFields:nil];

// If shouldRetryOnConnection is NO, never retry
self.client.shouldRetryOnConnectionError = NO;
Expand All @@ -226,7 +226,7 @@ - (void)testDisassociateRetriesFailedRequests {

// Check that it returns NO for 400 status codes
UAHTTPRequest *request = [[UAHTTPRequest alloc] init];
request.response = [[NSHTTPURLResponse alloc] initWithURL:nil statusCode:400 HTTPVersion:nil headerFields:nil];
request.response = [[NSHTTPURLResponse alloc] initWithURL:[NSURL URLWithString:@""] statusCode:400 HTTPVersion:nil headerFields:nil];
if (retryBlock(request)) {
return NO;
}
Expand Down Expand Up @@ -254,7 +254,7 @@ -(void)testDisassociateSucceedsRequest {

for (NSInteger i = 200; i < 300; i++) {
UAHTTPRequest *request = [[UAHTTPRequest alloc] init];
request.response = [[NSHTTPURLResponse alloc] initWithURL:nil statusCode:i HTTPVersion:nil headerFields:nil];
request.response = [[NSHTTPURLResponse alloc] initWithURL:[NSURL URLWithString:@""] statusCode:i HTTPVersion:nil headerFields:nil];
if (!whereBlock(request)) {
return NO;
}
Expand Down
12 changes: 6 additions & 6 deletions AirshipLib/AirshipLogicTests/UATagGroupsAPIClientTest.m
Expand Up @@ -90,7 +90,7 @@ - (void)testUpdateChannelTagsRetriesFailedRequest {

for (NSInteger i = 500; i < 600; i++) {
UAHTTPRequest *request = [[UAHTTPRequest alloc] init];
request.response = [[NSHTTPURLResponse alloc] initWithURL:nil statusCode:i HTTPVersion:nil headerFields:nil];
request.response = [[NSHTTPURLResponse alloc] initWithURL:[NSURL URLWithString:@""] statusCode:i HTTPVersion:nil headerFields:nil];

// If shouldRetryOnConnection is NO, never retry
self.client.shouldRetryOnConnectionError = NO;
Expand All @@ -111,7 +111,7 @@ - (void)testUpdateChannelTagsRetriesFailedRequest {

// Check that it returns NO for 400 status codes
UAHTTPRequest *request = [[UAHTTPRequest alloc] init];
request.response = [[NSHTTPURLResponse alloc] initWithURL:nil statusCode:400 HTTPVersion:nil headerFields:nil];
request.response = [[NSHTTPURLResponse alloc] initWithURL:[NSURL URLWithString:@""] statusCode:400 HTTPVersion:nil headerFields:nil];
if (retryBlock(request)) {
return NO;
}
Expand Down Expand Up @@ -144,7 +144,7 @@ - (void)testUpdateChannelTagsSucceedsRequest {

for (NSInteger i = 200; i < 300; i++) {
UAHTTPRequest *request = [[UAHTTPRequest alloc] init];
request.response = [[NSHTTPURLResponse alloc] initWithURL:nil statusCode:i HTTPVersion:nil headerFields:nil];
request.response = [[NSHTTPURLResponse alloc] initWithURL:[NSURL URLWithString:@""] statusCode:i HTTPVersion:nil headerFields:nil];
if (!whereBlock(request)) {
return NO;
}
Expand Down Expand Up @@ -348,7 +348,7 @@ - (void)testUpdateNamedUserTagsRetriesFailedRequest {

for (NSInteger i = 500; i < 600; i++) {
UAHTTPRequest *request = [[UAHTTPRequest alloc] init];
request.response = [[NSHTTPURLResponse alloc] initWithURL:nil statusCode:i HTTPVersion:nil headerFields:nil];
request.response = [[NSHTTPURLResponse alloc] initWithURL:[NSURL URLWithString:@""] statusCode:i HTTPVersion:nil headerFields:nil];

// If shouldRetryOnConnection is NO, never retry
self.client.shouldRetryOnConnectionError = NO;
Expand All @@ -369,7 +369,7 @@ - (void)testUpdateNamedUserTagsRetriesFailedRequest {

// Check that it returns NO for 400 status codes
UAHTTPRequest *request = [[UAHTTPRequest alloc] init];
request.response = [[NSHTTPURLResponse alloc] initWithURL:nil statusCode:400 HTTPVersion:nil headerFields:nil];
request.response = [[NSHTTPURLResponse alloc] initWithURL:[NSURL URLWithString:@""] statusCode:400 HTTPVersion:nil headerFields:nil];
if (retryBlock(request)) {
return NO;
}
Expand Down Expand Up @@ -401,7 +401,7 @@ - (void)testUpdateNamedUserTagsSucceedsRequest {

for (NSInteger i = 200; i < 300; i++) {
UAHTTPRequest *request = [[UAHTTPRequest alloc] init];
request.response = [[NSHTTPURLResponse alloc] initWithURL:nil statusCode:i HTTPVersion:nil headerFields:nil];
request.response = [[NSHTTPURLResponse alloc] initWithURL:[NSURL URLWithString:@""] statusCode:i HTTPVersion:nil headerFields:nil];
if (!whereBlock(request)) {
return NO;
}
Expand Down
12 changes: 6 additions & 6 deletions AirshipLib/AirshipLogicTests/UAUserAPIClientTest.m
Expand Up @@ -82,7 +82,7 @@ -(void)testCreateUserRetry {

for (NSInteger i = 500; i < 600; i++) {
UAHTTPRequest *request = [[UAHTTPRequest alloc] init];
request.response = [[NSHTTPURLResponse alloc] initWithURL:nil statusCode:i HTTPVersion:nil headerFields:nil];
request.response = [[NSHTTPURLResponse alloc] initWithURL:[NSURL URLWithString:@""] statusCode:i HTTPVersion:nil headerFields:nil];

if (!retryBlock(request)) {
return NO;
Expand All @@ -91,7 +91,7 @@ -(void)testCreateUserRetry {

// Check that it returns NO for 400 status codes
UAHTTPRequest *request = [[UAHTTPRequest alloc] init];
request.response = [[NSHTTPURLResponse alloc] initWithURL:nil statusCode:400 HTTPVersion:nil headerFields:nil];
request.response = [[NSHTTPURLResponse alloc] initWithURL:[NSURL URLWithString:@""] statusCode:400 HTTPVersion:nil headerFields:nil];
if (retryBlock(request)) {
return NO;
}
Expand All @@ -105,7 +105,7 @@ -(void)testCreateUserRetry {

// Check that it returns YES for 201
UAHTTPRequest *request = [[UAHTTPRequest alloc] init];
request.response = [[NSHTTPURLResponse alloc] initWithURL:nil statusCode:201 HTTPVersion:nil headerFields:nil];
request.response = [[NSHTTPURLResponse alloc] initWithURL:[NSURL URLWithString:@""] statusCode:201 HTTPVersion:nil headerFields:nil];
if (succeedsBlock(request)) {
return YES;
}
Expand Down Expand Up @@ -264,7 +264,7 @@ -(void)testUpdateUserRetry {

for (NSInteger i = 500; i < 600; i++) {
UAHTTPRequest *request = [[UAHTTPRequest alloc] init];
request.response = [[NSHTTPURLResponse alloc] initWithURL:nil statusCode:i HTTPVersion:nil headerFields:nil];
request.response = [[NSHTTPURLResponse alloc] initWithURL:[NSURL URLWithString:@""] statusCode:i HTTPVersion:nil headerFields:nil];

if (!retryBlock(request)) {
return NO;
Expand All @@ -273,7 +273,7 @@ -(void)testUpdateUserRetry {

// Check that it returns NO for 400 status codes
UAHTTPRequest *request = [[UAHTTPRequest alloc] init];
request.response = [[NSHTTPURLResponse alloc] initWithURL:nil statusCode:400 HTTPVersion:nil headerFields:nil];
request.response = [[NSHTTPURLResponse alloc] initWithURL:[NSURL URLWithString:@""] statusCode:400 HTTPVersion:nil headerFields:nil];
if (retryBlock(request)) {
return NO;
}
Expand All @@ -287,7 +287,7 @@ -(void)testUpdateUserRetry {

// Check that it returns YES for 201
UAHTTPRequest *request = [[UAHTTPRequest alloc] init];
request.response = [[NSHTTPURLResponse alloc] initWithURL:nil statusCode:201 HTTPVersion:nil headerFields:nil];
request.response = [[NSHTTPURLResponse alloc] initWithURL:[NSURL URLWithString:@""] statusCode:201 HTTPVersion:nil headerFields:nil];
if (succeedsBlock(request)) {
return YES;
}
Expand Down
2 changes: 1 addition & 1 deletion AirshipLib/AirshipLogicTests/UAWalletActionTest.m
Expand Up @@ -126,7 +126,7 @@ - (void)testRejectsDuplicatePass {

// Call the success block with a 200
UAHTTPRequest *request = [[UAHTTPRequest alloc] init];
request.response = [[NSHTTPURLResponse alloc] initWithURL:nil statusCode:200 HTTPVersion:nil headerFields:nil];
request.response = [[NSHTTPURLResponse alloc] initWithURL:[NSURL URLWithString:@""] statusCode:200 HTTPVersion:nil headerFields:nil];

request.responseData = [NSData data];

Expand Down
1 change: 0 additions & 1 deletion AirshipLib/AirshipLogicTests/UAWhitelistTest.m
Expand Up @@ -123,7 +123,6 @@ - (void)testSchemeWildcard {
[self.whitelist addEntry:@"*://www.urbanairship.com"];

// Reject
XCTAssertFalse([self.whitelist isWhitelisted:[NSURL URLWithString:nil]]);
XCTAssertFalse([self.whitelist isWhitelisted:[NSURL URLWithString:@""]]);
XCTAssertFalse([self.whitelist isWhitelisted:[NSURL URLWithString:@"urbanairship.com"]]);
XCTAssertFalse([self.whitelist isWhitelisted:[NSURL URLWithString:@"www.urbanairship.com"]]);
Expand Down

0 comments on commit ff45334

Please sign in to comment.