Skip to content

Commit a91d2da

Browse files
author
Dennis Labordus
committed
Fixed sonar issues
Signed-off-by: Dennis Labordus <[email protected]>
1 parent 0dda661 commit a91d2da

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

repository-basex/src/main/java/org/lfenergy/compas/scl/data/repository/CompasSclDataBaseXRepository.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ public List<Item> listVersionsByUUID(SclType type, UUID id) {
121121
sclDataMarshaller::unmarshal);
122122

123123
if (items.isEmpty()) {
124-
throw new CompasNoDataFoundException("No versions found for type '" + type + "' with ID '" + id + "'");
124+
var message = String.format("No versions found for type '%s' with ID '%s'", type, id);
125+
throw new CompasNoDataFoundException(message);
125126
}
126127
return items;
127128
}
@@ -140,7 +141,8 @@ public Element findByUUID(SclType type, UUID id) {
140141
xmlString -> elementConverter.convertToElement(xmlString, SCL_ELEMENT_NAME, SCL_NS_URI));
141142

142143
if (result.isEmpty()) {
143-
throw new CompasNoDataFoundException("No record found for type '" + type + "' with ID '" + id + "'");
144+
var message = String.format("No record found for type '%s' with ID '%s'", type, id);
145+
throw new CompasNoDataFoundException(message);
144146
}
145147
return result.get(0);
146148
}
@@ -154,7 +156,8 @@ public Element findByUUID(SclType type, UUID id, Version version) {
154156
xmlString -> elementConverter.convertToElement(xmlString, SCL_ELEMENT_NAME, SCL_NS_URI));
155157

156158
if (result.isEmpty()) {
157-
throw new CompasNoDataFoundException("No record found for type '" + type + "' with ID '" + id + "' and version '" + version + "'");
159+
var message = String.format("No record found for type '%s' with ID '%s' and version '%s'", type, id, version);
160+
throw new CompasNoDataFoundException(message);
158161
}
159162
return result.get(0);
160163
}

repository-basex/src/test/java/org/lfenergy/compas/scl/data/repository/CompasSclDataBaseXRepositoryTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,9 @@ void findByUUIDWithVersion_WhenCalledWithUnknownVersion_ThenExceptionIsThrown()
169169
var scl = readSCL(uuid, version);
170170
repository.create(TYPE, uuid, scl, version);
171171

172+
var unknownVersion = new Version(1, 1, 1);
172173
var exception = assertThrows(CompasNoDataFoundException.class, () -> {
173-
repository.findByUUID(TYPE, uuid, new Version(1, 1, 1));
174+
repository.findByUUID(TYPE, uuid, unknownVersion);
174175
});
175176
assertEquals(NO_DATA_FOUND_ERROR_CODE, exception.getErrorCode());
176177
}

repository/src/main/java/org/lfenergy/compas/scl/data/exception/CompasNoDataFoundException.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
// SPDX-License-Identifier: Apache-2.0
44
package org.lfenergy.compas.scl.data.exception;
55

6+
import org.lfenergy.compas.core.commons.exception.CompasException;
7+
68
import static org.lfenergy.compas.scl.data.exception.CompasSclDataServiceErrorCode.NO_DATA_FOUND_ERROR_CODE;
79

8-
public class CompasNoDataFoundException extends CompasSclDataServiceException {
10+
public class CompasNoDataFoundException extends CompasException {
911
public CompasNoDataFoundException(String message) {
1012
super(NO_DATA_FOUND_ERROR_CODE, message);
1113
}

0 commit comments

Comments
 (0)