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 @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 { void deleteArtifactWhichDoesNotExistsBySHA1HashWithoutException() throws IOException {
try { try {
artifactFilesystemRepository.deleteBySha1(TENANT, "sha1HashWhichDoesNotExists"); 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 static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtActionType; 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.RepositoryApplicationConfiguration;
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSet; import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSet;
import org.eclipse.hawkbit.repository.model.BaseEntity; import org.eclipse.hawkbit.repository.model.BaseEntity;
@@ -201,4 +202,12 @@ public abstract class AbstractManagementApiIntegrationTest extends AbstractRestI
((JpaDistributionSet) set).lock(); ((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(); private static final Random RND = new Random();
@Test @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) }) @ExpectEvents({ @Expect(type = DistributionSetTagCreatedEvent.class, count = 2) })
public void getDistributionSetTags() throws Exception { public void getDistributionSetTags() throws Exception {
final List<DistributionSetTag> tags = testdataFactory.createDistributionSetTags(2); final List<DistributionSetTag> tags = testdataFactory.createDistributionSetTags(2);
@@ -132,7 +132,7 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt
} }
@Test @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 { public void getDistributionSetTagsByDistributionSetIdAndTagDescription() throws Exception {
final List<DistributionSetTag> tags = testdataFactory.createDistributionSetTags(2); final List<DistributionSetTag> tags = testdataFactory.createDistributionSetTags(2);
final DistributionSetTag tag1 = tags.get(0); final DistributionSetTag tag1 = tags.get(0);
@@ -160,7 +160,7 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt
} }
@Test @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) }) @ExpectEvents({ @Expect(type = DistributionSetTagCreatedEvent.class, count = 2) })
public void getDistributionSetTag() throws Exception { public void getDistributionSetTag() throws Exception {
final List<DistributionSetTag> tags = testdataFactory.createDistributionSetTags(2); final List<DistributionSetTag> tags = testdataFactory.createDistributionSetTags(2);
@@ -237,7 +237,7 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt
} }
@Test @Test
@Description("Verfies that the delete call is reflected by the repository.") @Description("Verifies that the delete call is reflected by the repository.")
@ExpectEvents({ @ExpectEvents({
@Expect(type = DistributionSetTagCreatedEvent.class, count = 1), @Expect(type = DistributionSetTagCreatedEvent.class, count = 1),
@Expect(type = DistributionSetTagDeletedEvent.class, count = 1) }) @Expect(type = DistributionSetTagDeletedEvent.class, count = 1) })
@@ -320,7 +320,7 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt
} }
@Test @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({ @ExpectEvents({
@Expect(type = DistributionSetTagCreatedEvent.class, count = 1), @Expect(type = DistributionSetTagCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 2), @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.mgmt.rest.api.MgmtRestConstants;
import org.eclipse.hawkbit.repository.builder.SoftwareModuleTypeCreate; import org.eclipse.hawkbit.repository.builder.SoftwareModuleTypeCreate;
import org.eclipse.hawkbit.repository.exception.AssignmentQuotaExceededException; 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.DistributionSetType;
import org.eclipse.hawkbit.repository.model.NamedEntity; import org.eclipse.hawkbit.repository.model.NamedEntity;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType; import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
@@ -155,7 +156,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
public void addMandatoryModuleToDistributionSetType() throws Exception { public void addMandatoryModuleToDistributionSetType() throws Exception {
DistributionSetType testType = distributionSetTypeManagement.create(entityFactory.distributionSetType().create() DistributionSetType testType = distributionSetTypeManagement.create(entityFactory.distributionSetType().create()
.key("test123").name("TestName123").description("Desc123").colour("col12")); .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()) mvc.perform(post("/rest/v1/distributionsettypes/{dstID}/mandatorymoduletypes", testType.getId())
.content("{\"id\":" + osType.getId() + "}").contentType(MediaType.APPLICATION_JSON)) .content("{\"id\":" + osType.getId() + "}").contentType(MediaType.APPLICATION_JSON))
@@ -164,7 +165,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
testType = distributionSetTypeManagement.get(testType.getId()).get(); testType = distributionSetTypeManagement.get(testType.getId()).get();
assertThat(testType.getLastModifiedBy()).isEqualTo("uploadTester"); assertThat(testType.getLastModifiedBy()).isEqualTo("uploadTester");
assertThat(testType.getOptLockRevision()).isEqualTo(2); assertThat(testType.getOptLockRevision()).isEqualTo(version(2));
assertThat(testType.getMandatoryModuleTypes()).containsExactly(osType); assertThat(testType.getMandatoryModuleTypes()).containsExactly(osType);
assertThat(testType.getOptionalModuleTypes()).isEmpty(); assertThat(testType.getOptionalModuleTypes()).isEmpty();
} }
@@ -175,7 +176,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
public void addOptionalModuleToDistributionSetType() throws Exception { public void addOptionalModuleToDistributionSetType() throws Exception {
DistributionSetType testType = distributionSetTypeManagement.create(entityFactory.distributionSetType().create() DistributionSetType testType = distributionSetTypeManagement.create(entityFactory.distributionSetType().create()
.key("test123").name("TestName123").description("Desc123").colour("col12")); .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()) mvc.perform(post("/rest/v1/distributionsettypes/{dstID}/optionalmoduletypes", testType.getId())
.content("{\"id\":" + osType.getId() + "}").contentType(MediaType.APPLICATION_JSON)) .content("{\"id\":" + osType.getId() + "}").contentType(MediaType.APPLICATION_JSON))
@@ -184,7 +185,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
testType = distributionSetTypeManagement.get(testType.getId()).get(); testType = distributionSetTypeManagement.get(testType.getId()).get();
assertThat(testType.getLastModifiedBy()).isEqualTo("uploadTester"); assertThat(testType.getLastModifiedBy()).isEqualTo("uploadTester");
assertThat(testType.getOptLockRevision()).isEqualTo(2); assertThat(testType.getOptLockRevision()).isEqualTo(version(2));
assertThat(testType.getOptionalModuleTypes()).containsExactly(osType); assertThat(testType.getOptionalModuleTypes()).containsExactly(osType);
assertThat(testType.getMandatoryModuleTypes()).isEmpty(); assertThat(testType.getMandatoryModuleTypes()).isEmpty();
@@ -207,7 +208,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
final DistributionSetType testType = distributionSetTypeManagement.create(entityFactory.distributionSetType() final DistributionSetType testType = distributionSetTypeManagement.create(entityFactory.distributionSetType()
.create().key("testType").name("testType").description("testType").colour("col12")); .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) { for (int i = 0; i < moduleTypeIds.size() - 1; ++i) {
mvc.perform(post("/rest/v1/distributionsettypes/{dstID}/optionalmoduletypes", testType.getId()) 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() final DistributionSetType testType2 = distributionSetTypeManagement.create(entityFactory.distributionSetType()
.create().key("testType2").name("testType2").description("testType2").colour("col12")); .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) { for (int i = 0; i < moduleTypeIds.size() - 1; ++i) {
mvc.perform(post("/rest/v1/distributionsettypes/{dstID}/mandatorymoduletypes", testType2.getId()) 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(); testType = distributionSetTypeManagement.get(testType.getId()).get();
assertThat(testType.getLastModifiedBy()).isEqualTo("uploadTester"); assertThat(testType.getLastModifiedBy()).isEqualTo("uploadTester");
assertThat(testType.getOptLockRevision()).isEqualTo(2); assertThat(testType.getOptLockRevision()).isEqualTo(version(2));
assertThat(testType.getOptionalModuleTypes()).containsExactly(appType); assertThat(testType.getOptionalModuleTypes()).containsExactly(appType);
assertThat(testType.getMandatoryModuleTypes()).isEmpty(); assertThat(testType.getMandatoryModuleTypes()).isEmpty();
} }
@@ -349,7 +350,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
testType = distributionSetTypeManagement.get(testType.getId()).get(); testType = distributionSetTypeManagement.get(testType.getId()).get();
assertThat(testType.getLastModifiedBy()).isEqualTo("uploadTester"); assertThat(testType.getLastModifiedBy()).isEqualTo("uploadTester");
assertThat(testType.getOptLockRevision()).isEqualTo(2); assertThat(testType.getOptLockRevision()).isEqualTo(version(2));
assertThat(testType.getOptionalModuleTypes()).isEmpty(); assertThat(testType.getOptionalModuleTypes()).isEmpty();
assertThat(testType.getMandatoryModuleTypes()).containsExactly(osType); assertThat(testType.getMandatoryModuleTypes()).containsExactly(osType);
} }
@@ -736,7 +737,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
final DistributionSetType testType = distributionSetTypeManagement.create(entityFactory.distributionSetType() final DistributionSetType testType = distributionSetTypeManagement.create(entityFactory.distributionSetType()
.create().key("test123").name("TestName123").description("Desc123").colour("col") .create().key("test123").name("TestName123").description("Desc123").colour("col")
.mandatory(Collections.singletonList(osType.getId())).optional(Collections.singletonList(appType.getId()))); .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.getOptionalModuleTypes()).containsExactly(appType);
assertThat(testType.getMandatoryModuleTypes()).containsExactly(osType); assertThat(testType.getMandatoryModuleTypes()).containsExactly(osType);
return testType; return testType;

View File

@@ -947,7 +947,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
} }
@Test @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 { void createTargetWithInvalidPropertyBadRequest() throws Exception {
final Target test1 = entityFactory.target().create().controllerId("id1") final Target test1 = entityFactory.target().create().controllerId("id1")
.name(RandomStringUtils.randomAlphanumeric(NamedEntity.NAME_MAX_SIZE + 1)).build(); .name(RandomStringUtils.randomAlphanumeric(NamedEntity.NAME_MAX_SIZE + 1)).build();
@@ -1413,7 +1413,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
} }
@Test @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 { void updateAction() throws Exception {
final Target target = testdataFactory.createTarget(); final Target target = testdataFactory.createTarget();
final DistributionSet set = testdataFactory.createDistributionSet(); final DistributionSet set = testdataFactory.createDistributionSet();
@@ -1516,7 +1516,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
} }
@Test @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 { void assignDownloadOnlyDistributionSetToTarget() throws Exception {
final Target target = testdataFactory.createTarget(); final Target target = testdataFactory.createTarget();
final DistributionSet set = testdataFactory.createDistributionSet("one"); final DistributionSet set = testdataFactory.createDistributionSet("one");
@@ -1538,7 +1538,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
} }
@Test @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.") + "the assignment does not change the target.")
void offlineAssignDistributionSetToTarget() throws Exception { void offlineAssignDistributionSetToTarget() throws Exception {
Target target = testdataFactory.createTarget(); Target target = testdataFactory.createTarget();

View File

@@ -67,7 +67,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
private static final Random RND = new Random(); private static final Random RND = new Random();
@Test @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) }) @ExpectEvents({ @Expect(type = TargetTagCreatedEvent.class, count = 2) })
public void getTargetTags() throws Exception { public void getTargetTags() throws Exception {
final List<TargetTag> tags = testdataFactory.createTargetTags(2, ""); final List<TargetTag> tags = testdataFactory.createTargetTags(2, "");
@@ -130,7 +130,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
} }
@Test @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) }) @ExpectEvents({ @Expect(type = TargetTagCreatedEvent.class, count = 2) })
public void getTargetTag() throws Exception { public void getTargetTag() throws Exception {
final List<TargetTag> tags = testdataFactory.createTargetTags(2, ""); final List<TargetTag> tags = testdataFactory.createTargetTags(2, "");
@@ -208,7 +208,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
} }
@Test @Test
@Description("Verfies that the delete call is reflected by the repository.") @Description("Verifies that the delete call is reflected by the repository.")
@ExpectEvents({ @ExpectEvents({
@Expect(type = TargetTagCreatedEvent.class, count = 1), @Expect(type = TargetTagCreatedEvent.class, count = 1),
@Expect(type = TargetTagDeletedEvent.class, count = 1) }) @Expect(type = TargetTagDeletedEvent.class, count = 1) })
@@ -650,7 +650,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
} }
@Test @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({ @ExpectEvents({
@Expect(type = TargetTagCreatedEvent.class, count = 1), @Expect(type = TargetTagCreatedEvent.class, count = 1),
@Expect(type = TargetCreatedEvent.class, count = 2), @Expect(type = TargetCreatedEvent.class, count = 2),

View File

@@ -321,7 +321,7 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest {
void addDistributionSetTypeToTargetType() throws Exception { void addDistributionSetTypeToTargetType() throws Exception {
String typeName = "TestTypeAddDs"; String typeName = "TestTypeAddDs";
TargetType testType = createTestTargetTypeInDB(typeName); TargetType testType = createTestTargetTypeInDB(typeName);
assertThat(testType.getOptLockRevision()).isEqualTo(1); assertThat(testType.getOptLockRevision()).isEqualTo(version(1));
mvc.perform(post(TARGETTYPE_DSTYPES_ENDPOINT, testType.getId()) mvc.perform(post(TARGETTYPE_DSTYPES_ENDPOINT, testType.getId())
.content("[{\"id\":" + standardDsType.getId() + "}]").contentType(MediaType.APPLICATION_JSON)) .content("[{\"id\":" + standardDsType.getId() + "}]").contentType(MediaType.APPLICATION_JSON))
@@ -330,7 +330,7 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest {
testType = targetTypeManagement.get(testType.getId()).get(); testType = targetTypeManagement.get(testType.getId()).get();
assertThat(testType.getLastModifiedBy()).isEqualTo(TEST_USER); assertThat(testType.getLastModifiedBy()).isEqualTo(TEST_USER);
assertThat(testType.getOptLockRevision()).isEqualTo(2); assertThat(testType.getOptLockRevision()).isEqualTo(version(2));
assertThat(testType.getCompatibleDistributionSetTypes()).containsExactly(standardDsType); assertThat(testType.getCompatibleDistributionSetTypes()).containsExactly(standardDsType);
} }
@@ -380,7 +380,7 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest {
testType = targetTypeManagement.get(testType.getId()).get(); testType = targetTypeManagement.get(testType.getId()).get();
assertThat(testType.getLastModifiedBy()).isEqualTo(TEST_USER); assertThat(testType.getLastModifiedBy()).isEqualTo(TEST_USER);
assertThat(testType.getOptLockRevision()).isEqualTo(2); assertThat(testType.getOptLockRevision()).isEqualTo(version(2));
assertThat(testType.getCompatibleDistributionSetTypes()).isEmpty(); assertThat(testType.getCompatibleDistributionSetTypes()).isEmpty();
} }
@@ -398,7 +398,7 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest {
testType = targetTypeManagement.get(testType.getId()).get(); testType = targetTypeManagement.get(testType.getId()).get();
assertThat(testType.getLastModifiedBy()).isEqualTo(TEST_USER); assertThat(testType.getLastModifiedBy()).isEqualTo(TEST_USER);
assertThat(testType.getOptLockRevision()).isEqualTo(2); assertThat(testType.getOptLockRevision()).isEqualTo(version(2));
assertThat(testType.getCompatibleDistributionSetTypes()).isEmpty(); assertThat(testType.getCompatibleDistributionSetTypes()).isEmpty();
assertThat(distributionSetTypeManagement.getByKey(standardDsType.getKey())).isEmpty(); assertThat(distributionSetTypeManagement.getByKey(standardDsType.getKey())).isEmpty();
} }
@@ -641,7 +641,7 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest {
@Step @Step
private TargetType createTestTargetTypeInDB(String name, List<DistributionSetType> dsTypes) { private TargetType createTestTargetTypeInDB(String name, List<DistributionSetType> dsTypes) {
TargetType targetType = testdataFactory.createTargetType(name, dsTypes); TargetType targetType = testdataFactory.createTargetType(name, dsTypes);
assertThat(targetType.getOptLockRevision()).isEqualTo(1); assertThat(targetType.getOptLockRevision()).isEqualTo(version(1));
return targetType; 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 @Override
public List<Statistic> countRolloutsByStatusForDistributionSet(final Long id) { public List<Statistic> countRolloutsByStatusForDistributionSet(final Long id) {
assertDistributionSetExists(id); assertDistributionSetExists(id);
return distributionSetRepository.countRolloutsByStatusForDistributionSet(id).stream().map(Statistic.class::cast).toList();
return distributionSetRepository.countRolloutsByStatusForDistributionSet(id).stream()
.map(Statistic.class::cast).toList();
} }
@Override @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.Multitenant;
import org.eclipse.persistence.annotations.MultitenantType; import org.eclipse.persistence.annotations.MultitenantType;
import org.eclipse.persistence.annotations.TenantDiscriminatorColumn; import org.eclipse.persistence.annotations.TenantDiscriminatorColumn;
import org.hibernate.annotations.TenantId;
/** /**
* Holder of the base attributes common to all tenant aware entities. * Holder of the base attributes common to all tenant aware entities.
@@ -45,11 +44,9 @@ public abstract class AbstractJpaTenantAwareBaseEntity extends AbstractJpaBaseEn
@Serial @Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Column(name = "tenant", nullable = false, insertable = false, updatable = false, length = 40) // eclipselink @Column(name = "tenant", nullable = false, insertable = false, updatable = false, length = 40)
// @Column(name = "tenant", nullable = false, updatable = false, length = 40) // hibernate
@Size(min = 1, max = 40) @Size(min = 1, max = 40)
@NotNull @NotNull
@TenantId // Hibernate MultiTenant support
private String tenant; private String tenant;
/** /**

View File

@@ -244,6 +244,14 @@ public abstract class AbstractJpaIntegrationTest extends AbstractIntegrationTest
return rolloutGroupRepository.findById(group.getId()).get(); 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) { private JpaRollout refresh(final Rollout rollout) {
return rolloutRepository.findById(rollout.getId()).get(); return rolloutRepository.findById(rollout.getId()).get();
} }

View File

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

View File

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

View File

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

View File

@@ -151,7 +151,7 @@ public class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest
} }
@Test @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() { public void createSoftwareModuleTypeFailsWithExistingEntity() {
softwareModuleTypeManagement.create(entityFactory.softwareModuleType().create().key("thetype").name("thename")); softwareModuleTypeManagement.create(entityFactory.softwareModuleType().create().key("thetype").name("thename"));
try { try {
@@ -165,7 +165,7 @@ public class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest
} }
@Test @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() { public void createSoftwareModuleTypesFailsWithExistingEntity() {
softwareModuleTypeManagement.create(entityFactory.softwareModuleType().create().key("thetype").name("thename")); softwareModuleTypeManagement.create(entityFactory.softwareModuleType().create().key("thetype").name("thename"));
try { try {
@@ -191,7 +191,7 @@ public class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest
} }
@Test @Test
@Description("Verfies that multiple types are created as requested.") @Description("Verifies that multiple types are created as requested.")
public void createMultipleSoftwareModuleTypes() { public void createMultipleSoftwareModuleTypes() {
final List<SoftwareModuleType> created = softwareModuleTypeManagement final List<SoftwareModuleType> created = softwareModuleTypeManagement
.create(Arrays.asList(entityFactory.softwareModuleType().create().key("thetype").name("thename"), .create(Arrays.asList(entityFactory.softwareModuleType().create().key("thetype").name("thename"),

View File

@@ -327,7 +327,7 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
} }
@Test @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() { void findTargetByAssignedDistributionSet() {
final DistributionSet assignedSet = testdataFactory.createDistributionSet(""); final DistributionSet assignedSet = testdataFactory.createDistributionSet("");
testdataFactory.createTargets(10, "unassigned", "unassigned"); testdataFactory.createTargets(10, "unassigned", "unassigned");

View File

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

View File

@@ -35,19 +35,19 @@ public class EntityInterceptorListenerTest extends AbstractJpaIntegrationTest {
} }
@Test @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() { public void prePersistIsCalledWhenPersistingATarget() {
executePersistAndAssertCallbackResult(new PrePersistEntityListener()); executePersistAndAssertCallbackResult(new PrePersistEntityListener());
} }
@Test @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() { public void postPersistIsCalledWhenPersistingATarget() {
executePersistAndAssertCallbackResult(new PostPersistEntityListener()); executePersistAndAssertCallbackResult(new PostPersistEntityListener());
} }
@Test @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() { public void postLoadIsCalledWhenLoadATarget() {
final PostLoadEntityListener postLoadEntityListener = new PostLoadEntityListener(); final PostLoadEntityListener postLoadEntityListener = new PostLoadEntityListener();
EntityInterceptorHolder.getInstance().getEntityInterceptors().add(postLoadEntityListener); EntityInterceptorHolder.getInstance().getEntityInterceptors().add(postLoadEntityListener);
@@ -60,25 +60,25 @@ public class EntityInterceptorListenerTest extends AbstractJpaIntegrationTest {
} }
@Test @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() { public void preUpdateIsCalledWhenUpdateATarget() {
executeUpdateAndAssertCallbackResult(new PreUpdateEntityListener()); executeUpdateAndAssertCallbackResult(new PreUpdateEntityListener());
} }
@Test @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() { public void postUpdateIsCalledWhenUpdateATarget() {
executeUpdateAndAssertCallbackResult(new PostUpdateEntityListener()); executeUpdateAndAssertCallbackResult(new PostUpdateEntityListener());
} }
@Test @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() { public void preRemoveIsCalledWhenDeletingATarget() {
executeDeleteAndAssertCallbackResult(new PreRemoveEntityListener()); executeDeleteAndAssertCallbackResult(new PreRemoveEntityListener());
} }
@Test @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() { public void postRemoveIsCalledWhenDeletingATarget() {
executeDeleteAndAssertCallbackResult(new PostRemoveEntityListener()); executeDeleteAndAssertCallbackResult(new PostRemoveEntityListener());
} }

View File

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