-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from reportportal/rc/5.12.3
5.12.3 || Fix back compatibility
- Loading branch information
Showing
8 changed files
with
66 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
.../java/com/epam/ta/reportportal/ws/reporting/databind/OffsetDateTimeInstantSerializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.epam.ta.reportportal.ws.reporting.databind; | ||
|
||
import com.fasterxml.jackson.core.JsonGenerator; | ||
import com.fasterxml.jackson.databind.JsonSerializer; | ||
import com.fasterxml.jackson.databind.SerializerProvider; | ||
import java.io.IOException; | ||
import java.time.Instant; | ||
import java.time.ZoneOffset; | ||
import java.time.format.DateTimeFormatter; | ||
|
||
public class OffsetDateTimeInstantSerializer extends JsonSerializer<Instant> { | ||
|
||
private static final DateTimeFormatter formatter = DateTimeFormatter | ||
.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSSSSZ") | ||
.withZone(ZoneOffset.UTC); | ||
|
||
@Override | ||
public void serialize(Instant value, JsonGenerator gen, SerializerProvider provider) | ||
throws IOException { | ||
gen.writeString(formatter.format(value)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...om/epam/ta/reportportal/ws/reporting/serializers/OffsetDateTimeInstantSerializerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.epam.ta.reportportal.ws.reporting.serializers; | ||
|
||
import com.epam.ta.reportportal.ws.reporting.LaunchResource; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import java.io.IOException; | ||
import java.time.Instant; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class OffsetDateTimeInstantSerializerTest { | ||
|
||
private static final String EXPECTED_PARSED_TIME = "2024-11-01T08:39:14.125000+0000"; | ||
|
||
@Test | ||
void serializeTimeInCompatibleFormat() throws IOException { | ||
LaunchResource launchResource = new LaunchResource(); | ||
launchResource.setStartTime(Instant.ofEpochMilli(1730450354125L)); | ||
ObjectMapper objectMapper = new ObjectMapper(); | ||
String s = objectMapper.writeValueAsString(launchResource); | ||
Assertions.assertTrue(s.contains(EXPECTED_PARSED_TIME)); | ||
} | ||
|
||
} |