Added support for different version schemes depending on the provider (#2124)

Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2024-12-06 14:40:13 +02:00
committed by GitHub
parent 2a476d1268
commit be6a58a38a
19 changed files with 106 additions and 73 deletions

View File

@@ -97,7 +97,7 @@ class ArtifactFilesystemRepositoryTest {
}
@Test
@Description("Verfies that an artifact which does not exists is deleted quietly in the file-system repository")
@Description("Verifies that an artifact which does not exists is deleted quietly in the file-system repository")
void deleteArtifactWhichDoesNotExistsBySHA1HashWithoutException() throws IOException {
try {
artifactFilesystemRepository.deleteBySha1(TENANT, "sha1HashWhichDoesNotExists");

View File

@@ -14,6 +14,7 @@ import static org.hamcrest.Matchers.equalTo;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtActionType;
import org.eclipse.hawkbit.repository.jpa.JpaConstants;
import org.eclipse.hawkbit.repository.jpa.RepositoryApplicationConfiguration;
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSet;
import org.eclipse.hawkbit.repository.model.BaseEntity;
@@ -201,4 +202,12 @@ public abstract class AbstractManagementApiIntegrationTest extends AbstractRestI
((JpaDistributionSet) set).lock();
}
}
// version is 1, 2 ... based
protected int version(final int version) {
return switch (JpaConstants.JPA_VENDOR) {
case ECLIPSELINK -> version;
case HIBERNATE -> version - 1;
};
}
}

View File

@@ -60,7 +60,7 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt
private static final Random RND = new Random();
@Test
@Description("Verfies that a paged result list of DS tags reflects the content on the repository side.")
@Description("Verifies that a paged result list of DS tags reflects the content on the repository side.")
@ExpectEvents({ @Expect(type = DistributionSetTagCreatedEvent.class, count = 2) })
public void getDistributionSetTags() throws Exception {
final List<DistributionSetTag> tags = testdataFactory.createDistributionSetTags(2);
@@ -132,7 +132,7 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt
}
@Test
@Description("Verfies that a paged result list of DS tags reflects the content on the repository side when filtered by distribution set id field AND tag field.")
@Description("Verifies that a paged result list of DS tags reflects the content on the repository side when filtered by distribution set id field AND tag field.")
public void getDistributionSetTagsByDistributionSetIdAndTagDescription() throws Exception {
final List<DistributionSetTag> tags = testdataFactory.createDistributionSetTags(2);
final DistributionSetTag tag1 = tags.get(0);
@@ -160,7 +160,7 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt
}
@Test
@Description("Verfies that a single result of a DS tag reflects the content on the repository side.")
@Description("Verifies that a single result of a DS tag reflects the content on the repository side.")
@ExpectEvents({ @Expect(type = DistributionSetTagCreatedEvent.class, count = 2) })
public void getDistributionSetTag() throws Exception {
final List<DistributionSetTag> tags = testdataFactory.createDistributionSetTags(2);
@@ -237,7 +237,7 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt
}
@Test
@Description("Verfies that the delete call is reflected by the repository.")
@Description("Verifies that the delete call is reflected by the repository.")
@ExpectEvents({
@Expect(type = DistributionSetTagCreatedEvent.class, count = 1),
@Expect(type = DistributionSetTagDeletedEvent.class, count = 1) })
@@ -320,7 +320,7 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt
}
@Test
@Description("Verfies that tag assignments done through toggle API command are correctly assigned or unassigned.")
@Description("Verifies that tag assignments done through toggle API command are correctly assigned or unassigned.")
@ExpectEvents({
@Expect(type = DistributionSetTagCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 2),

View File

@@ -38,6 +38,7 @@ import org.eclipse.hawkbit.exception.SpServerError;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.eclipse.hawkbit.repository.builder.SoftwareModuleTypeCreate;
import org.eclipse.hawkbit.repository.exception.AssignmentQuotaExceededException;
import org.eclipse.hawkbit.repository.jpa.JpaConstants;
import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.repository.model.NamedEntity;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
@@ -155,7 +156,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
public void addMandatoryModuleToDistributionSetType() throws Exception {
DistributionSetType testType = distributionSetTypeManagement.create(entityFactory.distributionSetType().create()
.key("test123").name("TestName123").description("Desc123").colour("col12"));
assertThat(testType.getOptLockRevision()).isEqualTo(1);
assertThat(testType.getOptLockRevision()).isEqualTo(version(1));
mvc.perform(post("/rest/v1/distributionsettypes/{dstID}/mandatorymoduletypes", testType.getId())
.content("{\"id\":" + osType.getId() + "}").contentType(MediaType.APPLICATION_JSON))
@@ -164,7 +165,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
testType = distributionSetTypeManagement.get(testType.getId()).get();
assertThat(testType.getLastModifiedBy()).isEqualTo("uploadTester");
assertThat(testType.getOptLockRevision()).isEqualTo(2);
assertThat(testType.getOptLockRevision()).isEqualTo(version(2));
assertThat(testType.getMandatoryModuleTypes()).containsExactly(osType);
assertThat(testType.getOptionalModuleTypes()).isEmpty();
}
@@ -175,7 +176,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
public void addOptionalModuleToDistributionSetType() throws Exception {
DistributionSetType testType = distributionSetTypeManagement.create(entityFactory.distributionSetType().create()
.key("test123").name("TestName123").description("Desc123").colour("col12"));
assertThat(testType.getOptLockRevision()).isEqualTo(1);
assertThat(testType.getOptLockRevision()).isEqualTo(version(1));
mvc.perform(post("/rest/v1/distributionsettypes/{dstID}/optionalmoduletypes", testType.getId())
.content("{\"id\":" + osType.getId() + "}").contentType(MediaType.APPLICATION_JSON))
@@ -184,7 +185,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
testType = distributionSetTypeManagement.get(testType.getId()).get();
assertThat(testType.getLastModifiedBy()).isEqualTo("uploadTester");
assertThat(testType.getOptLockRevision()).isEqualTo(2);
assertThat(testType.getOptLockRevision()).isEqualTo(version(2));
assertThat(testType.getOptionalModuleTypes()).containsExactly(osType);
assertThat(testType.getMandatoryModuleTypes()).isEmpty();
@@ -207,7 +208,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
final DistributionSetType testType = distributionSetTypeManagement.create(entityFactory.distributionSetType()
.create().key("testType").name("testType").description("testType").colour("col12"));
assertThat(testType.getOptLockRevision()).isEqualTo(1);
assertThat(testType.getOptLockRevision()).isEqualTo(version(1));
for (int i = 0; i < moduleTypeIds.size() - 1; ++i) {
mvc.perform(post("/rest/v1/distributionsettypes/{dstID}/optionalmoduletypes", testType.getId())
@@ -228,7 +229,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
final DistributionSetType testType2 = distributionSetTypeManagement.create(entityFactory.distributionSetType()
.create().key("testType2").name("testType2").description("testType2").colour("col12"));
assertThat(testType2.getOptLockRevision()).isEqualTo(1);
assertThat(testType2.getOptLockRevision()).isEqualTo(version(1));
for (int i = 0; i < moduleTypeIds.size() - 1; ++i) {
mvc.perform(post("/rest/v1/distributionsettypes/{dstID}/mandatorymoduletypes", testType2.getId())
@@ -331,7 +332,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
testType = distributionSetTypeManagement.get(testType.getId()).get();
assertThat(testType.getLastModifiedBy()).isEqualTo("uploadTester");
assertThat(testType.getOptLockRevision()).isEqualTo(2);
assertThat(testType.getOptLockRevision()).isEqualTo(version(2));
assertThat(testType.getOptionalModuleTypes()).containsExactly(appType);
assertThat(testType.getMandatoryModuleTypes()).isEmpty();
}
@@ -349,7 +350,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
testType = distributionSetTypeManagement.get(testType.getId()).get();
assertThat(testType.getLastModifiedBy()).isEqualTo("uploadTester");
assertThat(testType.getOptLockRevision()).isEqualTo(2);
assertThat(testType.getOptLockRevision()).isEqualTo(version(2));
assertThat(testType.getOptionalModuleTypes()).isEmpty();
assertThat(testType.getMandatoryModuleTypes()).containsExactly(osType);
}
@@ -736,7 +737,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
final DistributionSetType testType = distributionSetTypeManagement.create(entityFactory.distributionSetType()
.create().key("test123").name("TestName123").description("Desc123").colour("col")
.mandatory(Collections.singletonList(osType.getId())).optional(Collections.singletonList(appType.getId())));
assertThat(testType.getOptLockRevision()).isEqualTo(1);
assertThat(testType.getOptLockRevision()).isEqualTo(version(1));
assertThat(testType.getOptionalModuleTypes()).containsExactly(appType);
assertThat(testType.getMandatoryModuleTypes()).containsExactly(osType);
return testType;

View File

@@ -947,7 +947,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
}
@Test
@Description("Verfies that a properties of new targets are validated as in allowed size range.")
@Description("Verifies that a properties of new targets are validated as in allowed size range.")
void createTargetWithInvalidPropertyBadRequest() throws Exception {
final Target test1 = entityFactory.target().create().controllerId("id1")
.name(RandomStringUtils.randomAlphanumeric(NamedEntity.NAME_MAX_SIZE + 1)).build();
@@ -1413,7 +1413,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
}
@Test
@Description("Verfies that an action is switched from soft to forced if requested by management API")
@Description("Verifies that an action is switched from soft to forced if requested by management API")
void updateAction() throws Exception {
final Target target = testdataFactory.createTarget();
final DistributionSet set = testdataFactory.createDistributionSet();
@@ -1516,7 +1516,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
}
@Test
@Description("Verfies that a DOWNLOAD_ONLY DS to target assignment is properly handled")
@Description("Verifies that a DOWNLOAD_ONLY DS to target assignment is properly handled")
void assignDownloadOnlyDistributionSetToTarget() throws Exception {
final Target target = testdataFactory.createTarget();
final DistributionSet set = testdataFactory.createDistributionSet("one");
@@ -1538,7 +1538,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
}
@Test
@Description("Verfies that an offline DS to target assignment is reflected by the repository and that repeating "
@Description("Verifies that an offline DS to target assignment is reflected by the repository and that repeating "
+ "the assignment does not change the target.")
void offlineAssignDistributionSetToTarget() throws Exception {
Target target = testdataFactory.createTarget();

View File

@@ -67,7 +67,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
private static final Random RND = new Random();
@Test
@Description("Verfies that a paged result list of target tags reflects the content on the repository side.")
@Description("Verifies that a paged result list of target tags reflects the content on the repository side.")
@ExpectEvents({ @Expect(type = TargetTagCreatedEvent.class, count = 2) })
public void getTargetTags() throws Exception {
final List<TargetTag> tags = testdataFactory.createTargetTags(2, "");
@@ -130,7 +130,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
}
@Test
@Description("Verfies that a single result of a target tag reflects the content on the repository side.")
@Description("Verifies that a single result of a target tag reflects the content on the repository side.")
@ExpectEvents({ @Expect(type = TargetTagCreatedEvent.class, count = 2) })
public void getTargetTag() throws Exception {
final List<TargetTag> tags = testdataFactory.createTargetTags(2, "");
@@ -208,7 +208,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
}
@Test
@Description("Verfies that the delete call is reflected by the repository.")
@Description("Verifies that the delete call is reflected by the repository.")
@ExpectEvents({
@Expect(type = TargetTagCreatedEvent.class, count = 1),
@Expect(type = TargetTagDeletedEvent.class, count = 1) })
@@ -650,7 +650,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
}
@Test
@Description("Verfies that tag assignments done through tag API command are correctly stored in the repository.")
@Description("Verifies that tag assignments done through tag API command are correctly stored in the repository.")
@ExpectEvents({
@Expect(type = TargetTagCreatedEvent.class, count = 1),
@Expect(type = TargetCreatedEvent.class, count = 2),

View File

@@ -321,7 +321,7 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest {
void addDistributionSetTypeToTargetType() throws Exception {
String typeName = "TestTypeAddDs";
TargetType testType = createTestTargetTypeInDB(typeName);
assertThat(testType.getOptLockRevision()).isEqualTo(1);
assertThat(testType.getOptLockRevision()).isEqualTo(version(1));
mvc.perform(post(TARGETTYPE_DSTYPES_ENDPOINT, testType.getId())
.content("[{\"id\":" + standardDsType.getId() + "}]").contentType(MediaType.APPLICATION_JSON))
@@ -330,7 +330,7 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest {
testType = targetTypeManagement.get(testType.getId()).get();
assertThat(testType.getLastModifiedBy()).isEqualTo(TEST_USER);
assertThat(testType.getOptLockRevision()).isEqualTo(2);
assertThat(testType.getOptLockRevision()).isEqualTo(version(2));
assertThat(testType.getCompatibleDistributionSetTypes()).containsExactly(standardDsType);
}
@@ -380,7 +380,7 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest {
testType = targetTypeManagement.get(testType.getId()).get();
assertThat(testType.getLastModifiedBy()).isEqualTo(TEST_USER);
assertThat(testType.getOptLockRevision()).isEqualTo(2);
assertThat(testType.getOptLockRevision()).isEqualTo(version(2));
assertThat(testType.getCompatibleDistributionSetTypes()).isEmpty();
}
@@ -398,7 +398,7 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest {
testType = targetTypeManagement.get(testType.getId()).get();
assertThat(testType.getLastModifiedBy()).isEqualTo(TEST_USER);
assertThat(testType.getOptLockRevision()).isEqualTo(2);
assertThat(testType.getOptLockRevision()).isEqualTo(version(2));
assertThat(testType.getCompatibleDistributionSetTypes()).isEmpty();
assertThat(distributionSetTypeManagement.getByKey(standardDsType.getKey())).isEmpty();
}
@@ -641,7 +641,7 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest {
@Step
private TargetType createTestTargetTypeInDB(String name, List<DistributionSetType> dsTypes) {
TargetType targetType = testdataFactory.createTargetType(name, dsTypes);
assertThat(targetType.getOptLockRevision()).isEqualTo(1);
assertThat(targetType.getOptLockRevision()).isEqualTo(version(1));
return targetType;
}

View File

@@ -0,0 +1,20 @@
/**
* Copyright (c) 2024 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.hawkbit.repository.jpa;
public class JpaConstants {
public enum JpaVendor {
ECLIPSELINK,
HIBERNATE // NOT SUPPORTED!
}
public static final JpaVendor JPA_VENDOR = JpaVendor.ECLIPSELINK;
}

View File

@@ -615,9 +615,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
@Override
public List<Statistic> countRolloutsByStatusForDistributionSet(final Long id) {
assertDistributionSetExists(id);
return distributionSetRepository.countRolloutsByStatusForDistributionSet(id).stream()
.map(Statistic.class::cast).toList();
return distributionSetRepository.countRolloutsByStatusForDistributionSet(id).stream().map(Statistic.class::cast).toList();
}
@Override

View File

@@ -28,7 +28,6 @@ import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
import org.eclipse.persistence.annotations.Multitenant;
import org.eclipse.persistence.annotations.MultitenantType;
import org.eclipse.persistence.annotations.TenantDiscriminatorColumn;
import org.hibernate.annotations.TenantId;
/**
* Holder of the base attributes common to all tenant aware entities.
@@ -45,11 +44,9 @@ public abstract class AbstractJpaTenantAwareBaseEntity extends AbstractJpaBaseEn
@Serial
private static final long serialVersionUID = 1L;
@Column(name = "tenant", nullable = false, insertable = false, updatable = false, length = 40) // eclipselink
// @Column(name = "tenant", nullable = false, updatable = false, length = 40) // hibernate
@Column(name = "tenant", nullable = false, insertable = false, updatable = false, length = 40)
@Size(min = 1, max = 40)
@NotNull
@TenantId // Hibernate MultiTenant support
private String tenant;
/**

View File

@@ -244,6 +244,14 @@ public abstract class AbstractJpaIntegrationTest extends AbstractIntegrationTest
return rolloutGroupRepository.findById(group.getId()).get();
}
// version is 1, 2 ... based
protected int version(final int version) {
return switch (JpaConstants.JPA_VENDOR) {
case ECLIPSELINK -> version;
case HIBERNATE -> version - 1;
};
}
private JpaRollout refresh(final Rollout rollout) {
return rolloutRepository.findById(rollout.getId()).get();
}

View File

@@ -508,13 +508,13 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
// create a DS
final DistributionSet ds = testdataFactory.createDistributionSet("testDs");
// initial opt lock revision must be zero
assertThat(ds.getOptLockRevision()).isEqualTo(1);
assertThat(ds.getOptLockRevision()).isEqualTo(version(1));
// create an DS meta data entry
createDistributionSetMetadata(ds.getId(), new JpaDistributionSetMetadata(knownKey, ds, knownValue));
final DistributionSet changedLockRevisionDS = getOrThrow(distributionSetManagement.get(ds.getId()));
assertThat(changedLockRevisionDS.getOptLockRevision()).isEqualTo(2);
assertThat(changedLockRevisionDS.getOptLockRevision()).isEqualTo(version(2));
// update the DS metadata
final JpaDistributionSetMetadata updated = (JpaDistributionSetMetadata) distributionSetManagement
@@ -522,7 +522,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
// we are updating the sw metadata so also modifying the base software
// module so opt lock revision must be three
final DistributionSet reloadedDS = getOrThrow(distributionSetManagement.get(ds.getId()));
assertThat(reloadedDS.getOptLockRevision()).isEqualTo(3);
assertThat(reloadedDS.getOptLockRevision()).isEqualTo(version(3));
assertThat(reloadedDS.getLastModifiedAt()).isPositive();
// verify updated meta data contains the updated value

View File

@@ -38,11 +38,11 @@ public class LazyControllerManagementTest extends AbstractJpaIntegrationTest {
private RepositoryProperties repositoryProperties;
@Test
@Description("Verfies that lazy target poll update is executed as specified.")
@Description("Verifies that lazy target poll update is executed as specified.")
@ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetPollEvent.class, count = 2) })
public void lazyFindOrRegisterTargetIfItDoesNotexist() throws InterruptedException {
public void lazyFindOrRegisterTargetIfItDoesNotExist() throws InterruptedException {
final Target target = controllerManagement.findOrRegisterTargetIfItDoesNotExist("AA", LOCALHOST);
assertThat(target).as("target should not be null").isNotNull();

View File

@@ -458,7 +458,7 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
}
@Test
@Description("Verfies that all undeleted software modules are found in the repository.")
@Description("Verifies that all undeleted software modules are found in the repository.")
public void countSoftwareModuleTypesAll() {
testdataFactory.createSoftwareModuleOs();
@@ -472,7 +472,7 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
}
@Test
@Description("Verfies that software modules are returned that are assigned to given DS.")
@Description("Verifies that software modules are returned that are assigned to given DS.")
public void findSoftwareModuleByAssignedTo() {
// test modules
final SoftwareModule one = testdataFactory.createSoftwareModuleOs();
@@ -499,7 +499,7 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
final SoftwareModule ah = testdataFactory.createSoftwareModuleApp();
assertThat(ah.getOptLockRevision()).isEqualTo(1);
assertThat(ah.getOptLockRevision()).isEqualTo(version(1));
final SoftwareModuleMetadataCreate swMetadata1 = entityFactory.softwareModuleMetadata().create(ah.getId())
.key(knownKey1).value(knownValue1);
@@ -511,7 +511,7 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
.createMetaData(Arrays.asList(swMetadata1, swMetadata2));
final SoftwareModule changedLockRevisionModule = softwareModuleManagement.get(ah.getId()).get();
assertThat(changedLockRevisionModule.getOptLockRevision()).isEqualTo(2);
assertThat(changedLockRevisionModule.getOptLockRevision()).isEqualTo(version(2));
assertThat(softwareModuleMetadata).hasSize(2);
assertThat(softwareModuleMetadata.get(0)).isNotNull();
@@ -604,7 +604,7 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
// create a base software module
final SoftwareModule ah = testdataFactory.createSoftwareModuleApp();
// initial opt lock revision must be 1
assertThat(ah.getOptLockRevision()).isEqualTo(1);
assertThat(ah.getOptLockRevision()).isEqualTo(version(1));
// create an software module meta data entry
final SoftwareModuleMetadata softwareModuleMetadata = softwareModuleManagement.createMetaData(
@@ -615,7 +615,7 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
// base software module should have now the opt lock revision one
// because we are modifying the base software module
SoftwareModule changedLockRevisionModule = softwareModuleManagement.get(ah.getId()).get();
assertThat(changedLockRevisionModule.getOptLockRevision()).isEqualTo(2);
assertThat(changedLockRevisionModule.getOptLockRevision()).isEqualTo(version(2));
// update the software module metadata
final SoftwareModuleMetadata updated = softwareModuleManagement.updateMetaData(entityFactory
@@ -624,7 +624,7 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
// we are updating the sw metadata so also modifying the base software
// module so opt lock revision must be two
changedLockRevisionModule = softwareModuleManagement.get(ah.getId()).get();
assertThat(changedLockRevisionModule.getOptLockRevision()).isEqualTo(3);
assertThat(changedLockRevisionModule.getOptLockRevision()).isEqualTo(version(3));
// verify updated meta data contains the updated value
assertThat(updated).isNotNull();

View File

@@ -151,7 +151,7 @@ public class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest
}
@Test
@Description("Verfies that it is not possible to create a type that alrady exists.")
@Description("Verifies that it is not possible to create a type that alrady exists.")
public void createSoftwareModuleTypeFailsWithExistingEntity() {
softwareModuleTypeManagement.create(entityFactory.softwareModuleType().create().key("thetype").name("thename"));
try {
@@ -165,7 +165,7 @@ public class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest
}
@Test
@Description("Verfies that it is not possible to create a list of types where one already exists.")
@Description("Verifies that it is not possible to create a list of types where one already exists.")
public void createSoftwareModuleTypesFailsWithExistingEntity() {
softwareModuleTypeManagement.create(entityFactory.softwareModuleType().create().key("thetype").name("thename"));
try {
@@ -191,7 +191,7 @@ public class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest
}
@Test
@Description("Verfies that multiple types are created as requested.")
@Description("Verifies that multiple types are created as requested.")
public void createMultipleSoftwareModuleTypes() {
final List<SoftwareModuleType> created = softwareModuleTypeManagement
.create(Arrays.asList(entityFactory.softwareModuleType().create().key("thetype").name("thename"),

View File

@@ -327,7 +327,7 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
}
@Test
@Description("Verfies that targets with given assigned DS are returned from repository.")
@Description("Verifies that targets with given assigned DS are returned from repository.")
void findTargetByAssignedDistributionSet() {
final DistributionSet assignedSet = testdataFactory.createDistributionSet("");
testdataFactory.createTargets(10, "unassigned", "unassigned");

View File

@@ -840,14 +840,14 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
// create a target
final Target target = testdataFactory.createTarget("target1");
// initial opt lock revision must be zero
assertThat(target.getOptLockRevision()).isEqualTo(1);
assertThat(target.getOptLockRevision()).isEqualTo(version(1));
// create target meta data entry
insertTargetMetadata(knownKey, knownValue, target);
Target changedLockRevisionTarget = targetManagement.get(target.getId())
.orElseThrow(NoSuchElementException::new);
assertThat(changedLockRevisionTarget.getOptLockRevision()).isEqualTo(2);
assertThat(changedLockRevisionTarget.getOptLockRevision()).isEqualTo(version(2));
// Unsure if needed maybe to wait for a db flush?
// Thread.sleep(100);
@@ -858,7 +858,7 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
// we are updating the target meta data so also modifying the base
// software module so opt lock revision must be three
changedLockRevisionTarget = targetManagement.get(target.getId()).orElseThrow(NoSuchElementException::new);
assertThat(changedLockRevisionTarget.getOptLockRevision()).isEqualTo(3);
assertThat(changedLockRevisionTarget.getOptLockRevision()).isEqualTo(version(3));
assertThat(changedLockRevisionTarget.getLastModifiedAt()).isPositive();
// verify updated meta data contains the updated value
@@ -881,7 +881,7 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
// initial opt lock revision must be one
final Optional<JpaTarget> targetFound = targetRepository.findById(target.getId());
assertThat(targetFound).isPresent();
assertThat(targetFound.get().getOptLockRevision()).isEqualTo(1);
assertThat(targetFound.get().getOptLockRevision()).isEqualTo(version(1));
assertThat(targetFound.get().getTargetType().getId()).isEqualTo(targetTypes.get(0).getId());
// update the target type
@@ -892,7 +892,7 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
// opt lock revision must be changed
final Optional<JpaTarget> targetFound1 = targetRepository.findById(target.getId());
assertThat(targetFound1).isPresent();
assertThat(targetFound1.get().getOptLockRevision()).isEqualTo(2);
assertThat(targetFound1.get().getOptLockRevision()).isEqualTo(version(2));
assertThat(targetFound1.get().getTargetType().getId()).isEqualTo(targetTypes.get(1).getId());
// unassign the target type
@@ -901,7 +901,7 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
// opt lock revision must be changed
final Optional<JpaTarget> targetFound2 = targetRepository.findById(target.getId());
assertThat(targetFound2).isPresent();
assertThat(targetFound2.get().getOptLockRevision()).isEqualTo(3);
assertThat(targetFound2.get().getOptLockRevision()).isEqualTo(version(3));
assertThat(targetFound2.get().getTargetType()).isNull();
}
@@ -914,7 +914,7 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
// initial opt lock revision must be one
final Optional<JpaTarget> targetFound = targetRepository.findById(target.getId());
assertThat(targetFound).isPresent();
assertThat(targetFound.get().getOptLockRevision()).isEqualTo(1);
assertThat(targetFound.get().getOptLockRevision()).isEqualTo(version(1));
assertThat(targetFound.get().getTargetType()).isNull();
// create a target type
@@ -927,7 +927,7 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
// opt lock revision must be changed
final Optional<JpaTarget> targetFound1 = targetRepository.findById(target.getId());
assertThat(targetFound1).isPresent();
assertThat(targetFound1.get().getOptLockRevision()).isEqualTo(2);
assertThat(targetFound1.get().getOptLockRevision()).isEqualTo(version(2));
assertThat(targetFound1.get().getTargetType().getId()).isEqualTo(targetType.getId());
}
@@ -1003,7 +1003,7 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
// initial opt lock revision must be one
final Optional<JpaTarget> targetFound = targetRepository.findById(target.getId());
assertThat(targetFound).isPresent();
assertThat(targetFound.get().getOptLockRevision()).isEqualTo(1);
assertThat(targetFound.get().getOptLockRevision()).isEqualTo(version(1));
assertThat(targetFound.get().getTargetType()).isNull();
// assign target type to target
@@ -1017,7 +1017,7 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
// opt lock revision is not changed
final Optional<JpaTarget> targetFound1 = targetRepository.findById(target.getId());
assertThat(targetFound1).isPresent();
assertThat(targetFound1.get().getOptLockRevision()).isEqualTo(1);
assertThat(targetFound1.get().getOptLockRevision()).isEqualTo(version(1));
}
@Test
@@ -1032,7 +1032,7 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
// initial opt lock revision must be one
final Optional<JpaTarget> targetFound = targetRepository.findById(target.getId());
assertThat(targetFound).isPresent();
assertThat(targetFound.get().getOptLockRevision()).isEqualTo(1);
assertThat(targetFound.get().getOptLockRevision()).isEqualTo(version(1));
assertThat(targetFound.get().getTargetType().getName()).isEqualTo(targetType.getName());
// un-assign target type from target
@@ -1041,7 +1041,7 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
// opt lock revision must be changed
final Optional<JpaTarget> targetFound1 = targetRepository.findById(target.getId());
assertThat(targetFound1).isPresent();
assertThat(targetFound1.get().getOptLockRevision()).isEqualTo(2);
assertThat(targetFound1.get().getOptLockRevision()).isEqualTo(version(2));
assertThat(targetFound1.get().getTargetType()).isNull();
}

View File

@@ -35,19 +35,19 @@ public class EntityInterceptorListenerTest extends AbstractJpaIntegrationTest {
}
@Test
@Description("Verfies that the pre persist is called after a entity creation.")
@Description("Verifies that the pre persist is called after a entity creation.")
public void prePersistIsCalledWhenPersistingATarget() {
executePersistAndAssertCallbackResult(new PrePersistEntityListener());
}
@Test
@Description("Verfies that the post persist is called after a entity creation.")
@Description("Verifies that the post persist is called after a entity creation.")
public void postPersistIsCalledWhenPersistingATarget() {
executePersistAndAssertCallbackResult(new PostPersistEntityListener());
}
@Test
@Description("Verfies that the post load is called after a entity is loaded.")
@Description("Verifies that the post load is called after a entity is loaded.")
public void postLoadIsCalledWhenLoadATarget() {
final PostLoadEntityListener postLoadEntityListener = new PostLoadEntityListener();
EntityInterceptorHolder.getInstance().getEntityInterceptors().add(postLoadEntityListener);
@@ -60,25 +60,25 @@ public class EntityInterceptorListenerTest extends AbstractJpaIntegrationTest {
}
@Test
@Description("Verfies that the pre update is called after a entity update.")
@Description("Verifies that the pre update is called after a entity update.")
public void preUpdateIsCalledWhenUpdateATarget() {
executeUpdateAndAssertCallbackResult(new PreUpdateEntityListener());
}
@Test
@Description("Verfies that the post update is called after a entity update.")
@Description("Verifies that the post update is called after a entity update.")
public void postUpdateIsCalledWhenUpdateATarget() {
executeUpdateAndAssertCallbackResult(new PostUpdateEntityListener());
}
@Test
@Description("Verfies that the pre remove is called after a entity deletion.")
@Description("Verifies that the pre remove is called after a entity deletion.")
public void preRemoveIsCalledWhenDeletingATarget() {
executeDeleteAndAssertCallbackResult(new PreRemoveEntityListener());
}
@Test
@Description("Verfies that the post remove is called after a entity deletion.")
@Description("Verifies that the post remove is called after a entity deletion.")
public void postRemoveIsCalledWhenDeletingATarget() {
executeDeleteAndAssertCallbackResult(new PostRemoveEntityListener());
}

View File

@@ -23,7 +23,7 @@ import org.junit.jupiter.api.Test;
public class ModelEqualsHashcodeTest extends AbstractJpaIntegrationTest {
@Test
@Description("Verfies that different objects even with identical primary key, version and tenant "
@Description("Verifies that different objects even with identical primary key, version and tenant "
+ "return different hash codes.")
public void differentEntitiesReturnDifferentHashCodes() {
assertThat(new JpaAction().hashCode()).as("action should have different hashcode than action status")
@@ -40,7 +40,7 @@ public class ModelEqualsHashcodeTest extends AbstractJpaIntegrationTest {
}
@Test
@Description("Verfies that different object even with identical primary key, version and tenant "
@Description("Verifies that different object even with identical primary key, version and tenant "
+ "are not equal.")
public void differentEntitiesAreNotEqual() {
assertThat(new JpaAction().equals(new JpaActionStatus())).as("action equals action status").isFalse();
@@ -53,7 +53,7 @@ public class ModelEqualsHashcodeTest extends AbstractJpaIntegrationTest {
}
@Test
@Description("Verfies that updated entities are not equal.")
@Description("Verifies that updated entities are not equal.")
public void changedEntitiesAreNotEqual() {
final SoftwareModuleType type = softwareModuleTypeManagement
.create(entityFactory.softwareModuleType().create().key("test").name("test"));