Cleanup file streaming utilities (#559)
* Cleanup file streaming. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Added missing comments. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Fix typo. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Split utility class. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Dependency cleanup. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Add missing dependency, Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Remove repository api dependency from rest core. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Fix build and sonar issues. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Remove custom ConstraintViolationException Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * RequestMapping should be public. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Fix errors. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Removed dead code. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Not null Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Fix nullpointer. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Code cleanup. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
@@ -29,7 +29,7 @@ public class RemoteTenantAwareEventTest extends AbstractRemoteEventTest {
|
||||
@Test
|
||||
@Description("Verifies that the download progress reloading by remote events works")
|
||||
public void reloadDownloadProgessByRemoteEvent() {
|
||||
final DownloadProgressEvent downloadProgressEvent = new DownloadProgressEvent("DEFAULT", 3L, "Node");
|
||||
final DownloadProgressEvent downloadProgressEvent = new DownloadProgressEvent("DEFAULT", 1L, 3L, "Node");
|
||||
|
||||
DownloadProgressEvent remoteEvent = (DownloadProgressEvent) createProtoStuffEvent(downloadProgressEvent);
|
||||
assertThat(downloadProgressEvent).isEqualTo(remoteEvent);
|
||||
|
||||
@@ -26,7 +26,6 @@ public class ActionTest {
|
||||
@Description("Ensures that timeforced moded switch from soft to forces after defined timeframe.")
|
||||
public void timeforcedHitNewHasCodeIsGenerated() throws InterruptedException {
|
||||
|
||||
final boolean active;
|
||||
// current time + 1 seconds
|
||||
final long sleepTime = 1000;
|
||||
final long timeForceTimeAt = System.currentTimeMillis() + sleepTime;
|
||||
|
||||
@@ -104,10 +104,8 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
final Artifact result = artifactManagement.createArtifact(new ByteArrayInputStream(random), sm.getId(), "file1",
|
||||
false);
|
||||
final Artifact result11 = artifactManagement.createArtifact(new ByteArrayInputStream(random), sm.getId(),
|
||||
"file11", false);
|
||||
final Artifact result12 = artifactManagement.createArtifact(new ByteArrayInputStream(random), sm.getId(),
|
||||
"file12", false);
|
||||
artifactManagement.createArtifact(new ByteArrayInputStream(random), sm.getId(), "file11", false);
|
||||
artifactManagement.createArtifact(new ByteArrayInputStream(random), sm.getId(), "file12", false);
|
||||
final Artifact result2 = artifactManagement.createArtifact(new ByteArrayInputStream(random), sm2.getId(),
|
||||
"file2", false);
|
||||
|
||||
@@ -270,8 +268,7 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
assertThat(artifactManagement.findArtifactBySoftwareModule(PAGE, sm.getId())).isEmpty();
|
||||
|
||||
final Artifact result = artifactManagement.createArtifact(new RandomGeneratedInputStream(5 * 1024), sm.getId(),
|
||||
"file1", false);
|
||||
artifactManagement.createArtifact(new RandomGeneratedInputStream(5 * 1024), sm.getId(), "file1", false);
|
||||
|
||||
assertThat(artifactManagement.findArtifactBySoftwareModule(PAGE, sm.getId())).hasSize(1);
|
||||
}
|
||||
|
||||
@@ -747,7 +747,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Deletes multiple targets and verfies that all related metadat is also deleted.")
|
||||
@Description("Deletes multiple targets and verfies that all related metadata is also deleted.")
|
||||
public void deletesTargetsAndVerifyCascadeDeletes() {
|
||||
|
||||
final String undeployedTargetPrefix = "undep-T";
|
||||
|
||||
@@ -21,6 +21,8 @@ import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.validation.ValidationException;
|
||||
|
||||
import org.assertj.core.api.Condition;
|
||||
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
|
||||
import org.eclipse.hawkbit.repository.builder.RolloutCreate;
|
||||
@@ -37,7 +39,6 @@ import org.eclipse.hawkbit.repository.event.remote.entity.RolloutUpdatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.SoftwareModuleCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.TargetCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.TargetUpdatedEvent;
|
||||
import org.eclipse.hawkbit.repository.exception.ConstraintViolationException;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityReadOnlyException;
|
||||
import org.eclipse.hawkbit.repository.exception.RolloutIllegalStateException;
|
||||
@@ -139,7 +140,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Expect(type = RolloutUpdatedEvent.class, count = 1),
|
||||
@Expect(type = TargetCreatedEvent.class, count = 10) })
|
||||
public void entityQueriesReferringToNotExistingEntitiesThrowsException() {
|
||||
final Rollout createdRollout = testdataFactory.createRollout("xxx");
|
||||
testdataFactory.createRollout("xxx");
|
||||
|
||||
verifyThrownExceptionBy(() -> rolloutManagement.deleteRollout(NOT_EXIST_IDL), "Rollout");
|
||||
|
||||
@@ -1089,7 +1090,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
final DistributionSet distributionSet = testdataFactory.createDistributionSet("dsFor" + rolloutName);
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
assertThatExceptionOfType(ValidationException.class)
|
||||
.isThrownBy(() -> testdataFactory.createRolloutByVariables(rolloutName, "desc", amountGroups,
|
||||
"id==notExisting", distributionSet, successCondition, errorCondition))
|
||||
.withMessageContaining("does not match any existing");
|
||||
@@ -1336,7 +1337,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
rolloutGroups.add(generateRolloutGroup(0, percentTargetsInGroup1, null));
|
||||
rolloutGroups.add(generateRolloutGroup(1, percentTargetsInGroup2, null));
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
assertThatExceptionOfType(ValidationException.class)
|
||||
.isThrownBy(() -> rolloutManagement.createRollout(myRollout, rolloutGroups, conditions))
|
||||
.withMessageContaining("groups don't match");
|
||||
|
||||
@@ -1357,7 +1358,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
generateRolloutGroup(0, percentTargetsInGroup1, null),
|
||||
generateRolloutGroup(1, percentTargetsInGroup2, null));
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
assertThatExceptionOfType(ValidationException.class)
|
||||
.isThrownBy(() -> rolloutManagement.createRollout(myRollout, rolloutGroups, conditions))
|
||||
.withMessageContaining("percentage has to be between 1 and 100");
|
||||
|
||||
@@ -1373,7 +1374,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
|
||||
final RolloutGroupConditions conditions = new RolloutGroupConditionBuilder().withDefaults().build();
|
||||
final RolloutCreate myRollout = generateTargetsAndRollout(rolloutName, amountTargetsForRollout);
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
assertThatExceptionOfType(ValidationException.class)
|
||||
.isThrownBy(() -> rolloutManagement.createRollout(myRollout, illegalGroupAmount, conditions))
|
||||
.withMessageContaining("not be greater than " + quotaManagement.getMaxRolloutGroupsPerRollout());
|
||||
|
||||
|
||||
@@ -252,8 +252,8 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Description("Counts all software modules in the repsitory that are not marked as deleted.")
|
||||
public void countSoftwareModulesAll() {
|
||||
// found in test
|
||||
final SoftwareModule one = testdataFactory.createSoftwareModuleOs("one");
|
||||
final SoftwareModule two = testdataFactory.createSoftwareModuleOs("two");
|
||||
testdataFactory.createSoftwareModuleOs("one");
|
||||
testdataFactory.createSoftwareModuleOs("two");
|
||||
final SoftwareModule deleted = testdataFactory.createSoftwareModuleOs("deleted");
|
||||
// ignored
|
||||
softwareModuleManagement.deleteSoftwareModule(deleted.getId());
|
||||
|
||||
@@ -484,8 +484,6 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
*/
|
||||
private void checkTargetHasTags(final boolean strict, final Iterable<Target> targets, final TargetTag... tags) {
|
||||
_target: for (final Target tl : targets) {
|
||||
final Target t = targetManagement.findTargetByControllerID(tl.getControllerId()).get();
|
||||
|
||||
for (final Tag tt : tagManagement.findAllTargetTags(PAGE, tl.getControllerId())) {
|
||||
for (final Tag tag : tags) {
|
||||
if (tag.getName().equals(tt.getName())) {
|
||||
@@ -502,7 +500,7 @@ public class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
private void checkTargetHasNotTags(final Iterable<Target> targets, final TargetTag... tags) {
|
||||
for (final Target tl : targets) {
|
||||
final Target t = targetManagement.findTargetByControllerID(tl.getControllerId()).get();
|
||||
targetManagement.findTargetByControllerID(tl.getControllerId()).get();
|
||||
|
||||
for (final Tag tag : tags) {
|
||||
for (final Tag tt : tagManagement.findAllTargetTags(PAGE, tl.getControllerId())) {
|
||||
|
||||
@@ -315,8 +315,8 @@ public class RSQLUtilityTest {
|
||||
.thenReturn(mock(Predicate.class));
|
||||
|
||||
// test
|
||||
final Predicate result = RSQLUtility.parse(correctRsql, TestFieldEnum.class, setupMacroLookup())
|
||||
.toPredicate(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock);
|
||||
RSQLUtility.parse(correctRsql, TestFieldEnum.class, setupMacroLookup()).toPredicate(baseSoftwareModuleRootMock,
|
||||
criteriaQueryMock, criteriaBuilderMock);
|
||||
|
||||
// verification
|
||||
verify(macroResolver).lookup(overdueProp);
|
||||
|
||||
@@ -14,8 +14,6 @@ import static org.junit.Assert.assertThat;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.powermock.api.mockito.PowerMockito.mockStatic;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
import org.apache.commons.lang3.text.StrSubstitutor;
|
||||
import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
|
||||
import org.eclipse.hawkbit.repository.TimestampCalculator;
|
||||
@@ -48,8 +46,6 @@ public class VirtualPropertyResolverTest {
|
||||
|
||||
private StrSubstitutor substitutor;
|
||||
|
||||
private Long nowTestTime;
|
||||
|
||||
private static final TenantConfigurationValue<String> TEST_POLLING_TIME_INTERVAL = TenantConfigurationValue
|
||||
.<String> builder().value("00:05:00").build();
|
||||
private static final TenantConfigurationValue<String> TEST_POLLING_OVERDUE_TIME_INTERVAL = TenantConfigurationValue
|
||||
@@ -57,7 +53,6 @@ public class VirtualPropertyResolverTest {
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
nowTestTime = Instant.now().toEpochMilli();
|
||||
when(confMgmt.getConfigurationValue(TenantConfigurationKey.POLLING_TIME_INTERVAL, String.class))
|
||||
.thenReturn(TEST_POLLING_TIME_INTERVAL);
|
||||
when(confMgmt.getConfigurationValue(TenantConfigurationKey.POLLING_OVERDUE_TIME_INTERVAL, String.class))
|
||||
|
||||
Reference in New Issue
Block a user