diff --git a/.github/workflows/promote.yml b/.github/workflows/promote.yml index 901c951..5df0950 100644 --- a/.github/workflows/promote.yml +++ b/.github/workflows/promote.yml @@ -105,4 +105,4 @@ jobs: else echo 'Verification failed, please check the bundle' 1>&2 exit 1 - fi \ No newline at end of file + fi diff --git a/build.gradle b/build.gradle index 880e4e3..d6d1178 100644 --- a/build.gradle +++ b/build.gradle @@ -2,7 +2,7 @@ plugins { id 'io.spring.dependency-management' version '1.1.6' id 'java' id 'java-library' - id 'org.owasp.dependencycheck' version '11.1.0' + id 'org.owasp.dependencycheck' version '11.1.1' } project.ext { @@ -16,13 +16,15 @@ def scriptsUrl = 'https://raw.githubusercontent.com/reportportal/gradle-scripts/ apply from: scriptsUrl + '/release-commons.gradle' apply from: scriptsUrl + '/signing.gradle' -//apply from: scriptsUrl + '/build-quality.gradle' +//apply from: scriptsUrl + '/build-quality.gradle' // TODO: fix scripts java { sourceCompatibility = JavaVersion.VERSION_21 targetCompatibility = JavaVersion.VERSION_21 } +ext['spring-boot.version'] = "${springBootVersion}" + repositories { mavenCentral { url "https://repo1.maven.org/maven2" } if (!releaseMode) { @@ -32,8 +34,8 @@ repositories { dependencyManagement { imports { - mavenBom 'org.springframework.boot:spring-boot-dependencies:2.1.5.RELEASE' - mavenBom('com.epam.reportportal:commons-bom:5.12.3') + mavenBom "org.springframework.boot:spring-boot-dependencies:${springBootVersion}" + mavenBom "com.epam.reportportal:commons-bom:5.12.3" } } @@ -41,24 +43,23 @@ dependencies { if (releaseMode) { api 'com.epam.reportportal:commons-reporting:5.12.3' } else { - api 'com.github.reportportal:commons-reporting:develop-SNAPSHOT' + api 'com.github.reportportal:commons-reporting:b997ee3' } api 'org.springframework:spring-webmvc' api 'org.springframework.security:spring-security-core' api 'org.apache.tika:tika-core' - implementation "org.springdoc:springdoc-openapi-data-rest:${sprindocAnnotationsVersion}" + api "org.springdoc:springdoc-openapi-starter-common:${springDocVersion}" api "com.fasterxml.jackson.core:jackson-databind:${jacksonVersion}" - api "javax.validation:validation-api:${validationApiVersion}" - implementation "org.apache.commons:commons-lang3:${commonsLangVersion}" - implementation group: 'com.google.guava', name: 'guava', version: '28.2-jre' - implementation 'javax.servlet:javax.servlet-api' + api "org.apache.commons:commons-lang3:${commonsLangVersion}" + api "com.google.guava:guava:${guava}" + implementation 'jakarta.servlet:jakarta.servlet-api:6.1.0' + implementation "org.hibernate.validator:hibernate-validator:${hibernateValidatorVersion}" implementation 'org.freemarker:freemarker' implementation 'ch.qos.logback:logback-classic' - implementation 'net.coobird:thumbnailator:0.4.11' - implementation 'com.google.guava:guava' - implementation 'javax.inject:javax.inject:1' + implementation 'net.coobird:thumbnailator:0.4.20' + api 'jakarta.inject:jakarta.inject-api:2.0.1' // add lombok support compileOnly "org.projectlombok:lombok:${lombokVersion}" @@ -66,15 +67,23 @@ dependencies { testCompileOnly "org.projectlombok:lombok:${lombokVersion}" testAnnotationProcessor "org.projectlombok:lombok:${lombokVersion}" - testImplementation "junit:junit:${junitVersion}" + testImplementation "org.junit.jupiter:junit-jupiter-api:${junitVersion}" + testImplementation "org.junit.jupiter:junit-jupiter-params:${junitVersion}" + testImplementation "org.junit.jupiter:junit-jupiter-engine:${junitVersion}" testImplementation "org.mockito:mockito-junit-jupiter:${mockitoJunitJupiter}" - testImplementation "org.hibernate.validator:hibernate-validator:${hibernateValidatorVersion}" - testImplementation "javax.el:javax.el-api:${elApiVersion}" - testImplementation "org.glassfish:javax.el:${elApiVersion}" + testImplementation "org.hamcrest:hamcrest:2.2" + testImplementation "org.glassfish:jakarta.el:4.0.2" } -wrapper { - gradleVersion = '8.10' +test { + useJUnitPlatform() + testLogging { + events = ['failed'] + exceptionFormat = 'short' + } + reports { + junitXml.required = true + } } tasks.preTagCommit.enabled = false diff --git a/gradle.properties b/gradle.properties index 595811c..bc7ad0a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,11 +1,11 @@ version=5.12.3 description=EPAM Report portal common libs -hibernateValidatorVersion=6.2.0.Final -validationApiVersion=2.0.1.Final -junitVersion=4.13.1 -elApiVersion=3.0.0 -sprindocAnnotationsVersion=1.7.0 -commonsLangVersion=3.9 -mockitoJunitJupiter=2.23.0 -jacksonVersion=2.13.4.2 -lombokVersion=1.18.30 +hibernateValidatorVersion=8.0.1.Final +junitVersion=5.11.0 +springBootVersion=3.4.0 +springDocVersion=2.6.0 +commonsLangVersion=3.17.0 +mockitoJunitJupiter=5.14.2 +jacksonVersion=2.18.0 +lombokVersion=1.18.36 +guava=33.2.1-jre diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 9355b41..e2847c8 100755 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/jitpack.yml b/jitpack.yml index a202792..727c9ab 100644 --- a/jitpack.yml +++ b/jitpack.yml @@ -1,2 +1,2 @@ jdk: - - openjdk21 \ No newline at end of file + - openjdk21 diff --git a/src/main/java/com/epam/reportportal/annotations/NotBlankString.java b/src/main/java/com/epam/reportportal/annotations/NotBlankString.java index d235a53..626b20d 100644 --- a/src/main/java/com/epam/reportportal/annotations/NotBlankString.java +++ b/src/main/java/com/epam/reportportal/annotations/NotBlankString.java @@ -16,12 +16,12 @@ package com.epam.reportportal.annotations; +import jakarta.validation.Constraint; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import javax.validation.Constraint; /** * Can be used with strings. Checks if string is blank. diff --git a/src/main/java/com/epam/reportportal/annotations/NotBlankStringCollection.java b/src/main/java/com/epam/reportportal/annotations/NotBlankStringCollection.java index 10cca24..760b62d 100644 --- a/src/main/java/com/epam/reportportal/annotations/NotBlankStringCollection.java +++ b/src/main/java/com/epam/reportportal/annotations/NotBlankStringCollection.java @@ -16,12 +16,12 @@ package com.epam.reportportal.annotations; +import jakarta.validation.Constraint; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import javax.validation.Constraint; /** * Can be used with collection of strings. Checks if collection contains only not blank elements. diff --git a/src/main/java/com/epam/reportportal/annotations/NotBlankStringCollectionValidator.java b/src/main/java/com/epam/reportportal/annotations/NotBlankStringCollectionValidator.java index 953515c..43e3b5d 100644 --- a/src/main/java/com/epam/reportportal/annotations/NotBlankStringCollectionValidator.java +++ b/src/main/java/com/epam/reportportal/annotations/NotBlankStringCollectionValidator.java @@ -16,9 +16,9 @@ package com.epam.reportportal.annotations; +import jakarta.validation.ConstraintValidator; +import jakarta.validation.ConstraintValidatorContext; import java.util.Collection; -import javax.validation.ConstraintValidator; -import javax.validation.ConstraintValidatorContext; /** * @author Ihar Kahadouski diff --git a/src/main/java/com/epam/reportportal/annotations/NotBlankStringValidator.java b/src/main/java/com/epam/reportportal/annotations/NotBlankStringValidator.java index e7a0c0e..56a298d 100644 --- a/src/main/java/com/epam/reportportal/annotations/NotBlankStringValidator.java +++ b/src/main/java/com/epam/reportportal/annotations/NotBlankStringValidator.java @@ -16,8 +16,8 @@ package com.epam.reportportal.annotations; -import javax.validation.ConstraintValidator; -import javax.validation.ConstraintValidatorContext; +import jakarta.validation.ConstraintValidator; +import jakarta.validation.ConstraintValidatorContext; /** * @author Ihar Kahadouski diff --git a/src/main/java/com/epam/reportportal/annotations/NotNullMapValue.java b/src/main/java/com/epam/reportportal/annotations/NotNullMapValue.java index 1d57023..8d52e9a 100644 --- a/src/main/java/com/epam/reportportal/annotations/NotNullMapValue.java +++ b/src/main/java/com/epam/reportportal/annotations/NotNullMapValue.java @@ -16,11 +16,11 @@ package com.epam.reportportal.annotations; +import jakarta.validation.Constraint; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import javax.validation.Constraint; @Constraint(validatedBy = {NotNullMapValueValidator.class}) @Target({ElementType.FIELD}) diff --git a/src/main/java/com/epam/reportportal/annotations/NotNullMapValueValidator.java b/src/main/java/com/epam/reportportal/annotations/NotNullMapValueValidator.java index 031f83f..db39575 100644 --- a/src/main/java/com/epam/reportportal/annotations/NotNullMapValueValidator.java +++ b/src/main/java/com/epam/reportportal/annotations/NotNullMapValueValidator.java @@ -16,9 +16,9 @@ package com.epam.reportportal.annotations; +import jakarta.validation.ConstraintValidator; +import jakarta.validation.ConstraintValidatorContext; import java.util.Map; -import javax.validation.ConstraintValidator; -import javax.validation.ConstraintValidatorContext; public class NotNullMapValueValidator implements ConstraintValidator> { diff --git a/src/main/java/com/epam/reportportal/commons/template/TemplateEngineProvider.java b/src/main/java/com/epam/reportportal/commons/template/TemplateEngineProvider.java index 3040e20..57794d6 100644 --- a/src/main/java/com/epam/reportportal/commons/template/TemplateEngineProvider.java +++ b/src/main/java/com/epam/reportportal/commons/template/TemplateEngineProvider.java @@ -6,8 +6,8 @@ import com.google.common.base.Preconditions; import freemarker.template.TemplateExceptionHandler; import freemarker.template.Version; +import jakarta.inject.Provider; import java.util.Locale; -import javax.inject.Provider; /** * Factory bean for {@link TemplateEngine} diff --git a/src/main/java/com/epam/reportportal/model/ActivityResource.java b/src/main/java/com/epam/reportportal/model/ActivityResource.java index 70812f1..9b5c4e9 100644 --- a/src/main/java/com/epam/reportportal/model/ActivityResource.java +++ b/src/main/java/com/epam/reportportal/model/ActivityResource.java @@ -21,8 +21,8 @@ import com.fasterxml.jackson.annotation.JsonProperty; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema.RequiredMode; +import jakarta.validation.constraints.NotNull; import java.time.Instant; -import javax.validation.constraints.NotNull; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; diff --git a/src/main/java/com/epam/reportportal/model/EntryCreatedRS.java b/src/main/java/com/epam/reportportal/model/EntryCreatedRS.java index 313f361..bcfa843 100644 --- a/src/main/java/com/epam/reportportal/model/EntryCreatedRS.java +++ b/src/main/java/com/epam/reportportal/model/EntryCreatedRS.java @@ -19,34 +19,28 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; /** * Response when some entry has been created and we need to return ID * * @author Andrei Varabyeu */ +@Setter +@Getter @JsonInclude(Include.NON_NULL) +@NoArgsConstructor public class EntryCreatedRS { @JsonProperty("id") private Long id; - public EntryCreatedRS() { - - } - public EntryCreatedRS(Long id) { this.id = id; } - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - @Override public String toString() { final StringBuilder sb = new StringBuilder("EntryCreatedRS{"); @@ -55,4 +49,4 @@ public String toString() { return sb.toString(); } -} \ No newline at end of file +} diff --git a/src/main/java/com/epam/reportportal/model/Page.java b/src/main/java/com/epam/reportportal/model/Page.java index 2bf8bc0..3cb6a0e 100644 --- a/src/main/java/com/epam/reportportal/model/Page.java +++ b/src/main/java/com/epam/reportportal/model/Page.java @@ -18,6 +18,7 @@ import java.util.Collection; import java.util.Iterator; +import lombok.Getter; /** * Paged response representation Re-implementation of Spring's HATEAOS Page implementation to get @@ -25,6 +26,7 @@ * * @author Andrei Varabyeu */ +@Getter public class Page implements Iterable { private final Collection content; @@ -52,19 +54,12 @@ public Page(Collection content, long size, long number, long totalElements) { this.page = new PageMetadata(size, number, totalElements); } - public Collection getContent() { - return content; - } - - public PageMetadata getPage() { - return page; - } - @Override public Iterator iterator() { return content.iterator(); } + @Getter public static class PageMetadata { long number; @@ -96,22 +91,6 @@ public PageMetadata(long size, long number, long totalElements) { size == 0 ? 0 : (long) Math.ceil((double) totalElements / (double) size)); } - public long getNumber() { - return number; - } - - public long getSize() { - return size; - } - - public long getTotalElements() { - return totalElements; - } - - public long getTotalPages() { - return totalPages; - } - @Override public String toString() { final StringBuilder sb = new StringBuilder("PageMetadata{"); diff --git a/src/main/java/com/epam/reportportal/model/externalsystem/PostTicketRQ.java b/src/main/java/com/epam/reportportal/model/externalsystem/PostTicketRQ.java index deabf11..2e66d51 100644 --- a/src/main/java/com/epam/reportportal/model/externalsystem/PostTicketRQ.java +++ b/src/main/java/com/epam/reportportal/model/externalsystem/PostTicketRQ.java @@ -20,11 +20,12 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonProperty; +import jakarta.validation.constraints.Max; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.Size; import java.util.List; import java.util.Map; -import javax.validation.constraints.Max; -import javax.validation.constraints.Min; -import javax.validation.constraints.Size; +import lombok.Setter; /** * Domain object for creating ticket in bug tracking system. @@ -32,6 +33,7 @@ * @author Aliaksei_Makayed * @author Andrei_Ramanchuk */ +@Setter @JsonInclude(Include.NON_NULL) public class PostTicketRQ extends Authentic { @@ -63,14 +65,6 @@ public Map getBackLinks() { return backLinks; } - public void setBackLinks(Map backLinks) { - this.backLinks = backLinks; - } - - public void setFields(List data) { - this.fields = data; - } - public List getFields() { return fields; } @@ -79,42 +73,22 @@ public boolean getIsIncludeLogs() { return isIncludeLogs; } - public void setIsIncludeLogs(boolean isIncludeLogs) { - this.isIncludeLogs = isIncludeLogs; - } - public boolean getIsIncludeScreenshots() { return isIncludeScreenshots; } - public void setIsIncludeScreenshots(boolean isIncludeScreenshots) { - this.isIncludeScreenshots = isIncludeScreenshots; - } - public boolean getIsIncludeComments() { return isIncludeComments; } - public void setIsIncludeComments(boolean value) { - this.isIncludeComments = value; - } - public int getNumberOfLogs() { return numberOfLogs; } - public void setNumberOfLogs(int numberOfLogs) { - this.numberOfLogs = numberOfLogs; - } - public Long getTestItemId() { return testItemId; } - public void setTestItemId(Long testItemId) { - this.testItemId = testItemId; - } - @Override public String toString() { return "PostTicketRQ [fields=" + fields + ", isIncludeLogs=" + isIncludeLogs @@ -123,4 +97,4 @@ public String toString() { + ", testItemId=" + testItemId + ", backLinks=" + backLinks + "]"; } -} \ No newline at end of file +} diff --git a/src/main/java/com/epam/reportportal/model/integration/auth/AbstractAuthResource.java b/src/main/java/com/epam/reportportal/model/integration/auth/AbstractAuthResource.java index 3e3c8dc..22faf48 100644 --- a/src/main/java/com/epam/reportportal/model/integration/auth/AbstractAuthResource.java +++ b/src/main/java/com/epam/reportportal/model/integration/auth/AbstractAuthResource.java @@ -18,20 +18,17 @@ import com.fasterxml.jackson.annotation.JsonInclude; import java.io.Serializable; +import lombok.Getter; +import lombok.Setter; /** * @author Ihar Kahadouski */ +@Setter +@Getter @JsonInclude(JsonInclude.Include.NON_NULL) public class AbstractAuthResource implements Serializable { private String type; - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } } diff --git a/src/main/java/com/epam/reportportal/model/integration/auth/AbstractLdapResource.java b/src/main/java/com/epam/reportportal/model/integration/auth/AbstractLdapResource.java index c3ebe16..eef03fe 100644 --- a/src/main/java/com/epam/reportportal/model/integration/auth/AbstractLdapResource.java +++ b/src/main/java/com/epam/reportportal/model/integration/auth/AbstractLdapResource.java @@ -18,11 +18,15 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import javax.validation.Valid; +import jakarta.validation.Valid; +import lombok.Getter; +import lombok.Setter; /** * @author Ivan Budayeu */ +@Setter +@Getter @JsonInclude(JsonInclude.Include.NON_NULL) public abstract class AbstractLdapResource extends AbstractAuthResource { @@ -33,22 +37,6 @@ public abstract class AbstractLdapResource extends AbstractAuthResource { @JsonProperty(value = "ldapAttributes") private LdapAttributes ldapAttributes; - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public LdapAttributes getLdapAttributes() { - return ldapAttributes; - } - - public void setLdapAttributes(LdapAttributes ldapAttributes) { - this.ldapAttributes = ldapAttributes; - } - @Override public String toString() { return "AbstractLdapResource{" + "id=" + id + ", ldapAttributes=" + ldapAttributes + '}'; diff --git a/src/main/java/com/epam/reportportal/model/integration/auth/ActiveDirectoryResource.java b/src/main/java/com/epam/reportportal/model/integration/auth/ActiveDirectoryResource.java index ddf89f4..cada5c0 100644 --- a/src/main/java/com/epam/reportportal/model/integration/auth/ActiveDirectoryResource.java +++ b/src/main/java/com/epam/reportportal/model/integration/auth/ActiveDirectoryResource.java @@ -18,10 +18,14 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Getter; +import lombok.Setter; /** * @author Ivan Budayeu */ +@Setter +@Getter @JsonInclude(JsonInclude.Include.NON_NULL) public class ActiveDirectoryResource extends AbstractLdapResource { @@ -31,22 +35,6 @@ public class ActiveDirectoryResource extends AbstractLdapResource { @JsonProperty(value = "searchFilter") private String searchFilter; - public String getDomain() { - return domain; - } - - public void setDomain(String domain) { - this.domain = domain; - } - - public String getSearchFilter() { - return searchFilter; - } - - public void setSearchFilter(String searchFilter) { - this.searchFilter = searchFilter; - } - @Override public String toString() { return "ActiveDirectoryResource{" + "domain='" + domain + '\'' + ", searchFilter='" diff --git a/src/main/java/com/epam/reportportal/model/integration/auth/LdapAttributes.java b/src/main/java/com/epam/reportportal/model/integration/auth/LdapAttributes.java index 6a2a838..dcf3658 100644 --- a/src/main/java/com/epam/reportportal/model/integration/auth/LdapAttributes.java +++ b/src/main/java/com/epam/reportportal/model/integration/auth/LdapAttributes.java @@ -18,15 +18,19 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Pattern; import java.io.Serializable; -import javax.validation.Valid; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Pattern; +import lombok.Getter; +import lombok.Setter; /** * @author Ivan Budayeu */ +@Setter +@Getter @JsonInclude(JsonInclude.Include.NON_NULL) public class LdapAttributes implements Serializable { @@ -48,43 +52,10 @@ public class LdapAttributes implements Serializable { @JsonProperty("synchronizationAttributes") private SynchronizationAttributesResource synchronizationAttributes; - public Boolean getEnabled() { - return enabled; - } - - public void setEnabled(Boolean enabled) { - this.enabled = enabled; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public String getBaseDn() { - return baseDn; - } - - public void setBaseDn(String baseDn) { - this.baseDn = baseDn; - } - - public SynchronizationAttributesResource getSynchronizationAttributes() { - return synchronizationAttributes; - } - - public void setSynchronizationAttributes( - SynchronizationAttributesResource synchronizationAttributes) { - this.synchronizationAttributes = synchronizationAttributes; - } - @Override public String toString() { return "LdapAttributes{" + "enabled=" + enabled + ", url='" + url + '\'' + ", baseDn='" + baseDn + '\'' + ", synchronizationAttributes=" + synchronizationAttributes + '}'; } -} \ No newline at end of file +} diff --git a/src/main/java/com/epam/reportportal/model/integration/auth/LdapResource.java b/src/main/java/com/epam/reportportal/model/integration/auth/LdapResource.java index 0b02afe..cf327dd 100644 --- a/src/main/java/com/epam/reportportal/model/integration/auth/LdapResource.java +++ b/src/main/java/com/epam/reportportal/model/integration/auth/LdapResource.java @@ -18,10 +18,14 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Getter; +import lombok.Setter; /** * @author Ivan Budayeu */ +@Setter +@Getter @JsonInclude(JsonInclude.Include.NON_NULL) public class LdapResource extends AbstractLdapResource { @@ -46,62 +50,6 @@ public class LdapResource extends AbstractLdapResource { @JsonProperty(value = "managerDn") private String managerDn; - public String getUserDnPattern() { - return userDnPattern; - } - - public void setUserDnPattern(String userDnPattern) { - this.userDnPattern = userDnPattern; - } - - public String getUserSearchFilter() { - return userSearchFilter; - } - - public void setUserSearchFilter(String userSearchFilter) { - this.userSearchFilter = userSearchFilter; - } - - public String getGroupSearchBase() { - return groupSearchBase; - } - - public void setGroupSearchBase(String groupSearchBase) { - this.groupSearchBase = groupSearchBase; - } - - public String getGroupSearchFilter() { - return groupSearchFilter; - } - - public void setGroupSearchFilter(String groupSearchFilter) { - this.groupSearchFilter = groupSearchFilter; - } - - public String getPasswordEncoderType() { - return passwordEncoderType; - } - - public void setPasswordEncoderType(String passwordEncoderType) { - this.passwordEncoderType = passwordEncoderType; - } - - public String getPasswordAttribute() { - return passwordAttribute; - } - - public void setPasswordAttribute(String passwordAttribute) { - this.passwordAttribute = passwordAttribute; - } - - public String getManagerDn() { - return managerDn; - } - - public void setManagerDn(String managerDn) { - this.managerDn = managerDn; - } - @Override public String toString() { return "LdapResource{" + "userDnPattern='" + userDnPattern + '\'' + ", userSearchFilter='" diff --git a/src/main/java/com/epam/reportportal/model/integration/auth/SamlProvidersResource.java b/src/main/java/com/epam/reportportal/model/integration/auth/SamlProvidersResource.java index 2f21d3b..cd02bf0 100644 --- a/src/main/java/com/epam/reportportal/model/integration/auth/SamlProvidersResource.java +++ b/src/main/java/com/epam/reportportal/model/integration/auth/SamlProvidersResource.java @@ -17,23 +17,20 @@ package com.epam.reportportal.model.integration.auth; import com.fasterxml.jackson.annotation.JsonInclude; +import jakarta.validation.Valid; import java.util.List; -import javax.validation.Valid; +import lombok.Getter; +import lombok.Setter; /** * @author Ihar Kahadouski */ +@Setter +@Getter @JsonInclude(JsonInclude.Include.NON_NULL) public class SamlProvidersResource extends AbstractAuthResource { @Valid private List providers; - public List getProviders() { - return providers; - } - - public void setProviders(List providers) { - this.providers = providers; - } } diff --git a/src/main/java/com/epam/reportportal/model/integration/auth/SamlResource.java b/src/main/java/com/epam/reportportal/model/integration/auth/SamlResource.java index ccdd334..b8c9f92 100644 --- a/src/main/java/com/epam/reportportal/model/integration/auth/SamlResource.java +++ b/src/main/java/com/epam/reportportal/model/integration/auth/SamlResource.java @@ -19,12 +19,16 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotEmpty; +import lombok.Getter; +import lombok.Setter; /** * @author Ihar Kahadouski */ +@Setter +@Getter @Schema @JsonInclude(JsonInclude.Include.NON_NULL) public class SamlResource extends AbstractAuthResource { @@ -78,99 +82,4 @@ public class SamlResource extends AbstractAuthResource { */ private boolean enabled; - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getCallbackUrl() { - return callbackUrl; - } - - public void setCallbackUrl(String callbackUrl) { - this.callbackUrl = callbackUrl; - } - - public String getIdentityProviderName() { - return identityProviderName; - } - - public void setIdentityProviderName(String identityProviderName) { - this.identityProviderName = identityProviderName; - } - - public String getIdentityProviderAlias() { - return identityProviderAlias; - } - - public void setIdentityProviderAlias(String identityProviderAlias) { - this.identityProviderAlias = identityProviderAlias; - } - - public String getIdentityProviderMetadataUrl() { - return identityProviderMetadataUrl; - } - - public void setIdentityProviderMetadataUrl(String identityProviderMetadataUrl) { - this.identityProviderMetadataUrl = identityProviderMetadataUrl; - } - - public String getIdentityProviderNameId() { - return identityProviderNameId; - } - - public void setIdentityProviderNameId(String identityProviderNameId) { - this.identityProviderNameId = identityProviderNameId; - } - - public String getIdentityProviderUrl() { - return identityProviderUrl; - } - - public void setIdentityProviderUrl(String identityProviderUrl) { - this.identityProviderUrl = identityProviderUrl; - } - - public String getFullNameAttribute() { - return fullNameAttribute; - } - - public void setFullNameAttribute(String fullNameAttribute) { - this.fullNameAttribute = fullNameAttribute; - } - - public String getFirstNameAttribute() { - return firstNameAttribute; - } - - public void setFirstNameAttribute(String firstNameAttribute) { - this.firstNameAttribute = firstNameAttribute; - } - - public String getLastNameAttribute() { - return lastNameAttribute; - } - - public void setLastNameAttribute(String lastNameAttribute) { - this.lastNameAttribute = lastNameAttribute; - } - - public String getEmailAttribute() { - return emailAttribute; - } - - public void setEmailAttribute(String emailAttribute) { - this.emailAttribute = emailAttribute; - } - - public boolean isEnabled() { - return enabled; - } - - public void setEnabled(boolean enabled) { - this.enabled = enabled; - } -} \ No newline at end of file +} diff --git a/src/main/java/com/epam/reportportal/model/integration/auth/SynchronizationAttributesResource.java b/src/main/java/com/epam/reportportal/model/integration/auth/SynchronizationAttributesResource.java index 1e66e93..52f167f 100644 --- a/src/main/java/com/epam/reportportal/model/integration/auth/SynchronizationAttributesResource.java +++ b/src/main/java/com/epam/reportportal/model/integration/auth/SynchronizationAttributesResource.java @@ -18,12 +18,16 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import jakarta.validation.constraints.NotBlank; import java.io.Serializable; -import javax.validation.constraints.NotBlank; +import lombok.Getter; +import lombok.Setter; /** * @author Ivan Budayeu */ +@Setter +@Getter @JsonInclude(JsonInclude.Include.NON_NULL) public class SynchronizationAttributesResource implements Serializable { @@ -43,46 +47,6 @@ public class SynchronizationAttributesResource implements Serializable { @JsonProperty(value = "photo") private String photo; - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public String getFullName() { - return fullName; - } - - public void setFullName(String fullName) { - this.fullName = fullName; - } - - public String getPhoto() { - return photo; - } - - public void setPhoto(String photo) { - this.photo = photo; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } - @Override public String toString() { return "SynchronizationAttributesResource{" + diff --git a/src/main/java/com/epam/reportportal/model/integration/auth/UpdateAuthRQ.java b/src/main/java/com/epam/reportportal/model/integration/auth/UpdateAuthRQ.java index 147918a..1840c31 100644 --- a/src/main/java/com/epam/reportportal/model/integration/auth/UpdateAuthRQ.java +++ b/src/main/java/com/epam/reportportal/model/integration/auth/UpdateAuthRQ.java @@ -18,13 +18,17 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; import java.util.Map; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; +import lombok.Getter; +import lombok.Setter; /** * @author Ihar Kahadouski */ +@Setter +@Getter @JsonInclude(JsonInclude.Include.NON_NULL) public class UpdateAuthRQ { @@ -35,22 +39,6 @@ public class UpdateAuthRQ { @JsonProperty("integrationParameters") private Map integrationParams; - public Boolean getEnabled() { - return enabled; - } - - public void setEnabled(Boolean enabled) { - this.enabled = enabled; - } - - public Map getIntegrationParams() { - return integrationParams; - } - - public void setIntegrationParams(Map integrationParams) { - this.integrationParams = integrationParams; - } - @Override public String toString() { return "UpdateAuthRQ{" + "enabled=" + enabled + ", authParams=" + integrationParams + '}'; diff --git a/src/main/java/com/epam/reportportal/model/launch/cluster/ClusterInfoResource.java b/src/main/java/com/epam/reportportal/model/launch/cluster/ClusterInfoResource.java index af7c6ba..9cc6497 100644 --- a/src/main/java/com/epam/reportportal/model/launch/cluster/ClusterInfoResource.java +++ b/src/main/java/com/epam/reportportal/model/launch/cluster/ClusterInfoResource.java @@ -19,11 +19,18 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import java.util.Map; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; /** * @author Ivan Budayeu */ +@Setter +@Getter @JsonInclude(JsonInclude.Include.NON_NULL) +@NoArgsConstructor public class ClusterInfoResource { @JsonProperty(value = "id") @@ -44,9 +51,6 @@ public class ClusterInfoResource { @JsonProperty(value = "matchedTests") private Long matchedTests; - public ClusterInfoResource() { - } - public ClusterInfoResource(Long id, Long index, Long launchId, String message, Long matchedTests) { this.id = id; this.index = index; @@ -55,51 +59,4 @@ public ClusterInfoResource(Long id, Long index, Long launchId, String message, L this.matchedTests = matchedTests; } - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public Long getIndex() { - return index; - } - - public void setIndex(Long index) { - this.index = index; - } - - public Long getLaunchId() { - return launchId; - } - - public void setLaunchId(Long launchId) { - this.launchId = launchId; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - public Map getMetadata() { - return metadata; - } - - public void setMetadata(Map metadata) { - this.metadata = metadata; - } - - public Long getMatchedTests() { - return matchedTests; - } - - public void setMatchedTests(Long matchedTests) { - this.matchedTests = matchedTests; - } } diff --git a/src/main/java/com/epam/reportportal/model/launch/cluster/CreateClustersRQ.java b/src/main/java/com/epam/reportportal/model/launch/cluster/CreateClustersRQ.java index de2e9f2..36c29c7 100644 --- a/src/main/java/com/epam/reportportal/model/launch/cluster/CreateClustersRQ.java +++ b/src/main/java/com/epam/reportportal/model/launch/cluster/CreateClustersRQ.java @@ -18,12 +18,18 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import javax.validation.constraints.NotNull; +import jakarta.validation.constraints.NotNull; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; /** * @author Ivan Budayeu */ +@Setter +@Getter @JsonInclude(JsonInclude.Include.NON_NULL) +@NoArgsConstructor public class CreateClustersRQ { @NotNull @@ -33,22 +39,4 @@ public class CreateClustersRQ { @JsonProperty(value = "removeNumbers") private boolean removeNumbers; - public CreateClustersRQ() { - } - - public Long getLaunchId() { - return launchId; - } - - public void setLaunchId(Long launchId) { - this.launchId = launchId; - } - - public boolean isRemoveNumbers() { - return removeNumbers; - } - - public void setRemoveNumbers(boolean removeNumbers) { - this.removeNumbers = removeNumbers; - } } diff --git a/src/main/java/com/epam/reportportal/model/project/AnalyzerConfig.java b/src/main/java/com/epam/reportportal/model/project/AnalyzerConfig.java index 208d4ed..9b2e8e4 100644 --- a/src/main/java/com/epam/reportportal/model/project/AnalyzerConfig.java +++ b/src/main/java/com/epam/reportportal/model/project/AnalyzerConfig.java @@ -24,13 +24,17 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.Max; -import javax.validation.constraints.Min; +import jakarta.validation.constraints.Max; +import jakarta.validation.constraints.Min; +import lombok.Getter; +import lombok.Setter; /** * @author Pavel Bortnik */ +@Setter +@Getter @JsonInclude(JsonInclude.Include.NON_NULL) @Schema public class AnalyzerConfig { @@ -53,8 +57,6 @@ public class AnalyzerConfig { private Boolean isAutoAnalyzerEnabled; @JsonProperty(value = "analyzerMode") - @In(allowedValues = {"all", "launch_name", "current_launch", "previous_launch", - "current_and_the_same_name"}) @Schema(allowableValues = "ALL, LAUNCH_NAME, CURRENT_LAUNCH, PREVIOUS_LAUNCH, CURRENT_AND_THE_SAME_NAME") private String analyzerMode; @@ -65,59 +67,4 @@ public class AnalyzerConfig { @JsonProperty(value = "allMessagesShouldMatch") private boolean allMessagesShouldMatch; - public boolean isIndexingRunning() { - return indexingRunning; - } - - public void setIndexingRunning(boolean indexingRunning) { - this.indexingRunning = indexingRunning; - } - - public Integer getMinShouldMatch() { - return minShouldMatch; - } - - public void setMinShouldMatch(Integer minShouldMatch) { - this.minShouldMatch = minShouldMatch; - } - - public Integer getSearchLogsMinShouldMatch() { - return searchLogsMinShouldMatch; - } - - public void setSearchLogsMinShouldMatch(Integer searchLogsMinShouldMatch) { - this.searchLogsMinShouldMatch = searchLogsMinShouldMatch; - } - - public Integer getNumberOfLogLines() { - return numberOfLogLines; - } - - public void setNumberOfLogLines(Integer numberOfLogLines) { - this.numberOfLogLines = numberOfLogLines; - } - - public Boolean getIsAutoAnalyzerEnabled() { - return isAutoAnalyzerEnabled; - } - - public void setIsAutoAnalyzerEnabled(Boolean autoAnalyzerEnabled) { - isAutoAnalyzerEnabled = autoAnalyzerEnabled; - } - - public String getAnalyzerMode() { - return analyzerMode; - } - - public void setAnalyzerMode(String analyzerMode) { - this.analyzerMode = analyzerMode; - } - - public boolean isAllMessagesShouldMatch() { - return allMessagesShouldMatch; - } - - public void setAllMessagesShouldMatch(boolean allMessagesShouldMatch) { - this.allMessagesShouldMatch = allMessagesShouldMatch; - } } diff --git a/src/main/java/com/epam/reportportal/model/settings/OAuthRegistrationResource.java b/src/main/java/com/epam/reportportal/model/settings/OAuthRegistrationResource.java index 1415ccf..8c756de 100644 --- a/src/main/java/com/epam/reportportal/model/settings/OAuthRegistrationResource.java +++ b/src/main/java/com/epam/reportportal/model/settings/OAuthRegistrationResource.java @@ -19,18 +19,24 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.Pattern; import java.io.Serializable; import java.util.Map; import java.util.Set; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.Pattern; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; /** * Settings for OAuth provider registration. * * @author Anton Machulski */ +@Setter +@Getter @JsonInclude(JsonInclude.Include.NON_NULL) +@EqualsAndHashCode public class OAuthRegistrationResource implements Serializable { public static final String URL_PATTERN = "^(http://|https://)?(www\\.)?([a-zA-Z0-9-]+)(\\.[a-zA-Z0-9-]+)*(:[0-9]+)?(/[a-z_-]+)*$"; @@ -83,197 +89,4 @@ public class OAuthRegistrationResource implements Serializable { @JsonProperty(value = "restrictions") private Map restrictions; - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getClientId() { - return clientId; - } - - public void setClientId(String clientId) { - this.clientId = clientId; - } - - public String getClientSecret() { - return clientSecret; - } - - public void setClientSecret(String clientSecret) { - this.clientSecret = clientSecret; - } - - public String getClientAuthMethod() { - return clientAuthMethod; - } - - public void setClientAuthMethod(String clientAuthMethod) { - this.clientAuthMethod = clientAuthMethod; - } - - public String getAuthGrantType() { - return authGrantType; - } - - public void setAuthGrantType(String authGrantType) { - this.authGrantType = authGrantType; - } - - public String getRedirectUrlTemplate() { - return redirectUrlTemplate; - } - - public void setRedirectUrlTemplate(String redirectUrlTemplate) { - this.redirectUrlTemplate = redirectUrlTemplate; - } - - public String getAuthorizationUri() { - return authorizationUri; - } - - public void setAuthorizationUri(String authorizationUri) { - this.authorizationUri = authorizationUri; - } - - public String getTokenUri() { - return tokenUri; - } - - public void setTokenUri(String tokenUri) { - this.tokenUri = tokenUri; - } - - public String getUserInfoEndpointUri() { - return userInfoEndpointUri; - } - - public void setUserInfoEndpointUri(String userInfoEndpointUri) { - this.userInfoEndpointUri = userInfoEndpointUri; - } - - public String getUserInfoEndpointNameAttribute() { - return userInfoEndpointNameAttribute; - } - - public void setUserInfoEndpointNameAttribute(String userInfoEndpointNameAttribute) { - this.userInfoEndpointNameAttribute = userInfoEndpointNameAttribute; - } - - public String getJwkSetUri() { - return jwkSetUri; - } - - public void setJwkSetUri(String jwkSetUri) { - this.jwkSetUri = jwkSetUri; - } - - public String getClientName() { - return clientName; - } - - public void setClientName(String clientName) { - this.clientName = clientName; - } - - public Set getScopes() { - return scopes; - } - - public void setScopes(Set scopes) { - this.scopes = scopes; - } - - public Map getRestrictions() { - return restrictions; - } - - public void setRestrictions(Map restrictions) { - this.restrictions = restrictions; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - - OAuthRegistrationResource that = (OAuthRegistrationResource) o; - - if (id != null ? !id.equals(that.id) : that.id != null) { - return false; - } - if (clientId != null ? !clientId.equals(that.clientId) : that.clientId != null) { - return false; - } - if (clientSecret != null ? !clientSecret.equals(that.clientSecret) - : that.clientSecret != null) { - return false; - } - if (clientAuthMethod != null ? !clientAuthMethod.equals(that.clientAuthMethod) - : that.clientAuthMethod != null) { - return false; - } - if (authGrantType != null ? !authGrantType.equals(that.authGrantType) - : that.authGrantType != null) { - return false; - } - if (redirectUrlTemplate != null ? !redirectUrlTemplate.equals(that.redirectUrlTemplate) - : that.redirectUrlTemplate != null) { - return false; - } - if (authorizationUri != null ? !authorizationUri.equals(that.authorizationUri) - : that.authorizationUri != null) { - return false; - } - if (tokenUri != null ? !tokenUri.equals(that.tokenUri) : that.tokenUri != null) { - return false; - } - if (userInfoEndpointUri != null ? !userInfoEndpointUri.equals(that.userInfoEndpointUri) - : that.userInfoEndpointUri != null) { - return false; - } - if (userInfoEndpointNameAttribute != null ? - !userInfoEndpointNameAttribute.equals(that.userInfoEndpointNameAttribute) : - that.userInfoEndpointNameAttribute != null) { - return false; - } - if (jwkSetUri != null ? !jwkSetUri.equals(that.jwkSetUri) : that.jwkSetUri != null) { - return false; - } - if (clientName != null ? !clientName.equals(that.clientName) : that.clientName != null) { - return false; - } - if (scopes != null ? !scopes.equals(that.scopes) : that.scopes != null) { - return false; - } - return restrictions != null ? restrictions.equals(that.restrictions) - : that.restrictions == null; - } - - @Override - public int hashCode() { - int result = id != null ? id.hashCode() : 0; - result = 31 * result + (clientId != null ? clientId.hashCode() : 0); - result = 31 * result + (clientSecret != null ? clientSecret.hashCode() : 0); - result = 31 * result + (clientAuthMethod != null ? clientAuthMethod.hashCode() : 0); - result = 31 * result + (authGrantType != null ? authGrantType.hashCode() : 0); - result = 31 * result + (redirectUrlTemplate != null ? redirectUrlTemplate.hashCode() : 0); - result = 31 * result + (authorizationUri != null ? authorizationUri.hashCode() : 0); - result = 31 * result + (tokenUri != null ? tokenUri.hashCode() : 0); - result = 31 * result + (userInfoEndpointUri != null ? userInfoEndpointUri.hashCode() : 0); - result = 31 * result + (userInfoEndpointNameAttribute != null - ? userInfoEndpointNameAttribute.hashCode() : 0); - result = 31 * result + (jwkSetUri != null ? jwkSetUri.hashCode() : 0); - result = 31 * result + (clientName != null ? clientName.hashCode() : 0); - result = 31 * result + (scopes != null ? scopes.hashCode() : 0); - result = 31 * result + (restrictions != null ? restrictions.hashCode() : 0); - return result; - } } diff --git a/src/main/java/com/epam/reportportal/model/validation/NotBlankWithSizeValidator.java b/src/main/java/com/epam/reportportal/model/validation/NotBlankWithSizeValidator.java index 7063648..105e975 100644 --- a/src/main/java/com/epam/reportportal/model/validation/NotBlankWithSizeValidator.java +++ b/src/main/java/com/epam/reportportal/model/validation/NotBlankWithSizeValidator.java @@ -17,8 +17,8 @@ package com.epam.reportportal.model.validation; import com.epam.ta.reportportal.ws.annotations.NotBlankWithSize; -import javax.validation.ConstraintValidator; -import javax.validation.ConstraintValidatorContext; +import jakarta.validation.ConstraintValidator; +import jakarta.validation.ConstraintValidatorContext; import org.apache.commons.lang3.StringUtils; /** diff --git a/src/main/java/com/epam/reportportal/rules/commons/exception/forwarding/ClientResponseForwardingExceptionHandler.java b/src/main/java/com/epam/reportportal/rules/commons/exception/forwarding/ClientResponseForwardingExceptionHandler.java index e995f79..a7aa311 100644 --- a/src/main/java/com/epam/reportportal/rules/commons/exception/forwarding/ClientResponseForwardingExceptionHandler.java +++ b/src/main/java/com/epam/reportportal/rules/commons/exception/forwarding/ClientResponseForwardingExceptionHandler.java @@ -16,10 +16,11 @@ package com.epam.reportportal.rules.commons.exception.forwarding; import com.google.common.io.ByteStreams; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import java.io.ByteArrayInputStream; import java.io.IOException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +import lombok.Setter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.core.Ordered; @@ -32,6 +33,7 @@ * * @author Andrei Varabyeu */ +@Setter public class ClientResponseForwardingExceptionHandler implements HandlerExceptionResolver, Ordered { private static final Logger LOGGER = LoggerFactory.getLogger( @@ -76,7 +78,4 @@ public int getOrder() { return order; } - public void setOrder(int order) { - this.order = order; - } -} \ No newline at end of file +} diff --git a/src/main/java/com/epam/reportportal/rules/commons/exception/forwarding/ResponseForwardingException.java b/src/main/java/com/epam/reportportal/rules/commons/exception/forwarding/ResponseForwardingException.java index f84ca6f..ea81e92 100644 --- a/src/main/java/com/epam/reportportal/rules/commons/exception/forwarding/ResponseForwardingException.java +++ b/src/main/java/com/epam/reportportal/rules/commons/exception/forwarding/ResponseForwardingException.java @@ -33,6 +33,7 @@ import com.google.common.io.ByteStreams; import java.io.IOException; +import lombok.Getter; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.client.ClientHttpResponse; @@ -42,6 +43,7 @@ * * @author Andrei Varabyeu */ +@Getter public class ResponseForwardingException extends RuntimeException { private final byte[] body; @@ -50,19 +52,8 @@ public class ResponseForwardingException extends RuntimeException { public ResponseForwardingException(ClientHttpResponse response) throws IOException { this.headers = response.getHeaders(); - this.status = response.getStatusCode(); + this.status = HttpStatus.valueOf(response.getStatusCode().value()); this.body = ByteStreams.toByteArray(response.getBody()); } - public byte[] getBody() { - return body; - } - - public HttpHeaders getHeaders() { - return headers; - } - - public HttpStatus getStatus() { - return status; - } -} \ No newline at end of file +} diff --git a/src/main/java/com/epam/reportportal/rules/commons/exception/message/ArgumentNotValidMessageBuilder.java b/src/main/java/com/epam/reportportal/rules/commons/exception/message/ArgumentNotValidMessageBuilder.java index 7fccf54..864e256 100644 --- a/src/main/java/com/epam/reportportal/rules/commons/exception/message/ArgumentNotValidMessageBuilder.java +++ b/src/main/java/com/epam/reportportal/rules/commons/exception/message/ArgumentNotValidMessageBuilder.java @@ -16,6 +16,8 @@ package com.epam.reportportal.rules.commons.exception.message; +import lombok.Getter; +import lombok.Setter; import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.context.support.ReloadableResourceBundleMessageSource; import org.springframework.validation.ObjectError; @@ -26,6 +28,8 @@ * * @author Andrei Varabyeu */ +@Setter +@Getter public class ArgumentNotValidMessageBuilder implements ExceptionMessageBuilder { @@ -48,13 +52,5 @@ public String buildMessage(MethodArgumentNotValidException e) { return sb.toString(); } - public ReloadableResourceBundleMessageSource getMessageSource() { - return messageSource; - } - - public void setMessageSource(ReloadableResourceBundleMessageSource messageSource) { - this.messageSource = messageSource; - } - -} \ No newline at end of file +} diff --git a/src/main/java/com/epam/reportportal/rules/commons/exception/message/ExceptionMessageBuilder.java b/src/main/java/com/epam/reportportal/rules/commons/exception/message/ExceptionMessageBuilder.java index 7faf5eb..f947152 100644 --- a/src/main/java/com/epam/reportportal/rules/commons/exception/message/ExceptionMessageBuilder.java +++ b/src/main/java/com/epam/reportportal/rules/commons/exception/message/ExceptionMessageBuilder.java @@ -18,7 +18,7 @@ /** * Builds custom exception strings from Exception. Lots of exceptions have custom data which should - * be showed to clients in custom way + * be shown to the clients in custom way * * @author Andrei Varabyeu */ diff --git a/src/main/java/com/epam/reportportal/rules/commons/exception/rest/ReportPortalExceptionResolver.java b/src/main/java/com/epam/reportportal/rules/commons/exception/rest/ReportPortalExceptionResolver.java index 4f9883f..84e5b3f 100644 --- a/src/main/java/com/epam/reportportal/rules/commons/exception/rest/ReportPortalExceptionResolver.java +++ b/src/main/java/com/epam/reportportal/rules/commons/exception/rest/ReportPortalExceptionResolver.java @@ -39,7 +39,7 @@ public ReportPortalExceptionResolver(ErrorResolver defaultErrorResolver) { @Override public RestError resolveError(Exception ex) { - LOGGER.error("ReportPortalExceptionResolver > " + ex.getMessage(), ex); + LOGGER.error("ReportPortalExceptionResolver > {}", ex.getMessage(), ex); if (ReportPortalException.class.isAssignableFrom(ex.getClass())) { ReportPortalException currentException = (ReportPortalException) ex; @@ -55,4 +55,4 @@ public RestError resolveError(Exception ex) { return defaultErrorResolver.resolveError(ex); } } -} \ No newline at end of file +} diff --git a/src/main/java/com/epam/reportportal/rules/commons/exception/rest/RestError.java b/src/main/java/com/epam/reportportal/rules/commons/exception/rest/RestError.java index fa3f09b..263acce 100644 --- a/src/main/java/com/epam/reportportal/rules/commons/exception/rest/RestError.java +++ b/src/main/java/com/epam/reportportal/rules/commons/exception/rest/RestError.java @@ -23,29 +23,10 @@ /** * Rest Error representation. Contains rest error template and real exception data * + * @param httpStatus HTTP Status * @author Andrei Varabyeu */ -public class RestError { - - private final ErrorRS errorRS; - - /** - * HTTP Status - */ - private final HttpStatus httpStatus; - - public RestError(HttpStatus httpStatus, ErrorRS errorRS) { - this.httpStatus = httpStatus; - this.errorRS = errorRS; - } - - public ErrorRS getErrorRS() { - return errorRS; - } - - public HttpStatus getHttpStatus() { - return httpStatus; - } +public record RestError(HttpStatus httpStatus, ErrorRS errorRS) { /** * Builder for Rest Error @@ -88,4 +69,4 @@ public RestError build() { return new RestError(status, errorRS); } } -} \ No newline at end of file +} diff --git a/src/main/java/com/epam/reportportal/rules/commons/exception/rest/RestErrorDefinition.java b/src/main/java/com/epam/reportportal/rules/commons/exception/rest/RestErrorDefinition.java index 244a769..8670886 100644 --- a/src/main/java/com/epam/reportportal/rules/commons/exception/rest/RestErrorDefinition.java +++ b/src/main/java/com/epam/reportportal/rules/commons/exception/rest/RestErrorDefinition.java @@ -18,6 +18,7 @@ import com.epam.reportportal.rules.commons.exception.message.ExceptionMessageBuilder; import com.epam.reportportal.rules.exception.ErrorType; +import lombok.Getter; import org.springframework.http.HttpStatus; /** @@ -27,7 +28,9 @@ */ public class RestErrorDefinition { + @Getter private final HttpStatus httpStatus; + @Getter private final ErrorType error; private final ExceptionMessageBuilder exceptionMessageBuilder; @@ -44,14 +47,6 @@ public RestErrorDefinition(int httpStatus, ErrorType error, this(HttpStatus.valueOf(httpStatus), error, exceptionMessageBuilder); } - public HttpStatus getHttpStatus() { - return httpStatus; - } - - public ErrorType getError() { - return error; - } - public String getExceptionMessage(T e) { return exceptionMessageBuilder.buildMessage(e); } @@ -59,4 +54,4 @@ public String getExceptionMessage(T e) { public ExceptionMessageBuilder getExceptionMessageBuilder() { return exceptionMessageBuilder; } -} \ No newline at end of file +} diff --git a/src/main/java/com/epam/reportportal/rules/commons/exception/rest/RestExceptionHandler.java b/src/main/java/com/epam/reportportal/rules/commons/exception/rest/RestExceptionHandler.java index 6c78a7e..085c6fd 100644 --- a/src/main/java/com/epam/reportportal/rules/commons/exception/rest/RestExceptionHandler.java +++ b/src/main/java/com/epam/reportportal/rules/commons/exception/rest/RestExceptionHandler.java @@ -16,11 +16,11 @@ package com.epam.reportportal.rules.commons.exception.rest; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.Collections; import java.util.List; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; import org.slf4j.LoggerFactory; import org.springframework.http.HttpInputMessage; import org.springframework.http.HttpOutputMessage; @@ -93,10 +93,10 @@ protected ModelAndView handleCustomException(HttpServletRequest request, if (error == null) { return null; } - applyStatusIfPossible(webRequest, error.getHttpStatus()); + applyStatusIfPossible(webRequest, error.httpStatus()); try { - return handleResponseBody(error.getErrorRS(), webRequest); + return handleResponseBody(error.errorRS(), webRequest); } catch (IOException e) { if (logger.isWarnEnabled()) { logger.warn("Unable to write error message", e); @@ -182,4 +182,4 @@ protected ModelAndView handleMissingServletRequestParameter( HttpServletResponse response, Object handler) throws IOException { return handleCustomException(request, response, ex); } -} \ No newline at end of file +} diff --git a/src/main/java/com/epam/reportportal/rules/commons/validation/BusinessRule.java b/src/main/java/com/epam/reportportal/rules/commons/validation/BusinessRule.java index 29997c8..6c32a0d 100644 --- a/src/main/java/com/epam/reportportal/rules/commons/validation/BusinessRule.java +++ b/src/main/java/com/epam/reportportal/rules/commons/validation/BusinessRule.java @@ -28,7 +28,7 @@ public class BusinessRule { private BusinessRule() { - //should be create by factory-methods only + //should be created by factory-methods only } /** diff --git a/src/main/java/com/epam/reportportal/rules/exception/ErrorRS.java b/src/main/java/com/epam/reportportal/rules/exception/ErrorRS.java index c38011e..87eb56a 100644 --- a/src/main/java/com/epam/reportportal/rules/exception/ErrorRS.java +++ b/src/main/java/com/epam/reportportal/rules/exception/ErrorRS.java @@ -32,6 +32,9 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize; import java.io.IOException; import java.io.Serializable; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; /** * Base Error response body for all Report Portal exceptions @@ -39,8 +42,11 @@ * @author Andrei Varabyeu * */ +@Setter +@Getter @JsonPropertyOrder({ "errorCode", "message", "stackTrace" }) @JsonInclude(Include.NON_NULL) +@EqualsAndHashCode public class ErrorRS implements Serializable { /** * Generated SVUID @@ -58,61 +64,6 @@ public class ErrorRS implements Serializable { @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 { @@ -142,4 +93,4 @@ public String toString() { + ", message='" + message + '\'' + '}'; } -} \ No newline at end of file +} diff --git a/src/main/java/com/epam/reportportal/rules/exception/ErrorType.java b/src/main/java/com/epam/reportportal/rules/exception/ErrorType.java index f7169c4..f8ee3ca 100644 --- a/src/main/java/com/epam/reportportal/rules/exception/ErrorType.java +++ b/src/main/java/com/epam/reportportal/rules/exception/ErrorType.java @@ -16,11 +16,14 @@ package com.epam.reportportal.rules.exception; +import lombok.Getter; + /** * Report Portal's exception list * * @author Andrei Varabyeu */ +@Getter public enum ErrorType { /** @@ -506,14 +509,6 @@ public enum ErrorType { this.description = description; } - public int getCode() { - return code; - } - - public String getDescription() { - return description; - } - /** * Get instance by code * diff --git a/src/test/java/com/epam/reportportal/annotations/NotBlankStringCollectionValidatorTest.java b/src/test/java/com/epam/reportportal/annotations/NotBlankStringCollectionValidatorTest.java index f7ac6fb..a8f89bb 100644 --- a/src/test/java/com/epam/reportportal/annotations/NotBlankStringCollectionValidatorTest.java +++ b/src/test/java/com/epam/reportportal/annotations/NotBlankStringCollectionValidatorTest.java @@ -16,17 +16,19 @@ package com.epam.reportportal.annotations; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.ArrayList; import java.util.List; import java.util.Set; -import javax.validation.ConstraintViolation; -import javax.validation.Validation; -import javax.validation.Validator; -import javax.validation.ValidatorFactory; -import org.junit.Test; +import jakarta.validation.ConstraintViolation; +import jakarta.validation.Validation; +import jakarta.validation.Validator; +import jakarta.validation.ValidatorFactory; +import lombok.Getter; +import lombok.Setter; +import org.junit.jupiter.api.Test; /** * @author Ihar Kahadouski @@ -123,17 +125,12 @@ public void testEmptyCollection() { assertFalse(found); } + @Setter + @Getter private static class TestEntity { @NotBlankStringCollection private List collection; - public List getCollection() { - return collection; - } - - public void setCollection(List collection) { - this.collection = collection; - } } -} \ No newline at end of file +} diff --git a/src/test/java/com/epam/reportportal/annotations/NotBlankStringValidatorTest.java b/src/test/java/com/epam/reportportal/annotations/NotBlankStringValidatorTest.java index 0951d07..52315f5 100644 --- a/src/test/java/com/epam/reportportal/annotations/NotBlankStringValidatorTest.java +++ b/src/test/java/com/epam/reportportal/annotations/NotBlankStringValidatorTest.java @@ -16,15 +16,17 @@ package com.epam.reportportal.annotations; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.Set; -import javax.validation.ConstraintViolation; -import javax.validation.Validation; -import javax.validation.Validator; -import org.junit.BeforeClass; -import org.junit.Test; +import jakarta.validation.ConstraintViolation; +import jakarta.validation.Validation; +import jakarta.validation.Validator; +import lombok.Getter; +import lombok.Setter; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /** * @author Ihar Kahadouski @@ -33,7 +35,7 @@ public class NotBlankStringValidatorTest { private static Validator validator; - @BeforeClass + @BeforeAll public static void init() { validator = Validation.buildDefaultValidatorFactory().getValidator(); } @@ -57,18 +59,13 @@ public void blankTest() { assertFalse(constraints.isEmpty()); } + @Setter + @Getter private static class TestClass { @NotBlankString private String value; - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } } -} \ No newline at end of file +} diff --git a/src/test/java/com/epam/reportportal/annotations/NotNullMapValueValidatorTest.java b/src/test/java/com/epam/reportportal/annotations/NotNullMapValueValidatorTest.java index a50a60c..df2f4b7 100644 --- a/src/test/java/com/epam/reportportal/annotations/NotNullMapValueValidatorTest.java +++ b/src/test/java/com/epam/reportportal/annotations/NotNullMapValueValidatorTest.java @@ -16,23 +16,25 @@ package com.epam.reportportal.annotations; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.HashMap; import java.util.Map; import java.util.Set; -import javax.validation.ConstraintViolation; -import javax.validation.Validation; -import javax.validation.Validator; -import org.junit.BeforeClass; -import org.junit.Test; +import jakarta.validation.ConstraintViolation; +import jakarta.validation.Validation; +import jakarta.validation.Validator; +import lombok.Getter; +import lombok.Setter; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; public class NotNullMapValueValidatorTest { private static Validator validator; - @BeforeClass + @BeforeAll public static void init() { validator = Validation.buildDefaultValidatorFactory().getValidator(); } @@ -58,17 +60,12 @@ public void nullValueTest() { assertFalse(constraints.isEmpty()); } + @Setter + @Getter private static class TestClass { @NotNullMapValue private Map map; - public Map getMap() { - return map; - } - - public void setMap(Map map) { - this.map = map; - } } -} \ No newline at end of file +} diff --git a/src/test/java/com/epam/reportportal/commons/SafeTest.java b/src/test/java/com/epam/reportportal/commons/SafeTest.java index f575f5d..bfca0eb 100644 --- a/src/test/java/com/epam/reportportal/commons/SafeTest.java +++ b/src/test/java/com/epam/reportportal/commons/SafeTest.java @@ -21,10 +21,13 @@ package com.epam.reportportal.commons; import static com.epam.reportportal.commons.Safe.safe; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import java.util.concurrent.atomic.AtomicBoolean; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; + /** * Tests for {@link Safe} @@ -37,7 +40,7 @@ public class SafeTest { public void testHappy() { AtomicBoolean result = new AtomicBoolean(false); safe(() -> result.set(true)); - Assert.assertTrue("Action is not executed", result.get()); + assertTrue(result.get(), "Action is not executed"); } @Test @@ -56,7 +59,7 @@ public void testWithCallback() { throw new Exception("hello"); }, e -> result.set(true)); - Assert.assertTrue("Callback is not executed", result.get()); + assertTrue(result.get(), "Callback is not executed"); } @@ -71,13 +74,13 @@ public void testWithCallbackAndError() { throw new RuntimeException("wraps error", e); }); } catch (RuntimeException e) { - Assert.assertEquals("Incorrect message", "wraps error", e.getMessage()); + assertEquals("wraps error", e.getMessage(), "Incorrect message"); return; } - Assert.fail("Exception hasn't been thrown"); + fail("Exception hasn't been thrown"); - Assert.assertTrue("Callback is not executed", result.get()); + assertTrue(result.get(), "Callback is not executed"); } -} \ No newline at end of file +} diff --git a/src/test/java/com/epam/reportportal/commons/ThumbnailatorImplTest.java b/src/test/java/com/epam/reportportal/commons/ThumbnailatorImplTest.java index 6979407..2e8cfac 100644 --- a/src/test/java/com/epam/reportportal/commons/ThumbnailatorImplTest.java +++ b/src/test/java/com/epam/reportportal/commons/ThumbnailatorImplTest.java @@ -21,12 +21,13 @@ package com.epam.reportportal.commons; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.awt.image.BufferedImage; import java.io.IOException; import java.io.InputStream; import javax.imageio.ImageIO; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Set of tests for Thumbnailator @@ -54,8 +55,8 @@ public void checkThumbnailator() throws IOException { BufferedImage image = ImageIO.read(is); - Assert.assertEquals("Incorrect image height", THUMBNAIL_HEIGHT, image.getHeight()); - Assert.assertEquals("Incorrect image width", THUMBNAIL_WIDTH, image.getWidth()); + assertEquals(THUMBNAIL_HEIGHT, image.getHeight(), "Incorrect image height"); + assertEquals(THUMBNAIL_WIDTH, image.getWidth(), "Incorrect image width"); } -} \ No newline at end of file +} diff --git a/src/test/java/com/epam/reportportal/commons/template/TemplateEngineProviderTest.java b/src/test/java/com/epam/reportportal/commons/template/TemplateEngineProviderTest.java index 627d628..e497ac4 100644 --- a/src/test/java/com/epam/reportportal/commons/template/TemplateEngineProviderTest.java +++ b/src/test/java/com/epam/reportportal/commons/template/TemplateEngineProviderTest.java @@ -1,9 +1,10 @@ package com.epam.reportportal.commons.template; +import static org.hamcrest.MatcherAssert.assertThat; + import com.google.common.collect.ImmutableMap; import org.hamcrest.CoreMatchers; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * @author Andrei Varabyeu @@ -14,6 +15,6 @@ public class TemplateEngineProviderTest { public void testProvider() { final String res = new TemplateEngineProvider().get() .merge("template.ftl", ImmutableMap.builder().put("var", "hello world").build()); - Assert.assertThat(res, CoreMatchers.is("hello world")); + assertThat(res, CoreMatchers.is("hello world")); } } diff --git a/src/test/java/com/epam/reportportal/commons/template/TemplateEngineTest.java b/src/test/java/com/epam/reportportal/commons/template/TemplateEngineTest.java index e9bb331..bb3d23e 100644 --- a/src/test/java/com/epam/reportportal/commons/template/TemplateEngineTest.java +++ b/src/test/java/com/epam/reportportal/commons/template/TemplateEngineTest.java @@ -20,14 +20,15 @@ */ package com.epam.reportportal.commons.template; +import static org.hamcrest.MatcherAssert.assertThat; + import freemarker.template.Configuration; import freemarker.template.TemplateExceptionHandler; import freemarker.template.Version; import java.util.Collections; import java.util.Locale; import org.hamcrest.CoreMatchers; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * @author Andrei Varabyeu @@ -52,7 +53,7 @@ public void merge() throws Exception { String result = new FreemarkerTemplateEngine(cfg).merge("template.ftl", Collections.singletonMap("var", "hello world")); - Assert.assertThat(result, CoreMatchers.is("hello world")); + assertThat(result, CoreMatchers.is("hello world")); } -} \ No newline at end of file +} diff --git a/src/test/java/com/epam/reportportal/model/settings/OAuthRegistrationResourceTest.java b/src/test/java/com/epam/reportportal/model/settings/OAuthRegistrationResourceTest.java index 23740d8..06230dc 100644 --- a/src/test/java/com/epam/reportportal/model/settings/OAuthRegistrationResourceTest.java +++ b/src/test/java/com/epam/reportportal/model/settings/OAuthRegistrationResourceTest.java @@ -16,12 +16,14 @@ package com.epam.reportportal.model.settings; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.ArrayList; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * @author Ivan Budayeu @@ -65,7 +67,7 @@ public void regexTestPositive() { for (String url : correctUrls) { Matcher matcher = pattern.matcher(url); - Assert.assertTrue(matcher.matches()); + assertTrue(matcher.matches()); } } @@ -75,8 +77,8 @@ public void regexTestNegative() { for (String url : wrongUrls) { Matcher matcher = pattern.matcher(url); - Assert.assertFalse(matcher.matches()); + assertFalse(matcher.matches()); } } -} \ No newline at end of file +} diff --git a/src/test/java/com/epam/reportportal/model/user/EditUserRqValidationTest.java b/src/test/java/com/epam/reportportal/model/user/EditUserRqValidationTest.java index 6c9e4fc..4700dc4 100644 --- a/src/test/java/com/epam/reportportal/model/user/EditUserRqValidationTest.java +++ b/src/test/java/com/epam/reportportal/model/user/EditUserRqValidationTest.java @@ -16,13 +16,15 @@ package com.epam.reportportal.model.user; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.ArrayList; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * @author Ivan Budayeu @@ -35,9 +37,9 @@ public class EditUserRqValidationTest { private List correctNames; private List incorrectNames; - @Before + @BeforeEach public void setUp() { - correctNames = new ArrayList() { + correctNames = new ArrayList<>() { { add("J J"); add("J"); @@ -47,7 +49,7 @@ public void setUp() { } }; - incorrectNames = new ArrayList() { + incorrectNames = new ArrayList<>() { { add(" "); add(""); @@ -62,12 +64,12 @@ public void setUp() { public void validateFullName() { for (String name : correctNames) { Matcher matcher = pattern.matcher(name); - Assert.assertTrue(matcher.matches()); + assertTrue(matcher.matches()); } for (String name : incorrectNames) { Matcher matcher = pattern.matcher(name); - Assert.assertFalse(matcher.matches()); + assertFalse(matcher.matches()); } } } diff --git a/src/test/java/com/epam/reportportal/rules/ErrorSerializationTest.java b/src/test/java/com/epam/reportportal/rules/ErrorSerializationTest.java index d95259e..608bac0 100644 --- a/src/test/java/com/epam/reportportal/rules/ErrorSerializationTest.java +++ b/src/test/java/com/epam/reportportal/rules/ErrorSerializationTest.java @@ -12,55 +12,54 @@ * 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.rules; +import static org.junit.jupiter.api.Assertions.assertEquals; + import com.epam.reportportal.rules.exception.ErrorRS; import com.epam.reportportal.rules.exception.ErrorType; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; -import org.junit.Assert; -import org.junit.Test; - import java.io.IOException; +import org.junit.jupiter.api.Test; /** * Serializer/Deserializer unit tests - * + * * @author Andrei Varabyeu - * */ public class ErrorSerializationTest { - private static final String SERIALIZATION_RESULT = "{\"errorCode\":5000,\"message\":\"MESSAGE\",\"stackTrace\":\"STACK_TRACE\"}"; + private static final String SERIALIZATION_RESULT = "{\"errorCode\":5000,\"message\":\"MESSAGE\",\"stackTrace\":\"STACK_TRACE\"}"; - private ObjectMapper om = getObjectMapper(); + private final ObjectMapper om = getObjectMapper(); - @Test - public void testSerializer() throws JsonProcessingException { - String json = om.writeValueAsString(getErrorResponse()); - Assert.assertEquals(SERIALIZATION_RESULT, json); - } + @Test + public void testSerializer() throws JsonProcessingException { + String json = om.writeValueAsString(getErrorResponse()); + assertEquals(SERIALIZATION_RESULT, json); + } - @Test - public void testDeserializer() throws IOException { - ErrorRS fromJson = om.readValue(SERIALIZATION_RESULT, ErrorRS.class); - Assert.assertEquals(getErrorResponse(), fromJson); - } + @Test + public void testDeserializer() throws IOException { + ErrorRS fromJson = om.readValue(SERIALIZATION_RESULT, ErrorRS.class); + assertEquals(getErrorResponse(), fromJson); + } - private ErrorRS getErrorResponse() { - ErrorRS error = new ErrorRS(); - error.setMessage("MESSAGE"); - error.setStackTrace("STACK_TRACE"); - error.setErrorType(ErrorType.UNCLASSIFIED_ERROR); - return error; - } + private ErrorRS getErrorResponse() { + ErrorRS error = new ErrorRS(); + error.setMessage("MESSAGE"); + error.setStackTrace("STACK_TRACE"); + error.setErrorType(ErrorType.UNCLASSIFIED_ERROR); + return error; + } - private ObjectMapper getObjectMapper() { - ObjectMapper om = new ObjectMapper(); - om.configure(SerializationFeature.INDENT_OUTPUT, false); - return om; - } -} \ No newline at end of file + private ObjectMapper getObjectMapper() { + ObjectMapper om = new ObjectMapper(); + om.configure(SerializationFeature.INDENT_OUTPUT, false); + return om; + } +} diff --git a/src/test/java/com/epam/reportportal/rules/ErrorTypeTest.java b/src/test/java/com/epam/reportportal/rules/ErrorTypeTest.java index 1149037..27adbf6 100644 --- a/src/test/java/com/epam/reportportal/rules/ErrorTypeTest.java +++ b/src/test/java/com/epam/reportportal/rules/ErrorTypeTest.java @@ -12,28 +12,28 @@ * 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.rules; -import com.epam.reportportal.rules.exception.ErrorType; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import com.epam.reportportal.rules.exception.ErrorType; import java.util.HashSet; import java.util.Set; +import org.junit.jupiter.api.Test; /** * @author Dzmitry_Kavalets */ public class ErrorTypeTest { - @Test - public void duplicateCodes() { - final int length = ErrorType.values().length; - Set codes = new HashSet<>(); - for (ErrorType errorType : ErrorType.values()) { - codes.add(errorType.getCode()); - } - Assert.assertEquals(length, codes.size()); - } -} \ No newline at end of file + @Test + public void duplicateCodes() { + final int length = ErrorType.values().length; + Set codes = new HashSet<>(); + for (ErrorType errorType : ErrorType.values()) { + codes.add(errorType.getCode()); + } + assertEquals(length, codes.size()); + } +} diff --git a/src/test/java/com/epam/reportportal/rules/rest/ExceptionHandlingTest.java b/src/test/java/com/epam/reportportal/rules/rest/ExceptionHandlingTest.java index 4f14889..84db030 100644 --- a/src/test/java/com/epam/reportportal/rules/rest/ExceptionHandlingTest.java +++ b/src/test/java/com/epam/reportportal/rules/rest/ExceptionHandlingTest.java @@ -16,6 +16,9 @@ package com.epam.reportportal.rules.rest; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; + import com.epam.reportportal.rules.commons.ExceptionMappings; import com.epam.reportportal.rules.commons.exception.rest.DefaultErrorResolver; import com.epam.reportportal.rules.commons.exception.rest.ErrorResolver; @@ -23,47 +26,28 @@ import com.epam.reportportal.rules.exception.ErrorType; import com.epam.reportportal.rules.exception.ReportPortalException; import com.google.common.base.Strings; -import java.lang.reflect.InvocationTargetException; import java.util.Arrays; import java.util.List; import org.hamcrest.Matchers; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.springframework.http.HttpStatus; import org.springframework.http.converter.HttpMessageNotReadableException; import org.springframework.web.bind.MissingServletRequestParameterException; + /** * Error Resolver Tests * * @author Andrei Varabyeu */ -@RunWith(Parameterized.class) public class ExceptionHandlingTest { private static final String EXCEPTION_MESSAGE = "Some exception"; - private final ErrorResolver errorResolver = new DefaultErrorResolver(ExceptionMappings.DEFAULT_MAPPING); - - private final Exception exception; - - private final ErrorType errorType; - - private final HttpStatus httpStatus; - - private final String errorMessage; - - public ExceptionHandlingTest(Exception exception, ErrorType errorType, HttpStatus httpStatus, - String errorMessage) { - this.exception = exception; - this.errorType = errorType; - this.httpStatus = httpStatus; - this.errorMessage = errorMessage; - } + private final ErrorResolver errorResolver = new DefaultErrorResolver( + ExceptionMappings.DEFAULT_MAPPING); - @Parameterized.Parameters(name = "{index}:{0},{1},{2}") public static List getParameters() { return Arrays.asList(new Object[][]{ {new ReportPortalException(EXCEPTION_MESSAGE), ErrorType.UNCLASSIFIED_REPORT_PORTAL_ERROR, @@ -79,21 +63,22 @@ public static List getParameters() { "Incorrect Request. Required request parameter 'test' for method parameter type test is not present"}}); } - @Test - public void testErrorHandlingException() - throws IllegalArgumentException, SecurityException, InstantiationException, IllegalAccessException, InvocationTargetException, - NoSuchMethodException { + @ParameterizedTest + @MethodSource("getParameters") + public void testErrorHandlingException(Exception exception, ErrorType errorType, + HttpStatus httpStatus, String errorMessage) + throws IllegalArgumentException, SecurityException { RestError restError = errorResolver.resolveError(exception); validate(restError, errorType, httpStatus, errorMessage); } private void validate(RestError restError, ErrorType errorType, HttpStatus httpStatus, String exceptionMessage) { - Assert.assertThat(restError.getErrorRS().getMessage(), + assertThat(restError.errorRS().getMessage(), Matchers.containsString( Strings.isNullOrEmpty(exceptionMessage) ? EXCEPTION_MESSAGE : exceptionMessage)); - Assert.assertEquals(errorType, restError.getErrorRS().getErrorType()); - Assert.assertEquals(httpStatus, restError.getHttpStatus()); + assertEquals(errorType, restError.errorRS().getErrorType()); + assertEquals(httpStatus, restError.httpStatus()); } -} \ No newline at end of file +} diff --git a/src/test/java/com/epam/reportportal/rules/rest/StatusCodeMappingTest.java b/src/test/java/com/epam/reportportal/rules/rest/StatusCodeMappingTest.java index 18dba13..a5e0b4b 100644 --- a/src/test/java/com/epam/reportportal/rules/rest/StatusCodeMappingTest.java +++ b/src/test/java/com/epam/reportportal/rules/rest/StatusCodeMappingTest.java @@ -16,10 +16,11 @@ package com.epam.reportportal.rules.rest; +import static org.junit.jupiter.api.Assertions.assertEquals; + import com.epam.reportportal.rules.commons.exception.rest.StatusCodeMapping; import com.epam.reportportal.rules.exception.ErrorType; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Status Code mapping test @@ -37,6 +38,6 @@ public void testMapping() { } } - Assert.assertEquals(errors.toString(), 0, errors.length()); + assertEquals(0, errors.length(), errors.toString()); } -} \ No newline at end of file +} diff --git a/src/test/java/com/epam/reportportal/rules/validation/SuppliersTest.java b/src/test/java/com/epam/reportportal/rules/validation/SuppliersTest.java index bc60c2a..d346d2b 100644 --- a/src/test/java/com/epam/reportportal/rules/validation/SuppliersTest.java +++ b/src/test/java/com/epam/reportportal/rules/validation/SuppliersTest.java @@ -17,11 +17,12 @@ package com.epam.reportportal.rules.validation; import static com.epam.reportportal.rules.commons.validation.Suppliers.trimMessage; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; import com.epam.reportportal.rules.commons.validation.Suppliers; import org.hamcrest.Matchers; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Several tests for {@link Suppliers} @@ -34,22 +35,22 @@ public class SuppliersTest { public void testSimpleSupplier() { String demoString = "demo string"; String suppliedString = Suppliers.stringSupplier(demoString).get(); - Assert.assertEquals("Initial and supplied strings are not equal", demoString, suppliedString); + assertEquals(demoString, suppliedString, "Initial and supplied strings are not equal"); } @Test public void testFormattedSupplier() { String demoString = "here is {} parameter"; String suppliedString = Suppliers.formattedSupplier(demoString, "first").get(); - Assert.assertEquals("Initial and supplied strings are not equal", "here is first parameter", - suppliedString); + assertEquals("here is first parameter", + suppliedString, "Initial and supplied strings are not equal"); } @Test public void checkNoParamsInMessage() { String demoString = "here is parameter {}"; String suppliedString = Suppliers.formattedSupplier(demoString).get(); - Assert.assertThat("Incorrect message builder", suppliedString, + assertThat("Incorrect message builder", suppliedString, Matchers.is("here is parameter")); } @@ -57,7 +58,7 @@ public void checkNoParamsInMessage() { public void checkParamsInMessage() { String demoString = "here is parameter {}"; String suppliedString = Suppliers.formattedSupplier(demoString, ":hello world").get(); - Assert.assertThat("Incorrect message builder", suppliedString, + assertThat("Incorrect message builder", suppliedString, Matchers.is("here is parameter :hello world")); } @@ -66,18 +67,18 @@ public void trimMessageTest() { String errMessage = "Incorrect truncate"; String toTrim = "hello world"; - Assert.assertEquals(errMessage, "hello worl", trimMessage(toTrim, 10)); - Assert.assertEquals(errMessage, "hello world", trimMessage(toTrim, 15)); - Assert.assertEquals(errMessage, "hello world", trimMessage(toTrim, 11)); - Assert.assertEquals(errMessage, "hello", trimMessage(toTrim, 5)); + assertEquals("hello worl", trimMessage(toTrim, 10), errMessage); + assertEquals("hello world", trimMessage(toTrim, 15), errMessage); + assertEquals("hello world", trimMessage(toTrim, 11), errMessage); + assertEquals("hello", trimMessage(toTrim, 5), errMessage); } @Test public void trimFormattedSupplierMessageTest() { String demoString = "here is parameter {}"; String suppliedString = Suppliers.formattedSupplier(demoString, () -> "param").get(); - Assert.assertThat("Incorrect message builder", suppliedString, + assertThat("Incorrect message builder", suppliedString, Matchers.is("here is parameter param")); } -} \ No newline at end of file +}