Skip to content

Commit

Permalink
EPMRPP-89703 || Replace commons-model lib with commons-reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel Bortnik committed Apr 4, 2024
1 parent 16dce7c commit 0762573
Show file tree
Hide file tree
Showing 59 changed files with 794 additions and 118 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@
### Added
- A method to emit a log entry for a certain item:
com.epam.reportportal.service.ReportPortal.emitLog(io.reactivex.Maybe<java.lang.String>,
java.util.function.Function<java.lang.String,com.epam.ta.reportportal.ws.model.log.SaveLogRQ>)
java.util.function.Function<java.lang.String,com.epam.ta.reportportal.ws.reporting.SaveLogRQ>)
### Changed
- Apache Tika was updated on version 1.20

Expand Down
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ compileTestJava.options.encoding = 'UTF-8'

repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}

dependencies {
api ('com.epam.reportportal:commons-model:5.0.0') {
api ('com.github.reportportal:commons-reporting:5c74bb2') {
exclude module: 'jackson-databind'
}
api 'com.fasterxml.jackson.core:jackson-databind:2.12.7.1' // Access is needed by HTTP loggers to format JSON
Expand All @@ -50,6 +51,7 @@ dependencies {
api ("com.squareup.retrofit2:retrofit:${project.retrofit_version}") {
exclude module: 'okhttp'
}
implementation "org.apache.commons:commons-lang3:${project.lang3_version}"
implementation "com.squareup.okhttp3:okhttp:${project.okhttp_version}"
implementation "com.squareup.retrofit2:converter-scalars:${project.retrofit_version}"
implementation ("com.squareup.retrofit2:converter-jackson:${project.retrofit_version}") {
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ scripts_branch=develop
excludeTests=
aspectj_version=1.9.19
slf4j_version=2.0.7
lang3_version=3.14.0
2 changes: 1 addition & 1 deletion src/main/java/com/epam/reportportal/annotations/Step.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.epam.reportportal.annotations;

import com.epam.ta.reportportal.ws.model.StartTestItemRQ;
import com.epam.ta.reportportal.ws.reporting.StartTestItemRQ;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import java.lang.annotation.Target;

/**
* Annotation used in {@link Attributes} as field, to provide {@link com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ}
* Annotation used in {@link Attributes} as field, to provide {@link com.epam.ta.reportportal.ws.reporting.ItemAttributesRQ}
* with both 'key' and 'value' fields specified
*
* @author <a href="mailto:ivan_budayeu@epam.com">Ivan Budayeu</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import java.lang.annotation.Target;

/**
* Annotation used in {@link Attributes} as field, to provide {@link com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ}
* Annotation used in {@link Attributes} as field, to provide {@link com.epam.ta.reportportal.ws.reporting.ItemAttributesRQ}
* with only 'value' field specified ('key' in the resulted entity will be NULL)
*
* @author <a href="mailto:ivan_budayeu@epam.com">Ivan Budayeu</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import java.lang.annotation.*;

/**
* Annotation for test methods and classes to attach {@link com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ} to the test items
* Annotation for test methods and classes to attach {@link com.epam.ta.reportportal.ws.reporting.ItemAttributesRQ} to the test items
*
* @author <a href="mailto:ivan_budayeu@epam.com">Ivan Budayeu</a>
* @see Attribute
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import java.lang.annotation.Target;

/**
* Annotation used in {@link Attributes} as field, to provide multiple {@link com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ}
* Annotation used in {@link Attributes} as field, to provide multiple {@link com.epam.ta.reportportal.ws.reporting.ItemAttributesRQ}
* with both 'key' and 'value' fields specified.
* Used to prevent duplication of {@link Attribute} annotation with the same value and different keys
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import java.lang.annotation.Target;

/**
* Annotation used in {@link Attributes} as field, to provide multiple {@link com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ}
* Annotation used in {@link Attributes} as field, to provide multiple {@link com.epam.ta.reportportal.ws.reporting.ItemAttributesRQ}
* with both 'key' (optional) and 'value' fields specified.
* Used to prevent duplication of {@link Attribute} annotation with the same key and different values
*
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/epam/reportportal/aspect/StepAspect.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import com.epam.reportportal.annotations.Step;
import com.epam.reportportal.service.Launch;
import com.epam.ta.reportportal.ws.model.StartTestItemRQ;
import com.epam.ta.reportportal.ws.reporting.StartTestItemRQ;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.*;
import org.aspectj.lang.reflect.MethodSignature;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import com.epam.reportportal.annotations.Step;
import com.epam.reportportal.annotations.attribute.Attributes;
import com.epam.reportportal.utils.AttributeParser;
import com.epam.ta.reportportal.ws.model.StartTestItemRQ;
import com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ;
import com.epam.ta.reportportal.ws.reporting.ItemAttributesRQ;
import com.epam.ta.reportportal.ws.reporting.StartTestItemRQ;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.reflect.MethodSignature;

Expand Down
145 changes: 145 additions & 0 deletions src/main/java/com/epam/reportportal/exception/ErrorRS.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
/*
* Copyright 2019 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.exception;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.ObjectCodec;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import java.io.IOException;
import java.io.Serializable;

/**
* Base Error response body for all Report Portal exceptions
*
* @author Andrei Varabyeu
*
*/
@JsonPropertyOrder({ "errorCode", "message", "stackTrace" })
@JsonInclude(Include.NON_NULL)
public class ErrorRS implements Serializable {
/**
* Generated SVUID
*/
private static final long serialVersionUID = -3717290684860161862L;

@JsonSerialize(using = ErrorTypeSerializer.class)
@JsonDeserialize(using = ErrorTypeDeserializer.class)
@JsonProperty("errorCode")
private ErrorType errorType;

@JsonProperty("stackTrace")
private String stackTrace;

@JsonProperty("message")
private String message;

public ErrorType getErrorType() {
return errorType;
}

public void setErrorType(ErrorType errorType) {
this.errorType = errorType;
}

public String getStackTrace() {
return stackTrace;
}

public void setStackTrace(String stackTrace) {
this.stackTrace = stackTrace;
}

public String getMessage() {
return message;
}

public void setMessage(String message) {
this.message = message;
}

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((errorType == null) ? 0 : errorType.hashCode());
result = prime * result + ((message == null) ? 0 : message.hashCode());
result = prime * result + ((stackTrace == null) ? 0 : stackTrace.hashCode());
return result;
}

@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
ErrorRS other = (ErrorRS) obj;
if (errorType != other.errorType)
return false;
if (message == null) {
if (other.message != null)
return false;
} else if (!message.equals(other.message))
return false;
if (stackTrace == null) {
return other.stackTrace == null;
} else
return stackTrace.equals(other.stackTrace);
}

private static class ErrorTypeDeserializer extends JsonDeserializer<ErrorType> {

@Override
public ErrorType deserialize(JsonParser parser, DeserializationContext context) throws IOException {
ObjectCodec oc = parser.getCodec();
JsonNode node = oc.readTree(parser);
return ErrorType.getByCode(node.asInt());

}

}

private static class ErrorTypeSerializer extends JsonSerializer<ErrorType> {

@Override
public void serialize(ErrorType error, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
jsonGenerator.writeNumber(error.getCode());
}

}

@Override
public String toString() {
return "ErrorRS{" + "errorType=" + errorType
+ ", stackTrace='" + stackTrace + '\''
+ ", message='" + message + '\''
+ '}';
}
}
Loading

0 comments on commit 0762573

Please sign in to comment.