Worked on the interfaces and documentation.
Signed-off-by: Kai Zimmermann <kai.zimmermann@bosch-si.com>
This commit is contained in:
@@ -138,7 +138,7 @@ public class DdiArtifactStoreController implements DdiDlArtifactStoreControllerR
|
||||
.getActionForDownloadByTargetAndSoftwareModule(target.getControllerId(), artifact.getSoftwareModule());
|
||||
final String range = request.getHeader("Range");
|
||||
|
||||
final ActionStatus actionStatus = new ActionStatus();
|
||||
final ActionStatus actionStatus = controllerManagement.generateActionStatus();
|
||||
actionStatus.setAction(action);
|
||||
actionStatus.setOccurredAt(System.currentTimeMillis());
|
||||
actionStatus.setStatus(Status.DOWNLOAD);
|
||||
@@ -150,7 +150,7 @@ public class DdiArtifactStoreController implements DdiDlArtifactStoreControllerR
|
||||
actionStatus.addMessage(
|
||||
ControllerManagement.SERVER_MESSAGE_PREFIX + "Target downloads: " + request.getRequestURI());
|
||||
}
|
||||
controllerManagement.addActionStatusMessage(actionStatus);
|
||||
controllerManagement.addInformationalActionStatus(actionStatus);
|
||||
return action;
|
||||
}
|
||||
|
||||
|
||||
@@ -132,7 +132,7 @@ public class DdiRootController implements DdiRootControllerRestApi {
|
||||
|
||||
return new ResponseEntity<>(
|
||||
DataConversionHelper.fromTarget(target, controllerManagement.findActionByTargetAndActive(target),
|
||||
controllerManagement.findPollingTime(), tenantAware),
|
||||
controllerManagement.getPollingTime(), tenantAware),
|
||||
HttpStatus.OK);
|
||||
}
|
||||
|
||||
@@ -174,7 +174,7 @@ public class DdiRootController implements DdiRootControllerRestApi {
|
||||
.getActionForDownloadByTargetAndSoftwareModule(target.getControllerId(), module);
|
||||
final String range = request.getHeader("Range");
|
||||
|
||||
final ActionStatus statusMessage = new ActionStatus();
|
||||
final ActionStatus statusMessage = controllerManagement.generateActionStatus();
|
||||
statusMessage.setAction(action);
|
||||
statusMessage.setOccurredAt(System.currentTimeMillis());
|
||||
statusMessage.setStatus(Status.DOWNLOAD);
|
||||
@@ -186,7 +186,7 @@ public class DdiRootController implements DdiRootControllerRestApi {
|
||||
statusMessage.addMessage(
|
||||
ControllerManagement.SERVER_MESSAGE_PREFIX + "Target downloads " + request.getRequestURI());
|
||||
}
|
||||
controllerManagement.addActionStatusMessage(statusMessage);
|
||||
controllerManagement.addInformationalActionStatus(statusMessage);
|
||||
return action;
|
||||
}
|
||||
|
||||
@@ -247,8 +247,7 @@ public class DdiRootController implements DdiRootControllerRestApi {
|
||||
|
||||
LOG.debug("Found an active UpdateAction for target {}. returning deyploment: {}", targetid, base);
|
||||
|
||||
controllerManagement.registerRetrieved(action,
|
||||
ControllerManagement.SERVER_MESSAGE_PREFIX
|
||||
controllerManagement.registerRetrieved(action, ControllerManagement.SERVER_MESSAGE_PREFIX
|
||||
+ "Target retrieved update action and should start now the download.");
|
||||
|
||||
return new ResponseEntity<>(base, HttpStatus.OK);
|
||||
@@ -285,8 +284,7 @@ public class DdiRootController implements DdiRootControllerRestApi {
|
||||
return new ResponseEntity<>(HttpStatus.GONE);
|
||||
}
|
||||
|
||||
controllerManagement.addUpdateActionStatus(
|
||||
generateUpdateStatus(feedback, targetid, feedback.getId(), action), action);
|
||||
controllerManagement.addUpdateActionStatus(generateUpdateStatus(feedback, targetid, feedback.getId(), action));
|
||||
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
|
||||
@@ -295,7 +293,7 @@ public class DdiRootController implements DdiRootControllerRestApi {
|
||||
private ActionStatus generateUpdateStatus(final DdiActionFeedback feedback, final String targetid,
|
||||
final Long actionid, final Action action) {
|
||||
|
||||
final ActionStatus actionStatus = new ActionStatus();
|
||||
final ActionStatus actionStatus = controllerManagement.generateActionStatus();
|
||||
actionStatus.setAction(action);
|
||||
actionStatus.setOccurredAt(System.currentTimeMillis());
|
||||
|
||||
@@ -420,15 +418,15 @@ public class DdiRootController implements DdiRootControllerRestApi {
|
||||
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
||||
controllerManagement
|
||||
.addCancelActionStatus(generateActionCancelStatus(feedback, target, feedback.getId(), action), action);
|
||||
controllerManagement.addCancelActionStatus(
|
||||
generateActionCancelStatus(feedback, target, feedback.getId(), action, controllerManagement));
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
private static ActionStatus generateActionCancelStatus(final DdiActionFeedback feedback, final Target target,
|
||||
final Long actionid, final Action action) {
|
||||
final Long actionid, final Action action, final ControllerManagement controllerManagement) {
|
||||
|
||||
final ActionStatus actionStatus = new ActionStatus();
|
||||
final ActionStatus actionStatus = controllerManagement.generateActionStatus();
|
||||
actionStatus.setAction(action);
|
||||
actionStatus.setOccurredAt(System.currentTimeMillis());
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ public class DdiArtifactDownloadTest extends AbstractRestIntegrationTestWithMong
|
||||
@Description("Tests non allowed requests on the artifact ressource, e.g. invalid URI, wrong if-match, wrong command.")
|
||||
public void invalidRequestsOnArtifactResource() throws Exception {
|
||||
// create target
|
||||
Target target = new Target("4712");
|
||||
Target target = targetManagement.generateTarget("4712");
|
||||
target = targetManagement.createTarget(target);
|
||||
final List<Target> targets = new ArrayList<>();
|
||||
targets.add(target);
|
||||
@@ -158,7 +158,7 @@ public class DdiArtifactDownloadTest extends AbstractRestIntegrationTestWithMong
|
||||
@Description("Tests non allowed requests on the artifact ressource, e.g. invalid URI, wrong if-match, wrong command.")
|
||||
public void invalidRequestsOnArtifactResourceByName() throws Exception {
|
||||
// create target
|
||||
Target target = new Target("4712");
|
||||
Target target = targetManagement.generateTarget("4712");
|
||||
target = targetManagement.createTarget(target);
|
||||
final List<Target> targets = new ArrayList<>();
|
||||
targets.add(target);
|
||||
@@ -244,7 +244,7 @@ public class DdiArtifactDownloadTest extends AbstractRestIntegrationTestWithMong
|
||||
assertThat(artifactRepository.findAll()).hasSize(0);
|
||||
|
||||
// create target
|
||||
Target target = new Target("4712");
|
||||
Target target = targetManagement.generateTarget("4712");
|
||||
target = targetManagement.createTarget(target);
|
||||
final List<Target> targets = new ArrayList<Target>();
|
||||
targets.add(target);
|
||||
@@ -287,7 +287,7 @@ public class DdiArtifactDownloadTest extends AbstractRestIntegrationTestWithMong
|
||||
@Description("Tests valid MD5SUm file downloads through the artifact resource by identifying the artifact by ID.")
|
||||
public void downloadMd5sumThroughControllerApi() throws Exception {
|
||||
// create target
|
||||
Target target = new Target("4712");
|
||||
Target target = targetManagement.generateTarget("4712");
|
||||
target = targetManagement.createTarget(target);
|
||||
|
||||
// create ds
|
||||
@@ -325,7 +325,7 @@ public class DdiArtifactDownloadTest extends AbstractRestIntegrationTestWithMong
|
||||
assertThat(artifactRepository.findAll()).hasSize(0);
|
||||
|
||||
// create target
|
||||
Target target = new Target("4712");
|
||||
Target target = targetManagement.generateTarget("4712");
|
||||
target = targetManagement.createTarget(target);
|
||||
final List<Target> targets = new ArrayList();
|
||||
targets.add(target);
|
||||
@@ -356,7 +356,7 @@ public class DdiArtifactDownloadTest extends AbstractRestIntegrationTestWithMong
|
||||
assertThat(artifactRepository.findAll()).hasSize(0);
|
||||
|
||||
// create target
|
||||
Target target = new Target("4712");
|
||||
Target target = targetManagement.generateTarget("4712");
|
||||
target = targetManagement.createTarget(target);
|
||||
final List<Target> targets = new ArrayList<>();
|
||||
targets.add(target);
|
||||
@@ -389,13 +389,13 @@ public class DdiArtifactDownloadTest extends AbstractRestIntegrationTestWithMong
|
||||
Arrays.equals(result.getResponse().getContentAsByteArray(), random));
|
||||
|
||||
// one (update) action
|
||||
assertThat(actionRepository.findByTargetAndDistributionSet(pageReq, target, ds).getContent()).hasSize(1);
|
||||
final Action action = actionRepository.findByTargetAndDistributionSet(pageReq, target, ds).getContent().get(0);
|
||||
assertThat(deploymentManagement.findActionsByTarget(target)).hasSize(1);
|
||||
final Action action = deploymentManagement.findActionsByTarget(target).get(0);
|
||||
|
||||
// one status - download
|
||||
assertThat(actionStatusRepository.findAll()).hasSize(2);
|
||||
assertThat(actionStatusRepository.findByAction(pageReq, action).getContent()).hasSize(2);
|
||||
assertThat(actionStatusRepository.findByAction(new PageRequest(0, 400, Direction.DESC, "id"), action)
|
||||
assertThat(action.getActionStatus()).hasSize(2);
|
||||
assertThat(deploymentManagement.findActionStatusByAction(new PageRequest(0, 400, Direction.DESC, "id"), action)
|
||||
.getContent().get(0).getStatus()).isEqualTo(Status.DOWNLOAD);
|
||||
|
||||
// download complete
|
||||
@@ -407,7 +407,7 @@ public class DdiArtifactDownloadTest extends AbstractRestIntegrationTestWithMong
|
||||
@Description("Test various HTTP range requests for artifact download, e.g. chunk download or download resume.")
|
||||
public void rangeDownloadArtifactByName() throws Exception {
|
||||
// create target
|
||||
Target target = new Target("4712");
|
||||
Target target = targetManagement.generateTarget("4712");
|
||||
target = targetManagement.createTarget(target);
|
||||
final List<Target> targets = new ArrayList<>();
|
||||
targets.add(target);
|
||||
@@ -515,7 +515,7 @@ public class DdiArtifactDownloadTest extends AbstractRestIntegrationTestWithMong
|
||||
assertThat(artifactRepository.findAll()).hasSize(0);
|
||||
|
||||
// create target
|
||||
Target target = new Target("4712");
|
||||
Target target = targetManagement.generateTarget("4712");
|
||||
target = targetManagement.createTarget(target);
|
||||
final List<Target> targets = new ArrayList<>();
|
||||
targets.add(target);
|
||||
@@ -538,7 +538,7 @@ public class DdiArtifactDownloadTest extends AbstractRestIntegrationTestWithMong
|
||||
@Description("Downloads an MD5SUM file by the related artifacts filename.")
|
||||
public void downloadMd5sumFileByName() throws Exception {
|
||||
// create target
|
||||
Target target = new Target("4712");
|
||||
Target target = targetManagement.generateTarget("4712");
|
||||
target = targetManagement.createTarget(target);
|
||||
|
||||
// create ds
|
||||
|
||||
@@ -49,7 +49,7 @@ public class DdiCancelActionTest extends AbstractRestIntegrationTest {
|
||||
@Description("Test of the controller can continue a started update even after a cancel command if it so desires.")
|
||||
public void rootRsCancelActionButContinueAnyway() throws Exception {
|
||||
// prepare test data
|
||||
final Target target = new Target("4712");
|
||||
final Target target = targetManagement.generateTarget("4712");
|
||||
final DistributionSet ds = TestDataUtil.generateDistributionSet("", softwareManagement,
|
||||
distributionSetManagement);
|
||||
final Target savedTarget = targetManagement.createTarget(target);
|
||||
@@ -106,7 +106,7 @@ public class DdiCancelActionTest extends AbstractRestIntegrationTest {
|
||||
@Test
|
||||
@Description("Test for cancel operation of a update action.")
|
||||
public void rootRsCancelAction() throws Exception {
|
||||
final Target target = new Target("4712");
|
||||
final Target target = targetManagement.generateTarget("4712");
|
||||
final DistributionSet ds = TestDataUtil.generateDistributionSet("", softwareManagement,
|
||||
distributionSetManagement);
|
||||
final Target savedTarget = targetManagement.createTarget(target);
|
||||
@@ -224,7 +224,7 @@ public class DdiCancelActionTest extends AbstractRestIntegrationTest {
|
||||
}
|
||||
|
||||
private Action createCancelAction(final String targetid) {
|
||||
final Target target = new Target(targetid);
|
||||
final Target target = targetManagement.generateTarget(targetid);
|
||||
final DistributionSet ds = TestDataUtil.generateDistributionSet(targetid, softwareManagement,
|
||||
distributionSetManagement);
|
||||
final Target savedTarget = targetManagement.createTarget(target);
|
||||
@@ -241,7 +241,7 @@ public class DdiCancelActionTest extends AbstractRestIntegrationTest {
|
||||
@Description("Tests the feedback channel of the cancel operation.")
|
||||
public void rootRsCancelActionFeedback() throws Exception {
|
||||
|
||||
final Target target = new Target("4712");
|
||||
final Target target = targetManagement.generateTarget("4712");
|
||||
final DistributionSet ds = TestDataUtil.generateDistributionSet("", softwareManagement,
|
||||
distributionSetManagement);
|
||||
|
||||
@@ -334,7 +334,7 @@ public class DdiCancelActionTest extends AbstractRestIntegrationTest {
|
||||
@Test
|
||||
@Description("Tests the feeback chanel of for multiple open cancel operations on the same target.")
|
||||
public void multipleCancelActionFeedback() throws Exception {
|
||||
final Target target = new Target("4712");
|
||||
final Target target = targetManagement.generateTarget("4712");
|
||||
final DistributionSet ds = TestDataUtil.generateDistributionSet("", softwareManagement,
|
||||
distributionSetManagement, true);
|
||||
final DistributionSet ds2 = TestDataUtil.generateDistributionSet("2", softwareManagement,
|
||||
@@ -453,7 +453,7 @@ public class DdiCancelActionTest extends AbstractRestIntegrationTest {
|
||||
@Test
|
||||
@Description("Tests the feeback channel closing for too many feedbacks, i.e. denial of service prevention.")
|
||||
public void tooMuchCancelActionFeedback() throws Exception {
|
||||
final Target target = targetManagement.createTarget(new Target("4712"));
|
||||
final Target target = targetManagement.createTarget(targetManagement.generateTarget("4712"));
|
||||
final DistributionSet ds = TestDataUtil.generateDistributionSet("", softwareManagement,
|
||||
distributionSetManagement);
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ public class DdiConfigDataTest extends AbstractIntegrationTest {
|
||||
@Description("We verify that the config data (i.e. device attributes like serial number, hardware revision etc.) "
|
||||
+ "are requested only once from the device.")
|
||||
public void requestConfigDataIfEmpty() throws Exception {
|
||||
final Target target = new Target("4712");
|
||||
final Target target = targetManagement.generateTarget("4712");
|
||||
final Target savedTarget = targetManagement.createTarget(target);
|
||||
|
||||
final long current = System.currentTimeMillis();
|
||||
@@ -84,7 +84,7 @@ public class DdiConfigDataTest extends AbstractIntegrationTest {
|
||||
@Description("We verify that the config data (i.e. device attributes like serial number, hardware revision etc.) "
|
||||
+ "can be uploaded correctly by the controller.")
|
||||
public void putConfigData() throws Exception {
|
||||
targetManagement.createTarget(new Target("4717"));
|
||||
targetManagement.createTarget(targetManagement.generateTarget("4717"));
|
||||
|
||||
// initial
|
||||
final Map<String, String> attributes = new HashMap<>();
|
||||
@@ -127,7 +127,7 @@ public class DdiConfigDataTest extends AbstractIntegrationTest {
|
||||
@Description("We verify that the config data (i.e. device attributes like serial number, hardware revision etc.) "
|
||||
+ "upload limitation is inplace which is meant to protect the server from malicious attempts.")
|
||||
public void putToMuchConfigData() throws Exception {
|
||||
targetManagement.createTarget(new Target("4717"));
|
||||
targetManagement.createTarget(targetManagement.generateTarget("4717"));
|
||||
|
||||
// initial
|
||||
Map<String, String> attributes = new HashMap<>();
|
||||
@@ -150,7 +150,7 @@ public class DdiConfigDataTest extends AbstractIntegrationTest {
|
||||
@Description("We verify that the config data (i.e. device attributes like serial number, hardware revision etc.) "
|
||||
+ "resource behaves as exptected in cae of invalid request attempts.")
|
||||
public void badConfigData() throws Exception {
|
||||
final Target target = new Target("4712");
|
||||
final Target target = targetManagement.generateTarget("4712");
|
||||
final Target savedTarget = targetManagement.createTarget(target);
|
||||
|
||||
// not allowed methods
|
||||
|
||||
@@ -26,6 +26,7 @@ import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.RandomUtils;
|
||||
import org.eclipse.hawkbit.TestDataUtil;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.Action;
|
||||
import org.eclipse.hawkbit.repository.model.Action.ActionType;
|
||||
import org.eclipse.hawkbit.repository.model.Action.Status;
|
||||
@@ -40,8 +41,6 @@ import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
||||
import org.fest.assertions.core.Condition;
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.domain.Sort.Direction;
|
||||
import org.springframework.hateoas.MediaTypes;
|
||||
import org.springframework.http.MediaType;
|
||||
@@ -96,7 +95,7 @@ public class DdiDeploymentBaseTest extends AbstractRestIntegrationTestWithMongoD
|
||||
@Description("Forced deployment to a controller. Checks if the resource reponse payload for a given deployment is as expected.")
|
||||
public void deplomentForceAction() throws Exception {
|
||||
// Prepare test data
|
||||
final Target target = new Target("4712");
|
||||
final Target target = targetManagement.generateTarget("4712");
|
||||
final DistributionSet ds = TestDataUtil.generateDistributionSet("", softwareManagement,
|
||||
distributionSetManagement, true);
|
||||
final DistributionSet ds2 = TestDataUtil.generateDistributionSet("2", softwareManagement,
|
||||
@@ -228,9 +227,9 @@ public class DdiDeploymentBaseTest extends AbstractRestIntegrationTestWithMongoD
|
||||
.isGreaterThanOrEqualTo(current);
|
||||
|
||||
// Retrieved is reported
|
||||
final Iterable<ActionStatus> actionStatusMessages = actionStatusRepository
|
||||
.findAll(new PageRequest(0, 100, Direction.DESC, "id"));
|
||||
assertThat(actionStatusMessages).hasSize(3);
|
||||
final Iterable<ActionStatus> actionStatusMessages = deploymentManagement
|
||||
.findActionStatusByAction(new PageRequest(0, 100, Direction.DESC, "id"), uaction);
|
||||
assertThat(actionStatusMessages).hasSize(2);
|
||||
final ActionStatus actionStatusMessage = actionStatusMessages.iterator().next();
|
||||
assertThat(actionStatusMessage.getStatus()).isEqualTo(Status.RETRIEVED);
|
||||
}
|
||||
@@ -239,7 +238,7 @@ public class DdiDeploymentBaseTest extends AbstractRestIntegrationTestWithMongoD
|
||||
@Description("Attempt/soft deployment to a controller. Checks if the resource reponse payload for a given deployment is as expected.")
|
||||
public void deplomentAttemptAction() throws Exception {
|
||||
// Prepare test data
|
||||
final Target target = new Target("4712");
|
||||
final Target target = targetManagement.generateTarget("4712");
|
||||
final DistributionSet ds = TestDataUtil.generateDistributionSet("", softwareManagement,
|
||||
distributionSetManagement, true);
|
||||
final DistributionSet ds2 = TestDataUtil.generateDistributionSet("2", softwareManagement,
|
||||
@@ -361,9 +360,9 @@ public class DdiDeploymentBaseTest extends AbstractRestIntegrationTestWithMongoD
|
||||
.isGreaterThanOrEqualTo(current);
|
||||
|
||||
// Retrieved is reported
|
||||
final Iterable<ActionStatus> actionStatusMessages = actionStatusRepository
|
||||
.findAll(new PageRequest(0, 100, Direction.DESC, "id"));
|
||||
assertThat(actionStatusMessages).hasSize(3);
|
||||
final List<ActionStatus> actionStatusMessages = deploymentManagement
|
||||
.findActionStatusByAction(new PageRequest(0, 100, Direction.DESC, "id"), uaction).getContent();
|
||||
assertThat(actionStatusMessages).hasSize(2);
|
||||
final ActionStatus actionStatusMessage = actionStatusMessages.iterator().next();
|
||||
assertThat(actionStatusMessage.getStatus()).isEqualTo(Status.RETRIEVED);
|
||||
}
|
||||
@@ -372,7 +371,7 @@ public class DdiDeploymentBaseTest extends AbstractRestIntegrationTestWithMongoD
|
||||
@Description("Attempt/soft deployment to a controller including automated switch to hard. Checks if the resource reponse payload for a given deployment is as expected.")
|
||||
public void deplomentAutoForceAction() throws Exception {
|
||||
// Prepare test data
|
||||
final Target target = new Target("4712");
|
||||
final Target target = targetManagement.generateTarget("4712");
|
||||
final DistributionSet ds = TestDataUtil.generateDistributionSet("", softwareManagement,
|
||||
distributionSetManagement, true);
|
||||
final DistributionSet ds2 = TestDataUtil.generateDistributionSet("2", softwareManagement,
|
||||
@@ -503,9 +502,9 @@ public class DdiDeploymentBaseTest extends AbstractRestIntegrationTestWithMongoD
|
||||
.isGreaterThanOrEqualTo(current);
|
||||
|
||||
// Retrieved is reported
|
||||
final Iterable<ActionStatus> actionStatusMessages = actionStatusRepository
|
||||
.findAll(new PageRequest(0, 100, Direction.DESC, "id"));
|
||||
assertThat(actionStatusMessages).hasSize(3);
|
||||
final Iterable<ActionStatus> actionStatusMessages = deploymentManagement
|
||||
.findActionStatusByAction(new PageRequest(0, 100, Direction.DESC, "id"), uaction).getContent();
|
||||
assertThat(actionStatusMessages).hasSize(2);
|
||||
final ActionStatus actionStatusMessage = actionStatusMessages.iterator().next();
|
||||
assertThat(actionStatusMessage.getStatus()).isEqualTo(Status.RETRIEVED);
|
||||
}
|
||||
@@ -513,7 +512,7 @@ public class DdiDeploymentBaseTest extends AbstractRestIntegrationTestWithMongoD
|
||||
@Test
|
||||
@Description("Test various invalid access attempts to the deployment resource und the expected behaviour of the server.")
|
||||
public void badDeploymentAction() throws Exception {
|
||||
final Target target = targetManagement.createTarget(new Target("4712"));
|
||||
final Target target = targetManagement.createTarget(targetManagement.generateTarget("4712"));
|
||||
|
||||
// not allowed methods
|
||||
mvc.perform(post("/{tenant}/controller/v1/4712/deploymentBase/1", tenantAware.getCurrentTenant()))
|
||||
@@ -534,7 +533,7 @@ public class DdiDeploymentBaseTest extends AbstractRestIntegrationTestWithMongoD
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound());
|
||||
|
||||
// wrong media type
|
||||
final List<Target> toAssign = new ArrayList<Target>();
|
||||
final List<Target> toAssign = new ArrayList<>();
|
||||
toAssign.add(target);
|
||||
final DistributionSet savedSet = TestDataUtil.generateDistributionSet("", softwareManagement,
|
||||
distributionSetManagement);
|
||||
@@ -554,16 +553,15 @@ public class DdiDeploymentBaseTest extends AbstractRestIntegrationTestWithMongoD
|
||||
@Description("The server protects itself against to many feedback upload attempts. The test verfies that "
|
||||
+ "it is not possible to exceed the configured maximum number of feedback uplods.")
|
||||
public void toMuchDeplomentActionFeedback() throws Exception {
|
||||
final Target target = targetManagement.createTarget(new Target("4712"));
|
||||
final Target target = targetManagement.createTarget(targetManagement.generateTarget("4712"));
|
||||
final DistributionSet ds = TestDataUtil.generateDistributionSet("", softwareManagement,
|
||||
distributionSetManagement);
|
||||
|
||||
final List<Target> toAssign = new ArrayList<Target>();
|
||||
final List<Target> toAssign = new ArrayList<>();
|
||||
toAssign.add(target);
|
||||
|
||||
deploymentManagement.assignDistributionSet(ds.getId(), new String[] { "4712" });
|
||||
final Pageable pageReq = new PageRequest(0, 100);
|
||||
final Action action = actionRepository.findByDistributionSet(pageReq, ds).getContent().get(0);
|
||||
final Action action = deploymentManagement.findActionsByTarget(target).get(0);
|
||||
|
||||
final String feedback = JsonBuilder.deploymentActionFeedback(action.getId().toString(), "proceeding");
|
||||
// assign distribution set creates an action status, so only 99 left
|
||||
@@ -583,9 +581,9 @@ public class DdiDeploymentBaseTest extends AbstractRestIntegrationTestWithMongoD
|
||||
@Test
|
||||
@Description("Multiple uploads of deployment status feedback to the server.")
|
||||
public void multipleDeplomentActionFeedback() throws Exception {
|
||||
final Target target1 = new Target("4712");
|
||||
final Target target2 = new Target("4713");
|
||||
final Target target3 = new Target("4714");
|
||||
final Target target1 = targetManagement.generateTarget("4712");
|
||||
final Target target2 = targetManagement.generateTarget("4713");
|
||||
final Target target3 = targetManagement.generateTarget("4714");
|
||||
final Target savedTarget1 = targetManagement.createTarget(target1);
|
||||
targetManagement.createTarget(target2);
|
||||
targetManagement.createTarget(target3);
|
||||
@@ -597,7 +595,7 @@ public class DdiDeploymentBaseTest extends AbstractRestIntegrationTestWithMongoD
|
||||
final DistributionSet ds3 = TestDataUtil.generateDistributionSet("3", softwareManagement,
|
||||
distributionSetManagement, true);
|
||||
|
||||
final List<Target> toAssign = new ArrayList<Target>();
|
||||
final List<Target> toAssign = new ArrayList<>();
|
||||
toAssign.add(savedTarget1);
|
||||
|
||||
final Action action1 = deploymentManagement.findActionWithDetails(
|
||||
@@ -637,7 +635,8 @@ public class DdiDeploymentBaseTest extends AbstractRestIntegrationTestWithMongoD
|
||||
assertThat(myT.getTargetInfo().getInstalledDistributionSet().getId()).isEqualTo(ds1.getId());
|
||||
assertThat(myT.getAssignedDistributionSet()).isEqualTo(ds3);
|
||||
|
||||
Iterable<ActionStatus> actionStatusMessages = actionStatusRepository.findAll(new Sort(Direction.DESC, "id"));
|
||||
Iterable<ActionStatus> actionStatusMessages = deploymentManagement
|
||||
.findActionStatusAll(new PageRequest(0, 100, Direction.DESC, "id")).getContent();
|
||||
assertThat(actionStatusMessages).hasSize(4);
|
||||
assertThat(actionStatusMessages.iterator().next().getStatus()).isEqualTo(Status.FINISHED);
|
||||
|
||||
@@ -657,7 +656,8 @@ public class DdiDeploymentBaseTest extends AbstractRestIntegrationTestWithMongoD
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(myT)).hasSize(1);
|
||||
assertThat(myT.getTargetInfo().getInstalledDistributionSet().getId()).isEqualTo(ds2.getId());
|
||||
assertThat(myT.getAssignedDistributionSet()).isEqualTo(ds3);
|
||||
actionStatusMessages = actionStatusRepository.findAll(new PageRequest(0, 100, Direction.DESC, "id"));
|
||||
actionStatusMessages = deploymentManagement.findActionStatusAll(new PageRequest(0, 100, Direction.DESC, "id"))
|
||||
.getContent();
|
||||
assertThat(actionStatusMessages).hasSize(5);
|
||||
assertThat(actionStatusMessages).haveAtLeast(1, new ActionStatusCondition(Status.FINISHED));
|
||||
|
||||
@@ -676,7 +676,8 @@ public class DdiDeploymentBaseTest extends AbstractRestIntegrationTestWithMongoD
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(myT)).hasSize(0);
|
||||
assertThat(myT.getTargetInfo().getInstalledDistributionSet()).isEqualTo(ds3);
|
||||
assertThat(myT.getAssignedDistributionSet()).isEqualTo(ds3);
|
||||
actionStatusMessages = actionStatusRepository.findAll();
|
||||
actionStatusMessages = deploymentManagement.findActionStatusAll(new PageRequest(0, 100, Direction.DESC, "id"))
|
||||
.getContent();
|
||||
assertThat(actionStatusMessages).hasSize(6);
|
||||
assertThat(actionStatusMessages).haveAtLeast(1, new ActionStatusCondition(Status.FINISHED));
|
||||
|
||||
@@ -685,18 +686,19 @@ public class DdiDeploymentBaseTest extends AbstractRestIntegrationTestWithMongoD
|
||||
@Test
|
||||
@Description("Verfies that an update action is correctly set to error if the controller provides error feedback.")
|
||||
public void rootRsSingleDeplomentActionWithErrorFeedback() throws Exception {
|
||||
final Target target = new Target("4712");
|
||||
final Target target = targetManagement.generateTarget("4712");
|
||||
DistributionSet ds = TestDataUtil.generateDistributionSet("", softwareManagement, distributionSetManagement);
|
||||
|
||||
final Target savedTarget = targetManagement.createTarget(target);
|
||||
|
||||
List<Target> toAssign = new ArrayList<Target>();
|
||||
List<Target> toAssign = new ArrayList<>();
|
||||
toAssign.add(savedTarget);
|
||||
|
||||
assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus())
|
||||
.isEqualTo(TargetUpdateStatus.UNKNOWN);
|
||||
deploymentManagement.assignDistributionSet(ds, toAssign);
|
||||
final Action action = actionRepository.findByDistributionSet(pageReq, ds).getContent().get(0);
|
||||
final Action action = actionRepository.findByDistributionSet(pageReq, (JpaDistributionSet) ds).getContent()
|
||||
.get(0);
|
||||
|
||||
long current = System.currentTimeMillis();
|
||||
long lastModified = targetManagement.findTargetByControllerID("4712").getLastModifiedAt();
|
||||
@@ -719,7 +721,8 @@ public class DdiDeploymentBaseTest extends AbstractRestIntegrationTestWithMongoD
|
||||
.hasSize(0);
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(myT)).hasSize(0);
|
||||
assertThat(deploymentManagement.findActionsByTarget(myT)).hasSize(1);
|
||||
final Iterable<ActionStatus> actionStatusMessages = actionStatusRepository.findAll();
|
||||
final Iterable<ActionStatus> actionStatusMessages = deploymentManagement
|
||||
.findActionStatusAll(new PageRequest(0, 100, Direction.DESC, "id")).getContent();
|
||||
assertThat(actionStatusMessages).hasSize(2);
|
||||
assertThat(actionStatusMessages).haveAtLeast(1, new ActionStatusCondition(Status.ERROR));
|
||||
|
||||
@@ -751,9 +754,9 @@ public class DdiDeploymentBaseTest extends AbstractRestIntegrationTestWithMongoD
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(myT)).hasSize(0);
|
||||
assertThat(deploymentManagement.findInActiveActionsByTarget(myT)).hasSize(2);
|
||||
assertThat(actionStatusRepository.findAll()).hasSize(4);
|
||||
assertThat(actionStatusRepository.findByAction(pageReq, action).getContent()).haveAtLeast(1,
|
||||
assertThat(deploymentManagement.findActionStatusByAction(pageReq, action).getContent()).haveAtLeast(1,
|
||||
new ActionStatusCondition(Status.ERROR));
|
||||
assertThat(actionStatusRepository.findByAction(pageReq, action2).getContent()).haveAtLeast(1,
|
||||
assertThat(deploymentManagement.findActionStatusByAction(pageReq, action2).getContent()).haveAtLeast(1,
|
||||
new ActionStatusCondition(Status.FINISHED));
|
||||
|
||||
}
|
||||
@@ -761,27 +764,29 @@ public class DdiDeploymentBaseTest extends AbstractRestIntegrationTestWithMongoD
|
||||
@Test
|
||||
@Description("Verfies that the controller can provided as much feedback entries as necessry as long as it is in the configured limites.")
|
||||
public void rootRsSingleDeplomentActionFeedback() throws Exception {
|
||||
final Target target = new Target("4712");
|
||||
final Target target = targetManagement.generateTarget("4712");
|
||||
final DistributionSet ds = TestDataUtil.generateDistributionSet("", softwareManagement,
|
||||
distributionSetManagement);
|
||||
|
||||
final Target savedTarget = targetManagement.createTarget(target);
|
||||
|
||||
final List<Target> toAssign = new ArrayList<Target>();
|
||||
final List<Target> toAssign = new ArrayList<>();
|
||||
toAssign.add(savedTarget);
|
||||
|
||||
Target myT = targetManagement.findTargetByControllerID("4712");
|
||||
assertThat(myT.getTargetInfo().getUpdateStatus()).isEqualTo(TargetUpdateStatus.UNKNOWN);
|
||||
deploymentManagement.assignDistributionSet(ds, toAssign);
|
||||
final Action action = actionRepository.findByDistributionSet(pageReq, ds).getContent().get(0);
|
||||
final Action action = actionRepository.findByDistributionSet(pageReq, (JpaDistributionSet) ds).getContent()
|
||||
.get(0);
|
||||
|
||||
myT = targetManagement.findTargetByControllerID("4712");
|
||||
assertThat(myT.getTargetInfo().getUpdateStatus()).isEqualTo(TargetUpdateStatus.PENDING);
|
||||
assertThat(targetRepository.findByTargetInfoInstalledDistributionSet(new PageRequest(0, 10), ds)).hasSize(0);
|
||||
assertThat(targetRepository.findByAssignedDistributionSet(new PageRequest(0, 10), ds)).hasSize(1);
|
||||
assertThat(targetRepository
|
||||
.findByAssignedDistributionSetOrTargetInfoInstalledDistributionSet(new PageRequest(0, 10), ds, ds))
|
||||
.hasSize(1);
|
||||
assertThat(targetRepository.findByTargetInfoInstalledDistributionSet(new PageRequest(0, 10),
|
||||
(JpaDistributionSet) ds)).hasSize(0);
|
||||
assertThat(targetRepository.findByAssignedDistributionSet(new PageRequest(0, 10), (JpaDistributionSet) ds))
|
||||
.hasSize(1);
|
||||
assertThat(targetRepository.findByAssignedDistributionSetOrTargetInfoInstalledDistributionSet(
|
||||
new PageRequest(0, 10), (JpaDistributionSet) ds, (JpaDistributionSet) ds)).hasSize(1);
|
||||
|
||||
// Now valid Feedback
|
||||
|
||||
@@ -903,18 +908,19 @@ public class DdiDeploymentBaseTest extends AbstractRestIntegrationTestWithMongoD
|
||||
assertThat(actionStatusRepository.findAll()).haveAtLeast(1, new ActionStatusCondition(Status.CANCELED));
|
||||
assertThat(actionStatusRepository.findAll()).haveAtLeast(1, new ActionStatusCondition(Status.FINISHED));
|
||||
|
||||
assertThat(targetRepository.findByTargetInfoInstalledDistributionSet(new PageRequest(0, 10), ds)).hasSize(1);
|
||||
assertThat(targetRepository.findByAssignedDistributionSet(new PageRequest(0, 10), ds)).hasSize(1);
|
||||
assertThat(targetRepository
|
||||
.findByAssignedDistributionSetOrTargetInfoInstalledDistributionSet(new PageRequest(0, 10), ds, ds))
|
||||
.hasSize(1);
|
||||
assertThat(targetRepository.findByTargetInfoInstalledDistributionSet(new PageRequest(0, 10),
|
||||
(JpaDistributionSet) ds)).hasSize(1);
|
||||
assertThat(targetRepository.findByAssignedDistributionSet(new PageRequest(0, 10), (JpaDistributionSet) ds))
|
||||
.hasSize(1);
|
||||
assertThat(targetRepository.findByAssignedDistributionSetOrTargetInfoInstalledDistributionSet(
|
||||
new PageRequest(0, 10), (JpaDistributionSet) ds, (JpaDistributionSet) ds)).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Various forbidden request appempts on the feedback resource. Ensures correct answering behaviour as expected to these kind of errors.")
|
||||
public void badDeplomentActionFeedback() throws Exception {
|
||||
final Target target = new Target("4712");
|
||||
final Target target2 = new Target("4713");
|
||||
final Target target = targetManagement.generateTarget("4712");
|
||||
final Target target2 = targetManagement.generateTarget("4713");
|
||||
final DistributionSet savedSet = TestDataUtil.generateDistributionSet("", softwareManagement,
|
||||
distributionSetManagement);
|
||||
final DistributionSet savedSet2 = TestDataUtil.generateDistributionSet("1", softwareManagement,
|
||||
|
||||
@@ -80,7 +80,7 @@ public class DdiRootControllerTest extends AbstractRestIntegrationTestWithMongoD
|
||||
// create target first with "knownPrincipal" user and audit data
|
||||
final String knownTargetControllerId = "target1";
|
||||
final String knownCreatedBy = "knownPrincipal";
|
||||
targetManagement.createTarget(new Target(knownTargetControllerId));
|
||||
targetManagement.createTarget(targetManagement.generateTarget(knownTargetControllerId));
|
||||
final Target findTargetByControllerID = targetManagement.findTargetByControllerID(knownTargetControllerId);
|
||||
assertThat(findTargetByControllerID.getCreatedBy()).isEqualTo(knownCreatedBy);
|
||||
assertThat(findTargetByControllerID.getCreatedAt()).isNotNull();
|
||||
@@ -226,7 +226,7 @@ public class DdiRootControllerTest extends AbstractRestIntegrationTestWithMongoD
|
||||
@Description("Ensures that the target state machine of a precomissioned target switches from "
|
||||
+ "UNKNOWN to REGISTERED when the target polls for the first time.")
|
||||
public void rootRsPrecommissioned() throws Exception {
|
||||
final Target target = new Target("4711");
|
||||
final Target target = targetManagement.generateTarget("4711");
|
||||
targetManagement.createTarget(target);
|
||||
|
||||
assertThat(targetRepository.findByControllerId("4711").getTargetInfo().getUpdateStatus())
|
||||
@@ -265,7 +265,7 @@ public class DdiRootControllerTest extends AbstractRestIntegrationTestWithMongoD
|
||||
public void tryToFinishAnUpdateProcessAfterItHasBeenFinished() throws Exception {
|
||||
|
||||
// mock
|
||||
final Target target = new Target("911");
|
||||
final Target target = targetManagement.generateTarget("911");
|
||||
final DistributionSet ds = TestDataUtil.generateDistributionSet("", softwareManagement,
|
||||
distributionSetManagement);
|
||||
Target savedTarget = targetManagement.createTarget(target);
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.eclipse.hawkbit.dmf.json.model.SoftwareModule;
|
||||
import org.eclipse.hawkbit.eventbus.EventSubscriber;
|
||||
import org.eclipse.hawkbit.eventbus.event.CancelTargetAssignmentEvent;
|
||||
import org.eclipse.hawkbit.eventbus.event.TargetAssignDistributionSetEvent;
|
||||
import org.eclipse.hawkbit.repository.SoftwareManagement;
|
||||
import org.eclipse.hawkbit.repository.model.LocalArtifact;
|
||||
import org.eclipse.hawkbit.util.IpUtil;
|
||||
import org.springframework.amqp.core.Message;
|
||||
@@ -52,6 +53,9 @@ public class AmqpMessageDispatcherService extends BaseAmqpService {
|
||||
@Autowired
|
||||
private AmqpSenderService amqpSenderService;
|
||||
|
||||
@Autowired
|
||||
private SoftwareManagement softwareManagement;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
|
||||
@@ -336,7 +336,7 @@ public class AmqpMessageHandlerService extends BaseAmqpService {
|
||||
final ActionUpdateStatus actionUpdateStatus = convertMessage(message, ActionUpdateStatus.class);
|
||||
final Action action = checkActionExist(message, actionUpdateStatus);
|
||||
|
||||
final ActionStatus actionStatus = new ActionStatus();
|
||||
final ActionStatus actionStatus = controllerManagement.generateActionStatus();
|
||||
actionUpdateStatus.getMessage().forEach(actionStatus::addMessage);
|
||||
|
||||
actionStatus.setAction(action);
|
||||
|
||||
@@ -40,11 +40,14 @@ import org.eclipse.hawkbit.eventbus.event.TargetAssignDistributionSetEvent;
|
||||
import org.eclipse.hawkbit.repository.ArtifactManagement;
|
||||
import org.eclipse.hawkbit.repository.ControllerManagement;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaAction;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaActionStatus;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaSoftwareModule;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaTarget;
|
||||
import org.eclipse.hawkbit.repository.model.Action;
|
||||
import org.eclipse.hawkbit.repository.model.Action.Status;
|
||||
import org.eclipse.hawkbit.repository.model.LocalArtifact;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.repository.model.helper.SecurityTokenGeneratorHolder;
|
||||
import org.eclipse.hawkbit.security.SecurityTokenGenerator;
|
||||
import org.junit.Before;
|
||||
@@ -347,6 +350,7 @@ public class AmqpMessageHandlerServiceTest {
|
||||
final Action action = createActionWithTarget(22L, Status.FINISHED);
|
||||
when(controllerManagementMock.findActionWithDetails(Matchers.any())).thenReturn(action);
|
||||
when(controllerManagementMock.addUpdateActionStatus(Matchers.any())).thenReturn(action);
|
||||
when(controllerManagementMock.generateActionStatus()).thenReturn(new JpaActionStatus());
|
||||
// for the test the same action can be used
|
||||
final List<Action> actionList = new ArrayList<>();
|
||||
actionList.add(action);
|
||||
@@ -409,7 +413,7 @@ public class AmqpMessageHandlerServiceTest {
|
||||
|
||||
private List<SoftwareModule> createSoftwareModuleList() {
|
||||
final List<SoftwareModule> softwareModuleList = new ArrayList<>();
|
||||
final SoftwareModule softwareModule = new SoftwareModule();
|
||||
final JpaSoftwareModule softwareModule = new JpaSoftwareModule();
|
||||
softwareModule.setId(777L);
|
||||
softwareModuleList.add(softwareModule);
|
||||
return softwareModuleList;
|
||||
@@ -420,11 +424,11 @@ public class AmqpMessageHandlerServiceTest {
|
||||
initalizeSecurityTokenGenerator();
|
||||
|
||||
// Mock
|
||||
final Action action = new Action();
|
||||
final JpaAction action = new JpaAction();
|
||||
action.setId(targetId);
|
||||
action.setStatus(status);
|
||||
action.setTenant("DEFAULT");
|
||||
final Target target = new Target("target1");
|
||||
final JpaTarget target = new JpaTarget("target1");
|
||||
action.setTarget(target);
|
||||
|
||||
return action;
|
||||
|
||||
@@ -21,6 +21,43 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public enum ActionStatus {
|
||||
/**
|
||||
* Action requests download by this target which has now started.
|
||||
*/
|
||||
DOWNLOAD,
|
||||
|
||||
DOWNLOAD, RETRIEVED, RUNNING, FINISHED, ERROR, WARNING, CANCELED, CANCEL_REJECTED;
|
||||
/**
|
||||
* Action has been send to the target.
|
||||
*/
|
||||
RETRIEVED,
|
||||
|
||||
/**
|
||||
* Action is still running for this target.
|
||||
*/
|
||||
RUNNING,
|
||||
|
||||
/**
|
||||
* Action is finished successfully for this target.
|
||||
*/
|
||||
FINISHED,
|
||||
|
||||
/**
|
||||
* Action has failed for this target.
|
||||
*/
|
||||
ERROR,
|
||||
|
||||
/**
|
||||
* Action is still running but with warnings.
|
||||
*/
|
||||
WARNING,
|
||||
|
||||
/**
|
||||
* Action has been canceled for this target.
|
||||
*/
|
||||
CANCELED,
|
||||
|
||||
/**
|
||||
* Cancellation has been rejected by the target..
|
||||
*/
|
||||
CANCEL_REJECTED;
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ public final class MgmtDistributionSetMapper {
|
||||
static DistributionSet fromRequest(final MgmtDistributionSetRequestBodyPost dsRest,
|
||||
final SoftwareManagement softwareManagement, final DistributionSetManagement distributionSetManagement) {
|
||||
|
||||
final DistributionSet result = new DistributionSet();
|
||||
final DistributionSet result = distributionSetManagement.generateDistributionSet();
|
||||
result.setDescription(dsRest.getDescription());
|
||||
result.setName(dsRest.getName());
|
||||
result.setType(findDistributionSetTypeWithExceptionIfNotFound(dsRest.getType(), distributionSetManagement));
|
||||
@@ -135,13 +135,14 @@ public final class MgmtDistributionSetMapper {
|
||||
* @return
|
||||
*/
|
||||
static List<DistributionSetMetadata> fromRequestDsMetadata(final DistributionSet ds,
|
||||
final List<MgmtMetadata> metadata) {
|
||||
final List<MgmtMetadata> metadata, final DistributionSetManagement distributionSetManagement) {
|
||||
final List<DistributionSetMetadata> mappedList = new ArrayList<>(metadata.size());
|
||||
for (final MgmtMetadata metadataRest : metadata) {
|
||||
if (metadataRest.getKey() == null) {
|
||||
throw new IllegalArgumentException("the key of the metadata must be present");
|
||||
}
|
||||
mappedList.add(new DistributionSetMetadata(metadataRest.getKey(), ds, metadataRest.getValue()));
|
||||
mappedList.add(distributionSetManagement.generateDistributionSetMetadata(ds, metadataRest.getKey(),
|
||||
metadataRest.getValue()));
|
||||
}
|
||||
return mappedList;
|
||||
}
|
||||
@@ -170,12 +171,11 @@ public final class MgmtDistributionSetMapper {
|
||||
|
||||
response.setRequiredMigrationStep(distributionSet.isRequiredMigrationStep());
|
||||
|
||||
response.add(
|
||||
linkTo(methodOn(MgmtDistributionSetRestApi.class).getDistributionSet(response.getDsId())).withRel("self"));
|
||||
response.add(linkTo(methodOn(MgmtDistributionSetRestApi.class).getDistributionSet(response.getDsId()))
|
||||
.withRel("self"));
|
||||
|
||||
response.add(linkTo(
|
||||
methodOn(MgmtDistributionSetTypeRestApi.class).getDistributionSetType(distributionSet.getType().getId()))
|
||||
.withRel("type"));
|
||||
response.add(linkTo(methodOn(MgmtDistributionSetTypeRestApi.class)
|
||||
.getDistributionSetType(distributionSet.getType().getId())).withRel("type"));
|
||||
|
||||
response.add(linkTo(methodOn(MgmtDistributionSetRestApi.class).getMetadata(response.getDsId(),
|
||||
Integer.parseInt(MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET),
|
||||
@@ -206,7 +206,7 @@ public final class MgmtDistributionSetMapper {
|
||||
|
||||
static MgmtMetadata toResponseDsMetadata(final DistributionSetMetadata metadata) {
|
||||
final MgmtMetadata metadataRest = new MgmtMetadata();
|
||||
metadataRest.setKey(metadata.getId().getKey());
|
||||
metadataRest.setKey(metadata.getKey());
|
||||
metadataRest.setValue(metadata.getValue());
|
||||
return metadataRest;
|
||||
}
|
||||
|
||||
@@ -27,22 +27,18 @@ import org.eclipse.hawkbit.mgmt.rest.api.MgmtDistributionSetRestApi;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
|
||||
import org.eclipse.hawkbit.repository.DeploymentManagement;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetAssignmentResult;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetFields;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetMetadataFields;
|
||||
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
|
||||
import org.eclipse.hawkbit.repository.SoftwareManagement;
|
||||
import org.eclipse.hawkbit.repository.SystemManagement;
|
||||
import org.eclipse.hawkbit.repository.TargetFields;
|
||||
import org.eclipse.hawkbit.repository.TargetManagement;
|
||||
import org.eclipse.hawkbit.repository.TargetWithActionType;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||
import org.eclipse.hawkbit.repository.jpa.TargetWithActionType;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.DsMetadataCompositeKey;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetMetadata;
|
||||
import org.eclipse.hawkbit.repository.model.DsMetadataCompositeKey;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.repository.rsql.RSQLUtility;
|
||||
import org.eclipse.hawkbit.tenancy.TenantAware;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -96,10 +92,9 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
|
||||
final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting);
|
||||
final Page<DistributionSet> findDsPage;
|
||||
if (rsqlParam != null) {
|
||||
findDsPage = this.distributionSetManagement.findDistributionSetsAll(
|
||||
RSQLUtility.parse(rsqlParam, DistributionSetFields.class), pageable, false);
|
||||
findDsPage = this.distributionSetManagement.findDistributionSetsAll(rsqlParam, pageable, false);
|
||||
} else {
|
||||
findDsPage = this.distributionSetManagement.findDistributionSetsAll(pageable, false, null);
|
||||
findDsPage = this.distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageable, false, null);
|
||||
}
|
||||
|
||||
final List<MgmtDistributionSet> rest = MgmtDistributionSetMapper.toResponseFromDsList(findDsPage.getContent());
|
||||
@@ -181,8 +176,8 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
|
||||
final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting);
|
||||
final Page<Target> targetsAssignedDS;
|
||||
if (rsqlParam != null) {
|
||||
targetsAssignedDS = this.targetManagement.findTargetByAssignedDistributionSet(distributionSetId,
|
||||
RSQLUtility.parse(rsqlParam, TargetFields.class), pageable);
|
||||
targetsAssignedDS = this.targetManagement.findTargetByAssignedDistributionSet(distributionSetId, rsqlParam,
|
||||
pageable);
|
||||
} else {
|
||||
targetsAssignedDS = this.targetManagement.findTargetByAssignedDistributionSet(distributionSetId, pageable);
|
||||
}
|
||||
@@ -210,7 +205,7 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
|
||||
final Page<Target> targetsInstalledDS;
|
||||
if (rsqlParam != null) {
|
||||
targetsInstalledDS = this.targetManagement.findTargetByInstalledDistributionSet(distributionSetId,
|
||||
RSQLUtility.parse(rsqlParam, TargetFields.class), pageable);
|
||||
rsqlParam, pageable);
|
||||
} else {
|
||||
targetsInstalledDS = this.targetManagement.findTargetByInstalledDistributionSet(distributionSetId,
|
||||
pageable);
|
||||
@@ -257,8 +252,8 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
|
||||
final Page<DistributionSetMetadata> metaDataPage;
|
||||
|
||||
if (rsqlParam != null) {
|
||||
metaDataPage = this.distributionSetManagement.findDistributionSetMetadataByDistributionSetId(
|
||||
distributionSetId, RSQLUtility.parse(rsqlParam, DistributionSetMetadataFields.class), pageable);
|
||||
metaDataPage = this.distributionSetManagement
|
||||
.findDistributionSetMetadataByDistributionSetId(distributionSetId, rsqlParam, pageable);
|
||||
} else {
|
||||
metaDataPage = this.distributionSetManagement
|
||||
.findDistributionSetMetadataByDistributionSetId(distributionSetId, pageable);
|
||||
@@ -289,8 +284,8 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
|
||||
// check if distribution set exists otherwise throw exception
|
||||
// immediately
|
||||
final DistributionSet ds = findDistributionSetWithExceptionIfNotFound(distributionSetId);
|
||||
final DistributionSetMetadata updated = this.distributionSetManagement
|
||||
.updateDistributionSetMetadata(new DistributionSetMetadata(metadataKey, ds, metadata.getValue()));
|
||||
final DistributionSetMetadata updated = this.distributionSetManagement.updateDistributionSetMetadata(
|
||||
distributionSetManagement.generateDistributionSetMetadata(ds, metadataKey, metadata.getValue()));
|
||||
return ResponseEntity.ok(MgmtDistributionSetMapper.toResponseDsMetadata(updated));
|
||||
}
|
||||
|
||||
@@ -312,8 +307,8 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
|
||||
// immediately
|
||||
final DistributionSet ds = findDistributionSetWithExceptionIfNotFound(distributionSetId);
|
||||
|
||||
final List<DistributionSetMetadata> created = this.distributionSetManagement
|
||||
.createDistributionSetMetadata(MgmtDistributionSetMapper.fromRequestDsMetadata(ds, metadataRest));
|
||||
final List<DistributionSetMetadata> created = this.distributionSetManagement.createDistributionSetMetadata(
|
||||
MgmtDistributionSetMapper.fromRequestDsMetadata(ds, metadataRest, distributionSetManagement));
|
||||
return new ResponseEntity<>(MgmtDistributionSetMapper.toResponseDsMetadata(created), HttpStatus.CREATED);
|
||||
|
||||
}
|
||||
|
||||
@@ -21,13 +21,11 @@ import org.eclipse.hawkbit.mgmt.rest.api.MgmtDistributionSetTagRestApi;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
|
||||
import org.eclipse.hawkbit.repository.TagFields;
|
||||
import org.eclipse.hawkbit.repository.TagManagement;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetTagAssignmentResult;
|
||||
import org.eclipse.hawkbit.repository.rsql.RSQLUtility;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -75,8 +73,8 @@ public class MgmtDistributionSetTagResource implements MgmtDistributionSetTagRes
|
||||
countTargetsAll = this.tagManagement.countTargetTags();
|
||||
|
||||
} else {
|
||||
final Page<DistributionSetTag> findTargetPage = this.tagManagement
|
||||
.findAllDistributionSetTags(RSQLUtility.parse(rsqlParam, TagFields.class), pageable);
|
||||
final Page<DistributionSetTag> findTargetPage = this.tagManagement.findAllDistributionSetTags(rsqlParam,
|
||||
pageable);
|
||||
countTargetsAll = findTargetPage.getTotalElements();
|
||||
findTargetsAll = findTargetPage;
|
||||
|
||||
@@ -99,7 +97,7 @@ public class MgmtDistributionSetTagResource implements MgmtDistributionSetTagRes
|
||||
LOG.debug("creating {} ds tags", tags.size());
|
||||
|
||||
final List<DistributionSetTag> createdTags = this.tagManagement
|
||||
.createDistributionSetTags(MgmtTagMapper.mapDistributionSetTagFromRequest(tags));
|
||||
.createDistributionSetTags(MgmtTagMapper.mapDistributionSetTagFromRequest(tagManagement, tags));
|
||||
|
||||
return new ResponseEntity<>(MgmtTagMapper.toResponseDistributionSetTag(createdTags), HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@@ -14,10 +14,11 @@ import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionSetTypeRequestBodyPost;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionSetType;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionSetTypeRequestBodyPost;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtDistributionSetTypeRestApi;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.SoftwareManagement;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||
@@ -35,21 +36,22 @@ final class MgmtDistributionSetTypeMapper {
|
||||
|
||||
}
|
||||
|
||||
static List<DistributionSetType> smFromRequest(final SoftwareManagement softwareManagement,
|
||||
static List<DistributionSetType> smFromRequest(final DistributionSetManagement distributionSetManagement,
|
||||
final SoftwareManagement softwareManagement,
|
||||
final Iterable<MgmtDistributionSetTypeRequestBodyPost> smTypesRest) {
|
||||
final List<DistributionSetType> mappedList = new ArrayList<>();
|
||||
|
||||
for (final MgmtDistributionSetTypeRequestBodyPost smRest : smTypesRest) {
|
||||
mappedList.add(fromRequest(softwareManagement, smRest));
|
||||
mappedList.add(fromRequest(distributionSetManagement, softwareManagement, smRest));
|
||||
}
|
||||
return mappedList;
|
||||
}
|
||||
|
||||
static DistributionSetType fromRequest(final SoftwareManagement softwareManagement,
|
||||
final MgmtDistributionSetTypeRequestBodyPost smsRest) {
|
||||
static DistributionSetType fromRequest(final DistributionSetManagement distributionSetManagement,
|
||||
final SoftwareManagement softwareManagement, final MgmtDistributionSetTypeRequestBodyPost smsRest) {
|
||||
|
||||
final DistributionSetType result = new DistributionSetType(smsRest.getKey(), smsRest.getName(),
|
||||
smsRest.getDescription());
|
||||
final DistributionSetType result = distributionSetManagement.generateDistributionSetType(smsRest.getKey(),
|
||||
smsRest.getName(), smsRest.getDescription());
|
||||
|
||||
// Add mandatory
|
||||
smsRest.getMandatorymodules().stream().map(mand -> {
|
||||
|
||||
@@ -12,14 +12,13 @@ import java.util.List;
|
||||
|
||||
import org.eclipse.hawkbit.mgmt.json.model.MgmtId;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.PagedList;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionSetType;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionSetTypeRequestBodyPost;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionSetTypeRequestBodyPut;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionSetType;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleType;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtDistributionSetTypeRestApi;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetTypeFields;
|
||||
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
|
||||
import org.eclipse.hawkbit.repository.SoftwareManagement;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||
@@ -27,7 +26,6 @@ import org.eclipse.hawkbit.repository.model.Artifact;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||
import org.eclipse.hawkbit.repository.rsql.RSQLUtility;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
@@ -71,8 +69,7 @@ public class MgmtDistributionSetTypeResource implements MgmtDistributionSetTypeR
|
||||
final Slice<DistributionSetType> findModuleTypessAll;
|
||||
Long countModulesAll;
|
||||
if (rsqlParam != null) {
|
||||
findModuleTypessAll = distributionSetManagement.findDistributionSetTypesByPredicate(
|
||||
RSQLUtility.parse(rsqlParam, DistributionSetTypeFields.class), pageable);
|
||||
findModuleTypessAll = distributionSetManagement.findDistributionSetTypesAll(rsqlParam, pageable);
|
||||
countModulesAll = ((Page<DistributionSetType>) findModuleTypessAll).getTotalElements();
|
||||
} else {
|
||||
findModuleTypessAll = distributionSetManagement.findDistributionSetTypesAll(pageable);
|
||||
@@ -124,8 +121,9 @@ public class MgmtDistributionSetTypeResource implements MgmtDistributionSetTypeR
|
||||
public ResponseEntity<List<MgmtDistributionSetType>> createDistributionSetTypes(
|
||||
@RequestBody final List<MgmtDistributionSetTypeRequestBodyPost> distributionSetTypes) {
|
||||
|
||||
final List<DistributionSetType> createdSoftwareModules = distributionSetManagement.createDistributionSetTypes(
|
||||
MgmtDistributionSetTypeMapper.smFromRequest(softwareManagement, distributionSetTypes));
|
||||
final List<DistributionSetType> createdSoftwareModules = distributionSetManagement
|
||||
.createDistributionSetTypes(MgmtDistributionSetTypeMapper.smFromRequest(distributionSetManagement,
|
||||
softwareManagement, distributionSetTypes));
|
||||
|
||||
return new ResponseEntity<>(MgmtDistributionSetTypeMapper.toTypesResponse(createdSoftwareModules),
|
||||
HttpStatus.CREATED);
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.eclipse.hawkbit.mgmt.json.model.rollout.MgmtRolloutSuccessAction.Succ
|
||||
import org.eclipse.hawkbit.mgmt.json.model.rolloutgroup.MgmtRolloutGroupResponseBody;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRolloutRestApi;
|
||||
import org.eclipse.hawkbit.repository.RolloutManagement;
|
||||
import org.eclipse.hawkbit.repository.model.Action.ActionType;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.Rollout;
|
||||
@@ -83,9 +84,9 @@ final class MgmtRolloutMapper {
|
||||
return body;
|
||||
}
|
||||
|
||||
static Rollout fromRequest(final MgmtRolloutRestRequestBody restRequest, final DistributionSet distributionSet,
|
||||
final String filterQuery) {
|
||||
final Rollout rollout = new Rollout();
|
||||
static Rollout fromRequest(final RolloutManagement rolloutManagement, final MgmtRolloutRestRequestBody restRequest,
|
||||
final DistributionSet distributionSet, final String filterQuery) {
|
||||
final Rollout rollout = rolloutManagement.generateRollout();
|
||||
rollout.setName(restRequest.getName());
|
||||
rollout.setDescription(restRequest.getDescription());
|
||||
rollout.setDistributionSet(distributionSet);
|
||||
|
||||
@@ -19,8 +19,6 @@ import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRolloutRestApi;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
|
||||
import org.eclipse.hawkbit.repository.RolloutFields;
|
||||
import org.eclipse.hawkbit.repository.RolloutGroupFields;
|
||||
import org.eclipse.hawkbit.repository.RolloutGroupManagement;
|
||||
import org.eclipse.hawkbit.repository.RolloutManagement;
|
||||
import org.eclipse.hawkbit.repository.TargetFields;
|
||||
@@ -28,18 +26,18 @@ import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.Rollout;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroup;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupConditions;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupErrorAction;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupErrorCondition;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupSuccessAction;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupSuccessCondition;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroupConditionBuilder;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroupConditions;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.repository.rsql.RSQLUtility;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
@@ -80,8 +78,7 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi {
|
||||
|
||||
final Page<Rollout> findModulesAll;
|
||||
if (rsqlParam != null) {
|
||||
findModulesAll = this.rolloutManagement
|
||||
.findAllWithDetailedStatusByPredicate(RSQLUtility.parse(rsqlParam, RolloutFields.class), pageable);
|
||||
findModulesAll = this.rolloutManagement.findAllWithDetailedStatusByPredicate(rsqlParam, pageable);
|
||||
} else {
|
||||
findModulesAll = this.rolloutManagement.findAll(pageable);
|
||||
}
|
||||
@@ -136,12 +133,12 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi {
|
||||
errorActionExpr = rolloutRequestBody.getErrorAction().getExpression();
|
||||
}
|
||||
|
||||
final RolloutGroupConditions rolloutGroupConditions = new RolloutGroup.RolloutGroupConditionBuilder()
|
||||
final RolloutGroupConditions rolloutGroupConditions = new RolloutGroupConditionBuilder()
|
||||
.successCondition(successCondition, successConditionExpr)
|
||||
.successAction(successAction, successActionExpr).errorCondition(errorCondition, errorConditionExpr)
|
||||
.errorAction(errorAction, errorActionExpr).build();
|
||||
final Rollout rollout = this.rolloutManagement.createRollout(
|
||||
MgmtRolloutMapper.fromRequest(rolloutRequestBody, distributionSet,
|
||||
MgmtRolloutMapper.fromRequest(rolloutManagement, rolloutRequestBody, distributionSet,
|
||||
rolloutRequestBody.getTargetFilterQuery()),
|
||||
rolloutRequestBody.getAmountGroups(), rolloutGroupConditions);
|
||||
|
||||
@@ -191,8 +188,7 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi {
|
||||
|
||||
final Page<RolloutGroup> findRolloutGroupsAll;
|
||||
if (rsqlParam != null) {
|
||||
findRolloutGroupsAll = this.rolloutGroupManagement.findRolloutGroupsByPredicate(rollout,
|
||||
RSQLUtility.parse(rsqlParam, RolloutGroupFields.class), pageable);
|
||||
findRolloutGroupsAll = this.rolloutGroupManagement.findRolloutGroupsAll(rollout, rsqlParam, pageable);
|
||||
} else {
|
||||
findRolloutGroupsAll = this.rolloutGroupManagement.findRolloutGroupsByRolloutId(rolloutId, pageable);
|
||||
}
|
||||
@@ -228,8 +224,7 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi {
|
||||
|
||||
final Page<Target> rolloutGroupTargets;
|
||||
if (rsqlParam != null) {
|
||||
final Specification<Target> rsqlSpecification = RSQLUtility.parse(rsqlParam, TargetFields.class);
|
||||
rolloutGroupTargets = this.rolloutGroupManagement.findRolloutGroupTargets(rolloutGroup, rsqlSpecification,
|
||||
rolloutGroupTargets = this.rolloutGroupManagement.findRolloutGroupTargets(rolloutGroup, rsqlParam,
|
||||
pageable);
|
||||
} else {
|
||||
final Page<Target> pageTargets = this.rolloutGroupManagement.findRolloutGroupTargets(rolloutGroup,
|
||||
|
||||
@@ -54,18 +54,20 @@ public final class MgmtSoftwareModuleMapper {
|
||||
|
||||
static SoftwareModule fromRequest(final MgmtSoftwareModuleRequestBodyPost smsRest,
|
||||
final SoftwareManagement softwareManagement) {
|
||||
return new SoftwareModule(getSoftwareModuleTypeFromKeyString(smsRest.getType(), softwareManagement),
|
||||
smsRest.getName(), smsRest.getVersion(), smsRest.getDescription(), smsRest.getVendor());
|
||||
return softwareManagement.generateSoftwareModule(
|
||||
getSoftwareModuleTypeFromKeyString(smsRest.getType(), softwareManagement), smsRest.getName(),
|
||||
smsRest.getVersion(), smsRest.getDescription(), smsRest.getVendor());
|
||||
}
|
||||
|
||||
static List<SoftwareModuleMetadata> fromRequestSwMetadata(final SoftwareModule sw,
|
||||
final List<MgmtMetadata> metadata) {
|
||||
static List<SoftwareModuleMetadata> fromRequestSwMetadata(final SoftwareManagement softwareManagement,
|
||||
final SoftwareModule sw, final List<MgmtMetadata> metadata) {
|
||||
final List<SoftwareModuleMetadata> mappedList = new ArrayList<>(metadata.size());
|
||||
for (final MgmtMetadata metadataRest : metadata) {
|
||||
if (metadataRest.getKey() == null) {
|
||||
throw new IllegalArgumentException("the key of the metadata must be present");
|
||||
}
|
||||
mappedList.add(new SoftwareModuleMetadata(metadataRest.getKey(), sw, metadataRest.getValue()));
|
||||
mappedList.add(softwareManagement.generateSoftwareModuleMetadata(sw, metadataRest.getKey(),
|
||||
metadataRest.getValue()));
|
||||
}
|
||||
return mappedList;
|
||||
}
|
||||
@@ -116,7 +118,7 @@ public final class MgmtSoftwareModuleMapper {
|
||||
|
||||
static MgmtMetadata toResponseSwMetadata(final SoftwareModuleMetadata metadata) {
|
||||
final MgmtMetadata metadataRest = new MgmtMetadata();
|
||||
metadataRest.setKey(metadata.getId().getKey());
|
||||
metadataRest.setKey(metadata.getKey());
|
||||
metadataRest.setValue(metadata.getValue());
|
||||
return metadataRest;
|
||||
}
|
||||
|
||||
@@ -22,14 +22,11 @@ import org.eclipse.hawkbit.mgmt.rest.api.MgmtSoftwareModuleRestApi;
|
||||
import org.eclipse.hawkbit.repository.ArtifactManagement;
|
||||
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
|
||||
import org.eclipse.hawkbit.repository.SoftwareManagement;
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleFields;
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleMetadataFields;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.SwMetadataCompositeKey;
|
||||
import org.eclipse.hawkbit.repository.model.Artifact;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata;
|
||||
import org.eclipse.hawkbit.repository.model.SwMetadataCompositeKey;
|
||||
import org.eclipse.hawkbit.repository.rsql.RSQLUtility;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -139,8 +136,7 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
|
||||
final Slice<SoftwareModule> findModulesAll;
|
||||
Long countModulesAll;
|
||||
if (rsqlParam != null) {
|
||||
findModulesAll = softwareManagement
|
||||
.findSoftwareModulesByPredicate(RSQLUtility.parse(rsqlParam, SoftwareModuleFields.class), pageable);
|
||||
findModulesAll = softwareManagement.findSoftwareModulesByPredicate(rsqlParam, pageable);
|
||||
countModulesAll = ((Page<SoftwareModule>) findModulesAll).getTotalElements();
|
||||
} else {
|
||||
findModulesAll = softwareManagement.findSoftwareModulesAll(pageable);
|
||||
@@ -217,8 +213,8 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
|
||||
final Page<SoftwareModuleMetadata> metaDataPage;
|
||||
|
||||
if (rsqlParam != null) {
|
||||
metaDataPage = softwareManagement.findSoftwareModuleMetadataBySoftwareModuleId(softwareModuleId,
|
||||
RSQLUtility.parse(rsqlParam, SoftwareModuleMetadataFields.class), pageable);
|
||||
metaDataPage = softwareManagement.findSoftwareModuleMetadataBySoftwareModuleId(softwareModuleId, rsqlParam,
|
||||
pageable);
|
||||
} else {
|
||||
metaDataPage = softwareManagement.findSoftwareModuleMetadataBySoftwareModuleId(softwareModuleId, pageable);
|
||||
}
|
||||
@@ -233,8 +229,7 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
|
||||
public ResponseEntity<MgmtMetadata> getMetadataValue(@PathVariable("softwareModuleId") final Long softwareModuleId,
|
||||
@PathVariable("metadataKey") final String metadataKey) {
|
||||
final SoftwareModule sw = findSoftwareModuleWithExceptionIfNotFound(softwareModuleId, null);
|
||||
final SoftwareModuleMetadata findOne = softwareManagement
|
||||
.findSoftwareModuleMetadata(new SwMetadataCompositeKey(sw, metadataKey));
|
||||
final SoftwareModuleMetadata findOne = softwareManagement.findSoftwareModuleMetadata(sw, metadataKey);
|
||||
return ResponseEntity.<MgmtMetadata> ok(MgmtSoftwareModuleMapper.toResponseSwMetadata(findOne));
|
||||
}
|
||||
|
||||
@@ -242,8 +237,8 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
|
||||
public ResponseEntity<MgmtMetadata> updateMetadata(@PathVariable("softwareModuleId") final Long softwareModuleId,
|
||||
@PathVariable("metadataKey") final String metadataKey, @RequestBody final MgmtMetadata metadata) {
|
||||
final SoftwareModule sw = findSoftwareModuleWithExceptionIfNotFound(softwareModuleId, null);
|
||||
final SoftwareModuleMetadata updated = softwareManagement
|
||||
.updateSoftwareModuleMetadata(new SoftwareModuleMetadata(metadataKey, sw, metadata.getValue()));
|
||||
final SoftwareModuleMetadata updated = softwareManagement.updateSoftwareModuleMetadata(
|
||||
softwareManagement.generateSoftwareModuleMetadata(sw, metadataKey, metadata.getValue()));
|
||||
return ResponseEntity.ok(MgmtSoftwareModuleMapper.toResponseSwMetadata(updated));
|
||||
}
|
||||
|
||||
@@ -261,8 +256,8 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi {
|
||||
@RequestBody final List<MgmtMetadata> metadataRest) {
|
||||
final SoftwareModule sw = findSoftwareModuleWithExceptionIfNotFound(softwareModuleId, null);
|
||||
|
||||
final List<SoftwareModuleMetadata> created = softwareManagement
|
||||
.createSoftwareModuleMetadata(MgmtSoftwareModuleMapper.fromRequestSwMetadata(sw, metadataRest));
|
||||
final List<SoftwareModuleMetadata> created = softwareManagement.createSoftwareModuleMetadata(
|
||||
MgmtSoftwareModuleMapper.fromRequestSwMetadata(softwareManagement, sw, metadataRest));
|
||||
|
||||
return new ResponseEntity<>(MgmtSoftwareModuleMapper.toResponseSwMetadata(created), HttpStatus.CREATED);
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ import java.util.List;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleType;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleTypeRequestBodyPost;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtSoftwareModuleTypeRestApi;
|
||||
import org.eclipse.hawkbit.repository.SoftwareManagement;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||
|
||||
/**
|
||||
@@ -35,18 +36,25 @@ final class MgmtSoftwareModuleTypeMapper {
|
||||
|
||||
}
|
||||
|
||||
static List<SoftwareModuleType> smFromRequest(final Iterable<MgmtSoftwareModuleTypeRequestBodyPost> smTypesRest) {
|
||||
static List<SoftwareModuleType> smFromRequest(final SoftwareManagement softwareManagement,
|
||||
final Iterable<MgmtSoftwareModuleTypeRequestBodyPost> smTypesRest) {
|
||||
final List<SoftwareModuleType> mappedList = new ArrayList<>();
|
||||
|
||||
for (final MgmtSoftwareModuleTypeRequestBodyPost smRest : smTypesRest) {
|
||||
mappedList.add(fromRequest(smRest));
|
||||
mappedList.add(fromRequest(softwareManagement, smRest));
|
||||
}
|
||||
return mappedList;
|
||||
}
|
||||
|
||||
static SoftwareModuleType fromRequest(final MgmtSoftwareModuleTypeRequestBodyPost smsRest) {
|
||||
return new SoftwareModuleType(smsRest.getKey(), smsRest.getName(), smsRest.getDescription(),
|
||||
smsRest.getMaxAssignments());
|
||||
static SoftwareModuleType fromRequest(final SoftwareManagement softwareManagement,
|
||||
final MgmtSoftwareModuleTypeRequestBodyPost smsRest) {
|
||||
final SoftwareModuleType result = softwareManagement.generateSoftwareModuleType();
|
||||
result.setName(smsRest.getName());
|
||||
result.setKey(smsRest.getKey());
|
||||
result.setDescription(smsRest.getDescription());
|
||||
result.setMaxAssignments(smsRest.getMaxAssignments());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static List<MgmtSoftwareModuleType> toTypesResponse(final List<SoftwareModuleType> types) {
|
||||
|
||||
@@ -18,12 +18,10 @@ import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtSoftwareModuleTypeRestApi;
|
||||
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
|
||||
import org.eclipse.hawkbit.repository.SoftwareManagement;
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleTypeFields;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||
import org.eclipse.hawkbit.repository.model.Artifact;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||
import org.eclipse.hawkbit.repository.rsql.RSQLUtility;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
@@ -62,8 +60,7 @@ public class MgmtSoftwareModuleTypeResource implements MgmtSoftwareModuleTypeRes
|
||||
final Slice<SoftwareModuleType> findModuleTypessAll;
|
||||
Long countModulesAll;
|
||||
if (rsqlParam != null) {
|
||||
findModuleTypessAll = this.softwareManagement.findSoftwareModuleTypesByPredicate(
|
||||
RSQLUtility.parse(rsqlParam, SoftwareModuleTypeFields.class), pageable);
|
||||
findModuleTypessAll = this.softwareManagement.findSoftwareModuleTypesAll(rsqlParam, pageable);
|
||||
countModulesAll = ((Page<SoftwareModuleType>) findModuleTypessAll).getTotalElements();
|
||||
} else {
|
||||
findModuleTypessAll = this.softwareManagement.findSoftwareModuleTypesAll(pageable);
|
||||
@@ -112,8 +109,8 @@ public class MgmtSoftwareModuleTypeResource implements MgmtSoftwareModuleTypeRes
|
||||
public ResponseEntity<List<MgmtSoftwareModuleType>> createSoftwareModuleTypes(
|
||||
@RequestBody final List<MgmtSoftwareModuleTypeRequestBodyPost> softwareModuleTypes) {
|
||||
|
||||
final List<SoftwareModuleType> createdSoftwareModules = this.softwareManagement
|
||||
.createSoftwareModuleType(MgmtSoftwareModuleTypeMapper.smFromRequest(softwareModuleTypes));
|
||||
final List<SoftwareModuleType> createdSoftwareModules = this.softwareManagement.createSoftwareModuleType(
|
||||
MgmtSoftwareModuleTypeMapper.smFromRequest(softwareManagement, softwareModuleTypes));
|
||||
|
||||
return new ResponseEntity<>(MgmtSoftwareModuleTypeMapper.toTypesResponse(createdSoftwareModules),
|
||||
HttpStatus.CREATED);
|
||||
|
||||
@@ -18,6 +18,7 @@ import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtTag;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtTagRequestBodyPut;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtDistributionSetTagRestApi;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtTargetTagRestApi;
|
||||
import org.eclipse.hawkbit.repository.TagManagement;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
||||
import org.eclipse.hawkbit.repository.model.Tag;
|
||||
import org.eclipse.hawkbit.repository.model.TargetTag;
|
||||
@@ -84,8 +85,9 @@ final class MgmtTagMapper {
|
||||
|
||||
mapTag(response, distributionSetTag);
|
||||
|
||||
response.add(linkTo(methodOn(MgmtDistributionSetTagRestApi.class).getDistributionSetTag(distributionSetTag.getId()))
|
||||
.withRel("self"));
|
||||
response.add(
|
||||
linkTo(methodOn(MgmtDistributionSetTagRestApi.class).getDistributionSetTag(distributionSetTag.getId()))
|
||||
.withRel("self"));
|
||||
|
||||
response.add(linkTo(
|
||||
methodOn(MgmtDistributionSetTagRestApi.class).getAssignedDistributionSets(distributionSetTag.getId()))
|
||||
@@ -94,20 +96,22 @@ final class MgmtTagMapper {
|
||||
return response;
|
||||
}
|
||||
|
||||
static List<TargetTag> mapTargeTagFromRequest(final Iterable<MgmtTagRequestBodyPut> tags) {
|
||||
static List<TargetTag> mapTargeTagFromRequest(final TagManagement tagManagement,
|
||||
final Iterable<MgmtTagRequestBodyPut> tags) {
|
||||
final List<TargetTag> mappedList = new ArrayList<>();
|
||||
for (final MgmtTagRequestBodyPut targetTagRest : tags) {
|
||||
mappedList.add(
|
||||
new TargetTag(targetTagRest.getName(), targetTagRest.getDescription(), targetTagRest.getColour()));
|
||||
mappedList.add(tagManagement.generateTargetTag(targetTagRest.getName(), targetTagRest.getDescription(),
|
||||
targetTagRest.getColour()));
|
||||
}
|
||||
return mappedList;
|
||||
}
|
||||
|
||||
static List<DistributionSetTag> mapDistributionSetTagFromRequest(final Iterable<MgmtTagRequestBodyPut> tags) {
|
||||
static List<DistributionSetTag> mapDistributionSetTagFromRequest(final TagManagement tagManagement,
|
||||
final Iterable<MgmtTagRequestBodyPut> tags) {
|
||||
final List<DistributionSetTag> mappedList = new ArrayList<>();
|
||||
for (final MgmtTagRequestBodyPut targetTagRest : tags) {
|
||||
mappedList.add(new DistributionSetTag(targetTagRest.getName(), targetTagRest.getDescription(),
|
||||
targetTagRest.getColour()));
|
||||
mappedList.add(tagManagement.generateDistributionSetTag(targetTagRest.getName(),
|
||||
targetTagRest.getDescription(), targetTagRest.getColour()));
|
||||
}
|
||||
return mappedList;
|
||||
}
|
||||
|
||||
@@ -25,10 +25,11 @@ import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTargetRequestBody;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtTargetRestApi;
|
||||
import org.eclipse.hawkbit.repository.ActionFields;
|
||||
import org.eclipse.hawkbit.repository.TargetManagement;
|
||||
import org.eclipse.hawkbit.repository.model.Action;
|
||||
import org.eclipse.hawkbit.repository.model.ActionStatus;
|
||||
import org.eclipse.hawkbit.repository.model.PollStatus;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.repository.model.TargetInfo.PollStatus;
|
||||
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
|
||||
import org.eclipse.hawkbit.rest.data.SortDirection;
|
||||
|
||||
@@ -168,16 +169,17 @@ public final class MgmtTargetMapper {
|
||||
return targetRest;
|
||||
}
|
||||
|
||||
static List<Target> fromRequest(final Iterable<MgmtTargetRequestBody> targetsRest) {
|
||||
static List<Target> fromRequest(final TargetManagement targetManagement,
|
||||
final Iterable<MgmtTargetRequestBody> targetsRest) {
|
||||
final List<Target> mappedList = new ArrayList<>();
|
||||
for (final MgmtTargetRequestBody targetRest : targetsRest) {
|
||||
mappedList.add(fromRequest(targetRest));
|
||||
mappedList.add(fromRequest(targetManagement, targetRest));
|
||||
}
|
||||
return mappedList;
|
||||
}
|
||||
|
||||
static Target fromRequest(final MgmtTargetRequestBody targetRest) {
|
||||
final Target target = new Target(targetRest.getControllerId());
|
||||
static Target fromRequest(final TargetManagement targetManagement, final MgmtTargetRequestBody targetRest) {
|
||||
final Target target = targetManagement.generateTarget(targetRest.getControllerId());
|
||||
target.setDescription(targetRest.getDescription());
|
||||
target.setName(targetRest.getName());
|
||||
return target;
|
||||
|
||||
@@ -26,18 +26,15 @@ import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTargetRequestBody;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtDistributionSetRestApi;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtTargetRestApi;
|
||||
import org.eclipse.hawkbit.repository.ActionFields;
|
||||
import org.eclipse.hawkbit.repository.ActionStatusFields;
|
||||
import org.eclipse.hawkbit.repository.DeploymentManagement;
|
||||
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
|
||||
import org.eclipse.hawkbit.repository.TargetFields;
|
||||
import org.eclipse.hawkbit.repository.TargetManagement;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||
import org.eclipse.hawkbit.repository.model.Action;
|
||||
import org.eclipse.hawkbit.repository.model.Action.ActionType;
|
||||
import org.eclipse.hawkbit.repository.model.ActionStatus;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.repository.rsql.RSQLUtility;
|
||||
import org.eclipse.hawkbit.rest.data.SortDirection;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -46,7 +43,6 @@ import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Slice;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
@@ -93,8 +89,7 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
|
||||
final Slice<Target> findTargetsAll;
|
||||
final Long countTargetsAll;
|
||||
if (rsqlParam != null) {
|
||||
final Page<Target> findTargetPage = this.targetManagement
|
||||
.findTargetsAll(RSQLUtility.parse(rsqlParam, TargetFields.class), pageable);
|
||||
final Page<Target> findTargetPage = this.targetManagement.findTargetsAll(rsqlParam, pageable);
|
||||
countTargetsAll = findTargetPage.getTotalElements();
|
||||
findTargetsAll = findTargetPage;
|
||||
} else {
|
||||
@@ -110,7 +105,7 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
|
||||
public ResponseEntity<List<MgmtTarget>> createTargets(@RequestBody final List<MgmtTargetRequestBody> targets) {
|
||||
LOG.debug("creating {} targets", targets.size());
|
||||
final Iterable<Target> createdTargets = this.targetManagement
|
||||
.createTargets(MgmtTargetMapper.fromRequest(targets));
|
||||
.createTargets(MgmtTargetMapper.fromRequest(targetManagement, targets));
|
||||
LOG.debug("{} targets created, return status {}", targets.size(), HttpStatus.CREATED);
|
||||
return new ResponseEntity<>(MgmtTargetMapper.toResponse(createdTargets), HttpStatus.CREATED);
|
||||
}
|
||||
@@ -170,9 +165,8 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
|
||||
final Slice<Action> activeActions;
|
||||
final Long totalActionCount;
|
||||
if (rsqlParam != null) {
|
||||
final Specification<Action> parse = RSQLUtility.parse(rsqlParam, ActionFields.class);
|
||||
activeActions = this.deploymentManagement.findActionsByTarget(parse, foundTarget, pageable);
|
||||
totalActionCount = this.deploymentManagement.countActionsByTarget(parse, foundTarget);
|
||||
activeActions = this.deploymentManagement.findActionsByTarget(rsqlParam, foundTarget, pageable);
|
||||
totalActionCount = this.deploymentManagement.countActionsByTarget(rsqlParam, foundTarget);
|
||||
} else {
|
||||
activeActions = this.deploymentManagement.findActionsByTarget(foundTarget, pageable);
|
||||
totalActionCount = this.deploymentManagement.countActionsByTarget(foundTarget);
|
||||
@@ -250,8 +244,8 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
|
||||
final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam);
|
||||
final Sort sorting = PagingUtility.sanitizeActionStatusSortParam(sortParam);
|
||||
|
||||
final Page<ActionStatus> statusList = this.deploymentManagement.findActionStatusByAction(
|
||||
new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting), action, true);
|
||||
final Page<ActionStatus> statusList = this.deploymentManagement.findActionStatusByActionWithMessages(
|
||||
new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting), action);
|
||||
|
||||
return new ResponseEntity<>(
|
||||
new PagedList<>(MgmtTargetMapper.toActionStatusRestResponse(statusList.getContent()),
|
||||
|
||||
@@ -20,14 +20,12 @@ import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTarget;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtTargetTagRestApi;
|
||||
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
|
||||
import org.eclipse.hawkbit.repository.TagFields;
|
||||
import org.eclipse.hawkbit.repository.TagManagement;
|
||||
import org.eclipse.hawkbit.repository.TargetManagement;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.repository.model.TargetTag;
|
||||
import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult;
|
||||
import org.eclipse.hawkbit.repository.rsql.RSQLUtility;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -75,8 +73,7 @@ public class MgmtTargetTagResource implements MgmtTargetTagRestApi {
|
||||
countTargetsAll = this.tagManagement.countTargetTags();
|
||||
|
||||
} else {
|
||||
final Page<TargetTag> findTargetPage = this.tagManagement
|
||||
.findAllTargetTags(RSQLUtility.parse(rsqlParam, TagFields.class), pageable);
|
||||
final Page<TargetTag> findTargetPage = this.tagManagement.findAllTargetTags(rsqlParam, pageable);
|
||||
countTargetsAll = findTargetPage.getTotalElements();
|
||||
findTargetsAll = findTargetPage;
|
||||
|
||||
@@ -96,7 +93,7 @@ public class MgmtTargetTagResource implements MgmtTargetTagRestApi {
|
||||
public ResponseEntity<List<MgmtTag>> createTargetTags(@RequestBody final List<MgmtTagRequestBodyPut> tags) {
|
||||
LOG.debug("creating {} target tags", tags.size());
|
||||
final List<TargetTag> createdTargetTags = this.tagManagement
|
||||
.createTargetTags(MgmtTagMapper.mapTargeTagFromRequest(tags));
|
||||
.createTargetTags(MgmtTagMapper.mapTargeTagFromRequest(tagManagement, tags));
|
||||
return new ResponseEntity<>(MgmtTagMapper.toResponse(createdTargetTags), HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,10 +30,10 @@ import org.eclipse.hawkbit.TestDataUtil;
|
||||
import org.eclipse.hawkbit.WithUser;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.DsMetadataCompositeKey;
|
||||
import org.eclipse.hawkbit.repository.model.Action.Status;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetMetadata;
|
||||
import org.eclipse.hawkbit.repository.model.DsMetadataCompositeKey;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.rest.AbstractRestIntegrationTest;
|
||||
@@ -76,7 +76,7 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
final DistributionSet disSet = TestDataUtil.generateDistributionSetWithNoSoftwareModules("Eris", "560a",
|
||||
distributionSetManagement);
|
||||
final List<Long> smIDs = new ArrayList<Long>();
|
||||
SoftwareModule sm = new SoftwareModule(osType, "Dysnomia ", "15,772", null, null);
|
||||
SoftwareModule sm = softwareManagement.generateSoftwareModule(osType, "Dysnomia ", "15,772", null, null);
|
||||
sm = softwareManagement.createSoftwareModule(sm);
|
||||
smIDs.add(sm.getId());
|
||||
final JSONArray smList = new JSONArray();
|
||||
@@ -92,7 +92,7 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
final String[] knownTargetIds = new String[] { "1", "2" };
|
||||
final JSONArray list = new JSONArray();
|
||||
for (final String targetId : knownTargetIds) {
|
||||
targetManagement.createTarget(new Target(targetId));
|
||||
targetManagement.createTarget(targetManagement.generateTarget(targetId));
|
||||
list.put(new JSONObject().put("id", Long.valueOf(targetId)));
|
||||
}
|
||||
deploymentManagement.assignDistributionSet(disSet.getId(), knownTargetIds[0]);
|
||||
@@ -120,7 +120,7 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
final DistributionSet disSet = TestDataUtil.generateDistributionSetWithNoSoftwareModules("Mars", "686,980",
|
||||
distributionSetManagement);
|
||||
final List<Long> smIDs = new ArrayList<>();
|
||||
SoftwareModule sm = new SoftwareModule(osType, "Phobos", "0,3189", null, null);
|
||||
SoftwareModule sm = softwareManagement.generateSoftwareModule(osType, "Phobos", "0,3189", null, null);
|
||||
sm = softwareManagement.createSoftwareModule(sm);
|
||||
smIDs.add(sm.getId());
|
||||
final JSONArray smList = new JSONArray();
|
||||
@@ -136,7 +136,7 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
final String[] knownTargetIds = new String[] { "1", "2" };
|
||||
final JSONArray list = new JSONArray();
|
||||
for (final String targetId : knownTargetIds) {
|
||||
targetManagement.createTarget(new Target(targetId));
|
||||
targetManagement.createTarget(targetManagement.generateTarget(targetId));
|
||||
list.put(new JSONObject().put("id", Long.valueOf(targetId)));
|
||||
}
|
||||
// assign DisSet to target and test assignment
|
||||
@@ -150,8 +150,8 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
.andExpect(jsonPath("$.total", equalTo(knownTargetIds.length)));
|
||||
|
||||
// Create another SM and post assignment
|
||||
final List<Long> smID2s = new ArrayList<Long>();
|
||||
SoftwareModule sm2 = new SoftwareModule(appType, "Deimos", "1,262", null, null);
|
||||
final List<Long> smID2s = new ArrayList<>();
|
||||
SoftwareModule sm2 = softwareManagement.generateSoftwareModule(appType, "Deimos", "1,262", null, null);
|
||||
sm2 = softwareManagement.createSoftwareModule(sm2);
|
||||
smID2s.add(sm2.getId());
|
||||
final JSONArray smList2 = new JSONArray();
|
||||
@@ -178,13 +178,13 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
.andExpect(jsonPath("$.size", equalTo(disSet.getModules().size())));
|
||||
// create Software Modules
|
||||
final List<Long> smIDs = new ArrayList<Long>();
|
||||
SoftwareModule sm = new SoftwareModule(osType, "Europa", "3,551", null, null);
|
||||
SoftwareModule sm = softwareManagement.generateSoftwareModule(osType, "Europa", "3,551", null, null);
|
||||
sm = softwareManagement.createSoftwareModule(sm);
|
||||
smIDs.add(sm.getId());
|
||||
SoftwareModule sm2 = new SoftwareModule(appType, "Ganymed", "7,155", null, null);
|
||||
SoftwareModule sm2 = softwareManagement.generateSoftwareModule(appType, "Ganymed", "7,155", null, null);
|
||||
sm2 = softwareManagement.createSoftwareModule(sm2);
|
||||
smIDs.add(sm2.getId());
|
||||
SoftwareModule sm3 = new SoftwareModule(runtimeType, "Kallisto", "16,689", null, null);
|
||||
SoftwareModule sm3 = softwareManagement.generateSoftwareModule(runtimeType, "Kallisto", "16,689", null, null);
|
||||
sm3 = softwareManagement.createSoftwareModule(sm3);
|
||||
smIDs.add(sm3.getId());
|
||||
final JSONArray list = new JSONArray();
|
||||
@@ -234,7 +234,7 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
final String[] knownTargetIds = new String[] { "1", "2", "3", "4", "5" };
|
||||
final JSONArray list = new JSONArray();
|
||||
for (final String targetId : knownTargetIds) {
|
||||
targetManagement.createTarget(new Target(targetId));
|
||||
targetManagement.createTarget(targetManagement.generateTarget(targetId));
|
||||
list.put(new JSONObject().put("id", Long.valueOf(targetId)));
|
||||
}
|
||||
// assign already one target to DS
|
||||
@@ -258,7 +258,7 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
final String knownTargetId = "knownTargetId1";
|
||||
final Set<DistributionSet> createDistributionSetsAlphabetical = createDistributionSetsAlphabetical(1);
|
||||
final DistributionSet createdDs = createDistributionSetsAlphabetical.iterator().next();
|
||||
targetManagement.createTarget(new Target(knownTargetId));
|
||||
targetManagement.createTarget(targetManagement.generateTarget(knownTargetId));
|
||||
deploymentManagement.assignDistributionSet(createdDs.getId(), knownTargetId);
|
||||
|
||||
mvc.perform(get(
|
||||
@@ -285,10 +285,10 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
final String knownTargetId = "knownTargetId1";
|
||||
final Set<DistributionSet> createDistributionSetsAlphabetical = createDistributionSetsAlphabetical(1);
|
||||
final DistributionSet createdDs = createDistributionSetsAlphabetical.iterator().next();
|
||||
final Target createTarget = targetManagement.createTarget(new Target(knownTargetId));
|
||||
final Target createTarget = targetManagement.createTarget(targetManagement.generateTarget(knownTargetId));
|
||||
// create some dummy targets which are not assigned or installed
|
||||
targetManagement.createTarget(new Target("dummy1"));
|
||||
targetManagement.createTarget(new Target("dummy2"));
|
||||
targetManagement.createTarget(targetManagement.generateTarget("dummy1"));
|
||||
targetManagement.createTarget(targetManagement.generateTarget("dummy2"));
|
||||
// assign knownTargetId to distribution set
|
||||
deploymentManagement.assignDistributionSet(createdDs.getId(), knownTargetId);
|
||||
// make it in install state
|
||||
@@ -348,7 +348,8 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
@Description("Ensures that multiple DS requested are listed with expected payload.")
|
||||
public void getDistributionSets() throws Exception {
|
||||
// prepare test data
|
||||
assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, false, true)).hasSize(0);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageReq, false, true))
|
||||
.hasSize(0);
|
||||
|
||||
DistributionSet set = TestDataUtil.generateDistributionSet("one", softwareManagement,
|
||||
distributionSetManagement);
|
||||
@@ -361,7 +362,8 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
// load also lazy stuff
|
||||
set = distributionSetManagement.findDistributionSetByIdWithDetails(set.getId());
|
||||
|
||||
assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, false, true)).hasSize(1);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageReq, false, true))
|
||||
.hasSize(1);
|
||||
|
||||
// perform request
|
||||
mvc.perform(get("/rest/v1/distributionsets").accept(MediaType.APPLICATION_JSON))
|
||||
@@ -425,14 +427,15 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
@WithUser(principal = "uploadTester", allSpPermissions = true)
|
||||
@Description("Ensures that multipe DS posted to API are created in the repository.")
|
||||
public void createDistributionSets() throws JSONException, Exception {
|
||||
assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, false, true)).hasSize(0);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageReq, false, true))
|
||||
.hasSize(0);
|
||||
|
||||
final SoftwareModule ah = softwareManagement
|
||||
.createSoftwareModule(new SoftwareModule(appType, "agent-hub", "1.0.1", null, ""));
|
||||
final SoftwareModule jvm = softwareManagement
|
||||
.createSoftwareModule(new SoftwareModule(runtimeType, "oracle-jre", "1.7.2", null, ""));
|
||||
final SoftwareModule ah = softwareManagement.createSoftwareModule(
|
||||
softwareManagement.generateSoftwareModule(appType, "agent-hub", "1.0.1", null, ""));
|
||||
final SoftwareModule jvm = softwareManagement.createSoftwareModule(
|
||||
softwareManagement.generateSoftwareModule(runtimeType, "oracle-jre", "1.7.2", null, ""));
|
||||
final SoftwareModule os = softwareManagement
|
||||
.createSoftwareModule(new SoftwareModule(osType, "poky", "3.0.2", null, ""));
|
||||
.createSoftwareModule(softwareManagement.generateSoftwareModule(osType, "poky", "3.0.2", null, ""));
|
||||
|
||||
DistributionSet one = TestDataUtil.buildDistributionSet("one", "one", standardDsType, os, jvm, ah);
|
||||
DistributionSet two = TestDataUtil.buildDistributionSet("two", "two", standardDsType, os, jvm, ah);
|
||||
@@ -527,7 +530,8 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
.isEqualTo(String.valueOf(three.getId()));
|
||||
|
||||
// check in database
|
||||
assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, false, true)).hasSize(3);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageReq, false, true))
|
||||
.hasSize(3);
|
||||
assertThat(one.isRequiredMigrationStep()).isEqualTo(false);
|
||||
assertThat(two.isRequiredMigrationStep()).isEqualTo(false);
|
||||
assertThat(three.isRequiredMigrationStep()).isEqualTo(true);
|
||||
@@ -541,19 +545,22 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
@Description("Ensures that DS deletion request to API is reflected by the repository.")
|
||||
public void deleteUnassignedistributionSet() throws Exception {
|
||||
// prepare test data
|
||||
assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, false, true)).hasSize(0);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageReq, false, true))
|
||||
.hasSize(0);
|
||||
|
||||
final DistributionSet set = TestDataUtil.generateDistributionSet("one", softwareManagement,
|
||||
distributionSetManagement);
|
||||
|
||||
assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, false, true)).hasSize(1);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageReq, false, true))
|
||||
.hasSize(1);
|
||||
|
||||
// perform request
|
||||
mvc.perform(delete("/rest/v1/distributionsets/{smId}", set.getId())).andDo(MockMvcResultPrinter.print())
|
||||
.andExpect(status().isOk());
|
||||
|
||||
// check repository content
|
||||
assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, false, true)).isEmpty();
|
||||
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageReq, false, true))
|
||||
.isEmpty();
|
||||
assertThat(distributionSetRepository.findAll()).isEmpty();
|
||||
}
|
||||
|
||||
@@ -561,22 +568,26 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
@Description("Ensures that assigned DS deletion request to API is reflected by the repository by means of deleted flag set.")
|
||||
public void deleteAssignedDistributionSet() throws Exception {
|
||||
// prepare test data
|
||||
assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, false, true)).hasSize(0);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageReq, false, true))
|
||||
.hasSize(0);
|
||||
|
||||
final DistributionSet set = TestDataUtil.generateDistributionSet("one", softwareManagement,
|
||||
distributionSetManagement);
|
||||
targetManagement.createTarget(new Target("test"));
|
||||
targetManagement.createTarget(targetManagement.generateTarget("test"));
|
||||
deploymentManagement.assignDistributionSet(set.getId(), "test");
|
||||
|
||||
assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, false, true)).hasSize(1);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageReq, false, true))
|
||||
.hasSize(1);
|
||||
|
||||
// perform request
|
||||
mvc.perform(delete("/rest/v1/distributionsets/{smId}", set.getId())).andDo(MockMvcResultPrinter.print())
|
||||
.andExpect(status().isOk());
|
||||
|
||||
// check repository content
|
||||
assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, false, true)).hasSize(0);
|
||||
assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, true, true)).hasSize(1);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageReq, false, true))
|
||||
.hasSize(0);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageReq, true, true))
|
||||
.hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -584,14 +595,16 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
public void updateDistributionSet() throws Exception {
|
||||
|
||||
// prepare test data
|
||||
assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, false, true)).hasSize(0);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageReq, false, true))
|
||||
.hasSize(0);
|
||||
|
||||
final DistributionSet set = TestDataUtil.generateDistributionSet("one", softwareManagement,
|
||||
distributionSetManagement);
|
||||
|
||||
assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, false, true)).hasSize(1);
|
||||
assertThat(distributionSetManagement.findDistributionSetsByDeletedAndOrCompleted(pageReq, false, true))
|
||||
.hasSize(1);
|
||||
|
||||
final DistributionSet update = new DistributionSet();
|
||||
final DistributionSet update = distributionSetManagement.generateDistributionSet();
|
||||
update.setVersion("anotherVersion");
|
||||
update.setName(null);
|
||||
update.setType(standardDsType);
|
||||
@@ -600,11 +613,10 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
||||
|
||||
assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, false, true).getContent().get(0)
|
||||
.getVersion()).isEqualTo("anotherVersion");
|
||||
assertThat(
|
||||
distributionSetManagement.findDistributionSetsAll(pageReq, false, true).getContent().get(0).getName())
|
||||
.isEqualTo(set.getName());
|
||||
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());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -692,8 +704,8 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
|
||||
final DistributionSet testDS = TestDataUtil.generateDistributionSet("one", softwareManagement,
|
||||
distributionSetManagement);
|
||||
distributionSetManagement
|
||||
.createDistributionSetMetadata(new DistributionSetMetadata(knownKey, testDS, knownValue));
|
||||
distributionSetManagement.createDistributionSetMetadata(
|
||||
distributionSetManagement.generateDistributionSetMetadata(testDS, knownKey, knownValue));
|
||||
|
||||
final JSONObject jsonObject = new JSONObject().put("key", knownKey).put("value", updateValue);
|
||||
|
||||
@@ -718,8 +730,8 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
|
||||
final DistributionSet testDS = TestDataUtil.generateDistributionSet("one", softwareManagement,
|
||||
distributionSetManagement);
|
||||
distributionSetManagement
|
||||
.createDistributionSetMetadata(new DistributionSetMetadata(knownKey, testDS, knownValue));
|
||||
distributionSetManagement.createDistributionSetMetadata(
|
||||
distributionSetManagement.generateDistributionSetMetadata(testDS, knownKey, knownValue));
|
||||
|
||||
mvc.perform(delete("/rest/v1/distributionsets/{dsId}/metadata/{key}", testDS.getId(), knownKey))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
||||
@@ -740,8 +752,8 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
final String knownValue = "knownValue";
|
||||
final DistributionSet testDS = TestDataUtil.generateDistributionSet("one", softwareManagement,
|
||||
distributionSetManagement);
|
||||
distributionSetManagement
|
||||
.createDistributionSetMetadata(new DistributionSetMetadata(knownKey, testDS, knownValue));
|
||||
distributionSetManagement.createDistributionSetMetadata(
|
||||
distributionSetManagement.generateDistributionSetMetadata(testDS, knownKey, knownValue));
|
||||
|
||||
mvc.perform(get("/rest/v1/distributionsets/{dsId}/metadata/{key}", testDS.getId(), knownKey))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||
@@ -760,8 +772,9 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
final DistributionSet testDS = TestDataUtil.generateDistributionSet("one", softwareManagement,
|
||||
distributionSetManagement);
|
||||
for (int index = 0; index < totalMetadata; index++) {
|
||||
distributionSetManagement.createDistributionSetMetadata(new DistributionSetMetadata(knownKeyPrefix + index,
|
||||
distributionSetManagement.findDistributionSetById(testDS.getId()), knownValuePrefix + index));
|
||||
distributionSetManagement.createDistributionSetMetadata(distributionSetManagement
|
||||
.generateDistributionSetMetadata(distributionSetManagement.findDistributionSetById(testDS.getId()),
|
||||
knownKeyPrefix + index, knownValuePrefix + index));
|
||||
}
|
||||
|
||||
mvc.perform(get("/rest/v1/distributionsets/{dsId}/metadata?offset=" + offsetParam + "&limit=" + limitParam,
|
||||
@@ -795,8 +808,8 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
public void filterDistributionSetComplete() throws Exception {
|
||||
final int amount = 10;
|
||||
TestDataUtil.generateDistributionSets(amount, softwareManagement, distributionSetManagement);
|
||||
distributionSetManagement.createDistributionSet(new DistributionSet("incomplete", "2", "incomplete",
|
||||
distributionSetManagement.findDistributionSetTypeByKey("ecl_os"), null));
|
||||
distributionSetManagement.createDistributionSet(distributionSetManagement.generateDistributionSet("incomplete",
|
||||
"2", "incomplete", distributionSetManagement.findDistributionSetTypeByKey("ecl_os"), null));
|
||||
|
||||
final String rsqlFindLikeDs1OrDs2 = "complete==" + Boolean.TRUE;
|
||||
|
||||
@@ -815,7 +828,7 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
final String[] knownTargetIds = new String[] { "1", "2", "3", "4", "5" };
|
||||
final JSONArray list = new JSONArray();
|
||||
for (final String targetId : knownTargetIds) {
|
||||
targetManagement.createTarget(new Target(targetId));
|
||||
targetManagement.createTarget(targetManagement.generateTarget(targetId));
|
||||
list.put(new JSONObject().put("id", Long.valueOf(targetId)));
|
||||
}
|
||||
|
||||
@@ -840,8 +853,9 @@ public class MgmtDistributionSetResourceTest extends AbstractRestIntegrationTest
|
||||
final DistributionSet testDS = TestDataUtil.generateDistributionSet("one", softwareManagement,
|
||||
distributionSetManagement);
|
||||
for (int index = 0; index < totalMetadata; index++) {
|
||||
distributionSetManagement.createDistributionSetMetadata(new DistributionSetMetadata(knownKeyPrefix + index,
|
||||
distributionSetManagement.findDistributionSetById(testDS.getId()), knownValuePrefix + index));
|
||||
distributionSetManagement.createDistributionSetMetadata(distributionSetManagement
|
||||
.generateDistributionSetMetadata(distributionSetManagement.findDistributionSetById(testDS.getId()),
|
||||
knownKeyPrefix + index, knownValuePrefix + index));
|
||||
}
|
||||
|
||||
final String rsqlSearchValue1 = "value==knownValue1";
|
||||
|
||||
@@ -25,7 +25,6 @@ import java.util.List;
|
||||
|
||||
import org.eclipse.hawkbit.WithUser;
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||
@@ -58,8 +57,8 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
|
||||
@Description("Checks the correct behaviour of /rest/v1/distributionsettypes GET requests.")
|
||||
public void getDistributionSetTypes() throws Exception {
|
||||
|
||||
DistributionSetType testType = distributionSetManagement
|
||||
.createDistributionSetType(new DistributionSetType("test123", "TestName123", "Desc123"));
|
||||
DistributionSetType testType = distributionSetManagement.createDistributionSetType(
|
||||
distributionSetManagement.generateDistributionSetType("test123", "TestName123", "Desc123"));
|
||||
testType.setDescription("Desc1234");
|
||||
testType = distributionSetManagement.updateDistributionSetType(testType);
|
||||
|
||||
@@ -96,8 +95,8 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
|
||||
@Description("Checks the correct behaviour of /rest/v1/distributionsettypes GET requests with sorting by KEY.")
|
||||
public void getDistributionSetTypesSortedByKey() throws Exception {
|
||||
|
||||
DistributionSetType testType = distributionSetManagement
|
||||
.createDistributionSetType(new DistributionSetType("zzzzz", "TestName123", "Desc123"));
|
||||
DistributionSetType testType = distributionSetManagement.createDistributionSetType(
|
||||
distributionSetManagement.generateDistributionSetType("zzzzz", "TestName123", "Desc123"));
|
||||
testType.setDescription("Desc1234");
|
||||
testType = distributionSetManagement.updateDistributionSetType(testType);
|
||||
|
||||
@@ -136,12 +135,12 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
|
||||
assertThat(distributionSetManagement.countDistributionSetTypesAll()).isEqualTo(3);
|
||||
|
||||
final List<DistributionSetType> types = new ArrayList<>();
|
||||
types.add(new DistributionSetType("test1", "TestName1", "Desc1").addMandatoryModuleType(osType)
|
||||
.addOptionalModuleType(runtimeType));
|
||||
types.add(new DistributionSetType("test2", "TestName2", "Desc2").addOptionalModuleType(osType)
|
||||
.addOptionalModuleType(runtimeType).addOptionalModuleType(appType));
|
||||
types.add(new DistributionSetType("test3", "TestName3", "Desc3").addMandatoryModuleType(osType)
|
||||
.addMandatoryModuleType(runtimeType));
|
||||
types.add(distributionSetManagement.generateDistributionSetType("test1", "TestName1", "Desc1")
|
||||
.addMandatoryModuleType(osType).addOptionalModuleType(runtimeType));
|
||||
types.add(distributionSetManagement.generateDistributionSetType("test2", "TestName2", "Desc2")
|
||||
.addOptionalModuleType(osType).addOptionalModuleType(runtimeType).addOptionalModuleType(appType));
|
||||
types.add(distributionSetManagement.generateDistributionSetType("test3", "TestName3", "Desc3")
|
||||
.addMandatoryModuleType(osType).addMandatoryModuleType(runtimeType));
|
||||
|
||||
final MvcResult mvcResult = mvc
|
||||
.perform(post("/rest/v1/distributionsettypes/").content(JsonBuilder.distributionSetTypes(types))
|
||||
@@ -205,8 +204,8 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
|
||||
@WithUser(principal = "uploadTester", allSpPermissions = true)
|
||||
@Description("Checks the correct behaviour of /rest/v1/distributionsettypes/{ID}/mandatorymoduletypes POST requests.")
|
||||
public void addMandatoryModuleToDistributionSetType() throws JSONException, Exception {
|
||||
DistributionSetType testType = distributionSetManagement
|
||||
.createDistributionSetType(new DistributionSetType("test123", "TestName123", "Desc123"));
|
||||
DistributionSetType testType = distributionSetManagement.createDistributionSetType(
|
||||
distributionSetManagement.generateDistributionSetType("test123", "TestName123", "Desc123"));
|
||||
assertThat(testType.getOptLockRevision()).isEqualTo(1);
|
||||
|
||||
mvc.perform(post("/rest/v1/distributionsettypes/{dstID}/mandatorymoduletypes", testType.getId())
|
||||
@@ -224,8 +223,8 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
|
||||
@WithUser(principal = "uploadTester", allSpPermissions = true)
|
||||
@Description("Checks the correct behaviour of /rest/v1/distributionsettypes/{ID}/optionalmoduletypes POST requests.")
|
||||
public void addOptionalModuleToDistributionSetType() throws JSONException, Exception {
|
||||
DistributionSetType testType = distributionSetManagement
|
||||
.createDistributionSetType(new DistributionSetType("test123", "TestName123", "Desc123"));
|
||||
DistributionSetType testType = distributionSetManagement.createDistributionSetType(
|
||||
distributionSetManagement.generateDistributionSetType("test123", "TestName123", "Desc123"));
|
||||
assertThat(testType.getOptLockRevision()).isEqualTo(1);
|
||||
|
||||
mvc.perform(post("/rest/v1/distributionsettypes/{dstID}/optionalmoduletypes", testType.getId())
|
||||
@@ -244,8 +243,8 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
|
||||
@WithUser(principal = "uploadTester", allSpPermissions = true)
|
||||
@Description("Checks the correct behaviour of /rest/v1/distributionsettypes/{ID}/mandatorymoduletypes GET requests.")
|
||||
public void getMandatoryModulesOfDistributionSetType() throws JSONException, Exception {
|
||||
final DistributionSetType testType = distributionSetManagement
|
||||
.createDistributionSetType(new DistributionSetType("test123", "TestName123", "Desc123")
|
||||
final DistributionSetType testType = distributionSetManagement.createDistributionSetType(
|
||||
distributionSetManagement.generateDistributionSetType("test123", "TestName123", "Desc123")
|
||||
.addMandatoryModuleType(osType).addOptionalModuleType(appType));
|
||||
assertThat(testType.getOptLockRevision()).isEqualTo(1);
|
||||
assertThat(testType.getOptionalModuleTypes()).containsExactly(appType);
|
||||
@@ -263,8 +262,8 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
|
||||
@WithUser(principal = "uploadTester", allSpPermissions = true)
|
||||
@Description("Checks the correct behaviour of /rest/v1/distributionsettypes/{ID}/optionalmoduletypes GET requests.")
|
||||
public void getOptionalModulesOfDistributionSetType() throws JSONException, Exception {
|
||||
final DistributionSetType testType = distributionSetManagement
|
||||
.createDistributionSetType(new DistributionSetType("test123", "TestName123", "Desc123")
|
||||
final DistributionSetType testType = distributionSetManagement.createDistributionSetType(
|
||||
distributionSetManagement.generateDistributionSetType("test123", "TestName123", "Desc123")
|
||||
.addMandatoryModuleType(osType).addOptionalModuleType(appType));
|
||||
assertThat(testType.getOptLockRevision()).isEqualTo(1);
|
||||
assertThat(testType.getOptionalModuleTypes()).containsExactly(appType);
|
||||
@@ -283,8 +282,8 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
|
||||
@WithUser(principal = "uploadTester", allSpPermissions = true)
|
||||
@Description("Checks the correct behaviour of /rest/v1/distributionsettypes/{ID}/mandatorymoduletypes/{ID} GET requests.")
|
||||
public void getMandatoryModuleOfDistributionSetType() throws JSONException, Exception {
|
||||
final DistributionSetType testType = distributionSetManagement
|
||||
.createDistributionSetType(new DistributionSetType("test123", "TestName123", "Desc123")
|
||||
final DistributionSetType testType = distributionSetManagement.createDistributionSetType(
|
||||
distributionSetManagement.generateDistributionSetType("test123", "TestName123", "Desc123")
|
||||
.addMandatoryModuleType(osType).addOptionalModuleType(appType));
|
||||
assertThat(testType.getOptLockRevision()).isEqualTo(1);
|
||||
assertThat(testType.getOptionalModuleTypes()).containsExactly(appType);
|
||||
@@ -305,8 +304,8 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
|
||||
@WithUser(principal = "uploadTester", allSpPermissions = true)
|
||||
@Description("Checks the correct behaviour of /rest/v1/distributionsettypes/{ID}/optionalmoduletypes/{ID} GET requests.")
|
||||
public void getOptionalModuleOfDistributionSetType() throws JSONException, Exception {
|
||||
final DistributionSetType testType = distributionSetManagement
|
||||
.createDistributionSetType(new DistributionSetType("test123", "TestName123", "Desc123")
|
||||
final DistributionSetType testType = distributionSetManagement.createDistributionSetType(
|
||||
distributionSetManagement.generateDistributionSetType("test123", "TestName123", "Desc123")
|
||||
.addMandatoryModuleType(osType).addOptionalModuleType(appType));
|
||||
assertThat(testType.getOptLockRevision()).isEqualTo(1);
|
||||
assertThat(testType.getOptionalModuleTypes()).containsExactly(appType);
|
||||
@@ -327,8 +326,8 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
|
||||
@WithUser(principal = "uploadTester", allSpPermissions = true)
|
||||
@Description("Checks the correct behaviour of /rest/v1/distributionsettypes/{ID}/mandatorymoduletypes/{ID} DELETE requests.")
|
||||
public void removeMandatoryModuleToDistributionSetType() throws JSONException, Exception {
|
||||
DistributionSetType testType = distributionSetManagement
|
||||
.createDistributionSetType(new DistributionSetType("test123", "TestName123", "Desc123")
|
||||
DistributionSetType testType = distributionSetManagement.createDistributionSetType(
|
||||
distributionSetManagement.generateDistributionSetType("test123", "TestName123", "Desc123")
|
||||
.addMandatoryModuleType(osType).addOptionalModuleType(appType));
|
||||
assertThat(testType.getOptLockRevision()).isEqualTo(1);
|
||||
assertThat(testType.getOptionalModuleTypes()).containsExactly(appType);
|
||||
@@ -349,8 +348,8 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
|
||||
@WithUser(principal = "uploadTester", allSpPermissions = true)
|
||||
@Description("Checks the correct behaviour of /rest/v1/distributionsettypes/{ID}/optionalmoduletypes/{ID} DELETE requests.")
|
||||
public void removeOptionalModuleToDistributionSetType() throws JSONException, Exception {
|
||||
DistributionSetType testType = distributionSetManagement
|
||||
.createDistributionSetType(new DistributionSetType("test123", "TestName123", "Desc123")
|
||||
DistributionSetType testType = distributionSetManagement.createDistributionSetType(
|
||||
distributionSetManagement.generateDistributionSetType("test123", "TestName123", "Desc123")
|
||||
.addMandatoryModuleType(osType).addOptionalModuleType(appType));
|
||||
assertThat(testType.getOptLockRevision()).isEqualTo(1);
|
||||
assertThat(testType.getOptionalModuleTypes()).containsExactly(appType);
|
||||
@@ -372,8 +371,8 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
|
||||
@Description("Checks the correct behaviour of /rest/v1/distributionsettypes/{ID} GET requests.")
|
||||
public void getDistributionSetType() throws Exception {
|
||||
|
||||
DistributionSetType testType = distributionSetManagement
|
||||
.createDistributionSetType(new DistributionSetType("test123", "TestName123", "Desc123"));
|
||||
DistributionSetType testType = distributionSetManagement.createDistributionSetType(
|
||||
distributionSetManagement.generateDistributionSetType("test123", "TestName123", "Desc123"));
|
||||
testType.setDescription("Desc1234");
|
||||
testType = distributionSetManagement.updateDistributionSetType(testType);
|
||||
|
||||
@@ -391,8 +390,8 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
|
||||
@WithUser(principal = "uploadTester", allSpPermissions = true)
|
||||
@Description("Checks the correct behaviour of /rest/v1/DistributionSetTypes/{ID} DELETE requests (hard delete scenario).")
|
||||
public void deleteDistributionSetTypeUnused() throws Exception {
|
||||
final DistributionSetType testType = distributionSetManagement
|
||||
.createDistributionSetType(new DistributionSetType("test123", "TestName123", "Desc123"));
|
||||
final DistributionSetType testType = distributionSetManagement.createDistributionSetType(
|
||||
distributionSetManagement.generateDistributionSetType("test123", "TestName123", "Desc123"));
|
||||
|
||||
assertThat(distributionSetManagement.countDistributionSetTypesAll()).isEqualTo(4);
|
||||
|
||||
@@ -406,10 +405,10 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
|
||||
@WithUser(principal = "uploadTester", allSpPermissions = true)
|
||||
@Description("Checks the correct behaviour of /rest/v1/DistributionSetTypes/{ID} DELETE requests (soft delete scenario).")
|
||||
public void deleteDistributionSetTypeUsed() throws Exception {
|
||||
final DistributionSetType testType = distributionSetManagement
|
||||
.createDistributionSetType(new DistributionSetType("test123", "TestName123", "Desc123"));
|
||||
distributionSetManagement
|
||||
.createDistributionSet(new DistributionSet("sdfsd", "dsfsdf", "sdfsdf", testType, null));
|
||||
final DistributionSetType testType = distributionSetManagement.createDistributionSetType(
|
||||
distributionSetManagement.generateDistributionSetType("test123", "TestName123", "Desc123"));
|
||||
distributionSetManagement.createDistributionSet(
|
||||
distributionSetManagement.generateDistributionSet("sdfsd", "dsfsdf", "sdfsdf", testType, null));
|
||||
|
||||
assertThat(distributionSetManagement.countDistributionSetTypesAll()).isEqualTo(4);
|
||||
assertThat(distributionSetTypeRepository.count()).isEqualTo(4);
|
||||
@@ -424,8 +423,8 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
|
||||
@Test
|
||||
@Description("Checks the correct behaviour of /rest/v1/distributionsettypes/{ID} PUT requests.")
|
||||
public void updateDistributionSetTypeOnlyDescriptionAndNameUntouched() throws Exception {
|
||||
final DistributionSetType testType = distributionSetManagement
|
||||
.createDistributionSetType(new DistributionSetType("test123", "TestName123", "Desc123"));
|
||||
final DistributionSetType testType = distributionSetManagement.createDistributionSetType(
|
||||
distributionSetManagement.generateDistributionSetType("test123", "TestName123", "Desc123"));
|
||||
|
||||
final String body = new JSONObject().put("id", testType.getId()).put("description", "foobardesc")
|
||||
.put("name", "nameShouldNotBeChanged").toString();
|
||||
@@ -479,11 +478,11 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
|
||||
@Test
|
||||
@Description("Ensures that the server is behaving as expected on invalid requests (wrong media type, wrong ID etc.).")
|
||||
public void invalidRequestsOnDistributionSetTypesResource() throws Exception {
|
||||
final DistributionSetType testType = distributionSetManagement
|
||||
.createDistributionSetType(new DistributionSetType("test123", "TestName123", "Desc123"));
|
||||
final DistributionSetType testType = distributionSetManagement.createDistributionSetType(
|
||||
distributionSetManagement.generateDistributionSetType("test123", "TestName123", "Desc123"));
|
||||
|
||||
final SoftwareModuleType testSmType = softwareManagement
|
||||
.createSoftwareModuleType(new SoftwareModuleType("test123", "TestName123", "Desc123", 5));
|
||||
final SoftwareModuleType testSmType = softwareManagement.createSoftwareModuleType(
|
||||
softwareManagement.generateSoftwareModuleType("test123", "TestName123", "Desc123", 5));
|
||||
|
||||
final List<DistributionSetType> types = new ArrayList<>();
|
||||
types.add(testType);
|
||||
@@ -526,8 +525,10 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
|
||||
|
||||
// Modules types at creation time invalid
|
||||
|
||||
final DistributionSetType testNewType = new DistributionSetType("test123", "TestName123", "Desc123");
|
||||
testNewType.addMandatoryModuleType(new SoftwareModuleType("foo", "bar", "test", Integer.MAX_VALUE));
|
||||
final DistributionSetType testNewType = distributionSetManagement.generateDistributionSetType("test123",
|
||||
"TestName123", "Desc123");
|
||||
testNewType.addMandatoryModuleType(
|
||||
softwareManagement.generateSoftwareModuleType("foo", "bar", "test", Integer.MAX_VALUE));
|
||||
|
||||
mvc.perform(post("/rest/v1/distributionsettypes")
|
||||
.content(JsonBuilder.distributionSetTypes(Lists.newArrayList(testNewType)))
|
||||
@@ -560,10 +561,10 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
|
||||
@Test
|
||||
@Description("Search erquest of software module types.")
|
||||
public void searchDistributionSetTypeRsql() throws Exception {
|
||||
final DistributionSetType testType = distributionSetManagement
|
||||
.createDistributionSetType(new DistributionSetType("test123", "TestName123", "Desc123"));
|
||||
final DistributionSetType testType2 = distributionSetManagement
|
||||
.createDistributionSetType(new DistributionSetType("test1234", "TestName1234", "Desc123"));
|
||||
final DistributionSetType testType = distributionSetManagement.createDistributionSetType(
|
||||
distributionSetManagement.generateDistributionSetType("test123", "TestName123", "Desc123"));
|
||||
final DistributionSetType testType2 = distributionSetManagement.createDistributionSetType(
|
||||
distributionSetManagement.generateDistributionSetType("test1234", "TestName1234", "Desc123"));
|
||||
|
||||
final String rsqlFindLikeDs1OrDs2 = "name==TestName123,name==TestName1234";
|
||||
|
||||
@@ -577,7 +578,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractRestIntegration
|
||||
char character = 'a';
|
||||
for (int index = 0; index < amount; index++) {
|
||||
final String str = String.valueOf(character);
|
||||
final SoftwareModule softwareModule = new SoftwareModule(osType, str, str, str, str);
|
||||
final SoftwareModule softwareModule = softwareManagement.generateSoftwareModule(osType, str, str, str, str);
|
||||
|
||||
softwareManagement.createSoftwareModule(softwareModule);
|
||||
character++;
|
||||
|
||||
@@ -30,8 +30,8 @@ import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.Rollout;
|
||||
import org.eclipse.hawkbit.repository.model.Rollout.RolloutStatus;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroup;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupConditionBuilder;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupSuccessCondition;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroupConditionBuilder;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.rest.AbstractRestIntegrationTest;
|
||||
import org.eclipse.hawkbit.rest.util.JsonBuilder;
|
||||
@@ -577,7 +577,7 @@ public class MgmtRolloutResourceTest extends AbstractRestIntegrationTest {
|
||||
|
||||
private Rollout createRollout(final String name, final int amountGroups, final long distributionSetId,
|
||||
final String targetFilterQuery) {
|
||||
final Rollout rollout = new Rollout();
|
||||
final Rollout rollout = rolloutManagement.generateRollout();
|
||||
rollout.setDistributionSet(distributionSetManagement.findDistributionSetById(distributionSetId));
|
||||
rollout.setName(name);
|
||||
rollout.setTargetFilterQuery(targetFilterQuery);
|
||||
|
||||
@@ -44,7 +44,6 @@ import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.LocalArtifact;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata;
|
||||
import org.eclipse.hawkbit.repository.model.SwMetadataCompositeKey;
|
||||
import org.eclipse.hawkbit.rest.AbstractRestIntegrationTestWithMongoDB;
|
||||
import org.eclipse.hawkbit.rest.json.model.ExceptionInfo;
|
||||
import org.eclipse.hawkbit.rest.util.JsonBuilder;
|
||||
@@ -92,11 +91,15 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
|
||||
final String updateVendor = "newVendor1";
|
||||
final String updateDescription = "newDescription1";
|
||||
|
||||
softwareManagement.createSoftwareModule(new SoftwareModule(appType, "agent-hub", "1.0.1", null, ""));
|
||||
softwareManagement.createSoftwareModule(new SoftwareModule(runtimeType, "oracle-jre", "1.7.2", null, ""));
|
||||
softwareManagement.createSoftwareModule(new SoftwareModule(osType, "poky", "3.0.2", null, ""));
|
||||
softwareManagement.createSoftwareModule(
|
||||
softwareManagement.generateSoftwareModule(appType, "agent-hub", "1.0.1", null, ""));
|
||||
softwareManagement.createSoftwareModule(
|
||||
softwareManagement.generateSoftwareModule(runtimeType, "oracle-jre", "1.7.2", null, ""));
|
||||
softwareManagement
|
||||
.createSoftwareModule(softwareManagement.generateSoftwareModule(osType, "poky", "3.0.2", null, ""));
|
||||
|
||||
SoftwareModule sm = new SoftwareModule(osType, knownSWName, knownSWVersion, knownSWDescription, knownSWVendor);
|
||||
SoftwareModule sm = softwareManagement.generateSoftwareModule(osType, knownSWName, knownSWVersion,
|
||||
knownSWDescription, knownSWVendor);
|
||||
sm = softwareManagement.createSoftwareModule(sm);
|
||||
|
||||
assertThat(sm.getName()).as("Wrong name of the software module").isEqualTo(knownSWName);
|
||||
@@ -122,7 +125,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
|
||||
@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 {
|
||||
SoftwareModule sm = new SoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
SoftwareModule sm = softwareManagement.generateSoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
sm = softwareManagement.createSoftwareModule(sm);
|
||||
assertThat(artifactRepository.findAll()).hasSize(0);
|
||||
|
||||
@@ -191,7 +194,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
|
||||
assertThat(softwareManagement.findSoftwareModulesAll(pageReq)).hasSize(0);
|
||||
assertThat(artifactRepository.findAll()).hasSize(0);
|
||||
|
||||
SoftwareModule sm = new SoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
SoftwareModule sm = softwareManagement.generateSoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
sm = softwareManagement.createSoftwareModule(sm);
|
||||
|
||||
final MockMultipartFile file = new MockMultipartFile("file", "orig", null, new byte[0]);
|
||||
@@ -204,7 +207,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
|
||||
@Test
|
||||
@Description("Verfies that the system does not accept identical artifacts uploads for the same software module. Expected response: CONFLICT")
|
||||
public void duplicateUploadArtifact() throws Exception {
|
||||
SoftwareModule sm = new SoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
SoftwareModule sm = softwareManagement.generateSoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
sm = softwareManagement.createSoftwareModule(sm);
|
||||
|
||||
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
||||
@@ -226,7 +229,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
|
||||
@Test
|
||||
@Description("verfies that option to upload artifacts with a custom defined by metadata, i.e. not the file name of the binary itself.")
|
||||
public void uploadArtifactWithCustomName() throws Exception {
|
||||
SoftwareModule sm = new SoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
SoftwareModule sm = softwareManagement.generateSoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
sm = softwareManagement.createSoftwareModule(sm);
|
||||
assertThat(artifactRepository.findAll()).hasSize(0);
|
||||
|
||||
@@ -253,7 +256,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
|
||||
@Test
|
||||
@Description("Verfies that the system refuses upload of an artifact where the provided hash sums do not match. Expected result: BAD REQUEST")
|
||||
public void uploadArtifactWithHashCheck() throws Exception {
|
||||
SoftwareModule sm = new SoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
SoftwareModule sm = softwareManagement.generateSoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
sm = softwareManagement.createSoftwareModule(sm);
|
||||
assertThat(artifactRepository.findAll()).hasSize(0);
|
||||
|
||||
@@ -297,7 +300,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
|
||||
@Test
|
||||
@Description("Tests binary download of an artifact including verfication that the downloaded binary is consistent and that the etag header is as expected identical to the SHA1 hash of the file.")
|
||||
public void downloadArtifact() throws Exception {
|
||||
SoftwareModule sm = new SoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
SoftwareModule sm = softwareManagement.generateSoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
sm = softwareManagement.createSoftwareModule(sm);
|
||||
|
||||
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
||||
@@ -332,7 +335,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
|
||||
@Description("Verifies the listing of one defined artifact assigned to a given software module. That includes the artifact metadata and download links.")
|
||||
public void getArtifact() throws Exception {
|
||||
// prepare data for test
|
||||
SoftwareModule sm = new SoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
SoftwareModule sm = softwareManagement.generateSoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
sm = softwareManagement.createSoftwareModule(sm);
|
||||
|
||||
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
||||
@@ -358,7 +361,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
|
||||
@Test
|
||||
@Description("Verifies the listing of all artifacts assigned to a software module. That includes the artifact metadata and download links.")
|
||||
public void getArtifacts() throws Exception {
|
||||
SoftwareModule sm = new SoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
SoftwareModule sm = softwareManagement.generateSoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
sm = softwareManagement.createSoftwareModule(sm);
|
||||
|
||||
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
||||
@@ -401,7 +404,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
|
||||
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
||||
final MockMultipartFile file = new MockMultipartFile("file", "orig", null, random);
|
||||
|
||||
SoftwareModule sm = new SoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
SoftwareModule sm = softwareManagement.generateSoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
sm = softwareManagement.createSoftwareModule(sm);
|
||||
|
||||
// no artifact available
|
||||
@@ -434,7 +437,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
|
||||
@Test
|
||||
@Description("Verfies that the system refuses unsupported request types and answers as defined to them, e.g. NOT FOUND on a non existing resource. Or a HTTP POST for updating a resource results in METHOD NOT ALLOWED etc.")
|
||||
public void invalidRequestsOnSoftwaremodulesResource() throws Exception {
|
||||
SoftwareModule sm = new SoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
SoftwareModule sm = softwareManagement.generateSoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
sm = softwareManagement.createSoftwareModule(sm);
|
||||
|
||||
final List<SoftwareModule> modules = new ArrayList<>();
|
||||
@@ -516,13 +519,16 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
|
||||
@WithUser(principal = "uploadTester", allSpPermissions = true)
|
||||
@Description("Test retrieval of all software modules the user has access to.")
|
||||
public void getSoftwareModules() throws Exception {
|
||||
SoftwareModule os = new SoftwareModule(osType, "name1", "version1", "description1", "vendor1");
|
||||
SoftwareModule os = softwareManagement.generateSoftwareModule(osType, "name1", "version1", "description1",
|
||||
"vendor1");
|
||||
os = softwareManagement.createSoftwareModule(os);
|
||||
|
||||
SoftwareModule jvm = new SoftwareModule(runtimeType, "name1", "version1", "description1", "vendor1");
|
||||
SoftwareModule jvm = softwareManagement.generateSoftwareModule(runtimeType, "name1", "version1", "description1",
|
||||
"vendor1");
|
||||
jvm = softwareManagement.createSoftwareModule(jvm);
|
||||
|
||||
SoftwareModule ah = new SoftwareModule(appType, "name1", "version1", "description1", "vendor1");
|
||||
SoftwareModule ah = softwareManagement.generateSoftwareModule(appType, "name1", "version1", "description1",
|
||||
"vendor1");
|
||||
ah = softwareManagement.createSoftwareModule(ah);
|
||||
|
||||
mvc.perform(get("/rest/v1/softwaremodules").accept(MediaType.APPLICATION_JSON))
|
||||
@@ -584,22 +590,28 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
|
||||
@Test
|
||||
@Description("Test the various filter parameters, e.g. filter by name or type of the module.")
|
||||
public void getSoftwareModulesWithFilterParameters() throws Exception {
|
||||
SoftwareModule os1 = new SoftwareModule(osType, "osName1", "1.0.0", "description1", "vendor1");
|
||||
SoftwareModule os1 = softwareManagement.generateSoftwareModule(osType, "osName1", "1.0.0", "description1",
|
||||
"vendor1");
|
||||
os1 = softwareManagement.createSoftwareModule(os1);
|
||||
|
||||
SoftwareModule jvm1 = new SoftwareModule(runtimeType, "runtimeName1", "2.0.0", "description1", "vendor1");
|
||||
SoftwareModule jvm1 = softwareManagement.generateSoftwareModule(runtimeType, "runtimeName1", "2.0.0",
|
||||
"description1", "vendor1");
|
||||
jvm1 = softwareManagement.createSoftwareModule(jvm1);
|
||||
|
||||
SoftwareModule ah1 = new SoftwareModule(appType, "appName1", "3.0.0", "description1", "vendor1");
|
||||
SoftwareModule ah1 = softwareManagement.generateSoftwareModule(appType, "appName1", "3.0.0", "description1",
|
||||
"vendor1");
|
||||
ah1 = softwareManagement.createSoftwareModule(ah1);
|
||||
|
||||
SoftwareModule os2 = new SoftwareModule(osType, "osName2", "1.0.1", "description2", "vendor2");
|
||||
SoftwareModule os2 = softwareManagement.generateSoftwareModule(osType, "osName2", "1.0.1", "description2",
|
||||
"vendor2");
|
||||
os2 = softwareManagement.createSoftwareModule(os2);
|
||||
|
||||
SoftwareModule jvm2 = new SoftwareModule(runtimeType, "runtimeName2", "2.0.1", "description2", "vendor2");
|
||||
SoftwareModule jvm2 = softwareManagement.generateSoftwareModule(runtimeType, "runtimeName2", "2.0.1",
|
||||
"description2", "vendor2");
|
||||
jvm2 = softwareManagement.createSoftwareModule(jvm2);
|
||||
|
||||
SoftwareModule ah2 = new SoftwareModule(appType, "appName2", "3.0.1", "description2", "vendor2");
|
||||
SoftwareModule ah2 = softwareManagement.generateSoftwareModule(appType, "appName2", "3.0.1", "description2",
|
||||
"vendor2");
|
||||
ah2 = softwareManagement.createSoftwareModule(ah2);
|
||||
|
||||
assertThat(softwareManagement.findSoftwareModulesAll(pageReq)).hasSize(6);
|
||||
@@ -676,7 +688,8 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
|
||||
@WithUser(principal = "uploadTester", allSpPermissions = true)
|
||||
@Description("Tests GET request on /rest/v1/softwaremodules/{smId}.")
|
||||
public void getSoftareModule() throws Exception {
|
||||
SoftwareModule os = new SoftwareModule(osType, "name1", "version1", "description1", "vendor1");
|
||||
SoftwareModule os = softwareManagement.generateSoftwareModule(osType, "name1", "version1", "description1",
|
||||
"vendor1");
|
||||
os = softwareManagement.createSoftwareModule(os);
|
||||
|
||||
mvc.perform(get("/rest/v1/softwaremodules/{smId}", os.getId()).accept(MediaType.APPLICATION_JSON))
|
||||
@@ -695,7 +708,8 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
|
||||
.andExpect(jsonPath("$_links.artifacts.href",
|
||||
equalTo("http://localhost/rest/v1/softwaremodules/" + os.getId() + "/artifacts")));
|
||||
|
||||
SoftwareModule jvm = new SoftwareModule(runtimeType, "name1", "version1", "description1", "vendor1");
|
||||
SoftwareModule jvm = softwareManagement.generateSoftwareModule(runtimeType, "name1", "version1", "description1",
|
||||
"vendor1");
|
||||
jvm = softwareManagement.createSoftwareModule(jvm);
|
||||
|
||||
mvc.perform(get("/rest/v1/softwaremodules/{smId}", jvm.getId()).accept(MediaType.APPLICATION_JSON))
|
||||
@@ -714,7 +728,8 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
|
||||
.andExpect(jsonPath("$_links.artifacts.href",
|
||||
equalTo("http://localhost/rest/v1/softwaremodules/" + jvm.getId() + "/artifacts")));
|
||||
|
||||
SoftwareModule ah = new SoftwareModule(appType, "name1", "version1", "description1", "vendor1");
|
||||
SoftwareModule ah = softwareManagement.generateSoftwareModule(appType, "name1", "version1", "description1",
|
||||
"vendor1");
|
||||
ah = softwareManagement.createSoftwareModule(ah);
|
||||
|
||||
mvc.perform(get("/rest/v1/softwaremodules/{smId}", ah.getId()).accept(MediaType.APPLICATION_JSON))
|
||||
@@ -740,9 +755,12 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
|
||||
@WithUser(principal = "uploadTester", allSpPermissions = true)
|
||||
@Description("Verfies that the create request actually results in the creation of the modules in the repository.")
|
||||
public void createSoftwareModules() throws JSONException, Exception {
|
||||
final SoftwareModule os = new SoftwareModule(osType, "name1", "version1", "description1", "vendor1");
|
||||
final SoftwareModule jvm = new SoftwareModule(runtimeType, "name2", "version1", "description1", "vendor1");
|
||||
final SoftwareModule ah = new SoftwareModule(appType, "name3", "version1", "description1", "vendor1");
|
||||
final SoftwareModule os = softwareManagement.generateSoftwareModule(osType, "name1", "version1", "description1",
|
||||
"vendor1");
|
||||
final SoftwareModule jvm = softwareManagement.generateSoftwareModule(runtimeType, "name2", "version1",
|
||||
"description1", "vendor1");
|
||||
final SoftwareModule ah = softwareManagement.generateSoftwareModule(appType, "name3", "version1",
|
||||
"description1", "vendor1");
|
||||
|
||||
final List<SoftwareModule> modules = new ArrayList<>();
|
||||
modules.add(os);
|
||||
@@ -823,7 +841,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
|
||||
@Description("Verifies successfull deletion of software modules that are not in use, i.e. assigned to a DS.")
|
||||
public void deleteUnassignedSoftwareModule() throws Exception {
|
||||
|
||||
SoftwareModule sm = new SoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
SoftwareModule sm = softwareManagement.generateSoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
sm = softwareManagement.createSoftwareModule(sm);
|
||||
|
||||
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
||||
@@ -879,7 +897,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
|
||||
@Description("Tests the deletion of an artifact including verfication that the artifact is actually erased in the repository and removed from the software module.")
|
||||
public void deleteArtifact() throws Exception {
|
||||
// Create 1 SM
|
||||
SoftwareModule sm = new SoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
SoftwareModule sm = softwareManagement.generateSoftwareModule(osType, "name 1", "version 1", null, null);
|
||||
sm = softwareManagement.createSoftwareModule(sm);
|
||||
|
||||
final byte random[] = RandomStringUtils.random(5 * 1024).getBytes();
|
||||
@@ -918,8 +936,8 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
|
||||
final String knownKey2 = "knownKey1";
|
||||
final String knownValue2 = "knownValue1";
|
||||
|
||||
final SoftwareModule sm = softwareManagement
|
||||
.createSoftwareModule(new SoftwareModule(osType, "name 1", "version 1", null, null));
|
||||
final SoftwareModule sm = softwareManagement.createSoftwareModule(
|
||||
softwareManagement.generateSoftwareModule(osType, "name 1", "version 1", null, null));
|
||||
|
||||
final JSONArray jsonArray = new JSONArray();
|
||||
jsonArray.put(new JSONObject().put("key", knownKey1).put("value", knownValue1));
|
||||
@@ -932,10 +950,8 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
|
||||
.andExpect(jsonPath("[1]key", equalTo(knownKey2)))
|
||||
.andExpect(jsonPath("[1]value", equalTo(knownValue2)));
|
||||
|
||||
final SoftwareModuleMetadata metaKey1 = softwareManagement
|
||||
.findSoftwareModuleMetadata(new SwMetadataCompositeKey(sm, knownKey1));
|
||||
final SoftwareModuleMetadata metaKey2 = softwareManagement
|
||||
.findSoftwareModuleMetadata(new SwMetadataCompositeKey(sm, knownKey2));
|
||||
final SoftwareModuleMetadata metaKey1 = softwareManagement.findSoftwareModuleMetadata(sm, knownKey1);
|
||||
final SoftwareModuleMetadata metaKey2 = softwareManagement.findSoftwareModuleMetadata(sm, knownKey2);
|
||||
|
||||
assertThat(metaKey1.getValue()).as("Metadata key is wrong").isEqualTo(knownValue1);
|
||||
assertThat(metaKey2.getValue()).as("Metadata key is wrong").isEqualTo(knownValue2);
|
||||
@@ -949,9 +965,10 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
|
||||
final String knownValue = "knownValue";
|
||||
final String updateValue = "valueForUpdate";
|
||||
|
||||
final SoftwareModule sm = softwareManagement
|
||||
.createSoftwareModule(new SoftwareModule(osType, "name 1", "version 1", null, null));
|
||||
softwareManagement.createSoftwareModuleMetadata(new SoftwareModuleMetadata(knownKey, sm, knownValue));
|
||||
final SoftwareModule sm = softwareManagement.createSoftwareModule(
|
||||
softwareManagement.generateSoftwareModule(osType, "name 1", "version 1", null, null));
|
||||
softwareManagement.createSoftwareModuleMetadata(
|
||||
softwareManagement.generateSoftwareModuleMetadata(sm, knownKey, knownValue));
|
||||
|
||||
final JSONObject jsonObject = new JSONObject().put("key", knownKey).put("value", updateValue);
|
||||
|
||||
@@ -961,8 +978,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
|
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
|
||||
.andExpect(jsonPath("key", equalTo(knownKey))).andExpect(jsonPath("value", equalTo(updateValue)));
|
||||
|
||||
final SoftwareModuleMetadata assertDS = softwareManagement
|
||||
.findSoftwareModuleMetadata(new SwMetadataCompositeKey(sm, knownKey));
|
||||
final SoftwareModuleMetadata assertDS = softwareManagement.findSoftwareModuleMetadata(sm, knownKey);
|
||||
assertThat(assertDS.getValue()).as("Metadata is wrong").isEqualTo(updateValue);
|
||||
}
|
||||
|
||||
@@ -973,15 +989,16 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
|
||||
final String knownKey = "knownKey";
|
||||
final String knownValue = "knownValue";
|
||||
|
||||
final SoftwareModule sm = softwareManagement
|
||||
.createSoftwareModule(new SoftwareModule(osType, "name 1", "version 1", null, null));
|
||||
softwareManagement.createSoftwareModuleMetadata(new SoftwareModuleMetadata(knownKey, sm, knownValue));
|
||||
final SoftwareModule sm = softwareManagement.createSoftwareModule(
|
||||
softwareManagement.generateSoftwareModule(osType, "name 1", "version 1", null, null));
|
||||
softwareManagement.createSoftwareModuleMetadata(
|
||||
softwareManagement.generateSoftwareModuleMetadata(sm, knownKey, knownValue));
|
||||
|
||||
mvc.perform(delete("/rest/v1/softwaremodules/{swId}/metadata/{key}", sm.getId(), knownKey))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
||||
|
||||
try {
|
||||
softwareManagement.findSoftwareModuleMetadata(new SwMetadataCompositeKey(sm, knownKey));
|
||||
softwareManagement.findSoftwareModuleMetadata(sm, knownKey);
|
||||
fail("expected EntityNotFoundException but didn't throw");
|
||||
} catch (final EntityNotFoundException e) {
|
||||
// ok as expected
|
||||
@@ -994,12 +1011,13 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
|
||||
final int totalMetadata = 10;
|
||||
final String knownKeyPrefix = "knownKey";
|
||||
final String knownValuePrefix = "knownValue";
|
||||
final SoftwareModule sm = softwareManagement
|
||||
.createSoftwareModule(new SoftwareModule(osType, "name 1", "version 1", null, null));
|
||||
final SoftwareModule sm = softwareManagement.createSoftwareModule(
|
||||
softwareManagement.generateSoftwareModule(osType, "name 1", "version 1", null, null));
|
||||
|
||||
for (int index = 0; index < totalMetadata; index++) {
|
||||
softwareManagement.createSoftwareModuleMetadata(new SoftwareModuleMetadata(knownKeyPrefix + index,
|
||||
softwareManagement.findSoftwareModuleById(sm.getId()), knownValuePrefix + index));
|
||||
softwareManagement.createSoftwareModuleMetadata(softwareManagement.generateSoftwareModuleMetadata(
|
||||
softwareManagement.findSoftwareModuleById(sm.getId()), knownKeyPrefix + index,
|
||||
knownValuePrefix + index));
|
||||
}
|
||||
|
||||
final String rsqlSearchValue1 = "value==knownValue1";
|
||||
@@ -1014,7 +1032,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractRestIntegrationTestW
|
||||
char character = 'a';
|
||||
for (int index = 0; index < amount; index++) {
|
||||
final String str = String.valueOf(character);
|
||||
final SoftwareModule softwareModule = new SoftwareModule(osType, str, str, str, str);
|
||||
final SoftwareModule softwareModule = softwareManagement.generateSoftwareModule(osType, str, str, str, str);
|
||||
|
||||
softwareManagement.createSoftwareModule(softwareModule);
|
||||
character++;
|
||||
|
||||
@@ -54,8 +54,8 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractRestIntegrationT
|
||||
@WithUser(principal = "uploadTester", allSpPermissions = true)
|
||||
@Description("Checks the correct behaviour of /rest/v1/softwaremoduletypes GET requests.")
|
||||
public void getSoftwareModuleTypes() throws Exception {
|
||||
SoftwareModuleType testType = softwareManagement
|
||||
.createSoftwareModuleType(new SoftwareModuleType("test123", "TestName123", "Desc123", 5));
|
||||
SoftwareModuleType testType = softwareManagement.createSoftwareModuleType(
|
||||
softwareManagement.generateSoftwareModuleType("test123", "TestName123", "Desc123", 5));
|
||||
testType.setDescription("Desc1234");
|
||||
testType = softwareManagement.updateSoftwareModuleType(testType);
|
||||
|
||||
@@ -97,7 +97,7 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractRestIntegrationT
|
||||
@Description("Checks the correct behaviour of /rest/v1/softwaremoduletypes GET requests with sorting by MAXASSIGNMENTS field.")
|
||||
public void getSoftwareModuleTypesSortedByMaxAssignments() throws Exception {
|
||||
SoftwareModuleType testType = softwareManagement
|
||||
.createSoftwareModuleType(new SoftwareModuleType("test123", "TestName123", "Desc123", 5));
|
||||
.createSoftwareModuleType(softwareManagement.generateSoftwareModuleType("test123", "TestName123", "Desc123", 5));
|
||||
testType.setDescription("Desc1234");
|
||||
testType = softwareManagement.updateSoftwareModuleType(testType);
|
||||
|
||||
@@ -138,9 +138,9 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractRestIntegrationT
|
||||
public void createSoftwareModuleTypes() throws JSONException, Exception {
|
||||
|
||||
final List<SoftwareModuleType> types = new ArrayList<>();
|
||||
types.add(new SoftwareModuleType("test1", "TestName1", "Desc1", 1));
|
||||
types.add(new SoftwareModuleType("test2", "TestName2", "Desc2", 2));
|
||||
types.add(new SoftwareModuleType("test3", "TestName3", "Desc3", 3));
|
||||
types.add(softwareManagement.generateSoftwareModuleType("test1", "TestName1", "Desc1", 1));
|
||||
types.add(softwareManagement.generateSoftwareModuleType("test2", "TestName2", "Desc2", 2));
|
||||
types.add(softwareManagement.generateSoftwareModuleType("test3", "TestName3", "Desc3", 3));
|
||||
|
||||
final MvcResult mvcResult = mvc
|
||||
.perform(post("/rest/v1/softwaremoduletypes/").content(JsonBuilder.softwareModuleTypes(types))
|
||||
@@ -183,7 +183,7 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractRestIntegrationT
|
||||
@Description("Checks the correct behaviour of /rest/v1/softwaremoduletypes/{ID} GET requests.")
|
||||
public void getSoftwareModuleType() throws Exception {
|
||||
SoftwareModuleType testType = softwareManagement
|
||||
.createSoftwareModuleType(new SoftwareModuleType("test123", "TestName123", "Desc123", 5));
|
||||
.createSoftwareModuleType(softwareManagement.generateSoftwareModuleType("test123", "TestName123", "Desc123", 5));
|
||||
testType.setDescription("Desc1234");
|
||||
testType = softwareManagement.updateSoftwareModuleType(testType);
|
||||
|
||||
@@ -204,7 +204,7 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractRestIntegrationT
|
||||
@Description("Checks the correct behaviour of /rest/v1/softwaremoduletypes/{ID} DELETE requests (hard delete scenario).")
|
||||
public void deleteSoftwareModuleTypeUnused() throws Exception {
|
||||
final SoftwareModuleType testType = softwareManagement
|
||||
.createSoftwareModuleType(new SoftwareModuleType("test123", "TestName123", "Desc123", 5));
|
||||
.createSoftwareModuleType(softwareManagement.generateSoftwareModuleType("test123", "TestName123", "Desc123", 5));
|
||||
|
||||
assertThat(softwareManagement.countSoftwareModuleTypesAll()).isEqualTo(4);
|
||||
|
||||
@@ -219,9 +219,9 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractRestIntegrationT
|
||||
@Description("Checks the correct behaviour of /rest/v1/softwaremoduletypes/{ID} DELETE requests (soft delete scenario).")
|
||||
public void deleteSoftwareModuleTypeUsed() throws Exception {
|
||||
final SoftwareModuleType testType = softwareManagement
|
||||
.createSoftwareModuleType(new SoftwareModuleType("test123", "TestName123", "Desc123", 5));
|
||||
softwareManagement
|
||||
.createSoftwareModule(new SoftwareModule(testType, "name", "version", "description", "vendor"));
|
||||
.createSoftwareModuleType(softwareManagement.generateSoftwareModuleType("test123", "TestName123", "Desc123", 5));
|
||||
softwareManagement.createSoftwareModule(
|
||||
softwareManagement.generateSoftwareModule(testType, "name", "version", "description", "vendor"));
|
||||
|
||||
assertThat(softwareManagement.countSoftwareModuleTypesAll()).isEqualTo(4);
|
||||
assertThat(softwareModuleTypeRepository.count()).isEqualTo(4);
|
||||
@@ -237,7 +237,7 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractRestIntegrationT
|
||||
@Description("Checks the correct behaviour of /rest/v1/softwaremoduletypes/{ID} PUT requests.")
|
||||
public void updateSoftwareModuleTypeOnlyDescriptionAndNameUntouched() throws Exception {
|
||||
final SoftwareModuleType testType = softwareManagement
|
||||
.createSoftwareModuleType(new SoftwareModuleType("test123", "TestName123", "Desc123", 5));
|
||||
.createSoftwareModuleType(softwareManagement.generateSoftwareModuleType("test123", "TestName123", "Desc123", 5));
|
||||
|
||||
final String body = new JSONObject().put("id", testType.getId()).put("description", "foobardesc")
|
||||
.put("name", "nameShouldNotBeChanged").toString();
|
||||
@@ -293,7 +293,7 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractRestIntegrationT
|
||||
@Description("Ensures that the server is behaving as expected on invalid requests (wrong media type, wrong ID etc.).")
|
||||
public void invalidRequestsOnSoftwaremoduleTypesResource() throws Exception {
|
||||
final SoftwareModuleType testType = softwareManagement
|
||||
.createSoftwareModuleType(new SoftwareModuleType("test123", "TestName123", "Desc123", 5));
|
||||
.createSoftwareModuleType(softwareManagement.generateSoftwareModuleType("test123", "TestName123", "Desc123", 5));
|
||||
|
||||
final List<SoftwareModuleType> types = new ArrayList<>();
|
||||
types.add(testType);
|
||||
@@ -332,9 +332,9 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractRestIntegrationT
|
||||
@Description("Search erquest of software module types.")
|
||||
public void searchSoftwareModuleTypeRsql() throws Exception {
|
||||
final SoftwareModuleType testType = softwareManagement
|
||||
.createSoftwareModuleType(new SoftwareModuleType("test123", "TestName123", "Desc123", 5));
|
||||
.createSoftwareModuleType(softwareManagement.generateSoftwareModuleType("test123", "TestName123", "Desc123", 5));
|
||||
final SoftwareModuleType testType2 = softwareManagement
|
||||
.createSoftwareModuleType(new SoftwareModuleType("test1234", "TestName1234", "Desc123", 5));
|
||||
.createSoftwareModuleType(softwareManagement.generateSoftwareModuleType("test1234", "TestName1234", "Desc123", 5));
|
||||
|
||||
final String rsqlFindLikeDs1OrDs2 = "name==TestName123,name==TestName1234";
|
||||
|
||||
@@ -349,7 +349,7 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractRestIntegrationT
|
||||
char character = 'a';
|
||||
for (int index = 0; index < amount; index++) {
|
||||
final String str = String.valueOf(character);
|
||||
final SoftwareModule softwareModule = new SoftwareModule(osType, str, str, str, str);
|
||||
final SoftwareModule softwareModule = softwareManagement.generateSoftwareModule(osType, str, str, str, str);
|
||||
|
||||
softwareManagement.createSoftwareModule(softwareModule);
|
||||
character++;
|
||||
|
||||
@@ -37,6 +37,9 @@ import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
|
||||
import org.eclipse.hawkbit.repository.ActionFields;
|
||||
import org.eclipse.hawkbit.repository.ActionStatusFields;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSet;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaTarget;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaTargetInfo;
|
||||
import org.eclipse.hawkbit.repository.model.Action;
|
||||
import org.eclipse.hawkbit.repository.model.Action.ActionType;
|
||||
import org.eclipse.hawkbit.repository.model.Action.Status;
|
||||
@@ -44,7 +47,6 @@ import org.eclipse.hawkbit.repository.model.ActionStatus;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.repository.model.TargetInfo;
|
||||
import org.eclipse.hawkbit.rest.AbstractRestIntegrationTest;
|
||||
import org.eclipse.hawkbit.rest.exception.MessageNotReadableException;
|
||||
import org.eclipse.hawkbit.rest.json.model.ExceptionInfo;
|
||||
@@ -56,7 +58,6 @@ import org.json.JSONObject;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Slice;
|
||||
import org.springframework.data.domain.Sort.Direction;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -110,9 +111,8 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
final String knownTargetId = "targetId";
|
||||
final List<Action> actions = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId);
|
||||
actions.get(0).setStatus(Status.FINISHED);
|
||||
controllerManagament.addUpdateActionStatus(
|
||||
new ActionStatus(actions.get(0), Status.FINISHED, System.currentTimeMillis(), "testmessage"),
|
||||
actions.get(0));
|
||||
controllerManagament.addUpdateActionStatus(controllerManagament.generateActionStatus(actions.get(0),
|
||||
Status.FINISHED, System.currentTimeMillis(), "testmessage"));
|
||||
|
||||
final PageRequest pageRequest = new PageRequest(0, 1000, Direction.ASC, ActionFields.ID.getFieldName());
|
||||
final ActionStatus status = deploymentManagement
|
||||
@@ -141,7 +141,7 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
public void securityTokenIsNotInResponseIfMissingPermission() throws Exception {
|
||||
|
||||
final String knownControllerId = "knownControllerId";
|
||||
targetManagement.createTarget(new Target(knownControllerId));
|
||||
targetManagement.createTarget(targetManagement.generateTarget(knownControllerId));
|
||||
mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}", knownControllerId))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("securityToken").doesNotExist());
|
||||
@@ -154,7 +154,7 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
public void securityTokenIsInResponseWithCorrectPermission() throws Exception {
|
||||
|
||||
final String knownControllerId = "knownControllerId";
|
||||
final Target createTarget = targetManagement.createTarget(new Target(knownControllerId));
|
||||
final Target createTarget = targetManagement.createTarget(targetManagement.generateTarget(knownControllerId));
|
||||
mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}", knownControllerId))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("securityToken", equalTo(createTarget.getSecurityToken())));
|
||||
@@ -185,8 +185,8 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
}
|
||||
|
||||
private void createTarget(final String controllerId) {
|
||||
final Target target = new Target(controllerId);
|
||||
final TargetInfo targetInfo = new TargetInfo(target);
|
||||
final JpaTarget target = (JpaTarget) targetManagement.generateTarget(controllerId);
|
||||
final JpaTargetInfo targetInfo = new JpaTargetInfo(target);
|
||||
targetInfo.setAddress(IpUtil.createHttpUri("127.0.0.1").toString());
|
||||
target.setTargetInfo(targetInfo);
|
||||
targetManagement.createTarget(target);
|
||||
@@ -199,7 +199,7 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
// prepare test
|
||||
final DistributionSet dsA = TestDataUtil.generateDistributionSet("", softwareManagement,
|
||||
distributionSetManagement);
|
||||
final Target createTarget = targetManagement.createTarget(new Target("knownTargetId"));
|
||||
final Target createTarget = targetManagement.createTarget(targetManagement.generateTarget("knownTargetId"));
|
||||
|
||||
deploymentManagement.assignDistributionSet(dsA, Lists.newArrayList(createTarget));
|
||||
|
||||
@@ -306,7 +306,7 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
@Description("Ensures that deletion is executed if permitted.")
|
||||
public void deleteTargetReturnsOK() throws Exception {
|
||||
final String knownControllerId = "knownControllerIdDelete";
|
||||
targetManagement.createTarget(new Target(knownControllerId));
|
||||
targetManagement.createTarget(targetManagement.generateTarget(knownControllerId));
|
||||
|
||||
mvc.perform(delete(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId))
|
||||
.andExpect(status().isOk());
|
||||
@@ -342,7 +342,7 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
final String body = new JSONObject().put("description", knownNewDescription).toString();
|
||||
|
||||
// prepare
|
||||
final Target t = new Target(knownControllerId);
|
||||
final Target t = targetManagement.generateTarget(knownControllerId);
|
||||
t.setDescription("old description");
|
||||
t.setName(knownNameNotModiy);
|
||||
targetManagement.createTarget(t);
|
||||
@@ -599,9 +599,10 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
final DistributionSet ds = TestDataUtil.generateDistributionSet("", softwareManagement,
|
||||
distributionSetManagement);
|
||||
// assign ds to target
|
||||
deploymentManagement.assignDistributionSet(ds.getId(), knownControllerId);
|
||||
final Long actionId = deploymentManagement.assignDistributionSet(ds.getId(), knownControllerId).getActions()
|
||||
.get(0);
|
||||
// give feedback, so installedDS is in SNYC
|
||||
feedbackToByInSync(knownControllerId, ds);
|
||||
feedbackToByInSync(actionId);
|
||||
// test
|
||||
|
||||
final SoftwareModule os = ds.findFirstModuleByType(osType);
|
||||
@@ -683,13 +684,13 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
|
||||
@Test
|
||||
public void createTargetsListReturnsSuccessful() throws Exception {
|
||||
final Target test1 = new Target("id1");
|
||||
final Target test1 = targetManagement.generateTarget("id1");
|
||||
test1.setDescription("testid1");
|
||||
test1.setName("testname1");
|
||||
final Target test2 = new Target("id2");
|
||||
final Target test2 = targetManagement.generateTarget("id2");
|
||||
test2.setDescription("testid2");
|
||||
test2.setName("testname2");
|
||||
final Target test3 = new Target("id3");
|
||||
final Target test3 = targetManagement.generateTarget("id3");
|
||||
test3.setName("testname3");
|
||||
test3.setDescription("testid3");
|
||||
|
||||
@@ -812,7 +813,7 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
@Test
|
||||
public void getActionWithEmptyResult() throws Exception {
|
||||
final String knownTargetId = "targetId";
|
||||
final Target target = new Target(knownTargetId);
|
||||
final Target target = targetManagement.generateTarget(knownTargetId);
|
||||
targetManagement.createTarget(target);
|
||||
|
||||
mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/"
|
||||
@@ -1027,12 +1028,12 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
|
||||
final PageRequest pageRequest = new PageRequest(0, 100, Direction.ASC, ActionStatusFields.ID.getFieldName());
|
||||
|
||||
Target target = new Target(knownTargetId);
|
||||
Target target = targetManagement.generateTarget(knownTargetId);
|
||||
target = targetManagement.createTarget(target);
|
||||
final List<Target> targets = new ArrayList<>();
|
||||
targets.add(target);
|
||||
|
||||
final Iterator<DistributionSet> sets = TestDataUtil
|
||||
final Iterator<JpaDistributionSet> sets = TestDataUtil
|
||||
.generateDistributionSets(2, softwareManagement, distributionSetManagement).iterator();
|
||||
final DistributionSet one = sets.next();
|
||||
final DistributionSet two = sets.next();
|
||||
@@ -1045,8 +1046,8 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
Thread.sleep(10);
|
||||
deploymentManagement.assignDistributionSet(two, updatedTargets);
|
||||
|
||||
// two updates, one cancelation
|
||||
final List<Action> actions = actionRepository.findAll(pageRequest).getContent();
|
||||
// two updates, one cancellation
|
||||
final List<Action> actions = deploymentManagement.findActionsByTarget(target);
|
||||
|
||||
assertThat(actions).hasSize(2);
|
||||
return actions;
|
||||
@@ -1073,7 +1074,7 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
@Test
|
||||
public void assignDistributionSetToTarget() throws Exception {
|
||||
|
||||
final Target target = targetManagement.createTarget(new Target("fsdfsd"));
|
||||
final Target target = targetManagement.createTarget(targetManagement.generateTarget("fsdfsd"));
|
||||
final DistributionSet set = TestDataUtil.generateDistributionSet("one", softwareManagement,
|
||||
distributionSetManagement);
|
||||
|
||||
@@ -1087,7 +1088,7 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
@Test
|
||||
public void assignDistributionSetToTargetWithActionTimeForcedAndTime() throws Exception {
|
||||
|
||||
final Target target = targetManagement.createTarget(new Target("fsdfsd"));
|
||||
final Target target = targetManagement.createTarget(targetManagement.generateTarget("fsdfsd"));
|
||||
final DistributionSet set = TestDataUtil.generateDistributionSet("one", softwareManagement,
|
||||
distributionSetManagement);
|
||||
|
||||
@@ -1116,7 +1117,7 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
.content("{\"id\":" + set.getId() + "}").contentType(MediaType.APPLICATION_JSON))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound());
|
||||
|
||||
targetManagement.createTarget(new Target("fsdfsd"));
|
||||
targetManagement.createTarget(targetManagement.generateTarget("fsdfsd"));
|
||||
|
||||
mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/fsdfsd/assignedDS")
|
||||
.content("{\"id\":" + set.getId() + "}").contentType(MediaType.APPLICATION_JSON))
|
||||
@@ -1206,7 +1207,7 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
final Map<String, String> knownControllerAttrs = new HashMap<>();
|
||||
knownControllerAttrs.put("a", "1");
|
||||
knownControllerAttrs.put("b", "2");
|
||||
final Target target = new Target(knownTargetId);
|
||||
final Target target = targetManagement.generateTarget(knownTargetId);
|
||||
targetManagement.createTarget(target);
|
||||
controllerManagament.updateControllerAttributes(knownTargetId, knownControllerAttrs);
|
||||
|
||||
@@ -1220,7 +1221,7 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
public void getControllerEmptyAttributesReturnsNoContent() throws Exception {
|
||||
// create target with attributes
|
||||
final String knownTargetId = "targetIdWithAttributes";
|
||||
final Target target = new Target(knownTargetId);
|
||||
final Target target = targetManagement.generateTarget(knownTargetId);
|
||||
targetManagement.createTarget(target);
|
||||
|
||||
// test query target over rest resource
|
||||
@@ -1254,7 +1255,7 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
}
|
||||
|
||||
private void createSingleTarget(final String controllerId, final String name) {
|
||||
final Target target = new Target(controllerId);
|
||||
final Target target = targetManagement.generateTarget(controllerId);
|
||||
target.setName(name);
|
||||
target.setDescription(TARGET_DESCRIPTION_TEST);
|
||||
targetManagement.createTarget(target);
|
||||
@@ -1271,7 +1272,7 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
char character = 'a';
|
||||
for (int index = 0; index < amount; index++) {
|
||||
final String str = String.valueOf(character);
|
||||
final Target target = new Target(str);
|
||||
final Target target = targetManagement.generateTarget(str);
|
||||
target.setName(str);
|
||||
target.setDescription(str);
|
||||
final Target savedTarget = targetManagement.createTarget(target);
|
||||
@@ -1283,20 +1284,12 @@ public class MgmtTargetResourceTest extends AbstractRestIntegrationTest {
|
||||
/**
|
||||
* helper method to give feedback mark an target IN_SNCY
|
||||
*
|
||||
* @param controllerId
|
||||
* the controller id to give feedback to
|
||||
* @param savedSet
|
||||
* the distribution set
|
||||
* @throws Exception
|
||||
* @throws JSONException
|
||||
*/
|
||||
private void feedbackToByInSync(final String controllerId, final DistributionSet savedSet)
|
||||
throws Exception, JSONException {
|
||||
final Pageable pageReq = new PageRequest(0, 100);
|
||||
final Action action = actionRepository.findByDistributionSet(pageReq, savedSet).getContent().get(0);
|
||||
private void feedbackToByInSync(final Long actionId) {
|
||||
final Action action = deploymentManagement.findAction(actionId);
|
||||
|
||||
final ActionStatus actionStatus = new ActionStatus(action, Status.FINISHED, 0l);
|
||||
controllerManagement.addUpdateActionStatus(actionStatus, action);
|
||||
final ActionStatus actionStatus = controllerManagement.generateActionStatus(action, Status.FINISHED, 0L);
|
||||
controllerManagement.addUpdateActionStatus(actionStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -49,7 +49,7 @@ public class SMRessourceMisingMongoDbConnectionTest extends AbstractIntegrationT
|
||||
|
||||
assertThat(softwareManagement.findSoftwareModulesAll(pageReq)).hasSize(0);
|
||||
assertThat(artifactRepository.findAll()).hasSize(0);
|
||||
SoftwareModule sm = new SoftwareModule(softwareManagement.findSoftwareModuleTypeByKey("os"), "name 1",
|
||||
SoftwareModule sm = softwareManagement.generateSoftwareModule(softwareManagement.findSoftwareModuleTypeByKey("os"), "name 1",
|
||||
"version 1", null, null);
|
||||
sm = softwareManagement.createSoftwareModule(sm);
|
||||
assertThat(artifactRepository.findAll()).hasSize(0);
|
||||
|
||||
@@ -171,8 +171,8 @@ public interface DeploymentManagement {
|
||||
/**
|
||||
* counts all actions associated to a specific target.
|
||||
*
|
||||
* @param spec
|
||||
* the specification to filter the count result
|
||||
* @param rsqlParam
|
||||
* rsql query string
|
||||
* @param target
|
||||
* the target associated to the actions to count
|
||||
* @return the count value of found actions associated to the target
|
||||
@@ -271,8 +271,8 @@ public interface DeploymentManagement {
|
||||
* Retrieves all {@link Action}s assigned to a specific {@link Target} and a
|
||||
* given specification.
|
||||
*
|
||||
* @param specifiction
|
||||
* the specification to narrow down the search
|
||||
* @param rsqlParam
|
||||
* rsql query string
|
||||
* @param target
|
||||
* the target which must be assigned to the actions
|
||||
* @param pageable
|
||||
@@ -280,7 +280,6 @@ public interface DeploymentManagement {
|
||||
* @return a slice of actions assigned to the specific target and the
|
||||
* specification
|
||||
*/
|
||||
// TODO fix this
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Slice<Action> findActionsByTarget(@NotNull String rsqlParam, @NotNull Target target, @NotNull Pageable pageable);
|
||||
|
||||
|
||||
@@ -59,10 +59,9 @@ public class DistributionSetAssignmentResult extends AssignmentResult<Target> {
|
||||
return actions;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public List<Target> getAssignedEntity() {
|
||||
return (List<Target>) targetManagement.findTargetByControllerID(assignedTargets);
|
||||
return targetManagement.findTargetByControllerID(assignedTargets);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -86,6 +86,9 @@ public interface DistributionSetManagement {
|
||||
/**
|
||||
* Count all {@link DistributionSet}s in the repository that are not marked
|
||||
* as deleted.
|
||||
*
|
||||
* @param type
|
||||
* to look for
|
||||
*
|
||||
* @return number of {@link DistributionSet}s
|
||||
*/
|
||||
@@ -289,8 +292,8 @@ public interface DistributionSetManagement {
|
||||
*
|
||||
* @param distributionSetId
|
||||
* the distribution set id to retrieve the meta data from
|
||||
* @param spec
|
||||
* the specification to filter the result
|
||||
* @param rsqlParam
|
||||
* rsql query string
|
||||
* @param pageable
|
||||
* the page request to page the result
|
||||
* @return a paged result of all meta data entries for a given distribution
|
||||
@@ -343,8 +346,8 @@ public interface DistributionSetManagement {
|
||||
/**
|
||||
* finds all {@link DistributionSet}s.
|
||||
*
|
||||
* @param spec
|
||||
* the specification to add for the search query.
|
||||
* @param rsqlParam
|
||||
* rsql query string
|
||||
* @param pageReq
|
||||
* the pagination parameter
|
||||
* @param deleted
|
||||
@@ -432,8 +435,8 @@ public interface DistributionSetManagement {
|
||||
/**
|
||||
* Generic predicate based query for {@link DistributionSetType}.
|
||||
*
|
||||
* @param spec
|
||||
* of the search
|
||||
* @param rsqlParam
|
||||
* rsql query string
|
||||
* @param pageable
|
||||
* parameter for paging
|
||||
*
|
||||
|
||||
@@ -130,8 +130,8 @@ public interface TagManagement {
|
||||
/**
|
||||
* Retrieves all DistributionSet tags based on the given specification.
|
||||
*
|
||||
* @param spec
|
||||
* the specification for the query
|
||||
* @param rsqlParam
|
||||
* rsql query string
|
||||
* @param pageable
|
||||
* pagination parameter
|
||||
* @return the found {@link DistributionSetTag}s, never {@code null}
|
||||
@@ -159,8 +159,8 @@ public interface TagManagement {
|
||||
/**
|
||||
* Retrieves all target tags based on the given specification.
|
||||
*
|
||||
* @param spec
|
||||
* the specification for the query
|
||||
* @param rsqlParam
|
||||
* rsql query string
|
||||
* @param pageable
|
||||
* pagination parameter
|
||||
* @return the found {@link Target}s, never {@code null}
|
||||
@@ -245,12 +245,48 @@ public interface TagManagement {
|
||||
*/
|
||||
DistributionSetTag generateDistributionSetTag();
|
||||
|
||||
/**
|
||||
* Generates a {@link TargetTag} without persisting it.
|
||||
*
|
||||
* @param name
|
||||
* of the tag
|
||||
* @param description
|
||||
* of the tag
|
||||
* @param colour
|
||||
* of the tag
|
||||
* @return {@link TargetTag} object
|
||||
*/
|
||||
TargetTag generateTargetTag(String name, String description, String colour);
|
||||
|
||||
/**
|
||||
* Generates a {@link TargetTag} without persisting it.
|
||||
*
|
||||
* @param name
|
||||
* of the tag
|
||||
* @return {@link TargetTag} object
|
||||
*/
|
||||
TargetTag generateTargetTag(String name);
|
||||
|
||||
/**
|
||||
* Generates a {@link DistributionSetTag} without persisting it.
|
||||
*
|
||||
* @param name
|
||||
* of the tag
|
||||
* @param description
|
||||
* of the tag
|
||||
* @param colour
|
||||
* of the tag
|
||||
* @return {@link DistributionSetTag} object
|
||||
*/
|
||||
DistributionSetTag generateDistributionSetTag(String name, String description, String colour);
|
||||
|
||||
/**
|
||||
* Generates a {@link DistributionSetTag} without persisting it.
|
||||
*
|
||||
* @param name
|
||||
* of the tag
|
||||
* @return {@link DistributionSetTag} object
|
||||
*/
|
||||
DistributionSetTag generateDistributionSetTag(String name);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -395,7 +395,7 @@ public class JpaControllerManagement implements ControllerManagement {
|
||||
// retrieves after the other we don't want to store to protect to
|
||||
// overflood action status in
|
||||
// case controller retrieves a action multiple times.
|
||||
if (resultList.isEmpty() || resultList.get(0)[1] != Status.RETRIEVED) {
|
||||
if (resultList.isEmpty() || !Status.RETRIEVED.equals(resultList.get(0)[1])) {
|
||||
// document that the status has been retrieved
|
||||
actionStatusRepository
|
||||
.save(new JpaActionStatus(action, Status.RETRIEVED, System.currentTimeMillis(), message));
|
||||
|
||||
@@ -81,7 +81,7 @@ public class JpaTenantConfigurationManagement implements EnvironmentAware, Tenan
|
||||
final TenantConfigurationKey configurationKey, final Class<T> propertyType,
|
||||
final TenantConfiguration tenantConfiguration) {
|
||||
if (tenantConfiguration != null) {
|
||||
return TenantConfigurationValue.<T> builder().isGlobal(false).createdBy(tenantConfiguration.getCreatedBy())
|
||||
return TenantConfigurationValue.<T> builder().global(false).createdBy(tenantConfiguration.getCreatedBy())
|
||||
.createdAt(tenantConfiguration.getCreatedAt())
|
||||
.lastModifiedAt(tenantConfiguration.getLastModifiedAt())
|
||||
.lastModifiedBy(tenantConfiguration.getLastModifiedBy())
|
||||
@@ -89,7 +89,7 @@ public class JpaTenantConfigurationManagement implements EnvironmentAware, Tenan
|
||||
|
||||
} else if (configurationKey.getDefaultKeyName() != null) {
|
||||
|
||||
return TenantConfigurationValue.<T> builder().isGlobal(true).createdBy(null).createdAt(null)
|
||||
return TenantConfigurationValue.<T> builder().global(true).createdBy(null).createdAt(null)
|
||||
.lastModifiedAt(null).lastModifiedBy(null)
|
||||
.value(getGlobalConfigurationValue(configurationKey, propertyType)).build();
|
||||
}
|
||||
@@ -149,8 +149,7 @@ public class JpaTenantConfigurationManagement implements EnvironmentAware, Tenan
|
||||
|
||||
final Class<T> clazzT = (Class<T>) value.getClass();
|
||||
|
||||
return TenantConfigurationValue.<T> builder().isGlobal(false)
|
||||
.createdBy(updatedTenantConfiguration.getCreatedBy())
|
||||
return TenantConfigurationValue.<T> builder().global(false).createdBy(updatedTenantConfiguration.getCreatedBy())
|
||||
.createdAt(updatedTenantConfiguration.getCreatedAt())
|
||||
.lastModifiedAt(updatedTenantConfiguration.getLastModifiedAt())
|
||||
.lastModifiedBy(updatedTenantConfiguration.getLastModifiedBy())
|
||||
|
||||
@@ -59,8 +59,11 @@ public class JpaDistributionSetTag extends AbstractJpaTag implements Distributio
|
||||
super(name, description, colour);
|
||||
}
|
||||
|
||||
/**
|
||||
* Default constructor for JPA.
|
||||
*/
|
||||
public JpaDistributionSetTag() {
|
||||
super();
|
||||
// Default constructor for JPA.
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -158,7 +158,6 @@ public class JpaRollout extends AbstractJpaNamedEntity implements Rollout {
|
||||
this.totalTargets = totalTargets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRolloutGroupsTotal() {
|
||||
return rolloutGroupsTotal;
|
||||
}
|
||||
|
||||
@@ -32,10 +32,6 @@ public class JpaSoftwareModuleType extends AbstractJpaNamedEntity implements Sof
|
||||
@Column(name = "type_key", nullable = false, length = 64)
|
||||
private String key;
|
||||
|
||||
public void setMaxAssignments(final int maxAssignments) {
|
||||
this.maxAssignments = maxAssignments;
|
||||
}
|
||||
|
||||
@Column(name = "max_ds_assignments", nullable = false)
|
||||
private int maxAssignments;
|
||||
|
||||
@@ -87,10 +83,15 @@ public class JpaSoftwareModuleType extends AbstractJpaNamedEntity implements Sof
|
||||
}
|
||||
|
||||
/**
|
||||
* Default Constructor.
|
||||
* Default Constructor for JPA.
|
||||
*/
|
||||
public JpaSoftwareModuleType() {
|
||||
super();
|
||||
// Default Constructor for JPA.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxAssignments(final int maxAssignments) {
|
||||
this.maxAssignments = maxAssignments;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -108,7 +109,6 @@ public class JpaSoftwareModuleType extends AbstractJpaNamedEntity implements Sof
|
||||
return deleted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDeleted(final boolean deleted) {
|
||||
this.deleted = deleted;
|
||||
}
|
||||
|
||||
@@ -37,6 +37,14 @@ public class JpaTargetFilterQuery extends AbstractJpaTenantAwareBaseEntity imple
|
||||
// Default constructor for JPA.
|
||||
}
|
||||
|
||||
/**
|
||||
* Public constructor.
|
||||
*
|
||||
* @param name
|
||||
* of the {@link TargetFilterQuery}.
|
||||
* @param query
|
||||
* of the {@link TargetFilterQuery}.
|
||||
*/
|
||||
public JpaTargetFilterQuery(final String name, final String query) {
|
||||
this.name = name;
|
||||
this.query = query;
|
||||
|
||||
@@ -60,7 +60,7 @@ public class JpaTargetTag extends AbstractJpaTag implements TargetTag {
|
||||
}
|
||||
|
||||
public JpaTargetTag() {
|
||||
super();
|
||||
// Default constructor for JPA.
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,11 +18,19 @@ import org.springframework.data.jpa.domain.Specification;
|
||||
* Spring Data JPQL Specifications.
|
||||
*
|
||||
*/
|
||||
public class TargetFilterQuerySpecification {
|
||||
public final class TargetFilterQuerySpecification {
|
||||
private TargetFilterQuerySpecification() {
|
||||
// utility class
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link Specification} for retrieving {@link JpaTargetFilterQuery}s based
|
||||
* on is {@link JpaTargetFilterQuery#getName()}.
|
||||
*
|
||||
* @param searchText
|
||||
* of the filter
|
||||
* @return the {@link JpaTargetFilterQuery} {@link Specification}
|
||||
*/
|
||||
public static Specification<JpaTargetFilterQuery> likeName(final String searchText) {
|
||||
return (targetFilterQueryRoot, query, cb) -> {
|
||||
final String searchTextToLower = searchText.toLowerCase();
|
||||
|
||||
@@ -189,12 +189,12 @@ public interface Action extends TenantAwareBaseEntity {
|
||||
CANCELING,
|
||||
|
||||
/**
|
||||
* Action has been presented to the target.
|
||||
* Action has been send to the target.
|
||||
*/
|
||||
RETRIEVED,
|
||||
|
||||
/**
|
||||
* Action needs download by this target which has now started.
|
||||
* Action requests download by this target which has now started.
|
||||
*/
|
||||
DOWNLOAD,
|
||||
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.model;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* The poll time object which holds all the necessary information around the
|
||||
* target poll time, e.g. the last poll time, the next poll time and the overdue
|
||||
* poll time.
|
||||
*
|
||||
*/
|
||||
public class PollStatus {
|
||||
private final LocalDateTime lastPollDate;
|
||||
private final LocalDateTime nextPollDate;
|
||||
private final LocalDateTime overdueDate;
|
||||
private final LocalDateTime currentDate;
|
||||
|
||||
public PollStatus(final LocalDateTime lastPollDate, final LocalDateTime nextPollDate,
|
||||
final LocalDateTime overdueDate, final LocalDateTime currentDate) {
|
||||
this.lastPollDate = lastPollDate;
|
||||
this.nextPollDate = nextPollDate;
|
||||
this.overdueDate = overdueDate;
|
||||
this.currentDate = currentDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* calculates if the target poll time is overdue and the target has not been
|
||||
* polled in the configured poll time interval.
|
||||
*
|
||||
* @return {@code true} if the current time is after the poll time overdue
|
||||
* date otherwise {@code false}.
|
||||
*/
|
||||
public boolean isOverdue() {
|
||||
return currentDate.isAfter(overdueDate);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the lastPollDate
|
||||
*/
|
||||
public LocalDateTime getLastPollDate() {
|
||||
return lastPollDate;
|
||||
}
|
||||
|
||||
public LocalDateTime getNextPollDate() {
|
||||
return nextPollDate;
|
||||
}
|
||||
|
||||
public LocalDateTime getOverdueDate() {
|
||||
return overdueDate;
|
||||
}
|
||||
|
||||
public LocalDateTime getCurrentDate() {
|
||||
return currentDate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PollTime [lastPollDate=" + lastPollDate + ", nextPollDate=" + nextPollDate + ", overdueDate="
|
||||
+ overdueDate + ", currentDate=" + currentDate + "]";
|
||||
}
|
||||
}
|
||||
@@ -9,8 +9,10 @@
|
||||
package org.eclipse.hawkbit.repository.model;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.Action.ActionType;
|
||||
import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus.Status;
|
||||
|
||||
/**
|
||||
* Software update operations in large scale IoT scenarios with hundred of
|
||||
@@ -57,20 +59,46 @@ public interface Rollout extends NamedEntity {
|
||||
*/
|
||||
RolloutStatus getStatus();
|
||||
|
||||
/**
|
||||
* @return {@link ActionType} of the rollout.
|
||||
*/
|
||||
ActionType getActionType();
|
||||
|
||||
/**
|
||||
* @param actionType
|
||||
* of the rollout.
|
||||
*/
|
||||
void setActionType(ActionType actionType);
|
||||
|
||||
/**
|
||||
* @return time in {@link TimeUnit#MILLISECONDS} after which
|
||||
* {@link #isForced()} switches to <code>true</code> in case of
|
||||
* {@link ActionType#TIMEFORCED}.
|
||||
*/
|
||||
long getForcedTime();
|
||||
|
||||
/**
|
||||
* @param forcedTime
|
||||
* in {@link TimeUnit#MILLISECONDS} after which
|
||||
* {@link #isForced()} switches to <code>true</code> in case of
|
||||
* {@link ActionType#TIMEFORCED}.
|
||||
*/
|
||||
void setForcedTime(long forcedTime);
|
||||
|
||||
/**
|
||||
* @return number of {@link Target}s in this rollout.
|
||||
*/
|
||||
long getTotalTargets();
|
||||
|
||||
int getRolloutGroupsTotal();
|
||||
|
||||
/**
|
||||
* @return number of {@link RolloutGroup}s.
|
||||
*/
|
||||
int getRolloutGroupsCreated();
|
||||
|
||||
/**
|
||||
* @return all states with the respective target count in that
|
||||
* {@link Status}.
|
||||
*/
|
||||
TotalTargetCountStatus getTotalTargetCountStatus();
|
||||
|
||||
/**
|
||||
|
||||
@@ -182,4 +182,4 @@ public interface RolloutGroup extends NamedEntity {
|
||||
return beanName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.model;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupErrorAction;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupErrorCondition;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupSuccessAction;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupSuccessCondition;
|
||||
|
||||
/**
|
||||
* Builder to build easily the {@link RolloutGroupConditions}.
|
||||
*
|
||||
*/
|
||||
public class RolloutGroupConditionBuilder {
|
||||
private final RolloutGroupConditions conditions = new RolloutGroupConditions();
|
||||
|
||||
/**
|
||||
* @return completed {@link RolloutGroupConditions}.
|
||||
*/
|
||||
public RolloutGroupConditions build() {
|
||||
return conditions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the finish condition and expression on the builder.
|
||||
*
|
||||
* @param condition
|
||||
* the finish condition
|
||||
* @param expression
|
||||
* the finish expression
|
||||
* @return the builder itself
|
||||
*/
|
||||
public RolloutGroupConditionBuilder successCondition(final RolloutGroupSuccessCondition condition,
|
||||
final String expression) {
|
||||
conditions.setSuccessCondition(condition);
|
||||
conditions.setSuccessConditionExp(expression);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the success action and expression on the builder.
|
||||
*
|
||||
* @param action
|
||||
* the success action
|
||||
* @param expression
|
||||
* the error expression
|
||||
* @return the builder itself
|
||||
*/
|
||||
public RolloutGroupConditionBuilder successAction(final RolloutGroupSuccessAction action, final String expression) {
|
||||
conditions.setSuccessAction(action);
|
||||
conditions.setSuccessActionExp(expression);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the error condition and expression on the builder.
|
||||
*
|
||||
* @param condition
|
||||
* the error condition
|
||||
* @param expression
|
||||
* the error expression
|
||||
* @return the builder itself
|
||||
*/
|
||||
public RolloutGroupConditionBuilder errorCondition(final RolloutGroupErrorCondition condition,
|
||||
final String expression) {
|
||||
conditions.setErrorCondition(condition);
|
||||
conditions.setErrorConditionExp(expression);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the error action and expression on the builder.
|
||||
*
|
||||
* @param action
|
||||
* the error action
|
||||
* @param expression
|
||||
* the error expression
|
||||
* @return the builder itself
|
||||
*/
|
||||
public RolloutGroupConditionBuilder errorAction(final RolloutGroupErrorAction action, final String expression) {
|
||||
conditions.setErrorAction(action);
|
||||
conditions.setErrorActionExp(expression);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.model;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupErrorAction;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupErrorCondition;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupSuccessAction;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupSuccessCondition;
|
||||
|
||||
/**
|
||||
* Object which holds all {@link RolloutGroup} conditions together which can
|
||||
* easily built.
|
||||
*/
|
||||
public class RolloutGroupConditions {
|
||||
private RolloutGroupSuccessCondition successCondition;
|
||||
private String successConditionExp;
|
||||
private RolloutGroupSuccessAction successAction;
|
||||
private String successActionExp;
|
||||
private RolloutGroupErrorCondition errorCondition;
|
||||
private String errorConditionExp;
|
||||
private RolloutGroupErrorAction errorAction;
|
||||
private String errorActionExp;
|
||||
|
||||
public RolloutGroupSuccessCondition getSuccessCondition() {
|
||||
return successCondition;
|
||||
}
|
||||
|
||||
public void setSuccessCondition(final RolloutGroupSuccessCondition finishCondition) {
|
||||
successCondition = finishCondition;
|
||||
}
|
||||
|
||||
public String getSuccessConditionExp() {
|
||||
return successConditionExp;
|
||||
}
|
||||
|
||||
public void setSuccessConditionExp(final String finishConditionExp) {
|
||||
successConditionExp = finishConditionExp;
|
||||
}
|
||||
|
||||
public RolloutGroupSuccessAction getSuccessAction() {
|
||||
return successAction;
|
||||
}
|
||||
|
||||
public void setSuccessAction(final RolloutGroupSuccessAction successAction) {
|
||||
this.successAction = successAction;
|
||||
}
|
||||
|
||||
public String getSuccessActionExp() {
|
||||
return successActionExp;
|
||||
}
|
||||
|
||||
public void setSuccessActionExp(final String successActionExp) {
|
||||
this.successActionExp = successActionExp;
|
||||
}
|
||||
|
||||
public RolloutGroupErrorCondition getErrorCondition() {
|
||||
return errorCondition;
|
||||
}
|
||||
|
||||
public void setErrorCondition(final RolloutGroupErrorCondition errorCondition) {
|
||||
this.errorCondition = errorCondition;
|
||||
}
|
||||
|
||||
public String getErrorConditionExp() {
|
||||
return errorConditionExp;
|
||||
}
|
||||
|
||||
public void setErrorConditionExp(final String errorConditionExp) {
|
||||
this.errorConditionExp = errorConditionExp;
|
||||
}
|
||||
|
||||
public RolloutGroupErrorAction getErrorAction() {
|
||||
return errorAction;
|
||||
}
|
||||
|
||||
public void setErrorAction(final RolloutGroupErrorAction errorAction) {
|
||||
this.errorAction = errorAction;
|
||||
}
|
||||
|
||||
public String getErrorActionExp() {
|
||||
return errorActionExp;
|
||||
}
|
||||
|
||||
public void setErrorActionExp(final String errorActionExp) {
|
||||
this.errorActionExp = errorActionExp;
|
||||
}
|
||||
}
|
||||
@@ -8,22 +8,53 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.model;
|
||||
|
||||
/**
|
||||
* {@link SoftwareModuleType} is an abstract definition used in
|
||||
* {@link DistributionSetType}s and includes additional {@link SoftwareModule}
|
||||
* specific information.
|
||||
*
|
||||
*/
|
||||
public interface SoftwareModuleType extends NamedEntity {
|
||||
|
||||
/**
|
||||
* @return business key of this {@link SoftwareModuleType}.
|
||||
*/
|
||||
String getKey();
|
||||
|
||||
/**
|
||||
* @param key
|
||||
* of this {@link SoftwareModuleType}.
|
||||
*/
|
||||
void setKey(String key);
|
||||
|
||||
/**
|
||||
* @return maximum assignments of an {@link SoftwareModule} of this type to
|
||||
* a {@link DistributionSet}.
|
||||
*/
|
||||
int getMaxAssignments();
|
||||
|
||||
/**
|
||||
* @param maxAssignments
|
||||
* of an {@link SoftwareModule} of this type to a
|
||||
* {@link DistributionSet}.
|
||||
*/
|
||||
void setMaxAssignments(int maxAssignments);
|
||||
|
||||
/**
|
||||
* @return <code>true</code> if the type is deleted and only kept for
|
||||
* history purposes.
|
||||
*/
|
||||
boolean isDeleted();
|
||||
|
||||
void setDeleted(boolean deleted);
|
||||
|
||||
/**
|
||||
* @return get color code to by used in management UI views.
|
||||
*/
|
||||
String getColour();
|
||||
|
||||
void setColour(String colour);
|
||||
/**
|
||||
* @param colour
|
||||
* code to by used in management UI views.
|
||||
*/
|
||||
void setColour(final String colour);
|
||||
|
||||
}
|
||||
@@ -60,6 +60,8 @@ public class TargetIdName implements Serializable {
|
||||
}
|
||||
|
||||
@Override
|
||||
// Exception squid:S864 - generated code
|
||||
@SuppressWarnings("squid:S864")
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
|
||||
@@ -14,14 +14,14 @@ package org.eclipse.hawkbit.repository.model;
|
||||
* @param <T>
|
||||
* type of the configuration value
|
||||
*/
|
||||
public class TenantConfigurationValue<T> {
|
||||
public final class TenantConfigurationValue<T> {
|
||||
|
||||
private T value;
|
||||
private Long lastModifiedAt;
|
||||
private String lastModifiedBy;
|
||||
private Long createdAt;
|
||||
private String createdBy;
|
||||
private boolean isGlobal = true;
|
||||
private boolean global = true;
|
||||
|
||||
private TenantConfigurationValue() {
|
||||
}
|
||||
@@ -41,7 +41,7 @@ public class TenantConfigurationValue<T> {
|
||||
* @return true, if is global
|
||||
*/
|
||||
public boolean isGlobal() {
|
||||
return isGlobal;
|
||||
return global;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,13 +126,13 @@ public class TenantConfigurationValue<T> {
|
||||
/**
|
||||
* set the is global attribute.
|
||||
*
|
||||
* @param isGlobal
|
||||
* @param global
|
||||
* true when there is no tenant specific value, false
|
||||
* otherwise
|
||||
* @return the tenant configuration value builder
|
||||
*/
|
||||
public TenantConfigurationValueBuilder<T> isGlobal(final boolean isGlobal) {
|
||||
this.configuration.isGlobal = isGlobal;
|
||||
public TenantConfigurationValueBuilder<T> global(final boolean global) {
|
||||
this.configuration.global = global;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,8 @@ import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* Store all states with the target count of a rollout or rolloutgroup.
|
||||
* Store target count of a {@link Rollout} or {@link RolloutGroup} for every
|
||||
* {@link Status}.
|
||||
*
|
||||
*/
|
||||
public class TotalTargetCountStatus {
|
||||
@@ -24,7 +25,35 @@ public class TotalTargetCountStatus {
|
||||
* Status of the total target counts.
|
||||
*/
|
||||
public enum Status {
|
||||
SCHEDULED, RUNNING, ERROR, FINISHED, CANCELLED, NOTSTARTED
|
||||
/**
|
||||
* Action is scheduled.
|
||||
*/
|
||||
SCHEDULED,
|
||||
|
||||
/**
|
||||
* Action is still running.
|
||||
*/
|
||||
RUNNING,
|
||||
|
||||
/**
|
||||
* Action failed.
|
||||
*/
|
||||
ERROR,
|
||||
|
||||
/**
|
||||
* Action is completed.
|
||||
*/
|
||||
FINISHED,
|
||||
|
||||
/**
|
||||
* Action is canceled.
|
||||
*/
|
||||
CANCELLED,
|
||||
|
||||
/**
|
||||
* Action is not started yet.
|
||||
*/
|
||||
NOTSTARTED
|
||||
}
|
||||
|
||||
private final Map<Status, Long> statusTotalCountMap = new EnumMap<>(Status.class);
|
||||
@@ -35,7 +64,7 @@ public class TotalTargetCountStatus {
|
||||
*
|
||||
* @param targetCountActionStatus
|
||||
* the action state map
|
||||
* @param totalTargets
|
||||
* @param totalTargetCount
|
||||
* the total target count
|
||||
*/
|
||||
public TotalTargetCountStatus(final List<TotalTargetCountActionStatus> targetCountActionStatus,
|
||||
@@ -81,8 +110,7 @@ public class TotalTargetCountStatus {
|
||||
* @param statusTotalCountMap
|
||||
* the map
|
||||
* @param rolloutStatusCountItems
|
||||
* all target statut with total count
|
||||
* @return <true> some state is populated <false> nothing is happend
|
||||
* all target {@link Status} with total count
|
||||
*/
|
||||
private final void mapActionStatusToTotalTargetCountStatus(
|
||||
final List<TotalTargetCountActionStatus> targetCountActionStatus) {
|
||||
@@ -93,33 +121,40 @@ public class TotalTargetCountStatus {
|
||||
statusTotalCountMap.put(Status.RUNNING, 0L);
|
||||
Long notStartedTargetCount = totalTargetCount;
|
||||
for (final TotalTargetCountActionStatus item : targetCountActionStatus) {
|
||||
switch (item.getStatus()) {
|
||||
case SCHEDULED:
|
||||
statusTotalCountMap.put(Status.SCHEDULED, item.getCount());
|
||||
break;
|
||||
case ERROR:
|
||||
statusTotalCountMap.put(Status.ERROR, item.getCount());
|
||||
break;
|
||||
case FINISHED:
|
||||
statusTotalCountMap.put(Status.FINISHED, item.getCount());
|
||||
break;
|
||||
case RETRIEVED:
|
||||
case RUNNING:
|
||||
case WARNING:
|
||||
case DOWNLOAD:
|
||||
case CANCELING:
|
||||
final Long runningItemsCount = statusTotalCountMap.get(Status.RUNNING) + item.getCount();
|
||||
statusTotalCountMap.put(Status.RUNNING, runningItemsCount);
|
||||
break;
|
||||
case CANCELED:
|
||||
statusTotalCountMap.put(Status.CANCELLED, item.getCount());
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("State " + item.getStatus() + "is not valid");
|
||||
}
|
||||
convertStatus(item);
|
||||
notStartedTargetCount -= item.getCount();
|
||||
}
|
||||
statusTotalCountMap.put(TotalTargetCountStatus.Status.NOTSTARTED, notStartedTargetCount);
|
||||
}
|
||||
|
||||
// Exception squid:MethodCyclomaticComplexity - simple state conversion, not
|
||||
// really complex.
|
||||
@SuppressWarnings("squid:MethodCyclomaticComplexity")
|
||||
private void convertStatus(final TotalTargetCountActionStatus item) {
|
||||
switch (item.getStatus()) {
|
||||
case SCHEDULED:
|
||||
statusTotalCountMap.put(Status.SCHEDULED, item.getCount());
|
||||
break;
|
||||
case ERROR:
|
||||
statusTotalCountMap.put(Status.ERROR, item.getCount());
|
||||
break;
|
||||
case FINISHED:
|
||||
statusTotalCountMap.put(Status.FINISHED, item.getCount());
|
||||
break;
|
||||
case RETRIEVED:
|
||||
case RUNNING:
|
||||
case WARNING:
|
||||
case DOWNLOAD:
|
||||
case CANCELING:
|
||||
final Long runningItemsCount = statusTotalCountMap.get(Status.RUNNING) + item.getCount();
|
||||
statusTotalCountMap.put(Status.RUNNING, runningItemsCount);
|
||||
break;
|
||||
case CANCELED:
|
||||
statusTotalCountMap.put(Status.CANCELLED, item.getCount());
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("State " + item.getStatus() + "is not valid");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user