Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…rting into develop

# Conflicts:
#	build.gradle
#	src/main/java/com/epam/ta/reportportal/ws/reporting/LaunchResource.java
#	src/main/java/com/epam/ta/reportportal/ws/reporting/TestItemResource.java
#	src/main/java/com/epam/ta/reportportal/ws/reporting/databind/MultiFormatDateDeserializer.java
#	src/test/java/com/epam/ta/reportportal/ws/reporting/deserializers/MultiFormatDateDeserializerTest.java
  • Loading branch information
pbortnik committed Nov 11, 2024
2 parents d8de030 + 10b76be commit 5b9bbd8
Show file tree
Hide file tree
Showing 11 changed files with 72 additions and 7 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ on:

env:
GH_USER_NAME: github.actor
SCRIPTS_VERSION: 5.10.0
RELEASE_VERSION: 5.10.0
SCRIPTS_VERSION: 5.12.0
RELEASE_VERSION: 5.12.3

jobs:
release:
Expand Down Expand Up @@ -43,6 +43,7 @@ jobs:
id: release
run: |
./gradlew release -PreleaseMode -Pscripts.version=${{env.SCRIPTS_VERSION}} \
-Pbom.version=${{env.BOM_VERSION}} -Pmigrations.version=${{env.MIGRATIONS_VERSION}} \
-PgithubUserName=${{env.GH_USER_NAME}} -PgithubToken=${{secrets.GITHUB_TOKEN}} \
-PgpgPassphrase=${{secrets.GPG_PASSPHRASE}} -PgpgPrivateKey="${{secrets.GPG_PRIVATE_KEY}}" \
-Prelease.releaseVersion=${{env.RELEASE_VERSION}}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![stackoverflow](https://img.shields.io/badge/reportportal-stackoverflow-orange.svg?style=flat)](http://stackoverflow.com/questions/tagged/reportportal)

[![Build Status](https://travis-ci.org/reportportal/commons-model.svg?branch=master)](https://travis-ci.org/reportportal/commons-model)
[![Maven Central](https://img.shields.io/maven-central/v/com.epam.reportportal/commons-model.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22com.epam.reportportal%22%20AND%20a:%22commons-model%22)
[![Build Status](https://travis-ci.org/reportportal/commons-reporting.svg?branch=master)](https://travis-ci.org/reportportal/commons-reporting)
[![Maven Central](https://img.shields.io/maven-central/v/com.epam.reportportal/commons-reporting.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22com.epam.reportportal%22%20AND%20a:%22commons-reporting%22)
6 changes: 5 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ plugins {
def scriptsUrl = 'https://raw.githubusercontent.com/reportportal/gradle-scripts/' +
(project.hasProperty("releaseMode") ? getProperty('scripts.version') : 'master')

project.ext.publishRepo = "https://maven.pkg.github.com/reportportal/commons-model"
project.ext.publishRepo = "https://maven.pkg.github.com/reportportal/commons-reporting"

apply from: scriptsUrl + '/release-commons.gradle'
apply from: scriptsUrl + '/signing.gradle'
Expand Down Expand Up @@ -71,3 +71,7 @@ dependencies {
test {
useJUnitPlatform()
}

tasks.preTagCommit.enabled = false
tasks.updateVersion.enabled = false
tasks.commitNewVersion.enabled = false
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=5.10.0
version=5.12.3
description=EPAM Report portal. REST Reporting API model
hibernateValidatorVersion=6.1.2.Final
validationApiVersion=2.0.1.Final
Expand Down
Empty file modified gradlew
100644 → 100755
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@

package com.epam.ta.reportportal.ws.reporting;

import com.epam.ta.reportportal.ws.reporting.databind.OffsetDateTimeInstantSerializer;
import com.epam.ta.reportportal.ws.reporting.databind.MultiFormatDateDeserializer;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import java.time.Instant;
import java.util.LinkedHashSet;
import java.util.Map;
Expand Down Expand Up @@ -68,14 +70,17 @@ public class LaunchResource extends OwnedResource {
@NotNull
@JsonProperty(value = "startTime", required = true)
@JsonDeserialize(using = MultiFormatDateDeserializer.class)
@JsonSerialize(using = OffsetDateTimeInstantSerializer.class)
private Instant startTime;

@JsonProperty(value = "endTime")
@JsonDeserialize(using = MultiFormatDateDeserializer.class)
@JsonSerialize(using = OffsetDateTimeInstantSerializer.class)
private Instant endTime;

@JsonProperty(value = "lastModified")
@JsonDeserialize(using = MultiFormatDateDeserializer.class)
@JsonSerialize(using = OffsetDateTimeInstantSerializer.class)
private Instant lastModified;

@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@

package com.epam.ta.reportportal.ws.reporting;

import com.epam.ta.reportportal.ws.reporting.databind.OffsetDateTimeInstantSerializer;
import com.epam.ta.reportportal.ws.reporting.databind.MultiFormatDateDeserializer;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import java.time.Instant;
import java.util.List;
import java.util.Set;
Expand Down Expand Up @@ -65,10 +67,12 @@ public class TestItemResource {

@JsonProperty(value = "startTime")
@JsonDeserialize(using = MultiFormatDateDeserializer.class)
@JsonSerialize(using = OffsetDateTimeInstantSerializer.class)
private Instant startTime;

@JsonProperty(value = "endTime")
@JsonDeserialize(using = MultiFormatDateDeserializer.class)
@JsonSerialize(using = OffsetDateTimeInstantSerializer.class)
private Instant endTime;

@JsonProperty(value = "status")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ public class MultiFormatDateDeserializer extends JsonDeserializer<Instant> {
private static final DateTimeFormatter TIMESTAMP_FORMAT =
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").withZone(ZoneId.of("UTC"));

private static final DateTimeFormatter ZONE_OFFSET_FORMAT = DateTimeFormatter
.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSSSSZ")
.withZone(ZoneOffset.UTC);

private static final DateTimeFormatter LOCAL_DATE_TIME_MS_FORMAT =
DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS");

Expand All @@ -54,7 +58,8 @@ public class MultiFormatDateDeserializer extends JsonDeserializer<Instant> {
DateTimeFormatter.ISO_LOCAL_DATE_TIME,
TIMESTAMP_FORMAT,
LOCAL_DATE_TIME_MS_FORMAT,
LOCAL_DATE_TIME_MS_FORMAT_DATE
LOCAL_DATE_TIME_MS_FORMAT_DATE,
ZONE_OFFSET_FORMAT
);

@Override
Expand Down
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));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class MultiFormatDateDeserializerTest {
"2024-03-01T20:24:09.930+00:00",
"2024-03-01T19:24:09.930-01:00",
"2024-03-01T23:24:09.930+0300",
"2024-03-01T20:24:09.930000+0000",
"1709324649930"
})
void deserializeDates(String strDate) throws IOException {
Expand Down
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));
}

}

0 comments on commit 5b9bbd8

Please sign in to comment.