Split repository API for module and DS management. Refactor utility usage (#524)
* Split DS management and reduce util usage. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Split sw module and type management. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Sonar issues. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Make sonar listen to the exception! Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Register both beans. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Split JPA implementations. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Revert user details change. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Fix compilation errors. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Fix bean queries. Fix image path. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Document preferred utility usage. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Fix exmaples and revert unintended checkin. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Code cleanup. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Typos, readibility. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Remove unused reference. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Rollouts cache delete aware. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Fix rolloutgroup delete event. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Add new RolloutGroupDeletedEvent event Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
@@ -33,7 +33,7 @@ import org.eclipse.hawkbit.repository.ArtifactManagement;
|
||||
import org.eclipse.hawkbit.repository.ControllerManagement;
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.repository.RepositoryConstants;
|
||||
import org.eclipse.hawkbit.repository.SoftwareManagement;
|
||||
import org.eclipse.hawkbit.repository.SoftwareModuleManagement;
|
||||
import org.eclipse.hawkbit.repository.SystemManagement;
|
||||
import org.eclipse.hawkbit.repository.builder.ActionStatusCreate;
|
||||
import org.eclipse.hawkbit.repository.exception.ArtifactBinaryNotFoundException;
|
||||
@@ -82,7 +82,7 @@ public class DdiRootController implements DdiRootControllerRestApi {
|
||||
private ControllerManagement controllerManagement;
|
||||
|
||||
@Autowired
|
||||
private SoftwareManagement softwareManagement;
|
||||
private SoftwareModuleManagement softwareModuleManagement;
|
||||
|
||||
@Autowired
|
||||
private ArtifactManagement artifactManagement;
|
||||
@@ -114,7 +114,7 @@ public class DdiRootController implements DdiRootControllerRestApi {
|
||||
final Target target = controllerManagement.findByControllerId(controllerId)
|
||||
.orElseThrow(() -> new EntityNotFoundException(Target.class, controllerId));
|
||||
|
||||
final SoftwareModule softwareModule = softwareManagement.findSoftwareModuleById(softwareModuleId)
|
||||
final SoftwareModule softwareModule = softwareModuleManagement.findSoftwareModuleById(softwareModuleId)
|
||||
.orElseThrow(() -> new EntityNotFoundException(SoftwareModule.class, softwareModuleId));
|
||||
|
||||
return new ResponseEntity<>(
|
||||
@@ -144,7 +144,7 @@ public class DdiRootController implements DdiRootControllerRestApi {
|
||||
|
||||
final Target target = controllerManagement.findByControllerId(controllerId)
|
||||
.orElseThrow(() -> new EntityNotFoundException(Target.class, controllerId));
|
||||
final SoftwareModule module = softwareManagement.findSoftwareModuleById(softwareModuleId)
|
||||
final SoftwareModule module = softwareModuleManagement.findSoftwareModuleById(softwareModuleId)
|
||||
.orElseThrow(() -> new EntityNotFoundException(SoftwareModule.class, softwareModuleId));
|
||||
|
||||
if (checkModule(fileName, module)) {
|
||||
@@ -208,7 +208,7 @@ public class DdiRootController implements DdiRootControllerRestApi {
|
||||
controllerManagement.findByControllerId(controllerId)
|
||||
.orElseThrow(() -> new EntityNotFoundException(Target.class, controllerId));
|
||||
|
||||
final SoftwareModule module = softwareManagement.findSoftwareModuleById(softwareModuleId)
|
||||
final SoftwareModule module = softwareModuleManagement.findSoftwareModuleById(softwareModuleId)
|
||||
.orElseThrow(() -> new EntityNotFoundException(SoftwareModule.class, softwareModuleId));
|
||||
|
||||
if (checkModule(fileName, module)) {
|
||||
|
||||
@@ -46,7 +46,6 @@ import org.springframework.http.MediaType;
|
||||
import org.springframework.test.web.servlet.MvcResult;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.net.HttpHeaders;
|
||||
|
||||
import ru.yandex.qatools.allure.annotations.Description;
|
||||
@@ -78,7 +77,7 @@ public class DdiArtifactDownloadTest extends AbstractDDiApiIntegrationTest {
|
||||
public void invalidRequestsOnArtifactResource() throws Exception {
|
||||
// create target
|
||||
final Target target = testdataFactory.createTarget();
|
||||
final List<Target> targets = Lists.newArrayList(target);
|
||||
final List<Target> targets = Arrays.asList(target);
|
||||
|
||||
// create ds
|
||||
final DistributionSet ds = testdataFactory.createDistributionSet("");
|
||||
@@ -161,11 +160,11 @@ public class DdiArtifactDownloadTest extends AbstractDDiApiIntegrationTest {
|
||||
public void downloadArtifactThroughFileName() throws Exception {
|
||||
downLoadProgress = 1;
|
||||
shippedBytes = 0;
|
||||
assertThat(softwareManagement.findSoftwareModulesAll(PAGE)).hasSize(0);
|
||||
assertThat(softwareModuleManagement.findSoftwareModulesAll(PAGE)).hasSize(0);
|
||||
|
||||
// create target
|
||||
final Target target = testdataFactory.createTarget();
|
||||
final List<Target> targets = Lists.newArrayList(target);
|
||||
final List<Target> targets = Arrays.asList(target);
|
||||
|
||||
// create ds
|
||||
final DistributionSet ds = testdataFactory.createDistributionSet("");
|
||||
@@ -224,8 +223,8 @@ public class DdiArtifactDownloadTest extends AbstractDDiApiIntegrationTest {
|
||||
"attachment;filename=" + artifact.getFilename() + ".MD5SUM"))
|
||||
.andReturn();
|
||||
|
||||
assertThat(result.getResponse().getContentAsByteArray()).isEqualTo(
|
||||
new String(artifact.getMd5Hash() + " " + artifact.getFilename()).getBytes(Charsets.US_ASCII));
|
||||
assertThat(result.getResponse().getContentAsByteArray())
|
||||
.isEqualTo((artifact.getMd5Hash() + " " + artifact.getFilename()).getBytes(Charsets.US_ASCII));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -234,7 +233,7 @@ public class DdiArtifactDownloadTest extends AbstractDDiApiIntegrationTest {
|
||||
public void rangeDownloadArtifact() throws Exception {
|
||||
// create target
|
||||
final Target target = testdataFactory.createTarget();
|
||||
final List<Target> targets = Lists.newArrayList(target);
|
||||
final List<Target> targets = Arrays.asList(target);
|
||||
|
||||
// create ds
|
||||
final DistributionSet ds = testdataFactory.createDistributionSet("");
|
||||
|
||||
@@ -23,6 +23,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@@ -54,7 +55,6 @@ import org.springframework.data.domain.Sort.Direction;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.web.servlet.MvcResult;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.jayway.jsonpath.JsonPath;
|
||||
|
||||
import ru.yandex.qatools.allure.annotations.Description;
|
||||
@@ -124,7 +124,7 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
||||
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(0);
|
||||
|
||||
List<Target> saved = deploymentManagement.assignDistributionSet(ds.getId(), ActionType.FORCED,
|
||||
RepositoryModelConstants.NO_FORCE_TIME, Lists.newArrayList(savedTarget.getControllerId()))
|
||||
RepositoryModelConstants.NO_FORCE_TIME, Arrays.asList(savedTarget.getControllerId()))
|
||||
.getAssignedEntity();
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(1);
|
||||
|
||||
@@ -232,8 +232,7 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
||||
final DistributionSet ds = testdataFactory.createDistributionSet("", true);
|
||||
|
||||
final DistributionSetAssignmentResult result = deploymentManagement.assignDistributionSet(ds.getId(),
|
||||
ActionType.TIMEFORCED, System.currentTimeMillis() + 1_000,
|
||||
Lists.newArrayList(target.getControllerId()));
|
||||
ActionType.TIMEFORCED, System.currentTimeMillis() + 1_000, Arrays.asList(target.getControllerId()));
|
||||
|
||||
final Action action = deploymentManagement
|
||||
.findActiveActionsByTarget(PAGE, result.getAssignedEntity().get(0).getControllerId()).getContent()
|
||||
@@ -286,7 +285,7 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
||||
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(0);
|
||||
|
||||
List<Target> saved = deploymentManagement.assignDistributionSet(ds.getId(), ActionType.SOFT,
|
||||
RepositoryModelConstants.NO_FORCE_TIME, Lists.newArrayList(savedTarget.getControllerId()))
|
||||
RepositoryModelConstants.NO_FORCE_TIME, Arrays.asList(savedTarget.getControllerId()))
|
||||
.getAssignedEntity();
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(1);
|
||||
|
||||
@@ -401,7 +400,7 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
||||
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(0);
|
||||
|
||||
List<Target> saved = deploymentManagement.assignDistributionSet(ds.getId(), ActionType.TIMEFORCED,
|
||||
System.currentTimeMillis(), Lists.newArrayList(savedTarget.getControllerId())).getAssignedEntity();
|
||||
System.currentTimeMillis(), Arrays.asList(savedTarget.getControllerId())).getAssignedEntity();
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(1);
|
||||
|
||||
final Action action = deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())
|
||||
@@ -657,8 +656,7 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
||||
assertThat(targetManagement.findTargetByControllerID("4712").get().getUpdateStatus())
|
||||
.isEqualTo(TargetUpdateStatus.UNKNOWN);
|
||||
assignDistributionSet(ds, toAssign);
|
||||
final Action action = deploymentManagement.findActionsByDistributionSet(PAGE, ds.getId()).getContent()
|
||||
.get(0);
|
||||
final Action action = deploymentManagement.findActionsByDistributionSet(PAGE, ds.getId()).getContent().get(0);
|
||||
|
||||
mvc.perform(post("/{tenant}/controller/v1/4712/deploymentBase/" + action.getId() + "/feedback",
|
||||
tenantAware.getCurrentTenant())
|
||||
@@ -684,9 +682,9 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
||||
|
||||
// redo
|
||||
ds = distributionSetManagement.findDistributionSetByIdWithDetails(ds.getId()).get();
|
||||
assignDistributionSet(ds, Lists.newArrayList(targetManagement.findTargetByControllerID("4712").get()));
|
||||
final Action action2 = deploymentManagement.findActiveActionsByTarget(PAGE, myT.getControllerId())
|
||||
.getContent().get(0);
|
||||
assignDistributionSet(ds, Arrays.asList(targetManagement.findTargetByControllerID("4712").get()));
|
||||
final Action action2 = deploymentManagement.findActiveActionsByTarget(PAGE, myT.getControllerId()).getContent()
|
||||
.get(0);
|
||||
|
||||
mvc.perform(post("/{tenant}/controller/v1/4712/deploymentBase/" + action2.getId() + "/feedback",
|
||||
tenantAware.getCurrentTenant())
|
||||
@@ -719,13 +717,12 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
||||
|
||||
final Target savedTarget = testdataFactory.createTarget("4712");
|
||||
|
||||
final List<Target> toAssign = Lists.newArrayList(savedTarget);
|
||||
final List<Target> toAssign = Arrays.asList(savedTarget);
|
||||
|
||||
Target myT = targetManagement.findTargetByControllerID("4712").get();
|
||||
assertThat(myT.getUpdateStatus()).isEqualTo(TargetUpdateStatus.UNKNOWN);
|
||||
assignDistributionSet(ds, toAssign);
|
||||
final Action action = deploymentManagement.findActionsByDistributionSet(PAGE, ds.getId()).getContent()
|
||||
.get(0);
|
||||
final Action action = deploymentManagement.findActionsByDistributionSet(PAGE, ds.getId()).getContent().get(0);
|
||||
|
||||
myT = targetManagement.findTargetByControllerID("4712").get();
|
||||
assertThat(myT.getUpdateStatus()).isEqualTo(TargetUpdateStatus.PENDING);
|
||||
@@ -875,14 +872,14 @@ public class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
|
||||
.accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
|
||||
.andExpect(status().isNotFound());
|
||||
|
||||
final List<Target> toAssign = Lists.newArrayList(savedTarget);
|
||||
final List<Target> toAssign2 = Lists.newArrayList(savedTarget2);
|
||||
final List<Target> toAssign = Arrays.asList(savedTarget);
|
||||
final List<Target> toAssign2 = Arrays.asList(savedTarget2);
|
||||
|
||||
savedTarget = assignDistributionSet(savedSet, toAssign).getAssignedEntity().iterator().next();
|
||||
assignDistributionSet(savedSet2, toAssign2);
|
||||
|
||||
final Action updateAction = deploymentManagement
|
||||
.findActiveActionsByTarget(PAGE, savedTarget.getControllerId()).getContent().get(0);
|
||||
final Action updateAction = deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())
|
||||
.getContent().get(0);
|
||||
|
||||
// action exists but is not assigned to this target
|
||||
mvc.perform(post("/{tenant}/controller/v1/4713/deploymentBase/" + updateAction.getId() + "/feedback",
|
||||
|
||||
@@ -13,6 +13,7 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.Action;
|
||||
@@ -25,7 +26,6 @@ import org.springframework.http.MediaType;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.web.servlet.MvcResult;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.net.HttpHeaders;
|
||||
|
||||
import ru.yandex.qatools.allure.annotations.Description;
|
||||
@@ -147,7 +147,7 @@ public class DosFilterTest extends AbstractDDiApiIntegrationTest {
|
||||
private Long prepareDeploymentBase() {
|
||||
final DistributionSet ds = testdataFactory.createDistributionSet("test");
|
||||
final Target target = testdataFactory.createTarget("4711");
|
||||
final List<Target> toAssign = Lists.newArrayList(target);
|
||||
final List<Target> toAssign = Arrays.asList(target);
|
||||
|
||||
final Iterable<Target> saved = assignDistributionSet(ds, toAssign).getAssignedEntity();
|
||||
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, target.getControllerId())).hasSize(1);
|
||||
|
||||
Reference in New Issue
Block a user