Fix Sonar findings (#2489)
Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -1325,8 +1325,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
|
|||||||
|
|
||||||
retrieveAndVerifyRolloutGroupInCreating(rollout, firstGroup);
|
retrieveAndVerifyRolloutGroupInCreating(rollout, firstGroup);
|
||||||
retrieveAndVerifyRolloutGroupInReady(rollout, firstGroup);
|
retrieveAndVerifyRolloutGroupInReady(rollout, firstGroup);
|
||||||
retrieveAndVerifyRolloutGroupInRunningAndScheduled(rollout, firstGroup, secondGroup, confirmationFlowEnabled,
|
retrieveAndVerifyRolloutGroupInRunningAndScheduled(rollout, firstGroup, secondGroup, confirmationRequired);
|
||||||
confirmationRequired);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1825,8 +1824,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void retrieveAndVerifyRolloutGroupInRunningAndScheduled(final Rollout rollout,
|
private void retrieveAndVerifyRolloutGroupInRunningAndScheduled(final Rollout rollout,
|
||||||
final RolloutGroup firstGroup, final RolloutGroup secondGroup, final boolean confirmationFlowEnabled,
|
final RolloutGroup firstGroup, final RolloutGroup secondGroup, final boolean confirmationRequired) throws Exception {
|
||||||
final boolean confirmationRequired) throws Exception {
|
|
||||||
rolloutManagement.start(rollout.getId());
|
rolloutManagement.start(rollout.getId());
|
||||||
rolloutHandler.handleAll();
|
rolloutHandler.handleAll();
|
||||||
mvc.perform(get("/rest/v1/rollouts/{rolloutId}/deploygroups/{groupId}", rollout.getId(), firstGroup.getId())
|
mvc.perform(get("/rest/v1/rollouts/{rolloutId}/deploygroups/{groupId}", rollout.getId(), firstGroup.getId())
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ class AutoAssignCheckerIntTest extends AbstractJpaIntegrationTest {
|
|||||||
|
|
||||||
verifyThatTargetsHaveDistributionSetAssignment(toAssignDs, targets.subList(0, 1), targetsCount);
|
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());
|
autoAssignChecker.checkSingleTarget(targets.get(0).getControllerId());
|
||||||
verifyThatTargetsHaveDistributionSetAssignedAndActionStatus(toAssignDs, targets.subList(0, 1), expectedStatus);
|
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);
|
assertThat(actionsByDs).allMatch(action -> action.getStatus() == status);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void verifyThatTargetsNotHaveDistributionSetAssignment(final DistributionSet set,
|
private void verifyThatTargetsNotHaveDistributionSetAssignment(final List<Target> targets) {
|
||||||
final List<Target> targets) {
|
|
||||||
final List<Long> targetIds = targets.stream().map(Target::getId).toList();
|
final List<Long> targetIds = targets.stream().map(Target::getId).toList();
|
||||||
|
|
||||||
final Slice<Target> targetsAll = targetManagement.findAll(PAGE);
|
final Slice<Target> targetsAll = targetManagement.findAll(PAGE);
|
||||||
@@ -471,7 +470,6 @@ class AutoAssignCheckerIntTest extends AbstractJpaIntegrationTest {
|
|||||||
assertThat(deploymentManagement.getAssignedDistributionSet(target.getControllerId())).isEmpty();
|
assertThat(deploymentManagement.getAssignedDistributionSet(target.getControllerId())).isEmpty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void verifyThatCreatedActionsAreInitiatedByCurrentUser(final TargetFilterQuery targetFilterQuery,
|
private void verifyThatCreatedActionsAreInitiatedByCurrentUser(final TargetFilterQuery targetFilterQuery,
|
||||||
|
|||||||
@@ -40,10 +40,11 @@ import com.vaadin.flow.component.select.Select;
|
|||||||
import com.vaadin.flow.component.textfield.TextArea;
|
import com.vaadin.flow.component.textfield.TextArea;
|
||||||
import com.vaadin.flow.component.textfield.TextField;
|
import com.vaadin.flow.component.textfield.TextField;
|
||||||
import com.vaadin.flow.component.upload.Upload;
|
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.data.renderer.ComponentRenderer;
|
||||||
import com.vaadin.flow.router.PageTitle;
|
import com.vaadin.flow.router.PageTitle;
|
||||||
import com.vaadin.flow.router.Route;
|
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 lombok.extern.slf4j.Slf4j;
|
||||||
import org.eclipse.hawkbit.mgmt.json.model.PagedList;
|
import org.eclipse.hawkbit.mgmt.json.model.PagedList;
|
||||||
import org.eclipse.hawkbit.mgmt.json.model.artifact.MgmtArtifact;
|
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);
|
artifactGrid.setSelectionMode(Grid.SelectionMode.NONE);
|
||||||
|
|
||||||
final FileBuffer fileBuffer = new FileBuffer();
|
final Upload uploadBtn = new Upload(uploadEvent -> {
|
||||||
final Upload uploadBtn = new Upload(fileBuffer);
|
|
||||||
uploadBtn.setMaxFiles(10);
|
|
||||||
uploadBtn.setWidthFull();
|
|
||||||
uploadBtn.setDropAllowed(true);
|
|
||||||
uploadBtn.addSucceededListener(e -> {
|
|
||||||
final MgmtArtifact artifact = hawkbitClient.getSoftwareModuleRestApi()
|
final MgmtArtifact artifact = hawkbitClient.getSoftwareModuleRestApi()
|
||||||
.uploadArtifact(
|
.uploadArtifact(
|
||||||
softwareModuleId,
|
softwareModuleId,
|
||||||
new MultipartFileImpl(fileBuffer, e.getContentLength(), e.getMIMEType()),
|
new MultipartFileImpl(uploadEvent),
|
||||||
fileBuffer.getFileName(), null, null, null)
|
uploadEvent.getFileName(), null, null, null)
|
||||||
.getBody();
|
.getBody();
|
||||||
artifacts.add(artifact);
|
artifacts.add(artifact);
|
||||||
artifactGrid.refreshGrid(false);
|
artifactGrid.refreshGrid(false);
|
||||||
});
|
});
|
||||||
|
uploadBtn.setMaxFiles(10);
|
||||||
|
uploadBtn.setWidthFull();
|
||||||
|
uploadBtn.setDropAllowed(true);
|
||||||
|
|
||||||
final Button finishBtn = Utils.tooltip(new Button("Finish"), "Finish (Enter)");
|
final Button finishBtn = Utils.tooltip(new Button("Finish"), "Finish (Enter)");
|
||||||
finishBtn.addClickListener(e -> close());
|
finishBtn.addClickListener(e -> close());
|
||||||
@@ -382,19 +381,15 @@ public class SoftwareModuleView extends TableView<MgmtSoftwareModule, Long> {
|
|||||||
|
|
||||||
private static class MultipartFileImpl implements MultipartFile {
|
private static class MultipartFileImpl implements MultipartFile {
|
||||||
|
|
||||||
private final FileBuffer fileBuffer;
|
private final UploadEvent uploadEvent;
|
||||||
private final String mimeType;
|
|
||||||
private final long contentLength;
|
|
||||||
|
|
||||||
public MultipartFileImpl(final FileBuffer fileBuffer, final long contentLength, final String mimeType) {
|
public MultipartFileImpl(final UploadEvent uploadEvent) {
|
||||||
this.fileBuffer = fileBuffer;
|
this.uploadEvent = uploadEvent;
|
||||||
this.contentLength = contentLength;
|
|
||||||
this.mimeType = mimeType;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return fileBuffer.getFileName();
|
return uploadEvent.getFileName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -404,17 +399,17 @@ public class SoftwareModuleView extends TableView<MgmtSoftwareModule, Long> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getContentType() {
|
public String getContentType() {
|
||||||
return mimeType;
|
return uploadEvent.getContentType();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isEmpty() {
|
public boolean isEmpty() {
|
||||||
return contentLength == 0;
|
return uploadEvent.getFileSize() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getSize() {
|
public long getSize() {
|
||||||
return contentLength;
|
return uploadEvent.getFileSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -427,7 +422,7 @@ public class SoftwareModuleView extends TableView<MgmtSoftwareModule, Long> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InputStream getInputStream() {
|
public InputStream getInputStream() {
|
||||||
return fileBuffer.getInputStream();
|
return uploadEvent.getInputStream();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user