TimerValues { @Bean public String getCrlRate(TimerConfigurationType timerConfiguration) { String timerName = "CRL renewal"; if (timerConfiguration != null && timerConfiguration.getCrlRenewal() != null) { TimerType crlRenewal = timerConfiguration.getCrlRenewal(); if (crlRenewal.getLength() != 0 && crlRenewal.getUnit() != 0) { String rate = String.valueOf(getUnitOfTime(crlRenewal.getUnit()) * crlRenewal.getLength()); logRateForTimer(timerName, rate); return rate; } } String rate = String.valueOf(2 * HOUR); logRateForTimer(timerName, rate); return rate; }  @Bean String getFullBlacklistRate(); @Bean String getDeltaBlacklistRate(TimerConfigurationType timerConfiguration); @Bean String getCVCRate(TimerConfigurationType timerConfiguration); @Bean String getMasterDefectRate(TimerConfigurationType timerConfiguration); @Bean String getCrlRate(TimerConfigurationType timerConfiguration); @Bean String getKeyLockRate();  }
@Test void testGetCrlRate() { TimerValues timerValues = new TimerValues(); String crlRate = timerValues.getCrlRate(null); final String defaultRate = String.valueOf(2 * TimerValues.HOUR); Assertions.assertEquals(defaultRate, crlRate); TimerConfigurationType timerConfiguration = new TimerConfigurationType(); crlRate = timerValues.getCrlRate(timerConfiguration); Assertions.assertEquals(defaultRate, crlRate); TimerType crlTimer = new TimerType(); crlTimer.setUnit(Calendar.MINUTE); crlTimer.setLength(30); timerConfiguration.setCrlRenewal(crlTimer); crlRate = timerValues.getCrlRate(timerConfiguration); Assertions.assertEquals(String.valueOf(30 * 60 * 1000), crlRate); }
@Test void testInvalidTimerUnit() { TimerValues timerValues = new TimerValues(); TimerConfigurationType timerConfigurationType = new TimerConfigurationType(); TimerType timerType = new TimerType(); timerType.setUnit(Calendar.MILLISECOND); timerType.setLength(10); timerConfigurationType.setCrlRenewal(timerType); IllegalArgumentException illegalArgumentException = Assertions.assertThrows(IllegalArgumentException.class, () -> timerValues.getCrlRate(timerConfigurationType)); Assertions.assertEquals("Unsupported unit of time: " + Calendar.MILLISECOND, illegalArgumentException.getMessage()); }