mirror of
https://github.com/kestra-io/kestra.git
synced 2025-12-19 18:05:41 -05:00
* feat(Unit Tests) #8171 convert hamcrest to assertj * fix(Unit Tests) #8171 failing unit test after assertj migration --------- Co-authored-by: nKwiatkowski <nkwiatkowski@kestra.io>
This commit is contained in:
@@ -12,9 +12,7 @@ import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.List;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class H2FlowRepositoryTest extends AbstractJdbcFlowRepositoryTest {
|
||||
|
||||
@@ -31,7 +29,7 @@ public class H2FlowRepositoryTest extends AbstractJdbcFlowRepositoryTest {
|
||||
|
||||
// FIXME since the big task renaming, H2 return 6 instead of 2
|
||||
// as no core change this is a test artefact, or a latent bug in H2.
|
||||
assertThat((long) search.size(), is(6L));
|
||||
assertThat((long) search.size()).isEqualTo(6L);
|
||||
|
||||
SearchResult<Flow> flow = search
|
||||
.stream()
|
||||
@@ -40,7 +38,7 @@ public class H2FlowRepositoryTest extends AbstractJdbcFlowRepositoryTest {
|
||||
.equals("trigger-multiplecondition-listener"))
|
||||
.findFirst()
|
||||
.orElseThrow();
|
||||
assertThat(flow.getFragments().getFirst(), containsString("condition.MultipleCondition[/mark]"));
|
||||
assertThat(flow.getFragments().getFirst()).contains("condition.MultipleCondition[/mark]");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4,24 +4,23 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class H2FunctionsTest {
|
||||
@Test
|
||||
public void jqNull() {
|
||||
String jqString = H2Functions.jqString("{\"a\": null}", ".a");
|
||||
assertThat(jqString, is(nullValue()));
|
||||
assertThat(jqString).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jqString() {
|
||||
String jqString = H2Functions.jqString("{\"a\": \"b\"}", ".a");
|
||||
assertThat(jqString, is("b"));
|
||||
assertThat(jqString).isEqualTo("b");
|
||||
|
||||
// on arrays, it will use the first element
|
||||
jqString = H2Functions.jqString("{\"labels\":[{\"key\":\"a\",\"value\":\"aValue\"},{\"key\":\"b\",\"value\":\"bValue\"}]}", ".labels[].value");
|
||||
assertThat(jqString, is("aValue"));
|
||||
assertThat(jqString).isEqualTo("aValue");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -29,30 +28,30 @@ class H2FunctionsTest {
|
||||
String jqString = H2Functions.jqString("""
|
||||
{"a": [{"b": "c", "d": "e"}]}
|
||||
""", ".a[].b");
|
||||
assertThat(jqString, is("c"));
|
||||
assertThat(jqString).isEqualTo("c");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jqBoolean() {
|
||||
Boolean jqString = H2Functions.jqBoolean("{\"a\": true}", ".a");
|
||||
assertThat(jqString, is(true));
|
||||
assertThat(jqString).isEqualTo(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jqInteger() {
|
||||
Integer jqString = H2Functions.jqInteger("{\"a\": 2147483647}", ".a");
|
||||
assertThat(jqString, is(2147483647));
|
||||
assertThat(jqString).isEqualTo(2147483647);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jqLong() {
|
||||
Long jqString = H2Functions.jqLong("{\"a\": 9223372036854775807}", ".a");
|
||||
assertThat(jqString, is(9223372036854775807L));
|
||||
assertThat(jqString).isEqualTo(9223372036854775807L);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jqStringArray() {
|
||||
String[] jqString = H2Functions.jqStringArray("{\"a\": [\"1\", \"2\", \"3\"]}", ".a");
|
||||
assertThat(List.of(jqString), containsInAnyOrder("1", "2", "3"));
|
||||
assertThat(List.of(jqString)).containsExactlyInAnyOrder("1", "2", "3");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user