-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: renaming RelationshipCreationContents
- Loading branch information
Showing
12 changed files
with
128 additions
and
128 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
45 changes: 16 additions & 29 deletions
45
...d_types/lib/src/contents/relationship_creation_content/relationship_creation_content.dart
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 |
---|---|---|
@@ -1,37 +1,24 @@ | ||
import 'dart:collection'; | ||
part of 'relationship_creation_content_derivation.dart'; | ||
|
||
import 'package:equatable/equatable.dart'; | ||
import 'package:meta/meta.dart'; | ||
class RelationshipCreationContent extends RelationshipCreationContentDerivation { | ||
final Response response; | ||
|
||
import '../arbitraty_json.dart'; | ||
import '../response.dart'; | ||
const RelationshipCreationContent({ | ||
required this.response, | ||
}); | ||
|
||
part 'relationship_creation_content_containing_response.dart'; | ||
factory RelationshipCreationContent.fromJson(Map json) => RelationshipCreationContent( | ||
response: Response.fromJson(json['response']), | ||
); | ||
|
||
abstract class RelationshipCreationContent extends Equatable { | ||
const RelationshipCreationContent(); | ||
|
||
factory RelationshipCreationContent.fromJson(Map json) { | ||
if (json.containsKey('response')) { | ||
return RelationshipCreationContentContainingResponse.fromJson(json); | ||
} | ||
|
||
return ArbitraryRelationshipCreationContent(json); | ||
} | ||
|
||
Map<String, dynamic> toJson(); | ||
|
||
@mustCallSuper | ||
@override | ||
List<Object?> get props; | ||
} | ||
|
||
class ArbitraryRelationshipCreationContent extends RelationshipCreationContent with MapMixin<String, dynamic>, ArbitraryJSON { | ||
@override | ||
final Map<String, dynamic> internalJson; | ||
|
||
ArbitraryRelationshipCreationContent(Map internalJson) : internalJson = Map<String, dynamic>.from(internalJson); | ||
Map<String, dynamic> toJson() { | ||
return { | ||
'@type': 'RelationshipCreationContent', | ||
'response': response.toJson(), | ||
}; | ||
} | ||
|
||
@override | ||
List<Object?> get props => [internalJson]; | ||
List<Object?> get props => [response]; | ||
} |
24 changes: 0 additions & 24 deletions
24
...ents/relationship_creation_content/relationship_creation_content_containing_response.dart
This file was deleted.
Oops, something went wrong.
37 changes: 37 additions & 0 deletions
37
.../src/contents/relationship_creation_content/relationship_creation_content_derivation.dart
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,37 @@ | ||
import 'dart:collection'; | ||
|
||
import 'package:equatable/equatable.dart'; | ||
import 'package:meta/meta.dart'; | ||
|
||
import '../arbitraty_json.dart'; | ||
import '../response.dart'; | ||
|
||
part 'relationship_creation_content.dart'; | ||
|
||
abstract class RelationshipCreationContentDerivation extends Equatable { | ||
const RelationshipCreationContentDerivation(); | ||
|
||
factory RelationshipCreationContentDerivation.fromJson(Map json) { | ||
if (json.containsKey('response')) { | ||
return RelationshipCreationContent.fromJson(json); | ||
} | ||
|
||
return ArbitraryRelationshipCreationContent(json); | ||
} | ||
|
||
Map<String, dynamic> toJson(); | ||
|
||
@mustCallSuper | ||
@override | ||
List<Object?> get props; | ||
} | ||
|
||
class ArbitraryRelationshipCreationContent extends RelationshipCreationContentDerivation with MapMixin<String, dynamic>, ArbitraryJSON { | ||
@override | ||
final Map<String, dynamic> internalJson; | ||
|
||
ArbitraryRelationshipCreationContent(Map internalJson) : internalJson = Map<String, dynamic>.from(internalJson); | ||
|
||
@override | ||
List<Object?> get props => [internalJson]; | ||
} |
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
2 changes: 1 addition & 1 deletion
2
packages/enmeshed_types/lib/src/dvos/transport/relationship_dvo.g.dart
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
51 changes: 0 additions & 51 deletions
51
...relationship_creation_content/relationship_creation_content_containing_response_test.dart
This file was deleted.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
...contents/relationship_creation_content/relationship_creation_content_derivation_test.dart
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,24 @@ | ||
import 'package:enmeshed_types/enmeshed_types.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
group('RelationshipCreationContentDerivation fromJson', () { | ||
test('parsed valid RelationshipCreationContent', () { | ||
final relationshipCreationContentJson = { | ||
'@type': 'RelationshipCreationContentDerivation', | ||
'response': const Response(result: ResponseResult.Accepted, requestId: 'aRequestId', items: []).toJson(), | ||
}; | ||
final relationshipCreationContent = RelationshipCreationContentDerivation.fromJson(relationshipCreationContentJson); | ||
expect(relationshipCreationContent, isA<RelationshipCreationContent>()); | ||
}); | ||
|
||
test('parsed valid ArbitraryRelationshipCreationContent when not given a Response', () { | ||
final arbitraryRelationshipCreationContentJson = { | ||
'@type': 'RelationshipCreationContentDerivation', | ||
'internalJson': 'anInternalJson', | ||
}; | ||
final arbitraryRelationshipCreationContent = RelationshipCreationContentDerivation.fromJson(arbitraryRelationshipCreationContentJson); | ||
expect(arbitraryRelationshipCreationContent, isA<ArbitraryRelationshipCreationContent>()); | ||
}); | ||
}); | ||
} |
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