Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding new test case, to show the entire (current) API; Running again…
…st RHCLOUD.....
- Loading branch information
Showing
4 changed files
with
132 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// | ||
// AGPipelineUsecaseTests.h | ||
// AeroGear-iOS | ||
// | ||
// Created by matzew on 24.08.12. | ||
// Copyright (c) 2012 JBoss. All rights reserved. | ||
// | ||
|
||
#import <SenTestingKit/SenTestingKit.h> | ||
|
||
@interface AGPipelineUsecaseTests : SenTestCase | ||
|
||
@end |
113 changes: 113 additions & 0 deletions
113
AeroGear-iOS/AeroGear-iOSTests/AGPipelineUsecaseTests.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
// | ||
// AGPipelineUsecaseTests.m | ||
// AeroGear-iOS | ||
// | ||
// Created by matzew on 24.08.12. | ||
// Copyright (c) 2012 JBoss. All rights reserved. | ||
// | ||
|
||
#import "AGPipelineUsecaseTests.h" | ||
#import "AGPipeline.h" | ||
#import "AGPipe.h" | ||
|
||
@implementation AGPipelineUsecaseTests { | ||
BOOL _finishedFlag; | ||
|
||
id<AGPipe> projects; | ||
} | ||
|
||
// TODO: static hack... | ||
NSMutableDictionary* projectEntity; | ||
|
||
-(void)setUp { | ||
[super setUp]; | ||
_finishedFlag = NO; | ||
|
||
// basic setup, for every test: | ||
// create the 'todo' pipeline; | ||
NSURL* projectsURL = [NSURL URLWithString:@"http://todo-aerogear.rhcloud.com/todo-server/projects/"]; | ||
AGPipeline* todo = [AGPipeline pipelineWithPipe:@"projects" url:projectsURL type:@"REST"]; | ||
|
||
// get access to the projects pipe | ||
projects = [todo get:@"projects"]; | ||
|
||
|
||
} | ||
|
||
-(void)tearDown { | ||
projects = nil; | ||
[super tearDown]; | ||
} | ||
|
||
-(void) testCreateTodoPipelineAndCreateProject{ | ||
// PIPELINE is created in setup | ||
|
||
|
||
// create a 'new' project entity... | ||
// using NS(Mutable)Dictionary, for now.......... | ||
|
||
projectEntity = [NSMutableDictionary dictionary]; | ||
[projectEntity setValue:@"Hello World" forKey:@"title"]; | ||
|
||
|
||
// save the 'new' project: | ||
[projects save:projectEntity success:^(id responseObject) { | ||
NSLog(@"CREATE RESPONSE\n%@", [responseObject description]); | ||
|
||
// get the id of the new project: | ||
id resourceId = [responseObject valueForKey:@"id"]; | ||
// update the 'object'..... | ||
[projectEntity setValue:[resourceId stringValue] forKey:@"id"]; | ||
|
||
_finishedFlag = YES; | ||
|
||
} failure:^(NSError *error) { | ||
|
||
NSLog(@"SAVE: An error occured! \n%@", error); | ||
}]; | ||
|
||
|
||
while(!_finishedFlag) { | ||
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]; | ||
} | ||
} | ||
|
||
|
||
-(void) testCreateTodoPipelineAndUpdateProject{ | ||
|
||
// change the title of the project: | ||
[projectEntity setValue:@"Hello Update World!" forKey:@"title"]; | ||
|
||
|
||
[projects save:projectEntity success:^(id responseObject) { | ||
NSLog(@"UPDATE RESPONSE\n%@", [responseObject description]); | ||
_finishedFlag = YES; | ||
|
||
} failure:^(NSError *error) { | ||
|
||
NSLog(@"UPDATE: An error occured! \n%@", error); | ||
}]; | ||
|
||
|
||
while(!_finishedFlag) { | ||
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]; | ||
} | ||
} | ||
|
||
-(void) testCreateTodoPipelineAnd_RemoveProject{ | ||
// just remove this project: | ||
[projects remove:[projectEntity objectForKey:@"id"] success:^(id responseObject) { | ||
NSLog(@"DELETE RESPONSE\n%@", [responseObject description]); | ||
_finishedFlag = YES; | ||
|
||
} failure:^(NSError *error) { | ||
|
||
NSLog(@"DELETE: An error occured! \n%@", error); | ||
}]; | ||
while(!_finishedFlag) { | ||
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]; | ||
} | ||
} | ||
|
||
|
||
@end |