use of com.mercedesbenz.sechub.domain.administration.autocleanup.AdministrationAutoCleanupConfig in project sechub by mercedes-benz.
the class AdministrationAutoCleanupDaysCalculatorTest method days_calculated_as_expected.
@CsvSource({ "5,weeks,35", "20,days,20", "1,day,1", "2,months,60", "1,month,30", "1,MONTH,30", "0,MONTH,0", "0,DAY,0" })
@ParameterizedTest
void days_calculated_as_expected(int amount, String unit, long expectedDays) {
/* prepare */
String json = "{ 'cleanupTime' : { 'unit':'" + unit + "', 'amount': " + amount + "}" + "}";
AdministrationAutoCleanupConfig config = AdministrationAutoCleanupConfig.fromString(json);
/* execute */
long calculatedDays = calculatorToTest.calculateCleanupTimeInDays(config);
/* test */
assertEquals(expectedDays, calculatedDays);
}
use of com.mercedesbenz.sechub.domain.administration.autocleanup.AdministrationAutoCleanupConfig in project sechub by mercedes-benz.
the class AdministrationConfigServiceTest method when_calculator_calculates_a_positive_day_count_or_zero_no__exception_is_thrown_and_an_event_sent.
@ParameterizedTest
@CsvSource({ "0", "1", "100", "4711" })
void when_calculator_calculates_a_positive_day_count_or_zero_no__exception_is_thrown_and_an_event_sent(long calculatedDays) {
/* prepare */
emulateExistingInitialAdministrationConfig();
AdministrationAutoCleanupConfig autoCleanupConfiguration = new AdministrationAutoCleanupConfig();
when(calculator.calculateCleanupTimeInDays(autoCleanupConfiguration)).thenReturn(calculatedDays);
/* execute */
serviceToTest.updateAutoCleanupConfiguration(autoCleanupConfiguration);
/* test */
verify(domainMessageService).sendAsynchron(any());
}
use of com.mercedesbenz.sechub.domain.administration.autocleanup.AdministrationAutoCleanupConfig in project sechub by mercedes-benz.
the class AdministrationConfigServiceTest method an_existing_config_is_updated_with_null_throws_illegal_argument.
@Test
void an_existing_config_is_updated_with_null_throws_illegal_argument() {
/* prepare */
emulateExistingInitialAdministrationConfig();
AdministrationAutoCleanupConfig autoCleanupConfiguration = null;
/* execute + test */
assertThrows(IllegalArgumentException.class, () -> serviceToTest.updateAutoCleanupConfiguration(autoCleanupConfiguration));
}
use of com.mercedesbenz.sechub.domain.administration.autocleanup.AdministrationAutoCleanupConfig in project sechub by mercedes-benz.
the class AdministrationConfigServiceTest method when_calculator_calculates_an_negative_days_count_a_non_acceptable_exception_is_thrown.
@ParameterizedTest
@CsvSource({ "-1", "-100", "-4711" })
void when_calculator_calculates_an_negative_days_count_a_non_acceptable_exception_is_thrown(long calculatedDays) {
/* prepare */
emulateExistingInitialAdministrationConfig();
AdministrationAutoCleanupConfig autoCleanupConfiguration = new AdministrationAutoCleanupConfig();
when(calculator.calculateCleanupTimeInDays(autoCleanupConfiguration)).thenReturn(calculatedDays);
/* execute + test */
assertThrows(NotAcceptableException.class, () -> serviceToTest.updateAutoCleanupConfiguration(autoCleanupConfiguration));
}
use of com.mercedesbenz.sechub.domain.administration.autocleanup.AdministrationAutoCleanupConfig in project sechub by mercedes-benz.
the class AdministrationConfigServiceTest method an_existing_config_is_updated_with_given_auto_cleanup_config.
@Test
void an_existing_config_is_updated_with_given_auto_cleanup_config() {
/* prepare */
emulateExistingInitialAdministrationConfig();
AdministrationAutoCleanupConfig autoCleanupConfiguration = new AdministrationAutoCleanupConfig();
/* execute */
serviceToTest.updateAutoCleanupConfiguration(autoCleanupConfiguration);
/* test */
verify(repository).findById(0);
ArgumentCaptor<AdministrationConfig> captor = ArgumentCaptor.forClass(AdministrationConfig.class);
verify(transactionService).saveConfigInOwnTransaction(captor.capture());
AdministrationConfig storedConfig = captor.getValue();
assertEquals(storedConfig.autoCleanupConfiguration, autoCleanupConfiguration.toJSON());
}
Aggregations