Refactor management api style (#2445)

Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2025-06-10 17:09:03 +03:00
committed by GitHub
parent 85ef8652fc
commit 2992f5c211
88 changed files with 671 additions and 736 deletions

View File

@@ -200,9 +200,9 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
final Pageable pageable = PagingUtility.toPageable(pagingOffsetParam, pagingLimitParam, sanitizeDistributionSetSortParam(sortParam));
final Page<Target> targetsAssignedDS;
if (rsqlParam != null) {
targetsAssignedDS = this.targetManagement.findByAssignedDistributionSetAndRsql(pageable, distributionSetId, rsqlParam);
targetsAssignedDS = this.targetManagement.findByAssignedDistributionSetAndRsql(distributionSetId, rsqlParam, pageable);
} else {
targetsAssignedDS = this.targetManagement.findByAssignedDistributionSet(pageable, distributionSetId);
targetsAssignedDS = this.targetManagement.findByAssignedDistributionSet(distributionSetId, pageable);
}
return ResponseEntity.ok(new PagedList<>(
@@ -218,9 +218,9 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
final Pageable pageable = PagingUtility.toPageable(pagingOffsetParam, pagingLimitParam, sanitizeDistributionSetSortParam(sortParam));
final Page<Target> targetsInstalledDS;
if (rsqlParam != null) {
targetsInstalledDS = this.targetManagement.findByInstalledDistributionSetAndRsql(pageable, distributionSetId, rsqlParam);
targetsInstalledDS = this.targetManagement.findByInstalledDistributionSetAndRsql(distributionSetId, rsqlParam, pageable);
} else {
targetsInstalledDS = this.targetManagement.findByInstalledDistributionSet(pageable, distributionSetId);
targetsInstalledDS = this.targetManagement.findByInstalledDistributionSet(distributionSetId, pageable);
}
return ResponseEntity.ok(new PagedList<>(
@@ -233,7 +233,7 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
final int pagingOffsetParam, final int pagingLimitParam, final String sortParam) {
final Pageable pageable = PagingUtility.toPageable(pagingOffsetParam, pagingLimitParam, sanitizeDistributionSetSortParam(sortParam));
final Page<TargetFilterQuery> targetFilterQueries = targetFilterQueryManagement
.findByAutoAssignDSAndRsql(pageable, distributionSetId, rsqlParam);
.findByAutoAssignDSAndRsql(distributionSetId, rsqlParam, pageable);
return ResponseEntity.ok(new PagedList<>(
MgmtTargetFilterQueryMapper.toResponse(targetFilterQueries.getContent(), tenantConfigHelper.isConfirmationFlowEnabled(), false),

View File

@@ -94,13 +94,13 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi {
final List<MgmtRolloutResponseBody> rest;
if (isFullMode) {
rollouts = rsqlParam == null
? rolloutManagement.findAllWithDetailedStatus(pageable, false)
: rolloutManagement.findByRsqlWithDetailedStatus(pageable, rsqlParam, false);
? rolloutManagement.findAllWithDetailedStatus(false, pageable)
: rolloutManagement.findByRsqlWithDetailedStatus(rsqlParam, false, pageable);
rest = MgmtRolloutMapper.toResponseRolloutWithDetails(rollouts.getContent());
} else {
rollouts = rsqlParam == null
? rolloutManagement.findAll(pageable, false)
: rolloutManagement.findByRsql(pageable, rsqlParam, false);
? rolloutManagement.findAll(false, pageable)
: rolloutManagement.findByRsql(rsqlParam, false, pageable);
rest = MgmtRolloutMapper.toResponseRollout(rollouts.getContent());
}
return ResponseEntity.ok(new PagedList<>(rest, rollouts.getTotalElements()));
@@ -256,7 +256,7 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi {
if (rsqlParam == null) {
rolloutGroupTargets = this.rolloutGroupManagement.findTargetsOfRolloutGroup(groupId, pageable);
} else {
rolloutGroupTargets = this.rolloutGroupManagement.findTargetsOfRolloutGroupByRsql(pageable, groupId, rsqlParam);
rolloutGroupTargets = this.rolloutGroupManagement.findTargetsOfRolloutGroupByRsql(groupId, rsqlParam, pageable);
}
final List<MgmtTarget> rest = MgmtTargetMapper.toResponse(rolloutGroupTargets.getContent(), tenantConfigHelper);
return ResponseEntity.ok(new PagedList<>(rest, rolloutGroupTargets.getTotalElements()));

View File

@@ -80,7 +80,7 @@ public class MgmtTargetFilterQueryResource implements MgmtTargetFilterQueryRestA
final Slice<TargetFilterQuery> findTargetFiltersAll;
final long countTargetsAll;
if (rsqlParam != null) {
final Page<TargetFilterQuery> findFilterPage = filterManagement.findByRsql(pageable, rsqlParam);
final Page<TargetFilterQuery> findFilterPage = filterManagement.findByRsql(rsqlParam, pageable);
countTargetsAll = findFilterPage.getTotalElements();
findTargetFiltersAll = findFilterPage;
} else {

View File

@@ -118,7 +118,7 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
final Slice<Target> findTargetsAll;
final long countTargetsAll;
if (rsqlParam != null) {
findTargetsAll = targetManagement.findByRsql(pageable, rsqlParam);
findTargetsAll = targetManagement.findByRsql(rsqlParam, pageable);
countTargetsAll = targetManagement.countByRsql(rsqlParam);
} else {
findTargetsAll = targetManagement.findAll(pageable);
@@ -340,7 +340,7 @@ public class MgmtTargetResource implements MgmtTargetRestApi {
return ResponseEntity.notFound().build();
}
final Pageable pageable = PagingUtility.toPageable(pagingOffsetParam, pagingLimitParam, sanitizeActionStatusSortParam(sortParam));
final Page<ActionStatus> statusList = this.deploymentManagement.findActionStatusByAction(pageable, action.getId());
final Page<ActionStatus> statusList = this.deploymentManagement.findActionStatusByAction(action.getId(), pageable);
return ResponseEntity.ok(new PagedList<>(
MgmtTargetMapper.toActionStatusRestResponse(statusList.getContent(), deploymentManagement),

View File

@@ -70,7 +70,7 @@ public class MgmtTargetTagResource implements MgmtTargetTagRestApi {
if (rsqlParam == null) {
findTargetsAll = this.tagManagement.findAll(pageable);
} else {
findTargetsAll = this.tagManagement.findByRsql(pageable, rsqlParam);
findTargetsAll = this.tagManagement.findByRsql(rsqlParam, pageable);
}
final List<MgmtTag> rest = MgmtTagMapper.toResponse(findTargetsAll.getContent());
@@ -128,9 +128,9 @@ public class MgmtTargetTagResource implements MgmtTargetTagRestApi {
final Pageable pageable = PagingUtility.toPageable(pagingOffsetParam, pagingLimitParam, sanitizeTagSortParam(sortParam));
final Page<Target> findTargetsAll;
if (rsqlParam == null) {
findTargetsAll = targetManagement.findByTag(pageable, targetTagId);
findTargetsAll = targetManagement.findByTag(targetTagId, pageable);
} else {
findTargetsAll = targetManagement.findByRsqlAndTag(pageable, rsqlParam, targetTagId);
findTargetsAll = targetManagement.findByRsqlAndTag(rsqlParam, targetTagId, pageable);
}
final List<MgmtTarget> rest = MgmtTargetMapper.toResponse(findTargetsAll.getContent(), tenantConfigHelper);

View File

@@ -58,7 +58,7 @@ public class MgmtTargetTypeResource implements MgmtTargetTypeRestApi {
final Slice<TargetType> findTargetTypesAll;
long countTargetTypesAll;
if (rsqlParam != null) {
findTargetTypesAll = targetTypeManagement.findByRsql(pageable, rsqlParam);
findTargetTypesAll = targetTypeManagement.findByRsql(rsqlParam, pageable);
countTargetTypesAll = ((Page<TargetType>) findTargetTypesAll).getTotalElements();
} else {
findTargetTypesAll = targetTypeManagement.findAll(pageable);

View File

@@ -206,7 +206,7 @@ public final class MgmtTargetMapper {
return actionStatus.stream()
.map(status -> toResponse(status,
deploymentManagement.findMessagesByActionStatusId(
PageRequest.of(0, MgmtRestConstants.REQUEST_PARAMETER_PAGING_MAX_LIMIT), status.getId())
status.getId(), PageRequest.of(0, MgmtRestConstants.REQUEST_PARAMETER_PAGING_MAX_LIMIT))
.getContent()))
.toList();
}

View File

@@ -311,7 +311,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
.andExpect(jsonPath("$.alreadyAssigned", equalTo(1)))
.andExpect(jsonPath("$.total", equalTo(knownTargetIds.length)));
assertThat(targetManagement.findByAssignedDistributionSet(PAGE, createdDs.getId()).getContent())
assertThat(targetManagement.findByAssignedDistributionSet(createdDs.getId(), PAGE).getContent())
.as("Five targets in repository have DS assigned").hasSize(5);
}
@@ -398,7 +398,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
.contentType(MediaType.APPLICATION_JSON).content(payload.toString()))
.andExpect(status().isForbidden());
assertThat(targetManagement.findByAssignedDistributionSet(PAGE, ds.getId()).getContent()).isEmpty();
assertThat(targetManagement.findByAssignedDistributionSet(ds.getId(), PAGE).getContent()).isEmpty();
}
@Test
@@ -451,10 +451,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
.andExpect(jsonPath("$.alreadyAssigned", equalTo(1)))
.andExpect(jsonPath("$.total", equalTo(targets.size())));
assertThat(targetManagement.findByAssignedDistributionSet(PAGE, createdDs.getId()).getContent())
assertThat(targetManagement.findByAssignedDistributionSet(createdDs.getId(), PAGE).getContent())
.as("Five targets in repository have DS assigned").hasSize(5);
assertThat(targetManagement.findByInstalledDistributionSet(PAGE, createdDs.getId()).getContent()).hasSize(4);
assertThat(targetManagement.findByInstalledDistributionSet(createdDs.getId(), PAGE).getContent()).hasSize(4);
}
@Test
@@ -789,7 +789,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
@Description("Ensures that multiple DS requested are listed with expected payload.")
void getDistributionSets() throws Exception {
// prepare test data
assertThat(distributionSetManagement.findByCompleted(PAGE, true)).isEmpty();
assertThat(distributionSetManagement.findByCompleted(true, PAGE)).isEmpty();
DistributionSet set = testdataFactory.createDistributionSet("one");
set = distributionSetManagement.update(entityFactory.distributionSet().update(set.getId())
@@ -798,7 +798,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
// load also lazy stuff
set = distributionSetManagement.getWithDetails(set.getId()).get();
assertThat(distributionSetManagement.findByCompleted(PAGE, true)).hasSize(1);
assertThat(distributionSetManagement.findByCompleted(true, PAGE)).hasSize(1);
// perform request
mvc.perform(get("/rest/v1/distributionsets").accept(MediaType.APPLICATION_JSON))
@@ -864,7 +864,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
@WithUser(principal = "uploadTester", allSpPermissions = true)
@Description("Ensures that multipe DS posted to API are created in the repository.")
void createDistributionSets() throws Exception {
assertThat(distributionSetManagement.findByCompleted(PAGE, true)).isEmpty();
assertThat(distributionSetManagement.findByCompleted(true, PAGE)).isEmpty();
final SoftwareModule ah = testdataFactory.createSoftwareModule(TestdataFactory.SM_TYPE_APP);
final SoftwareModule jvm = testdataFactory.createSoftwareModule(TestdataFactory.SM_TYPE_RT);
final SoftwareModule os = testdataFactory.createSoftwareModule(TestdataFactory.SM_TYPE_OS);
@@ -907,7 +907,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
.hasToString(String.valueOf(three.getId()));
// check in database
assertThat(distributionSetManagement.findByCompleted(PAGE, true)).hasSize(3);
assertThat(distributionSetManagement.findByCompleted(true, PAGE)).hasSize(3);
assertThat(one.isRequiredMigrationStep()).isFalse();
assertThat(two.isRequiredMigrationStep()).isFalse();
assertThat(three.isRequiredMigrationStep()).isTrue();
@@ -921,11 +921,11 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
@Description("Ensures that DS deletion request to API is reflected by the repository.")
void deleteUnassignedistributionSet() throws Exception {
// prepare test data
assertThat(distributionSetManagement.findByCompleted(PAGE, true)).isEmpty();
assertThat(distributionSetManagement.findByCompleted(true, PAGE)).isEmpty();
final DistributionSet set = testdataFactory.createDistributionSet("one");
assertThat(distributionSetManagement.findByCompleted(PAGE, true)).hasSize(1);
assertThat(distributionSetManagement.findByCompleted(true, PAGE)).hasSize(1);
// perform request
mvc.perform(delete("/rest/v1/distributionsets/{smId}", set.getId()))
@@ -933,7 +933,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
.andExpect(status().isOk());
// check repository content
assertThat(distributionSetManagement.findByCompleted(PAGE, true)).isEmpty();
assertThat(distributionSetManagement.findByCompleted(true, PAGE)).isEmpty();
assertThat(distributionSetManagement.count()).isZero();
}
@@ -949,13 +949,13 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
@Description("Ensures that assigned DS deletion request to API is reflected by the repository by means of deleted flag set.")
void deleteAssignedDistributionSet() throws Exception {
// prepare test data
assertThat(distributionSetManagement.findByCompleted(PAGE, true)).isEmpty();
assertThat(distributionSetManagement.findByCompleted(true, PAGE)).isEmpty();
final DistributionSet set = testdataFactory.createDistributionSet("one");
testdataFactory.createTarget("test");
assignDistributionSet(set.getId(), "test");
assertThat(distributionSetManagement.findByCompleted(PAGE, true)).hasSize(1);
assertThat(distributionSetManagement.findByCompleted(true, PAGE)).hasSize(1);
mvc.perform(get("/rest/v1/distributionsets/{dsId}", set.getId()))
.andDo(MockMvcResultPrinter.print())
@@ -972,14 +972,14 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
.andExpect(jsonPath("$.deleted", equalTo(true)));
// check repository content
assertThat(distributionSetManagement.findByCompleted(PAGE, true)).isEmpty();
assertThat(distributionSetManagement.findByCompleted(true, PAGE)).isEmpty();
}
@Test
@Description("Ensures that DS property update request to API is reflected by the repository.")
void updateDistributionSet() throws Exception {
// prepare test data
assertThat(distributionSetManagement.findByCompleted(PAGE, true)).isEmpty();
assertThat(distributionSetManagement.findByCompleted(true, PAGE)).isEmpty();
final DistributionSet set = testdataFactory.createDistributionSet("one");
assertThat(distributionSetManagement.count()).isEqualTo(1);
@@ -1009,7 +1009,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
void updateRequiredMigrationStepFailsIfDistributionSetisInUse() throws Exception {
// prepare test data
assertThat(distributionSetManagement.findByCompleted(PAGE, true)).isEmpty();
assertThat(distributionSetManagement.findByCompleted(true, PAGE)).isEmpty();
final DistributionSet set = testdataFactory.createDistributionSet("one");
assignDistributionSet(set.getId(), testdataFactory.createTarget().getControllerId());
@@ -1310,7 +1310,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
.andExpect(jsonPath("$.alreadyAssigned", equalTo(1)))
.andExpect(jsonPath("$.total", equalTo(knownTargetIds.length)));
assertThat(targetManagement.findByAssignedDistributionSet(PAGE, createdDs.getId()).getContent())
assertThat(targetManagement.findByAssignedDistributionSet(createdDs.getId(), PAGE).getContent())
.as("Five targets in repository have DS assigned").hasSize(5);
}
@@ -1604,7 +1604,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
@Description("Tests the lock. It is verified that the distribution set can be marked as locked through update operation.")
void lockDistributionSet() throws Exception {
// prepare test data
assertThat(distributionSetManagement.findByCompleted(PAGE, true)).isEmpty();
assertThat(distributionSetManagement.findByCompleted(true, PAGE)).isEmpty();
final DistributionSet set = testdataFactory.createDistributionSet("one");
assertThat(distributionSetManagement.count()).isEqualTo(1);
@@ -1626,7 +1626,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
@Description("Tests the unlock.")
void unlockDistributionSet() throws Exception {
// prepare test data
assertThat(distributionSetManagement.findByCompleted(PAGE, true)).isEmpty();
assertThat(distributionSetManagement.findByCompleted(true, PAGE)).isEmpty();
final DistributionSet set = testdataFactory.createDistributionSet("one");
assertThat(distributionSetManagement.count()).isEqualTo(1);

View File

@@ -459,7 +459,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
rolloutHandler.handleAll();
final Rollout rollout = rolloutManagement.findByRsql(PAGE, "name==rollout1", false).getContent().get(0);
final Rollout rollout = rolloutManagement.findByRsql("name==rollout1", false, PAGE).getContent().get(0);
rolloutManagement.start(rollout.getId());
rolloutHandler.handleAll();
@@ -766,7 +766,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
final DistributionSet dsA = testdataFactory.createDistributionSet("");
postRollout("rollout1", 5, dsA.getId(), "id==target*", 20, Action.ActionType.FORCED);
final List<Rollout> content = rolloutManagement.findAll(PAGE, false).getContent();
final List<Rollout> content = rolloutManagement.findAll(false, PAGE).getContent();
assertThat(content).hasSizeGreaterThan(0).allSatisfy(rollout -> {
assertThat(rolloutGroupManagement.findByRollout(rollout.getId(), PAGE))
.describedAs("Confirmation required flag depends on feature active.")
@@ -803,7 +803,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
.andExpect(status().isCreated())
.andReturn();
final List<Rollout> content = rolloutManagement.findAll(PAGE, false).getContent();
final List<Rollout> content = rolloutManagement.findAll(false, PAGE).getContent();
assertThat(content).hasSize(1).allSatisfy(rollout -> {
final List<RolloutGroup> groups = rolloutGroupManagement.findByRollout(rollout.getId(), PAGE).getContent();
assertThat(groups).hasSize(2).allMatch(group -> {
@@ -846,7 +846,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
.andExpect(status().isCreated())
.andReturn();
final List<Rollout> content = rolloutManagement.findAll(PAGE, false).getContent();
final List<Rollout> content = rolloutManagement.findAll(false, PAGE).getContent();
assertThat(content).hasSize(1).allSatisfy(rollout -> {
final List<RolloutGroup> groups = rolloutGroupManagement.findByRollout(rollout.getId(), PAGE).getContent();
assertThat(groups).hasSize(2).allMatch(group -> {
@@ -1552,7 +1552,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isCreated());
final List<Rollout> rollouts = rolloutManagement.findAll(PAGE, false).getContent();
final List<Rollout> rollouts = rolloutManagement.findAll(false, PAGE).getContent();
assertThat(rollouts).hasSize(2);
assertThat(rollouts.get(0).getWeight()).get().isEqualTo(weight);
}

View File

@@ -275,8 +275,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
+ filterQuery.getId();
final String distributionsetHrefPrefix = "http://localhost" + MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING;
final String dsQuery = "?offset=0&limit=50&q=name==" + set.getName() + ";" + "version==" + set.getVersion();
final String dsQuery = "?q=name==" + set.getName() + ";" + "version==" + set.getVersion() + "&offset=0&limit=50";
mvc.perform(
post(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + filterQuery.getId() + "/autoAssignDS")
.content("{\"id\":" + set.getId() + "}").contentType(MediaType.APPLICATION_JSON))

View File

@@ -376,7 +376,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
final PageRequest pageRequest = PageRequest.of(0, 1000, Direction.ASC, ActionFields.ID.getJpaEntityFieldName());
final Action action = deploymentManagement.findActionsByTarget(knownTargetId, pageRequest).getContent().get(0);
final ActionStatus status = deploymentManagement.findActionStatusByAction(PAGE, action.getId()).getContent()
final ActionStatus status = deploymentManagement.findActionStatusByAction(action.getId(), PAGE).getContent()
.stream().sorted((e1, e2) -> Long.compare(e2.getId(), e1.getId())).toList().get(0);
mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/"
@@ -1337,7 +1337,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
final String knownTargetId = "targetId";
final Action action = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId).get(0);
// retrieve list in default descending order for actionstaus entries
final List<ActionStatus> actionStatus = deploymentManagement.findActionStatusByAction(PAGE, action.getId())
final List<ActionStatus> actionStatus = deploymentManagement.findActionStatusByAction(action.getId(), PAGE)
.getContent().stream().sorted((e1, e2) -> Long.compare(e2.getId(), e1.getId()))
.toList();
@@ -1365,7 +1365,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
void getActionsStatusSortedByReportedAt() throws Exception {
final String knownTargetId = "targetId";
final Action action = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId).get(0);
final List<ActionStatus> actionStatus = deploymentManagement.findActionStatusByAction(PAGE, action.getId())
final List<ActionStatus> actionStatus = deploymentManagement.findActionStatusByAction(action.getId(), PAGE)
.getContent().stream().sorted(Comparator.comparingLong(Identifiable::getId))
.toList();
@@ -1414,7 +1414,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
final String knownTargetId = "targetId";
final Action action = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId).get(0);
final List<ActionStatus> actionStatus = deploymentManagement.findActionStatusByAction(PAGE, action.getId())
final List<ActionStatus> actionStatus = deploymentManagement.findActionStatusByAction(action.getId(), PAGE)
.getContent().stream().sorted((e1, e2) -> Long.compare(e1.getId(), e2.getId()))
.toList();
@@ -1668,7 +1668,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
implicitLock(set);
final List<Action> findActiveActionsByTarget = deploymentManagement
.findActiveActionsByTarget(PAGE, target.getControllerId()).getContent();
.findActiveActionsByTarget(target.getControllerId(), PAGE).getContent();
assertThat(findActiveActionsByTarget).hasSize(1);
assertThat(findActiveActionsByTarget.get(0).getActionType()).isEqualTo(ActionType.TIMEFORCED);
assertThat(findActiveActionsByTarget.get(0).getForcedTime()).isEqualTo(forceTime);

View File

@@ -22,12 +22,10 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.stream.Collectors;
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
@@ -49,9 +47,6 @@ import org.eclipse.hawkbit.repository.test.matcher.ExpectEvents;
import org.eclipse.hawkbit.rest.json.model.ExceptionInfo;
import org.eclipse.hawkbit.rest.util.JsonBuilder;
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.junit.jupiter.api.Test;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.ResultActions;
@@ -163,11 +158,11 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
.andExpect(status().isCreated())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE));
final Tag createdOne = targetTagManagement.findByRsql(PAGE, "name==thetest1").getContent().get(0);
final Tag createdOne = targetTagManagement.findByRsql("name==thetest1", PAGE).getContent().get(0);
assertThat(createdOne.getName()).isEqualTo(tagOne.getName());
assertThat(createdOne.getDescription()).isEqualTo(tagOne.getDescription());
assertThat(createdOne.getColour()).isEqualTo(tagOne.getColour());
final Tag createdTwo = targetTagManagement.findByRsql(PAGE, "name==thetest2").getContent().get(0);
final Tag createdTwo = targetTagManagement.findByRsql("name==thetest2", PAGE).getContent().get(0);
assertThat(createdTwo.getName()).isEqualTo(tagTwo.getName());
assertThat(createdTwo.getDescription()).isEqualTo(tagTwo.getDescription());
assertThat(createdTwo.getColour()).isEqualTo(tagTwo.getColour());
@@ -196,7 +191,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE));
final Tag updated = targetTagManagement.findByRsql(PAGE, "name==updatedName").getContent().get(0);
final Tag updated = targetTagManagement.findByRsql("name==updatedName", PAGE).getContent().get(0);
assertThat(updated.getName()).isEqualTo(update.getName());
assertThat(updated.getDescription()).isEqualTo(update.getDescription());
assertThat(updated.getColour()).isEqualTo(update.getColour());
@@ -303,7 +298,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
final List<Target> updated = targetManagement.findByTag(PAGE, tag.getId()).getContent();
final List<Target> updated = targetManagement.findByTag(tag.getId(), PAGE).getContent();
assertThat(updated.stream().map(Target::getControllerId).toList()).containsOnly(assigned.getControllerId());
}
@@ -325,7 +320,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
final List<Target> updated = targetManagement.findByTag(PAGE, tag.getId()).getContent();
final List<Target> updated = targetManagement.findByTag(tag.getId(), PAGE).getContent();
assertThat(updated.stream().map(Target::getControllerId).toList())
.containsOnly(assigned0.getControllerId(), assigned1.getControllerId());
}
@@ -366,7 +361,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
Collections.sort(notFound);
assertThat(notFound).isEqualTo(missing);
});
assertThat(targetManagement.findByTag(PAGE, tag.getId()).getContent()).isEmpty();
assertThat(targetManagement.findByTag(tag.getId(), PAGE).getContent()).isEmpty();
}
@Test
@@ -407,7 +402,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
Collections.sort(notFound);
assertThat(notFound).isEqualTo(missing);
});
assertThat(targetManagement.findByTag(PAGE, tag.getId()).getContent().stream().map(Target::getControllerId).sorted().toList())
assertThat(targetManagement.findByTag(tag.getId(), PAGE).getContent().stream().map(Target::getControllerId).sorted().toList())
.isEqualTo(targets.stream().sorted().toList());
}
@@ -440,7 +435,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
.contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
assertThat(targetManagement.findByTag(PAGE, tag.getId()).getContent().stream().map(Target::getControllerId).sorted().toList())
assertThat(targetManagement.findByTag(tag.getId(), PAGE).getContent().stream().map(Target::getControllerId).sorted().toList())
.isEqualTo(targets.stream().sorted().toList());
}
@@ -463,7 +458,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
final List<Target> updated = targetManagement.findByTag(PAGE, tag.getId()).getContent();
final List<Target> updated = targetManagement.findByTag(tag.getId(), PAGE).getContent();
assertThat(updated.stream().map(Target::getControllerId).toList())
.containsOnly(assigned.getControllerId());
}
@@ -489,7 +484,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
final List<Target> updated = targetManagement.findByTag(PAGE, tag.getId()).getContent();
final List<Target> updated = targetManagement.findByTag(tag.getId(), PAGE).getContent();
assertThat(updated.stream().map(Target::getControllerId).toList())
.containsOnly(assigned.getControllerId());
}
@@ -533,7 +528,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
Collections.sort(notFound);
assertThat(notFound).isEqualTo(missing);
});
assertThat(targetManagement.findByTag(PAGE, tag.getId()).getContent().stream().map(Target::getControllerId).sorted().toList())
assertThat(targetManagement.findByTag(tag.getId(), PAGE).getContent().stream().map(Target::getControllerId).sorted().toList())
.isEqualTo(targets.stream().sorted().toList());
}
@@ -577,7 +572,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
Collections.sort(notFound);
assertThat(notFound).isEqualTo(missing);
});
assertThat(targetManagement.findByTag(PAGE, tag.getId()).getContent()).isEmpty();
assertThat(targetManagement.findByTag(tag.getId(), PAGE).getContent()).isEmpty();
}
@Test
@@ -611,6 +606,6 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
.contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
assertThat(targetManagement.findByTag(PAGE, tag.getId()).getContent()).isEmpty();
assertThat(targetManagement.findByTag(tag.getId(), PAGE).getContent()).isEmpty();
}
}