@@ -45,7 +45,7 @@ public void after() throws Exception {
4545 }
4646
4747 @ Test
48- public void addAndReadTest () throws IllegalArgumentException , URISyntaxException {
48+ public void profileAssociationsCRUDTest () throws IllegalArgumentException , URISyntaxException {
4949 ProfileAssociationsDao dao = manager .getProfileAssociationsDao ();
5050 //TODO: update profile sid type below after merge from master
5151 Sid profileSid = Sid .generate (Sid .Type .ORGANIZATION );
@@ -64,17 +64,39 @@ public void addAndReadTest() throws IllegalArgumentException, URISyntaxException
6464 Assert .assertNotNull (resultantProfileAssociations );
6565 Assert .assertEquals (1 , resultantProfileAssociations .size ());
6666 Assert .assertEquals (profileAssociation .toString (), resultantProfileAssociations .get (0 ).toString ());
67-
67+
6868 // Add another ProfileAssociation with same profile
6969 Sid targetSid2 = Sid .generate (Sid .Type .ACCOUNT );
7070 ProfileAssociation profileAssociation2 = new ProfileAssociation (profileSid , targetSid2 , Calendar .getInstance ().getTime (), Calendar .getInstance ().getTime ());
7171 dao .addProfileAssociation (profileAssociation2 );
7272 resultantProfileAssociations = dao .getProfileAssociationsByProfileSid (profileSid .toString ());
7373 Assert .assertNotNull (resultantProfileAssociations );
7474 Assert .assertEquals (2 , resultantProfileAssociations .size ());
75+
76+ //Update Associated Profile Of All Such ProfileSid
77+ //TODO: update profile sid type below after merge from master
78+ Sid newProfileSid = Sid .generate (Sid .Type .ORGANIZATION );
79+ dao .updateAssociatedProfileOfAllSuchProfileSid (profileSid .toString (), newProfileSid .toString ());
80+ Assert .assertEquals (0 , dao .getProfileAssociationsByProfileSid (profileSid .toString ()).size ());
81+ Assert .assertEquals (2 , dao .getProfileAssociationsByProfileSid (newProfileSid .toString ()).size ());
82+
83+ //Update ProfileAssociation of target
84+ //TODO: update profile sid type below after merge from master
85+ Sid newProfileSid2 = Sid .generate (Sid .Type .ORGANIZATION );
86+ profileAssociation = dao .getProfileAssociationsByProfileSid (newProfileSid .toString ()).get (0 );
87+ ProfileAssociation updatedProfileAssociation = profileAssociation .setProfileSid (newProfileSid2 );
88+ dao .updateProfileAssociationOfTargetSid (updatedProfileAssociation );
89+ ProfileAssociation resultantProfileAssociationdao = dao .getProfileAssociationByTargetSid (updatedProfileAssociation .getTargetSid ().toString ());
90+ Assert .assertNotNull (resultantProfileAssociationdao );
91+ Assert .assertEquals (updatedProfileAssociation .getProfileSid ().toString (), resultantProfileAssociationdao .getProfileSid ().toString ());
92+
93+ //Delete ByProfileSid
94+ dao .deleteProfileAssociationByProfileSid (newProfileSid2 .toString ());
95+ Assert .assertEquals (0 ,dao .getProfileAssociationsByProfileSid (newProfileSid2 .toString ()).size ());
7596
76- //Update ProfileAssociation
77-
97+ //Delete ByTargetSid
98+ dao .deleteProfileAssociationByTargetSid (resultantProfileAssociationdao .getProfileSid ().toString ());
99+ Assert .assertNull (dao .getProfileAssociationByTargetSid (resultantProfileAssociationdao .getProfileSid ().toString ()));
78100 }
79101
80102}
0 commit comments