Skip to content

Commit

Permalink
feat(filters): removing dependency to assertj
Browse files Browse the repository at this point in the history
  • Loading branch information
TheWorkshopCom authored and fhussonnois committed Sep 12, 2023
1 parent d78219a commit 79333f6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 29 deletions.
4 changes: 0 additions & 4 deletions connect-file-pulse-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -381,10 +381,6 @@
<groupId>io.rest-assured</groupId>
<artifactId>json-path</artifactId>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
</dependency>
<dependency>
<groupId>io.streamthoughts</groupId>
<artifactId>kafka-connect-filepulse-local-fs</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@
import static io.streamthoughts.kafka.connect.filepulse.fs.filter.DateInFilenameFileListFilterTest.Fixture.invalidCutoffDate;
import static io.streamthoughts.kafka.connect.filepulse.fs.filter.DateInFilenameFileListFilterTest.Fixture.maxCutoffDate;
import static io.streamthoughts.kafka.connect.filepulse.fs.filter.DateInFilenameFileListFilterTest.Fixture.minCutoffDate;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.params.provider.Arguments.arguments;

import io.streamthoughts.kafka.connect.filepulse.source.FileObjectMeta;
Expand All @@ -52,10 +54,9 @@ class DateInFilenameFileListFilterTest {
@Test
void when_pattern_empty_configure_should_throw_exception() {
DateInFilenameFileListFilter filter = new DateInFilenameFileListFilter();
assertThatThrownBy(() -> filter.configure(Map.of()))
.isInstanceOf(ConfigException.class)
.hasMessageContaining(FILE_FILTER_DATE_REGEX_EXTRACTOR_PATTERN_CONFIG)
.hasNoCause();
ConfigException configException = assertThrows(ConfigException.class, () -> filter.configure(Map.of()));
assertNull(configException.getCause());
assertTrue(configException.getMessage().contains(FILE_FILTER_DATE_REGEX_EXTRACTOR_PATTERN_CONFIG));
}

@Test
Expand All @@ -65,10 +66,9 @@ void when_date_min_invalid_configure_should_throw_exception() {
FILE_FILTER_DATE_MIN_DATE_CONFIG, invalidCutoffDate);

DateInFilenameFileListFilter filter = new DateInFilenameFileListFilter();
assertThatThrownBy(() -> filter.configure(configs))
.isInstanceOf(ConfigException.class)
.hasMessageContaining(FILE_FILTER_DATE_MIN_DATE_CONFIG)
.hasNoCause();
ConfigException configException = assertThrows(ConfigException.class, () -> filter.configure(configs));
assertNull(configException.getCause());
assertTrue(configException.getMessage().contains(FILE_FILTER_DATE_MIN_DATE_CONFIG));
}

@Test
Expand All @@ -78,10 +78,9 @@ void when_date_max_invalid_configure_should_throw_exception() {
FILE_FILTER_DATE_MAX_DATE_CONFIG, invalidCutoffDate);

DateInFilenameFileListFilter filter = new DateInFilenameFileListFilter();
assertThatThrownBy(() -> filter.configure(configs))
.isInstanceOf(ConfigException.class)
.hasMessageContaining(FILE_FILTER_DATE_MAX_DATE_CONFIG)
.hasNoCause();
ConfigException configException = assertThrows(ConfigException.class, () -> filter.configure(configs));
assertNull(configException.getCause());
assertTrue(configException.getMessage().contains(FILE_FILTER_DATE_MAX_DATE_CONFIG));
}

@Test
Expand All @@ -90,10 +89,9 @@ void when_neither_max_date_nor_min_date_provided_configure_should_throw_exceptio
Map.of(FILE_FILTER_DATE_REGEX_EXTRACTOR_PATTERN_CONFIG, dateExtractorRegex);

DateInFilenameFileListFilter filter = new DateInFilenameFileListFilter();
assertThatThrownBy(() -> filter.configure(configs))
.isInstanceOf(ConfigException.class)
.hasMessageContaining("At least one of")
.hasNoCause();
ConfigException configException = assertThrows(ConfigException.class, () -> filter.configure(configs));
assertNull(configException.getCause());
assertTrue(configException.getMessage().contains("At least one of"));
}

private DateInFilenameFileListFilter prepareFilter(String minCutoffDate, String maxCutoffDate) {
Expand Down Expand Up @@ -122,7 +120,7 @@ void when_called_test_should_return_expected_value(Boolean expected,
String maxCutoffDate) {

DateInFilenameFileListFilter filter = prepareFilter(minCutoffDate, maxCutoffDate);
assertThat(filter.test(meta)).isEqualTo(expected);
assertEquals(expected, filter.test(meta));
}

public static Stream<Arguments> when_called_test_should_return_expected_value() {
Expand Down
6 changes: 0 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -611,12 +611,6 @@
<version>5.3.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.24.2</version>
<scope>test</scope>
</dependency>
<!-- END test dependencies-->
</dependencies>
</dependencyManagement>
Expand Down

0 comments on commit 79333f6

Please sign in to comment.