-
1
-
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
-
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
-
21
-
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
-
30
-
31
-
32
-
33
-
34
-
35
-
36
-
37
-
38
-
39
-
40
-
41
-
42
-
43
-
44
-
45
-
46
-
47
-
48
-
49
-
50
-
51
-
52
-
53
-
54
-
55
-
56
-
57
-
58
-
59
-
60
-
61
-
62
-
63
-
64
-
65
-
66
-
67
-
68
-
69
-
70
-
71
-
72
-
73
-
74
-
75
-
76
-
77
-
78
-
79
-
80
-
81
-
82
-
83
-
84
-
85
-
86
-
87
-
88
-
89
-
90
-
91
-
92
-
93
-
94
-
95
-
96
-
97
-
98
-
99
-
100
-
101
-
102
-
103
-
104
-
105
-
106
-
107
-
108
-
109
-
110
-
111
-
112
-
113
-
114
-
115
-
116
-
117
-
118
-
119
-
120
-
121
-
122
-
123
-
124
-
125
-
126
-
127
-
128
-
129
-
130
-
131
-
132
-
133
-
134
-
135
-
136
-
137
-
138
-
139
-
140
-
141
-
142
-
143
-
144
-
145
-
146
-
147
-
148
-
149
-
150
-
151
-
152
-
153
-
154
-
155
-
156
-
157
-
158
-
159
-
160
-
161
-
162
-
163
-
164
-
165
-
166
-
167
-
168
-
169
-
170
-
171
-
172
-
173
-
174
-
175
-
176
-
177
-
178
-
179
-
180
-
181
-
182
-
183
-
184
-
185
-
186
-
187
-
188
-
189
-
190
-
191
-
192
-
193
-
194
-
195
-
196
-
197
-
198
-
199
-
200
-
201
-
202
-
203
-
204
-
205
-
206
-
207
-
208
-
209
-
210
-
211
-
212
-
213
-
214
-
215
-
216
-
217
-
218
-
219
-
220
-
221
-
222
-
223
-
224
-
225
-
226
-
227
-
228
-
229
-
230
-
231
-
232
-
233
-
234
-
235
-
236
-
237
-
238
-
239
-
240
-
241
-
242
-
243
-
244
-
245
-
246
-
247
-
248
-
249
-
250
-
251
-
252
-
253
-
254
-
255
-
256
-
257
-
258
-
259
-
260
-
261
-
262
-
263
-
264
-
265
-
266
-
267
-
268
-
269
-
270
-
271
-
272
-
273
-
274
-
275
-
276
-
277
-
278
-
279
-
280
-
281
-
282
-
283
-
284
-
285
-
286
-
287
-
288
-
289
-
290
-
291
-
292
-
293
-
294
-
295
-
296
-
297
-
298
-
299
-
300
-
301
-
302
-
303
-
304
-
305
-
306
-
307
-
308
-
309
-
310
-
311
-
312
-
313
-
314
-
315
-
316
-
317
-
318
-
319
-
320
-
321
-
322
-
323
-
324
-
325
-
326
-
327
-
328
-
329
-
330
-
331
-
332
-
333
-
334
-
335
-
336
-
337
-
338
-
339
-
340
-
341
-
342
-
343
-
344
-
345
-
346
-
347
-
348
-
349
-
350
-
351
-
352
-
353
-
354
-
355
-
356
-
357
-
358
-
359
-
360
-
361
-
362
-
363
-
364
-
365
-
366
-
367
-
368
-
369
-
370
-
371
-
372
-
373
-
374
-
375
-
376
-
377
-
378
-
379
-
380
-
381
-
382
-
383
-
384
-
385
-
386
-
387
-
388
-
389
-
390
-
391
-
392
-
393
-
394
-
395
-
396
-
397
-
398
-
399
-
400
-
401
-
402
-
403
-
404
-
405
-
406
-
407
-
408
-
409
-
410
-
411
-
412
-
413
-
414
-
415
-
416
-
417
-
418
-
419
-
420
-
421
-
422
-
423
-
424
-
425
-
426
-
427
-
428
-
429
-
430
-
431
-
432
-
433
-
434
-
435
-
436
-
437
-
438
-
439
-
440
-
441
-
442
-
443
-
444
-
445
-
446
-
447
-
448
-
449
-
450
-
451
-
452
-
453
-
454
-
455
-
456
-
457
-
458
-
459
-
460
-
461
-
462
-
463
-
464
-
465
-
466
-
467
-
468
-
469
-
470
-
471
-
472
-
473
-
474
-
475
-
476
-
477
-
478
-
479
-
480
-
481
-
482
-
483
-
484
-
485
-
486
-
487
-
488
-
489
-
490
-
491
-
492
-
493
-
494
-
495
-
496
-
497
-
498
-
499
-
500
-
501
-
502
-
503
-
504
-
505
-
506
-
507
-
508
-
509
-
510
-
511
-
512
-
513
-
514
-
515
-
516
-
517
-
518
-
519
-
520
-
521
-
522
-
523
-
524
-
525
-
526
-
527
-
528
-
529
-
530
-
531
-
532
-
533
-
534
-
535
-
536
-
537
-
538
-
539
-
540
-
541
-
542
-
543
-
544
-
545
-
546
-
547
-
548
-
549
-
550
-
551
-
552
-
553
-
554
-
555
-
556
-
557
-
558
-
559
-
560
-
561
-
562
-
563
-
564
-
565
-
566
-
567
-
568
-
569
-
570
-
571
-
572
-
573
-
574
-
575
-
576
-
577
-
578
-
579
-
580
-
581
-
582
-
583
-
584
-
585
-
586
-
587
-
588
-
589
-
590
-
591
-
592
-
593
-
594
-
595
-
596
-
597
-
598
-
599
-
600
-
601
-
602
-
603
-
604
-
605
-
606
-
607
-
608
-
609
-
610
-
611
-
612
-
613
-
614
-
615
-
616
-
617
-
618
-
619
-
620
-
621
-
622
-
623
-
624
-
625
-
626
-
627
-
628
-
629
-
630
-
631
-
632
-
633
-
634
-
635
-
636
-
637
-
638
-
639
-
640
-
641
-
642
-
643
-
644
-
645
-
646
-
647
-
648
-
649
-
650
-
651
-
652
-
653
-
654
-
655
-
656
-
657
-
658
-
659
-
660
-
661
-
662
-
663
-
664
-
665
-
666
-
667
-
668
-
669
-
670
-
671
-
672
-
673
-
674
-
675
-
676
-
677
-
678
-
679
-
680
-
681
-
682
-
683
-
684
-
685
-
686
-
687
-
688
-
689
-
690
-
691
-
692
-
693
-
694
-
695
-
696
-
697
-
698
-
699
-
700
-
701
-
702
-
703
-
704
-
705
-
706
-
707
-
708
-
709
-
710
-
711
-
712
-
713
-
714
-
715
-
716
-
717
-
718
-
719
-
720
-
721
-
722
-
723
-
724
-
725
-
726
-
727
-
728
-
729
-
730
-
731
-
732
-
733
-
734
-
735
-
736
-
737
-
738
-
739
-
740
-
741
-
742
-
743
-
744
-
745
-
746
-
747
-
748
-
749
-
750
-
751
-
752
-
753
-
754
-
755
-
756
-
757
-
758
-
759
-
760
-
761
-
762
-
763
-
764
-
765
-
766
-
767
-
768
-
769
-
770
-
771
-
772
-
773
-
774
-
775
-
776
-
777
-
778
-
779
-
780
-
781
-
782
-
783
-
784
-
785
-
786
-
787
-
788
-
789
-
790
-
791
-
792
-
793
-
794
-
795
-
796
-
797
-
798
-
799
-
800
-
801
-
802
-
803
-
804
-
805
-
806
-
807
-
808
-
809
-
810
-
811
-
812
-
813
-
814
-
815
-
816
-
817
-
818
-
819
-
820
-
821
-
822
-
823
-
824
-
825
-
826
-
827
-
828
-
829
-
830
-
831
-
832
-
833
-
834
-
835
-
836
-
837
-
838
-
839
-
840
-
841
-
842
-
843
-
844
-
845
-
846
-
847
-
848
-
849
-
850
-
851
-
852
-
853
-
854
-
855
-
856
-
857
-
858
-
859
-
860
-
861
-
862
-
863
-
864
-
865
-
866
-
867
-
868
-
869
-
870
-
871
-
872
-
873
-
874
-
875
-
876
-
877
-
878
-
879
-
880
-
881
-
882
-
883
-
884
-
885
-
886
-
887
-
888
-
889
-
890
-
891
-
892
-
893
-
894
-
895
-
896
-
897
-
898
-
899
-
900
-
901
-
902
-
903
-
904
-
905
-
906
-
907
-
908
-
909
-
910
-
911
-
912
-
913
-
914
-
915
-
916
-
917
-
918
-
919
-
920
-
921
-
922
-
923
-
924
-
925
-
926
-
927
-
928
-
929
-
930
-
931
-
932
-
933
-
934
-
935
-
936
-
937
-
938
-
939
-
940
-
941
-
942
-
943
-
944
-
945
-
946
-
947
-
948
-
949
-
950
-
951
-
952
-
953
-
954
-
955
-
956
-
957
-
958
-
959
-
960
-
961
-
962
-
963
-
964
-
965
-
966
-
967
-
968
-
969
-
970
-
971
package activitypub
import (
"fmt"
"testing"
)
func TestActivityNew(t *testing.T) {
var testValue = ObjectID("test")
var testType ActivityVocabularyType = "Accept"
a := ActivityNew(testValue, testType, nil)
if a.ID != testValue {
t.Errorf("Activity Id '%v' different than expected '%v'", a.ID, testValue)
}
if a.Type != testType {
t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, testType)
}
g := ActivityNew(testValue, "", nil)
if g.ID != testValue {
t.Errorf("Activity Id '%v' different than expected '%v'", g.ID, testValue)
}
if g.Type != ActivityType {
t.Errorf("Activity Type '%v' different than expected '%v'", g.Type, ActivityType)
}
}
func TestAcceptNew(t *testing.T) {
var testValue = ObjectID("test")
a := AcceptNew(testValue, nil)
if a.ID != testValue {
t.Errorf("Activity Id '%v' different than expected '%v'", a.ID, testValue)
}
if a.Type != AcceptType {
t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, AcceptType)
}
}
func TestAddNew(t *testing.T) {
var testValue = ObjectID("test")
a := AddNew(testValue, nil, nil)
if a.ID != testValue {
t.Errorf("Activity Id '%v' different than expected '%v'", a.ID, testValue)
}
if a.Type != AddType {
t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, AddType)
}
}
func TestAnnounceNew(t *testing.T) {
var testValue = ObjectID("test")
a := AnnounceNew(testValue, nil)
if a.ID != testValue {
t.Errorf("Activity Id '%v' different than expected '%v'", a.ID, testValue)
}
if a.Type != AnnounceType {
t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, AnnounceType)
}
}
func TestBlockNew(t *testing.T) {
var testValue = ObjectID("test")
a := BlockNew(testValue, nil)
if a.ID != testValue {
t.Errorf("Activity Id '%v' different than expected '%v'", a.ID, testValue)
}
if a.Type != BlockType {
t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, BlockType)
}
}
func TestCreateNew(t *testing.T) {
var testValue = ObjectID("test")
a := CreateNew(testValue, nil)
if a.ID != testValue {
t.Errorf("Activity Id '%v' different than expected '%v'", a.ID, testValue)
}
if a.Type != CreateType {
t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, CreateType)
}
}
func TestDeleteNew(t *testing.T) {
var testValue = ObjectID("test")
a := DeleteNew(testValue, nil)
if a.ID != testValue {
t.Errorf("Activity Id '%v' different than expected '%v'", a.ID, testValue)
}
if a.Type != DeleteType {
t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, DeleteType)
}
}
func TestDislikeNew(t *testing.T) {
var testValue = ObjectID("test")
a := DislikeNew(testValue, nil)
if a.ID != testValue {
t.Errorf("Activity Id '%v' different than expected '%v'", a.ID, testValue)
}
if a.Type != DislikeType {
t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, DislikeType)
}
}
func TestFlagNew(t *testing.T) {
var testValue = ObjectID("test")
a := FlagNew(testValue, nil)
if a.ID != testValue {
t.Errorf("Activity Id '%v' different than expected '%v'", a.ID, testValue)
}
if a.Type != FlagType {
t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, FlagType)
}
}
func TestFollowNew(t *testing.T) {
var testValue = ObjectID("test")
a := FollowNew(testValue, nil)
if a.ID != testValue {
t.Errorf("Activity Id '%v' different than expected '%v'", a.ID, testValue)
}
if a.Type != FollowType {
t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, FollowType)
}
}
func TestIgnoreNew(t *testing.T) {
var testValue = ObjectID("test")
a := IgnoreNew(testValue, nil)
if a.ID != testValue {
t.Errorf("Activity Id '%v' different than expected '%v'", a.ID, testValue)
}
if a.Type != IgnoreType {
t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, IgnoreType)
}
}
func TestInviteNew(t *testing.T) {
var testValue = ObjectID("test")
a := InviteNew(testValue, nil)
if a.ID != testValue {
t.Errorf("Activity Id '%v' different than expected '%v'", a.ID, testValue)
}
if a.Type != InviteType {
t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, InviteType)
}
}
func TestJoinNew(t *testing.T) {
var testValue = ObjectID("test")
a := JoinNew(testValue, nil)
if a.ID != testValue {
t.Errorf("Activity Id '%v' different than expected '%v'", a.ID, testValue)
}
if a.Type != JoinType {
t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, JoinType)
}
}
func TestLeaveNew(t *testing.T) {
var testValue = ObjectID("test")
a := LeaveNew(testValue, nil)
if a.ID != testValue {
t.Errorf("Activity Id '%v' different than expected '%v'", a.ID, testValue)
}
if a.Type != LeaveType {
t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, LeaveType)
}
}
func TestLikeNew(t *testing.T) {
var testValue = ObjectID("test")
a := LikeNew(testValue, nil)
if a.ID != testValue {
t.Errorf("Activity Id '%v' different than expected '%v'", a.ID, testValue)
}
if a.Type != LikeType {
t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, LikeType)
}
}
func TestListenNew(t *testing.T) {
var testValue = ObjectID("test")
a := ListenNew(testValue, nil)
if a.ID != testValue {
t.Errorf("Activity Id '%v' different than expected '%v'", a.ID, testValue)
}
if a.Type != ListenType {
t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, ListenType)
}
}
func TestMoveNew(t *testing.T) {
var testValue = ObjectID("test")
a := MoveNew(testValue, nil)
if a.ID != testValue {
t.Errorf("Activity Id '%v' different than expected '%v'", a.ID, testValue)
}
if a.Type != MoveType {
t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, MoveType)
}
}
func TestOfferNew(t *testing.T) {
var testValue = ObjectID("test")
a := OfferNew(testValue, nil)
if a.ID != testValue {
t.Errorf("Activity Id '%v' different than expected '%v'", a.ID, testValue)
}
if a.Type != OfferType {
t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, OfferType)
}
}
func TestRejectNew(t *testing.T) {
var testValue = ObjectID("test")
a := RejectNew(testValue, nil)
if a.ID != testValue {
t.Errorf("Activity Id '%v' different than expected '%v'", a.ID, testValue)
}
if a.Type != RejectType {
t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, RejectType)
}
}
func TestReadNew(t *testing.T) {
var testValue = ObjectID("test")
a := ReadNew(testValue, nil)
if a.ID != testValue {
t.Errorf("Activity Id '%v' different than expected '%v'", a.ID, testValue)
}
if a.Type != ReadType {
t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, ReadType)
}
}
func TestRemoveNew(t *testing.T) {
var testValue = ObjectID("test")
a := RemoveNew(testValue, nil, nil)
if a.ID != testValue {
t.Errorf("Activity Id '%v' different than expected '%v'", a.ID, testValue)
}
if a.Type != RemoveType {
t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, RemoveType)
}
}
func TestTentativeRejectNew(t *testing.T) {
var testValue = ObjectID("test")
a := TentativeRejectNew(testValue, nil)
if a.ID != testValue {
t.Errorf("Activity Id '%v' different than expected '%v'", a.ID, testValue)
}
if a.Type != TentativeRejectType {
t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, TentativeRejectType)
}
}
func TestTentativeAcceptNew(t *testing.T) {
var testValue = ObjectID("test")
a := TentativeAcceptNew(testValue, nil)
if a.ID != testValue {
t.Errorf("Activity Id '%v' different than expected '%v'", a.ID, testValue)
}
if a.Type != TentativeAcceptType {
t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, TentativeAcceptType)
}
}
func TestUndoNew(t *testing.T) {
var testValue = ObjectID("test")
a := UndoNew(testValue, nil)
if a.ID != testValue {
t.Errorf("Activity Id '%v' different than expected '%v'", a.ID, testValue)
}
if a.Type != UndoType {
t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, UndoType)
}
}
func TestUpdateNew(t *testing.T) {
var testValue = ObjectID("test")
a := UpdateNew(testValue, nil)
if a.ID != testValue {
t.Errorf("Activity Id '%v' different than expected '%v'", a.ID, testValue)
}
if a.Type != UpdateType {
t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, UpdateType)
}
}
func TestViewNew(t *testing.T) {
var testValue = ObjectID("test")
a := ViewNew(testValue, nil)
if a.ID != testValue {
t.Errorf("Activity Id '%v' different than expected '%v'", a.ID, testValue)
}
if a.Type != ViewType {
t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, ViewType)
}
}
func TestActivityRecipients(t *testing.T) {
bob := PersonNew("bob")
alice := PersonNew("alice")
foo := OrganizationNew("foo")
bar := GroupNew("bar")
a := ActivityNew("t", "test", nil)
a.To.Append(bob)
a.To.Append(alice)
a.To.Append(foo)
a.To.Append(bar)
if len(a.To) != 4 {
t.Errorf("%T.To should have exactly 4(four) elements, not %d", a, len(a.To))
}
a.To.Append(bar)
a.To.Append(alice)
a.To.Append(foo)
a.To.Append(bob)
if len(a.To) != 8 {
t.Errorf("%T.To should have exactly 8(eight) elements, not %d", a, len(a.To))
}
a.Recipients()
if len(a.To) != 4 {
t.Errorf("%T.To should have exactly 4(four) elements, not %d", a, len(a.To))
}
b := ActivityNew("t", "test", nil)
b.To.Append(bar)
b.To.Append(alice)
b.To.Append(foo)
b.To.Append(bob)
b.Bto.Append(bar)
b.Bto.Append(alice)
b.Bto.Append(foo)
b.Bto.Append(bob)
b.CC.Append(bar)
b.CC.Append(alice)
b.CC.Append(foo)
b.CC.Append(bob)
b.BCC.Append(bar)
b.BCC.Append(alice)
b.BCC.Append(foo)
b.BCC.Append(bob)
b.Recipients()
if len(b.To) != 4 {
t.Errorf("%T.To should have exactly 4(four) elements, not %d", b, len(b.To))
}
if len(b.Bto) != 0 {
t.Errorf("%T.Bto should have exactly 0(zero) elements, not %d", b, len(b.Bto))
}
if len(b.CC) != 0 {
t.Errorf("%T.CC should have exactly 0(zero) elements, not %d", b, len(b.CC))
}
if len(b.BCC) != 0 {
t.Errorf("%T.BCC should have exactly 0(zero) elements, not %d", b, len(b.BCC))
}
}
func TestBlockRecipients(t *testing.T) {
bob := PersonNew("bob")
alice := PersonNew("alice")
foo := OrganizationNew("foo")
bar := GroupNew("bar")
a := BlockNew("bbb", bob)
a.To.Append(bob)
a.To.Append(alice)
a.To.Append(foo)
a.To.Append(bar)
if len(a.To) != 4 {
t.Errorf("%T.To should have exactly 4(four) elements, not %d", a, len(a.To))
}
a.To.Append(bar)
a.To.Append(alice)
a.To.Append(foo)
a.To.Append(bob)
if len(a.To) != 8 {
t.Errorf("%T.To should have exactly 8(eight) elements, not %d", a, len(a.To))
}
a.Recipients()
if len(a.To) != 3 {
t.Errorf("%T.To should have exactly 3(three) elements, not %d", a, len(a.To))
}
b := BlockNew("t", bob)
b.To.Append(bar)
b.To.Append(alice)
b.To.Append(foo)
b.To.Append(bob)
b.Bto.Append(bar)
b.Bto.Append(alice)
b.Bto.Append(foo)
b.Bto.Append(bob)
b.CC.Append(bar)
b.CC.Append(alice)
b.CC.Append(foo)
b.CC.Append(bob)
b.BCC.Append(bar)
b.BCC.Append(alice)
b.BCC.Append(foo)
b.BCC.Append(bob)
b.Recipients()
if len(b.To) != 3 {
t.Errorf("%T.To should have exactly 3(three) elements, not %d", b, len(b.To))
}
if len(b.Bto) != 0 {
t.Errorf("%T.Bto should have exactly 0(zero) elements, not %d", b, len(b.Bto))
}
if len(b.CC) != 0 {
t.Errorf("%T.CC should have exactly 0(zero) elements, not %d", b, len(b.CC))
}
if len(b.BCC) != 0 {
t.Errorf("%T.BCC should have exactly 0(zero) elements, not %d", b, len(b.BCC))
}
var err error
recIds := make([]ObjectID, 0)
err = checkDedup(b.To, &recIds)
if err != nil {
t.Error(err)
}
err = checkDedup(b.Bto, &recIds)
if err != nil {
t.Error(err)
}
err = checkDedup(b.CC, &recIds)
if err != nil {
t.Error(err)
}
err = checkDedup(b.BCC, &recIds)
if err != nil {
t.Error(err)
}
}
func TestCreate_Recipients(t *testing.T) {
to := PersonNew("bob")
o := ObjectNew(ArticleType)
cc := PersonNew("alice")
o.ID = "something"
c := CreateNew("act", o)
c.To.Append(to)
c.CC.Append(cc)
c.BCC.Append(cc)
c.Recipients()
var err error
recIds := make([]ObjectID, 0)
err = checkDedup(c.To, &recIds)
if err != nil {
t.Error(err)
}
err = checkDedup(c.Bto, &recIds)
if err != nil {
t.Error(err)
}
err = checkDedup(c.CC, &recIds)
if err != nil {
t.Error(err)
}
err = checkDedup(c.BCC, &recIds)
if err != nil {
t.Error(err)
}
}
func TestDislike_Recipients(t *testing.T) {
to := PersonNew("bob")
o := ObjectNew(ArticleType)
cc := PersonNew("alice")
o.ID = "something"
d := DislikeNew("act", o)
d.To.Append(to)
d.CC.Append(cc)
d.BCC.Append(cc)
d.Recipients()
var err error
recIds := make([]ObjectID, 0)
err = checkDedup(d.To, &recIds)
if err != nil {
t.Error(err)
}
err = checkDedup(d.Bto, &recIds)
if err != nil {
t.Error(err)
}
err = checkDedup(d.CC, &recIds)
if err != nil {
t.Error(err)
}
err = checkDedup(d.BCC, &recIds)
if err != nil {
t.Error(err)
}
}
func TestLike_Recipients(t *testing.T) {
to := PersonNew("bob")
o := ObjectNew(ArticleType)
cc := PersonNew("alice")
o.ID = "something"
l := LikeNew("act", o)
l.To.Append(to)
l.CC.Append(cc)
l.BCC.Append(cc)
l.Recipients()
var err error
recIds := make([]ObjectID, 0)
err = checkDedup(l.To, &recIds)
if err != nil {
t.Error(err)
}
err = checkDedup(l.Bto, &recIds)
if err != nil {
t.Error(err)
}
err = checkDedup(l.CC, &recIds)
if err != nil {
t.Error(err)
}
err = checkDedup(l.BCC, &recIds)
if err != nil {
t.Error(err)
}
}
func TestUpdate_Recipients(t *testing.T) {
to := PersonNew("bob")
o := ObjectNew(ArticleType)
cc := PersonNew("alice")
o.ID = "something"
u := UpdateNew("act", o)
u.To.Append(to)
u.CC.Append(cc)
u.BCC.Append(cc)
u.Recipients()
var err error
recIds := make([]ObjectID, 0)
err = checkDedup(u.To, &recIds)
if err != nil {
t.Error(err)
}
err = checkDedup(u.Bto, &recIds)
if err != nil {
t.Error(err)
}
err = checkDedup(u.CC, &recIds)
if err != nil {
t.Error(err)
}
err = checkDedup(u.BCC, &recIds)
if err != nil {
t.Error(err)
}
}
func TestActivity_GetID(t *testing.T) {
a := ActivityNew("test", ActivityType, Person{})
if a.GetID() != "test" {
t.Errorf("%T should return an empty %T object. Received %#v", a, a.GetID(), a.GetID())
}
}
func TestActivity_GetIDGetType(t *testing.T) {
a := ActivityNew("test", ActivityType, Person{})
if a.GetID() != "test" || a.GetType() != ActivityType {
t.Errorf("%T should not return an empty %T object. Received %#v", a, a.GetID(), a.GetID())
}
}
func TestActivity_IsLink(t *testing.T) {
a := ActivityNew("test", ActivityType, Person{})
if a.IsLink() {
t.Errorf("%T should not respond true to IsLink", a)
}
}
func TestActivity_IsObject(t *testing.T) {
a := ActivityNew("test", ActivityType, Person{})
if !a.IsObject() {
t.Errorf("%T should respond true to IsObject", a)
}
}
func checkDedup(list ItemCollection, recIds *[]ObjectID) error {
for _, rec := range list {
for _, id := range *recIds {
if rec.GetID() == id {
return fmt.Errorf("%T[%s] already stored in recipients list, Deduplication faild", rec, id)
}
}
*recIds = append(*recIds, rec.GetID())
}
return nil
}
func TestActivity_Recipients(t *testing.T) {
to := PersonNew("bob")
o := ObjectNew(ArticleType)
cc := PersonNew("alice")
o.ID = "something"
c := ActivityNew("act", ActivityType, o)
c.To.Append(to)
c.CC.Append(cc)
c.BCC.Append(cc)
c.Recipients()
var err error
recIds := make([]ObjectID, 0)
err = checkDedup(c.To, &recIds)
if err != nil {
t.Error(err)
}
err = checkDedup(c.Bto, &recIds)
if err != nil {
t.Error(err)
}
err = checkDedup(c.CC, &recIds)
if err != nil {
t.Error(err)
}
err = checkDedup(c.BCC, &recIds)
if err != nil {
t.Error(err)
}
}
func TestBlock_Recipients(t *testing.T) {
to := PersonNew("bob")
o := ObjectNew(ArticleType)
cc := PersonNew("alice")
o.ID = "something"
b := BlockNew("act", o)
b.To.Append(to)
b.CC.Append(cc)
b.BCC.Append(cc)
b.Recipients()
var err error
recIds := make([]ObjectID, 0)
err = checkDedup(b.To, &recIds)
if err != nil {
t.Error(err)
}
err = checkDedup(b.Bto, &recIds)
if err != nil {
t.Error(err)
}
err = checkDedup(b.CC, &recIds)
if err != nil {
t.Error(err)
}
err = checkDedup(b.BCC, &recIds)
if err != nil {
t.Error(err)
}
}
func TestActivity_UnmarshalJSON(t *testing.T) {
a := Activity{}
dataEmpty := []byte("{}")
a.UnmarshalJSON(dataEmpty)
if a.ID != "" {
t.Errorf("Unmarshaled object %T should have empty ID, received %q", a, a.ID)
}
if a.Type != "" {
t.Errorf("Unmarshaled object %T should have empty Type, received %q", a, a.Type)
}
if a.AttributedTo != nil {
t.Errorf("Unmarshaled object %T should have empty AttributedTo, received %q", a, a.AttributedTo)
}
if len(a.Name) != 0 {
t.Errorf("Unmarshaled object %T should have empty Name, received %q", a, a.Name)
}
if len(a.Summary) != 0 {
t.Errorf("Unmarshaled object %T should have empty Summary, received %q", a, a.Summary)
}
if len(a.Content) != 0 {
t.Errorf("Unmarshaled object %T should have empty Content, received %q", a, a.Content)
}
if a.URL != nil {
t.Errorf("Unmarshaled object %T should have empty URL, received %v", a, a.URL)
}
if !a.Published.IsZero() {
t.Errorf("Unmarshaled object %T should have empty Published, received %q", a, a.Published)
}
if !a.StartTime.IsZero() {
t.Errorf("Unmarshaled object %T should have empty StartTime, received %q", a, a.StartTime)
}
if !a.Updated.IsZero() {
t.Errorf("Unmarshaled object %T should have empty Updated, received %q", a, a.Updated)
}
}
func TestCreate_UnmarshalJSON(t *testing.T) {
c := Create{}
dataEmpty := []byte("{}")
c.UnmarshalJSON(dataEmpty)
if c.ID != "" {
t.Errorf("Unmarshaled object %T should have empty ID, received %q", c, c.ID)
}
if c.Type != "" {
t.Errorf("Unmarshaled object %T should have empty Type, received %q", c, c.Type)
}
if c.AttributedTo != nil {
t.Errorf("Unmarshaled object %T should have empty AttributedTo, received %q", c, c.AttributedTo)
}
if len(c.Name) != 0 {
t.Errorf("Unmarshaled object %T should have empty Name, received %q", c, c.Name)
}
if len(c.Summary) != 0 {
t.Errorf("Unmarshaled object %T should have empty Summary, received %q", c, c.Summary)
}
if len(c.Content) != 0 {
t.Errorf("Unmarshaled object %T should have empty Content, received %q", c, c.Content)
}
if c.URL != nil {
t.Errorf("Unmarshaled object %T should have empty URL, received %v", c, c.URL)
}
if !c.Published.IsZero() {
t.Errorf("Unmarshaled object %T should have empty Published, received %q", c, c.Published)
}
if !c.StartTime.IsZero() {
t.Errorf("Unmarshaled object %T should have empty StartTime, received %q", c, c.StartTime)
}
if !c.Updated.IsZero() {
t.Errorf("Unmarshaled object %T should have empty Updated, received %q", c, c.Updated)
}
}
func TestDislike_UnmarshalJSON(t *testing.T) {
d := Dislike{}
dataEmpty := []byte("{}")
d.UnmarshalJSON(dataEmpty)
if d.ID != "" {
t.Errorf("Unmarshaled object %T should have empty ID, received %q", d, d.ID)
}
if d.Type != "" {
t.Errorf("Unmarshaled object %T should have empty Type, received %q", d, d.Type)
}
if d.AttributedTo != nil {
t.Errorf("Unmarshaled object %T should have empty AttributedTo, received %q", d, d.AttributedTo)
}
if len(d.Name) != 0 {
t.Errorf("Unmarshaled object %T should have empty Name, received %q", d, d.Name)
}
if len(d.Summary) != 0 {
t.Errorf("Unmarshaled object %T should have empty Summary, received %q", d, d.Summary)
}
if len(d.Content) != 0 {
t.Errorf("Unmarshaled object %T should have empty Content, received %q", d, d.Content)
}
if d.URL != nil {
t.Errorf("Unmarshaled object %T should have empty URL, received %v", d, d.URL)
}
if !d.Published.IsZero() {
t.Errorf("Unmarshaled object %T should have empty Published, received %q", d, d.Published)
}
if !d.StartTime.IsZero() {
t.Errorf("Unmarshaled object %T should have empty StartTime, received %q", d, d.StartTime)
}
if !d.Updated.IsZero() {
t.Errorf("Unmarshaled object %T should have empty Updated, received %q", d, d.Updated)
}
}
func TestLike_UnmarshalJSON(t *testing.T) {
l := Like{}
dataEmpty := []byte("{}")
l.UnmarshalJSON(dataEmpty)
if l.ID != "" {
t.Errorf("Unmarshaled object %T should have empty ID, received %q", l, l.ID)
}
if l.Type != "" {
t.Errorf("Unmarshaled object %T should have empty Type, received %q", l, l.Type)
}
if l.AttributedTo != nil {
t.Errorf("Unmarshaled object %T should have empty AttributedTo, received %q", l, l.AttributedTo)
}
if len(l.Name) != 0 {
t.Errorf("Unmarshaled object %T should have empty Name, received %q", l, l.Name)
}
if len(l.Summary) != 0 {
t.Errorf("Unmarshaled object %T should have empty Summary, received %q", l, l.Summary)
}
if len(l.Content) != 0 {
t.Errorf("Unmarshaled object %T should have empty Content, received %q", l, l.Content)
}
if l.URL != nil {
t.Errorf("Unmarshaled object %T should have empty URL, received %v", l, l.URL)
}
if !l.Published.IsZero() {
t.Errorf("Unmarshaled object %T should have empty Published, received %q", l, l.Published)
}
if !l.StartTime.IsZero() {
t.Errorf("Unmarshaled object %T should have empty StartTime, received %q", l, l.StartTime)
}
if !l.Updated.IsZero() {
t.Errorf("Unmarshaled object %T should have empty Updated, received %q", l, l.Updated)
}
}
func TestUpdate_UnmarshalJSON(t *testing.T) {
u := Update{}
dataEmpty := []byte("{}")
u.UnmarshalJSON(dataEmpty)
if u.ID != "" {
t.Errorf("Unmarshaled object %T should have empty ID, received %q", u, u.ID)
}
if u.Type != "" {
t.Errorf("Unmarshaled object %T should have empty Type, received %q", u, u.Type)
}
if u.AttributedTo != nil {
t.Errorf("Unmarshaled object %T should have empty AttributedTo, received %q", u, u.AttributedTo)
}
if len(u.Name) != 0 {
t.Errorf("Unmarshaled object %T should have empty Name, received %q", u, u.Name)
}
if len(u.Summary) != 0 {
t.Errorf("Unmarshaled object %T should have empty Summary, received %q", u, u.Summary)
}
if len(u.Content) != 0 {
t.Errorf("Unmarshaled object %T should have empty Content, received %q", u, u.Content)
}
if u.URL != nil {
t.Errorf("Unmarshaled object %T should have empty URL, received %v", u, u.URL)
}
if !u.Published.IsZero() {
t.Errorf("Unmarshaled object %T should have empty Published, received %q", u, u.Published)
}
if !u.StartTime.IsZero() {
t.Errorf("Unmarshaled object %T should have empty StartTime, received %q", u, u.StartTime)
}
if !u.Updated.IsZero() {
t.Errorf("Unmarshaled object %T should have empty Updated, received %q", u, u.Updated)
}
}
func TestToActivity(t *testing.T) {
var it Item
act := ActivityNew(ObjectID("test"), CreateType, nil)
it = act
a, err := ToActivity(it)
if err != nil {
t.Error(err)
}
if a != act {
t.Errorf("Invalid activity returned by ToActivity #%v", a)
}
ob := ObjectNew(ArticleType)
it = ob
o, err := ToActivity(it)
if err == nil {
t.Errorf("Error returned when calling ToActivity with object should not be nil")
}
if o != nil {
t.Errorf("Invalid return by ToActivity #%v, should have been nil", o)
}
}
func TestFlattenActivityProperties(t *testing.T) {
t.Skipf("TODO")
}
func TestValidEventRSVPActivityType(t *testing.T) {
t.Skipf("TODO")
}
func TestValidGroupManagementActivityType(t *testing.T) {
t.Skipf("TODO")
}
func TestActivity_Clean(t *testing.T) {
t.Skipf("TODO")
}
func TestActivity_IsCollection(t *testing.T) {
t.Skipf("TODO")
}