Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 5.12.0 #9

Merged
merged 13 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.0
description=EPAM Report portal. REST Reporting API model
hibernateValidatorVersion=6.1.2.Final
validationApiVersion=2.0.1.Final
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,7 @@ public class LaunchResource extends OwnedResource {
@JsonProperty(value = "metadata")
private Map<String, Object> metadata;

@JsonProperty(value = "retentionPolicy")
private RetentionPolicy retentionPolicy;

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

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


import static com.epam.ta.reportportal.ws.reporting.ValidationConstraints.MAX_PARAMETERS_LENGTH;

import com.epam.ta.reportportal.ws.annotations.NotBlankWithSize;
Expand Down Expand Up @@ -66,7 +65,7 @@ public class MergeLaunchesRQ {

@NotEmpty
@JsonProperty(value = "launches", required = true)
@Schema(requiredMode = RequiredMode.REQUIRED)
@Schema(description = "A set of IDs of the launches to be merged.", requiredMode = RequiredMode.REQUIRED)
private Set<Long> launches;

@JsonProperty(value = "endTime")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright 2023 EPAM Systems
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

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

/**
* @author Ivan Kustau
*/
public enum RetentionPolicy {
IMPORTANT, REGULAR
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
import java.time.format.DateTimeParseException;
import java.time.temporal.TemporalAccessor;
import java.util.Arrays;
import java.util.List;

/**
* Deserialization class for parsing incoming dates of different formats.
Expand All @@ -38,7 +42,20 @@ public class MultiFormatDateDeserializer extends JsonDeserializer<Instant> {
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").withZone(ZoneId.of("UTC"));

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

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

private static final List<DateTimeFormatter> PREDEFINED_FORMATS = Arrays.asList(
DateTimeFormatter.RFC_1123_DATE_TIME,
DateTimeFormatter.ISO_OFFSET_DATE_TIME,
DateTimeFormatter.ISO_DATE_TIME,
DateTimeFormatter.ISO_LOCAL_DATE_TIME,
TIMESTAMP_FORMAT,
LOCAL_DATE_TIME_MS_FORMAT,
LOCAL_DATE_TIME_MS_FORMAT_DATE
);

@Override
public Instant deserialize(JsonParser parser, DeserializationContext context) throws IOException {
Expand All @@ -47,7 +64,6 @@ public Instant deserialize(JsonParser parser, DeserializationContext context) th
if (parser.getText() == null) {
return Instant.ofEpochMilli(longDate);
}
// ignore
} catch (Exception e) {
// ignore
}
Expand All @@ -59,16 +75,17 @@ public Instant deserialize(JsonParser parser, DeserializationContext context) th
}

String strDate = parser.getText();
DateTimeFormatter formatter =
new DateTimeFormatterBuilder().appendOptional(DateTimeFormatter.RFC_1123_DATE_TIME)
.appendOptional(DateTimeFormatter.ISO_OFFSET_DATE_TIME)
.appendOptional(DateTimeFormatter.ISO_DATE_TIME)
.appendOptional(DateTimeFormatter.ISO_LOCAL_DATE_TIME)
.appendOptional(TIMESTAMP_FORMAT)
.appendOptional(LOCAL_DATE_TIME_MS_FORMAT)
.toFormatter();

return LocalDateTime.from(formatter.parse(strDate)).toInstant(ZoneOffset.UTC);

for (DateTimeFormatter formatter : PREDEFINED_FORMATS) {
try {
TemporalAccessor parsedDate = formatter.parseBest(strDate, ZonedDateTime::from,
LocalDateTime::from);
return parsedDate instanceof ZonedDateTime ? ((ZonedDateTime) parsedDate).toInstant()
: ((LocalDateTime) parsedDate).toInstant(ZoneOffset.UTC);
} catch (DateTimeParseException e) {
// Exception means the text could not be parsed with this formatter, continue with next formatter
}
}
throw new IOException("Unable to parse date: " + strDate);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
Expand All @@ -44,10 +45,12 @@ class MultiFormatDateDeserializerTest {
@ParameterizedTest
@ValueSource(strings = {
"2024-03-01T20:24:09.930987Z",
"2024-03-01T20:24:09.930987654Z",
"2024-03-01T20:24:09.930987654",
"2024-03-01T20:24:09.930Z",
"2024-03-01T20:24:09.930",
"2024-03-01T20:24:09.930+00:00",
"2024-03-01T19:24:09.930-01:00",
"2024-03-01T23:24:09.930+0300",
"1709324649930"
})
void deserializeDates(String strDate) throws IOException {
Expand Down
Loading