Compare commits

...

3 Commits

Author SHA1 Message Date
YannC
32ce62c0cd tests(fix): Updated count variable 2023-07-10 15:46:39 +02:00
YannC
13bf5237e8 chore(version): update to version 'v0.9.7'. 2023-07-10 15:17:36 +02:00
Loïc Mathieu
6060ca0129 fix(jdbc): DateTimeFormatter can be reused in the JdbcMapper 2023-07-10 15:17:27 +02:00
5 changed files with 21 additions and 9 deletions

View File

@@ -19,7 +19,7 @@ import java.util.function.BiConsumer;
import java.util.function.Consumer;
public class Helpers {
public static long FLOWS_COUNT = 65;
public static long FLOWS_COUNT = 66;
public static ApplicationContext applicationContext() throws URISyntaxException {
return applicationContext(

View File

@@ -0,0 +1,6 @@
id: execution-start-date
namespace: io.kestra.tests
tasks:
- id: hello
type: io.kestra.core.tasks.debugs.Return
format: "{{ execution.startDate }}"

View File

@@ -1,3 +1,3 @@
version=0.9.5
version=0.9.7
micronautVersion=3.9.0
lombokVersion=1.18.26

View File

@@ -14,6 +14,9 @@ import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
public abstract class JdbcMapper {
private static final DateTimeFormatter INSTANT_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
.withZone(ZoneOffset.UTC);
private static final DateTimeFormatter ZONED_DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
private static ObjectMapper MAPPER;
public static ObjectMapper of() {
@@ -24,19 +27,14 @@ public abstract class JdbcMapper {
module.addSerializer(Instant.class, new JsonSerializer<>() {
@Override
public void serialize(Instant instant, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
jsonGenerator.writeString(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
.withZone(ZoneOffset.UTC)
.format(instant)
);
jsonGenerator.writeString(INSTANT_FORMATTER.format(instant));
}
});
module.addSerializer(ZonedDateTime.class, new JsonSerializer<>() {
@Override
public void serialize(ZonedDateTime instant, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
jsonGenerator.writeString(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSXXX")
.format(instant)
);
jsonGenerator.writeString(ZONED_DATE_TIME_FORMATTER.format(instant));
}
});

View File

@@ -27,6 +27,7 @@ import java.util.concurrent.TimeoutException;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.matchesPattern;
@MicronautTest(transactional = false)
@TestInstance(TestInstance.Lifecycle.PER_CLASS) // must be per-class to allow calling once init() which took a lot of time
@@ -240,4 +241,11 @@ public abstract class JdbcRunnerTest {
public void pauseRunTimeout() throws Exception {
pauseTest.runTimeout(runnerUtils);
}
@Test
void executionDate() throws TimeoutException {
Execution execution = runnerUtils.runOne("io.kestra.tests", "execution-start-date", null, null, Duration.ofSeconds(60));
assertThat((String) execution.getTaskRunList().get(0).getOutputs().get("value"), matchesPattern("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z"));
}
}