diff --git a/IoTKitLib/IoTKitLib/ComponentCatalogManagement.m b/IoTKitLib/IoTKitLib/ComponentCatalogManagement.m
index 7aa4c93..db93356 100644
--- a/IoTKitLib/IoTKitLib/ComponentCatalogManagement.m
+++ b/IoTKitLib/IoTKitLib/ComponentCatalogManagement.m
@@ -245,7 +245,7 @@ -(CloudResponse *)createCustomComponent:(ComponentCatalog *)createComponentCatal
return [CloudResponse createCloudResponseWithStatus:false andMessage:[NSString stringWithFormat:@"%@:ComponentCatalog need to be initialized & configured to create component",TAG]];
}
NSString *msg = [self validateActuatorCommand:createComponentCatalog];
- if (!msg) {
+ if (msg) {
return [CloudResponse createCloudResponseWithStatus:false andMessage:msg];
}
NSData *data = [self createBodyForCreationOfCustomComponent:createComponentCatalog];
@@ -280,7 +280,7 @@ -(CloudResponse *)updateAComponent:(ComponentCatalog *)updateComponentCatalog
return [CloudResponse createCloudResponseWithStatus:false andMessage:[NSString stringWithFormat:@"%@:ComponentCatalog need to be initialized & configured to update component",TAG]];
}
NSString *msg = [self validateActuatorCommand:updateComponentCatalog];
- if (!msg) {
+ if (msg) {
return [CloudResponse createCloudResponseWithStatus:false andMessage:msg];
}
NSData *data = [self createBodyForUpdationOfCustomComponent:updateComponentCatalog];
diff --git a/IoTKitLib/IoTKitLib/DataManagement.m b/IoTKitLib/IoTKitLib/DataManagement.m
index 3ea0148..508c994 100644
--- a/IoTKitLib/IoTKitLib/DataManagement.m
+++ b/IoTKitLib/IoTKitLib/DataManagement.m
@@ -147,7 +147,7 @@ -(CloudResponse *) submitDataOn:(NSString*) componentName AndValue:(NSString*) c
**************************************************************************************************************************/
-(CloudResponse *)retrieveDataOn:(ConfigureRetrieveData *)objRetrieveData{
NSString *msg = [self validateRetrieveDataValues:objRetrieveData];
- if (!msg) {
+ if (msg) {
return [CloudResponse createCloudResponseWithStatus:false andMessage:msg];
}
NSData *data = [self createHttpBodyToRetrieveData:objRetrieveData];
diff --git a/IoTKitLib/IoTKitLib/UserManagement.h b/IoTKitLib/IoTKitLib/UserManagement.h
index c113d55..cba7cdf 100644
--- a/IoTKitLib/IoTKitLib/UserManagement.h
+++ b/IoTKitLib/IoTKitLib/UserManagement.h
@@ -29,7 +29,7 @@
-(CloudResponse *) deleteUser:(NSString*)userId;
-(CloudResponse *) getUserInfo:(NSString*)userId;
-(CloudResponse *) updateUserAttributesOn:(NSString*) userId AndListOfAttributes:(NSDictionary*)listOfUserAttributes;
--(CloudResponse *) acceptTermsAndConditionsOn:(NSString*)userId Acceptance:(BOOL)isAccepted;
+//-(CloudResponse *) acceptTermsAndConditionsOn:(NSString*)userId Acceptance:(BOOL)isAccepted;
-(CloudResponse *) requestChangePasswordOn:(NSString*)emailId;
-(CloudResponse *) updateForgotPassword:(NSString*)mailToken AndNewPassword:(NSString*)newPassword;
-(CloudResponse *) changePasswordOn:(NSString*)emailId AndCurrentPassword:(NSString*)currentPassword
diff --git a/IoTKitLib/IoTKitLib/UserManagement.m b/IoTKitLib/IoTKitLib/UserManagement.m
index 934c81f..241956b 100644
--- a/IoTKitLib/IoTKitLib/UserManagement.m
+++ b/IoTKitLib/IoTKitLib/UserManagement.m
@@ -144,7 +144,7 @@ -(CloudResponse *) updateUserAttributesOn:(NSString*) userId AndListOfAttributes
* PARAMETERS : 1)userId
2)isAccepted(true/false)
**************************************************************************************************************************/
--(CloudResponse *) acceptTermsAndConditionsOn:(NSString*)userId Acceptance:(BOOL)isAccepted{
+/*-(CloudResponse *) acceptTermsAndConditionsOn:(NSString*)userId Acceptance:(BOOL)isAccepted{
NSString *tempUserId = [self validateAndGetUserId:userId];
if(!tempUserId){
return [CloudResponse createCloudResponseWithStatus:false andMessage:[NSString stringWithFormat:@"%@:userID empty and cannot find from user defaults",TAG]];
@@ -159,7 +159,7 @@ -(CloudResponse *) acceptTermsAndConditionsOn:(NSString*)userId Acceptance:(BOOL
AuthToken:self.getStoredAuthToken
DeviceToken:nil];
return [self initiateHttpOperation:httpOperation];
-}
+}*/
/***************************************************************************************************************************
* FUNCTION NAME: requestChangePasswordOn
*
@@ -332,7 +332,7 @@ -(NSData*)validateAndCreateHttpBodyForNewUser:(NSString*)emailId AndPassword:(NS
NSLog(@"%@:emailID and password are mandatory",TAG);
return nil;
}
- NSDictionary *newUserJson = [NSDictionary dictionaryWithObjectsAndKeys:emailId,EMAIL,password,PASSWORD,nil];
+ NSDictionary *newUserJson = [NSDictionary dictionaryWithObjectsAndKeys:emailId,EMAIL,password,PASSWORD,[NSNumber numberWithBool:true],@"termsAndConditions",nil];
NSError *error;
return [NSJSONSerialization dataWithJSONObject:newUserJson options:NSJSONWritingPrettyPrinted error:&error];
}
diff --git a/IoTKitLib/IoTKitLib/http/HttpRequestOperation.m b/IoTKitLib/IoTKitLib/http/HttpRequestOperation.m
index 288dd90..233657a 100644
--- a/IoTKitLib/IoTKitLib/http/HttpRequestOperation.m
+++ b/IoTKitLib/IoTKitLib/http/HttpRequestOperation.m
@@ -181,7 +181,7 @@ - (CloudResponse *)initiateAsyncRequest {
[self completeHandler:response onData:data AndError:error];
}];
- return [CloudResponse createCloudResponseWithStatus:true andMessage:@"initiateAsyncRequest"];
+ return [CloudResponse createCloudResponseWithStatus:true andMessage:@"initiatedAsyncRequest"];
}
/***************************************************************************************************************************
diff --git a/IoTTests/BasicSetup.h b/IoTTests/BasicSetup.h
index 9ca4c3e..8107b49 100644
--- a/IoTTests/BasicSetup.h
+++ b/IoTTests/BasicSetup.h
@@ -29,8 +29,6 @@
@interface BasicSetup : XCTestCase
--(void)configureResponseDelegateWithExpectedResponseCode:(NSInteger)expectedResponseCode;
--(void)waitForServerResponse;
-(NSString*)getRandomValueString;
-(NSString*)getRandomAccountName;
-(NSString*)getRandomDeviceName;
diff --git a/IoTTests/BasicSetup.m b/IoTTests/BasicSetup.m
index aa2ea95..274a0bd 100644
--- a/IoTTests/BasicSetup.m
+++ b/IoTTests/BasicSetup.m
@@ -27,49 +27,8 @@
#define RANDOM_RANGE_MAX 10000
#define RANDOM_RANGE_MAX_READING 100
-@interface BasicSetup ()
-
-@property(nonatomic,assign)NSInteger expectedResponseCode;
-@property(nonatomic,assign)NSInteger serverResponseCode;
-@property(nonatomic,assign)BOOL isServerResponded;
-@property(nonatomic,retain)NSString* serverResponseContent;
-@property(nonatomic,retain)HttpResponseDelegatee *responseDelegate;
-
-@end
-
@implementation BasicSetup
-/***************************************************************************************************************************
- * FUNCTION NAME: waitForServerResponse
- *
- * DESCRIPTION: method waits(UI thread) in active loop until server responsds for given request
- *
- * RETURNS: nothing
- *
- * PARAMETERS : nil
- **************************************************************************************************************************/
--(void)waitForServerResponse{
- @synchronized(self){
- while(!_isServerResponded){}
- _isServerResponded = false;
- XCTAssertEqual(_expectedResponseCode, _serverResponseCode,@"Server Response:%@", _serverResponseContent);
- }
-}
-
-/***************************************************************************************************************************
- * FUNCTION NAME: notifyServerResponse
- *
- * DESCRIPTION: method which notifies(updates _isServerResponded flag) when server responsds
- *
- * RETURNS: nothing
- *
- * PARAMETERS : nil
- **************************************************************************************************************************/
--(void)notifyServerResponse{
- _isServerResponded = true;
- CFRunLoopStop(CFRunLoopGetCurrent());
-}
-
/***************************************************************************************************************************
* FUNCTION NAME: setUp
*
@@ -81,8 +40,6 @@ -(void)notifyServerResponse{
**************************************************************************************************************************/
- (void)setUp {
[super setUp];
- _isServerResponded = false;
- _responseDelegate = [HttpResponseDelegatee sharedInstance];
}
/***************************************************************************************************************************
@@ -98,27 +55,6 @@ - (void)tearDown {
[super tearDown];
}
-/***************************************************************************************************************************
- * FUNCTION NAME: configureResponseDelegateWithExpectedResponseCode
- *
- * DESCRIPTION: method creates delegate receive server responses
- *
- * RETURNS: nothing
- *
- * PARAMETERS : expected response code
- **************************************************************************************************************************/
--(void)configureResponseDelegateWithExpectedResponseCode:(NSInteger)expectedResponseCode{
- __block BasicSetup *blockTest = self;
- __block HttpResponseDelegatee *blockResponseDelegate = _responseDelegate;
- blockResponseDelegate.readResponse = ^(CloudResponse *cloudResponse)
- {
- _expectedResponseCode = expectedResponseCode;
- _serverResponseCode = cloudResponse.responseCode;
- _serverResponseContent = cloudResponse.responseString;
- [blockTest notifyServerResponse];
- };
-}
-
/***************************************************************************************************************************
* FUNCTION NAME: getRandomValueString
*
diff --git a/IoTTests/Module_001_AuthorizationManagementTests.m b/IoTTests/Module_001_AuthorizationManagementTests.m
index ced4775..c4bf779 100644
--- a/IoTTests/Module_001_AuthorizationManagementTests.m
+++ b/IoTTests/Module_001_AuthorizationManagementTests.m
@@ -43,19 +43,17 @@ - (void)tearDown {
[super tearDown];
}
- (void)test_101_GetNewAuthorizationToken {
- [self configureResponseDelegateWithExpectedResponseCode:200];
- XCTAssertTrue([_authorizationObject getNewAuthorizationTokenWithUsername:@"intel.aricent.iot5@gmail.com" andPassword:@"Password2529"]);
- [self waitForServerResponse];
+ CloudResponse *response = [_authorizationObject getNewAuthorizationTokenWithUsername:@"intel.aricent.iot6@gmail.com" andPassword:@"Password2529"];
+ XCTAssertEqual(response.responseCode, 200);
+
}
- (void)test_103_GetAuthorizationTokenInfo {
- [self configureResponseDelegateWithExpectedResponseCode:200];
- XCTAssertTrue([_authorizationObject getAuthorizationTokenInfo]);
- [self waitForServerResponse];
+ CloudResponse *response = [_authorizationObject getAuthorizationTokenInfo];
+ XCTAssertEqual(response.responseCode, 200);
}
- (void)test_102_ValidateAuthorizationToken{
- [self configureResponseDelegateWithExpectedResponseCode:200];
- XCTAssertTrue([_authorizationObject validateAuthorizationToken]);
- [self waitForServerResponse];
+ CloudResponse *response = [_authorizationObject validateAuthorizationToken];
+ XCTAssertEqual(response.responseCode, 200);
}
@end
diff --git a/IoTTests/Module_002_AccountManagementTests.m b/IoTTests/Module_002_AccountManagementTests.m
index a95256c..07119d6 100644
--- a/IoTTests/Module_002_AccountManagementTests.m
+++ b/IoTTests/Module_002_AccountManagementTests.m
@@ -43,45 +43,37 @@ - (void)tearDown {
}
- (void)test_201_CreateAnAccount {
- [self configureResponseDelegateWithExpectedResponseCode:201];
- XCTAssertTrue([_accountManagementObject createAnAccount:[self getRandomAccountName]]);
- [self waitForServerResponse];
+ CloudResponse *response = [_accountManagementObject createAnAccount:[self getRandomAccountName]];
+ XCTAssertEqual(response.responseCode, 201);
}
- (void)test_202_GetNewAuthorizationToken{
- [self configureResponseDelegateWithExpectedResponseCode:200];
- AuthorizationManagement *auth = [[AuthorizationManagement alloc]init];
- XCTAssertTrue([auth getNewAuthorizationTokenWithUsername:@"intel.aricent.iot5@gmail.com" andPassword:@"Password2529"]);
- [self waitForServerResponse];
+ AuthorizationManagement *auth = [[AuthorizationManagement alloc]init];
+ CloudResponse *response = [auth getNewAuthorizationTokenWithUsername:@"intel.aricent.iot6@gmail.com" andPassword:@"Password2529"];
+ XCTAssertEqual(response.responseCode, 200);
}
- (void)test_203_GetAccountInformation {
- [self configureResponseDelegateWithExpectedResponseCode:200];
- XCTAssertTrue([_accountManagementObject getAccountInformation]);
- [self waitForServerResponse];
+ CloudResponse *response = [_accountManagementObject getAccountInformation];
+ XCTAssertEqual(response.responseCode, 200);
}
- (void)test_204_RenewAccountActivationCode {
- [self configureResponseDelegateWithExpectedResponseCode:200];
- XCTAssertTrue([_accountManagementObject renewAccountActivationCode]);
- [self waitForServerResponse];
+ CloudResponse *response = [_accountManagementObject renewAccountActivationCode];
+ XCTAssertEqual(response.responseCode, 200);
}
- (void)test_205_GetAccountActivationCode {
- [self configureResponseDelegateWithExpectedResponseCode:200];
- XCTAssertTrue([_accountManagementObject getAccountActivationCode]);
- [self waitForServerResponse];
+ CloudResponse *response = [_accountManagementObject getAccountActivationCode];
+ XCTAssertEqual(response.responseCode, 200);
}
- (void)test_206_AddAnotherUserToYourAccount {
- [self configureResponseDelegateWithExpectedResponseCode:200];
- XCTAssertTrue([_accountManagementObject addAnotherUserToAccount:[HttpUrlBuilder getAccountId] UserGettingInvited:@"545b0cb707024be10dec1152" Admin:false]);
- [self waitForServerResponse];
+ CloudResponse *response = [_accountManagementObject addAnotherUserToAccount:[HttpUrlBuilder getAccountId] UserGettingInvited:@"545b0cb707024be10dec1152" Admin:true];
+ XCTAssertEqual(response.responseCode, 200);
}
- (void)test_207_UpdateAnAccount {
- [self configureResponseDelegateWithExpectedResponseCode:200];
- XCTAssertTrue([_accountManagementObject updateAnAccount:[HttpUrlBuilder getAccountName]
- andOptionalAttributesWithSimpleKeyValues:nil]);
- [self waitForServerResponse];
+ CloudResponse *response = [_accountManagementObject updateAnAccount:[HttpUrlBuilder getAccountName]
+ andOptionalAttributesWithSimpleKeyValues:nil];
+ XCTAssertEqual(response.responseCode, 200);
}
- (void)test_208_DeleteAnAccount {
- [self configureResponseDelegateWithExpectedResponseCode:204];
- XCTAssertTrue([_accountManagementObject deleteAnAccount]);
- [self waitForServerResponse];
+ CloudResponse *response = [_accountManagementObject deleteAnAccount];
+ XCTAssertEqual(response.responseCode, 204);
}
@end
diff --git a/IoTTests/Module_003_DeviceManagementTests.m b/IoTTests/Module_003_DeviceManagementTests.m
index 90be7c2..276e05e 100644
--- a/IoTTests/Module_003_DeviceManagementTests.m
+++ b/IoTTests/Module_003_DeviceManagementTests.m
@@ -43,7 +43,6 @@ - (void)tearDown {
}
- (void)test_301_CreateNewDevice{
- [self configureResponseDelegateWithExpectedResponseCode:201];
NSString *devId = [self getRandomDeviceId];
Device *device = [Device createDeviceWithDeviceName:[self getRandomDeviceName]
andDeviceId:devId andGatewayId:devId];
@@ -54,11 +53,10 @@ - (void)test_301_CreateNewDevice{
[device addAttributeName:@"Camera" andValue:@"8MP"];
[device addAttributeName:@"Wifi" andValue:@"YES"];
[device addAttributeName:@"Retina Display" andValue:@"NO"];
- XCTAssertTrue([_deviceObject createNewDevice:device]);
- [self waitForServerResponse];
+ CloudResponse *response = [_deviceObject createNewDevice:device];
+ XCTAssertEqual(response.responseCode, 201);
}
- (void)test_302_UpdateADevice{
- [self configureResponseDelegateWithExpectedResponseCode:200];
Device *updateDevice = [Device createDeviceWithDeviceName:[self getRandomDeviceName]
andDeviceId:nil andGatewayId:[HttpUrlBuilder getDeviceId]];
[updateDevice addLocationInfo:15.0 AndLongitude:25.0 ANdHeight:20.0];
@@ -68,53 +66,44 @@ - (void)test_302_UpdateADevice{
[updateDevice addAttributeName:@"Camera" andValue:@"8MP"];
[updateDevice addAttributeName:@"Wifi" andValue:@"YES"];
[updateDevice addAttributeName:@"Retina Display" andValue:@"YES"];
- XCTAssertTrue([_deviceObject updateADevice:updateDevice]);
- [self waitForServerResponse];
+ CloudResponse *response = [_deviceObject updateADevice:updateDevice];
+ XCTAssertEqual(response.responseCode, 200);
}
- (void)test_303_GetDeviceList{
- [self configureResponseDelegateWithExpectedResponseCode:200];
- XCTAssertTrue([_deviceObject getDeviceList]);
- [self waitForServerResponse];
+ CloudResponse *response = [_deviceObject getDeviceList];
+ XCTAssertEqual(response.responseCode, 200);
}
- (void)test_304_GetMyDeviceInfo{
- [self configureResponseDelegateWithExpectedResponseCode:200];
- XCTAssertTrue([_deviceObject getMyDeviceInfo]);
- [self waitForServerResponse];
+ CloudResponse *response = [_deviceObject getMyDeviceInfo];
+ XCTAssertEqual(response.responseCode, 200);
}
- (void)test_305_GetInfoOnDevice{
- [self configureResponseDelegateWithExpectedResponseCode:200];
- XCTAssertTrue([_deviceObject getInfoOnDevice:[HttpUrlBuilder getDeviceId]]);
- [self waitForServerResponse];
+ CloudResponse *response = [_deviceObject getInfoOnDevice:[HttpUrlBuilder getDeviceId]];
+ XCTAssertEqual(response.responseCode, 200);
}
- (void)test_306_ActivateADevice{
- [self configureResponseDelegateWithExpectedResponseCode:200];
- XCTAssertTrue([_deviceObject activateADevice:[HttpUrlBuilder getAccountActivationCode]]);
- [self waitForServerResponse];
+ CloudResponse *response = [_deviceObject activateADevice:[HttpUrlBuilder getAccountActivationCode]];
+ XCTAssertEqual(response.responseCode, 200);
}
- (void)test_307_AddComponentToDevice{
- [self configureResponseDelegateWithExpectedResponseCode:201];
- XCTAssertTrue([_deviceObject addComponentToDevice:[self getRandomDeviceComponentName] WithType:@"temperature.v1.0"]);
- [self waitForServerResponse];
+ CloudResponse *response = [_deviceObject addComponentToDevice:[self getRandomDeviceComponentName] WithType:@"temperature.v1.0"];
+ XCTAssertEqual(response.responseCode, 201);
}
- (void)test_308_GetAllAttributes{
- [self configureResponseDelegateWithExpectedResponseCode:200];
- XCTAssertTrue([_deviceObject getAllAttributes]);
- [self waitForServerResponse];
+ CloudResponse *response = [_deviceObject getAllAttributes];
+ XCTAssertEqual(response.responseCode, 200);
}
- (void)test_309_GetAllTags{
- [self configureResponseDelegateWithExpectedResponseCode:200];
- XCTAssertTrue([_deviceObject getAllTags]);
- [self waitForServerResponse];
+ CloudResponse *response = [_deviceObject getAllTags];
+ XCTAssertEqual(response.responseCode, 200);
}
- (void)test_310_DeleteAComponent{
- [self configureResponseDelegateWithExpectedResponseCode:204];
- XCTAssertTrue([_deviceObject deleteAComponent:[HttpUrlBuilder getComponentName]]);
- [self waitForServerResponse];
+ CloudResponse *response = [_deviceObject deleteAComponent:[HttpUrlBuilder getComponentName]];
+ XCTAssertEqual(response.responseCode, 204);
}
- (void)test_311_DeleteADevice{
- [self configureResponseDelegateWithExpectedResponseCode:204];
- XCTAssertTrue([_deviceObject deleteADevice:[HttpUrlBuilder getDeviceId]]);
- [self waitForServerResponse];
+ CloudResponse *response = [_deviceObject deleteADevice:[HttpUrlBuilder getDeviceId]];
+ XCTAssertEqual(response.responseCode, 204);
}
@end
diff --git a/IoTTests/Module_004_ComponentCatalogManagementTests.m b/IoTTests/Module_004_ComponentCatalogManagementTests.m
index 6564f93..7dbcd24 100644
--- a/IoTTests/Module_004_ComponentCatalogManagementTests.m
+++ b/IoTTests/Module_004_ComponentCatalogManagementTests.m
@@ -42,22 +42,18 @@ - (void)tearDown {
[super tearDown];
}
- (void)test_401_ListAllComponentTypesCatalog{
- [self configureResponseDelegateWithExpectedResponseCode:200];
- XCTAssertTrue([_componentCatalogObject listAllComponentTypesCatalog]);
- [self waitForServerResponse];
+ CloudResponse *response = [_componentCatalogObject listAllComponentTypesCatalog];
+ XCTAssertEqual(response.responseCode, 200);
}
- (void)test_402_ListAllDetailsOfComponentTypesCatalog{
- [self configureResponseDelegateWithExpectedResponseCode:200];
- XCTAssertTrue([_componentCatalogObject listAllDetailsOfComponentTypesCatalog]);
- [self waitForServerResponse];
+ CloudResponse *response = [_componentCatalogObject listAllDetailsOfComponentTypesCatalog];
+ XCTAssertEqual(response.responseCode, 200);
}
- (void)test_403_ListComponentTypeDetails{
- [self configureResponseDelegateWithExpectedResponseCode:200];
- XCTAssertTrue([_componentCatalogObject listComponentTypeDetails:@"temperature.v1.0"]);
- [self waitForServerResponse];
+ CloudResponse *response = [_componentCatalogObject listComponentTypeDetails:@"temperature.v1.0"];
+ XCTAssertEqual(response.responseCode, 200);
}
- (void)test_404_CreateCustomComponent{
- [self configureResponseDelegateWithExpectedResponseCode:201];
ComponentCatalog *createComponentCatalog = [ComponentCatalog ComponentCatalogWith:[self getRandomCustomComponentName] AndVersion:@"1.0" AndType:@"actuator" AndDataType:@"Number" AndFormat:@"float" AndUnit:@"Degrees Celsius" AndDisplay:@"timeSeries"];
[createComponentCatalog setMinValue:5.0];
[createComponentCatalog setMaxValue:100.0];
@@ -67,11 +63,10 @@ - (void)test_404_CreateCustomComponent{
[createComponentCatalog addCommandParameters:@"AC3" AndValue:@"32-38"];
[createComponentCatalog addCommandParameters:@"TrueAC" AndValue:@"20-30"];
[createComponentCatalog addCommandParameters:@"LiveAC" AndValue:@"10-20"];
- XCTAssertTrue([_componentCatalogObject createCustomComponent:createComponentCatalog]);
- [self waitForServerResponse];
+ CloudResponse *response = [_componentCatalogObject createCustomComponent:createComponentCatalog];
+ XCTAssertEqual(response.responseCode, 201);
}
- (void)test_405_UpdateAComponent{
- [self configureResponseDelegateWithExpectedResponseCode:201];
ComponentCatalog *updateComponentCatalog = [ComponentCatalog ComponentCatalogWith:nil AndVersion:nil AndType:@"actuator" AndDataType:@"Number" AndFormat:@"integer" AndUnit:@"Degrees Celsius" AndDisplay:@"timeSeries"];
[updateComponentCatalog setMinValue:5.0];
[updateComponentCatalog setMaxValue:100.0];
@@ -81,9 +76,9 @@ - (void)test_405_UpdateAComponent{
[updateComponentCatalog addCommandParameters:@"AC3" AndValue:@"32-38"];
[updateComponentCatalog addCommandParameters:@"TrueAC" AndValue:@"10-30"];
[updateComponentCatalog addCommandParameters:@"LiveAC" AndValue:@"0-20"];
- XCTAssertTrue([_componentCatalogObject updateAComponent:updateComponentCatalog OnComponent:
- [[self getCustomComponentName] stringByAppendingString:@".V1.0"]]);
- [self waitForServerResponse];
+ CloudResponse *response = [_componentCatalogObject updateAComponent:updateComponentCatalog OnComponent:
+ [[self getCustomComponentName] stringByAppendingString:@".V1.0"]];
+ XCTAssertEqual(response.responseCode, 201);
}
diff --git a/IoTTests/Module_005_DataManagementTests.m b/IoTTests/Module_005_DataManagementTests.m
index 4b2495a..16a25a7 100644
--- a/IoTTests/Module_005_DataManagementTests.m
+++ b/IoTTests/Module_005_DataManagementTests.m
@@ -44,20 +44,18 @@ - (void)tearDown {
}
- (void)test_501_SubmitData{
- [self configureResponseDelegateWithExpectedResponseCode:201];
- XCTAssertTrue([_dataManagementObject submitDataOn:[HttpUrlBuilder getComponentName]
- AndValue:[self getRandomValue]
- AndLatitide:10 AndLongitude:20 AndHeight:30 AndAttributes:nil]);
- [self waitForServerResponse];
+ CloudResponse *response = [_dataManagementObject submitDataOn:[HttpUrlBuilder getComponentName]
+ AndValue:[self getRandomValue]
+ AndLatitide:10 AndLongitude:20 AndHeight:30 AndAttributes:nil];
+ XCTAssertEqual(response.responseCode, 201);
}
- (void)test_502_RetrieveData{
- [self configureResponseDelegateWithExpectedResponseCode:200];
ConfigureRetrieveData *retData = [[ConfigureRetrieveData alloc] initConfigureRetrieveData:0 ToTimeInMillis:[[NSDate date] timeIntervalSince1970] * 1000];
[retData addDeviceId:[HttpUrlBuilder getDeviceId]];
[retData addComponentId:[HttpUrlBuilder getComponentId:[HttpUrlBuilder getComponentName]]];
- XCTAssertTrue([_dataManagementObject retrieveDataOn:retData]);
- [self waitForServerResponse];
+ CloudResponse *response = [_dataManagementObject retrieveDataOn:retData];
+ XCTAssertEqual(response.responseCode, 200);
}
@end
diff --git a/IoTTests/Module_006_UserManagementTests.m b/IoTTests/Module_006_UserManagementTests.m
index 9de5da7..b68e640 100644
--- a/IoTTests/Module_006_UserManagementTests.m
+++ b/IoTTests/Module_006_UserManagementTests.m
@@ -43,59 +43,48 @@ - (void)tearDown {
[super tearDown];
}
- (void)test_601_CreateNewUser{
- [self configureResponseDelegateWithExpectedResponseCode:201];
- XCTAssertTrue([_userManagementObject createNewUserWith:@"intel.aricent.iot5@gmail.com"
- AndPassword:@"Password2529"]);
- [self waitForServerResponse];
+ CloudResponse *response = [_userManagementObject createNewUserWith:@"intel.aricent.iot6@gmail.com"
+ AndPassword:@"Password2529"];
+ XCTAssertEqual(response.responseCode, 201);
}
- (void)test_602_GetNewAuthorizationToken{
- [self configureResponseDelegateWithExpectedResponseCode:200];
AuthorizationManagement *auth = [[AuthorizationManagement alloc]init];
- XCTAssertTrue([auth getNewAuthorizationTokenWithUsername:@"intel.aricent.iot5@gmail.com" andPassword:@"Password2529"]);
- [self waitForServerResponse];
-}
-- (void)test_603_AcceptTermsAndConditions{
- [self configureResponseDelegateWithExpectedResponseCode:200];
- XCTAssertTrue([_userManagementObject acceptTermsAndConditionsOn:[HttpUrlBuilder getUserId]
- Acceptance:true]);
- [self waitForServerResponse];
+ CloudResponse *response = [auth getNewAuthorizationTokenWithUsername:@"intel.aricent.iot6@gmail.com" andPassword:@"Password2529"];
+ XCTAssertEqual(response.responseCode, 200);
}
+/*- (void)test_603_AcceptTermsAndConditions{
+ CloudResponse *response = [_userManagementObject acceptTermsAndConditionsOn:[HttpUrlBuilder getUserId]
+ Acceptance:true];
+ XCTAssertEqual(response.responseCode, 200);
+}*/
- (void)test_604_GetUserInfo{
- [self configureResponseDelegateWithExpectedResponseCode:200];
- XCTAssertTrue([_userManagementObject getUserInfo:[HttpUrlBuilder getUserId]]);
- [self waitForServerResponse];
+ CloudResponse *response = [_userManagementObject getUserInfo:[HttpUrlBuilder getUserId]];
+ XCTAssertEqual(response.responseCode, 200);
}
- (void)test_605_UpdateUserAttributes{
- [self configureResponseDelegateWithExpectedResponseCode:200];
- BOOL isTrue = [_userManagementObject updateUserAttributesOn:[HttpUrlBuilder getUserId]
- AndListOfAttributes:[NSDictionary dictionaryWithObjectsAndKeys:@"100000000",@"phone",@"hey hey",@"wish", nil]];
- XCTAssertTrue(isTrue);
- [self waitForServerResponse];
+ CloudResponse *response = [_userManagementObject updateUserAttributesOn:[HttpUrlBuilder getUserId]
+ AndListOfAttributes:[NSDictionary dictionaryWithObjectsAndKeys:@"100000000",@"phone",@"hey hey",@"wish", nil]];
+ XCTAssertEqual(response.responseCode, 200);
}
- (void)test_606_ChangePassword{
- [self configureResponseDelegateWithExpectedResponseCode:200];
- XCTAssertTrue([_userManagementObject changePasswordOn:@"intel.aricent.iot5@gmail.com" AndCurrentPassword:@"Password2529" AndNewPassword:@"Password25292"]);
- [self waitForServerResponse];
+ CloudResponse *response = [_userManagementObject changePasswordOn:@"intel.aricent.iot6@gmail.com" AndCurrentPassword:@"Password2529" AndNewPassword:@"Password25292"];
+ XCTAssertEqual(response.responseCode, 200);
}
- (void)test_607_GetNewAuthorizationToken{
- [self configureResponseDelegateWithExpectedResponseCode:200];
AuthorizationManagement *auth = [[AuthorizationManagement alloc]init];
- XCTAssertTrue([auth getNewAuthorizationTokenWithUsername:@"intel.aricent.iot5@gmail.com" andPassword:@"Password25292"]);
- [self waitForServerResponse];
+ CloudResponse *response = [auth getNewAuthorizationTokenWithUsername:@"intel.aricent.iot6@gmail.com" andPassword:@"Password25292"];
+ XCTAssertEqual(response.responseCode, 200);
}
- (void)test_608_RequestChangePassword{
- [self configureResponseDelegateWithExpectedResponseCode:200];
- XCTAssertTrue([_userManagementObject requestChangePasswordOn:@"intel.aricent.iot5@gmail.com"]);
- [self waitForServerResponse];
+ CloudResponse *response = [_userManagementObject requestChangePasswordOn:@"intel.aricent.iot6@gmail.com"];
+ XCTAssertEqual(response.responseCode, 200);
}
- (void)test_609_UpdateForgotPassword{
- [self configureResponseDelegateWithExpectedResponseCode:200];
- XCTAssertTrue([_userManagementObject updateForgotPassword:@"HqaRch3mzCaDe2XH" AndNewPassword:@"Password2529"]);
- [self waitForServerResponse];
+ CloudResponse *response = [_userManagementObject updateForgotPassword:@"dxmYkK0VNkJdTdqc" AndNewPassword:@"Password2529"];
+ XCTAssertEqual(response.responseCode, 200);
}
- (void)test_610_DeleteAUser{
- [self configureResponseDelegateWithExpectedResponseCode:204];
- XCTAssertTrue([_userManagementObject deleteUser:[HttpUrlBuilder getUserId]]);
- [self waitForServerResponse];
+ CloudResponse *response = [_userManagementObject deleteUser:[HttpUrlBuilder getUserId]];
+ XCTAssertEqual(response.responseCode, 204);
}
@end
diff --git a/IoTTests/Module_007_InvitationManagementTests.m b/IoTTests/Module_007_InvitationManagementTests.m
index 12dcca1..a11c7f7 100644
--- a/IoTTests/Module_007_InvitationManagementTests.m
+++ b/IoTTests/Module_007_InvitationManagementTests.m
@@ -42,23 +42,19 @@ - (void)tearDown {
[super tearDown];
}
- (void)test_701_CreateInvitation{
- [self configureResponseDelegateWithExpectedResponseCode:201];
- XCTAssertTrue([_invitationObject createInvitationTo:@"intel.aricent.iot3@gmail.com"]);
- [self waitForServerResponse];
+ CloudResponse *response = [_invitationObject createInvitationTo:@"intel.aricent.iot3@gmail.com"];
+ XCTAssertEqual(response.responseCode, 201);
}
- (void)test_702_GetInvitationListSendToSpecificUser{
- [self configureResponseDelegateWithExpectedResponseCode:200];
- XCTAssertTrue([_invitationObject getInvitationListSendToSpecificUser:@"intel.aricent.iot3@gmail.com"]);
- [self waitForServerResponse];
+ CloudResponse *response = [_invitationObject getInvitationListSendToSpecificUser:@"intel.aricent.iot3@gmail.com"];
+ XCTAssertEqual(response.responseCode, 200);
}
- (void)test_703_GetListOfInvitation{
- [self configureResponseDelegateWithExpectedResponseCode:200];
- XCTAssertTrue([_invitationObject getListOfInvitation]);
- [self waitForServerResponse];
+ CloudResponse *response = [_invitationObject getListOfInvitation];
+ XCTAssertEqual(response.responseCode, 200);
}
- (void)test_704_DeleteInvitations{
- [self configureResponseDelegateWithExpectedResponseCode:200];
- XCTAssertTrue([_invitationObject deleteInvitationsTo:@"intel.aricent.iot3@gmail.com"]);
- [self waitForServerResponse];
+ CloudResponse *response = [_invitationObject deleteInvitationsTo:@"intel.aricent.iot3@gmail.com"];
+ XCTAssertEqual(response.responseCode, 200);
}
@end
diff --git a/IoTTests/Module_008_RuleManagementTests.m b/IoTTests/Module_008_RuleManagementTests.m
index f91b0ce..466d1e8 100644
--- a/IoTTests/Module_008_RuleManagementTests.m
+++ b/IoTTests/Module_008_RuleManagementTests.m
@@ -43,7 +43,6 @@ - (void)tearDown {
}
- (void)test_801_CreateARule{
- [self configureResponseDelegateWithExpectedResponseCode:201];
Rule *ruleObj = [[Rule alloc] init];
RuleActions *ruleActionObj = [[RuleActions alloc] init];
RuleConditionValues *ruleConditionValuesObj = [[RuleConditionValues alloc] init];
@@ -71,11 +70,10 @@ - (void)test_801_CreateARule{
[ruleObj setRuleOperatorName:@"OR"];
[ruleObj addRuleConditionValues:ruleConditionValuesObj];
- XCTAssertTrue([_ruleObject createRule:ruleObj]);
- [self waitForServerResponse];
+ CloudResponse *response = [_ruleObject createRule:ruleObj];
+ XCTAssertEqual(response.responseCode, 201);
}
- (void)test_802_UpdateRule{
- [self configureResponseDelegateWithExpectedResponseCode:201];
Rule *updateRuleObj = [[Rule alloc] init];
RuleActions *updateRuleActionObj = [[RuleActions alloc] init];
RuleConditionValues *updateRuleConditionValuesObj = [[RuleConditionValues alloc] init];
@@ -102,31 +100,26 @@ - (void)test_802_UpdateRule{
[updateRuleObj setRuleOperatorName:@"OR"];
[updateRuleObj addRuleConditionValues:updateRuleConditionValuesObj];
- XCTAssertTrue([_ruleObject updateARule:updateRuleObj OnRule:[[NSUserDefaults standardUserDefaults] objectForKey:RULEID]]);
- [self waitForServerResponse];
+ CloudResponse *response = [_ruleObject updateARule:updateRuleObj OnRule:[[NSUserDefaults standardUserDefaults] objectForKey:RULEID]];
+ XCTAssertEqual(response.responseCode, 201);
}
- (void)test_803_CreateRuleAsDraft{
- [self configureResponseDelegateWithExpectedResponseCode:200];
- BOOL isTrue = [_ruleObject createRuleAsDraftUsing:
- [NSString stringWithFormat:@"%@-Draft",[self getRandomRuleName]]];
- XCTAssertTrue(isTrue);
- [self waitForServerResponse];
+ CloudResponse *response = [_ruleObject createRuleAsDraftUsing:
+ [NSString stringWithFormat:@"%@-Draft",[self getRandomRuleName]]];
+ XCTAssertEqual(response.responseCode, 200);
}
- (void)test_804_DeleteADraftRule{
- [self configureResponseDelegateWithExpectedResponseCode:204];
- XCTAssertTrue([_ruleObject deleteADraftRule:[[NSUserDefaults standardUserDefaults]
- objectForKey:DRAFTRULEID]]);
- [self waitForServerResponse];
+ CloudResponse *response = [_ruleObject deleteADraftRule:[[NSUserDefaults standardUserDefaults]
+ objectForKey:DRAFTRULEID]];
+ XCTAssertEqual(response.responseCode, 204);
}
- (void)test_805_GetInformationOnRule{
- [self configureResponseDelegateWithExpectedResponseCode:200];
- XCTAssertTrue([_ruleObject getInformationOnRule:[[NSUserDefaults standardUserDefaults]
- objectForKey:RULEID]]);
- [self waitForServerResponse];
+ CloudResponse *response = [_ruleObject getInformationOnRule:[[NSUserDefaults standardUserDefaults]
+ objectForKey:RULEID]];
+ XCTAssertEqual(response.responseCode, 200);
}
- (void)test_806_GetListOfRules{
- [self configureResponseDelegateWithExpectedResponseCode:200];
- XCTAssertTrue([_ruleObject getListOfRules]);
- [self waitForServerResponse];
+ CloudResponse *response = [_ruleObject getListOfRules];
+ XCTAssertEqual(response.responseCode, 200);
}
@end
diff --git a/IoTTests/Module_009_AdvancedDataInquiryTests.m b/IoTTests/Module_009_AdvancedDataInquiryTests.m
index 8135a95..977ae84 100644
--- a/IoTTests/Module_009_AdvancedDataInquiryTests.m
+++ b/IoTTests/Module_009_AdvancedDataInquiryTests.m
@@ -43,7 +43,6 @@ - (void)tearDown {
}
- (void)test_901_AdvancedDataInquiry {
- [self configureResponseDelegateWithExpectedResponseCode:200];
[_objAdvancedDataInquiry addGatewayId:[HttpUrlBuilder getDeviceId]];
//[objAdvancedDataInquiry addGatewayId:@"devTest"];
@@ -99,8 +98,8 @@ - (void)test_901_AdvancedDataInquiry {
[_objAdvancedDataInquiry addSortInfo:@"Timestamp" WithValue:@"Asc"];
[_objAdvancedDataInquiry addSortInfo:@"Value" WithValue:@"Desc"];
- [_objAdvancedDataInquiry request];
- [self waitForServerResponse];
+ CloudResponse *response = [_objAdvancedDataInquiry request];
+ XCTAssertEqual(response.responseCode, 200);
}
diff --git a/IoTTests/Module_010_AggregatedReportInterfaceTests.m b/IoTTests/Module_010_AggregatedReportInterfaceTests.m
index b0c299c..4c6a41f 100644
--- a/IoTTests/Module_010_AggregatedReportInterfaceTests.m
+++ b/IoTTests/Module_010_AggregatedReportInterfaceTests.m
@@ -44,7 +44,6 @@ - (void)tearDown {
}
- (void)test_1001_AggregatedReportInterface {
- [self configureResponseDelegateWithExpectedResponseCode:200];
[_aggregatedReportInterfaceObject addGatewayId:[HttpUrlBuilder getDeviceId]];
//[_aggregatedReportInterfaceObject addGatewayId:@"qwertyPAD1"];
//[_aggregatedReportInterfaceObject addGatewayId:@"devTest"];
@@ -88,8 +87,9 @@ - (void)test_1001_AggregatedReportInterface {
//sort
[_aggregatedReportInterfaceObject addSortInfo:@"timeHour" AndValue:@"Asc"];
//[_aggregatedReportInterfaceObject addSortInfo:@"sortField2" AndValue:@"Desc"];
- XCTAssertTrue([_aggregatedReportInterfaceObject request]);
- [self waitForServerResponse];
+
+ CloudResponse *response = [_aggregatedReportInterfaceObject request];
+ XCTAssertEqual(response.responseCode, 200);
}
diff --git a/IoTTests/Module_011_AlertManagementTests.m b/IoTTests/Module_011_AlertManagementTests.m
index 08b62cc..4de45ba 100644
--- a/IoTTests/Module_011_AlertManagementTests.m
+++ b/IoTTests/Module_011_AlertManagementTests.m
@@ -43,36 +43,31 @@ - (void)tearDown {
}
- (void)test_1102_GetListOfAlerts {
- [self configureResponseDelegateWithExpectedResponseCode:200];
- XCTAssertTrue([_alertObject getListOfAlerts]);
- [self waitForServerResponse];
+ CloudResponse *response = [_alertObject getListOfAlerts];
+ XCTAssertEqual(response.responseCode, 200);
}
- (void)test_1103_GetInfoOnAlert {
- [self configureResponseDelegateWithExpectedResponseCode:200];
- XCTAssertTrue([_alertObject getInfoOnAlert:[[NSUserDefaults standardUserDefaults]
- objectForKey:@"alert_Id"]]);
- [self waitForServerResponse];
+ CloudResponse *response = [_alertObject getInfoOnAlert:[[NSUserDefaults standardUserDefaults]
+ objectForKey:@"alert_Id"]];
+ XCTAssertEqual(response.responseCode, 200);
}
- (void)test_1104_UpdateAlertStatus {
- [self configureResponseDelegateWithExpectedResponseCode:200];
- XCTAssertTrue([_alertObject updateAlertStatus:[[NSUserDefaults standardUserDefaults]
- objectForKey:@"alert_Id"] WithStatus:@"Open"]);
- [self waitForServerResponse];
+ CloudResponse *response = [_alertObject updateAlertStatus:[[NSUserDefaults standardUserDefaults]
+ objectForKey:@"alert_Id"] WithStatus:@"Open"];
+ XCTAssertEqual(response.responseCode, 200);
}
- (void)test_1105_AddCommentsToTheAlert {
- [self configureResponseDelegateWithExpectedResponseCode:200];
- XCTAssertTrue([_alertObject addCommentsToTheAlert:[[NSUserDefaults standardUserDefaults]
- objectForKey:@"alert_Id"]
- OnUser:@"intel.aricent.iot5@gmail.com"
- AtTime:[self getCurrentTimeInMillis]
- WithComment:@"Demo comment on alert"]);
- [self waitForServerResponse];
+ CloudResponse *response = [_alertObject addCommentsToTheAlert:[[NSUserDefaults standardUserDefaults]
+ objectForKey:@"alert_Id"]
+ OnUser:@"intel.aricent.iot5@gmail.com"
+ AtTime:[self getCurrentTimeInMillis]
+ WithComment:@"Demo comment on alert"];
+ XCTAssertEqual(response.responseCode, 200);
}
- (void)test_1106_ResetAlert {
- [self configureResponseDelegateWithExpectedResponseCode:200];
- XCTAssertTrue([_alertObject resetAlert:[[NSUserDefaults standardUserDefaults]
- objectForKey:@"alert_Id"]]);
- [self waitForServerResponse];
+ CloudResponse *response = [_alertObject resetAlert:[[NSUserDefaults standardUserDefaults]
+ objectForKey:@"alert_Id"]];
+ XCTAssertEqual(response.responseCode, 200);
}
@end
diff --git a/TestApp/Base.lproj/Main.storyboard b/TestApp/Base.lproj/Main.storyboard
index 38cc4ca..691b966 100644
--- a/TestApp/Base.lproj/Main.storyboard
+++ b/TestApp/Base.lproj/Main.storyboard
@@ -17,11 +17,12 @@
-
-
-
-
-
-
-
-
+
+
+
+
+
-
-
-
-
+
+
+
-
+
-
-
+
+
+
-
-
+
-
-
+
+
+
-
-
-
-
-
-
+
+
@@ -206,36 +182,21 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
-
-
-
+
diff --git a/TestApp/ViewController.m b/TestApp/ViewController.m
index 10ea50c..6f306ca 100644
--- a/TestApp/ViewController.m
+++ b/TestApp/ViewController.m
@@ -57,24 +57,44 @@ - (void)viewDidLoad {
// Do any additional setup after loading the view, typically from a nib.
}
+/***************************************************************************************************************************
+ * FUNCTION NAME: connectToIoTServerSyncButtonClicked
+ *
+ * DESCRIPTION: synchronous version of method gets called on click of button,
+ *
+ * RETURNS: button action instance
+ *
+ * PARAMETERS : sender object
+ **************************************************************************************************************************/
+
- (IBAction)connectToIoTServerSyncButtonClicked:(id)sender {
self.responseCodeTextField.text = @"";
self.responseTextView.text = @"";
- //Authorization
- dispatch_async(dispatch_get_main_queue(), ^{//Executing on UI thread
+ //Authorization,Executing on UI thread, Blocks UI
+ dispatch_async(dispatch_get_main_queue(), ^{
AuthorizationManagement *auth = [[AuthorizationManagement alloc] init];
CloudResponse *response = [auth getNewAuthorizationTokenWithUsername:@"intel.aricent.iot5@gmail.com" andPassword:@"Password2529"];
self.responseCodeTextField.text = [NSString stringWithFormat:@"%ld",(long)response.responseCode];
self.responseTextView.text = response.responseString;
NSLog(@"ViewController: done sending request for authorization token code:%d msg:%@", response.status, response.responseString);
});
+ //Authorization,Executing on background thread, Does not blocks UI
+ /*dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{//Executing on background thread
+ AuthorizationManagement *auth = [[AuthorizationManagement alloc] init];
+ CloudResponse *response = [auth getNewAuthorizationTokenWithUsername:@"intel.aricent.iot5@gmail.com" andPassword:@"Password2529"];
+ dispatch_sync(dispatch_get_main_queue(), ^{//response showing on UI thread
+ self.responseCodeTextField.text = [NSString stringWithFormat:@"%ld",(long)response.responseCode];
+ self.responseTextView.text = response.responseString;
+ });
+ NSLog(@"ViewController: done sending request for authorization token code:%d msg:%@", response.status, response.responseString);
+ });*/
}
/***************************************************************************************************************************
* FUNCTION NAME: connectToIoTServerButtonClicked
*
- * DESCRIPTION: method gets called on click of button
+ * DESCRIPTION: Asynchronous version of method gets called on click of button,
*
* RETURNS: button action instance
*
@@ -95,11 +115,13 @@ - (IBAction)connectToIoTServerButtonClicked:(id)sender {
});
};
- //Authorization
-
+ //Authorization,Executing on UI thread, does not block UI as it is async http call
+ //note:following request can be executed on background thread
AuthorizationManagement *auth = [[AuthorizationManagement alloc] init];
CloudResponse *response = [auth getNewAuthorizationTokenWithUsername:@"intel.aricent.iot5@gmail.com" andPassword:@"Password2529"];
NSLog(@"ViewController: done sending request for authorization token code:%d msg:%@", response.status, response.responseString);
+ self.responseCodeTextField.text = [NSString stringWithFormat:@"%ld",(long)response.responseCode];
+ self.responseTextView.text = response.responseString;
}
/***************************************************************************************************************************