Sonar Fixes (#2233)

Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2025-01-24 15:41:06 +02:00
committed by GitHub
parent 0280d96d2c
commit a61e9cd6ae
66 changed files with 401 additions and 387 deletions

View File

@@ -387,8 +387,11 @@ public interface MgmtTargetTagRestApi {
@RequestBody List<String> controllerId);
enum OnNotFoundPolicy {
// if it has not found - operation fail
FAIL, // default
// if it has not found - do operation on found operation and fail indicating that not all are found
ON_WHAT_FOUND_AND_FAIL,
// if it has not found - do operation on found operation and success, silently
ON_WHAT_FOUND_AND_SUCCESS
}
}

View File

@@ -22,18 +22,18 @@ import org.junit.jupiter.api.Test;
@Feature("Unit Tests - Management API")
@Story("Paged List Handling")
public class PagedListTest {
class PagedListTest {
@Test
@Description("Ensures that a null payload entity throws an exception.")
public void createListWithNullContentThrowsException() {
void createListWithNullContentThrowsException() {
assertThatThrownBy(() -> new PagedList<>(null, 0))
.isInstanceOf(NullPointerException.class);
}
@Test
@Description("Create list with payload and verify content.")
public void createListWithContent() {
void createListWithContent() {
final long knownTotal = 2;
final List<String> knownContentList = new ArrayList<>();
knownContentList.add("content1");
@@ -44,7 +44,7 @@ public class PagedListTest {
@Test
@Description("Create list with payload and verify size values.")
public void createListWithSmallerTotalThanContentSizeIsOk() {
void createListWithSmallerTotalThanContentSizeIsOk() {
final long knownTotal = 0;
final List<String> knownContentList = new ArrayList<>();
knownContentList.add("content1");

View File

@@ -14,7 +14,6 @@ import static org.assertj.core.api.Assertions.assertThat;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -24,7 +23,7 @@ import org.springframework.context.annotation.Description;
@Story("Retrieve all open action ids")
@Description("Tests for the MgmtTargetAssignmentResponseBody")
public class MgmtTargetAssignmentResponseBodyTest {
class MgmtTargetAssignmentResponseBodyTest {
private static final List<Long> ASSIGNED_ACTIONS = Arrays.asList(4L, 5L, 6L);
private static final int ALREADY_ASSIGNED_COUNT = 3;
@@ -32,7 +31,7 @@ public class MgmtTargetAssignmentResponseBodyTest {
@Test
@Description("Tests that the ActionIds are serialized correctly in MgmtTargetAssignmentResponseBody")
public void testActionIdsSerialization() throws IOException {
void testActionIdsSerialization() throws IOException {
final MgmtTargetAssignmentResponseBody responseBody = generateResponseBody();
final ObjectMapper objectMapper = new ObjectMapper();
final String responseBodyAsString = objectMapper.writeValueAsString(responseBody);
@@ -70,9 +69,8 @@ public class MgmtTargetAssignmentResponseBodyTest {
}
private static MgmtTargetAssignmentResponseBody generateResponseBody() {
MgmtTargetAssignmentResponseBody response = new MgmtTargetAssignmentResponseBody();
response.setAssignedActions(
ASSIGNED_ACTIONS.stream().map(id -> new MgmtActionId(CONTROLLER_ID, id)).collect(Collectors.toList()));
final MgmtTargetAssignmentResponseBody response = new MgmtTargetAssignmentResponseBody();
response.setAssignedActions(ASSIGNED_ACTIONS.stream().map(id -> new MgmtActionId(CONTROLLER_ID, id)).toList());
response.setAlreadyAssigned(ALREADY_ASSIGNED_COUNT);
return response;
}