LCOV - code coverage report
Current view: top level - core/models - enriched_activity.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 31 32 96.9 %
Date: 2021-04-14 08:03:52 Functions: 0 0 -

          Line data    Source code
       1             : import 'package:equatable/equatable.dart';
       2             : import 'package:json_annotation/json_annotation.dart';
       3             : import 'package:stream_feed_dart/src/core/models/reaction.dart';
       4             : import 'package:stream_feed_dart/src/core/util/serializer.dart';
       5             : 
       6             : part 'enriched_activity.g.dart';
       7             : 
       8             : ///
       9             : class EnrichableField extends Equatable {
      10             :   ///
      11           6 :   const EnrichableField(this.data);
      12             : 
      13             :   ///
      14             :   final Object? data;
      15             : 
      16             :   ///
      17           5 :   static EnrichableField deserialize(Object? obj) {
      18           5 :     if (obj is String) {
      19           5 :       return EnrichableField(obj);
      20             :     }
      21           0 :     return EnrichableField(obj as Map<String, Object>?);
      22             :   }
      23             : 
      24           2 :   static Object? serialize(EnrichableField? field) => field?.data;
      25             : 
      26           4 :   @override
      27           8 :   List<Object?> get props => [data];
      28             : }
      29             : 
      30             : ///
      31             : @JsonSerializable()
      32             : class EnrichedActivity extends Equatable {
      33             :   ///
      34           6 :   const EnrichedActivity({
      35             :     this.id,
      36             :     this.actor,
      37             :     this.verb,
      38             :     this.object,
      39             :     this.foreignId,
      40             :     this.target,
      41             :     this.time,
      42             :     this.origin,
      43             :     this.to,
      44             :     this.score,
      45             :     this.analytics,
      46             :     this.extraContext,
      47             :     this.extraData,
      48             :     this.reactionCounts,
      49             :     this.ownReactions,
      50             :     this.latestReactions,
      51             :   });
      52             : 
      53             :   /// Create a new instance from a json
      54           5 :   factory EnrichedActivity.fromJson(Map<String, dynamic>? json) =>
      55           5 :       _$EnrichedActivityFromJson(
      56           5 :           Serializer.moveKeysToRoot(json, topLevelFields)!);
      57             : 
      58             :   ///
      59             :   @JsonKey(includeIfNull: false, toJson: Serializer.readOnly)
      60             :   final String? id;
      61             : 
      62             :   ///
      63             :   @JsonKey(
      64             :     fromJson: EnrichableField.deserialize,
      65             :     toJson: EnrichableField.serialize,
      66             :   )
      67             :   final EnrichableField? actor;
      68             : 
      69             :   ///
      70             :   final String? verb;
      71             : 
      72             :   ///
      73             :   @JsonKey(
      74             :     fromJson: EnrichableField.deserialize,
      75             :     toJson: EnrichableField.serialize,
      76             :   )
      77             :   final EnrichableField? object;
      78             : 
      79             :   ///
      80             :   @JsonKey(includeIfNull: false)
      81             :   final String? foreignId;
      82             : 
      83             :   ///
      84             :   @JsonKey(
      85             :     includeIfNull: false,
      86             :     fromJson: EnrichableField.deserialize,
      87             :     toJson: Serializer.readOnly,
      88             :   )
      89             :   final EnrichableField? target;
      90             : 
      91             :   ///
      92             :   @JsonKey(includeIfNull: false)
      93             :   final DateTime? time;
      94             : 
      95             :   ///
      96             :   @JsonKey(
      97             :     includeIfNull: false,
      98             :     fromJson: EnrichableField.deserialize,
      99             :     toJson: Serializer.readOnly,
     100             :   )
     101             :   final EnrichableField? origin;
     102             : 
     103             :   ///
     104             :   @JsonKey(includeIfNull: false, toJson: Serializer.readOnly)
     105             :   final List<String>? to;
     106             : 
     107             :   ///
     108             :   @JsonKey(includeIfNull: false, toJson: Serializer.readOnly)
     109             :   final double? score;
     110             : 
     111             :   ///
     112             :   @JsonKey(includeIfNull: false, toJson: Serializer.readOnly)
     113             :   final Map<String, Object>? analytics;
     114             : 
     115             :   ///
     116             :   @JsonKey(includeIfNull: false, toJson: Serializer.readOnly)
     117             :   final Map<String, Object>? extraContext;
     118             : 
     119             :   ///
     120             :   @JsonKey(includeIfNull: false, toJson: Serializer.readOnly)
     121             :   final Map<String, Object>? reactionCounts;
     122             : 
     123             :   ///
     124             :   @JsonKey(includeIfNull: false, toJson: Serializer.readOnly)
     125             :   final Map<String, List<Reaction>>? ownReactions;
     126             : 
     127             :   ///
     128             :   @JsonKey(includeIfNull: false, toJson: Serializer.readOnly)
     129             :   final Map<String, List<Reaction>>? latestReactions;
     130             : 
     131             :   /// Map of custom user extraData
     132             :   @JsonKey(includeIfNull: false)
     133             :   final Map<String, Object>? extraData;
     134             : 
     135             :   /// Known top level fields.
     136             :   /// Useful for [Serializer] methods.
     137             :   static const topLevelFields = [
     138             :     'actor',
     139             :     'verb',
     140             :     'object',
     141             :     'id',
     142             :     'foreign_id',
     143             :     'target',
     144             :     'time',
     145             :     'to',
     146             :     'analytics',
     147             :     'extra_context',
     148             :     'origin',
     149             :     'score',
     150             :     'reaction_counts',
     151             :     'own_reactions',
     152             :     'latest_reactions',
     153             :   ];
     154             : 
     155           4 :   @override
     156           4 :   List<Object?> get props => [
     157           4 :         actor,
     158           4 :         object,
     159           4 :         verb,
     160           4 :         target,
     161           4 :         to,
     162           4 :         foreignId,
     163           4 :         id,
     164           4 :         time,
     165           4 :         analytics,
     166           4 :         extraContext,
     167           4 :         origin,
     168           4 :         score,
     169           4 :         extraData,
     170           4 :         reactionCounts,
     171           4 :         ownReactions,
     172           4 :         latestReactions,
     173             :       ];
     174             : 
     175             :   /// Serialize to json
     176           2 :   Map<String, dynamic> toJson() => Serializer.moveKeysToMapInPlace(
     177           1 :       _$EnrichedActivityToJson(this), topLevelFields);
     178             : }

Generated by: LCOV version 1.15