Skip to content

Commit 9a3c56b

Browse files
Fixed Checkstyle and PMD
1 parent 54f11e4 commit 9a3c56b

2 files changed

Lines changed: 27 additions & 24 deletions

File tree

spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/support/copier/registering/EclipseSerializerRegisteringCopier.java

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@
2525

2626
import jakarta.validation.ConstraintViolation;
2727
import jakarta.validation.ConstraintViolationException;
28-
import jakarta.validation.Validation;
2928
import jakarta.validation.Validator;
30-
import jakarta.validation.ValidatorFactory;
3129

3230
import org.eclipse.serializer.persistence.binary.types.Binary;
3331
import org.eclipse.serializer.persistence.binary.types.BinaryStorer;
@@ -150,26 +148,7 @@ private <T> T copy(final T source, final PersistenceManager<Binary> persistenceM
150148
{
151149
return;
152150
}
153-
if(copiedObject != null)
154-
{
155-
if(!this.supportedChecker.isSupported(copiedObject.getClass()))
156-
{
157-
throw new DataTypeNotSupportedException(copiedObject.getClass());
158-
}
159-
final Set<ConstraintViolation<Object>> violations = this.validator.validate(copiedObject);
160-
if(!violations.isEmpty())
161-
{
162-
final String violationsAsMessage = violations.stream()
163-
.map(cv -> cv == null ? "null" : cv.getPropertyPath() + ": " + cv.getMessage())
164-
.collect(Collectors.joining(", "));
165-
166-
throw new ConstraintViolationException(
167-
"Error validating " + copiedObject.getClass().getName() + ":" + System.lineSeparator()
168-
+ violationsAsMessage,
169-
violations
170-
);
171-
}
172-
}
151+
this.validate(copiedObject);
173152
summarizer.incrementCopiedObjectsCount();
174153
if(DataTypeUtil.isPrimitiveType(copiedObject.getClass()))
175154
{
@@ -195,6 +174,30 @@ private <T> T copy(final T source, final PersistenceManager<Binary> persistenceM
195174
return returnValue;
196175
}
197176

177+
private void validate(final Object copiedObject)
178+
{
179+
if(copiedObject != null)
180+
{
181+
if(!this.supportedChecker.isSupported(copiedObject.getClass()))
182+
{
183+
throw new DataTypeNotSupportedException(copiedObject.getClass());
184+
}
185+
final Set<ConstraintViolation<Object>> violations = this.validator.validate(copiedObject);
186+
if(!violations.isEmpty())
187+
{
188+
final String violationsAsMessage = violations.stream()
189+
.map(cv -> cv == null ? "null" : cv.getPropertyPath() + ": " + cv.getMessage())
190+
.collect(Collectors.joining(", "));
191+
192+
throw new ConstraintViolationException(
193+
"Error validating " + copiedObject.getClass().getName() + ":" + System.lineSeparator()
194+
+ violationsAsMessage,
195+
violations
196+
);
197+
}
198+
}
199+
}
200+
198201
private static class Summarizer
199202
{
200203
private long copiedObjectsCount;

spring-data-eclipse-store/src/test/java/software/xdev/spring/data/eclipse/store/integration/isolated/tests/constraints/ConstraintsTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class ConstraintsTest
4040
private ConstraintsRepository repository;
4141

4242
@Test
43-
void assertFalse_True()
43+
void assertFalseWithTrue()
4444
{
4545
final ConstraintDaoObject constraintDaoObject = new ConstraintDaoObject();
4646
constraintDaoObject.setAlwaysFalse(true);
@@ -51,7 +51,7 @@ void assertFalse_True()
5151
}
5252

5353
@Test
54-
void assertFalse_False()
54+
void assertFalseWithFalse()
5555
{
5656
final ConstraintDaoObject constraintDaoObject = new ConstraintDaoObject();
5757
constraintDaoObject.setAlwaysFalse(false);

0 commit comments

Comments
 (0)