Skip to content

Commit

Permalink
EPMRPP-88602 Instant time (#20)
Browse files Browse the repository at this point in the history
* EPMRPP-88602 Instant time

* EPMRPP-88602 LDT serialization fix for analyzer
  • Loading branch information
grabsefx authored Apr 15, 2024
1 parent 188e101 commit d7f9bec
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 96 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright 2024 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.reportportal.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.LocalDateTime;

/**
* Serialization class for converting dates into array of integers.
* Required for compatibility with analyzer.
*
* @author Siarhei Hrabko
*/
public class LocalDateTimeSerializer extends JsonSerializer<LocalDateTime> {

@Override
public void serialize(LocalDateTime localDateTime, JsonGenerator jsonGenerator,
SerializerProvider serializerProvider) throws IOException {
int[] time = {
localDateTime.getYear(),
localDateTime.getMonthValue(),
localDateTime.getDayOfMonth(),
localDateTime.getHour(),
localDateTime.getMinute(),
localDateTime.getSecond(),
localDateTime.getNano()
};
jsonGenerator.writeArray(time, 0, 7);
}
}
106 changes: 10 additions & 96 deletions src/main/java/com/epam/reportportal/model/ActivityResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,23 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
import java.util.Date;
import java.time.Instant;
import javax.validation.constraints.NotNull;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;

/**
* JSON Representation of Report Portal's Activity domain object.
*
* @see <a href="http://en.wikipedia.org/wiki/HATEOAS">HATEOAS Description</a>
*/
@JsonInclude(Include.NON_NULL)
@Getter
@Setter
@ToString
@NoArgsConstructor
public class ActivityResource {

@NotNull
Expand All @@ -50,7 +58,7 @@ public class ActivityResource {
@NotNull
@JsonProperty(value = "lastModified", required = true)
@Schema(requiredMode = RequiredMode.REQUIRED)
private Date lastModified;
private Instant lastModified;

@NotNull
@JsonProperty(value = "actionType", required = true)
Expand All @@ -76,98 +84,4 @@ public class ActivityResource {
@JsonProperty(value = "objectName")
private String objectName;

public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}

public String getUser() {
return user;
}

public void setUser(String user) {
this.user = user;
}

public Long getLoggedObjectId() {
return loggedObjectId;
}

public void setLoggedObjectId(Long loggedObjectId) {
this.loggedObjectId = loggedObjectId;
}

public Date getLastModified() {
return lastModified;
}

public void setLastModified(Date lastModified) {
this.lastModified = lastModified;
}

public String getActionType() {
return actionType;
}

public void setActionType(String actionType) {
this.actionType = actionType;
}

public String getObjectType() {
return objectType;
}

public void setObjectType(String objectType) {
this.objectType = objectType;
}

public Long getProjectId() {
return projectId;
}

public void setProjectId(Long projectId) {
this.projectId = projectId;
}

public String getProjectName() {
return projectName;
}

public void setProjectName(String projectName) {
this.projectName = projectName;
}

public Object getDetails() {
return details;
}

public void setDetails(Object details) {
this.details = details;
}

public String getObjectName() {
return objectName;
}

public void setObjectName(String objectName) {
this.objectName = objectName;
}

@Override
public String toString() {
return "ActivityResource{" + "id=" + id
+ ", user='" + user + '\''
+ ", loggedObjectId='" + loggedObjectId + '\''
+ ", lastModified=" + lastModified
+ ", actionType='" + actionType + '\''
+ ", objectType='" + objectType + '\''
+ ", projectId=" + projectId
+ ", projectName='" + projectName + '\''
+ ", objectName='" + objectName + '\''
+ ", details=" + details
+ '}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@

package com.epam.reportportal.model.analyzer;

import com.epam.reportportal.databind.LocalDateTimeSerializer;
import com.epam.reportportal.model.project.AnalyzerConfig;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
Expand All @@ -38,6 +40,7 @@ public class IndexLaunch {
private String launchName;

@JsonProperty("launchStartTime")
@JsonSerialize(using = LocalDateTimeSerializer.class)
private LocalDateTime launchStartTime;

@JsonProperty("project")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@

package com.epam.reportportal.model.analyzer;

import com.epam.reportportal.databind.LocalDateTimeSerializer;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import java.time.LocalDateTime;
import java.util.Objects;

Expand All @@ -36,6 +38,7 @@ public class IndexLog {
private int logLevel;

@JsonProperty("logTime")
@JsonSerialize(using = LocalDateTimeSerializer.class)
private LocalDateTime logTime;

@JsonProperty("message")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@

package com.epam.reportportal.model.analyzer;

import com.epam.reportportal.databind.LocalDateTimeSerializer;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import java.time.LocalDateTime;
import java.util.Objects;
import java.util.Set;
Expand All @@ -37,6 +39,7 @@ public class IndexTestItem {
@JsonProperty("issueType")
private String issueTypeLocator;

@JsonSerialize(using = LocalDateTimeSerializer.class)
private LocalDateTime startTime;

@JsonProperty("logs")
Expand Down

0 comments on commit d7f9bec

Please sign in to comment.