Skip to content

Commit

Permalink
Add name to parametrized test and use set instead of list
Browse files Browse the repository at this point in the history
  • Loading branch information
RandomTannenbaum committed Jan 22, 2025
1 parent 702a057 commit a7ac03b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ public Optional<String> getJwkSetUri(String tenantId) {
return getTenantConfigById(tenantId).map(TenantConfig::jwkSetUri);
}

public List<String> getAllTenantIds() {
return new ArrayList<>(this.tenantConfigs.keySet());
public Set<String> getAllTenantIds() {
return this.tenantConfigs.keySet();
}

public record TenantConfig(String tenantId, String[] okrChampionEmails, String jwkSetUri, String issuerUrl,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -129,7 +131,7 @@ public void scheduledGenerationQuarters() {

String initialTenant = TenantContext.getCurrentTenant();

List<String> tenantSchemas = this.tenantConfigProvider.getAllTenantIds();
Set<String> tenantSchemas = this.tenantConfigProvider.getAllTenantIds();
// If we are in the last month of a quarter, generate the next quarter
if (isInLastMonthOfQuarter(currentQuarter, nextQuarter)) {
for (String schema : tenantSchemas) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ void getModelNameShouldReturnQuarter() {
assertEquals(QUARTER, quarterPersistenceService.getModelName());
}

@ParameterizedTest
@ParameterizedTest(name = "Should generate quarter with Cron-Job when current month is the last month of the current quarter")
@CsvSource(value = { "1,1,0", "2,1,0", "3,1,1", "4,1,0", "5,1,0", "6,2,1", "7,1,0", "8,1,0", "9,3,1", "10,3,0",
"11,1,0", "12,4,1" })
void testCronJob(int month, int quarterIndex, int amountOfInvocations) {
void shouldGenerateQuarterWithCronJob(int month, int quarterIndex, int amountOfInvocations) {
int startQuarter = 7;
ReflectionTestUtils.setField(quarterBusinessService, "quarterStart", startQuarter);
int nextYear = Year.now().atMonth(startQuarter).plusMonths(month + 12 - 1).getYear();
Expand Down

0 comments on commit a7ac03b

Please sign in to comment.