Added mising update of DS property. (#382)
* Added mising update of DS property. Updated sonar plugin and make sure that test code is not covered by sonar Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
@@ -40,9 +40,6 @@ public class MgmtDistributionSetRequestBodyPost extends MgmtDistributionSetReque
|
||||
@JsonProperty
|
||||
private List<MgmtSoftwareModuleAssigment> modules;
|
||||
|
||||
@JsonProperty
|
||||
private Boolean requiredMigrationStep;
|
||||
|
||||
@JsonProperty
|
||||
private String type;
|
||||
|
||||
@@ -102,25 +99,6 @@ public class MgmtDistributionSetRequestBodyPost extends MgmtDistributionSetReque
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the requiredMigrationStep
|
||||
*/
|
||||
public Boolean isRequiredMigrationStep() {
|
||||
return requiredMigrationStep;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param requiredMigrationStep
|
||||
* the requiredMigrationStep to set
|
||||
*
|
||||
* @return updated body
|
||||
*/
|
||||
public MgmtDistributionSetRequestBodyPost setRequiredMigrationStep(final Boolean requiredMigrationStep) {
|
||||
this.requiredMigrationStep = requiredMigrationStep;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the modules
|
||||
*/
|
||||
|
||||
@@ -30,6 +30,9 @@ public class MgmtDistributionSetRequestBodyPut {
|
||||
@JsonProperty
|
||||
private String version;
|
||||
|
||||
@JsonProperty
|
||||
private Boolean requiredMigrationStep;
|
||||
|
||||
/**
|
||||
* @return the name
|
||||
*/
|
||||
@@ -48,6 +51,25 @@ public class MgmtDistributionSetRequestBodyPut {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the requiredMigrationStep
|
||||
*/
|
||||
public Boolean isRequiredMigrationStep() {
|
||||
return requiredMigrationStep;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param requiredMigrationStep
|
||||
* the requiredMigrationStep to set
|
||||
*
|
||||
* @return updated body
|
||||
*/
|
||||
public MgmtDistributionSetRequestBodyPut setRequiredMigrationStep(final Boolean requiredMigrationStep) {
|
||||
this.requiredMigrationStep = requiredMigrationStep;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the description
|
||||
*/
|
||||
|
||||
@@ -152,7 +152,8 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
|
||||
return new ResponseEntity<>(
|
||||
MgmtDistributionSetMapper.toResponse(distributionSetManagement.updateDistributionSet(
|
||||
entityFactory.distributionSet().update(distributionSetId).name(toUpdate.getName())
|
||||
.description(toUpdate.getDescription()).version(toUpdate.getVersion()))),
|
||||
.description(toUpdate.getDescription()).version(toUpdate.getVersion())
|
||||
.requiredMigrationStep(toUpdate.isRequiredMigrationStep()))),
|
||||
HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetMetadata;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.repository.model.TargetWithActionType;
|
||||
import org.eclipse.hawkbit.repository.test.util.TestdataFactory;
|
||||
import org.eclipse.hawkbit.repository.test.util.WithUser;
|
||||
import org.eclipse.hawkbit.rest.AbstractRestIntegrationTest;
|
||||
@@ -660,17 +661,44 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
|
||||
final DistributionSet set = testdataFactory.createDistributionSet("one");
|
||||
|
||||
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageReq, false, true))
|
||||
.hasSize(1);
|
||||
assertThat(distributionSetManagement.countDistributionSetsAll()).isEqualTo(1);
|
||||
|
||||
mvc.perform(put("/rest/v1/distributionsets/{dsId}", set.getId()).content("{\"version\":\"anotherVersion\"}")
|
||||
mvc.perform(put("/rest/v1/distributionsets/{dsId}", set.getId())
|
||||
.content("{\"version\":\"anotherVersion\",\"requiredMigrationStep\":\"true\"}")
|
||||
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
||||
|
||||
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageReq, false, true)
|
||||
.getContent().get(0).getVersion()).isEqualTo("anotherVersion");
|
||||
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageReq, false, true)
|
||||
.getContent().get(0).getName()).isEqualTo(set.getName());
|
||||
final DistributionSet setupdated = distributionSetManagement.findDistributionSetById(set.getId());
|
||||
|
||||
assertThat(setupdated.isRequiredMigrationStep()).isEqualTo(true);
|
||||
assertThat(setupdated.getVersion()).isEqualTo("anotherVersion");
|
||||
assertThat(setupdated.getName()).isEqualTo(set.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Ensures that DS property update on requiredMigrationStep fails if DS is assigned to a target.")
|
||||
public void updateRequiredMigrationStepFailsIfDistributionSetisInUse() throws Exception {
|
||||
|
||||
// prepare test data
|
||||
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageReq, false, true))
|
||||
.hasSize(0);
|
||||
|
||||
final DistributionSet set = testdataFactory.createDistributionSet("one");
|
||||
deploymentManagement.assignDistributionSet(set.getId(),
|
||||
Lists.newArrayList(new TargetWithActionType(testdataFactory.createTarget().getControllerId())));
|
||||
|
||||
assertThat(distributionSetManagement.countDistributionSetsAll()).isEqualTo(1);
|
||||
|
||||
mvc.perform(put("/rest/v1/distributionsets/{dsId}", set.getId())
|
||||
.content("{\"version\":\"anotherVersion\",\"requiredMigrationStep\":\"true\"}")
|
||||
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isForbidden());
|
||||
|
||||
final DistributionSet setupdated = distributionSetManagement.findDistributionSetById(set.getId());
|
||||
|
||||
assertThat(setupdated.isRequiredMigrationStep()).isEqualTo(false);
|
||||
assertThat(setupdated.getVersion()).isEqualTo(set.getVersion());
|
||||
assertThat(setupdated.getName()).isEqualTo(set.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -8,17 +8,22 @@
|
||||
http://www.eclipse.org/legal/epl-v10.html
|
||||
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-repository</artifactId>
|
||||
<version>0.2.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>hawkbit-repository-test</artifactId>
|
||||
<name>hawkBit :: Repository Test Utilities</name>
|
||||
|
||||
<dependencies>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-repository</artifactId>
|
||||
<version>0.2.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>hawkbit-repository-test</artifactId>
|
||||
<name>hawkBit :: Repository Test Utilities</name>
|
||||
|
||||
<properties>
|
||||
<sonar.skip>true</sonar.skip>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-repository-api</artifactId>
|
||||
@@ -29,7 +34,7 @@
|
||||
<artifactId>hawkbit-repository-core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-artifact-repository-filesystem</artifactId>
|
||||
<version>${project.version}</version>
|
||||
@@ -46,7 +51,7 @@
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-tx</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<dependency>
|
||||
<groupId>net._01001111</groupId>
|
||||
<artifactId>jlorem</artifactId>
|
||||
</dependency>
|
||||
@@ -79,10 +84,10 @@
|
||||
<artifactId>spring-cloud-stream-binder-test</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-stream-test-support</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-stream-test-support</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.protostuff</groupId>
|
||||
<artifactId>protostuff-core</artifactId>
|
||||
</dependency>
|
||||
@@ -99,5 +104,5 @@
|
||||
<groupId>com.jayway.awaitility</groupId>
|
||||
<artifactId>awaitility</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -183,7 +183,7 @@ public abstract class JsonBuilder {
|
||||
|
||||
public static String deploymentActionFeedback(final String id, final String execution, final String finished,
|
||||
final String message) throws JSONException {
|
||||
final List<String> messages = new ArrayList<String>();
|
||||
final List<String> messages = new ArrayList<>();
|
||||
messages.add(message);
|
||||
|
||||
return new JSONObject().put("id", id).put("time", "20140511T121314")
|
||||
@@ -344,7 +344,8 @@ public abstract class JsonBuilder {
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
return new JSONObject().put("name", set.getName()).put("description", set.getDescription())
|
||||
.put("version", set.getVersion()).toString();
|
||||
.put("version", set.getVersion()).put("requiredMigrationStep", set.isRequiredMigrationStep())
|
||||
.toString();
|
||||
|
||||
}
|
||||
|
||||
@@ -399,13 +400,13 @@ public abstract class JsonBuilder {
|
||||
}
|
||||
|
||||
public static String rollout(final String name, final String description, final int groupSize,
|
||||
final long distributionSetId, final String targetFilterQuery, final RolloutGroupConditions conditions) {
|
||||
final long distributionSetId, final String targetFilterQuery, final RolloutGroupConditions conditions) {
|
||||
return rollout(name, description, groupSize, distributionSetId, targetFilterQuery, conditions, null);
|
||||
}
|
||||
|
||||
public static String rollout(final String name, final String description, final Integer groupSize,
|
||||
final long distributionSetId, final String targetFilterQuery, final RolloutGroupConditions conditions,
|
||||
final List<RolloutGroup> groups) {
|
||||
final List<RolloutGroup> groups) {
|
||||
final JSONObject json = new JSONObject();
|
||||
json.put("name", name);
|
||||
json.put("description", description);
|
||||
@@ -435,35 +436,35 @@ public abstract class JsonBuilder {
|
||||
errorAction.put("expression", conditions.getErrorActionExp());
|
||||
}
|
||||
|
||||
if(groups != null) {
|
||||
if (groups != null) {
|
||||
final JSONArray jsonGroups = new JSONArray();
|
||||
|
||||
for (RolloutGroup group : groups) {
|
||||
for (final RolloutGroup group : groups) {
|
||||
final JSONObject jsonGroup = new JSONObject();
|
||||
jsonGroup.put("name", group.getName());
|
||||
jsonGroup.put("description", group.getDescription());
|
||||
jsonGroup.put("targetFilterQuery", group.getTargetFilterQuery());
|
||||
jsonGroup.put("targetPercentage", group.getTargetPercentage());
|
||||
|
||||
if(group.getSuccessCondition() != null) {
|
||||
if (group.getSuccessCondition() != null) {
|
||||
final JSONObject successCondition = new JSONObject();
|
||||
jsonGroup.put("successCondition", successCondition);
|
||||
successCondition.put("condition", group.getSuccessCondition().toString());
|
||||
successCondition.put("expression", group.getSuccessConditionExp());
|
||||
}
|
||||
if(group.getSuccessAction() != null) {
|
||||
if (group.getSuccessAction() != null) {
|
||||
final JSONObject successAction = new JSONObject();
|
||||
jsonGroup.put("successAction", successAction);
|
||||
successAction.put("action", group.getSuccessAction().toString());
|
||||
successAction.put("expression", group.getSuccessActionExp());
|
||||
}
|
||||
if(group.getErrorCondition() != null) {
|
||||
if (group.getErrorCondition() != null) {
|
||||
final JSONObject errorCondition = new JSONObject();
|
||||
jsonGroup.put("errorCondition", errorCondition);
|
||||
errorCondition.put("condition", group.getErrorCondition().toString());
|
||||
errorCondition.put("expression", group.getErrorConditionExp());
|
||||
}
|
||||
if(group.getErrorAction() != null) {
|
||||
if (group.getErrorAction() != null) {
|
||||
final JSONObject errorAction = new JSONObject();
|
||||
jsonGroup.put("errorAction", errorAction);
|
||||
errorAction.put("action", group.getErrorAction().toString());
|
||||
@@ -487,7 +488,7 @@ public abstract class JsonBuilder {
|
||||
|
||||
public static String cancelActionFeedback(final String id, final String execution, final String message)
|
||||
throws JSONException {
|
||||
final List<String> messages = new ArrayList<String>();
|
||||
final List<String> messages = new ArrayList<>();
|
||||
messages.add(message);
|
||||
return new JSONObject().put("id", id).put("time", "20140511T121314")
|
||||
.put("status",
|
||||
|
||||
Reference in New Issue
Block a user