Refactor DS Management (#2591)
Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -198,7 +198,7 @@ public abstract class AbstractManagementApiIntegrationTest extends AbstractRestI
|
||||
static void implicitLock(final DistributionSet set) {
|
||||
if (!set.isLocked()) {
|
||||
((JpaDistributionSet) set).setOptLockRevision(set.getOptLockRevision() + 1);
|
||||
((JpaDistributionSet) set).lock();
|
||||
((JpaDistributionSet) set).setLocked(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -851,7 +851,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
|
||||
@WithUser(principal = "uploadTester", allSpPermissions = true)
|
||||
void getDistributionSets() throws Exception {
|
||||
// prepare test data
|
||||
assertThat(distributionSetManagement.findByCompleted(true, PAGE)).isEmpty();
|
||||
assertThat(distributionSetManagement.findAll(PAGE)).isEmpty();
|
||||
|
||||
DistributionSet set = testdataFactory.createDistributionSet("one");
|
||||
set = distributionSetManagement.update(DistributionSetManagement.Update.builder().id(set.getId())
|
||||
@@ -860,7 +860,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
|
||||
// load also lazy stuff
|
||||
set = distributionSetManagement.getWithDetails(set.getId()).get();
|
||||
|
||||
assertThat(distributionSetManagement.findByCompleted(true, PAGE)).hasSize(1);
|
||||
assertThat(distributionSetManagement.findAll(PAGE)).hasSize(1);
|
||||
|
||||
// perform request
|
||||
mvc.perform(get("/rest/v1/distributionsets").accept(MediaType.APPLICATION_JSON))
|
||||
@@ -930,7 +930,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
|
||||
@Test
|
||||
@WithUser(principal = "uploadTester", allSpPermissions = true)
|
||||
void createDistributionSets() throws Exception {
|
||||
assertThat(distributionSetManagement.findByCompleted(true, PAGE)).isEmpty();
|
||||
assertThat(distributionSetManagement.findAll(PAGE)).isEmpty();
|
||||
final SoftwareModule ah = testdataFactory.createSoftwareModule(TestdataFactory.SM_TYPE_APP);
|
||||
final SoftwareModule jvm = testdataFactory.createSoftwareModule(TestdataFactory.SM_TYPE_RT);
|
||||
final SoftwareModule os = testdataFactory.createSoftwareModule(TestdataFactory.SM_TYPE_OS);
|
||||
@@ -966,7 +966,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
|
||||
.hasToString(String.valueOf(three.getId()));
|
||||
|
||||
// check in database
|
||||
assertThat(distributionSetManagement.findByCompleted(true, PAGE)).hasSize(3);
|
||||
assertThat(distributionSetManagement.findAll(PAGE)).hasSize(3);
|
||||
assertThat(one.isRequiredMigrationStep()).isFalse();
|
||||
assertThat(two.isRequiredMigrationStep()).isFalse();
|
||||
assertThat(three.isRequiredMigrationStep()).isTrue();
|
||||
@@ -982,11 +982,11 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
|
||||
@Test
|
||||
void deleteUnassignedistributionSet() throws Exception {
|
||||
// prepare test data
|
||||
assertThat(distributionSetManagement.findByCompleted(true, PAGE)).isEmpty();
|
||||
assertThat(distributionSetManagement.findAll(PAGE)).isEmpty();
|
||||
|
||||
final DistributionSet set = testdataFactory.createDistributionSet("one");
|
||||
|
||||
assertThat(distributionSetManagement.findByCompleted(true, PAGE)).hasSize(1);
|
||||
assertThat(distributionSetManagement.findAll(PAGE)).hasSize(1);
|
||||
|
||||
// perform request
|
||||
mvc.perform(delete("/rest/v1/distributionsets/{smId}", set.getId()))
|
||||
@@ -994,7 +994,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
|
||||
.andExpect(status().isOk());
|
||||
|
||||
// check repository content
|
||||
assertThat(distributionSetManagement.findByCompleted(true, PAGE)).isEmpty();
|
||||
assertThat(distributionSetManagement.findAll(PAGE)).isEmpty();
|
||||
assertThat(distributionSetManagement.count()).isZero();
|
||||
}
|
||||
|
||||
@@ -1014,13 +1014,13 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
|
||||
@Test
|
||||
void deleteAssignedDistributionSet() throws Exception {
|
||||
// prepare test data
|
||||
assertThat(distributionSetManagement.findByCompleted(true, PAGE)).isEmpty();
|
||||
assertThat(distributionSetManagement.findAll(PAGE)).isEmpty();
|
||||
|
||||
final DistributionSet set = testdataFactory.createDistributionSet("one");
|
||||
testdataFactory.createTarget("test");
|
||||
assignDistributionSet(set.getId(), "test");
|
||||
|
||||
assertThat(distributionSetManagement.findByCompleted(true, PAGE)).hasSize(1);
|
||||
assertThat(distributionSetManagement.findAll(PAGE)).hasSize(1);
|
||||
|
||||
mvc.perform(get("/rest/v1/distributionsets/{dsId}", set.getId()))
|
||||
.andDo(MockMvcResultPrinter.print())
|
||||
@@ -1037,7 +1037,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
|
||||
.andExpect(jsonPath("$.deleted", equalTo(true)));
|
||||
|
||||
// check repository content
|
||||
assertThat(distributionSetManagement.findByCompleted(true, PAGE)).isEmpty();
|
||||
assertThat(distributionSetManagement.findAll(PAGE)).isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1046,7 +1046,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
|
||||
@Test
|
||||
void updateDistributionSet() throws Exception {
|
||||
// prepare test data
|
||||
assertThat(distributionSetManagement.findByCompleted(true, PAGE)).isEmpty();
|
||||
assertThat(distributionSetManagement.findAll(PAGE)).isEmpty();
|
||||
|
||||
final DistributionSet set = testdataFactory.createDistributionSet("one");
|
||||
assertThat(distributionSetManagement.count()).isEqualTo(1);
|
||||
@@ -1081,7 +1081,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
|
||||
void updateRequiredMigrationStepFailsIfDistributionSetisInUse() throws Exception {
|
||||
|
||||
// prepare test data
|
||||
assertThat(distributionSetManagement.findByCompleted(true, PAGE)).isEmpty();
|
||||
assertThat(distributionSetManagement.findAll(PAGE)).isEmpty();
|
||||
|
||||
final DistributionSet set = testdataFactory.createDistributionSet("one");
|
||||
assignDistributionSet(set.getId(), testdataFactory.createTarget().getControllerId());
|
||||
@@ -1723,7 +1723,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
|
||||
@Test
|
||||
void lockDistributionSet() throws Exception {
|
||||
// prepare test data
|
||||
assertThat(distributionSetManagement.findByCompleted(true, PAGE)).isEmpty();
|
||||
assertThat(distributionSetManagement.findAll(PAGE)).isEmpty();
|
||||
|
||||
final DistributionSet set = testdataFactory.createDistributionSet("one");
|
||||
assertThat(distributionSetManagement.count()).isEqualTo(1);
|
||||
@@ -1747,11 +1747,11 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
|
||||
@Test
|
||||
void unlockDistributionSet() throws Exception {
|
||||
// prepare test data
|
||||
assertThat(distributionSetManagement.findByCompleted(true, PAGE)).isEmpty();
|
||||
assertThat(distributionSetManagement.findAll(PAGE)).isEmpty();
|
||||
|
||||
final DistributionSet set = testdataFactory.createDistributionSet("one");
|
||||
assertThat(distributionSetManagement.count()).isEqualTo(1);
|
||||
distributionSetManagement.lock(set.getId());
|
||||
distributionSetManagement.lock(set);
|
||||
assertThat(distributionSetManagement.get(set.getId())
|
||||
.orElseThrow(() -> new EntityNotFoundException(SoftwareModule.class, set.getId())).isLocked())
|
||||
.as("Distribution set should be locked")
|
||||
|
||||
Reference in New Issue
Block a user