Fix Sonar findings (#2489)

Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2025-06-23 10:19:43 +03:00
committed by GitHub
parent 838e3e06f5
commit 5586e4b302
3 changed files with 21 additions and 30 deletions

View File

@@ -1325,8 +1325,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
retrieveAndVerifyRolloutGroupInCreating(rollout, firstGroup);
retrieveAndVerifyRolloutGroupInReady(rollout, firstGroup);
retrieveAndVerifyRolloutGroupInRunningAndScheduled(rollout, firstGroup, secondGroup, confirmationFlowEnabled,
confirmationRequired);
retrieveAndVerifyRolloutGroupInRunningAndScheduled(rollout, firstGroup, secondGroup, confirmationRequired);
}
/**
@@ -1825,8 +1824,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
}
private void retrieveAndVerifyRolloutGroupInRunningAndScheduled(final Rollout rollout,
final RolloutGroup firstGroup, final RolloutGroup secondGroup, final boolean confirmationFlowEnabled,
final boolean confirmationRequired) throws Exception {
final RolloutGroup firstGroup, final RolloutGroup secondGroup, final boolean confirmationRequired) throws Exception {
rolloutManagement.start(rollout.getId());
rolloutHandler.handleAll();
mvc.perform(get("/rest/v1/rollouts/{rolloutId}/deploygroups/{groupId}", rollout.getId(), firstGroup.getId())

View File

@@ -182,7 +182,7 @@ class AutoAssignCheckerIntTest extends AbstractJpaIntegrationTest {
verifyThatTargetsHaveDistributionSetAssignment(toAssignDs, targets.subList(0, 1), targetsCount);
verifyThatTargetsNotHaveDistributionSetAssignment(toAssignDs, targets.subList(1, 25));
verifyThatTargetsNotHaveDistributionSetAssignment(targets.subList(1, 25));
}
/**
@@ -241,7 +241,7 @@ class AutoAssignCheckerIntTest extends AbstractJpaIntegrationTest {
autoAssignChecker.checkSingleTarget(targets.get(0).getControllerId());
verifyThatTargetsHaveDistributionSetAssignedAndActionStatus(toAssignDs, targets.subList(0, 1), expectedStatus);
verifyThatTargetsNotHaveDistributionSetAssignment(toAssignDs, targets.subList(1, 25));
verifyThatTargetsNotHaveDistributionSetAssignment(targets.subList(1, 25));
}
/**
@@ -460,8 +460,7 @@ class AutoAssignCheckerIntTest extends AbstractJpaIntegrationTest {
assertThat(actionsByDs).allMatch(action -> action.getStatus() == status);
}
private void verifyThatTargetsNotHaveDistributionSetAssignment(final DistributionSet set,
final List<Target> targets) {
private void verifyThatTargetsNotHaveDistributionSetAssignment(final List<Target> targets) {
final List<Long> targetIds = targets.stream().map(Target::getId).toList();
final Slice<Target> targetsAll = targetManagement.findAll(PAGE);
@@ -471,7 +470,6 @@ class AutoAssignCheckerIntTest extends AbstractJpaIntegrationTest {
assertThat(deploymentManagement.getAssignedDistributionSet(target.getControllerId())).isEmpty();
}
}
}
private void verifyThatCreatedActionsAreInitiatedByCurrentUser(final TargetFilterQuery targetFilterQuery,

View File

@@ -40,10 +40,11 @@ import com.vaadin.flow.component.select.Select;
import com.vaadin.flow.component.textfield.TextArea;
import com.vaadin.flow.component.textfield.TextField;
import com.vaadin.flow.component.upload.Upload;
import com.vaadin.flow.component.upload.receivers.FileBuffer;
import com.vaadin.flow.data.renderer.ComponentRenderer;
import com.vaadin.flow.router.PageTitle;
import com.vaadin.flow.router.Route;
import com.vaadin.flow.server.streams.UploadEvent;
import com.vaadin.flow.server.streams.UploadHandler;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.hawkbit.mgmt.json.model.PagedList;
import org.eclipse.hawkbit.mgmt.json.model.artifact.MgmtArtifact;
@@ -351,21 +352,19 @@ public class SoftwareModuleView extends TableView<MgmtSoftwareModule, Long> {
});
artifactGrid.setSelectionMode(Grid.SelectionMode.NONE);
final FileBuffer fileBuffer = new FileBuffer();
final Upload uploadBtn = new Upload(fileBuffer);
uploadBtn.setMaxFiles(10);
uploadBtn.setWidthFull();
uploadBtn.setDropAllowed(true);
uploadBtn.addSucceededListener(e -> {
final Upload uploadBtn = new Upload(uploadEvent -> {
final MgmtArtifact artifact = hawkbitClient.getSoftwareModuleRestApi()
.uploadArtifact(
softwareModuleId,
new MultipartFileImpl(fileBuffer, e.getContentLength(), e.getMIMEType()),
fileBuffer.getFileName(), null, null, null)
new MultipartFileImpl(uploadEvent),
uploadEvent.getFileName(), null, null, null)
.getBody();
artifacts.add(artifact);
artifactGrid.refreshGrid(false);
});
uploadBtn.setMaxFiles(10);
uploadBtn.setWidthFull();
uploadBtn.setDropAllowed(true);
final Button finishBtn = Utils.tooltip(new Button("Finish"), "Finish (Enter)");
finishBtn.addClickListener(e -> close());
@@ -382,19 +381,15 @@ public class SoftwareModuleView extends TableView<MgmtSoftwareModule, Long> {
private static class MultipartFileImpl implements MultipartFile {
private final FileBuffer fileBuffer;
private final String mimeType;
private final long contentLength;
private final UploadEvent uploadEvent;
public MultipartFileImpl(final FileBuffer fileBuffer, final long contentLength, final String mimeType) {
this.fileBuffer = fileBuffer;
this.contentLength = contentLength;
this.mimeType = mimeType;
public MultipartFileImpl(final UploadEvent uploadEvent) {
this.uploadEvent = uploadEvent;
}
@Override
public String getName() {
return fileBuffer.getFileName();
return uploadEvent.getFileName();
}
@Override
@@ -404,17 +399,17 @@ public class SoftwareModuleView extends TableView<MgmtSoftwareModule, Long> {
@Override
public String getContentType() {
return mimeType;
return uploadEvent.getContentType();
}
@Override
public boolean isEmpty() {
return contentLength == 0;
return uploadEvent.getFileSize() == 0;
}
@Override
public long getSize() {
return contentLength;
return uploadEvent.getFileSize();
}
@Override
@@ -427,7 +422,7 @@ public class SoftwareModuleView extends TableView<MgmtSoftwareModule, Long> {
@Override
public InputStream getInputStream() {
return fileBuffer.getInputStream();
return uploadEvent.getInputStream();
}
@Override