Feature/remove junit5 leftovers (#1097)
* Migrate JUnit4 leftovers to JUnit5 Signed-off-by: Florian Ruschbaschan <Florian.Ruschbaschan@bosch.io> * Fix method name typos Signed-off-by: Florian Ruschbaschan <Florian.Ruschbaschan@bosch.io> * Avoid unnecessary Mockito stubbings Signed-off-by: Florian Ruschbaschan <Florian.Ruschbaschan@bosch.io> * Replace assertThrows by assertThatExceptionOfType, fix test TODO Signed-off-by: Florian Ruschbaschan <Florian.Ruschbaschan@bosch.io>
This commit is contained in:
committed by
GitHub
parent
84740a2b1c
commit
41922b6dca
@@ -8,7 +8,7 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.event.remote;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@ import java.util.Arrays;
|
||||
import io.qameta.allure.Description;
|
||||
import io.qameta.allure.Feature;
|
||||
import io.qameta.allure.Story;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
package org.eclipse.hawkbit.repository.event.remote.entity;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -10,8 +10,7 @@ package org.eclipse.hawkbit.repository.jpa;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
@@ -259,8 +258,7 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.eclipse.hawkbit.repository.ArtifactManagement#delete(long)}
|
||||
* .
|
||||
* {@link org.eclipse.hawkbit.repository.ArtifactManagement#delete(long)} .
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
@@ -452,12 +450,9 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
||||
@WithUser(allSpPermissions = true, removeFromAllPermission = { SpPermission.DOWNLOAD_REPOSITORY_ARTIFACT })
|
||||
@Description("Trys and fails to load an artifact without required permission. Checks if expected InsufficientPermissionException is thrown.")
|
||||
public void loadArtifactBinaryWithoutDownloadArtifactThrowsPermissionDenied() {
|
||||
try {
|
||||
artifactManagement.loadArtifactBinary("123");
|
||||
fail("Should not have worked with missing permission.");
|
||||
} catch (final InsufficientPermissionException e) {
|
||||
|
||||
}
|
||||
assertThatExceptionOfType(InsufficientPermissionException.class)
|
||||
.as("Should not have worked with missing permission.")
|
||||
.isThrownBy(() -> artifactManagement.loadArtifactBinary("123"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -527,8 +522,8 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
|
||||
throws IOException {
|
||||
try (final InputStream inputStream = artifactManagement.loadArtifactBinary(artifact.get().getHashes().getSha1())
|
||||
.get().getFileInputStream()) {
|
||||
assertTrue("The stored binary matches the given binary",
|
||||
IOUtils.contentEquals(new ByteArrayInputStream(randomBytes), inputStream));
|
||||
assertTrue(IOUtils.contentEquals(new ByteArrayInputStream(randomBytes), inputStream),
|
||||
"The stored binary matches the given binary");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,8 +10,7 @@ package org.eclipse.hawkbit.repository.jpa;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.util.AbstractMap.SimpleEntry;
|
||||
import java.util.ArrayList;
|
||||
@@ -433,11 +432,9 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(actionStatusRepository.findAll()).as("wrong size of action status").hasSize(4);
|
||||
|
||||
// force quit assignment
|
||||
try {
|
||||
deploymentManagement.forceQuitAction(assigningAction.getId());
|
||||
fail("expected ForceQuitActionNotAllowedException");
|
||||
} catch (final ForceQuitActionNotAllowedException ex) {
|
||||
}
|
||||
assertThatExceptionOfType(ForceQuitActionNotAllowedException.class)
|
||||
.as("expected ForceQuitActionNotAllowedException")
|
||||
.isThrownBy(() -> deploymentManagement.forceQuitAction(assigningAction.getId()));
|
||||
}
|
||||
|
||||
private JpaAction assignSet(final Target target, final DistributionSet ds) {
|
||||
@@ -482,8 +479,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
assertThat(actionRepository.count()).isEqualTo(20);
|
||||
assertThat(actionRepository.findByDistributionSetId(PAGE, ds.getId())).as("Offline actions are not active")
|
||||
.allMatch(action -> !action.isActive())
|
||||
.as("Actions should be initiated by current user")
|
||||
.allMatch(action -> !action.isActive()).as("Actions should be initiated by current user")
|
||||
.allMatch(a -> a.getInitiatedBy().equals(tenantAware.getCurrentUsername()));
|
||||
|
||||
assertThat(targetManagement.findByInstalledDistributionSet(PAGE, ds.getId()).getContent())
|
||||
@@ -928,11 +924,9 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
final DistributionSet incomplete = distributionSetManagement.create(entityFactory.distributionSet().create()
|
||||
.name("incomplete").version("v1").type(standardDsType).modules(Collections.singletonList(ah.getId())));
|
||||
|
||||
try {
|
||||
assignDistributionSet(incomplete, targets);
|
||||
fail("expected IncompleteDistributionSetException");
|
||||
} catch (final IncompleteDistributionSetException ex) {
|
||||
}
|
||||
assertThatExceptionOfType(IncompleteDistributionSetException.class)
|
||||
.as("expected IncompleteDistributionSetException")
|
||||
.isThrownBy(() -> assignDistributionSet(incomplete, targets));
|
||||
|
||||
final DistributionSet nowComplete = distributionSetManagement.assignSoftwareModules(incomplete.getId(),
|
||||
Sets.newHashSet(os.getId()));
|
||||
@@ -1224,32 +1218,35 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
targ = targetManagement.getByControllerID(targ.getControllerId()).get();
|
||||
|
||||
assertEquals("active target actions are wrong", 0,
|
||||
deploymentManagement.findActiveActionsByTarget(PAGE, targ.getControllerId()).getTotalElements());
|
||||
assertEquals("active actions are wrong", 1,
|
||||
deploymentManagement.findInActiveActionsByTarget(PAGE, targ.getControllerId()).getTotalElements());
|
||||
assertEquals(0, deploymentManagement.findActiveActionsByTarget(PAGE, targ.getControllerId()).getTotalElements(),
|
||||
"active target actions are wrong");
|
||||
assertEquals(1,
|
||||
deploymentManagement.findInActiveActionsByTarget(PAGE, targ.getControllerId()).getTotalElements(),
|
||||
"active actions are wrong");
|
||||
|
||||
assertEquals("tagret update status is not correct", TargetUpdateStatus.IN_SYNC, targ.getUpdateStatus());
|
||||
assertEquals("wrong assigned ds", dsA,
|
||||
deploymentManagement.getAssignedDistributionSet(targ.getControllerId()).get());
|
||||
assertEquals("wrong installed ds", dsA,
|
||||
deploymentManagement.getInstalledDistributionSet(targ.getControllerId()).get());
|
||||
assertEquals(TargetUpdateStatus.IN_SYNC, targ.getUpdateStatus(), "tagret update status is not correct");
|
||||
assertEquals(dsA, deploymentManagement.getAssignedDistributionSet(targ.getControllerId()).get(),
|
||||
"wrong assigned ds");
|
||||
assertEquals(dsA, deploymentManagement.getInstalledDistributionSet(targ.getControllerId()).get(),
|
||||
"wrong installed ds");
|
||||
|
||||
targs = assignDistributionSet(dsB.getId(), "target-id-A").getAssignedEntity().stream().map(Action::getTarget)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
targ = targs.iterator().next();
|
||||
|
||||
assertEquals("active actions are wrong", 1,
|
||||
deploymentManagement.findActiveActionsByTarget(PAGE, targ.getControllerId()).getTotalElements());
|
||||
assertEquals("target status is wrong", TargetUpdateStatus.PENDING,
|
||||
targetManagement.getByControllerID(targ.getControllerId()).get().getUpdateStatus());
|
||||
assertEquals("wrong assigned ds", dsB,
|
||||
deploymentManagement.getAssignedDistributionSet(targ.getControllerId()).get());
|
||||
assertEquals("Installed ds is wrong", dsA.getId(),
|
||||
deploymentManagement.getInstalledDistributionSet(targ.getControllerId()).get().getId());
|
||||
assertEquals("Active ds is wrong", dsB, deploymentManagement
|
||||
.findActiveActionsByTarget(PAGE, targ.getControllerId()).getContent().get(0).getDistributionSet());
|
||||
assertEquals(1, deploymentManagement.findActiveActionsByTarget(PAGE, targ.getControllerId()).getTotalElements(),
|
||||
"active actions are wrong");
|
||||
assertEquals(TargetUpdateStatus.PENDING,
|
||||
targetManagement.getByControllerID(targ.getControllerId()).get().getUpdateStatus(),
|
||||
"target status is wrong");
|
||||
assertEquals(dsB, deploymentManagement.getAssignedDistributionSet(targ.getControllerId()).get(),
|
||||
"wrong assigned ds");
|
||||
assertEquals(dsA.getId(),
|
||||
deploymentManagement.getInstalledDistributionSet(targ.getControllerId()).get().getId(),
|
||||
"Installed ds is wrong");
|
||||
assertEquals(dsB, deploymentManagement.findActiveActionsByTarget(PAGE, targ.getControllerId()).getContent()
|
||||
.get(0).getDistributionSet(), "Active ds is wrong");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
package org.eclipse.hawkbit.repository.jpa;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -19,6 +19,7 @@ import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.hawkbit.repository.DistributionSetTagManagement;
|
||||
import org.eclipse.hawkbit.repository.builder.TagCreate;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetTagUpdatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.TargetCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.TargetTagUpdatedEvent;
|
||||
@@ -107,63 +108,66 @@ public class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest
|
||||
// search for not deleted
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true)
|
||||
.setTagNames(Arrays.asList(tagA.getName()));
|
||||
assertEquals("filter works not correct",
|
||||
dsAs.spliterator().getExactSizeIfKnown() + dsABs.spliterator().getExactSizeIfKnown()
|
||||
assertEquals(dsAs.spliterator().getExactSizeIfKnown() + dsABs.spliterator().getExactSizeIfKnown()
|
||||
+ dsACs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
|
||||
distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getTotalElements());
|
||||
.getTotalElements(),
|
||||
"filter works not correct");
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true)
|
||||
.setTagNames(Arrays.asList(tagB.getName()));
|
||||
assertEquals("filter works not correct",
|
||||
assertEquals(
|
||||
dsBs.spliterator().getExactSizeIfKnown() + dsABs.spliterator().getExactSizeIfKnown()
|
||||
+ dsBCs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
|
||||
distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getTotalElements());
|
||||
.getTotalElements(),
|
||||
"filter works not correct");
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true)
|
||||
.setTagNames(Arrays.asList(tagC.getName()));
|
||||
assertEquals("filter works not correct",
|
||||
dsCs.spliterator().getExactSizeIfKnown() + dsACs.spliterator().getExactSizeIfKnown()
|
||||
assertEquals(dsCs.spliterator().getExactSizeIfKnown() + dsACs.spliterator().getExactSizeIfKnown()
|
||||
+ dsBCs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
|
||||
distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getTotalElements());
|
||||
.getTotalElements(),
|
||||
"filter works not correct");
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true)
|
||||
.setTagNames(Arrays.asList(tagX.getName()));
|
||||
assertEquals("filter works not correct", 0, distributionSetManagement
|
||||
.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build()).getTotalElements());
|
||||
assertEquals(0, distributionSetManagement
|
||||
.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build()).getTotalElements(),
|
||||
"filter works not correct");
|
||||
|
||||
assertEquals("wrong tag size", 5, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown());
|
||||
assertEquals(5, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown(), "wrong tag size");
|
||||
|
||||
distributionSetTagManagement.delete(tagY.getName());
|
||||
assertEquals("wrong tag size", 4, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown());
|
||||
assertEquals(4, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown(), "wrong tag size");
|
||||
distributionSetTagManagement.delete(tagX.getName());
|
||||
assertEquals("wrong tag size", 3, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown());
|
||||
assertEquals(3, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown(), "wrong tag size");
|
||||
|
||||
distributionSetTagManagement.delete(tagB.getName());
|
||||
assertEquals("wrong tag size", 2, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown());
|
||||
assertEquals(2, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown(), "wrong tag size");
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
||||
.setTagNames(Arrays.asList(tagA.getName()));
|
||||
assertEquals("filter works not correct",
|
||||
dsAs.spliterator().getExactSizeIfKnown() + dsABs.spliterator().getExactSizeIfKnown()
|
||||
assertEquals(dsAs.spliterator().getExactSizeIfKnown() + dsABs.spliterator().getExactSizeIfKnown()
|
||||
+ dsACs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
|
||||
distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getTotalElements());
|
||||
.getTotalElements(),
|
||||
"filter works not correct");
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
||||
.setTagNames(Arrays.asList(tagB.getName()));
|
||||
assertEquals("filter works not correct", 0, distributionSetManagement
|
||||
.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build()).getTotalElements());
|
||||
assertEquals(0, distributionSetManagement
|
||||
.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build()).getTotalElements(),
|
||||
"filter works not correct");
|
||||
|
||||
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
|
||||
.setTagNames(Arrays.asList(tagC.getName()));
|
||||
assertEquals("filter works not correct",
|
||||
dsCs.spliterator().getExactSizeIfKnown() + dsACs.spliterator().getExactSizeIfKnown()
|
||||
assertEquals(dsCs.spliterator().getExactSizeIfKnown() + dsACs.spliterator().getExactSizeIfKnown()
|
||||
+ dsBCs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
|
||||
distributionSetManagement.findByDistributionSetFilter(PAGE, distributionSetFilterBuilder.build())
|
||||
.getTotalElements());
|
||||
.getTotalElements(),
|
||||
"filter works not correct");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -252,13 +256,11 @@ public class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest
|
||||
@Test
|
||||
@Description("Ensures that a tag cannot be created if one exists already with that name (ecpects EntityAlreadyExistsException).")
|
||||
public void failedDuplicateDsTagNameException() {
|
||||
distributionSetTagManagement.create(entityFactory.tag().create().name("A"));
|
||||
try {
|
||||
distributionSetTagManagement.create(entityFactory.tag().create().name("A"));
|
||||
fail("should not have worked as tag already exists");
|
||||
} catch (final EntityAlreadyExistsException e) {
|
||||
final TagCreate tag = entityFactory.tag().create().name("A");
|
||||
distributionSetTagManagement.create(tag);
|
||||
|
||||
}
|
||||
assertThatExceptionOfType(EntityAlreadyExistsException.class).as("should not have worked as tag already exists")
|
||||
.isThrownBy(() -> distributionSetTagManagement.create(tag));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -267,12 +269,9 @@ public class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest
|
||||
distributionSetTagManagement.create(entityFactory.tag().create().name("A"));
|
||||
final DistributionSetTag tag = distributionSetTagManagement.create(entityFactory.tag().create().name("B"));
|
||||
|
||||
try {
|
||||
distributionSetTagManagement.update(entityFactory.tag().update(tag.getId()).name("A"));
|
||||
fail("should not have worked as tag already exists");
|
||||
} catch (final EntityAlreadyExistsException e) {
|
||||
|
||||
}
|
||||
assertThatExceptionOfType(EntityAlreadyExistsException.class).as("should not have worked as tag already exists")
|
||||
.isThrownBy(
|
||||
() -> distributionSetTagManagement.update(entityFactory.tag().update(tag.getId()).name("A")));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -10,8 +10,7 @@ package org.eclipse.hawkbit.repository.jpa;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
@@ -23,8 +22,8 @@ import java.util.List;
|
||||
import org.apache.commons.lang3.RandomUtils;
|
||||
import org.eclipse.hawkbit.repository.builder.SoftwareModuleMetadataCreate;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.SoftwareModuleCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
|
||||
import org.eclipse.hawkbit.repository.exception.AssignmentQuotaExceededException;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSet;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaSoftwareModuleMetadata;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaTarget;
|
||||
@@ -164,12 +163,9 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Description("Create Software Module call fails when called for existing entity.")
|
||||
public void createModuleCallFailsForExistingModule() {
|
||||
testdataFactory.createSoftwareModuleOs();
|
||||
try {
|
||||
testdataFactory.createSoftwareModuleOs();
|
||||
fail("Should not have worked as module already exists.");
|
||||
} catch (final EntityAlreadyExistsException e) {
|
||||
|
||||
}
|
||||
assertThatExceptionOfType(EntityAlreadyExistsException.class)
|
||||
.as("Should not have worked as module already exists.")
|
||||
.isThrownBy(() -> testdataFactory.createSoftwareModuleOs());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -304,7 +300,7 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
// [VERIFY EXPECTED RESULT]:
|
||||
// verify: assignedModule is marked as deleted
|
||||
assignedModule = softwareModuleManagement.get(assignedModule.getId()).get();
|
||||
assertTrue("The module should be flagged as deleted", assignedModule.isDeleted());
|
||||
assertTrue(assignedModule.isDeleted(), "The module should be flagged as deleted");
|
||||
assertThat(softwareModuleManagement.findAll(PAGE)).hasSize(0);
|
||||
assertThat(softwareModuleRepository.findAll()).hasSize(1);
|
||||
|
||||
@@ -344,7 +340,7 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
// [VERIFY EXPECTED RESULT]:
|
||||
// verify: assignedModule is marked as deleted
|
||||
assignedModule = softwareModuleManagement.get(assignedModule.getId()).get();
|
||||
assertTrue("The found module should be flagged deleted", assignedModule.isDeleted());
|
||||
assertTrue(assignedModule.isDeleted(), "The found module should be flagged deleted");
|
||||
assertThat(softwareModuleManagement.findAll(PAGE)).hasSize(0);
|
||||
assertThat(softwareModuleRepository.findAll()).hasSize(1);
|
||||
|
||||
@@ -451,8 +447,8 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
// verify: SoftwareModuleX and SofwtareModule are marked as deleted
|
||||
assertThat(moduleX).isNotNull();
|
||||
assertThat(moduleY).isNotNull();
|
||||
assertTrue("The module should be flagged deleted", moduleX.isDeleted());
|
||||
assertTrue("The module should be flagged deleted", moduleY.isDeleted());
|
||||
assertTrue(moduleX.isDeleted(), "The module should be flagged deleted");
|
||||
assertTrue(moduleY.isDeleted(), "The module should be flagged deleted");
|
||||
assertThat(softwareModuleManagement.findAll(PAGE)).hasSize(0);
|
||||
assertThat(softwareModuleRepository.findAll()).hasSize(2);
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
package org.eclipse.hawkbit.repository.jpa;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@@ -10,12 +10,11 @@ package org.eclipse.hawkbit.repository.jpa;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -28,11 +27,11 @@ import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetCreated
|
||||
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.TargetFilterQueryCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.exception.AssignmentQuotaExceededException;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
|
||||
import org.eclipse.hawkbit.repository.exception.InvalidAutoAssignActionTypeException;
|
||||
import org.eclipse.hawkbit.repository.exception.InvalidAutoAssignDistributionSetException;
|
||||
import org.eclipse.hawkbit.repository.exception.MultiAssignmentIsNotEnabledException;
|
||||
import org.eclipse.hawkbit.repository.exception.AssignmentQuotaExceededException;
|
||||
import org.eclipse.hawkbit.repository.exception.RSQLParameterUnsupportedFieldException;
|
||||
import org.eclipse.hawkbit.repository.model.Action;
|
||||
import org.eclipse.hawkbit.repository.model.Action.ActionType;
|
||||
@@ -108,8 +107,8 @@ public class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest
|
||||
final String filterName = "new target filter";
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement
|
||||
.create(entityFactory.targetFilterQuery().create().name(filterName).query("name==PendingTargets001"));
|
||||
assertEquals("Retrieved newly created custom target filter", targetFilterQuery,
|
||||
targetFilterQueryManagement.getByName(filterName).get());
|
||||
assertEquals(targetFilterQuery, targetFilterQueryManagement.getByName(filterName).get(),
|
||||
"Retrieved newly created custom target filter");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -139,15 +138,16 @@ public class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest
|
||||
|
||||
final List<TargetFilterQuery> results = targetFilterQueryManagement
|
||||
.findByRsql(PageRequest.of(0, 10), "name==" + filterName).getContent();
|
||||
assertEquals("Search result should have 1 result", 1, results.size());
|
||||
assertEquals("Retrieved newly created custom target filter", targetFilterQuery, results.get(0));
|
||||
assertEquals(1, results.size(), "Search result should have 1 result");
|
||||
assertEquals(targetFilterQuery, results.get(0), "Retrieved newly created custom target filter");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Test searching a target filter query with an invalid filter.")
|
||||
public void searchTargetFilterQueryInvalidField() {
|
||||
Assertions.assertThatExceptionOfType(RSQLParameterUnsupportedFieldException.class).isThrownBy(
|
||||
() -> targetFilterQueryManagement.findByRsql(PageRequest.of(0, 10), "unknownField==testValue").getContent());
|
||||
Assertions.assertThatExceptionOfType(RSQLParameterUnsupportedFieldException.class)
|
||||
.isThrownBy(() -> targetFilterQueryManagement
|
||||
.findByRsql(PageRequest.of(0, 10), "unknownField==testValue").getContent());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -157,13 +157,10 @@ public class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest
|
||||
targetFilterQueryManagement
|
||||
.create(entityFactory.targetFilterQuery().create().name(filterName).query("name==PendingTargets001"));
|
||||
|
||||
try {
|
||||
targetFilterQueryManagement.create(
|
||||
entityFactory.targetFilterQuery().create().name(filterName).query("name==PendingTargets001"));
|
||||
fail("should not have worked as query already exists");
|
||||
} catch (final EntityAlreadyExistsException e) {
|
||||
|
||||
}
|
||||
assertThatExceptionOfType(EntityAlreadyExistsException.class)
|
||||
.as("should not have worked as query already exists")
|
||||
.isThrownBy(() -> targetFilterQueryManagement.create(
|
||||
entityFactory.targetFilterQuery().create().name(filterName).query("name==PendingTargets001")));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -173,9 +170,8 @@ public class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest
|
||||
final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement
|
||||
.create(entityFactory.targetFilterQuery().create().name(filterName).query("name==PendingTargets001"));
|
||||
targetFilterQueryManagement.delete(targetFilterQuery.getId());
|
||||
assertFalse("Returns null as the target filter is deleted",
|
||||
targetFilterQueryManagement.get(targetFilterQuery.getId()).isPresent());
|
||||
|
||||
assertFalse(targetFilterQueryManagement.get(targetFilterQuery.getId()).isPresent(),
|
||||
"Returns null as the target filter is deleted");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -188,9 +184,8 @@ public class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest
|
||||
final String newQuery = "status==UNKNOWN";
|
||||
targetFilterQueryManagement
|
||||
.update(entityFactory.targetFilterQuery().update(targetFilterQuery.getId()).query(newQuery));
|
||||
assertEquals("Returns updated target filter query", newQuery,
|
||||
targetFilterQueryManagement.getByName(filterName).get().getQuery());
|
||||
|
||||
assertEquals(newQuery, targetFilterQueryManagement.getByName(filterName).get().getQuery(),
|
||||
"Returns updated target filter query");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -245,7 +240,6 @@ public class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest
|
||||
final DistributionSet distributionSet) {
|
||||
// assigning a distribution set with TIMEFORCED action is supposed to
|
||||
// fail as only FORCED and SOFT action types are allowed
|
||||
|
||||
assertThatExceptionOfType(InvalidAutoAssignActionTypeException.class)
|
||||
.isThrownBy(() -> targetFilterQueryManagement.updateAutoAssignDS(
|
||||
entityFactory.targetFilterQuery().updateAutoAssign(targetFilterQuery.getId())
|
||||
@@ -278,8 +272,8 @@ public class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest
|
||||
final ActionType actionType) {
|
||||
final TargetFilterQuery tfq = targetFilterQueryManagement.getByName(filterName).get();
|
||||
|
||||
assertEquals("Returns correct distribution set", distributionSet, tfq.getAutoAssignDistributionSet());
|
||||
assertEquals("Return correct action type", actionType, tfq.getAutoAssignActionType());
|
||||
assertEquals(distributionSet, tfq.getAutoAssignDistributionSet(), "Returns correct distribution set");
|
||||
assertEquals(actionType, tfq.getAutoAssignActionType(), "Return correct action type");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -335,16 +329,16 @@ public class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest
|
||||
|
||||
// Check if target filter query is there
|
||||
TargetFilterQuery tfq = targetFilterQueryManagement.getByName(filterName).get();
|
||||
assertEquals("Returns correct distribution set", distributionSet, tfq.getAutoAssignDistributionSet());
|
||||
assertEquals("Return correct action type", ActionType.FORCED, tfq.getAutoAssignActionType());
|
||||
assertEquals(distributionSet, tfq.getAutoAssignDistributionSet(), "Returns correct distribution set");
|
||||
assertEquals(ActionType.FORCED, tfq.getAutoAssignActionType(), "Return correct action type");
|
||||
|
||||
distributionSetManagement.delete(distributionSet.getId());
|
||||
|
||||
// Check if auto assign distribution set is null
|
||||
tfq = targetFilterQueryManagement.getByName(filterName).get();
|
||||
assertNotNull("Returns target filter query", tfq);
|
||||
assertNull("Returns distribution set as null", tfq.getAutoAssignDistributionSet());
|
||||
assertNull("Returns action type as null", tfq.getAutoAssignActionType());
|
||||
assertNotNull(tfq, "Returns target filter query");
|
||||
assertNull(tfq.getAutoAssignDistributionSet(), "Returns distribution set as null");
|
||||
assertNull(tfq.getAutoAssignActionType(), "Returns action type as null");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -366,20 +360,20 @@ public class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest
|
||||
|
||||
// Check if target filter query is there with the distribution set
|
||||
TargetFilterQuery tfq = targetFilterQueryManagement.getByName(filterName).get();
|
||||
assertEquals("Returns correct distribution set", distributionSet, tfq.getAutoAssignDistributionSet());
|
||||
assertEquals("Return correct action type", ActionType.FORCED, tfq.getAutoAssignActionType());
|
||||
assertEquals(distributionSet, tfq.getAutoAssignDistributionSet(), "Returns correct distribution set");
|
||||
assertEquals(ActionType.FORCED, tfq.getAutoAssignActionType(), "Return correct action type");
|
||||
|
||||
distributionSetManagement.delete(distributionSet.getId());
|
||||
|
||||
// Check if distribution set is still in the database with deleted flag
|
||||
assertTrue("Distribution set should be deleted",
|
||||
distributionSetManagement.get(distributionSet.getId()).get().isDeleted());
|
||||
assertTrue(distributionSetManagement.get(distributionSet.getId()).get().isDeleted(),
|
||||
"Distribution set should be deleted");
|
||||
|
||||
// Check if auto assign distribution set is null
|
||||
tfq = targetFilterQueryManagement.getByName(filterName).get();
|
||||
assertNotNull("Returns target filter query", tfq);
|
||||
assertNull("Returns distribution set as null", tfq.getAutoAssignDistributionSet());
|
||||
assertNull("Returns action type as null", tfq.getAutoAssignActionType());
|
||||
assertNotNull(tfq, "Returns target filter query");
|
||||
assertNull(tfq.getAutoAssignDistributionSet(), "Returns distribution set as null");
|
||||
assertNull(tfq.getAutoAssignActionType(), "Returns action type as null");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -10,7 +10,7 @@ package org.eclipse.hawkbit.repository.jpa;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
package org.eclipse.hawkbit.repository.jpa.rsql;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
import org.eclipse.hawkbit.repository.ActionFields;
|
||||
import org.eclipse.hawkbit.repository.exception.RSQLParameterUnsupportedFieldException;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
package org.eclipse.hawkbit.repository.jpa.rsql;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
package org.eclipse.hawkbit.repository.jpa.rsql;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
package org.eclipse.hawkbit.repository.jpa.rsql;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.eclipse.hawkbit.repository.TargetFilterQueryFields;
|
||||
import org.eclipse.hawkbit.repository.jpa.AbstractJpaIntegrationTest;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.jpa.rsql;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
|
||||
@@ -8,9 +8,10 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.jpa.rsql;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import org.apache.commons.lang3.text.StrSubstitutor;
|
||||
|
||||
Reference in New Issue
Block a user