Skip to content

Commit

Permalink
GH-96 Add Chat and Message mappings for recursive tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Dima Zen committed May 20, 2017
1 parent 489a2d1 commit 3bc5082
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 18 deletions.
52 changes: 34 additions & 18 deletions FastEasyMapping.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions FastEasyMappingTests/Mapping Provider/Chat+Mapping.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// For License please refer to LICENSE file in the root of FastEasyMapping project

#import "Chat+CoreDataClass.h"

@class FEMMapping;

@interface Chat (Mapping)

+ (FEMMapping *)defaultMapping;
+ (FEMMapping *)recursiveMapping;

@end
29 changes: 29 additions & 0 deletions FastEasyMappingTests/Mapping Provider/Chat+Mapping.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// For License please refer to LICENSE file in the root of FastEasyMapping project

#import "Chat+Mapping.h"
#import "ChatMessage+Mapping.h"

@import FastEasyMapping;

@implementation Chat (Mapping)

+ (FEMMapping *)defaultMapping {
FEMMapping *mapping = [[FEMMapping alloc] initWithEntityName:NSStringFromClass(self)];
mapping.primaryKey = @"primaryKey";
[mapping addAttributesFromArray:@[@"primaryKey"]];

return mapping;
}

+ (FEMMapping *)recursiveMapping {
FEMMapping *chat = [self defaultMapping];

FEMMapping *message = [ChatMessage defaultMapping];
[message addRelationshipMapping:[Chat defaultMapping] forProperty:@"chat" keyPath:@"chat"];

[chat addToManyRelationshipMapping:message forProperty:@"messages" keyPath:@"messages"];

return chat;
}

@end
11 changes: 11 additions & 0 deletions FastEasyMappingTests/Mapping Provider/ChatMessage+Mapping.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// For License please refer to LICENSE file in the root of FastEasyMapping project

#import "ChatMessage+CoreDataClass.h"

@class FEMMapping;

@interface ChatMessage (Mapping)

+ (FEMMapping *)defaultMapping;

@end
16 changes: 16 additions & 0 deletions FastEasyMappingTests/Mapping Provider/ChatMessage+Mapping.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// For License please refer to LICENSE file in the root of FastEasyMapping project

#import "ChatMessage+Mapping.h"

@import FastEasyMapping;

@implementation ChatMessage (Mapping)

+ (FEMMapping *)defaultMapping {
FEMMapping *mapping = [[FEMMapping alloc] initWithEntityName:NSStringFromClass(self)];
mapping.primaryKey = @"primaryKey";
[mapping addAttributesFromArray:@[@"primaryKey"]];
return mapping;
}

@end
10 changes: 10 additions & 0 deletions FastEasyMappingTests/Models/CoreData.xcdatamodel/contents
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@
<attribute name="year" optional="YES" attributeType="String" syncable="YES"/>
<relationship name="person" optional="YES" minCount="1" maxCount="1" deletionRule="Nullify" destinationEntity="Person" inverseName="car" inverseEntity="Person" syncable="YES"/>
</entity>
<entity name="Chat" representedClassName="Chat" syncable="YES" codeGenerationType="class">
<attribute name="primaryKey" optional="YES" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="NO" syncable="YES"/>
<relationship name="messages" optional="YES" toMany="YES" deletionRule="Cascade" destinationEntity="ChatMessage" inverseName="chat" inverseEntity="ChatMessage" syncable="YES"/>
</entity>
<entity name="ChatMessage" representedClassName="ChatMessage" syncable="YES" codeGenerationType="class">
<attribute name="primaryKey" optional="YES" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="NO" syncable="YES"/>
<relationship name="chat" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Chat" inverseName="messages" inverseEntity="Chat" syncable="YES"/>
</entity>
<entity name="ManagedObject" representedClassName="ManagedObject" syncable="YES">
<attribute name="boolObject" optional="YES" attributeType="Boolean" usesScalarValueType="NO" syncable="YES"/>
<attribute name="boolValue" optional="YES" attributeType="Boolean" usesScalarValueType="YES" syncable="YES"/>
Expand Down Expand Up @@ -55,6 +63,8 @@
</entity>
<elements>
<element name="Car" positionX="243" positionY="-990" width="128" height="120"/>
<element name="Chat" positionX="45" positionY="-828" width="128" height="75"/>
<element name="ChatMessage" positionX="54" positionY="-819" width="128" height="75"/>
<element name="ManagedObject" positionX="54" positionY="-900" width="128" height="315"/>
<element name="ManagedObjectChild" positionX="63" positionY="-810" width="128" height="75"/>
<element name="Person" positionX="54" positionY="-990" width="128" height="165"/>
Expand Down

0 comments on commit 3bc5082

Please sign in to comment.