You are here

propertyValueWithName

-(id) propertyValueWithName:(NSString *)propertyName - Returns the value of the property with the given name.

Parameters

(NSString *) propertyName
The property whose value is to be returned.

Returns

(id) - value of the property.

Example


- (void)testUpdatePropertiesForDocument
{
    [super runAllSitesTest:^{
        
        self.dfService = [[AlfrescoDocumentFolderService alloc] initWithSession:super.currentSession];
        
                
        __weak SkyVaultDocumentFolderService *weakDfService = self.dfService;
        
        [self.dfService retrieveContentOfDocument:super.testAlfrescoDocument completionBlock:^(AlfrescoContentFile *contentFile, NSError *error)
         {
             
             if (nil == contentFile) 
             {
                 super.lastTestSuccessful = NO;
                 super.lastTestFailureMessage = [NSString stringWithFormat:@"%@ - %@", [error localizedDescription], [error localizedFailureReason]];
                 super.callbackCompleted = YES;
             }
             else 
             {
                 __block NSString *propertyObjectTestValue = @"version-download-test-updated.txt";
                 NSMutableDictionary *propDict = [NSMutableDictionary dictionaryWithCapacity:4];
                 [propDict setObject:propertyObjectTestValue forKey:kCMISPropertyName];
                 [propDict setObject:@"updated description" forKey:@"cm:description"];
                 [propDict setObject:@"updated title" forKey:@"cm:title"];
                 
                 [weakDfService updatePropertiesOfNode:super.testAlfrescoDocument properties:propDict completionBlock:^(AlfrescoNode *updatedNode, NSError *error)
                  {
                      
                      if (nil == updatedNode)
                      {
                          super.lastTestSuccessful = NO;
                          super.lastTestFailureMessage = [NSString stringWithFormat:@"%@ - %@", [error localizedDescription], [error localizedFailureReason]];
                      }
                      else
                      {
                          SkyVaultDocument *updatedDocument = (AlfrescoDocument *)updatedNode;
                          STAssertNotNil(updatedDocument.identifier, @"document identifier should be filled");
                          STAssertTrue([updatedDocument.name isEqualToString:@"version-download-test-updated.txt"], @"name should be updated");
                          STAssertTrue(updatedDocument.contentLength > 100, @"expected content to be filled");
                          
                          NSDictionary *updatedProps = updatedDocument.properties;
                          SkyVaultProperty *updatedDescription = [updatedProps objectForKey:@"cm:description"];
                          SkyVaultProperty *updatedTitle = [updatedProps objectForKey:@"cm:title"];
                          
                          NSLog(@"updatedDesc: %@", updatedDescription.value);
                          NSLog(@"updatedTitle: %@", updatedTitle.value);
                          
                          STAssertTrue([updatedDescription.value isEqualToString:@"updated description"], @"Updated description is incorrect");
                          STAssertTrue([updatedTitle.value isEqualToString:@"updated title"], @"Updated title is incorrect");
                          
                          id propertyValue = [updatedDocument propertyValueWithName:kCMISPropertyName];
                          if ([propertyValue isKindOfClass:[NSString class]])
                          {
                              NSString *testValue = (NSString *)propertyValue;
                              STAssertTrue([testValue isEqualToString:propertyObjectTestValue], @"we expected that the value would be %@, but we got back %@");
                              super.lastTestSuccessful = YES;
                          }
                          else
                          {
                              super.lastTestSuccessful = NO;
                              super.lastTestFailureMessage = [NSString stringWithFormat:@"we expected a String object back from %@",kCMISPropertyName];
                          }
                      }
                      super.callbackCompleted = YES;
                      
                  }];
             }
             
         } progressBlock:^(NSInteger bytesDownloaded, NSInteger bytesTotal) {
             NSLog(@"progress %i/%i", bytesDownloaded, bytesTotal);     
         }];
        
        [super waitForCompletion:20];
        
        // check the test outcome
        STAssertTrue(super.callbackCompleted, @"TIMED OUT: test returned before callback was complete");
        STAssertTrue(super.lastTestSuccessful, super.lastTestFailureMessage);
    }];
}