Fix SonarQube issues (3) (#2206)
Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -31,7 +31,6 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import jakarta.validation.ConstraintViolationException;
|
||||
@@ -40,7 +39,6 @@ import io.qameta.allure.Description;
|
||||
import io.qameta.allure.Feature;
|
||||
import io.qameta.allure.Step;
|
||||
import io.qameta.allure.Story;
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
import org.apache.commons.lang3.RandomUtils;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.eclipse.hawkbit.im.authentication.SpPermission;
|
||||
@@ -805,7 +803,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("register target with too long controllerId should fail")
|
||||
.isThrownBy(() -> controllerManagement.findOrRegisterTargetIfItDoesNotExist(
|
||||
RandomStringUtils.randomAlphabetic(Target.CONTROLLER_ID_MAX_SIZE + 1), LOCALHOST));
|
||||
randomString(Target.CONTROLLER_ID_MAX_SIZE + 1), LOCALHOST));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -31,7 +31,6 @@ import io.qameta.allure.Description;
|
||||
import io.qameta.allure.Feature;
|
||||
import io.qameta.allure.Step;
|
||||
import io.qameta.allure.Story;
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
import org.assertj.core.api.Condition;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.RepositoryProperties;
|
||||
@@ -978,7 +977,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("entity with too long description should not be created")
|
||||
.isThrownBy(() -> distributionSetManagement.create(entityFactory.distributionSet().create().name("a")
|
||||
.version("a").description(RandomStringUtils.randomAlphanumeric(513))));
|
||||
.version("a").description(randomString(513))));
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("entity with invalid description should not be created")
|
||||
@@ -988,7 +987,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("entity with too long description should not be updated")
|
||||
.isThrownBy(() -> distributionSetManagement.update(entityFactory.distributionSet().update(set.getId())
|
||||
.description(RandomStringUtils.randomAlphanumeric(513))));
|
||||
.description(randomString(513))));
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("entity with invalid characters should not be updated").isThrownBy(() -> distributionSetManagement
|
||||
@@ -1000,8 +999,9 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("entity with too long name should not be created")
|
||||
.isThrownBy(() -> distributionSetManagement.create(entityFactory.distributionSet().create().version("a")
|
||||
.name(RandomStringUtils.randomAlphanumeric(NamedEntity.NAME_MAX_SIZE + 1))));
|
||||
.isThrownBy(() -> distributionSetManagement.create(entityFactory.distributionSet().create()
|
||||
.version("a")
|
||||
.name(randomString(NamedEntity.NAME_MAX_SIZE + 1))));
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("entity with too short name should not be created").isThrownBy(() -> distributionSetManagement
|
||||
@@ -1015,7 +1015,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("entity with too long name should not be updated")
|
||||
.isThrownBy(() -> distributionSetManagement.update(entityFactory.distributionSet().update(set.getId())
|
||||
.name(RandomStringUtils.randomAlphanumeric(NamedEntity.NAME_MAX_SIZE + 1))));
|
||||
.name(randomString(NamedEntity.NAME_MAX_SIZE + 1))));
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("entity with invalid characters should not be updated").isThrownBy(() -> distributionSetManagement
|
||||
@@ -1033,7 +1033,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("entity with too long version should not be created")
|
||||
.isThrownBy(() -> distributionSetManagement.create(entityFactory.distributionSet().create().name("a")
|
||||
.version(RandomStringUtils.randomAlphanumeric(NamedVersionedEntity.VERSION_MAX_SIZE + 1))));
|
||||
.version(randomString(NamedVersionedEntity.VERSION_MAX_SIZE + 1))));
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("entity with too short version should not be created").isThrownBy(() -> distributionSetManagement
|
||||
@@ -1042,7 +1042,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("entity with too long version should not be updated")
|
||||
.isThrownBy(() -> distributionSetManagement.update(entityFactory.distributionSet().update(set.getId())
|
||||
.version(RandomStringUtils.randomAlphanumeric(NamedVersionedEntity.VERSION_MAX_SIZE + 1))));
|
||||
.version(randomString(NamedVersionedEntity.VERSION_MAX_SIZE + 1))));
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("entity with too short version should not be updated").isThrownBy(() -> distributionSetManagement
|
||||
|
||||
@@ -25,7 +25,6 @@ import io.qameta.allure.Description;
|
||||
import io.qameta.allure.Feature;
|
||||
import io.qameta.allure.Step;
|
||||
import io.qameta.allure.Story;
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.builder.SoftwareModuleTypeCreate;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetCreatedEvent;
|
||||
@@ -50,13 +49,13 @@ import org.junit.jupiter.api.Test;
|
||||
*/
|
||||
@Feature("Component Tests - Repository")
|
||||
@Story("DistributionSet Management")
|
||||
public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
@Test
|
||||
@Description("Verifies that management get access react as specfied on calls for non existing entities by means "
|
||||
+ "of Optional not present.")
|
||||
@ExpectEvents({ @Expect(type = DistributionSetCreatedEvent.class, count = 0) })
|
||||
public void nonExistingEntityAccessReturnsNotPresent() {
|
||||
void nonExistingEntityAccessReturnsNotPresent() {
|
||||
assertThat(distributionSetTypeManagement.get(NOT_EXIST_IDL)).isNotPresent();
|
||||
assertThat(distributionSetTypeManagement.findByKey(NOT_EXIST_ID)).isNotPresent();
|
||||
assertThat(distributionSetTypeManagement.findByName(NOT_EXIST_ID)).isNotPresent();
|
||||
@@ -68,7 +67,7 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
|
||||
@ExpectEvents({
|
||||
@Expect(type = DistributionSetCreatedEvent.class, count = 0),
|
||||
@Expect(type = DistributionSetTypeCreatedEvent.class, count = 1) })
|
||||
public void entityQueriesReferringToNotExistingEntitiesThrowsException() {
|
||||
void entityQueriesReferringToNotExistingEntitiesThrowsException() {
|
||||
|
||||
final List<Long> softwareModuleTypes = Collections.singletonList(osType.getId());
|
||||
|
||||
@@ -98,7 +97,7 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
|
||||
@Expect(type = DistributionSetCreatedEvent.class, count = 1),
|
||||
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
|
||||
@Expect(type = DistributionSetUpdatedEvent.class, count = 0) })
|
||||
public void createAndUpdateDistributionSetWithInvalidFields() {
|
||||
void createAndUpdateDistributionSetWithInvalidFields() {
|
||||
final DistributionSet set = testdataFactory.createDistributionSet();
|
||||
|
||||
createAndUpdateDistributionSetWithInvalidDescription(set);
|
||||
@@ -108,7 +107,7 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
|
||||
|
||||
@Test
|
||||
@Description("Tests the successful module update of unused distribution set type which is in fact allowed.")
|
||||
public void updateUnassignedDistributionSetTypeModules() {
|
||||
void updateUnassignedDistributionSetTypeModules() {
|
||||
final DistributionSetType updatableType = distributionSetTypeManagement
|
||||
.create(entityFactory.distributionSetType().create().key("updatableType").name("to be deleted"));
|
||||
assertThat(distributionSetTypeManagement.findByKey("updatableType").get().getMandatoryModuleTypes()).isEmpty();
|
||||
@@ -133,7 +132,7 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
|
||||
|
||||
@Test
|
||||
@Description("Verifies that the quota for software module types per distribution set type is enforced as expected.")
|
||||
public void quotaMaxSoftwareModuleTypes() {
|
||||
void quotaMaxSoftwareModuleTypes() {
|
||||
final int quota = quotaManagement.getMaxSoftwareModuleTypesPerDistributionSetType();
|
||||
// create software module types
|
||||
final List<Long> moduleTypeIds = new ArrayList<>();
|
||||
@@ -180,7 +179,7 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
|
||||
|
||||
@Test
|
||||
@Description("Tests the successfull update of used distribution set type meta data which is in fact allowed.")
|
||||
public void updateAssignedDistributionSetTypeMetaData() {
|
||||
void updateAssignedDistributionSetTypeMetaData() {
|
||||
final DistributionSetType nonUpdatableType = createDistributionSetTypeUsedByDs();
|
||||
|
||||
distributionSetTypeManagement.update(
|
||||
@@ -193,7 +192,7 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
|
||||
|
||||
@Test
|
||||
@Description("Tests the unsuccessfull update of used distribution set type (module addition).")
|
||||
public void addModuleToAssignedDistributionSetTypeFails() {
|
||||
void addModuleToAssignedDistributionSetTypeFails() {
|
||||
final DistributionSetType nonUpdatableType = createDistributionSetTypeUsedByDs();
|
||||
|
||||
assertThatThrownBy(() -> distributionSetTypeManagement
|
||||
@@ -203,7 +202,7 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
|
||||
|
||||
@Test
|
||||
@Description("Tests the unsuccessfull update of used distribution set type (module removal).")
|
||||
public void removeModuleToAssignedDistributionSetTypeFails() {
|
||||
void removeModuleToAssignedDistributionSetTypeFails() {
|
||||
DistributionSetType nonUpdatableType = distributionSetTypeManagement
|
||||
.create(entityFactory.distributionSetType().create().key("updatableType").name("to be deleted"));
|
||||
assertThat(distributionSetTypeManagement.findByKey("updatableType").get().getMandatoryModuleTypes()).isEmpty();
|
||||
@@ -220,7 +219,7 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
|
||||
|
||||
@Test
|
||||
@Description("Tests the successfull deletion of unused (hard delete) distribution set types.")
|
||||
public void deleteUnassignedDistributionSetType() {
|
||||
void deleteUnassignedDistributionSetType() {
|
||||
final JpaDistributionSetType hardDelete = (JpaDistributionSetType) distributionSetTypeManagement
|
||||
.create(entityFactory.distributionSetType().create().key("delete").name("to be deleted"));
|
||||
|
||||
@@ -232,7 +231,7 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
|
||||
|
||||
@Test
|
||||
@Description("Tests the successfull deletion of used (soft delete) distribution set types.")
|
||||
public void deleteAssignedDistributionSetType() {
|
||||
void deleteAssignedDistributionSetType() {
|
||||
final int existing = (int) distributionSetTypeManagement.count();
|
||||
final JpaDistributionSetType toBeDeleted = (JpaDistributionSetType) distributionSetTypeManagement
|
||||
.create(entityFactory.distributionSetType().create().key("softdeleted").name("to be deleted"));
|
||||
@@ -252,7 +251,7 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
|
||||
|
||||
@Test
|
||||
@Description("Verifies that when no SoftwareModules are assigned to a Distribution then the DistributionSet is not complete.")
|
||||
public void shouldFailWhenDistributionSetHasNoSoftwareModulesAssigned() {
|
||||
void shouldFailWhenDistributionSetHasNoSoftwareModulesAssigned() {
|
||||
|
||||
final JpaDistributionSetType jpaDistributionSetType = (JpaDistributionSetType) distributionSetTypeManagement
|
||||
.create(entityFactory.distributionSetType().create().key("newType").name("new Type"));
|
||||
@@ -271,7 +270,7 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("set with too long description should not be created")
|
||||
.isThrownBy(() -> distributionSetManagement.create(entityFactory.distributionSet().create().name("a")
|
||||
.version("a").description(RandomStringUtils.randomAlphanumeric(513))));
|
||||
.version("a").description(randomString(513))));
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("set invalid description text should not be created")
|
||||
@@ -281,7 +280,7 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("set with too long description should not be updated")
|
||||
.isThrownBy(() -> distributionSetManagement.update(entityFactory.distributionSet().update(set.getId())
|
||||
.description(RandomStringUtils.randomAlphanumeric(513))));
|
||||
.description(randomString(513))));
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("set with invalid description should not be updated").isThrownBy(() -> distributionSetManagement
|
||||
@@ -294,7 +293,7 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class).as("set with too long name should not be created")
|
||||
.isThrownBy(() -> distributionSetManagement.create(entityFactory.distributionSet().create().version("a")
|
||||
.name(RandomStringUtils.randomAlphanumeric(NamedEntity.NAME_MAX_SIZE + 1))));
|
||||
.name(randomString(NamedEntity.NAME_MAX_SIZE + 1))));
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class).as("set with invalid name should not be created")
|
||||
.isThrownBy(() -> distributionSetManagement
|
||||
@@ -310,7 +309,7 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class).as("set with too long name should not be updated")
|
||||
.isThrownBy(() -> distributionSetManagement.update(entityFactory.distributionSet().update(set.getId())
|
||||
.name(RandomStringUtils.randomAlphanumeric(NamedEntity.NAME_MAX_SIZE + 1))));
|
||||
.name(randomString(NamedEntity.NAME_MAX_SIZE + 1))));
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class).as("set with invalid name should not be updated")
|
||||
.isThrownBy(() -> distributionSetManagement
|
||||
@@ -327,7 +326,7 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("set with too long version should not be created")
|
||||
.isThrownBy(() -> distributionSetManagement.create(entityFactory.distributionSet().create().name("a")
|
||||
.version(RandomStringUtils.randomAlphanumeric(NamedVersionedEntity.VERSION_MAX_SIZE + 1))));
|
||||
.version(randomString(NamedVersionedEntity.VERSION_MAX_SIZE + 1))));
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("set with invalid version should not be created").isThrownBy(() -> distributionSetManagement
|
||||
@@ -344,7 +343,7 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("set with too long version should not be updated")
|
||||
.isThrownBy(() -> distributionSetManagement.update(entityFactory.distributionSet().update(set.getId())
|
||||
.version(RandomStringUtils.randomAlphanumeric(NamedVersionedEntity.VERSION_MAX_SIZE + 1))));
|
||||
.version(randomString(NamedVersionedEntity.VERSION_MAX_SIZE + 1))));
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("set with invalid version should not be updated").isThrownBy(() -> distributionSetManagement
|
||||
|
||||
@@ -27,7 +27,6 @@ import io.qameta.allure.Description;
|
||||
import io.qameta.allure.Feature;
|
||||
import io.qameta.allure.Step;
|
||||
import io.qameta.allure.Story;
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
import org.eclipse.hawkbit.repository.TargetTagManagement;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.DistributionSetTagUpdatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.TargetCreatedEvent;
|
||||
@@ -239,7 +238,7 @@ class TargetTagManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("tag with too long description should not be created")
|
||||
.isThrownBy(() -> targetTagManagement.create(
|
||||
entityFactory.tag().create().name("a").description(RandomStringUtils.randomAlphanumeric(513))));
|
||||
entityFactory.tag().create().name("a").description(randomString(513))));
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("tag with invalid description should not be created").isThrownBy(() -> targetTagManagement
|
||||
.create(entityFactory.tag().create().name("a").description(INVALID_TEXT_HTML)));
|
||||
@@ -247,7 +246,7 @@ class TargetTagManagementTest extends AbstractJpaIntegrationTest {
|
||||
.as("tag with too long description should not be updated")
|
||||
.isThrownBy(() -> targetTagManagement.update(
|
||||
entityFactory.tag().update(tag.getId())
|
||||
.description(RandomStringUtils.randomAlphanumeric(513))));
|
||||
.description(randomString(513))));
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("tag with invalid description should not be updated")
|
||||
.isThrownBy(() -> targetTagManagement
|
||||
@@ -259,14 +258,14 @@ class TargetTagManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("tag with too long colour should not be created")
|
||||
.isThrownBy(() -> targetTagManagement.create(
|
||||
entityFactory.tag().create().name("a").colour(RandomStringUtils.randomAlphanumeric(17))));
|
||||
entityFactory.tag().create().name("a").colour(randomString(17))));
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("tag with invalid colour should not be created").isThrownBy(() -> targetTagManagement
|
||||
.create(entityFactory.tag().create().name("a").colour(INVALID_TEXT_HTML)));
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("tag with too long colour should not be updated")
|
||||
.isThrownBy(() -> targetTagManagement.update(
|
||||
entityFactory.tag().update(tag.getId()).colour(RandomStringUtils.randomAlphanumeric(17))));
|
||||
entityFactory.tag().update(tag.getId()).colour(randomString(17))));
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("tag with invalid colour should not be updated").isThrownBy(() -> targetTagManagement
|
||||
.update(entityFactory.tag().update(tag.getId()).colour(INVALID_TEXT_HTML)));
|
||||
@@ -277,16 +276,14 @@ class TargetTagManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("tag with too long name should not be created")
|
||||
.isThrownBy(() -> targetTagManagement
|
||||
.create(entityFactory.tag().create().name(RandomStringUtils.randomAlphanumeric(
|
||||
NamedEntity.NAME_MAX_SIZE + 1))));
|
||||
.create(entityFactory.tag().create().name(randomString(NamedEntity.NAME_MAX_SIZE + 1))));
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("tag with invalidname should not be created")
|
||||
.isThrownBy(() -> targetTagManagement.create(entityFactory.tag().create().name(INVALID_TEXT_HTML)));
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("tag with too long name should not be updated")
|
||||
.isThrownBy(() -> targetTagManagement
|
||||
.update(entityFactory.tag().update(tag.getId()).name(RandomStringUtils.randomAlphanumeric(
|
||||
NamedEntity.NAME_MAX_SIZE + 1))));
|
||||
.update(entityFactory.tag().update(tag.getId()).name(randomString(NamedEntity.NAME_MAX_SIZE + 1))));
|
||||
assertThatExceptionOfType(ConstraintViolationException.class).as("tag with invalid name should not be updated")
|
||||
.isThrownBy(() -> targetTagManagement
|
||||
.update(entityFactory.tag().update(tag.getId()).name(INVALID_TEXT_HTML)));
|
||||
|
||||
@@ -22,7 +22,6 @@ import io.qameta.allure.Description;
|
||||
import io.qameta.allure.Feature;
|
||||
import io.qameta.allure.Step;
|
||||
import io.qameta.allure.Story;
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.TargetTypeCreatedEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.TargetTypeUpdatedEvent;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
|
||||
@@ -78,8 +77,7 @@ class TargetTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("targetType with too long description should not be created")
|
||||
.isThrownBy(() -> targetTypeManagement.create(
|
||||
entityFactory.targetType().create().name("a").description(
|
||||
RandomStringUtils.randomAlphanumeric(TargetType.DESCRIPTION_MAX_SIZE + 1))));
|
||||
entityFactory.targetType().create().name("a").description(randomString(TargetType.DESCRIPTION_MAX_SIZE + 1))));
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("targetType with invalid description should not be created").isThrownBy(() -> targetTypeManagement
|
||||
@@ -88,8 +86,7 @@ class TargetTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("targetType with too long description should not be updated")
|
||||
.isThrownBy(() -> targetTypeManagement.update(
|
||||
entityFactory.targetType().update(targetType.getId()).description(
|
||||
RandomStringUtils.randomAlphanumeric(TargetType.DESCRIPTION_MAX_SIZE + 1))));
|
||||
entityFactory.targetType().update(targetType.getId()).description(randomString(TargetType.DESCRIPTION_MAX_SIZE + 1))));
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("targetType with invalid description should not be updated")
|
||||
@@ -213,8 +210,7 @@ class TargetTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("targetType with too long colour should not be created")
|
||||
.isThrownBy(() -> targetTypeManagement.create(
|
||||
entityFactory.targetType().create().name("a")
|
||||
.colour(RandomStringUtils.randomAlphanumeric(Type.COLOUR_MAX_SIZE + 1))));
|
||||
entityFactory.targetType().create().name("a").colour(randomString(Type.COLOUR_MAX_SIZE + 1))));
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("targetType with invalid colour should not be created").isThrownBy(() -> targetTypeManagement
|
||||
@@ -223,8 +219,7 @@ class TargetTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("targetType with too long colour should not be updated")
|
||||
.isThrownBy(() -> targetTypeManagement.update(
|
||||
entityFactory.targetType().update(targetType.getId())
|
||||
.colour(RandomStringUtils.randomAlphanumeric(Type.COLOUR_MAX_SIZE + 1))));
|
||||
entityFactory.targetType().update(targetType.getId()).colour(randomString(Type.COLOUR_MAX_SIZE + 1))));
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("targetType with invalid colour should not be updated").isThrownBy(() -> targetTypeManagement
|
||||
@@ -235,9 +230,7 @@ class TargetTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
private void createTargetTypeWithInvalidKey() {
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("targetType with too long key should not be created")
|
||||
.isThrownBy(() -> targetTypeManagement
|
||||
.create(entityFactory.targetType().create().name(RandomStringUtils.randomAlphanumeric(
|
||||
Type.KEY_MAX_SIZE + 1))));
|
||||
.isThrownBy(() -> targetTypeManagement.create(entityFactory.targetType().create().name(randomString(Type.KEY_MAX_SIZE + 1))));
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("targetType with invalid key should not be created").isThrownBy(
|
||||
@@ -249,8 +242,7 @@ class TargetTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("targetType with too long name should not be created")
|
||||
.isThrownBy(() -> targetTypeManagement
|
||||
.create(entityFactory.targetType().create().name(RandomStringUtils.randomAlphanumeric(
|
||||
NamedEntity.NAME_MAX_SIZE + 1))));
|
||||
.create(entityFactory.targetType().create().name(randomString(NamedEntity.NAME_MAX_SIZE + 1))));
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("targetType with invalid name should not be created").isThrownBy(
|
||||
@@ -259,8 +251,7 @@ class TargetTypeManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("targetType with too long name should not be updated")
|
||||
.isThrownBy(() -> targetTypeManagement
|
||||
.update(entityFactory.targetType().update(targetType.getId()).name(RandomStringUtils.randomAlphanumeric(
|
||||
NamedEntity.NAME_MAX_SIZE + 1))));
|
||||
.update(entityFactory.targetType().update(targetType.getId()).name(randomString(NamedEntity.NAME_MAX_SIZE + 1))));
|
||||
|
||||
assertThatExceptionOfType(ConstraintViolationException.class)
|
||||
.as("targetType with invalid name should not be updated").isThrownBy(() -> targetTypeManagement
|
||||
|
||||
@@ -107,7 +107,8 @@ import org.springframework.test.context.TestPropertySource;
|
||||
// Cleaning repository will fire "delete" events. We won't count them to the
|
||||
// test execution. So, the order execution between EventVerifier and Cleanup is
|
||||
// important!
|
||||
@TestExecutionListeners(listeners = { EventVerifier.class, CleanupTestExecutionListener.class },
|
||||
@TestExecutionListeners(
|
||||
listeners = { EventVerifier.class, CleanupTestExecutionListener.class },
|
||||
mergeMode = MergeMode.MERGE_WITH_DEFAULTS)
|
||||
@TestPropertySource(properties = "spring.main.allow-bean-definition-overriding=true")
|
||||
public abstract class AbstractIntegrationTest {
|
||||
|
||||
Reference in New Issue
Block a user