2424import java .sql .SQLException ;
2525import java .text .DateFormat ;
2626import java .text .SimpleDateFormat ;
27+ import java .time .Instant ;
28+ import java .time .temporal .ChronoUnit ;
29+ import java .util .Date ;
2730import java .util .List ;
2831
2932import org .dspace .authorize .ResourcePolicy ;
4043import org .dspace .eperson .service .GroupService ;
4144import org .dspace .pack .bagit .xml .policy .Policies ;
4245import org .dspace .pack .bagit .xml .policy .Policy ;
43- import org .joda .time .DateTime ;
4446import org .junit .Before ;
4547import org .junit .Test ;
4648
@@ -78,11 +80,11 @@ public void getPolicyForAdmin() throws Exception {
7880 when (adminGroup .getName ()).thenReturn (Group .ADMIN );
7981
8082 // set up an admin ResourcePolicy for the Community
81- final DateTime groupDateTime = DateTime . now ().minusDays ( 1 );
83+ final Date groupDate = Date . from ( Instant . now ().minus ( 1 , ChronoUnit . DAYS ) );
8284 final ResourcePolicy adminGroupPolicy = initReloadable (ResourcePolicy .class );
8385 adminGroupPolicy .setGroup (adminGroup );
8486 adminGroupPolicy .setRpType (TYPE_CUSTOM );
85- adminGroupPolicy .setStartDate (groupDateTime . toDate () );
87+ adminGroupPolicy .setStartDate (groupDate );
8688 community .getResourcePolicies ().add (adminGroupPolicy );
8789
8890 // now test that the Policy pojo we get back is correct
@@ -100,7 +102,7 @@ public void getPolicyForAdmin() throws Exception {
100102 assertThat (child .getAction ()).isEqualTo ("READ" );
101103 assertThat (child .getType ()).isEqualTo (TYPE_CUSTOM );
102104 assertThat (child .getGroup ()).isEqualTo (Group .ADMIN );
103- assertThat (child .getStartDate ()).isEqualTo (dateFormat .format (groupDateTime . toDate () ));
105+ assertThat (child .getStartDate ()).isEqualTo (dateFormat .format (groupDate ));
104106
105107 assertThat (child .getName ()).isNull ();
106108 assertThat (child .getEndDate ()).isNull ();
@@ -119,11 +121,11 @@ public void getPolicyForAnonymous() throws Exception {
119121 when (anonGroup .getName ()).thenReturn (Group .ANONYMOUS );
120122
121123 // set up the ResourcePolicy
122- final DateTime groupDateTime = DateTime . now ().minusDays ( 1 );
124+ final Date groupDate = Date . from ( Instant . now ().minus ( 1 , ChronoUnit . DAYS ) );
123125 final ResourcePolicy anonGroupPolicy = initReloadable (ResourcePolicy .class );
124126 anonGroupPolicy .setGroup (anonGroup );
125127 anonGroupPolicy .setRpType (TYPE_CUSTOM );
126- anonGroupPolicy .setEndDate (groupDateTime . toDate () );
128+ anonGroupPolicy .setEndDate (groupDate );
127129
128130 community .getResourcePolicies ().add (anonGroupPolicy );
129131
@@ -140,7 +142,7 @@ public void getPolicyForAnonymous() throws Exception {
140142 assertThat (child .getAction ()).isEqualTo ("READ" );
141143 assertThat (child .getType ()).isEqualTo (TYPE_CUSTOM );
142144 assertThat (child .getGroup ()).isEqualTo (Group .ANONYMOUS );
143- assertThat (child .getEndDate ()).isEqualTo (dateFormat .format (groupDateTime . toDate () ));
145+ assertThat (child .getEndDate ()).isEqualTo (dateFormat .format (groupDate ));
144146
145147 assertThat (child .getName ()).isNull ();
146148 assertThat (child .getEperson ()).isNull ();
@@ -160,11 +162,11 @@ public void getPolicyForEPerson() throws Exception {
160162 when (ePerson .getEmail ()).thenReturn (epersonEmail );
161163
162164 // Create the ePerson policy
163- final DateTime ePersonDateTime = DateTime . now ().plusDays ( 1 );
165+ final Date ePersonDate = Date . from ( Instant . now ().plus ( 1 , ChronoUnit . DAYS ) );
164166 final ResourcePolicy ePersonPolicy = initReloadable (ResourcePolicy .class );
165167 ePersonPolicy .setEPerson (ePerson );
166168 ePersonPolicy .setRpType (TYPE_CUSTOM );
167- ePersonPolicy .setStartDate (ePersonDateTime . toDate () );
169+ ePersonPolicy .setStartDate (ePersonDate );
168170
169171 community .getResourcePolicies ().add (ePersonPolicy );
170172
@@ -181,7 +183,7 @@ public void getPolicyForEPerson() throws Exception {
181183 assertThat (child .getAction ()).isEqualTo ("READ" );
182184 assertThat (child .getType ()).isEqualTo (TYPE_CUSTOM );
183185 assertThat (child .getEperson ()).isEqualTo (epersonEmail );
184- assertThat (child .getStartDate ()).isEqualTo (dateFormat .format (ePersonDateTime . toDate () ));
186+ assertThat (child .getStartDate ()).isEqualTo (dateFormat .format (ePersonDate ));
185187
186188 assertThat (child .getName ()).isNull ();
187189 assertThat (child .getGroup ()).isNull ();
0 commit comments