Introduced deleted flag in REST API (#665)
* — refactored distribution set update test, changed rollout test steps to check if deleted flag is set to false — added deleted json property for soft deletion of rollout, distribution set, distribution set type, software module, software module type, covered relevant get and put requests with tests Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch-si.com> * Changed deleted flag json property to primitive boolean type, tests refactoring Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch-si.com> * Deleted flag getters renaming Signed-off-by: Bogdan Bondar <Bogdan.Bondar@bosch-si.com>
This commit is contained in:
committed by
Dominic Schabel
parent
607cf92a9e
commit
d9fc3c0e31
@@ -50,93 +50,62 @@ public class MgmtDistributionSet extends MgmtNamedEntity {
|
||||
@JsonProperty
|
||||
private Boolean complete;
|
||||
|
||||
/**
|
||||
* @return the id
|
||||
*/
|
||||
@JsonProperty
|
||||
private boolean deleted;
|
||||
|
||||
public boolean isDeleted() {
|
||||
return deleted;
|
||||
}
|
||||
|
||||
public void setDeleted(final boolean deleted) {
|
||||
this.deleted = deleted;
|
||||
}
|
||||
|
||||
public Long getDsId() {
|
||||
return dsId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* the id to set
|
||||
*/
|
||||
@JsonIgnore
|
||||
public void setDsId(final Long id) {
|
||||
dsId = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the version
|
||||
*/
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param version
|
||||
* the version to set
|
||||
*/
|
||||
public void setVersion(final String version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the requiredMigrationStep
|
||||
*/
|
||||
public boolean isRequiredMigrationStep() {
|
||||
return requiredMigrationStep;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param requiredMigrationStep
|
||||
* the requiredMigrationStep to set
|
||||
*/
|
||||
public void setRequiredMigrationStep(final boolean requiredMigrationStep) {
|
||||
this.requiredMigrationStep = requiredMigrationStep;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the modules
|
||||
*/
|
||||
public List<MgmtSoftwareModule> getModules() {
|
||||
return modules;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param modules
|
||||
* the modules to set
|
||||
*/
|
||||
public void setModules(final List<MgmtSoftwareModule> modules) {
|
||||
this.modules = modules;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the type
|
||||
*/
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type
|
||||
* the type to set
|
||||
*/
|
||||
public void setType(final String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the complete
|
||||
*/
|
||||
public Boolean getComplete() {
|
||||
return complete;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param complete
|
||||
* the complete to set
|
||||
*/
|
||||
public void setComplete(final Boolean complete) {
|
||||
this.complete = complete;
|
||||
}
|
||||
|
||||
@@ -33,6 +33,17 @@ public class MgmtDistributionSetType extends MgmtNamedEntity {
|
||||
@JsonProperty
|
||||
private String key;
|
||||
|
||||
@JsonProperty
|
||||
private boolean deleted;
|
||||
|
||||
public boolean isDeleted() {
|
||||
return deleted;
|
||||
}
|
||||
|
||||
public void setDeleted(final boolean deleted) {
|
||||
this.deleted = deleted;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the moduleId
|
||||
*/
|
||||
|
||||
@@ -40,84 +40,57 @@ public class MgmtRolloutResponseBody extends MgmtNamedEntity {
|
||||
@JsonProperty
|
||||
private Map<String, Long> totalTargetsPerStatus;
|
||||
|
||||
/**
|
||||
* @return the status
|
||||
*/
|
||||
@JsonProperty
|
||||
private boolean deleted;
|
||||
|
||||
public boolean isDeleted() {
|
||||
return deleted;
|
||||
}
|
||||
|
||||
public void setDeleted(final boolean deleted) {
|
||||
this.deleted = deleted;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param status
|
||||
* the status to set
|
||||
*/
|
||||
public void setStatus(final String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the rolloutId
|
||||
*/
|
||||
public Long getRolloutId() {
|
||||
return rolloutId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rolloutId
|
||||
* the rolloutId to set
|
||||
*/
|
||||
public void setRolloutId(final Long rolloutId) {
|
||||
this.rolloutId = rolloutId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the targetFilterQuery
|
||||
*/
|
||||
public String getTargetFilterQuery() {
|
||||
return targetFilterQuery;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param targetFilterQuery
|
||||
* the targetFilterQuery to set
|
||||
*/
|
||||
public void setTargetFilterQuery(final String targetFilterQuery) {
|
||||
this.targetFilterQuery = targetFilterQuery;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the distributionSetId
|
||||
*/
|
||||
public Long getDistributionSetId() {
|
||||
return distributionSetId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param distributionSetId
|
||||
* the distributionSetId to set
|
||||
*/
|
||||
public void setDistributionSetId(final Long distributionSetId) {
|
||||
this.distributionSetId = distributionSetId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param totalTargets
|
||||
* the totalTargets to set
|
||||
*/
|
||||
public void setTotalTargets(final Long totalTargets) {
|
||||
this.totalTargets = totalTargets;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the totalTargets
|
||||
*/
|
||||
public Long getTotalTargets() {
|
||||
return totalTargets;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the totalTargetsPerStatus
|
||||
*/
|
||||
public Map<String, Long> getTotalTargetsPerStatus() {
|
||||
return totalTargetsPerStatus;
|
||||
}
|
||||
|
||||
@@ -35,63 +35,46 @@ public class MgmtSoftwareModule extends MgmtNamedEntity {
|
||||
@JsonProperty
|
||||
private String vendor;
|
||||
|
||||
/**
|
||||
* @return the moduleId
|
||||
*/
|
||||
@JsonProperty
|
||||
private boolean deleted;
|
||||
|
||||
public void setDeleted(final boolean deleted) {
|
||||
this.deleted = deleted;
|
||||
}
|
||||
|
||||
public boolean isDeleted() {
|
||||
return deleted;
|
||||
}
|
||||
|
||||
public Long getModuleId() {
|
||||
return moduleId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param moduleId
|
||||
* the moduleId to set
|
||||
*/
|
||||
@JsonIgnore
|
||||
public void setModuleId(final Long moduleId) {
|
||||
this.moduleId = moduleId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the version
|
||||
*/
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param version
|
||||
* the version to set
|
||||
*/
|
||||
public void setVersion(final String version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the type
|
||||
*/
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type
|
||||
* the type to set
|
||||
*/
|
||||
public void setType(final String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the vendor
|
||||
*/
|
||||
public String getVendor() {
|
||||
return vendor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param vendor
|
||||
* the vendor to set
|
||||
*/
|
||||
public void setVendor(final String vendor) {
|
||||
this.vendor = vendor;
|
||||
}
|
||||
|
||||
@@ -33,47 +33,37 @@ public class MgmtSoftwareModuleType extends MgmtNamedEntity {
|
||||
@JsonProperty
|
||||
private int maxAssignments;
|
||||
|
||||
/**
|
||||
* @return the moduleId
|
||||
*/
|
||||
@JsonProperty
|
||||
private boolean deleted;
|
||||
|
||||
public boolean isDeleted() {
|
||||
return deleted;
|
||||
}
|
||||
|
||||
public void setDeleted(final boolean deleted) {
|
||||
this.deleted = deleted;
|
||||
}
|
||||
|
||||
public Long getModuleId() {
|
||||
return moduleId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param moduleId
|
||||
* the moduleId to set
|
||||
*/
|
||||
public void setModuleId(final Long moduleId) {
|
||||
this.moduleId = moduleId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the key
|
||||
*/
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param key
|
||||
* the key to set
|
||||
*/
|
||||
public void setKey(final String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the maxAssignments
|
||||
*/
|
||||
public int getMaxAssignments() {
|
||||
return maxAssignments;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param maxAssignments
|
||||
* the maxAssignments to set
|
||||
*/
|
||||
public void setMaxAssignments(final int maxAssignments) {
|
||||
this.maxAssignments = maxAssignments;
|
||||
}
|
||||
|
||||
@@ -108,6 +108,7 @@ public final class MgmtDistributionSetMapper {
|
||||
response.setVersion(distributionSet.getVersion());
|
||||
response.setComplete(distributionSet.isComplete());
|
||||
response.setType(distributionSet.getType().getKey());
|
||||
response.setDeleted(distributionSet.isDeleted());
|
||||
|
||||
distributionSet.getModules()
|
||||
.forEach(module -> response.getModules().add(MgmtSoftwareModuleMapper.toResponse(module)));
|
||||
|
||||
@@ -88,6 +88,7 @@ final class MgmtDistributionSetTypeMapper {
|
||||
MgmtRestModelMapper.mapNamedToNamed(result, type);
|
||||
result.setKey(type.getKey());
|
||||
result.setModuleId(type.getId());
|
||||
result.setDeleted(type.isDeleted());
|
||||
|
||||
result.add(linkTo(methodOn(MgmtDistributionSetTypeRestApi.class).getDistributionSetType(result.getModuleId()))
|
||||
.withSelfRel());
|
||||
|
||||
@@ -77,6 +77,7 @@ final class MgmtRolloutMapper {
|
||||
body.setDistributionSetId(rollout.getDistributionSet().getId());
|
||||
body.setStatus(rollout.getStatus().toString().toLowerCase());
|
||||
body.setTotalTargets(rollout.getTotalTargets());
|
||||
body.setDeleted(rollout.isDeleted());
|
||||
|
||||
if (withDetails) {
|
||||
for (final TotalTargetCountStatus.Status status : TotalTargetCountStatus.Status.values()) {
|
||||
|
||||
@@ -79,8 +79,7 @@ public final class MgmtSoftwareModuleMapper {
|
||||
softwareModules.stream().map(MgmtSoftwareModuleMapper::toResponse).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
static List<MgmtSoftwareModuleMetadata> toResponseSwMetadata(
|
||||
final Collection<SoftwareModuleMetadata> metadata) {
|
||||
static List<MgmtSoftwareModuleMetadata> toResponseSwMetadata(final Collection<SoftwareModuleMetadata> metadata) {
|
||||
if (metadata == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
@@ -107,6 +106,7 @@ public final class MgmtSoftwareModuleMapper {
|
||||
response.setVersion(softwareModule.getVersion());
|
||||
response.setType(softwareModule.getType().getKey());
|
||||
response.setVendor(softwareModule.getVendor());
|
||||
response.setDeleted(softwareModule.isDeleted());
|
||||
|
||||
response.add(linkTo(methodOn(MgmtSoftwareModuleRestApi.class).getSoftwareModule(response.getModuleId()))
|
||||
.withSelfRel());
|
||||
|
||||
@@ -68,6 +68,7 @@ final class MgmtSoftwareModuleTypeMapper {
|
||||
result.setKey(type.getKey());
|
||||
result.setMaxAssignments(type.getMaxAssignments());
|
||||
result.setModuleId(type.getId());
|
||||
result.setDeleted(type.isDeleted());
|
||||
|
||||
result.add(linkTo(methodOn(MgmtSoftwareModuleTypeRestApi.class).getSoftwareModuleType(result.getModuleId()))
|
||||
.withSelfRel());
|
||||
|
||||
@@ -609,6 +609,7 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
|
||||
.andExpect(jsonPath("$.requiredMigrationStep", equalTo(set.isRequiredMigrationStep())))
|
||||
.andExpect(jsonPath("$.createdBy", equalTo(set.getCreatedBy())))
|
||||
.andExpect(jsonPath("$.complete", equalTo(Boolean.TRUE)))
|
||||
.andExpect(jsonPath("$.deleted", equalTo(set.isDeleted())))
|
||||
.andExpect(jsonPath("$.createdAt", equalTo(set.getCreatedAt())))
|
||||
.andExpect(jsonPath("$.lastModifiedBy", equalTo(set.getLastModifiedBy())))
|
||||
.andExpect(jsonPath("$.lastModifiedAt", equalTo(set.getLastModifiedAt())))
|
||||
@@ -771,10 +772,15 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
|
||||
|
||||
assertThat(distributionSetManagement.findByCompleted(PAGE, true)).hasSize(1);
|
||||
|
||||
// perform request
|
||||
mvc.perform(delete("/rest/v1/distributionsets/{smId}", set.getId())).andDo(MockMvcResultPrinter.print())
|
||||
mvc.perform(get("/rest/v1/distributionsets/{dsId}", set.getId())).andDo(MockMvcResultPrinter.print())
|
||||
.andExpect(status().isOk()).andExpect(jsonPath("$.deleted", equalTo(false)));
|
||||
|
||||
mvc.perform(delete("/rest/v1/distributionsets/{dsId}", set.getId())).andDo(MockMvcResultPrinter.print())
|
||||
.andExpect(status().isOk());
|
||||
|
||||
mvc.perform(get("/rest/v1/distributionsets/{dsId}", set.getId())).andDo(MockMvcResultPrinter.print())
|
||||
.andExpect(status().isOk()).andExpect(jsonPath("$.deleted", equalTo(true)));
|
||||
|
||||
// check repository content
|
||||
assertThat(distributionSetManagement.findByCompleted(PAGE, true)).hasSize(0);
|
||||
}
|
||||
@@ -790,16 +796,22 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
|
||||
|
||||
assertThat(distributionSetManagement.count()).isEqualTo(1);
|
||||
|
||||
mvc.perform(put("/rest/v1/distributionsets/{dsId}", set.getId())
|
||||
.content("{\"version\":\"anotherVersion\",\"requiredMigrationStep\":\"true\"}")
|
||||
final String body = new JSONObject().put("version", "anotherVersion").put("requiredMigrationStep", true)
|
||||
.put("deleted", true).toString();
|
||||
|
||||
mvc.perform(put("/rest/v1/distributionsets/{dsId}", set.getId()).content(body)
|
||||
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.version", equalTo("anotherVersion")))
|
||||
.andExpect(jsonPath("$.requiredMigrationStep", equalTo(true)))
|
||||
.andExpect(jsonPath("$.deleted", equalTo(false)));
|
||||
|
||||
final DistributionSet setupdated = distributionSetManagement.get(set.getId()).get();
|
||||
|
||||
assertThat(setupdated.isRequiredMigrationStep()).isEqualTo(true);
|
||||
assertThat(setupdated.getVersion()).isEqualTo("anotherVersion");
|
||||
assertThat(setupdated.getName()).isEqualTo(set.getName());
|
||||
assertThat(setupdated.isDeleted()).isEqualTo(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -363,7 +363,8 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
|
||||
.andExpect(jsonPath("$.description", equalTo("Desc1234")))
|
||||
.andExpect(jsonPath("$.createdBy", equalTo("uploadTester")))
|
||||
.andExpect(jsonPath("$.createdAt", equalTo(testType.getCreatedAt())))
|
||||
.andExpect(jsonPath("$.lastModifiedBy", equalTo("uploadTester")));
|
||||
.andExpect(jsonPath("$.lastModifiedBy", equalTo("uploadTester")))
|
||||
.andExpect(jsonPath("$.deleted", equalTo(testType.isDeleted())));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -401,9 +402,15 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
|
||||
assertThat(distributionSetTypeManagement.count()).isEqualTo(DEFAULT_DS_TYPES + 1);
|
||||
assertThat(distributionSetManagement.count()).isEqualTo(1);
|
||||
|
||||
mvc.perform(delete("/rest/v1/distributionsettypes/{smId}", testType.getId()))
|
||||
mvc.perform(get("/rest/v1/distributionsettypes/{dstId}", testType.getId())).andDo(MockMvcResultPrinter.print())
|
||||
.andExpect(status().isOk()).andExpect(jsonPath("$.deleted", equalTo(false)));
|
||||
|
||||
mvc.perform(delete("/rest/v1/distributionsettypes/{dstId}", testType.getId()))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
||||
|
||||
mvc.perform(get("/rest/v1/distributionsettypes/{dstId}", testType.getId())).andDo(MockMvcResultPrinter.print())
|
||||
.andExpect(status().isOk()).andExpect(jsonPath("$.deleted", equalTo(true)));
|
||||
|
||||
assertThat(distributionSetManagement.count()).isEqualTo(1);
|
||||
assertThat(distributionSetTypeManagement.count()).isEqualTo(DEFAULT_DS_TYPES);
|
||||
}
|
||||
@@ -424,6 +431,20 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
|
||||
.andExpect(jsonPath("$.name", equalTo("TestName123"))).andReturn();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests the update of the deletion flag. It is verfied that the distribution set type can't be marked as deleted through update operation.")
|
||||
public void updateDistributionSetTypeDeletedFlag() throws Exception {
|
||||
final DistributionSetType testType = distributionSetTypeManagement
|
||||
.create(entityFactory.distributionSetType().create().key("test123").name("TestName123").colour("col"));
|
||||
|
||||
final String body = new JSONObject().put("id", testType.getId()).put("deleted", true).toString();
|
||||
|
||||
mvc.perform(put("/rest/v1/distributionsettypes/{dstId}", testType.getId()).content(body)
|
||||
.contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.id", equalTo(testType.getId().intValue())))
|
||||
.andExpect(jsonPath("$.deleted", equalTo(false)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Checks the correct behaviour of /rest/v1/distributionsettypes GET requests with paging.")
|
||||
public void getDistributionSetTypesWithoutAddtionalRequestParameters() throws Exception {
|
||||
|
||||
@@ -249,7 +249,8 @@ public class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTes
|
||||
.andExpect(jsonPath("$.totalTargetsPerStatus.scheduled", equalTo(15)))
|
||||
.andExpect(jsonPath("$.totalTargetsPerStatus.cancelled", equalTo(0)))
|
||||
.andExpect(jsonPath("$.totalTargetsPerStatus.finished", equalTo(0)))
|
||||
.andExpect(jsonPath("$.totalTargetsPerStatus.error", equalTo(0)));
|
||||
.andExpect(jsonPath("$.totalTargetsPerStatus.error", equalTo(0)))
|
||||
.andExpect(jsonPath("$.deleted", equalTo(false)));
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -266,7 +267,8 @@ public class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTes
|
||||
.andExpect(jsonPath("$.totalTargetsPerStatus.scheduled", equalTo(0)))
|
||||
.andExpect(jsonPath("$.totalTargetsPerStatus.cancelled", equalTo(0)))
|
||||
.andExpect(jsonPath("$.totalTargetsPerStatus.finished", equalTo(0)))
|
||||
.andExpect(jsonPath("$.totalTargetsPerStatus.error", equalTo(0)));
|
||||
.andExpect(jsonPath("$.totalTargetsPerStatus.error", equalTo(0)))
|
||||
.andExpect(jsonPath("$.deleted", equalTo(false)));
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -285,7 +287,8 @@ public class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTes
|
||||
.andExpect(jsonPath("$.totalTargetsPerStatus.scheduled", equalTo(0)))
|
||||
.andExpect(jsonPath("$.totalTargetsPerStatus.cancelled", equalTo(0)))
|
||||
.andExpect(jsonPath("$.totalTargetsPerStatus.finished", equalTo(0)))
|
||||
.andExpect(jsonPath("$.totalTargetsPerStatus.error", equalTo(0)));
|
||||
.andExpect(jsonPath("$.totalTargetsPerStatus.error", equalTo(0)))
|
||||
.andExpect(jsonPath("$.deleted", equalTo(false)));
|
||||
}
|
||||
|
||||
@Step
|
||||
@@ -314,7 +317,8 @@ public class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTes
|
||||
.andExpect(
|
||||
jsonPath("$._links.resume.href", allOf(startsWith(HREF_ROLLOUT_PREFIX), endsWith("/resume"))))
|
||||
.andExpect(jsonPath("$._links.groups.href",
|
||||
allOf(startsWith(HREF_ROLLOUT_PREFIX), containsString("/deploygroups"))));
|
||||
allOf(startsWith(HREF_ROLLOUT_PREFIX), containsString("/deploygroups"))))
|
||||
.andExpect(jsonPath("$.deleted", equalTo(false)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -782,6 +786,16 @@ public class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTes
|
||||
assertThat(getRollout(rollout.getId()).getStatus()).isEqualTo(RolloutStatus.DELETING);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Soft deletion of a rollout: soft deletion appears when already running rollout is being deleted")
|
||||
public void deleteRunningRollout() throws Exception {
|
||||
final Rollout rollout = testdataFactory.createSoftDeletedRollout("softDeletedRollout");
|
||||
|
||||
mvc.perform(get("/rest/v1/rollouts/{rolloutid}", rollout.getId())).andDo(MockMvcResultPrinter.print())
|
||||
.andExpect(status().isOk()).andExpect(jsonPath("$.deleted", equalTo(true)));
|
||||
assertThat(getRollout(rollout.getId()).getStatus()).isEqualTo(RolloutStatus.DELETED);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Testing that rollout paged list with rsql parameter")
|
||||
public void getRolloutWithRSQLParam() throws Exception {
|
||||
|
||||
@@ -114,6 +114,38 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests the update of the deletion flag. It is verfied that the software module can't be marked as deleted through update operation.")
|
||||
@WithUser(principal = "smUpdateTester", allSpPermissions = true)
|
||||
public void updateSoftwareModuleDeletedFlag() throws Exception {
|
||||
final String knownSWName = "name1";
|
||||
final String knownSWVersion = "version1";
|
||||
|
||||
SoftwareModule sm = softwareModuleManagement
|
||||
.create(entityFactory.softwareModule().create().type(osType).name(knownSWName).version(knownSWVersion));
|
||||
|
||||
assertThat(sm.isDeleted()).as("Created software module should not be deleted").isEqualTo(false);
|
||||
|
||||
final String body = new JSONObject().put("deleted", true).toString();
|
||||
|
||||
// ensures that we are not to fast so that last modified is not set
|
||||
// correctly
|
||||
Thread.sleep(1);
|
||||
|
||||
mvc.perform(put("/rest/v1/softwaremodules/{smId}", sm.getId()).content(body)
|
||||
.contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.id", equalTo(sm.getId().intValue())))
|
||||
.andExpect(jsonPath("$.lastModifiedBy", equalTo("smUpdateTester")))
|
||||
.andExpect(jsonPath("$.lastModifiedAt", equalTo(sm.getLastModifiedAt())))
|
||||
.andExpect(jsonPath("$.deleted", equalTo(false)));
|
||||
|
||||
sm = softwareModuleManagement.get(sm.getId()).get();
|
||||
assertThat(sm.getLastModifiedBy()).isEqualTo("smUpdateTester");
|
||||
assertThat(sm.getLastModifiedAt()).isEqualTo(sm.getLastModifiedAt());
|
||||
assertThat(sm.isDeleted()).isEqualTo(false);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests the uppload of an artifact binary. The upload is executed and the content checked in the repository for completenes.")
|
||||
public void uploadArtifact() throws Exception {
|
||||
@@ -614,6 +646,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
|
||||
.andExpect(jsonPath("$.description", equalTo(os.getDescription())))
|
||||
.andExpect(jsonPath("$.vendor", equalTo(os.getVendor())))
|
||||
.andExpect(jsonPath("$.type", equalTo(os.getType().getKey())))
|
||||
.andExpect(jsonPath("$.deleted", equalTo(os.isDeleted())))
|
||||
.andExpect(jsonPath("$.createdBy", equalTo("uploadTester")))
|
||||
.andExpect(jsonPath("$.createdAt", equalTo(os.getCreatedAt())))
|
||||
.andExpect(jsonPath("$._links.metadata.href",
|
||||
@@ -706,28 +739,29 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verifies successfull deletion of software modules that are in use, i.e. assigned to a DS which should result in movinf the module to the archive.")
|
||||
@Description("Verifies successfull deletion of a software module that is in use, i.e. assigned to a DS which should result in movinf the module to the archive.")
|
||||
public void deleteAssignedSoftwareModule() throws Exception {
|
||||
final DistributionSet ds1 = testdataFactory.createDistributionSet("a");
|
||||
|
||||
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
||||
|
||||
artifactManagement.create(new ByteArrayInputStream(random), ds1.findFirstModuleByType(appType).get().getId(),
|
||||
"file1", false);
|
||||
final Long appTypeSmId = ds1.findFirstModuleByType(appType).get().getId();
|
||||
|
||||
assertThat(softwareModuleManagement.findAll(PAGE)).hasSize(3);
|
||||
artifactManagement.create(new ByteArrayInputStream(random), appTypeSmId, "file1", false);
|
||||
|
||||
assertThat(softwareModuleManagement.count()).isEqualTo(3);
|
||||
assertThat(artifactManagement.count()).isEqualTo(1);
|
||||
|
||||
mvc.perform(delete("/rest/v1/softwaremodules/{smId}", ds1.findFirstModuleByType(appType).get().getId()))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
||||
mvc.perform(delete("/rest/v1/softwaremodules/{smId}", ds1.findFirstModuleByType(runtimeType).get().getId()))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
||||
mvc.perform(delete("/rest/v1/softwaremodules/{smId}", ds1.findFirstModuleByType(osType).get().getId()))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
||||
mvc.perform(get("/rest/v1/softwaremodules/{smId}", appTypeSmId)).andDo(MockMvcResultPrinter.print())
|
||||
.andExpect(status().isOk()).andExpect(jsonPath("$.deleted", equalTo(false)));
|
||||
|
||||
// all 3 are now marked as deleted
|
||||
assertThat(softwareModuleManagement.findAll(PAGE).getNumber())
|
||||
.as("After delete no softwarmodule should be available").isEqualTo(0);
|
||||
mvc.perform(delete("/rest/v1/softwaremodules/{smId}", appTypeSmId)).andDo(MockMvcResultPrinter.print())
|
||||
.andExpect(status().isOk());
|
||||
|
||||
mvc.perform(get("/rest/v1/softwaremodules/{smId}", appTypeSmId)).andDo(MockMvcResultPrinter.print())
|
||||
.andExpect(status().isOk()).andExpect(jsonPath("$.deleted", equalTo(true)));
|
||||
|
||||
assertThat(softwareModuleManagement.count()).isEqualTo(2);
|
||||
assertThat(artifactManagement.count()).isEqualTo(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -221,7 +221,8 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt
|
||||
.andExpect(jsonPath("$.createdBy", equalTo("uploadTester")))
|
||||
.andExpect(jsonPath("$.createdAt", equalTo(testType.getCreatedAt())))
|
||||
.andExpect(jsonPath("$.lastModifiedBy", equalTo("uploadTester")))
|
||||
.andExpect(jsonPath("$.lastModifiedAt", equalTo(testType.getLastModifiedAt())));
|
||||
.andExpect(jsonPath("$.lastModifiedAt", equalTo(testType.getLastModifiedAt())))
|
||||
.andExpect(jsonPath("$.deleted", equalTo(testType.isDeleted())));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -255,8 +256,14 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt
|
||||
|
||||
assertThat(softwareModuleTypeManagement.count()).isEqualTo(4);
|
||||
|
||||
mvc.perform(delete("/rest/v1/softwaremoduletypes/{smId}", testType.getId())).andDo(MockMvcResultPrinter.print())
|
||||
.andExpect(status().isOk());
|
||||
mvc.perform(get("/rest/v1/softwaremoduletypes/{smtId}", testType.getId())).andDo(MockMvcResultPrinter.print())
|
||||
.andExpect(status().isOk()).andExpect(jsonPath("$.deleted", equalTo(false)));
|
||||
|
||||
mvc.perform(delete("/rest/v1/softwaremoduletypes/{smtId}", testType.getId()))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
||||
|
||||
mvc.perform(get("/rest/v1/softwaremoduletypes/{smtId}", testType.getId())).andDo(MockMvcResultPrinter.print())
|
||||
.andExpect(status().isOk()).andExpect(jsonPath("$.deleted", equalTo(true)));
|
||||
|
||||
assertThat(softwareModuleTypeManagement.count()).isEqualTo(3);
|
||||
}
|
||||
@@ -277,6 +284,24 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests the update of the deletion flag. It is verfied that the software module type can't be marked as deleted through update operation.")
|
||||
public void updateSoftwareModuleTypeDeletedFlag() throws Exception {
|
||||
SoftwareModuleType testType = createTestType();
|
||||
|
||||
final String body = new JSONObject().put("id", testType.getId()).put("deleted", true).toString();
|
||||
|
||||
mvc.perform(put("/rest/v1/softwaremoduletypes/{smtId}", testType.getId()).content(body)
|
||||
.contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.id", equalTo(testType.getId().intValue())))
|
||||
.andExpect(jsonPath("$.lastModifiedAt", equalTo(testType.getLastModifiedAt())))
|
||||
.andExpect(jsonPath("$.deleted", equalTo(false)));
|
||||
|
||||
testType = softwareModuleTypeManagement.get(testType.getId()).get();
|
||||
assertThat(testType.getLastModifiedAt()).isEqualTo(testType.getLastModifiedAt());
|
||||
assertThat(testType.isDeleted()).isEqualTo(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Checks the correct behaviour of /rest/v1/softwaremoduletypes GET requests with paging.")
|
||||
public void getSoftwareModuleTypesWithoutAddtionalRequestParameters() throws Exception {
|
||||
|
||||
@@ -1028,4 +1028,22 @@ public class TestdataFactory {
|
||||
return createRolloutByVariables(prefix, prefix + " description", 10, "controllerId==" + prefix + "*",
|
||||
createDistributionSet(prefix), "50", "5");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the soft deleted {@link Rollout} with a new
|
||||
* {@link DistributionSet} and {@link Target}s.
|
||||
*
|
||||
* @param prefix
|
||||
* for rollouts name, description,
|
||||
* {@link Target#getControllerId()} filter
|
||||
* @return created {@link Rollout}
|
||||
*/
|
||||
public Rollout createSoftDeletedRollout(final String prefix) {
|
||||
final Rollout newRollout = createRollout(prefix);
|
||||
rolloutManagement.start(newRollout.getId());
|
||||
rolloutManagement.handleRollouts();
|
||||
rolloutManagement.delete(newRollout.getId());
|
||||
rolloutManagement.handleRollouts();
|
||||
return newRollout;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user