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:
@@ -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;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -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),
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user