-
Notifications
You must be signed in to change notification settings - Fork 188
/
TestOrgStruct.java
1720 lines (1380 loc) · 72.3 KB
/
TestOrgStruct.java
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
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright (c) 2010-2020 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/
package com.evolveum.midpoint.model.intest.orgstruct;
import static org.assertj.core.api.Assertions.assertThat;
import static org.testng.AssertJUnit.assertEquals;
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.annotation.DirtiesContext.ClassMode;
import org.springframework.test.context.ContextConfiguration;
import org.testng.AssertJUnit;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test;
import com.evolveum.icf.dummy.resource.DummyAccount;
import com.evolveum.midpoint.model.api.ModelExecuteOptions;
import com.evolveum.midpoint.model.common.expression.ExpressionEnvironment;
import com.evolveum.midpoint.model.common.expression.ModelExpressionThreadLocalHolder;
import com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.PrismReferenceDefinition;
import com.evolveum.midpoint.prism.PrismReferenceValue;
import com.evolveum.midpoint.prism.delta.ItemDelta;
import com.evolveum.midpoint.prism.delta.ObjectDelta;
import com.evolveum.midpoint.prism.delta.ReferenceDelta;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.prism.query.ObjectQuery;
import com.evolveum.midpoint.prism.util.PrismAsserts;
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.schema.internals.InternalCounters;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.util.MiscSchemaUtil;
import com.evolveum.midpoint.schema.util.ObjectQueryUtil;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.test.DummyResourceContoller;
import com.evolveum.midpoint.test.util.TestUtil;
import com.evolveum.midpoint.util.exception.*;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
/**
* @author semancik
*/
@ContextConfiguration(locations = { "classpath:ctx-model-intest-test-main.xml" })
@DirtiesContext(classMode = ClassMode.AFTER_CLASS)
@Listeners({ com.evolveum.midpoint.tools.testng.AlphabeticalMethodInterceptor.class })
public class TestOrgStruct extends AbstractInitializedModelIntegrationTest {
public static final File TEST_DIR = new File("src/test/resources/orgstruct");
// RED resource has STRONG mappings
protected static final File RESOURCE_DUMMY_ORGTARGET_FILE = new File(TEST_DIR, "resource-dummy-orgtarget.xml");
protected static final String RESOURCE_DUMMY_ORGTARGET_OID = "89cb4c72-cd61-11e8-a21b-27cbf58a8c0e";
protected static final String RESOURCE_DUMMY_ORGTARGET_NAME = "orgtarget";
public static final File ROLE_DEFENDER_FILE = new File(TEST_DIR, "role-defender.xml");
public static final String ROLE_DEFENDER_OID = "12345111-1111-2222-1111-121212111567";
public static final File ROLE_META_DEFENDER_FILE = new File(TEST_DIR, "role-meta-defender.xml");
public static final String ROLE_META_DEFENDER_OID = "12345111-1111-2222-1111-121212111568";
public static final File ROLE_OFFENDER_FILE = new File(TEST_DIR, "role-offender.xml");
public static final String ROLE_OFFENDER_OID = "12345111-1111-2222-1111-121212111569";
public static final File ROLE_OFFENDER_ADMIN_FILE = new File(TEST_DIR, "role-offender-admin.xml");
public static final String ROLE_OFFENDER_ADMIN_OID = "12345111-1111-2222-1111-121212111566";
public static final File ROLE_META_DEFENDER_ADMIN_FILE = new File(TEST_DIR, "role-meta-defender-admin.xml");
public static final String ROLE_META_DEFENDER_ADMIN_OID = "12345111-1111-2222-1111-121212111565";
public static final File ROLE_END_PIRATE_FILE = new File(TEST_DIR, "role-end-pirate.xml");
public static final String ROLE_END_PIRATE_OID = "67780b58-cd69-11e8-b664-dbc7b09e163e";
public static final File ORG_TEMP_FILE = new File(TEST_DIR, "org-temp.xml");
public static final String ORG_TEMP_OID = "43214321-4311-0952-4762-854392584320";
public static final File ORG_FICTIONAL_FILE = new File(TEST_DIR, "org-fictional.xml");
public static final String ORG_FICTIONAL_OID = "b5b179cc-03c7-11e5-9839-001e8c717e5b";
@Override
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
super.initSystem(initTask, initResult);
addObject(ROLE_DEFENDER_FILE);
addObject(ROLE_META_DEFENDER_FILE);
addObject(ROLE_META_DEFENDER_ADMIN_FILE);
addObject(ROLE_OFFENDER_FILE);
addObject(ROLE_OFFENDER_ADMIN_FILE);
addObject(ROLE_END_PIRATE_FILE);
addObject(USER_HERMAN_FILE);
setDefaultUserTemplate(USER_TEMPLATE_ORG_ASSIGNMENT_OID); // used for tests 4xx
//DebugUtil.setDetailedDebugDump(true);
initDummyResourcePirate(RESOURCE_DUMMY_ORGTARGET_NAME,
RESOURCE_DUMMY_ORGTARGET_FILE, RESOURCE_DUMMY_ORGTARGET_OID, initTask, initResult);
}
@Test
public void test010AddOrgStruct() throws Exception {
// Dummy, just to be overridden in subclasses
addOrgStruct();
}
protected void addOrgStruct() throws Exception {
// Dummy, just to be overridden in subclasses
}
@Test
public void test051OrgStructSanity() throws Exception {
// WHEN
assertMonkeyIslandOrgSanity();
}
@Test
public void test052RootOrgQuery() throws Exception {
// GIVEN
Task task = getTestTask();
OperationResult result = task.getResult();
ObjectQuery query = ObjectQueryUtil.createRootOrgQuery(prismContext);
// WHEN
List<PrismObject<OrgType>> rootOrgs = modelService.searchObjects(OrgType.class, query, null, task, result);
// THEN
assertEquals("Unexpected number of root orgs", 2, rootOrgs.size());
// Post-condition
assertMonkeyIslandOrgSanity();
}
@Test
public void test100JackAssignOrgtarget() throws Exception {
Task task = getTestTask();
OperationResult result = task.getResult();
// Precondition
assertNoDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME);
assertNoDummyAccount(RESOURCE_DUMMY_ORGTARGET_NAME, ACCOUNT_JACK_DUMMY_USERNAME);
// WHEN
assignAccountToUser(USER_JACK_OID, RESOURCE_DUMMY_ORGTARGET_OID, null, task, result);
// THEN
PrismObject<UserType> userJack = getUser(USER_JACK_OID);
display("User jack after", userJack);
assertAccount(userJack, RESOURCE_DUMMY_ORGTARGET_OID);
assertJackOrgtarget(null);
// Postcondition
assertMonkeyIslandOrgSanity();
}
/**
* Scumm bar org also acts as a role, assigning account on dummy resource.
*/
@Test
public void test101JackAssignScummBar() throws Exception {
Task task = getTestTask();
OperationResult result = task.getResult();
// Precondition
assertNoDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME);
// WHEN
assignOrg(USER_JACK_OID, ORG_SCUMM_BAR_OID, task, result);
// THEN
PrismObject<UserType> userJack = getUser(USER_JACK_OID);
display("User jack after", userJack);
assertUserOrg(userJack, ORG_SCUMM_BAR_OID);
assertDefaultDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME, USER_JACK_FULL_NAME, true);
assertJackOrgtarget(null, ORG_SCUMM_BAR_NAME);
// Postcondition
assertMonkeyIslandOrgSanity();
}
@Test
public void test102JackUnassignScummBar() throws Exception {
Task task = getTestTask();
OperationResult result = task.getResult();
// WHEN
unassignOrg(USER_JACK_OID, ORG_SCUMM_BAR_OID, task, result);
// THEN
PrismObject<UserType> userJack = getUser(USER_JACK_OID);
display("User jack after", userJack);
assertUserNoOrg(userJack);
assertJackOrgtarget(null);
// Postcondition
assertMonkeyIslandOrgSanity();
}
/**
* Assign jack to both functional and project orgstruct.
* Assign both orgs at the same time.
*/
@Test
public void test201JackAssignScummBarAndSaveElaine() throws Exception {
Task task = getTestTask();
OperationResult result = task.getResult();
Collection<ItemDelta<?, ?>> modifications = new ArrayList<>();
modifications.add(createAssignmentModification(ORG_SCUMM_BAR_OID, OrgType.COMPLEX_TYPE, null, null, null, true));
modifications.add(createAssignmentModification(ORG_SAVE_ELAINE_OID, OrgType.COMPLEX_TYPE, null, null, null, true));
ObjectDelta<UserType> userDelta = prismContext.deltaFactory().object()
.createModifyDelta(USER_JACK_OID, modifications, UserType.class);
Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(userDelta);
// WHEN
modelService.executeChanges(deltas, null, task, result);
// THEN
PrismObject<UserType> userJack = getUser(USER_JACK_OID);
display("User jack after", userJack);
assertUserOrg(userJack, ORG_SCUMM_BAR_OID, ORG_SAVE_ELAINE_OID);
assertJackOrgtarget(null, ORG_SCUMM_BAR_NAME);
// Postcondition
assertMonkeyIslandOrgSanity();
}
/**
* Assign jack to functional orgstruct again.
*/
@Test
public void test202JackAssignMinistryOfOffense() throws Exception {
Task task = getTestTask();
OperationResult result = task.getResult();
// WHEN
assignOrg(USER_JACK_OID, ORG_MINISTRY_OF_OFFENSE_OID, task, result);
// THEN
PrismObject<UserType> userJack = getUser(USER_JACK_OID);
display("User jack after", userJack);
assertUserOrg(userJack, ORG_SCUMM_BAR_OID, ORG_SAVE_ELAINE_OID, ORG_MINISTRY_OF_OFFENSE_OID);
assertJackOrgtarget(null, ORG_SCUMM_BAR_NAME, ORG_MINISTRY_OF_OFFENSE_NAME);
// Postcondition
assertMonkeyIslandOrgSanity();
}
@Test
public void test207JackUnAssignScummBar() throws Exception {
Task task = getTestTask();
OperationResult result = task.getResult();
// WHEN
unassignOrg(USER_JACK_OID, ORG_SCUMM_BAR_OID, task, result);
// THEN
PrismObject<UserType> userJack = getUser(USER_JACK_OID);
display("User jack after", userJack);
assertUserOrg(userJack, ORG_SAVE_ELAINE_OID, ORG_MINISTRY_OF_OFFENSE_OID);
assertJackOrgtarget(null, ORG_MINISTRY_OF_OFFENSE_NAME);
// Postcondition
assertMonkeyIslandOrgSanity();
}
@Test
public void test208JackUnassignAll() throws Exception {
Task task = getTestTask();
OperationResult result = task.getResult();
// WHEN
when();
unassignAllReplace(USER_JACK_OID, task, result);
// THEN
then();
assertSuccess(result);
PrismObject<UserType> userJack = getUser(USER_JACK_OID);
display("User jack after", userJack);
assertUserNoOrg(userJack);
assertNoDummyAccount(RESOURCE_DUMMY_ORGTARGET_NAME, ACCOUNT_JACK_DUMMY_USERNAME);
// Postcondition
assertMonkeyIslandOrgSanity();
}
// besides Offense org assignment, we create also Defender role assignment (which indirectly creates Defense org assignment)
@Test
public void test210JackAssignMinistryOfOffenseMember() throws Exception {
Task task = getTestTask();
OperationResult result = task.getResult();
Collection<ItemDelta<?, ?>> modifications = new ArrayList<>();
modifications.add(createAssignmentModification(ORG_MINISTRY_OF_OFFENSE_OID, OrgType.COMPLEX_TYPE, null, null, null, true));
modifications.add(createAssignmentModification(ROLE_DEFENDER_OID, RoleType.COMPLEX_TYPE, null, null, null, true));
modifications.add(createAssignmentModification(RESOURCE_DUMMY_ORGTARGET_OID, ShadowKindType.ACCOUNT, null, true));
ObjectDelta<UserType> userDelta = prismContext.deltaFactory().object()
.createModifyDelta(USER_JACK_OID, modifications, UserType.class);
Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(userDelta);
// WHEN
modelService.executeChanges(deltas, null, task, result);
// THEN
PrismObject<UserType> userJack = getUser(USER_JACK_OID);
display("User jack after", userJack);
assertAssignedOrgs(userJack, ORG_MINISTRY_OF_OFFENSE_OID);
assertHasOrgs(userJack, ORG_MINISTRY_OF_OFFENSE_OID, ORG_MINISTRY_OF_DEFENSE_OID);
assertJackOrgtarget(null, ORG_MINISTRY_OF_OFFENSE_NAME, ORG_MINISTRY_OF_DEFENSE_NAME);
// Postcondition
assertMonkeyIslandOrgSanity();
}
@Test
public void test211JackAssignMinistryOfOffenseMinister() throws Exception {
Task task = getTestTask();
OperationResult result = task.getResult();
// WHEN
assignOrg(USER_JACK_OID, ORG_MINISTRY_OF_OFFENSE_OID, SchemaConstants.ORG_MANAGER, task, result);
// THEN
PrismObject<UserType> userJack = getUser(USER_JACK_OID);
display("User jack after", userJack);
assertAssignedOrgs(userJack, ORG_MINISTRY_OF_OFFENSE_OID, ORG_MINISTRY_OF_OFFENSE_OID);
assertHasOrgs(userJack, ORG_MINISTRY_OF_OFFENSE_OID, ORG_MINISTRY_OF_OFFENSE_OID, ORG_MINISTRY_OF_DEFENSE_OID);
assertAssignedOrg(userJack, ORG_MINISTRY_OF_OFFENSE_OID, SchemaConstants.ORG_MANAGER);
assertHasOrg(userJack, ORG_MINISTRY_OF_OFFENSE_OID, SchemaConstants.ORG_MANAGER);
assertAssignedOrg(userJack, ORG_MINISTRY_OF_OFFENSE_OID, null);
assertHasOrg(userJack, ORG_MINISTRY_OF_OFFENSE_OID, null);
assertHasOrg(userJack, ORG_MINISTRY_OF_DEFENSE_OID, null);
assertJackOrgtarget(null, ORG_MINISTRY_OF_OFFENSE_NAME, ORG_MINISTRY_OF_DEFENSE_NAME);
// Postcondition
assertMonkeyIslandOrgSanity();
}
@Test
public void test212JackUnassignMinistryOfOffenseMember() throws Exception {
Task task = getTestTask();
OperationResult result = task.getResult();
// WHEN
unassignOrg(USER_JACK_OID, ORG_MINISTRY_OF_OFFENSE_OID, null, task, result);
// THEN
PrismObject<UserType> userJack = getUser(USER_JACK_OID);
display("User jack after", userJack);
assertAssignedOrgs(userJack, ORG_MINISTRY_OF_OFFENSE_OID);
assertAssignedOrg(userJack, ORG_MINISTRY_OF_OFFENSE_OID, SchemaConstants.ORG_MANAGER);
assertHasOrgs(userJack, ORG_MINISTRY_OF_OFFENSE_OID, ORG_MINISTRY_OF_DEFENSE_OID);
assertHasOrg(userJack, ORG_MINISTRY_OF_OFFENSE_OID, SchemaConstants.ORG_MANAGER);
assertJackOrgtarget(null, ORG_MINISTRY_OF_DEFENSE_NAME);
// Postcondition
assertMonkeyIslandOrgSanity();
}
@Test
public void test213JackUnassignMinistryOfOffenseManager() throws Exception {
Task task = getTestTask();
OperationResult result = task.getResult();
// WHEN
unassignOrg(USER_JACK_OID, ORG_MINISTRY_OF_OFFENSE_OID, SchemaConstants.ORG_MANAGER, task, result);
// THEN
PrismObject<UserType> userJack = getUser(USER_JACK_OID);
display("User jack after", userJack);
assertAssignedNoOrg(userJack);
assertHasOrgs(userJack, ORG_MINISTRY_OF_DEFENSE_OID);
assertJackOrgtarget(null, ORG_MINISTRY_OF_DEFENSE_NAME);
// Postcondition
assertMonkeyIslandOrgSanity();
}
@Test
public void test220JackAssignMinistryOfOffenseMemberAgain() throws Exception {
Task task = getTestTask();
OperationResult result = task.getResult();
// WHEN
assignOrg(USER_JACK_OID, ORG_MINISTRY_OF_OFFENSE_OID, task, result);
// THEN
PrismObject<UserType> userJack = getUser(USER_JACK_OID);
display("User jack after", userJack);
assertAssignedOrgs(userJack, ORG_MINISTRY_OF_OFFENSE_OID);
assertHasOrgs(userJack, ORG_MINISTRY_OF_OFFENSE_OID, ORG_MINISTRY_OF_DEFENSE_OID);
assertAssignedOrg(userJack, ORG_MINISTRY_OF_OFFENSE_OID, null);
assertHasOrg(userJack, ORG_MINISTRY_OF_OFFENSE_OID, null);
assertJackOrgtarget(null, ORG_MINISTRY_OF_OFFENSE_NAME, ORG_MINISTRY_OF_DEFENSE_NAME);
// Postcondition
assertMonkeyIslandOrgSanity();
}
/**
* Assign jack to both functional and project orgstruct.
* Implemented to check org struct reconciliation in test223.
*/
@Test
public void test221JackAssignScummBarAndSaveElaine() throws Exception {
Task task = getTestTask();
OperationResult result = task.getResult();
Collection<ItemDelta<?, ?>> modifications = new ArrayList<>();
modifications.add(createAssignmentModification(ORG_SCUMM_BAR_OID, OrgType.COMPLEX_TYPE, null, null, null, true));
modifications.add(createAssignmentModification(ORG_SAVE_ELAINE_OID, OrgType.COMPLEX_TYPE, null, null, null, true));
ObjectDelta<UserType> userDelta = prismContext.deltaFactory().object()
.createModifyDelta(USER_JACK_OID, modifications, UserType.class);
// WHEN
executeChanges(userDelta, null, task, result);
// THEN
PrismObject<UserType> userJack = getUser(USER_JACK_OID);
display("User jack after", userJack);
assertAssignedOrgs(userJack, ORG_MINISTRY_OF_OFFENSE_OID, ORG_SCUMM_BAR_OID, ORG_SAVE_ELAINE_OID);
assertHasOrgs(userJack, ORG_MINISTRY_OF_OFFENSE_OID, ORG_SCUMM_BAR_OID, ORG_SAVE_ELAINE_OID, ORG_MINISTRY_OF_DEFENSE_OID);
assertJackOrgtarget(null, ORG_MINISTRY_OF_OFFENSE_NAME, ORG_MINISTRY_OF_DEFENSE_NAME, ORG_SCUMM_BAR_NAME);
// Postcondition
assertMonkeyIslandOrgSanity();
}
@Test
public void test223JackChangeMinistryOfOffenseMemberToManager() throws Exception {
Task task = getTestTask();
OperationResult result = task.getResult();
assertThat(getUser(USER_JACK_OID)).isNotNull();
Collection<ItemDelta<?, ?>> modifications = new ArrayList<>();
// this is now forbidden TODO 2020: do we want to keep it around?
// Long id = findAssignmentIdForTarget(jack, ORG_MINISTRY_OF_OFFENSE_OID);
// PrismReferenceDefinition referenceDefinition = getUserDefinition()
// .findItemDefinition(
// ItemPath.create(UserType.F_ASSIGNMENT, AssignmentType.F_TARGET_REF), PrismReferenceDefinition.class);
// ReferenceDelta referenceDelta = new ReferenceDelta(
// ItemPath.create(
// new NameItemPathSegment(UserType.F_ASSIGNMENT),
// new IdItemPathSegment(id),
// new NameItemPathSegment(AssignmentType.F_TARGET_REF)), referenceDefinition, prismContext);
// PrismReferenceValue oldValue = new PrismReferenceValueImpl(ORG_MINISTRY_OF_OFFENSE_OID, OrgType.COMPLEX_TYPE);
// PrismReferenceValue newValue = new PrismReferenceValueImpl(ORG_MINISTRY_OF_OFFENSE_OID, OrgType.COMPLEX_TYPE);
// newValue.setRelation(SchemaConstants.ORG_MANAGER);
//
// referenceDelta.addValueToDelete(oldValue);
// referenceDelta.addValueToAdd(newValue);
// modifications.add(referenceDelta);
modifications.add(createAssignmentModification(ORG_MINISTRY_OF_OFFENSE_OID, OrgType.COMPLEX_TYPE, null, null, null, false));
modifications.add(createAssignmentModification(ORG_MINISTRY_OF_OFFENSE_OID, OrgType.COMPLEX_TYPE, SchemaConstants.ORG_MANAGER, null, null, true));
ObjectDelta<UserType> userDelta = prismContext.deltaFactory().object()
.createModifyDelta(USER_JACK_OID, modifications, UserType.class);
// WHEN
executeChanges(userDelta, null, task, result);
// THEN
PrismObject<UserType> userJack = getUser(USER_JACK_OID);
display("User jack after", userJack);
assertAssignedOrgs(userJack, ORG_MINISTRY_OF_OFFENSE_OID, ORG_SCUMM_BAR_OID, ORG_SAVE_ELAINE_OID);
assertHasOrgs(userJack, ORG_MINISTRY_OF_OFFENSE_OID, ORG_SCUMM_BAR_OID, ORG_SAVE_ELAINE_OID, ORG_MINISTRY_OF_DEFENSE_OID);
assertAssignedOrg(userJack, ORG_MINISTRY_OF_OFFENSE_OID, SchemaConstants.ORG_MANAGER);
assertHasOrg(userJack, ORG_MINISTRY_OF_OFFENSE_OID, SchemaConstants.ORG_MANAGER);
assertAssignedOrg(userJack, ORG_SCUMM_BAR_OID, null);
assertHasOrg(userJack, ORG_SCUMM_BAR_OID, null);
assertAssignedOrg(userJack, ORG_SAVE_ELAINE_OID, null);
assertHasOrg(userJack, ORG_SAVE_ELAINE_OID, null);
assertJackOrgtarget(null, ORG_MINISTRY_OF_DEFENSE_NAME, ORG_SCUMM_BAR_NAME);
// Postcondition
assertMonkeyIslandOrgSanity();
}
/**
* Recompute jack. Make sure nothing is changed.
* MID-3384
*/
@Test
public void test230JackRecompute() throws Exception {
Task task = getTestTask();
OperationResult result = task.getResult();
rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT);
// WHEN
when();
recomputeUser(USER_JACK_OID, task, result);
// THEN
then();
assertSuccess(result);
assertRefs23x();
assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 2);
}
/**
* Destroy parentOrgRef and roleMembershipRef in the repo. Then recompute.
* Make sure that the refs are fixed.
* MID-3384
*/
@Test
public void test232JackDestroyRefsAndRecompute() throws Exception {
Task task = getTestTask();
OperationResult result = task.getResult();
clearUserOrgAndRoleRefs(USER_JACK_OID);
rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT);
rememberCounter(InternalCounters.CONNECTOR_OPERATION_COUNT);
// WHEN
when();
recomputeUser(USER_JACK_OID, executeOptions().reconcile(), task, result);
// THEN
then();
assertSuccess(result);
assertRefs23x();
assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 2);
assertCounterIncrement(InternalCounters.CONNECTOR_OPERATION_COUNT, 5);
}
/**
* Destroy parentOrgRef and roleMembershipRef in the repo. Then light recompute.
* Make sure that the refs are fixed and that the resources were not touched.
* MID-3384
*/
@Test
public void test234JackDestroyRefsAndLightRecompute() throws Exception {
Task task = getTestTask();
OperationResult result = task.getResult();
clearUserOrgAndRoleRefs(USER_JACK_OID);
rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT);
rememberCounter(InternalCounters.CONNECTOR_OPERATION_COUNT);
PartialProcessingOptionsType partialProcessing = new PartialProcessingOptionsType();
partialProcessing.setInbound(PartialProcessingTypeType.SKIP);
partialProcessing.setObjectTemplateBeforeAssignments(PartialProcessingTypeType.SKIP);
partialProcessing.setObjectTemplateAfterAssignments(PartialProcessingTypeType.SKIP);
partialProcessing.setProjection(PartialProcessingTypeType.SKIP);
partialProcessing.setApprovals(PartialProcessingTypeType.SKIP);
ModelExecuteOptions options = executeOptions()
.partialProcessing(partialProcessing)
.reconcileFocus(true);
// WHEN
when();
modelService.recompute(UserType.class, USER_JACK_OID, options, task, result);
// THEN
then();
assertSuccess(result);
assertRefs23x();
assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0);
assertCounterIncrement(InternalCounters.CONNECTOR_OPERATION_COUNT, 0);
}
private void assertRefs23x() throws Exception {
PrismObject<UserType> userAfter = getUser(USER_JACK_OID);
display("User after", userAfter);
assertAssignedOrgs(userAfter, ORG_MINISTRY_OF_OFFENSE_OID, ORG_SCUMM_BAR_OID, ORG_SAVE_ELAINE_OID);
assertHasOrgs(userAfter, ORG_MINISTRY_OF_OFFENSE_OID, ORG_SCUMM_BAR_OID, ORG_SAVE_ELAINE_OID, ORG_MINISTRY_OF_DEFENSE_OID);
assertAssignedOrg(userAfter, ORG_MINISTRY_OF_OFFENSE_OID, SchemaConstants.ORG_MANAGER);
assertHasOrg(userAfter, ORG_MINISTRY_OF_OFFENSE_OID, SchemaConstants.ORG_MANAGER);
assertAssignedOrg(userAfter, ORG_SCUMM_BAR_OID, null);
assertHasOrg(userAfter, ORG_SCUMM_BAR_OID, null);
assertAssignedOrg(userAfter, ORG_SAVE_ELAINE_OID, null);
assertHasOrg(userAfter, ORG_SAVE_ELAINE_OID, null);
// Postcondition
assertMonkeyIslandOrgSanity();
}
private Long findAssignmentIdForTarget(PrismObject<UserType> user, String targetOid) {
for (AssignmentType assignmentType : user.asObjectable().getAssignment()) {
if (assignmentType.getTargetRef() != null && targetOid.equals(assignmentType.getTargetRef().getOid())) {
return assignmentType.getId();
}
}
throw new IllegalStateException("No assignment pointing to " + targetOid + " found");
}
@Test
public void test300JackUnassignAllOrgs() throws Exception {
Task task = getTestTask();
OperationResult result = task.getResult();
Collection<ItemDelta<?, ?>> modifications = new ArrayList<>();
modifications.add((createAssignmentModification(ORG_MINISTRY_OF_OFFENSE_OID, OrgType.COMPLEX_TYPE, SchemaConstants.ORG_MANAGER, null, null, false)));
modifications.add((createAssignmentModification(ORG_SCUMM_BAR_OID, OrgType.COMPLEX_TYPE, null, null, null, false)));
modifications.add((createAssignmentModification(ORG_SAVE_ELAINE_OID, OrgType.COMPLEX_TYPE, null, null, null, false)));
ObjectDelta<UserType> userDelta = prismContext.deltaFactory().object()
.createModifyDelta(USER_JACK_OID, modifications, UserType.class);
// WHEN
when();
modelService.executeChanges(MiscSchemaUtil.createCollection(userDelta), null, task, result);
// THEN
then();
PrismObject<UserType> userJack = getUser(USER_JACK_OID);
display("User jack after", userJack);
assertAssignedNoOrg(userJack);
assertHasOrg(userJack, ORG_MINISTRY_OF_DEFENSE_OID, null);
// Postcondition
assertMonkeyIslandOrgSanity();
}
/**
* Assign jack to functional orgstruct again. Make him both minister and member (for Defense org i.e. for that which he already has indirect assignment)
*/
@Test
public void test301JackAssignMinistryOfOffense() throws Exception {
Task task = getTestTask();
OperationResult result = task.getResult();
// WHEN
assignOrg(USER_JACK_OID, ORG_MINISTRY_OF_DEFENSE_OID, SchemaConstants.ORG_MANAGER, task, result);
assignOrg(USER_JACK_OID, ORG_MINISTRY_OF_DEFENSE_OID, task, result);
// THEN
PrismObject<UserType> userJack = getUser(USER_JACK_OID);
display("User jack after", userJack);
assertUserOrg(userJack, ORG_MINISTRY_OF_DEFENSE_OID, ORG_MINISTRY_OF_DEFENSE_OID);
assertAssignedOrg(userJack, ORG_MINISTRY_OF_DEFENSE_OID, SchemaConstants.ORG_MANAGER);
assertHasOrg(userJack, ORG_MINISTRY_OF_DEFENSE_OID, SchemaConstants.ORG_MANAGER);
// Postcondition
assertMonkeyIslandOrgSanity();
}
/**
* Conflict: removing the role assignment (that should remove org assignment), while keeping explicit org assignment present
*/
@Test
public void test305JackConflictZeroAndMinus() throws Exception {
Task task = getTestTask();
OperationResult result = task.getResult();
Collection<ItemDelta<?, ?>> modifications = new ArrayList<>();
modifications.add((createAssignmentModification(ROLE_DEFENDER_OID, RoleType.COMPLEX_TYPE, null, null, null, false)));
ObjectDelta<UserType> userDelta = prismContext.deltaFactory().object()
.createModifyDelta(USER_JACK_OID, modifications, UserType.class);
Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(userDelta);
// WHEN
modelService.executeChanges(deltas, null, task, result);
// THEN
PrismObject<UserType> userJack = getUser(USER_JACK_OID);
display("User jack after", userJack);
assertUserOrg(userJack, ORG_MINISTRY_OF_DEFENSE_OID, ORG_MINISTRY_OF_DEFENSE_OID);
assertAssignedOrg(userJack, ORG_MINISTRY_OF_DEFENSE_OID, SchemaConstants.ORG_MANAGER);
assertHasOrg(userJack, ORG_MINISTRY_OF_DEFENSE_OID, SchemaConstants.ORG_MANAGER);
assertHasOrg(userJack, ORG_MINISTRY_OF_DEFENSE_OID, null);
// Postcondition
assertMonkeyIslandOrgSanity();
}
/**
* Another conflict: adding the role assignment (that should add org assignment), while deleting explicit org assignment
*/
@Test
public void test307JackConflictPlusAndMinus() throws Exception {
executeConflictPlusAndMinus();
}
protected void executeConflictPlusAndMinus() throws Exception {
Task task = getTestTask();
OperationResult result = task.getResult();
Collection<ItemDelta<?, ?>> modifications = new ArrayList<>();
modifications.add((createAssignmentModification(ROLE_DEFENDER_OID, RoleType.COMPLEX_TYPE, null, null, null, true)));
modifications.add((createAssignmentModification(ORG_MINISTRY_OF_DEFENSE_OID, OrgType.COMPLEX_TYPE, null, null, null, false)));
ObjectDelta<UserType> userDelta = prismContext.deltaFactory().object()
.createModifyDelta(USER_JACK_OID, modifications, UserType.class);
Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(userDelta);
// WHEN
modelService.executeChanges(deltas, null, task, result);
// THEN
PrismObject<UserType> userJack = getUser(USER_JACK_OID);
display("User jack after", userJack);
assertAssignedOrgs(userJack, ORG_MINISTRY_OF_DEFENSE_OID);
assertAssignedOrg(userJack, ORG_MINISTRY_OF_DEFENSE_OID, SchemaConstants.ORG_MANAGER);
assertNotAssignedOrg(userJack, ORG_MINISTRY_OF_DEFENSE_OID, null);
assertHasOrgs(userJack, ORG_MINISTRY_OF_DEFENSE_OID, ORG_MINISTRY_OF_DEFENSE_OID);
assertHasOrg(userJack, ORG_MINISTRY_OF_DEFENSE_OID, SchemaConstants.ORG_MANAGER);
assertHasOrg(userJack, ORG_MINISTRY_OF_DEFENSE_OID, null);
// Postcondition
assertMonkeyIslandOrgSanity();
}
// preparation for test309
// also tests that when removing indirectly assigned org, it disappears from parentOrgRef
@Test
public void test308JackUnassignRoleDefender() throws Exception {
Task task = getTestTask();
OperationResult result = task.getResult();
// WHEN
Collection<ItemDelta<?, ?>> modifications = new ArrayList<>();
modifications.add((createAssignmentModification(ROLE_DEFENDER_OID, RoleType.COMPLEX_TYPE, null, null, null, false)));
ObjectDelta<UserType> userDelta = prismContext.deltaFactory().object()
.createModifyDelta(USER_JACK_OID, modifications, UserType.class);
Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(userDelta);
modelService.executeChanges(deltas, null, task, result);
// THEN
PrismObject<UserType> userJack = getUser(USER_JACK_OID);
display("User jack after", userJack);
assertAssignedOrgs(userJack, ORG_MINISTRY_OF_DEFENSE_OID);
assertAssignedOrg(userJack, ORG_MINISTRY_OF_DEFENSE_OID, SchemaConstants.ORG_MANAGER);
assertNotAssignedOrg(userJack, ORG_MINISTRY_OF_DEFENSE_OID, null);
assertNotAssignedRole(userJack, ROLE_DEFENDER_OID);
assertHasOrgs(userJack, ORG_MINISTRY_OF_DEFENSE_OID);
assertHasOrg(userJack, ORG_MINISTRY_OF_DEFENSE_OID, SchemaConstants.ORG_MANAGER);
// Postcondition
assertMonkeyIslandOrgSanity();
}
/**
* Retrying last kind of conflict: adding the role assignment (that should add org assignment),
* while deleting explicit org assignment - even it is not there!
* <p>
* So this time there is originally NO parentOrgRef to Ministry of Defense/null.
* <p>
* This situation is a kind of abnormal, but deleting non-present value is considered to be legal.
* So we should treat a situation like this well.
*/
@Test
public void test309JackConflictPlusAndMinusAgain() throws Exception {
executeConflictPlusAndMinus();
}
/**
* MID-3874
*/
@Test
public void test310JackConflictParentOrgRefAndAssignmentsAddOrg() throws Exception {
Task task = getTestTask();
OperationResult result = task.getResult();
PrismObject<OrgType> orgBefore = createObject(OrgType.class, "Cheaters");
orgBefore.asObjectable().parentOrgRef(ORG_SCUMM_BAR_OID, OrgType.COMPLEX_TYPE);
display("Org before");
try {
// WHEN
when();
addObject(orgBefore, task, result);
assertNotReached();
} catch (PolicyViolationException e) {
then();
displayExpectedException(e);
assertFailure(result);
}
// Postcondition
assertMonkeyIslandOrgSanity();
}
// TODO: modify org: add parentOrgRef, removeParentOrgRef
/**
* Delete jack while he is still assigned.
*/
@Test
public void test349DeleteJack() throws Exception {
executeDeleteJack();
}
protected void executeDeleteJack()
throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException,
ExpressionEvaluationException, CommunicationException, ConfigurationException,
PolicyViolationException, SecurityViolationException {
Task task = getTestTask();
OperationResult result = task.getResult();
ObjectDelta<UserType> userDelta = prismContext.deltaFactory().object().createDeleteDelta(UserType.class, USER_JACK_OID
);
Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(userDelta);
// WHEN
modelService.executeChanges(deltas, null, task, result);
// THEN
result.computeStatus();
TestUtil.assertSuccess(result);
try {
getUser(USER_JACK_OID);
AssertJUnit.fail("Jack survived!");
} catch (ObjectNotFoundException e) {
// This is expected
}
}
/**
* Add new user Jack with an assignments as an manager and also a member of ministry of offense.
*/
@Test
public void test350AddJackAsMinistryOfOffenseManager() throws Exception {
Task task = getTestTask();
OperationResult result = task.getResult();
PrismObject<UserType> userJack = prismContext.parseObject(USER_JACK_FILE);
AssignmentType assignmentType = new AssignmentType();
ObjectReferenceType targetRef = new ObjectReferenceType();
targetRef.setOid(ORG_MINISTRY_OF_OFFENSE_OID);
targetRef.setType(OrgType.COMPLEX_TYPE);
assignmentType.setTargetRef(targetRef);
userJack.asObjectable().getAssignment().add(assignmentType);
assignmentType = new AssignmentType();
targetRef = new ObjectReferenceType();
targetRef.setOid(ORG_MINISTRY_OF_OFFENSE_OID);
targetRef.setType(OrgType.COMPLEX_TYPE);
targetRef.setRelation(SchemaConstants.ORG_MANAGER);
assignmentType.setTargetRef(targetRef);
userJack.asObjectable().getAssignment().add(assignmentType);
Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(userJack.createAddDelta());
// WHEN
modelService.executeChanges(deltas, null, task, result);
// THEN
userJack = getUser(USER_JACK_OID);
display("User jack after", userJack);
assertAssignedOrgs(userJack, ORG_MINISTRY_OF_OFFENSE_OID, ORG_MINISTRY_OF_OFFENSE_OID);
assertHasOrgs(userJack, ORG_MINISTRY_OF_OFFENSE_OID, ORG_MINISTRY_OF_OFFENSE_OID);
assertAssignedOrg(userJack, ORG_MINISTRY_OF_OFFENSE_OID, SchemaConstants.ORG_MANAGER);
assertHasOrg(userJack, ORG_MINISTRY_OF_OFFENSE_OID, SchemaConstants.ORG_MANAGER);
assertAssignedOrg(userJack, ORG_MINISTRY_OF_OFFENSE_OID, null);
assertHasOrg(userJack, ORG_MINISTRY_OF_OFFENSE_OID, null);
assertManager(USER_JACK_OID, null, null, false, result);
assertManager(USER_JACK_OID, null, ORG_TYPE_FUNCTIONAL, false, result);
assertManager(USER_JACK_OID, null, ORG_TYPE_PROJECT, false, result);
assertManager(USER_JACK_OID, USER_JACK_OID, null, true, result);
assertManager(USER_JACK_OID, USER_JACK_OID, ORG_TYPE_FUNCTIONAL, true, result);
assertManager(USER_JACK_OID, null, ORG_TYPE_PROJECT, true, result);
// Postcondition
assertMonkeyIslandOrgSanity();
}
@Test
public void test360ElaineAssignGovernor() throws Exception {
Task task = getTestTask();
OperationResult result = task.getResult();
// WHEN
assignOrg(USER_ELAINE_OID, ORG_GOVERNOR_OFFICE_OID, SchemaConstants.ORG_MANAGER, task, result);
// THEN
PrismObject<UserType> userElaine = getUser(USER_ELAINE_OID);
display("User jack after", userElaine);
assertAssignedOrgs(userElaine, ORG_GOVERNOR_OFFICE_OID);
assertHasOrgs(userElaine, ORG_GOVERNOR_OFFICE_OID);
assertAssignedOrg(userElaine, ORG_GOVERNOR_OFFICE_OID, SchemaConstants.ORG_MANAGER);
assertHasOrg(userElaine, ORG_GOVERNOR_OFFICE_OID, SchemaConstants.ORG_MANAGER);
assertManager(USER_JACK_OID, USER_ELAINE_OID, null, false, result);
assertManager(USER_JACK_OID, USER_ELAINE_OID, ORG_TYPE_FUNCTIONAL, false, result);
assertManager(USER_JACK_OID, null, ORG_TYPE_PROJECT, false, result);
assertManager(USER_JACK_OID, USER_JACK_OID, null, true, result);
assertManager(USER_JACK_OID, USER_JACK_OID, ORG_TYPE_FUNCTIONAL, true, result);
assertManager(USER_JACK_OID, null, ORG_TYPE_PROJECT, true, result);
assertManager(USER_ELAINE_OID, null, null, false, result);
assertManager(USER_ELAINE_OID, null, ORG_TYPE_FUNCTIONAL, false, result);
assertManager(USER_ELAINE_OID, null, ORG_TYPE_PROJECT, false, result);
assertManager(USER_ELAINE_OID, null, null, true, result);
assertManager(USER_ELAINE_OID, null, ORG_TYPE_FUNCTIONAL, true, result);
assertManager(USER_ELAINE_OID, null, ORG_TYPE_PROJECT, true, result);
// Postcondition
assertMonkeyIslandOrgSanity();
}
@Test
public void test362ElaineAssignGovernmentMember() throws Exception {
Task task = getTestTask();
OperationResult result = task.getResult();
// WHEN
assignOrg(USER_ELAINE_OID, ORG_GOVERNOR_OFFICE_OID, null, task, result);
// THEN
PrismObject<UserType> userElaine = getUser(USER_ELAINE_OID);
display("User jack after", userElaine);
assertAssignedOrgs(userElaine, ORG_GOVERNOR_OFFICE_OID, ORG_GOVERNOR_OFFICE_OID);
assertHasOrgs(userElaine, ORG_GOVERNOR_OFFICE_OID, ORG_GOVERNOR_OFFICE_OID);
assertAssignedOrg(userElaine, ORG_GOVERNOR_OFFICE_OID, SchemaConstants.ORG_MANAGER);
assertAssignedOrg(userElaine, ORG_GOVERNOR_OFFICE_OID);
assertHasOrg(userElaine, ORG_GOVERNOR_OFFICE_OID, SchemaConstants.ORG_MANAGER);
assertManager(USER_JACK_OID, USER_ELAINE_OID, null, false, result);
assertManager(USER_JACK_OID, USER_ELAINE_OID, ORG_TYPE_FUNCTIONAL, false, result);
assertManager(USER_JACK_OID, null, ORG_TYPE_PROJECT, false, result);
assertManager(USER_JACK_OID, USER_JACK_OID, null, true, result);
assertManager(USER_JACK_OID, USER_JACK_OID, ORG_TYPE_FUNCTIONAL, true, result);
assertManager(USER_JACK_OID, null, ORG_TYPE_PROJECT, true, result);
assertManager(USER_ELAINE_OID, null, null, false, result);
assertManager(USER_ELAINE_OID, null, ORG_TYPE_FUNCTIONAL, false, result);
assertManager(USER_ELAINE_OID, null, ORG_TYPE_PROJECT, false, result);
assertManager(USER_ELAINE_OID, USER_ELAINE_OID, null, true, result);
assertManager(USER_ELAINE_OID, USER_ELAINE_OID, ORG_TYPE_FUNCTIONAL, true, result);
assertManager(USER_ELAINE_OID, null, ORG_TYPE_PROJECT, true, result);
// Postcondition
assertMonkeyIslandOrgSanity();
}
@Test
public void test365GuybrushAssignSwashbucklerMember() throws Exception {
Task task = getTestTask();
OperationResult result = task.getResult();
// WHEN
assignOrg(USER_GUYBRUSH_OID, ORG_SWASHBUCKLER_SECTION_OID, null, task, result);
// THEN
PrismObject<UserType> userGuybrush = getUser(USER_GUYBRUSH_OID);
display("User jack after", userGuybrush);
assertAssignedOrgs(userGuybrush, ORG_SWASHBUCKLER_SECTION_OID);
assertHasOrgs(userGuybrush, ORG_SWASHBUCKLER_SECTION_OID);
assertAssignedOrg(userGuybrush, ORG_SWASHBUCKLER_SECTION_OID);
assertHasOrg(userGuybrush, ORG_SWASHBUCKLER_SECTION_OID);
assertManager(USER_JACK_OID, USER_ELAINE_OID, null, false, result);
assertManager(USER_JACK_OID, USER_ELAINE_OID, ORG_TYPE_FUNCTIONAL, false, result);
assertManager(USER_JACK_OID, null, ORG_TYPE_PROJECT, false, result);
assertManager(USER_JACK_OID, USER_JACK_OID, null, true, result);
assertManager(USER_JACK_OID, USER_JACK_OID, ORG_TYPE_FUNCTIONAL, true, result);
assertManager(USER_JACK_OID, null, ORG_TYPE_PROJECT, true, result);
assertManager(USER_ELAINE_OID, null, null, false, result);
assertManager(USER_ELAINE_OID, null, ORG_TYPE_FUNCTIONAL, false, result);
assertManager(USER_ELAINE_OID, null, ORG_TYPE_PROJECT, false, result);
assertManager(USER_ELAINE_OID, USER_ELAINE_OID, null, true, result);
assertManager(USER_ELAINE_OID, USER_ELAINE_OID, ORG_TYPE_FUNCTIONAL, true, result);
assertManager(USER_ELAINE_OID, null, ORG_TYPE_PROJECT, true, result);
assertManager(USER_GUYBRUSH_OID, USER_JACK_OID, null, false, result);
assertManager(USER_GUYBRUSH_OID, USER_JACK_OID, ORG_TYPE_FUNCTIONAL, false, result);
assertManager(USER_GUYBRUSH_OID, null, ORG_TYPE_PROJECT, false, result);
assertManager(USER_GUYBRUSH_OID, USER_JACK_OID, null, true, result);
assertManager(USER_GUYBRUSH_OID, USER_JACK_OID, ORG_TYPE_FUNCTIONAL, true, result);
assertManager(USER_GUYBRUSH_OID, null, ORG_TYPE_PROJECT, true, result);
// Postcondition