Hibernate versioning made to start from 1 to be EclipseLink compatible (#2156)
Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -15,7 +15,6 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
|||||||
|
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtActionType;
|
import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtActionType;
|
||||||
import org.eclipse.hawkbit.repository.jpa.Jpa;
|
|
||||||
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;
|
||||||
@@ -205,12 +204,4 @@ 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 (Jpa.JPA_VENDOR) {
|
|
||||||
case ECLIPSELINK -> version;
|
|
||||||
case HIBERNATE -> version - 1;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -214,7 +214,7 @@ class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIntegrati
|
|||||||
|
|
||||||
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(version(1));
|
assertThat(testType.getOptLockRevision()).isEqualTo(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())
|
||||||
@@ -235,7 +235,7 @@ class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIntegrati
|
|||||||
|
|
||||||
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(version(1));
|
assertThat(testType2.getOptLockRevision()).isEqualTo(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())
|
||||||
@@ -741,7 +741,7 @@ class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIntegrati
|
|||||||
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(version(1));
|
assertThat(testType.getOptLockRevision()).isEqualTo(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;
|
||||||
|
|||||||
@@ -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(version(1));
|
assertThat(testType.getOptLockRevision()).isEqualTo(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(version(2));
|
assertThat(testType.getOptLockRevision()).isEqualTo(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(version(2));
|
assertThat(testType.getOptLockRevision()).isEqualTo(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(version(2));
|
assertThat(testType.getOptLockRevision()).isEqualTo(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(version(1));
|
assertThat(targetType.getOptLockRevision()).isEqualTo(1);
|
||||||
return targetType;
|
return targetType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ public abstract class AbstractJpaBaseEntity extends AbstractBaseEntity {
|
|||||||
@Getter
|
@Getter
|
||||||
@Version
|
@Version
|
||||||
@Column(name = "optlock_revision")
|
@Column(name = "optlock_revision")
|
||||||
private int optLockRevision;
|
private int optLockRevision = 1;
|
||||||
|
|
||||||
// Audit fields. use property access to ensure that setters will be called and checked for modification
|
// Audit fields. use property access to ensure that setters will be called and checked for modification
|
||||||
// (touch implementation depends on setLastModifiedAt(1).
|
// (touch implementation depends on setLastModifiedAt(1).
|
||||||
|
|||||||
@@ -244,14 +244,6 @@ 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 (Jpa.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();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -505,13 +505,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(version(1));
|
assertThat(ds.getOptLockRevision()).isEqualTo(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(version(2));
|
assertThat(changedLockRevisionDS.getOptLockRevision()).isEqualTo(2);
|
||||||
|
|
||||||
// update the DS metadata
|
// update the DS metadata
|
||||||
final JpaDistributionSetMetadata updated = (JpaDistributionSetMetadata) distributionSetManagement
|
final JpaDistributionSetMetadata updated = (JpaDistributionSetMetadata) distributionSetManagement
|
||||||
@@ -519,7 +519,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(version(3));
|
assertThat(reloadedDS.getOptLockRevision()).isEqualTo(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
|
||||||
|
|||||||
@@ -499,7 +499,7 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
|
|
||||||
final SoftwareModule ah = testdataFactory.createSoftwareModuleApp();
|
final SoftwareModule ah = testdataFactory.createSoftwareModuleApp();
|
||||||
|
|
||||||
assertThat(ah.getOptLockRevision()).isEqualTo(version(1));
|
assertThat(ah.getOptLockRevision()).isEqualTo(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 @@ 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(version(2));
|
assertThat(changedLockRevisionModule.getOptLockRevision()).isEqualTo(2);
|
||||||
|
|
||||||
assertThat(softwareModuleMetadata).hasSize(2);
|
assertThat(softwareModuleMetadata).hasSize(2);
|
||||||
assertThat(softwareModuleMetadata.get(0)).isNotNull();
|
assertThat(softwareModuleMetadata.get(0)).isNotNull();
|
||||||
@@ -604,7 +604,7 @@ 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(version(1));
|
assertThat(ah.getOptLockRevision()).isEqualTo(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 @@ 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(version(2));
|
assertThat(changedLockRevisionModule.getOptLockRevision()).isEqualTo(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 @@ 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(version(3));
|
assertThat(changedLockRevisionModule.getOptLockRevision()).isEqualTo(3);
|
||||||
|
|
||||||
// verify updated meta data contains the updated value
|
// verify updated meta data contains the updated value
|
||||||
assertThat(updated).isNotNull();
|
assertThat(updated).isNotNull();
|
||||||
|
|||||||
@@ -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(version(1));
|
assertThat(target.getOptLockRevision()).isEqualTo(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(version(2));
|
assertThat(changedLockRevisionTarget.getOptLockRevision()).isEqualTo(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(version(3));
|
assertThat(changedLockRevisionTarget.getOptLockRevision()).isEqualTo(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(version(1));
|
assertThat(targetFound.get().getOptLockRevision()).isEqualTo(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(version(2));
|
assertThat(targetFound1.get().getOptLockRevision()).isEqualTo(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(version(3));
|
assertThat(targetFound2.get().getOptLockRevision()).isEqualTo(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(version(1));
|
assertThat(targetFound.get().getOptLockRevision()).isEqualTo(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(version(2));
|
assertThat(targetFound1.get().getOptLockRevision()).isEqualTo(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(version(1));
|
assertThat(targetFound.get().getOptLockRevision()).isEqualTo(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(version(1));
|
assertThat(targetFound1.get().getOptLockRevision()).isEqualTo(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(version(1));
|
assertThat(targetFound.get().getOptLockRevision()).isEqualTo(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(version(2));
|
assertThat(targetFound1.get().getOptLockRevision()).isEqualTo(2);
|
||||||
assertThat(targetFound1.get().getTargetType()).isNull();
|
assertThat(targetFound1.get().getTargetType()).isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -215,7 +215,7 @@ class TargetTagManagementTest extends AbstractJpaIntegrationTest {
|
|||||||
.isEqualTo("test123");
|
.isEqualTo("test123");
|
||||||
assertThat(targetTagRepository.findById(savedAssigned.getId()).get().getOptLockRevision())
|
assertThat(targetTagRepository.findById(savedAssigned.getId()).get().getOptLockRevision())
|
||||||
.as("wrong target tag is saved")
|
.as("wrong target tag is saved")
|
||||||
.isEqualTo(version(2));
|
.isEqualTo(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user