@@ -93,17 +93,18 @@ public class PersistenceResourceTest {
9393 private @ Mock @ NonNullByDefault ({}) Item itemMock ;
9494
9595 private static final String item = "Test" ;
96- private static final int startValue = 2016 ;
97- private static final int endValue = 2018 ;
96+ private static final int START_VALUE = 2016 ;
97+ private static final int END_VALUE = 2018 ;
98+ private static final int VALUE_COUNT = END_VALUE - START_VALUE + 1 ;
9899
99100 @ BeforeEach
100101 public void beforeEach () {
101102 pResource = new PersistenceResource (itemRegistryMock , localeServiceMock , persistenceServiceRegistryMock ,
102103 persistenceManagerMock , persistenceServiceConfigurationRegistryMock ,
103104 managedPersistenceServiceConfigurationProviderMock , timeZoneProviderMock , configurationServiceMock );
104105
105- items = new ArrayList <>(endValue - startValue + 1 );
106- for (int i = startValue ; i <= endValue ; i ++) {
106+ items = new ArrayList <>(VALUE_COUNT );
107+ for (int i = START_VALUE ; i <= END_VALUE ; i ++) {
107108 final int year = i ;
108109 items .add (new HistoricItem () {
109110 @ Override
@@ -249,17 +250,17 @@ public String getName() {
249250
250251 @ Override
251252 public @ Nullable Integer getCount () {
252- return endValue - startValue + 1 ;
253+ return VALUE_COUNT ;
253254 }
254255
255256 @ Override
256257 public @ Nullable Date getEarliest () {
257- return Date .from (ZonedDateTime .of (startValue , 1 , 1 , 0 , 0 , 0 , 0 , ZoneId .systemDefault ()).toInstant ());
258+ return Date .from (ZonedDateTime .of (START_VALUE , 1 , 1 , 0 , 0 , 0 , 0 , ZoneId .systemDefault ()).toInstant ());
258259 }
259260
260261 @ Override
261262 public @ Nullable Date getLatest () {
262- return Date .from (ZonedDateTime .of (endValue , 1 , 1 , 0 , 0 , 0 , 0 , ZoneId .systemDefault ()).toInstant ());
263+ return Date .from (ZonedDateTime .of (END_VALUE , 1 , 1 , 0 , 0 , 0 , 0 , ZoneId .systemDefault ()).toInstant ());
263264 }
264265 }));
265266
@@ -268,10 +269,10 @@ public String getName() {
268269 PersistenceItemInfoDTO itemInfo = dto .iterator ().next ();
269270 assertThat (itemInfo .name (), is (item ));
270271 assertThat (itemInfo .earliest (),
271- is (Date .from (ZonedDateTime .of (startValue , 1 , 1 , 0 , 0 , 0 , 0 , ZoneId .systemDefault ()).toInstant ())));
272+ is (Date .from (ZonedDateTime .of (START_VALUE , 1 , 1 , 0 , 0 , 0 , 0 , ZoneId .systemDefault ()).toInstant ())));
272273 assertThat (itemInfo .latest (),
273- is (Date .from (ZonedDateTime .of (endValue , 1 , 1 , 0 , 0 , 0 , 0 , ZoneId .systemDefault ()).toInstant ())));
274- assertThat (itemInfo .count (), is (endValue - startValue + 1 ));
274+ is (Date .from (ZonedDateTime .of (END_VALUE , 1 , 1 , 0 , 0 , 0 , 0 , ZoneId .systemDefault ()).toInstant ())));
275+ assertThat (itemInfo .count (), is (VALUE_COUNT ));
275276 }
276277
277278 @ Test
@@ -296,7 +297,7 @@ public String getName() {
296297
297298 @ Override
298299 public @ Nullable Date getLatest () {
299- return Date .from (ZonedDateTime .of (endValue , 1 , 1 , 0 , 0 , 0 , 0 , ZoneId .systemDefault ()).toInstant ());
300+ return Date .from (ZonedDateTime .of (END_VALUE , 1 , 1 , 0 , 0 , 0 , 0 , ZoneId .systemDefault ()).toInstant ());
300301 }
301302 });
302303
@@ -307,7 +308,7 @@ public String getName() {
307308 assertThat (itemInfo .name (), is (item ));
308309 assertNull (itemInfo .earliest ());
309310 assertThat (itemInfo .latest (),
310- is (Date .from (ZonedDateTime .of (endValue , 1 , 1 , 0 , 0 , 0 , 0 , ZoneId .systemDefault ()).toInstant ())));
311+ is (Date .from (ZonedDateTime .of (END_VALUE , 1 , 1 , 0 , 0 , 0 , 0 , ZoneId .systemDefault ()).toInstant ())));
311312 assertNull (itemInfo .count ());
312313 }
313314
@@ -329,18 +330,18 @@ public String getName() {
329330
330331 @ Override
331332 public @ Nullable Integer getCount () {
332- return 3 ;
333+ return VALUE_COUNT ;
333334 }
334335
335336 @ Override
336337 public @ Nullable Date getEarliest () {
337338 return Date
338- .from (ZonedDateTime .of (startValue , 1 , 1 , 0 , 0 , 0 , 0 , ZoneId .systemDefault ()).toInstant ());
339+ .from (ZonedDateTime .of (START_VALUE , 1 , 1 , 0 , 0 , 0 , 0 , ZoneId .systemDefault ()).toInstant ());
339340 }
340341
341342 @ Override
342343 public @ Nullable Date getLatest () {
343- return Date .from (ZonedDateTime .of (endValue , 1 , 1 , 0 , 0 , 0 , 0 , ZoneId .systemDefault ()).toInstant ());
344+ return Date .from (ZonedDateTime .of (END_VALUE , 1 , 1 , 0 , 0 , 0 , 0 , ZoneId .systemDefault ()).toInstant ());
344345 }
345346 };
346347 });
@@ -354,10 +355,10 @@ public String getName() {
354355 PersistenceItemInfoDTO itemInfo = dto .iterator ().next ();
355356 assertThat (itemInfo .name (), is (item ));
356357 assertThat (itemInfo .earliest (),
357- is (Date .from (ZonedDateTime .of (startValue , 1 , 1 , 0 , 0 , 0 , 0 , ZoneId .systemDefault ()).toInstant ())));
358+ is (Date .from (ZonedDateTime .of (START_VALUE , 1 , 1 , 0 , 0 , 0 , 0 , ZoneId .systemDefault ()).toInstant ())));
358359 assertThat (itemInfo .latest (),
359- is (Date .from (ZonedDateTime .of (endValue , 1 , 1 , 0 , 0 , 0 , 0 , ZoneId .systemDefault ()).toInstant ())));
360- assertThat (itemInfo .count (), is (endValue - startValue + 1 ));
360+ is (Date .from (ZonedDateTime .of (END_VALUE , 1 , 1 , 0 , 0 , 0 , 0 , ZoneId .systemDefault ()).toInstant ())));
361+ assertThat (itemInfo .count (), is (VALUE_COUNT ));
361362
362363 // Test when an alias exists
363364 when (persistenceServiceConfigurationRegistryMock .get (any ())).thenReturn (persistenceServiceConfigurationMock );
@@ -367,9 +368,9 @@ public String getName() {
367368 itemInfo = dto .iterator ().next ();
368369 assertThat (itemInfo .name (), is ("TestAlias" ));
369370 assertThat (itemInfo .earliest (),
370- is (Date .from (ZonedDateTime .of (startValue , 1 , 1 , 0 , 0 , 0 , 0 , ZoneId .systemDefault ()).toInstant ())));
371+ is (Date .from (ZonedDateTime .of (START_VALUE , 1 , 1 , 0 , 0 , 0 , 0 , ZoneId .systemDefault ()).toInstant ())));
371372 assertThat (itemInfo .latest (),
372- is (Date .from (ZonedDateTime .of (endValue , 1 , 1 , 0 , 0 , 0 , 0 , ZoneId .systemDefault ()).toInstant ())));
373- assertThat (itemInfo .count (), is (endValue - startValue + 1 ));
373+ is (Date .from (ZonedDateTime .of (END_VALUE , 1 , 1 , 0 , 0 , 0 , 0 , ZoneId .systemDefault ()).toInstant ())));
374+ assertThat (itemInfo .count (), is (VALUE_COUNT ));
374375 }
375376}
0 commit comments