Skip to content

Commit

Permalink
fix: replaced '.length() > 0' with '!.isEmpty()' in MappingConfig
Browse files Browse the repository at this point in the history
Signed-off-by: Jessica Lane <jesslane94@gmail.com>
  • Loading branch information
jesslane94 committed Jul 24, 2024
1 parent d150613 commit d000d3f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
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

0 comments on commit d000d3f

Please sign in to comment.