-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
107 changed files
with
7,626 additions
and
356 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,11 @@ | ||
version=5.11.1 | ||
description=EPAM Report portal. Report Portal Commons | ||
version=5.12.0 | ||
description=EPAM Report portal common libs | ||
hibernateValidatorVersion=6.1.2.Final | ||
validationApiVersion=2.0.1.Final | ||
junitVersion=4.12 | ||
elApiVersion=3.0.0 | ||
sprindocAnnotationsVersion=1.7.0 | ||
commonsLangVersion=3.9 | ||
mockitoJunitJupiter=2.23.0 | ||
jacksonVersion=2.10.2 | ||
lombokVersion=1.18.30 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* 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.annotations; | ||
|
||
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 value is contained in allowed values ignoring case. | ||
* <p> | ||
* {@code null} - valid value. | ||
* | ||
* @author <a href="mailto:ihar_kahadouski@epam.com">Ihar Kahadouski</a> | ||
*/ | ||
@Documented | ||
@Constraint(validatedBy = {InValidator.class, InCollectionValidator.class}) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ElementType.FIELD, ElementType.PARAMETER}) | ||
public @interface In { | ||
|
||
String message() default "Value is not allowed"; | ||
|
||
Class<?>[] groups() default {}; | ||
|
||
Class<?>[] payload() default {}; | ||
|
||
String[] allowedValues() default {}; | ||
} |
49 changes: 49 additions & 0 deletions
49
src/main/java/com/epam/reportportal/annotations/InCollectionValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* 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.annotations; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.Collection; | ||
import java.util.List; | ||
import javax.validation.ConstraintValidator; | ||
import javax.validation.ConstraintValidatorContext; | ||
|
||
/** | ||
* @author <a href="mailto:ihar_kahadouski@epam.com">Ihar Kahadouski</a> | ||
*/ | ||
public class InCollectionValidator implements ConstraintValidator<In, Collection<String>> { | ||
|
||
private String[] allowedValues; | ||
|
||
@Override | ||
public void initialize(In constraintAnnotation) { | ||
allowedValues = new String[constraintAnnotation.allowedValues().length]; | ||
for (int i = 0; i < constraintAnnotation.allowedValues().length; i++) { | ||
allowedValues[i] = constraintAnnotation.allowedValues()[i].toUpperCase(); | ||
} | ||
} | ||
|
||
@Override | ||
public boolean isValid(Collection<String> value, ConstraintValidatorContext context) { | ||
List<String> upperCaseList = new ArrayList<>(); | ||
for (String next : value) { | ||
upperCaseList.add(next.toUpperCase()); | ||
} | ||
return Arrays.asList(allowedValues).containsAll(upperCaseList); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
src/main/java/com/epam/reportportal/annotations/InValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* 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.annotations; | ||
|
||
import javax.validation.ConstraintValidator; | ||
import javax.validation.ConstraintValidatorContext; | ||
|
||
/** | ||
* @author <a href="mailto:ihar_kahadouski@epam.com">Ihar Kahadouski</a> | ||
*/ | ||
public class InValidator implements ConstraintValidator<In, String> { | ||
|
||
private String[] allowedValues; | ||
|
||
@Override | ||
public void initialize(In constraintAnnotation) { | ||
allowedValues = constraintAnnotation.allowedValues(); | ||
} | ||
|
||
@Override | ||
public boolean isValid(String value, ConstraintValidatorContext context) { | ||
if (null == value) { | ||
return true; | ||
} | ||
for (String next : allowedValues) { | ||
if (value.equalsIgnoreCase(next)) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
src/main/java/com/epam/reportportal/annotations/NotBlankString.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* 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.annotations; | ||
|
||
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. | ||
* <p> | ||
* {@code null} value is valid. | ||
* | ||
* @author <a href="mailto:ihar_kahadouski@epam.com">Ihar Kahadouski</a> | ||
*/ | ||
@Documented | ||
@Constraint(validatedBy = NotBlankStringValidator.class) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ElementType.FIELD, ElementType.PARAMETER}) | ||
public @interface NotBlankString { | ||
|
||
String message() default "Should not be blank"; | ||
|
||
Class<?>[] groups() default {}; | ||
|
||
Class<?>[] payload() default {}; | ||
} |
44 changes: 44 additions & 0 deletions
44
src/main/java/com/epam/reportportal/annotations/NotBlankStringCollection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* 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.annotations; | ||
|
||
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. | ||
* <p> | ||
* {@code null} - valid value. {@code empty collection} - valid value. | ||
* | ||
* @author <a href="mailto:ihar_kahadouski@epam.com">Ihar Kahadouski</a> | ||
*/ | ||
@Documented | ||
@Constraint(validatedBy = NotBlankStringCollectionValidator.class) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ElementType.FIELD, ElementType.PARAMETER}) | ||
public @interface NotBlankStringCollection { | ||
|
||
String message() default "Collection should not contain blank elements"; | ||
|
||
Class<?>[] groups() default {}; | ||
|
||
Class<?>[] payload() default {}; | ||
} |
41 changes: 41 additions & 0 deletions
41
src/main/java/com/epam/reportportal/annotations/NotBlankStringCollectionValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* 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.annotations; | ||
|
||
import java.util.Collection; | ||
import javax.validation.ConstraintValidator; | ||
import javax.validation.ConstraintValidatorContext; | ||
|
||
/** | ||
* @author <a href="mailto:ihar_kahadouski@epam.com">Ihar Kahadouski</a> | ||
*/ | ||
public class NotBlankStringCollectionValidator implements | ||
ConstraintValidator<NotBlankStringCollection, Collection<String>> { | ||
|
||
@Override | ||
public boolean isValid(Collection<String> value, ConstraintValidatorContext context) { | ||
if (null == value) { | ||
return true; | ||
} | ||
for (String next : value) { | ||
if (next.trim().isEmpty()) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
} |
Oops, something went wrong.