Fix some compile warnings (#2919)

* Fix some compile warnings
* Some classes made final
* JPA entities made not serializable

Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2026-02-11 14:05:46 +02:00
committed by GitHub
parent 17eacc729b
commit 62c76311e5
89 changed files with 362 additions and 358 deletions

View File

@@ -43,7 +43,7 @@ import org.springframework.hateoas.RepresentationModel;
}
}
}""")
public class MgmtActionId extends RepresentationModel<MgmtActionId> {
public final class MgmtActionId extends RepresentationModel<MgmtActionId> {
@Schema(description = "ID of the action")
private long id;

View File

@@ -24,7 +24,7 @@ import lombok.NoArgsConstructor;
*/
@NoArgsConstructor
@JsonDeserialize(using = MgmtDistributionSetAssignmentsDeserializer.class)
public class MgmtDistributionSetAssignments extends ArrayList<MgmtDistributionSetAssignment> {
public final class MgmtDistributionSetAssignments extends ArrayList<MgmtDistributionSetAssignment> {
@Serial
private static final long serialVersionUID = 1L;
@@ -39,16 +39,6 @@ public class MgmtDistributionSetAssignments extends ArrayList<MgmtDistributionSe
add(assignment);
}
/**
* Constructor for an object that contains multiple distribution set
* assignments
*
* @param assignments the assignments
*/
public MgmtDistributionSetAssignments(final List<MgmtDistributionSetAssignment> assignments) {
super(assignments);
}
@Override
@JsonIgnore
public boolean isEmpty() {

View File

@@ -308,7 +308,7 @@ public interface MgmtTargetRestApi {
@Operation(summary = "Controls (confirm/deny) actions waiting for confirmation", description = """
Either confirm or deny an action which is waiting for confirmation.
The action will be transferred into the RUNNING state in case confirming it.
The action will remain in WAITING_FOR_CONFIRMATION state in case denying it.
The action will remain in WAITING_FOR_CONFIRMATION state in case denying it.
Required Permission: READ_REPOSITORY AND UPDATE_TARGET
""")
@PutNoContentResponses

View File

@@ -470,6 +470,7 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio
final Map<String, Object> info = exceptionInfo.getInfo();
assertThat(info).isNotNull();
assertThat(info.get(EntityNotFoundException.TYPE)).isEqualTo(DistributionSet.class.getSimpleName());
@SuppressWarnings("unchecked")
final List<String> notFound = (List<String>) info.get(EntityNotFoundException.ENTITY_ID);
Collections.sort(notFound);
assertThat(notFound).isEqualTo(missing);

View File

@@ -97,8 +97,6 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
private RolloutGroupManagement rolloutGroupManagement;
@Autowired
private RolloutTestApprovalStrategy approvalStrategy;
@Autowired
private DistributionSetManagement distributionSetManagement;
/**
* Handles the GET request of retrieving a single rollout.
@@ -1984,7 +1982,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
private long postRollout(final String name, final int groupSize, final Long distributionSetId,
final String targetFilterQuery, final int targets, final Action.ActionType type, final Long startTime,
final Long forceTime, boolean isDynamic, String dynamicGroupSuffix, int dynamicGroupTargetsCount) throws Exception {
final Long forceTime, boolean isDynamic, final String dynamicGroupSuffix, int dynamicGroupTargetsCount) throws Exception {
final String actionType = MgmtRestModelMapper.convertActionType(type).getName();
final String rollout = JsonBuilder.rollout(name, "desc", groupSize, distributionSetId, targetFilterQuery,
new RolloutGroupConditionBuilder().withDefaults().build(), null, actionType, null, startTime, forceTime,

View File

@@ -381,6 +381,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
final Map<String, Object> info = exceptionInfo.getInfo();
assertThat(info).isNotNull();
assertThat(info.get(EntityNotFoundException.TYPE)).isEqualTo(Target.class.getSimpleName());
@SuppressWarnings("unchecked")
final List<String> notFound = (List<String>) info.get(EntityNotFoundException.ENTITY_ID);
Collections.sort(notFound);
assertThat(notFound).isEqualTo(missing);
@@ -424,6 +425,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
final Map<String, Object> info = exceptionInfo.getInfo();
assertThat(info).isNotNull();
assertThat(info.get(EntityNotFoundException.TYPE)).isEqualTo(Target.class.getSimpleName());
@SuppressWarnings("unchecked")
final List<String> notFound = (List<String>) info.get(EntityNotFoundException.ENTITY_ID);
Collections.sort(notFound);
assertThat(notFound).isEqualTo(missing);
@@ -558,6 +560,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
final Map<String, Object> info = exceptionInfo.getInfo();
assertThat(info).isNotNull();
assertThat(info.get(EntityNotFoundException.TYPE)).isEqualTo(Target.class.getSimpleName());
@SuppressWarnings("unchecked")
final List<String> notFound = (List<String>) info.get(EntityNotFoundException.ENTITY_ID);
Collections.sort(notFound);
assertThat(notFound).isEqualTo(missing);
@@ -604,6 +607,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
final Map<String, Object> info = exceptionInfo.getInfo();
assertThat(info).isNotNull();
assertThat(info.get(EntityNotFoundException.TYPE)).isEqualTo(Target.class.getSimpleName());
@SuppressWarnings("unchecked")
final List<String> notFound = (List<String>) info.get(EntityNotFoundException.ENTITY_ID);
Collections.sort(notFound);
assertThat(notFound).isEqualTo(missing);

View File

@@ -14,6 +14,7 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import java.util.HashMap;
import java.util.Map;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.eclipse.hawkbit.auth.SpPermission;
@@ -95,7 +96,7 @@ class PreAuthorizeEnabledTest extends AbstractSecurityTest {
mvc.perform(get("/rest/v1/system/configs")).andExpect(result -> {
// returns default DS type because of READ_TARGET
assertThat(result.getResponse().getStatus()).isEqualTo(HttpStatus.OK.value());
assertThat(new ObjectMapper().reader().readValue(result.getResponse().getContentAsString(), HashMap.class)).hasSize(1);
assertThat((Map<?, ?>) new ObjectMapper().reader().readValue(result.getResponse().getContentAsString(), HashMap.class)).hasSize(1);
});
}