Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: replaced .length() with .isEmpty() for filenameTypes check in MappingConfig #3256

Merged
merged 1 commit into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ public String[] getFilenamesAsArray() {
}

public boolean isValid() {
return kind != null && filenameTypes != null && filenameTypes.length() > 0;
return kind != null && filenameTypes != null && !filenameTypes.isEmpty();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ void getFilenamesAsArray_whenTypesPresent_thenReturnsArray() {
void isValid_withMissingKind_shouldReturnFalse() {
// Given
MappingConfig config = MappingConfig.builder()
.apiVersion("custom-cron-tab.example.com/v1")
.filenameTypes("crontab,cr")
.build();
.apiVersion("custom-cron-tab.example.com/v1")
.filenameTypes("crontab,cr")
.build();
// When
boolean result = config.isValid();
// Then
Expand All @@ -71,9 +71,23 @@ void isValid_withMissingKind_shouldReturnFalse() {
void isValid_withMissingFileNameTypes_shouldReturnFalse() {
// Given
MappingConfig config = MappingConfig.builder()
.apiVersion("custom-cron-tab.example.com/v1")
.kind("Foo")
.build();
.apiVersion("custom-cron-tab.example.com/v1")
.kind("Foo")
.build();
// When
boolean result = config.isValid();
// Then
assertThat(result).isFalse();
}

@Test
void isValid_withEmptyFileNameTypes_shouldReturnFalse() {
// Given
MappingConfig config = MappingConfig.builder()
.apiVersion("custom-cron-tab.example.com/v1")
.kind("Foo")
.filenameTypes("")
.build();
// When
boolean result = config.isValid();
// Then
Expand Down Expand Up @@ -110,7 +124,7 @@ void isValid_withKindAndApiVersionAndFileName_shouldReturnTrue() {
@Test
void equalsAndHashCodeShouldMatch() {
// Given
MappingConfig mc1 = MappingConfig.builder().kind("Foo").filenameTypes("foos").build();
MappingConfig mc1 = MappingConfig.builder().kind("Foo").filenameTypes("foos").build();
MappingConfig mc2 = MappingConfig.builder().kind("Foo").filenameTypes("foos").build();
// When + Then
assertThat(mc1)
Expand Down