ios - RestKit Testing mapping issue -


i using restkit 0.20.3 , trying setup simple test scenario:

i have simple model contains static method return mapping:

@interface tktag : nsobject  @property (nonatomic) int _id; @property (strong, nonatomic) nsstring *name;  + (rkobjectmapping *)objectmapping;  @end  @implementation tktag  + (rkobjectmapping *)objectmapping {     rkobjectmapping *mapping = [rkobjectmapping mappingforclass:[tktag class]];     [mapping addattributemappingsfromdictionary:@{         @"tag_id": @"_id",         @"tag": @"name"     }];     return mapping; } @end 

and here test:

- (void)testobjectmapping {     nsbundle *testtargetbundle = [nsbundle bundlewithidentifier:@"here.is.my.bundeidtests"]; [rktestfixture setfixturebundle:testtargetbundle];      tktag *tag = [tktag new];     id parsedjson = [rktestfixture parsedobjectwithcontentsoffixture:@"tag.json"]; rkmappingtest *test = [rkmappingtest testformapping:[tktag objectmapping] sourceobject:parsedjson destinationobject:tag];      [test addexpectation:[rkpropertymappingtestexpectation expectationwithsourcekeypath:@"tag_id" destinationkeypath:@"_id"]]; [test addexpectation:[rkpropertymappingtestexpectation expectationwithsourcekeypath:@"tag" destinationkeypath:@"name"]];      stasserttrue([test evaluate], nil); } 

when run tests, receive failure on [test evaluate] message -[tktagtest testobjectmapping] failed 0xacb67e0: failed error: (null)

here json:

{     "tag_id": "30308",     "tag": "mendesss",     "post_id": "68213" } 

debugging execution , setting the restkit log level debug using rklogconfigurebyname("restkit/objectmapping", rklogleveltrace), found:

test case '-[tktagtest testobjectmapping]' started. 2013-07-21 22:45:01.437 teckler[5332:a0b] d restkit.object_mapping:rkmappingoperation.m:952 starting mapping     operation... 2013-07-21 22:45:01.438 teckler[5332:a0b] t restkit.object_mapping:rkmappingoperation.m:953 performing     mapping operation: <rkmappingoperation 0x105b3690> 'tktag' object. mapping values object {     "post_id" = 68213;     tag = mendesss;     "tag_id" = 30308; } object <tktag: 0xacedb90> object mapping (null) 2013-07-21 22:45:01.438 teckler[5332:a0b] d restkit.object_mapping:rkmappingoperation.m:598 key-value     validation disabled mapping, skipping... 2013-07-21 22:45:01.438 teckler[5332:a0b] d restkit.object_mapping:rkmappingoperation.m:598 key-value     validation disabled mapping, skipping... 2013-07-21 22:45:01.439 teckler[5332:a0b] d restkit.object_mapping:rkmappingoperation.m:997 mapping operation     did not find mappable values attribute , relationship mappings in given object     representation 2013-07-21 22:45:01.439 teckler[5332:a0b] d restkit.object_mapping:rkmappingoperation.m:1019 failed mapping     operation: no mappable values found of attributes or relationship mappings unknown.m:0: error: -[tktagtest testobjectmapping] : 0xac56880: failed error: (null) rkmappingtest expectations: (     "map 'tag_id' '_id'",     "map 'tag' 'name'" ) events: ( ) during mapping <cfbasichash 0xac57e90 [0x2dccd88]>{type = immutable dict, count = 3, entries =>     0 : <cfstring 0xac460e0 [0x2dccd88]>{contents = "tag_id"} = <cfstring 0xac45f70 [0x2dccd88]>{contents =     "30308"}     1 : <cfstring 0xac45f80 [0x2dccd88]>{contents = "tag"} = <cfstring 0xac45ec0 [0x2dccd88]>{contents =     "mendesss"}     2 : <cfstring 0xac45e10 [0x2dccd88]>{contents = "post_id"} = <cfstring 0xac45d60 [0x2dccd88]>{contents =     "68213"} }  <tktag: 0xacedb90> mapping <rkobjectmapping:0xac45bd0 objectclass=tktag propertymappings=(     "<rkattributemapping: 0xac45ca0 tag_id => _id>",     "<rkattributemapping: 0xac45990 tag => name>" )> test case '-[tktagtest testobjectmapping]' failed (5.937 seconds). test suite 'tktagtest' finished @ 2013-07-22 01:45:01 +0000. 

any ideas doing wrong?

this issue when running unit tests. ok when performing request web server , mapping json.

i'll appreciate help.

try setting destinationobject nil:

rkmappingtest *test = [rkmappingtest testformapping:[dtomapping mymapping] sourceobject:parsedjson destinationobject:nil];


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -