TSK-1053: refactored taskana-data tests with assertJ
This commit is contained in:
parent
c09cf2f58b
commit
2112dcd79e
|
@ -44,12 +44,6 @@
|
||||||
<version>${version.junit.jupiter}</version>
|
<version>${version.junit.jupiter}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.junit.vintage</groupId>
|
|
||||||
<artifactId>junit-vintage-engine</artifactId>
|
|
||||||
<version>${version.junit.jupiter}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.h2database</groupId>
|
<groupId>com.h2database</groupId>
|
||||||
<artifactId>h2</artifactId>
|
<artifactId>h2</artifactId>
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package pro.taskana.sampledata;
|
package pro.taskana.sampledata;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
@ -8,14 +10,14 @@ class SampleDataProviderTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void getScriptsNotNull() {
|
void getScriptsNotNull() {
|
||||||
Assertions.assertNotNull(SampleDataProvider.getDefaultScripts());
|
assertThat(SampleDataProvider.getDefaultScripts()).isNotNull();
|
||||||
Assertions.assertNotNull(SampleDataProvider.getScriptsWithEvents());
|
assertThat(SampleDataProvider.getScriptsWithEvents()).isNotNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void getScriptsNotEmpty() {
|
void getScriptsNotEmpty() {
|
||||||
Assertions.assertTrue(SampleDataProvider.getDefaultScripts().count() > 0);
|
assertThat(SampleDataProvider.getDefaultScripts().count() > 0).isTrue();
|
||||||
Assertions.assertTrue(SampleDataProvider.getScriptsWithEvents().count() > 0);
|
assertThat(SampleDataProvider.getScriptsWithEvents().count() > 0).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package pro.taskana.sampledata;
|
package pro.taskana.sampledata;
|
||||||
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static pro.taskana.sampledata.SqlReplacer.DATE_TIME_FORMATTER;
|
import static pro.taskana.sampledata.SqlReplacer.DATE_TIME_FORMATTER;
|
||||||
import static pro.taskana.sampledata.SqlReplacer.RELATIVE_DATE_PATTERN;
|
import static pro.taskana.sampledata.SqlReplacer.RELATIVE_DATE_PATTERN;
|
||||||
|
|
||||||
|
@ -8,8 +8,6 @@ import java.time.Instant;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
import java.time.ZonedDateTime;
|
import java.time.ZonedDateTime;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import org.hamcrest.CoreMatchers;
|
|
||||||
import org.junit.jupiter.api.Assertions;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/** Test SampleDataGenerator. */
|
/** Test SampleDataGenerator. */
|
||||||
|
@ -20,29 +18,29 @@ class SqlReplacerTest {
|
||||||
ZonedDateTime now = Instant.now().atZone(ZoneId.of("UTC"));
|
ZonedDateTime now = Instant.now().atZone(ZoneId.of("UTC"));
|
||||||
String dateFormatted = now.format(DATE_TIME_FORMATTER);
|
String dateFormatted = now.format(DATE_TIME_FORMATTER);
|
||||||
String sqlStringReplaced = SqlReplacer.replaceDatePlaceholder(now, "... RELATIVE_DATE(0) ...");
|
String sqlStringReplaced = SqlReplacer.replaceDatePlaceholder(now, "... RELATIVE_DATE(0) ...");
|
||||||
assertThat(sqlStringReplaced, CoreMatchers.containsString(dateFormatted));
|
assertThat(sqlStringReplaced).contains(dateFormatted);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testDateRegex() {
|
void testDateRegex() {
|
||||||
|
|
||||||
Assertions.assertTrue(RELATIVE_DATE_PATTERN.matcher("RELATIVE_DATE(123)").matches());
|
assertThat(RELATIVE_DATE_PATTERN.matcher("RELATIVE_DATE(123)").matches()).isTrue();
|
||||||
|
|
||||||
Assertions.assertTrue(RELATIVE_DATE_PATTERN.matcher("... RELATIVE_DATE(5) ...").find());
|
assertThat(RELATIVE_DATE_PATTERN.matcher("... RELATIVE_DATE(5) ...").find()).isTrue();
|
||||||
Assertions.assertTrue(RELATIVE_DATE_PATTERN.matcher("... RELATIVE_DATE(0) ...").find());
|
assertThat(RELATIVE_DATE_PATTERN.matcher("... RELATIVE_DATE(0) ...").find()).isTrue();
|
||||||
Assertions.assertTrue(RELATIVE_DATE_PATTERN.matcher("... RELATIVE_DATE(-123) ...").find());
|
assertThat(RELATIVE_DATE_PATTERN.matcher("... RELATIVE_DATE(-123) ...").find()).isTrue();
|
||||||
|
|
||||||
Assertions.assertFalse(RELATIVE_DATE_PATTERN.matcher("... RELATIVE_DATE() ...").find());
|
assertThat(RELATIVE_DATE_PATTERN.matcher("... RELATIVE_DATE() ...").find()).isFalse();
|
||||||
Assertions.assertFalse(RELATIVE_DATE_PATTERN.matcher("... RELATIVE_DATE(ABCDE) ...").find());
|
assertThat(RELATIVE_DATE_PATTERN.matcher("... RELATIVE_DATE(ABCDE) ...").find()).isFalse();
|
||||||
Assertions.assertFalse(RELATIVE_DATE_PATTERN.matcher("... RELATIVE_NO(5) ...").find());
|
assertThat(RELATIVE_DATE_PATTERN.matcher("... RELATIVE_NO(5) ...").find()).isFalse();
|
||||||
Assertions.assertFalse(RELATIVE_DATE_PATTERN.matcher("...").find());
|
assertThat(RELATIVE_DATE_PATTERN.matcher("...").find()).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testDateRegexExtractGroup() {
|
void testDateRegexExtractGroup() {
|
||||||
Matcher matcher = RELATIVE_DATE_PATTERN.matcher("RELATIVE_DATE(123)");
|
Matcher matcher = RELATIVE_DATE_PATTERN.matcher("RELATIVE_DATE(123)");
|
||||||
Assertions.assertTrue(matcher.find());
|
assertThat(matcher.find()).isTrue();
|
||||||
Assertions.assertEquals("123", matcher.group(1));
|
assertThat(matcher.group(1)).isEqualTo("123");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -50,7 +48,8 @@ class SqlReplacerTest {
|
||||||
ZonedDateTime now = Instant.now().atZone(ZoneId.of("UTC"));
|
ZonedDateTime now = Instant.now().atZone(ZoneId.of("UTC"));
|
||||||
String dateFormatted = now.plusDays(5).format(DATE_TIME_FORMATTER);
|
String dateFormatted = now.plusDays(5).format(DATE_TIME_FORMATTER);
|
||||||
String sqlStringReplaced = SqlReplacer.replaceDatePlaceholder(now, "... RELATIVE_DATE(5) ...");
|
String sqlStringReplaced = SqlReplacer.replaceDatePlaceholder(now, "... RELATIVE_DATE(5) ...");
|
||||||
assertThat(sqlStringReplaced, CoreMatchers.containsString(dateFormatted));
|
|
||||||
|
assertThat(sqlStringReplaced).contains(dateFormatted);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -59,6 +58,6 @@ class SqlReplacerTest {
|
||||||
String dateFormatted = now.plusDays(-10).format(DATE_TIME_FORMATTER);
|
String dateFormatted = now.plusDays(-10).format(DATE_TIME_FORMATTER);
|
||||||
String sqlStringReplaced =
|
String sqlStringReplaced =
|
||||||
SqlReplacer.replaceDatePlaceholder(now, "... RELATIVE_DATE(-10) ...");
|
SqlReplacer.replaceDatePlaceholder(now, "... RELATIVE_DATE(-10) ...");
|
||||||
assertThat(sqlStringReplaced, CoreMatchers.containsString(dateFormatted));
|
assertThat(sqlStringReplaced).contains(dateFormatted);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue