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

@@ -173,13 +173,13 @@ class DdiCancelActionTest extends AbstractDDiApiIntegrationTest {
// Retrieved is reported // Retrieved is reported
List<Action> activeActionsByTarget = deploymentManagement List<Action> activeActionsByTarget = deploymentManagement
.findActiveActionsByTarget(PAGE, savedTarget.getControllerId()).getContent(); .findActiveActionsByTarget(savedTarget.getControllerId(), PAGE).getContent();
assertThat(activeActionsByTarget).hasSize(1); assertThat(activeActionsByTarget).hasSize(1);
assertThat(activeActionsByTarget.get(0).getStatus()).isEqualTo(Status.RUNNING); assertThat(activeActionsByTarget.get(0).getStatus()).isEqualTo(Status.RUNNING);
final Action cancelAction = deploymentManagement.cancelAction(actionId); final Action cancelAction = deploymentManagement.cancelAction(actionId);
activeActionsByTarget = deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId()) activeActionsByTarget = deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE)
.getContent(); .getContent();
// the canceled action should still be active! // the canceled action should still be active!
@@ -219,7 +219,7 @@ class DdiCancelActionTest extends AbstractDDiApiIntegrationTest {
.andDo(MockMvcResultPrinter.print()) .andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk()); .andExpect(status().isOk());
activeActionsByTarget = deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId()) activeActionsByTarget = deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE)
.getContent(); .getContent();
assertThat(activeActionsByTarget).isEmpty(); assertThat(activeActionsByTarget).isEmpty();
final Action canceledAction = deploymentManagement.findAction(cancelAction.getId()).get(); final Action canceledAction = deploymentManagement.findAction(cancelAction.getId()).get();
@@ -279,7 +279,7 @@ class DdiCancelActionTest extends AbstractDDiApiIntegrationTest {
final Action cancelAction = deploymentManagement.cancelAction(actionId); final Action cancelAction = deploymentManagement.cancelAction(actionId);
assertThat(countActionStatusAll()).isEqualTo(2); assertThat(countActionStatusAll()).isEqualTo(2);
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(1); assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE)).hasSize(1);
mvc.perform(post("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/cancelAction/" mvc.perform(post("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/cancelAction/"
+ cancelAction.getId() + "/feedback", tenantAware.getCurrentTenant()) + cancelAction.getId() + "/feedback", tenantAware.getCurrentTenant())
.content(getJsonProceedingCancelActionFeedback()).contentType(MediaType.APPLICATION_JSON) .content(getJsonProceedingCancelActionFeedback()).contentType(MediaType.APPLICATION_JSON)
@@ -287,7 +287,7 @@ class DdiCancelActionTest extends AbstractDDiApiIntegrationTest {
.andDo(MockMvcResultPrinter.print()) .andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk()); .andExpect(status().isOk());
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(1); assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE)).hasSize(1);
assertThat(countActionStatusAll()).isEqualTo(3); assertThat(countActionStatusAll()).isEqualTo(3);
mvc.perform(post("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/cancelAction/" mvc.perform(post("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/cancelAction/"
@@ -296,7 +296,7 @@ class DdiCancelActionTest extends AbstractDDiApiIntegrationTest {
.accept(MediaType.APPLICATION_JSON)) .accept(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print()) .andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk()); .andExpect(status().isOk());
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(1); assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE)).hasSize(1);
assertThat(countActionStatusAll()).isEqualTo(4); assertThat(countActionStatusAll()).isEqualTo(4);
mvc.perform(post("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/cancelAction/" mvc.perform(post("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/cancelAction/"
@@ -306,10 +306,10 @@ class DdiCancelActionTest extends AbstractDDiApiIntegrationTest {
.andDo(MockMvcResultPrinter.print()) .andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk()); .andExpect(status().isOk());
assertThat(countActionStatusAll()).isEqualTo(5); assertThat(countActionStatusAll()).isEqualTo(5);
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(1); assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE)).hasSize(1);
// cancellation canceled -> should remove the action from active // cancellation canceled -> should remove the action from active
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(1); assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE)).hasSize(1);
mvc.perform(post("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/cancelAction/" mvc.perform(post("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/cancelAction/"
+ cancelAction.getId() + "/feedback", tenantAware.getCurrentTenant()) + cancelAction.getId() + "/feedback", tenantAware.getCurrentTenant())
.content(getJsonCanceledCancelActionFeedback()).contentType(MediaType.APPLICATION_JSON) .content(getJsonCanceledCancelActionFeedback()).contentType(MediaType.APPLICATION_JSON)
@@ -317,13 +317,13 @@ class DdiCancelActionTest extends AbstractDDiApiIntegrationTest {
.andDo(MockMvcResultPrinter.print()) .andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk()); .andExpect(status().isOk());
assertThat(countActionStatusAll()).isEqualTo(6); assertThat(countActionStatusAll()).isEqualTo(6);
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(1); assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE)).hasSize(1);
// cancellation rejected -> action still active until controller close // cancellation rejected -> action still active until controller close
// it // it
// with finished or // with finished or
// error // error
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(1); assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE)).hasSize(1);
mvc.perform(post("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/cancelAction/" mvc.perform(post("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/cancelAction/"
+ cancelAction.getId() + "/feedback", tenantAware.getCurrentTenant()) + cancelAction.getId() + "/feedback", tenantAware.getCurrentTenant())
.content(getJsonRejectedCancelActionFeedback()).contentType(MediaType.APPLICATION_JSON) .content(getJsonRejectedCancelActionFeedback()).contentType(MediaType.APPLICATION_JSON)
@@ -331,7 +331,7 @@ class DdiCancelActionTest extends AbstractDDiApiIntegrationTest {
.andDo(MockMvcResultPrinter.print()) .andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk()); .andExpect(status().isOk());
assertThat(countActionStatusAll()).isEqualTo(7); assertThat(countActionStatusAll()).isEqualTo(7);
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(1); assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE)).hasSize(1);
// update closed -> should remove the action from active // update closed -> should remove the action from active
mvc.perform(post("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/deploymentBase/" mvc.perform(post("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/deploymentBase/"
@@ -341,7 +341,7 @@ class DdiCancelActionTest extends AbstractDDiApiIntegrationTest {
.andDo(MockMvcResultPrinter.print()) .andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk()); .andExpect(status().isOk());
assertThat(countActionStatusAll()).isEqualTo(8); assertThat(countActionStatusAll()).isEqualTo(8);
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).isEmpty(); assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE)).isEmpty();
} }
@Test @Test
@@ -366,12 +366,12 @@ class DdiCancelActionTest extends AbstractDDiApiIntegrationTest {
assertThat(countActionStatusAll()).isEqualTo(3); assertThat(countActionStatusAll()).isEqualTo(3);
// 3 update actions, 0 cancel actions // 3 update actions, 0 cancel actions
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(3); assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE)).hasSize(3);
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(3); assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE)).hasSize(3);
final Action cancelAction = deploymentManagement.cancelAction(actionId); final Action cancelAction = deploymentManagement.cancelAction(actionId);
final Action cancelAction2 = deploymentManagement.cancelAction(actionId2); final Action cancelAction2 = deploymentManagement.cancelAction(actionId2);
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(3); assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE)).hasSize(3);
assertThat(deploymentManagement.countActionsByTarget(savedTarget.getControllerId())).isEqualTo(3); assertThat(deploymentManagement.countActionsByTarget(savedTarget.getControllerId())).isEqualTo(3);
mvc.perform(get("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/cancelAction/" mvc.perform(get("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/cancelAction/"
+ cancelAction.getId(), tenantAware.getCurrentTenant()).accept(MediaType.APPLICATION_JSON)) + cancelAction.getId(), tenantAware.getCurrentTenant()).accept(MediaType.APPLICATION_JSON))
@@ -402,7 +402,7 @@ class DdiCancelActionTest extends AbstractDDiApiIntegrationTest {
assertThat(countActionStatusAll()).isEqualTo(7); assertThat(countActionStatusAll()).isEqualTo(7);
// 1 update actions, 1 cancel actions // 1 update actions, 1 cancel actions
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(2); assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE)).hasSize(2);
assertThat(deploymentManagement.countActionsByTarget(savedTarget.getControllerId())).isEqualTo(3); assertThat(deploymentManagement.countActionsByTarget(savedTarget.getControllerId())).isEqualTo(3);
mvc.perform(get("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/cancelAction/" mvc.perform(get("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/cancelAction/"
+ cancelAction2.getId(), tenantAware.getCurrentTenant()).accept(MediaType.APPLICATION_JSON)) + cancelAction2.getId(), tenantAware.getCurrentTenant()).accept(MediaType.APPLICATION_JSON))
@@ -442,12 +442,12 @@ class DdiCancelActionTest extends AbstractDDiApiIntegrationTest {
assertThat(countActionStatusAll()).isEqualTo(10); assertThat(countActionStatusAll()).isEqualTo(10);
// 1 update actions, 0 cancel actions // 1 update actions, 0 cancel actions
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(1); assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE)).hasSize(1);
final Action cancelAction3 = deploymentManagement.cancelAction(actionId3); final Action cancelAction3 = deploymentManagement.cancelAction(actionId3);
// action is in cancelling state // action is in cancelling state
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(1); assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE)).hasSize(1);
assertThat(deploymentManagement.countActionsByTarget(savedTarget.getControllerId())).isEqualTo(3); assertThat(deploymentManagement.countActionsByTarget(savedTarget.getControllerId())).isEqualTo(3);
assertThat(deploymentManagement.getAssignedDistributionSet(TestdataFactory.DEFAULT_CONTROLLER_ID).get()) assertThat(deploymentManagement.getAssignedDistributionSet(TestdataFactory.DEFAULT_CONTROLLER_ID).get())
.isEqualTo(ds3); .isEqualTo(ds3);
@@ -471,7 +471,7 @@ class DdiCancelActionTest extends AbstractDDiApiIntegrationTest {
assertThat(countActionStatusAll()).isEqualTo(13); assertThat(countActionStatusAll()).isEqualTo(13);
// final status // final status
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).isEmpty(); assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE)).isEmpty();
assertThat(deploymentManagement.countActionsByTarget(savedTarget.getControllerId())).isEqualTo(3); assertThat(deploymentManagement.countActionsByTarget(savedTarget.getControllerId())).isEqualTo(3);
} }

View File

@@ -82,7 +82,7 @@ class DdiConfirmationBaseTest extends AbstractDDiApiIntegrationTest {
nextBytes(ARTIFACT_SIZE), getOsModule(ds), "test1.signature", ARTIFACT_SIZE); nextBytes(ARTIFACT_SIZE), getOsModule(ds), "test1.signature", ARTIFACT_SIZE);
final Target savedTarget = testdataFactory.createTarget(DdiConfirmationBaseTest.DEFAULT_CONTROLLER_ID); final Target savedTarget = testdataFactory.createTarget(DdiConfirmationBaseTest.DEFAULT_CONTROLLER_ID);
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).isEmpty(); assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE)).isEmpty();
final List<Target> targetsAssignedToDs = assignDistributionSet( final List<Target> targetsAssignedToDs = assignDistributionSet(
ds.getId(), savedTarget.getControllerId(), Action.ActionType.FORCED).getAssignedEntity().stream() ds.getId(), savedTarget.getControllerId(), Action.ActionType.FORCED).getAssignedEntity().stream()
@@ -90,18 +90,18 @@ class DdiConfirmationBaseTest extends AbstractDDiApiIntegrationTest {
.toList(); .toList();
implicitLock(ds); implicitLock(ds);
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(1); assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE)).hasSize(1);
final Action action = deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId()).getContent().get(0); final Action action = deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE).getContent().get(0);
assertThat(deploymentManagement.countActionsAll()).isEqualTo(1); assertThat(deploymentManagement.countActionsAll()).isEqualTo(1);
assignDistributionSet(ds2, targetsAssignedToDs).getAssignedEntity(); assignDistributionSet(ds2, targetsAssignedToDs).getAssignedEntity();
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(2); assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE)).hasSize(2);
assertThat(deploymentManagement.countActionsAll()).isEqualTo(2); assertThat(deploymentManagement.countActionsAll()).isEqualTo(2);
final Action uaction = deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId()).getContent().get(0); final Action uaction = deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE).getContent().get(0);
assertThat(uaction.getDistributionSet()).isEqualTo(ds); assertThat(uaction.getDistributionSet()).isEqualTo(ds);
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(2); assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE)).hasSize(2);
// Run test // Run test
final long current = System.currentTimeMillis(); final long current = System.currentTimeMillis();
@@ -129,7 +129,7 @@ class DdiConfirmationBaseTest extends AbstractDDiApiIntegrationTest {
// Retrieved is reported // Retrieved is reported
final Iterable<ActionStatus> actionStatus = deploymentManagement final Iterable<ActionStatus> actionStatus = deploymentManagement
.findActionStatusByAction(PageRequest.of(0, 100, Sort.Direction.DESC, "id"), uaction.getId()); .findActionStatusByAction(uaction.getId(), PageRequest.of(0, 100, Sort.Direction.DESC, "id"));
assertThat(actionStatus).hasSize(1) assertThat(actionStatus).hasSize(1)
.allMatch(status -> status.getStatus() == Action.Status.WAIT_FOR_CONFIRMATION); .allMatch(status -> status.getStatus() == Action.Status.WAIT_FOR_CONFIRMATION);
} }
@@ -146,7 +146,7 @@ class DdiConfirmationBaseTest extends AbstractDDiApiIntegrationTest {
assignDistributionSet(distributionSet.getId(), target.getName()); assignDistributionSet(distributionSet.getId(), target.getName());
final Action action = deploymentManagement.findActiveActionsByTarget(PAGE, target.getControllerId()).getContent().get(0); final Action action = deploymentManagement.findActiveActionsByTarget(target.getControllerId(), PAGE).getContent().get(0);
// get confirmation base // get confirmation base
performGet(CONFIRMATION_BASE_ACTION, MediaType.parseMediaType(DdiRestConstants.MEDIA_TYPE_CBOR), performGet(CONFIRMATION_BASE_ACTION, MediaType.parseMediaType(DdiRestConstants.MEDIA_TYPE_CBOR),
@@ -166,7 +166,7 @@ class DdiConfirmationBaseTest extends AbstractDDiApiIntegrationTest {
savedTarget = getFirstAssignedTarget(assignDistributionSet(ds.getId(), savedTarget.getControllerId())); savedTarget = getFirstAssignedTarget(assignDistributionSet(ds.getId(), savedTarget.getControllerId()));
final String controllerId = savedTarget.getControllerId(); final String controllerId = savedTarget.getControllerId();
final Action savedAction = deploymentManagement.findActiveActionsByTarget(PAGE, controllerId).getContent().get(0); final Action savedAction = deploymentManagement.findActiveActionsByTarget(controllerId, PAGE).getContent().get(0);
mvc.perform(get(CONTROLLER_BASE, tenantAware.getCurrentTenant(), controllerId).accept(MediaType.APPLICATION_JSON)) mvc.perform(get(CONTROLLER_BASE, tenantAware.getCurrentTenant(), controllerId).accept(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print()) .andDo(MockMvcResultPrinter.print())
@@ -190,7 +190,7 @@ class DdiConfirmationBaseTest extends AbstractDDiApiIntegrationTest {
final String controllerId = savedTarget.getControllerId(); final String controllerId = savedTarget.getControllerId();
final Action savedAction = deploymentManagement.findActiveActionsByTarget(PAGE, controllerId).getContent().get(0); final Action savedAction = deploymentManagement.findActiveActionsByTarget(controllerId, PAGE).getContent().get(0);
mvc.perform(get(CONTROLLER_BASE, tenantAware.getCurrentTenant(), controllerId).accept(MediaType.APPLICATION_JSON)) mvc.perform(get(CONTROLLER_BASE, tenantAware.getCurrentTenant(), controllerId).accept(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print()) .andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk()) .andExpect(status().isOk())
@@ -219,7 +219,7 @@ class DdiConfirmationBaseTest extends AbstractDDiApiIntegrationTest {
final String controllerId = savedTarget.getControllerId(); final String controllerId = savedTarget.getControllerId();
final Action savedAction = deploymentManagement.findActiveActionsByTarget(PAGE, controllerId).getContent().get(0); final Action savedAction = deploymentManagement.findActiveActionsByTarget(controllerId, PAGE).getContent().get(0);
// disable confirmation flow // disable confirmation flow
disableConfirmationFlow(); disableConfirmationFlow();
@@ -268,7 +268,7 @@ class DdiConfirmationBaseTest extends AbstractDDiApiIntegrationTest {
String controllerId = savedTarget.getControllerId(); String controllerId = savedTarget.getControllerId();
final Action savedAction = deploymentManagement.findActiveActionsByTarget(PAGE, controllerId).getContent() final Action savedAction = deploymentManagement.findActiveActionsByTarget(controllerId, PAGE).getContent()
.get(0); .get(0);
sendConfirmationFeedback( sendConfirmationFeedback(
@@ -286,7 +286,7 @@ class DdiConfirmationBaseTest extends AbstractDDiApiIntegrationTest {
final String controllerId = testdataFactory.createTarget("989").getControllerId(); final String controllerId = testdataFactory.createTarget("989").getControllerId();
assignDistributionSet(testdataFactory.createDistributionSet("").getId(), controllerId); assignDistributionSet(testdataFactory.createDistributionSet("").getId(), controllerId);
final long actionId = deploymentManagement.findActiveActionsByTarget(PAGE, controllerId).getContent().get(0).getId(); final long actionId = deploymentManagement.findActiveActionsByTarget(controllerId, PAGE).getContent().get(0).getId();
final String confirmationBaseActionLink = String.format( final String confirmationBaseActionLink = String.format(
"/%s/controller/v1/%s/confirmationBase/%d", "/%s/controller/v1/%s/confirmationBase/%d",
@@ -387,7 +387,7 @@ class DdiConfirmationBaseTest extends AbstractDDiApiIntegrationTest {
Target savedTarget = testdataFactory.createTarget("989"); Target savedTarget = testdataFactory.createTarget("989");
savedTarget = getFirstAssignedTarget(assignDistributionSet(ds.getId(), savedTarget.getControllerId())); savedTarget = getFirstAssignedTarget(assignDistributionSet(ds.getId(), savedTarget.getControllerId()));
String controllerId = savedTarget.getControllerId(); String controllerId = savedTarget.getControllerId();
final Action savedAction = deploymentManagement.findActiveActionsByTarget(PAGE, controllerId).getContent().get(0); final Action savedAction = deploymentManagement.findActiveActionsByTarget(controllerId, PAGE).getContent().get(0);
sendConfirmationFeedback( sendConfirmationFeedback(
savedTarget, savedAction, DdiConfirmationFeedback.Confirmation.DENIED, 10, "Action denied message.") savedTarget, savedAction, DdiConfirmationFeedback.Confirmation.DENIED, 10, "Action denied message.")
@@ -432,7 +432,7 @@ class DdiConfirmationBaseTest extends AbstractDDiApiIntegrationTest {
final String controllerId = savedTarget.getControllerId(); final String controllerId = savedTarget.getControllerId();
final Action savedAction = deploymentManagement.findActiveActionsByTarget(PAGE, controllerId).getContent().get(0); final Action savedAction = deploymentManagement.findActiveActionsByTarget(controllerId, PAGE).getContent().get(0);
final String confirmedMessage = "Action confirmed message."; final String confirmedMessage = "Action confirmed message.";
final Integer confirmedCode = 10; final Integer confirmedCode = 10;
sendConfirmationFeedback( sendConfirmationFeedback(

View File

@@ -92,7 +92,7 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
testdataFactory.createArtifacts(softwareModuleId); testdataFactory.createArtifacts(softwareModuleId);
assignDistributionSet(distributionSet.getId(), target.getName()); assignDistributionSet(distributionSet.getId(), target.getName());
final Action action = deploymentManagement.findActiveActionsByTarget(PAGE, target.getControllerId()).getContent().get(0); final Action action = deploymentManagement.findActiveActionsByTarget(target.getControllerId(), PAGE).getContent().get(0);
// get deployment base // get deployment base
performGet(DEPLOYMENT_BASE, MediaType.parseMediaType(DdiRestConstants.MEDIA_TYPE_CBOR), status().isOk(), performGet(DEPLOYMENT_BASE, MediaType.parseMediaType(DdiRestConstants.MEDIA_TYPE_CBOR), status().isOk(),
@@ -153,18 +153,18 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
.toList(); .toList();
implicitLock(ds); implicitLock(ds);
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(1); assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE)).hasSize(1);
final Action action = deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId()).getContent().get(0); final Action action = deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE).getContent().get(0);
assertThat(deploymentManagement.countActionsAll()).isEqualTo(1); assertThat(deploymentManagement.countActionsAll()).isEqualTo(1);
assignDistributionSet(ds2, targetsAssignedToDs).getAssignedEntity(); assignDistributionSet(ds2, targetsAssignedToDs).getAssignedEntity();
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(2); assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE)).hasSize(2);
assertThat(deploymentManagement.countActionsAll()).isEqualTo(2); assertThat(deploymentManagement.countActionsAll()).isEqualTo(2);
final Action uaction = deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId()).getContent().get(0); final Action uaction = deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE).getContent().get(0);
assertThat(uaction.getDistributionSet()).isEqualTo(ds); assertThat(uaction.getDistributionSet()).isEqualTo(ds);
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(2); assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE)).hasSize(2);
// Run test // Run test
final long current = System.currentTimeMillis(); final long current = System.currentTimeMillis();
@@ -187,7 +187,7 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
// Retrieved is reported // Retrieved is reported
final Iterable<ActionStatus> actionStatusMessages = deploymentManagement final Iterable<ActionStatus> actionStatusMessages = deploymentManagement
.findActionStatusByAction(PageRequest.of(0, 100, Direction.DESC, "id"), uaction.getId()); .findActionStatusByAction(uaction.getId(), PageRequest.of(0, 100, Direction.DESC, "id"));
assertThat(actionStatusMessages).hasSize(2); assertThat(actionStatusMessages).hasSize(2);
final ActionStatus actionStatusMessage = actionStatusMessages.iterator().next(); final ActionStatus actionStatusMessage = actionStatusMessages.iterator().next();
assertThat(actionStatusMessage.getStatus()).isEqualTo(Status.RETRIEVED); assertThat(actionStatusMessage.getStatus()).isEqualTo(Status.RETRIEVED);
@@ -253,17 +253,17 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
final List<Target> saved = assignDistributionSet(ds.getId(), savedTarget.getControllerId(), ActionType.SOFT) final List<Target> saved = assignDistributionSet(ds.getId(), savedTarget.getControllerId(), ActionType.SOFT)
.getAssignedEntity().stream().map(Action::getTarget).toList(); .getAssignedEntity().stream().map(Action::getTarget).toList();
implicitLock(ds); implicitLock(ds);
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(1); assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE)).hasSize(1);
final Action action = deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId()).getContent().get(0); final Action action = deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE).getContent().get(0);
assertThat(deploymentManagement.countActionsAll()).isEqualTo(1); assertThat(deploymentManagement.countActionsAll()).isEqualTo(1);
assignDistributionSet(ds2, saved).getAssignedEntity(); assignDistributionSet(ds2, saved).getAssignedEntity();
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(2); assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE)).hasSize(2);
assertThat(deploymentManagement.countActionsAll()).isEqualTo(2); assertThat(deploymentManagement.countActionsAll()).isEqualTo(2);
final Action uaction = deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId()).getContent().get(0); final Action uaction = deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE).getContent().get(0);
assertThat(uaction.getDistributionSet()).isEqualTo(ds); assertThat(uaction.getDistributionSet()).isEqualTo(ds);
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(2); assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE)).hasSize(2);
// Run test // Run test
final long current = System.currentTimeMillis(); final long current = System.currentTimeMillis();
@@ -286,7 +286,7 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
// Retrieved is reported // Retrieved is reported
final List<ActionStatus> actionStatusMessages = deploymentManagement final List<ActionStatus> actionStatusMessages = deploymentManagement
.findActionStatusByAction(PageRequest.of(0, 100, Direction.DESC, "id"), uaction.getId()).getContent(); .findActionStatusByAction(uaction.getId(), PageRequest.of(0, 100, Direction.DESC, "id")).getContent();
assertThat(actionStatusMessages).hasSize(2); assertThat(actionStatusMessages).hasSize(2);
final ActionStatus actionStatusMessage = actionStatusMessages.iterator().next(); final ActionStatus actionStatusMessage = actionStatusMessages.iterator().next();
assertThat(actionStatusMessage.getStatus()).isEqualTo(Status.RETRIEVED); assertThat(actionStatusMessage.getStatus()).isEqualTo(Status.RETRIEVED);
@@ -308,17 +308,17 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
final List<Target> saved = assignDistributionSet(ds.getId(), savedTarget.getControllerId(), final List<Target> saved = assignDistributionSet(ds.getId(), savedTarget.getControllerId(),
ActionType.TIMEFORCED).getAssignedEntity().stream().map(Action::getTarget).toList(); ActionType.TIMEFORCED).getAssignedEntity().stream().map(Action::getTarget).toList();
implicitLock(ds); implicitLock(ds);
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(1); assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE)).hasSize(1);
final Action action = deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId()).getContent().get(0); final Action action = deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE).getContent().get(0);
assertThat(deploymentManagement.countActionsAll()).isEqualTo(1); assertThat(deploymentManagement.countActionsAll()).isEqualTo(1);
assignDistributionSet(ds2, saved).getAssignedEntity(); assignDistributionSet(ds2, saved).getAssignedEntity();
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(2); assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE)).hasSize(2);
assertThat(countActionStatusAll()).isEqualTo(2); assertThat(countActionStatusAll()).isEqualTo(2);
final Action uaction = deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId()).getContent().get(0); final Action uaction = deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE).getContent().get(0);
assertThat(uaction.getDistributionSet()).isEqualTo(ds); assertThat(uaction.getDistributionSet()).isEqualTo(ds);
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(2); assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE)).hasSize(2);
// Run test // Run test
final long current = System.currentTimeMillis(); final long current = System.currentTimeMillis();
@@ -344,7 +344,7 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
// Retrieved is reported // Retrieved is reported
final Iterable<ActionStatus> actionStatusMessages = deploymentManagement final Iterable<ActionStatus> actionStatusMessages = deploymentManagement
.findActionStatusByAction(PageRequest.of(0, 100, Direction.DESC, "id"), uaction.getId()).getContent(); .findActionStatusByAction(uaction.getId(), PageRequest.of(0, 100, Direction.DESC, "id")).getContent();
assertThat(actionStatusMessages).hasSize(2); assertThat(actionStatusMessages).hasSize(2);
final ActionStatus actionStatusMessage = actionStatusMessages.iterator().next(); final ActionStatus actionStatusMessage = actionStatusMessages.iterator().next();
assertThat(actionStatusMessage.getStatus()).isEqualTo(Status.RETRIEVED); assertThat(actionStatusMessage.getStatus()).isEqualTo(Status.RETRIEVED);
@@ -372,17 +372,17 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
.map(Action::getTarget) .map(Action::getTarget)
.toList(); .toList();
implicitLock(ds); implicitLock(ds);
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(1); assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE)).hasSize(1);
final Action action = deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId()).getContent().get(0); final Action action = deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE).getContent().get(0);
assertThat(deploymentManagement.countActionsAll()).isEqualTo(1); assertThat(deploymentManagement.countActionsAll()).isEqualTo(1);
assignDistributionSet(ds2, saved).getAssignedEntity(); assignDistributionSet(ds2, saved).getAssignedEntity();
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(2); assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE)).hasSize(2);
assertThat(deploymentManagement.countActionsAll()).isEqualTo(2); assertThat(deploymentManagement.countActionsAll()).isEqualTo(2);
final Action uaction = deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId()).getContent().get(0); final Action uaction = deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE).getContent().get(0);
assertThat(uaction.getDistributionSet()).isEqualTo(ds); assertThat(uaction.getDistributionSet()).isEqualTo(ds);
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(2); assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE)).hasSize(2);
// Run test // Run test
@@ -405,7 +405,7 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
// Retrieved is reported // Retrieved is reported
final List<ActionStatus> actionStatusMessages = deploymentManagement final List<ActionStatus> actionStatusMessages = deploymentManagement
.findActionStatusByAction(PageRequest.of(0, 100, Direction.DESC, "id"), uaction.getId()).getContent(); .findActionStatusByAction(uaction.getId(), PageRequest.of(0, 100, Direction.DESC, "id")).getContent();
assertThat(actionStatusMessages).hasSize(2); assertThat(actionStatusMessages).hasSize(2);
final ActionStatus actionStatusMessage = actionStatusMessages.iterator().next(); final ActionStatus actionStatusMessage = actionStatusMessages.iterator().next();
assertThat(actionStatusMessage.getStatus()).isEqualTo(Status.RETRIEVED); assertThat(actionStatusMessage.getStatus()).isEqualTo(Status.RETRIEVED);
@@ -512,7 +512,7 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
implicitLock(ds3); implicitLock(ds3);
findTargetAndAssertUpdateStatus(Optional.of(ds3), TargetUpdateStatus.PENDING, 3, Optional.empty()); findTargetAndAssertUpdateStatus(Optional.of(ds3), TargetUpdateStatus.PENDING, 3, Optional.empty());
assertThat(targetManagement.findByUpdateStatus(PageRequest.of(0, 10), TargetUpdateStatus.UNKNOWN)).hasSize(2); assertThat(targetManagement.findByUpdateStatus(TargetUpdateStatus.UNKNOWN, PageRequest.of(0, 10))).hasSize(2);
// action1 done // action1 done
postDeploymentFeedback(DEFAULT_CONTROLLER_ID, actionId1, getJsonClosedDeploymentActionFeedback(), status().isOk()); postDeploymentFeedback(DEFAULT_CONTROLLER_ID, actionId1, getJsonClosedDeploymentActionFeedback(), status().isOk());
@@ -557,15 +557,15 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
// redo // redo
ds = distributionSetManagement.getWithDetails(ds.getId()).get(); ds = distributionSetManagement.getWithDetails(ds.getId()).get();
assignDistributionSet(ds, Collections.singletonList(targetManagement.getByControllerID(DEFAULT_CONTROLLER_ID).get())); assignDistributionSet(ds, Collections.singletonList(targetManagement.getByControllerID(DEFAULT_CONTROLLER_ID).get()));
final Action action2 = deploymentManagement.findActiveActionsByTarget(PAGE, DEFAULT_CONTROLLER_ID).getContent().get(0); final Action action2 = deploymentManagement.findActiveActionsByTarget(DEFAULT_CONTROLLER_ID, PAGE).getContent().get(0);
postDeploymentFeedback(DEFAULT_CONTROLLER_ID, action2.getId(), getJsonClosedCancelActionFeedback(), status().isOk()); postDeploymentFeedback(DEFAULT_CONTROLLER_ID, action2.getId(), getJsonClosedCancelActionFeedback(), status().isOk());
findTargetAndAssertUpdateStatus(Optional.of(ds), TargetUpdateStatus.IN_SYNC, 0, Optional.of(ds)); findTargetAndAssertUpdateStatus(Optional.of(ds), TargetUpdateStatus.IN_SYNC, 0, Optional.of(ds));
assertTargetCountByStatus(0, 0, 1); assertTargetCountByStatus(0, 0, 1);
assertThat(deploymentManagement.findInActiveActionsByTarget(PAGE, DEFAULT_CONTROLLER_ID)).hasSize(2); assertThat(deploymentManagement.findInActiveActionsByTarget(DEFAULT_CONTROLLER_ID, PAGE)).hasSize(2);
assertThat(countActionStatusAll()).isEqualTo(4); assertThat(countActionStatusAll()).isEqualTo(4);
assertThat(deploymentManagement.findActionStatusByAction(PAGE, action.getId()).getContent()) assertThat(deploymentManagement.findActionStatusByAction(action.getId(), PAGE).getContent())
.haveAtLeast(1, new ActionStatusCondition(Status.ERROR)); .haveAtLeast(1, new ActionStatusCondition(Status.ERROR));
assertThat(deploymentManagement.findActionStatusByAction(PAGE, action2.getId()).getContent()) assertThat(deploymentManagement.findActionStatusByAction(action2.getId(), PAGE).getContent())
.haveAtLeast(1, new ActionStatusCondition(Status.FINISHED)); .haveAtLeast(1, new ActionStatusCondition(Status.FINISHED));
} }
@@ -605,8 +605,8 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
assertActionStatusCount(10, 7, 1, 1, 1); assertActionStatusCount(10, 7, 1, 1, 1);
assertTargetCountByStatus(0, 0, 1); assertTargetCountByStatus(0, 0, 1);
assertThat(targetManagement.findByInstalledDistributionSet(PAGE, ds.getId())).hasSize(1); assertThat(targetManagement.findByInstalledDistributionSet(ds.getId(), PAGE)).hasSize(1);
assertThat(targetManagement.findByAssignedDistributionSet(PAGE, ds.getId())).hasSize(1); assertThat(targetManagement.findByAssignedDistributionSet(ds.getId(), PAGE)).hasSize(1);
} }
@Test @Test
@@ -626,7 +626,7 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
assignDistributionSet(savedSet, Collections.singletonList(savedTarget)).getAssignedEntity().iterator().next(); assignDistributionSet(savedSet, Collections.singletonList(savedTarget)).getAssignedEntity().iterator().next();
assignDistributionSet(savedSet2, Collections.singletonList(testdataFactory.createTarget("4713"))); assignDistributionSet(savedSet2, Collections.singletonList(testdataFactory.createTarget("4713")));
final Action updateAction = deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId()).getContent().get(0); final Action updateAction = deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE).getContent().get(0);
// action exists but is not assigned to this target // action exists but is not assigned to this target
postDeploymentFeedback("4713", updateAction.getId(), getJsonActionFeedback(DdiStatus.ExecutionStatus.PROCEEDING, postDeploymentFeedback("4713", updateAction.getId(), getJsonActionFeedback(DdiStatus.ExecutionStatus.PROCEEDING,
@@ -740,7 +740,7 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
assertTargetCountByStatus(1, 0, 0); assertTargetCountByStatus(1, 0, 0);
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, target.getControllerId())).hasSize(1); assertThat(deploymentManagement.findActiveActionsByTarget(target.getControllerId(), PAGE)).hasSize(1);
assertThat(countActionStatusAll()).isEqualTo(actionStatusCount); assertThat(countActionStatusAll()).isEqualTo(actionStatusCount);
assertThat(findActionStatusAll(PAGE).getContent()) assertThat(findActionStatusAll(PAGE).getContent())
.haveAtLeast(minActionStatusCountInPage, new ActionStatusCondition(Status.RUNNING)); .haveAtLeast(minActionStatusCountInPage, new ActionStatusCondition(Status.RUNNING));
@@ -748,7 +748,7 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
private Target createTargetAndAssertNoActiveActions() { private Target createTargetAndAssertNoActiveActions() {
final Target savedTarget = testdataFactory.createTarget(DdiDeploymentBaseTest.DEFAULT_CONTROLLER_ID); final Target savedTarget = testdataFactory.createTarget(DdiDeploymentBaseTest.DEFAULT_CONTROLLER_ID);
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).isEmpty(); assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE)).isEmpty();
assertThat(deploymentManagement.countActionsAll()).isZero(); assertThat(deploymentManagement.countActionsAll()).isZero();
assertThat(countActionStatusAll()).isZero(); assertThat(countActionStatusAll()).isZero();
return savedTarget; return savedTarget;
@@ -767,15 +767,15 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
final Optional<DistributionSet> installedDs) { final Optional<DistributionSet> installedDs) {
final Target myT = targetManagement.getByControllerID(DdiDeploymentBaseTest.DEFAULT_CONTROLLER_ID).get(); final Target myT = targetManagement.getByControllerID(DdiDeploymentBaseTest.DEFAULT_CONTROLLER_ID).get();
assertThat(myT.getUpdateStatus()).isEqualTo(updateStatus); assertThat(myT.getUpdateStatus()).isEqualTo(updateStatus);
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, myT.getControllerId())).hasSize(activeActions); assertThat(deploymentManagement.findActiveActionsByTarget(myT.getControllerId(), PAGE)).hasSize(activeActions);
assertThat(deploymentManagement.getAssignedDistributionSet(myT.getControllerId())).isEqualTo(ds); assertThat(deploymentManagement.getAssignedDistributionSet(myT.getControllerId())).isEqualTo(ds);
assertThat(deploymentManagement.getInstalledDistributionSet(myT.getControllerId())).isEqualTo(installedDs); assertThat(deploymentManagement.getInstalledDistributionSet(myT.getControllerId())).isEqualTo(installedDs);
} }
private void assertTargetCountByStatus(final int pending, final int error, final int inSync) { private void assertTargetCountByStatus(final int pending, final int error, final int inSync) {
assertThat(targetManagement.findByUpdateStatus(PageRequest.of(0, 10), TargetUpdateStatus.PENDING)).hasSize(pending); assertThat(targetManagement.findByUpdateStatus(TargetUpdateStatus.PENDING, PageRequest.of(0, 10))).hasSize(pending);
assertThat(targetManagement.findByUpdateStatus(PageRequest.of(0, 10), TargetUpdateStatus.ERROR)).hasSize(error); assertThat(targetManagement.findByUpdateStatus(TargetUpdateStatus.ERROR, PageRequest.of(0, 10))).hasSize(error);
assertThat(targetManagement.findByUpdateStatus(PageRequest.of(0, 10), TargetUpdateStatus.IN_SYNC)).hasSize(inSync); assertThat(targetManagement.findByUpdateStatus(TargetUpdateStatus.IN_SYNC, PageRequest.of(0, 10))).hasSize(inSync);
} }
private void assertActionStatusCount(final int total, final int running, final int warning, final int finished, final int canceled) { private void assertActionStatusCount(final int total, final int running, final int warning, final int finished, final int canceled) {
@@ -789,7 +789,7 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
private void assertStatusAndActiveActionsCount(final TargetUpdateStatus status, final int activeActions) { private void assertStatusAndActiveActionsCount(final TargetUpdateStatus status, final int activeActions) {
final Target target = targetManagement.getByControllerID(DdiDeploymentBaseTest.DEFAULT_CONTROLLER_ID).get(); final Target target = targetManagement.getByControllerID(DdiDeploymentBaseTest.DEFAULT_CONTROLLER_ID).get();
assertThat(target.getUpdateStatus()).isEqualTo(status); assertThat(target.getUpdateStatus()).isEqualTo(status);
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, target.getControllerId())).hasSize(activeActions); assertThat(deploymentManagement.findActiveActionsByTarget(target.getControllerId(), PAGE)).hasSize(activeActions);
} }
private Page<ActionStatus> findActionStatusAll(final Pageable pageable) { private Page<ActionStatus> findActionStatusAll(final Pageable pageable) {

View File

@@ -452,7 +452,7 @@ class DdiInstalledBaseTest extends AbstractDDiApiIntegrationTest {
// Action is still finished after calling installedBase // Action is still finished after calling installedBase
final Iterable<ActionStatus> actionStatusMessages = deploymentManagement final Iterable<ActionStatus> actionStatusMessages = deploymentManagement
.findActionStatusByAction(PageRequest.of(0, 100, Sort.Direction.DESC, "id"), actionId); .findActionStatusByAction(actionId, PageRequest.of(0, 100, Sort.Direction.DESC, "id"));
assertThat(actionStatusMessages).hasSize(2); assertThat(actionStatusMessages).hasSize(2);
final ActionStatus actionStatusMessage = actionStatusMessages.iterator().next(); final ActionStatus actionStatusMessage = actionStatusMessages.iterator().next();
assertThat(actionStatusMessage.getStatus()).isEqualTo(Action.Status.FINISHED); assertThat(actionStatusMessage.getStatus()).isEqualTo(Action.Status.FINISHED);
@@ -538,7 +538,7 @@ class DdiInstalledBaseTest extends AbstractDDiApiIntegrationTest {
final DistributionSet ds = testdataFactory.createDistributionSet(""); final DistributionSet ds = testdataFactory.createDistributionSet("");
Target savedTarget = testdataFactory.createTarget("911"); Target savedTarget = testdataFactory.createTarget("911");
savedTarget = getFirstAssignedTarget(assignDistributionSet(ds.getId(), savedTarget.getControllerId())); savedTarget = getFirstAssignedTarget(assignDistributionSet(ds.getId(), savedTarget.getControllerId()));
final Action savedAction = deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId()).getContent().get(0); final Action savedAction = deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE).getContent().get(0);
postDeploymentFeedback(savedTarget.getControllerId(), savedAction.getId(), postDeploymentFeedback(savedTarget.getControllerId(), savedAction.getId(),
getJsonActionFeedback(DdiStatus.ExecutionStatus.SCHEDULED, DdiResult.FinalResult.NONE, getJsonActionFeedback(DdiStatus.ExecutionStatus.SCHEDULED, DdiResult.FinalResult.NONE,
@@ -633,7 +633,7 @@ class DdiInstalledBaseTest extends AbstractDDiApiIntegrationTest {
private Target createTargetAndAssertNoActiveActions() { private Target createTargetAndAssertNoActiveActions() {
final Target savedTarget = testdataFactory.createTarget(CONTROLLER_ID); final Target savedTarget = testdataFactory.createTarget(CONTROLLER_ID);
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).isEmpty(); assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE)).isEmpty();
assertThat(deploymentManagement.countActionsAll()).isZero(); assertThat(deploymentManagement.countActionsAll()).isZero();
assertThat(actionStatusRepository.count()).isZero(); assertThat(actionStatusRepository.count()).isZero();
return savedTarget; return savedTarget;

View File

@@ -241,7 +241,7 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
assignDistributionSet(ds.getId(), controllerId); assignDistributionSet(ds.getId(), controllerId);
final Action updateAction = deploymentManagement.findActiveActionsByTarget(PAGE, target.getControllerId()) final Action updateAction = deploymentManagement.findActiveActionsByTarget(target.getControllerId(), PAGE)
.getContent().get(0); .getContent().get(0);
final String etagWithFirstUpdate = mvc final String etagWithFirstUpdate = mvc
.perform(get(CONTROLLER_BASE, tenantAware.getCurrentTenant(), controllerId) .perform(get(CONTROLLER_BASE, tenantAware.getCurrentTenant(), controllerId)
@@ -287,7 +287,7 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
assignDistributionSet(ds2.getId(), controllerId); assignDistributionSet(ds2.getId(), controllerId);
final Action updateAction2 = deploymentManagement.findActiveActionsByTarget(PAGE, target.getControllerId()).getContent().get(0); final Action updateAction2 = deploymentManagement.findActiveActionsByTarget(target.getControllerId(), PAGE).getContent().get(0);
mvc.perform(get(CONTROLLER_BASE, tenantAware.getCurrentTenant(), controllerId) mvc.perform(get(CONTROLLER_BASE, tenantAware.getCurrentTenant(), controllerId)
.header("If-None-Match", etagAfterInstallation).accept(MediaType.APPLICATION_JSON) .header("If-None-Match", etagAfterInstallation).accept(MediaType.APPLICATION_JSON)
@@ -398,7 +398,7 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
final DistributionSet ds = testdataFactory.createDistributionSet(""); final DistributionSet ds = testdataFactory.createDistributionSet("");
Target savedTarget = testdataFactory.createTarget("911"); Target savedTarget = testdataFactory.createTarget("911");
savedTarget = getFirstAssignedTarget(assignDistributionSet(ds.getId(), savedTarget.getControllerId())); savedTarget = getFirstAssignedTarget(assignDistributionSet(ds.getId(), savedTarget.getControllerId()));
final Action savedAction = deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId()) final Action savedAction = deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE)
.getContent().get(0); .getContent().get(0);
sendDeploymentActionFeedback(savedTarget, savedAction, "proceeding", null) sendDeploymentActionFeedback(savedTarget, savedAction, "proceeding", null)
.andDo(MockMvcResultPrinter.print()) .andDo(MockMvcResultPrinter.print())
@@ -460,7 +460,7 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
final DistributionSet ds = testdataFactory.createDistributionSet(""); final DistributionSet ds = testdataFactory.createDistributionSet("");
Target savedTarget = testdataFactory.createTarget("911"); Target savedTarget = testdataFactory.createTarget("911");
savedTarget = getFirstAssignedTarget(assignDistributionSet(ds.getId(), savedTarget.getControllerId())); savedTarget = getFirstAssignedTarget(assignDistributionSet(ds.getId(), savedTarget.getControllerId()));
final Action savedAction = deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId()) final Action savedAction = deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE)
.getContent().get(0); .getContent().get(0);
sendDeploymentActionFeedback(savedTarget, savedAction, "scheduled", null, TARGET_SCHEDULED_INSTALLATION_MSG) sendDeploymentActionFeedback(savedTarget, savedAction, "scheduled", null, TARGET_SCHEDULED_INSTALLATION_MSG)
@@ -504,7 +504,7 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
final DistributionSet ds = testdataFactory.createDistributionSet(""); final DistributionSet ds = testdataFactory.createDistributionSet("");
Target savedTarget = testdataFactory.createTarget("911"); Target savedTarget = testdataFactory.createTarget("911");
savedTarget = getFirstAssignedTarget(assignDistributionSet(ds.getId(), savedTarget.getControllerId())); savedTarget = getFirstAssignedTarget(assignDistributionSet(ds.getId(), savedTarget.getControllerId()));
final Action savedAction = deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId()).getContent().get(0); final Action savedAction = deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE).getContent().get(0);
sendDeploymentActionFeedback(savedTarget, savedAction, "scheduled", null, TARGET_SCHEDULED_INSTALLATION_MSG) sendDeploymentActionFeedback(savedTarget, savedAction, "scheduled", null, TARGET_SCHEDULED_INSTALLATION_MSG)
.andDo(MockMvcResultPrinter.print()) .andDo(MockMvcResultPrinter.print())
@@ -548,7 +548,7 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
final DistributionSet ds = testdataFactory.createDistributionSet(""); final DistributionSet ds = testdataFactory.createDistributionSet("");
Target savedTarget = testdataFactory.createTarget("911"); Target savedTarget = testdataFactory.createTarget("911");
savedTarget = getFirstAssignedTarget(assignDistributionSet(ds.getId(), savedTarget.getControllerId())); savedTarget = getFirstAssignedTarget(assignDistributionSet(ds.getId(), savedTarget.getControllerId()));
final Action savedAction = deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId()) final Action savedAction = deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE)
.getContent().get(0); .getContent().get(0);
sendDeploymentActionFeedback(savedTarget, savedAction, "scheduled", null, TARGET_SCHEDULED_INSTALLATION_MSG) sendDeploymentActionFeedback(savedTarget, savedAction, "scheduled", null, TARGET_SCHEDULED_INSTALLATION_MSG)
@@ -636,7 +636,7 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
mvc.perform(get(CONTROLLER_BASE, "default-tenant", "1911")) mvc.perform(get(CONTROLLER_BASE, "default-tenant", "1911"))
.andExpect(status().isOk()); .andExpect(status().isOk());
final Action action = deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId()).getContent().get(0); final Action action = deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE).getContent().get(0);
mvc.perform(get(DEPLOYMENT_BASE, tenantAware.getCurrentTenant(), "1911", action.getId()) mvc.perform(get(DEPLOYMENT_BASE, tenantAware.getCurrentTenant(), "1911", action.getId())
.accept(MediaType.APPLICATION_JSON)) .accept(MediaType.APPLICATION_JSON))
@@ -658,7 +658,7 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
mvc.perform(get(CONTROLLER_BASE, "default-tenant", "1911")) mvc.perform(get(CONTROLLER_BASE, "default-tenant", "1911"))
.andExpect(status().isOk()); .andExpect(status().isOk());
final Action action = deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId()).getContent().get(0); final Action action = deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE).getContent().get(0);
mvc.perform(get(DEPLOYMENT_BASE, tenantAware.getCurrentTenant(), "1911", action.getId()) mvc.perform(get(DEPLOYMENT_BASE, tenantAware.getCurrentTenant(), "1911", action.getId())
.accept(MediaType.APPLICATION_JSON)) .accept(MediaType.APPLICATION_JSON))
@@ -695,7 +695,7 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
@Step @Step
private void assertAttributesUpdateNotRequestedAfterFailedDeployment(Target target, final DistributionSet ds) throws Exception { private void assertAttributesUpdateNotRequestedAfterFailedDeployment(Target target, final DistributionSet ds) throws Exception {
target = getFirstAssignedTarget(assignDistributionSet(ds.getId(), target.getControllerId())); target = getFirstAssignedTarget(assignDistributionSet(ds.getId(), target.getControllerId()));
final Action action = deploymentManagement.findActiveActionsByTarget(PAGE, target.getControllerId()).getContent().get(0); final Action action = deploymentManagement.findActiveActionsByTarget(target.getControllerId(), PAGE).getContent().get(0);
sendDeploymentActionFeedback(target, action, "closed", "failure") sendDeploymentActionFeedback(target, action, "closed", "failure")
.andExpect(status().isOk()); .andExpect(status().isOk());
assertThatAttributesUpdateIsNotRequested(target.getControllerId()); assertThatAttributesUpdateIsNotRequested(target.getControllerId());
@@ -704,7 +704,7 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
@Step @Step
private void assertAttributesUpdateRequestedAfterSuccessfulDeployment(Target target, final DistributionSet ds) throws Exception { private void assertAttributesUpdateRequestedAfterSuccessfulDeployment(Target target, final DistributionSet ds) throws Exception {
target = getFirstAssignedTarget(assignDistributionSet(ds.getId(), target.getControllerId())); target = getFirstAssignedTarget(assignDistributionSet(ds.getId(), target.getControllerId()));
final Action action = deploymentManagement.findActiveActionsByTarget(PAGE, target.getControllerId()).getContent().get(0); final Action action = deploymentManagement.findActiveActionsByTarget(target.getControllerId(), PAGE).getContent().get(0);
sendDeploymentActionFeedback(target, action, "closed", null) sendDeploymentActionFeedback(target, action, "closed", null)
.andExpect(status().isOk()); .andExpect(status().isOk());
assertThatAttributesUpdateIsRequested(target.getControllerId()); assertThatAttributesUpdateIsRequested(target.getControllerId());

View File

@@ -163,9 +163,9 @@ class DosFilterTest extends AbstractDDiApiIntegrationTest {
final List<Target> toAssign = Collections.singletonList(target); final List<Target> toAssign = Collections.singletonList(target);
assignDistributionSet(ds, toAssign); assignDistributionSet(ds, toAssign);
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, target.getControllerId())).hasSize(1); assertThat(deploymentManagement.findActiveActionsByTarget(target.getControllerId(), PAGE)).hasSize(1);
final Action uaction = deploymentManagement.findActiveActionsByTarget(PAGE, target.getControllerId()).getContent().get(0); final Action uaction = deploymentManagement.findActiveActionsByTarget(target.getControllerId(), PAGE).getContent().get(0);
return uaction.getId(); return uaction.getId();
} }

View File

@@ -593,7 +593,7 @@ public class AmqpMessageDispatcherService extends BaseAmqpService {
private List<SoftwareModuleMetadata> getSoftwareModuleMetadata(final SoftwareModule module) { private List<SoftwareModuleMetadata> getSoftwareModuleMetadata(final SoftwareModule module) {
return softwareModuleManagement.findMetaDataBySoftwareModuleIdAndTargetVisible( return softwareModuleManagement.findMetaDataBySoftwareModuleIdAndTargetVisible(
PageRequest.of(0, RepositoryConstants.MAX_META_DATA_COUNT), module.getId()).getContent(); module.getId(), PageRequest.of(0, RepositoryConstants.MAX_META_DATA_COUNT)).getContent();
} }
private void sendBatchUpdateMessage( private void sendBatchUpdateMessage(

View File

@@ -1146,12 +1146,12 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
try { try {
SecurityContextSwitch.runAsPrivileged(() -> { SecurityContextSwitch.runAsPrivileged(() -> {
final List<ActionStatus> actionStatusList = deploymentManagement final List<ActionStatus> actionStatusList = deploymentManagement
.findActionStatusByAction(PAGE, actionId).getContent(); .findActionStatusByAction(actionId, PAGE).getContent();
// Check correlation ID // Check correlation ID
final List<String> messagesFromServer = actionStatusList.stream() final List<String> messagesFromServer = actionStatusList.stream()
.flatMap(actionStatus -> deploymentManagement .flatMap(actionStatus -> deploymentManagement
.findMessagesByActionStatusId(PAGE, actionStatus.getId()).getContent().stream()) .findMessagesByActionStatusId(actionStatus.getId(), PAGE).getContent().stream())
.filter(Objects::nonNull) .filter(Objects::nonNull)
.filter(message -> message .filter(message -> message
.startsWith(RepositoryConstants.SERVER_MESSAGE_PREFIX + "DMF message")) .startsWith(RepositoryConstants.SERVER_MESSAGE_PREFIX + "DMF message"))
@@ -1184,7 +1184,7 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
try { try {
SecurityContextSwitch.runAsPrivileged(() -> { SecurityContextSwitch.runAsPrivileged(() -> {
final List<ActionStatus> actionStatusList = deploymentManagement final List<ActionStatus> actionStatusList = deploymentManagement
.findActionStatusByAction(PAGE, actionId).getContent(); .findActionStatusByAction(actionId, PAGE).getContent();
assertThat(actionStatusList).hasSize(statusListCount); assertThat(actionStatusList).hasSize(statusListCount);
final List<Status> status = actionStatusList.stream().map(ActionStatus::getStatus) final List<Status> status = actionStatusList.stream().map(ActionStatus::getStatus)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -206,7 +206,7 @@ public final class MgmtTargetMapper {
return actionStatus.stream() return actionStatus.stream()
.map(status -> toResponse(status, .map(status -> toResponse(status,
deploymentManagement.findMessagesByActionStatusId( 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())) .getContent()))
.toList(); .toList();
} }

View File

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

View File

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

View File

@@ -275,8 +275,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte
+ filterQuery.getId(); + filterQuery.getId();
final String distributionsetHrefPrefix = "http://localhost" + MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING; 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( mvc.perform(
post(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + filterQuery.getId() + "/autoAssignDS") post(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + filterQuery.getId() + "/autoAssignDS")
.content("{\"id\":" + set.getId() + "}").contentType(MediaType.APPLICATION_JSON)) .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 PageRequest pageRequest = PageRequest.of(0, 1000, Direction.ASC, ActionFields.ID.getJpaEntityFieldName());
final Action action = deploymentManagement.findActionsByTarget(knownTargetId, pageRequest).getContent().get(0); 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); .stream().sorted((e1, e2) -> Long.compare(e2.getId(), e1.getId())).toList().get(0);
mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/"
@@ -1337,7 +1337,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
final String knownTargetId = "targetId"; final String knownTargetId = "targetId";
final Action action = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId).get(0); final Action action = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId).get(0);
// retrieve list in default descending order for actionstaus entries // 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())) .getContent().stream().sorted((e1, e2) -> Long.compare(e2.getId(), e1.getId()))
.toList(); .toList();
@@ -1365,7 +1365,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
void getActionsStatusSortedByReportedAt() throws Exception { void getActionsStatusSortedByReportedAt() throws Exception {
final String knownTargetId = "targetId"; final String knownTargetId = "targetId";
final Action action = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId).get(0); 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)) .getContent().stream().sorted(Comparator.comparingLong(Identifiable::getId))
.toList(); .toList();
@@ -1414,7 +1414,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
final String knownTargetId = "targetId"; final String knownTargetId = "targetId";
final Action action = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId).get(0); 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())) .getContent().stream().sorted((e1, e2) -> Long.compare(e1.getId(), e2.getId()))
.toList(); .toList();
@@ -1668,7 +1668,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
implicitLock(set); implicitLock(set);
final List<Action> findActiveActionsByTarget = deploymentManagement final List<Action> findActiveActionsByTarget = deploymentManagement
.findActiveActionsByTarget(PAGE, target.getControllerId()).getContent(); .findActiveActionsByTarget(target.getControllerId(), PAGE).getContent();
assertThat(findActiveActionsByTarget).hasSize(1); assertThat(findActiveActionsByTarget).hasSize(1);
assertThat(findActiveActionsByTarget.get(0).getActionType()).isEqualTo(ActionType.TIMEFORCED); assertThat(findActiveActionsByTarget.get(0).getActionType()).isEqualTo(ActionType.TIMEFORCED);
assertThat(findActiveActionsByTarget.get(0).getForcedTime()).isEqualTo(forceTime); 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.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Random; import java.util.Random;
import java.util.stream.Collectors;
import io.qameta.allure.Description; import io.qameta.allure.Description;
import io.qameta.allure.Feature; 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.json.model.ExceptionInfo;
import org.eclipse.hawkbit.rest.util.JsonBuilder; import org.eclipse.hawkbit.rest.util.JsonBuilder;
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter; 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.junit.jupiter.api.Test;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.ResultActions; import org.springframework.test.web.servlet.ResultActions;
@@ -163,11 +158,11 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
.andExpect(status().isCreated()) .andExpect(status().isCreated())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)); .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.getName()).isEqualTo(tagOne.getName());
assertThat(createdOne.getDescription()).isEqualTo(tagOne.getDescription()); assertThat(createdOne.getDescription()).isEqualTo(tagOne.getDescription());
assertThat(createdOne.getColour()).isEqualTo(tagOne.getColour()); 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.getName()).isEqualTo(tagTwo.getName());
assertThat(createdTwo.getDescription()).isEqualTo(tagTwo.getDescription()); assertThat(createdTwo.getDescription()).isEqualTo(tagTwo.getDescription());
assertThat(createdTwo.getColour()).isEqualTo(tagTwo.getColour()); assertThat(createdTwo.getColour()).isEqualTo(tagTwo.getColour());
@@ -196,7 +191,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
.andExpect(status().isOk()) .andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)); .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.getName()).isEqualTo(update.getName());
assertThat(updated.getDescription()).isEqualTo(update.getDescription()); assertThat(updated.getDescription()).isEqualTo(update.getDescription());
assertThat(updated.getColour()).isEqualTo(update.getColour()); assertThat(updated.getColour()).isEqualTo(update.getColour());
@@ -303,7 +298,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
.andDo(MockMvcResultPrinter.print()) .andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk()); .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()); assertThat(updated.stream().map(Target::getControllerId).toList()).containsOnly(assigned.getControllerId());
} }
@@ -325,7 +320,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
.andDo(MockMvcResultPrinter.print()) .andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk()); .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()) assertThat(updated.stream().map(Target::getControllerId).toList())
.containsOnly(assigned0.getControllerId(), assigned1.getControllerId()); .containsOnly(assigned0.getControllerId(), assigned1.getControllerId());
} }
@@ -366,7 +361,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
Collections.sort(notFound); Collections.sort(notFound);
assertThat(notFound).isEqualTo(missing); assertThat(notFound).isEqualTo(missing);
}); });
assertThat(targetManagement.findByTag(PAGE, tag.getId()).getContent()).isEmpty(); assertThat(targetManagement.findByTag(tag.getId(), PAGE).getContent()).isEmpty();
} }
@Test @Test
@@ -407,7 +402,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
Collections.sort(notFound); Collections.sort(notFound);
assertThat(notFound).isEqualTo(missing); 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()); .isEqualTo(targets.stream().sorted().toList());
} }
@@ -440,7 +435,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
.contentType(MediaType.APPLICATION_JSON)) .contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print()) .andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk()); .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()); .isEqualTo(targets.stream().sorted().toList());
} }
@@ -463,7 +458,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
.andDo(MockMvcResultPrinter.print()) .andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk()); .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()) assertThat(updated.stream().map(Target::getControllerId).toList())
.containsOnly(assigned.getControllerId()); .containsOnly(assigned.getControllerId());
} }
@@ -489,7 +484,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
.andDo(MockMvcResultPrinter.print()) .andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk()); .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()) assertThat(updated.stream().map(Target::getControllerId).toList())
.containsOnly(assigned.getControllerId()); .containsOnly(assigned.getControllerId());
} }
@@ -533,7 +528,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
Collections.sort(notFound); Collections.sort(notFound);
assertThat(notFound).isEqualTo(missing); 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()); .isEqualTo(targets.stream().sorted().toList());
} }
@@ -577,7 +572,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
Collections.sort(notFound); Collections.sort(notFound);
assertThat(notFound).isEqualTo(missing); assertThat(notFound).isEqualTo(missing);
}); });
assertThat(targetManagement.findByTag(PAGE, tag.getId()).getContent()).isEmpty(); assertThat(targetManagement.findByTag(tag.getId(), PAGE).getContent()).isEmpty();
} }
@Test @Test
@@ -611,6 +606,6 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT
.contentType(MediaType.APPLICATION_JSON)) .contentType(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print()) .andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk()); .andExpect(status().isOk());
assertThat(targetManagement.findByTag(PAGE, tag.getId()).getContent()).isEmpty(); assertThat(targetManagement.findByTag(tag.getId(), PAGE).getContent()).isEmpty();
} }
} }

View File

@@ -45,6 +45,6 @@ List<Target> getByControllerID(@NotEmpty Collection<String> controllerId);
Optional<Target> findFirstByDescription(@NotEmpty String description); Optional<Target> findFirstByDescription(@NotEmpty String description);
// Query/search repository (page might be empty, no EntityNotFoundException) (note: pageReq always first in signature) // Query/search repository (page might be empty, no EntityNotFoundException) (note: pageReq always first in signature)
Page<Target> findByAssignedDistributionSet(@NotNull Pageable pageReq, @NotNull Long distributionSetID); Page<Target> findByAssignedDistributionSet(@NotNull Long distributionSetID, @NotNull Pageable pageable);
``` ```

View File

@@ -114,13 +114,13 @@ public interface ArtifactManagement {
/** /**
* Get local artifact for a base software module. * Get local artifact for a base software module.
* *
* @param pageReq Pageable parameter
* @param softwareModuleId software module id * @param softwareModuleId software module id
* @param pageable Pageable parameter
* @return Page<Artifact> * @return Page<Artifact>
* @throws EntityNotFoundException if software module with given ID does not exist * @throws EntityNotFoundException if software module with given ID does not exist
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Page<Artifact> findBySoftwareModule(@NotNull Pageable pageReq, long softwareModuleId); Page<Artifact> findBySoftwareModule(long softwareModuleId, @NotNull Pageable pageable);
/** /**
* Count local artifacts for a base software module. * Count local artifacts for a base software module.

View File

@@ -138,13 +138,13 @@ public interface ControllerManagement {
/** /**
* Retrieves all the {@link ActionStatus} entries of the given {@link Action}. * Retrieves all the {@link ActionStatus} entries of the given {@link Action}.
* *
* @param pageReq pagination parameter
* @param actionId to be filtered on * @param actionId to be filtered on
* @param pageable pagination parameter
* @return the corresponding {@link Page} of {@link ActionStatus} * @return the corresponding {@link Page} of {@link ActionStatus}
* @throws EntityNotFoundException if action with given ID does not exist * @throws EntityNotFoundException if action with given ID does not exist
*/ */
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER) @PreAuthorize(SpringEvalExpressions.IS_CONTROLLER)
Page<ActionStatus> findActionStatusByAction(@NotNull Pageable pageReq, long actionId); Page<ActionStatus> findActionStatusByAction(long actionId, @NotNull Pageable pageable);
/** /**
* Register new target in the repository (plug-and-play) and in case it already exists updates {@link Target#getAddress()} and * Register new target in the repository (plug-and-play) and in case it already exists updates {@link Target#getAddress()} and

View File

@@ -46,14 +46,12 @@ import org.springframework.data.domain.Slice;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
/** /**
* A DeploymentManagement service provides operations for the deployment of * A DeploymentManagement service provides operations for the deployment of {@link DistributionSet}s to {@link Target}s.
* {@link DistributionSet}s to {@link Target}s.
*/ */
public interface DeploymentManagement { public interface DeploymentManagement {
/** /**
* build a {@link DeploymentRequest} for a target distribution set * build a {@link DeploymentRequest} for a target distribution set assignment
* assignment
* *
* @param controllerId ID of target * @param controllerId ID of target
* @param distributionSetId ID of distribution set * @param distributionSetId ID of distribution set
@@ -64,26 +62,23 @@ public interface DeploymentManagement {
} }
/** /**
* Assigns {@link DistributionSet}s to {@link Target}s according to the * Assigns {@link DistributionSet}s to {@link Target}s according to the {@link DeploymentRequest}.
* {@link DeploymentRequest}.
* *
* @param deploymentRequests information about all target-ds-assignments that shall be made * @param deploymentRequests information about all target-ds-assignments that shall be made
* @return the list of assignment results * @return the list of assignment results
* @throws IncompleteDistributionSetException if mandatory {@link SoftwareModuleType} are not assigned as * @throws IncompleteDistributionSetException if mandatory {@link SoftwareModuleType} are not assigned as
* defined by the {@link DistributionSetType}. * defined by the {@link DistributionSetType}.
* @throws EntityNotFoundException if either provided {@link DistributionSet} or {@link Target}s * @throws EntityNotFoundException if either provided {@link DistributionSet} or {@link Target}s do not exist
* do not exist
* @throws AssignmentQuotaExceededException if the maximum number of targets the distribution set can be * @throws AssignmentQuotaExceededException if the maximum number of targets the distribution set can be
* assigned to at once is exceeded * assigned to at once is exceeded
* @throws MultiAssignmentIsNotEnabledException if the request results in multiple assignments to the same * @throws MultiAssignmentIsNotEnabledException if the request results in multiple assignments to the same
* target and multiassignment is disabled * target and multi-assignment is disabled
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_UPDATE_TARGET) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_UPDATE_TARGET)
List<DistributionSetAssignmentResult> assignDistributionSets(@Valid @NotEmpty List<DeploymentRequest> deploymentRequests); List<DistributionSetAssignmentResult> assignDistributionSets(@Valid @NotEmpty List<DeploymentRequest> deploymentRequests);
/** /**
* Assigns {@link DistributionSet}s to {@link Target}s according to the * Assigns {@link DistributionSet}s to {@link Target}s according to the {@link DeploymentRequest}.
* {@link DeploymentRequest}.
* *
* @param initiatedBy the username of the user who initiated the assignment * @param initiatedBy the username of the user who initiated the assignment
* @param deploymentRequests information about all target-ds-assignments that shall be made * @param deploymentRequests information about all target-ds-assignments that shall be made
@@ -91,21 +86,18 @@ public interface DeploymentManagement {
* @return the list of assignment results * @return the list of assignment results
* @throws IncompleteDistributionSetException if mandatory {@link SoftwareModuleType} are not assigned as * @throws IncompleteDistributionSetException if mandatory {@link SoftwareModuleType} are not assigned as
* defined by the {@link DistributionSetType}. * defined by the {@link DistributionSetType}.
* @throws EntityNotFoundException if either provided {@link DistributionSet} or {@link Target}s * @throws EntityNotFoundException if either provided {@link DistributionSet} or {@link Target}s do not exist
* do not exist
* @throws AssignmentQuotaExceededException if the maximum number of targets the distribution set can be * @throws AssignmentQuotaExceededException if the maximum number of targets the distribution set can be
* assigned to at once is exceeded * assigned to at once is exceeded
* @throws MultiAssignmentIsNotEnabledException if the request results in multiple assignments to the same * @throws MultiAssignmentIsNotEnabledException if the request results in multiple assignments to the same
* target and multiassignment is disabled * target and multi-assignment is disabled
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_UPDATE_TARGET) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_UPDATE_TARGET)
List<DistributionSetAssignmentResult> assignDistributionSets(String initiatedBy, List<DistributionSetAssignmentResult> assignDistributionSets(
@Valid @NotEmpty List<DeploymentRequest> deploymentRequests, String actionMessage); String initiatedBy, @Valid @NotEmpty List<DeploymentRequest> deploymentRequests, String actionMessage);
/** /**
* Registers "offline" assignments. "offline" assignment means adding a * Registers "offline" assignments. "offline" assignment means adding a completed action for a {@link DistributionSet} to a {@link Target}.
* completed action for a {@link DistributionSet} to a {@link Target}.
*
* The handling differs to hawkBit-managed updates by means that:<br/> * The handling differs to hawkBit-managed updates by means that:<br/>
* *
* <ol type="A"> * <ol type="A">
@@ -117,17 +109,14 @@ public interface DeploymentManagement {
* <li>does not send a {@link TargetAssignDistributionSetEvent}.</li> * <li>does not send a {@link TargetAssignDistributionSetEvent}.</li>
* </ol> * </ol>
* *
* @param assignments target IDs with the respective distribution set ID which they * @param assignments target IDs with the respective distribution set ID which they are supposed to be assigned to
* are supposed to be assigned to
* @return the assignment results * @return the assignment results
* @throws IncompleteDistributionSetException if mandatory {@link SoftwareModuleType} are not assigned as * @throws IncompleteDistributionSetException if mandatory {@link SoftwareModuleType} are not assigned as
* defined by the {@link DistributionSetType}. * defined by the {@link DistributionSetType}.
* @throws EntityNotFoundException if either provided {@link DistributionSet} or {@link Target}s * @throws EntityNotFoundException if either provided {@link DistributionSet} or {@link Target}s do not exist
* do not exist * @throws AssignmentQuotaExceededException if the maximum number of targets the distribution set can be assigned to at once is exceeded
* @throws AssignmentQuotaExceededException if the maximum number of targets the distribution set can be
* assigned to at once is exceeded
* @throws MultiAssignmentIsNotEnabledException if the request results in multiple assignments to the same * @throws MultiAssignmentIsNotEnabledException if the request results in multiple assignments to the same
* target and multiassignment is disabled * target and multi-assignment is disabled
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_UPDATE_TARGET) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_UPDATE_TARGET)
List<DistributionSetAssignmentResult> offlineAssignedDistributionSets(Collection<Entry<String, Long>> assignments, String initiatedBy); List<DistributionSetAssignmentResult> offlineAssignedDistributionSets(Collection<Entry<String, Long>> assignments, String initiatedBy);
@@ -136,14 +125,12 @@ public interface DeploymentManagement {
List<DistributionSetAssignmentResult> offlineAssignedDistributionSets(Collection<Entry<String, Long>> assignments); List<DistributionSetAssignmentResult> offlineAssignedDistributionSets(Collection<Entry<String, Long>> assignments);
/** /**
* Cancels the {@link Action} with the given ID. The method will immediately * Cancels the {@link Action} with the given ID. The method will immediately add a {@link Status#CANCELED} status to the action.
* add a {@link Status#CANCELED} status to the action. However, it might be * However, it might be possible that the controller will continue to work on the cancellation.
* possible that the controller will continue to work on the cancellation.
* *
* @param actionId to be canceled * @param actionId to be canceled
* @return canceled {@link Action} * @return canceled {@link Action}
* @throws CancelActionNotAllowedException in case the given action is not active or is already a cancel * @throws CancelActionNotAllowedException in case the given action is not active or is already a cancel action
* action
* @throws EntityNotFoundException if action with given ID does not exist * @throws EntityNotFoundException if action with given ID does not exist
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
@@ -152,7 +139,7 @@ public interface DeploymentManagement {
/** /**
* Counts all actions associated to a specific target. * Counts all actions associated to a specific target.
* *
* @param rsqlParam rsql query string * @param rsql rsql query string
* @param controllerId the target associated to the actions to count * @param controllerId the target associated to the actions to count
* @return the count value of found actions associated to the target * @return the count value of found actions associated to the target
* @throws RSQLParameterUnsupportedFieldException if a field in the RSQL string is used but not provided by the * @throws RSQLParameterUnsupportedFieldException if a field in the RSQL string is used but not provided by the
@@ -161,11 +148,10 @@ public interface DeploymentManagement {
* @throws EntityNotFoundException if target with given ID does not exist * @throws EntityNotFoundException if target with given ID does not exist
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
long countActionsByTarget(@NotNull String rsqlParam, @NotEmpty String controllerId); long countActionsByTarget(@NotNull String rsql, @NotEmpty String controllerId);
/** /**
* Returns total count of all actions * Returns total count of all actions<p/>
* <p/>
* No access control applied. * No access control applied.
* *
* @return the total amount of stored actions * @return the total amount of stored actions
@@ -174,15 +160,14 @@ public interface DeploymentManagement {
long countActionsAll(); long countActionsAll();
/** /**
* Counts the actions which match the given query. * Counts the actions which match the given query.<p/>
* <p/>
* No access control applied. * No access control applied.
* *
* @param rsqlParam RSQL query. * @param rsql RSQL query.
* @return the total number of actions matching the given RSQL query. * @return the total number of actions matching the given RSQL query.
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
long countActions(@NotNull String rsqlParam); long countActions(@NotNull String rsql);
/** /**
* Counts all actions associated to a specific target. * Counts all actions associated to a specific target.
@@ -215,37 +200,32 @@ public interface DeploymentManagement {
Slice<Action> findActionsAll(@NotNull Pageable pageable); Slice<Action> findActionsAll(@NotNull Pageable pageable);
/** /**
* Retrieves all {@link Action} entities which match the given RSQL query. * Retrieves all {@link Action} entities which match the given RSQL query.<p/>
* <p/>
* No access control applied. * No access control applied.
* *
* @param rsqlParam RSQL query string * @param rsql RSQL query string
* @param pageable the page request parameter for paging and sorting the result * @param pageable the page request parameter for paging and sorting the result
* @return a paged list of {@link Action}s. * @return a paged list of {@link Action}s.
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Slice<Action> findActions(@NotNull String rsqlParam, @NotNull Pageable pageable); Slice<Action> findActions(@NotNull String rsql, @NotNull Pageable pageable);
/** /**
* Retrieves all {@link Action}s assigned to a specific {@link Target} and a * Retrieves all {@link Action}s assigned to a specific {@link Target} and a given specification.
* given specification.
* *
* @param rsqlParam rsql query string * @param rsql rsql query string
* @param controllerId the target which must be assigned to the actions * @param controllerId the target which must be assigned to the actions
* @param pageable the page request * @param pageable the page request
* @return a slice of actions assigned to the specific target and the * @return a slice of actions assigned to the specific target and the specification
* specification
* @throws RSQLParameterUnsupportedFieldException if a field in the RSQL string is used but not provided by the * @throws RSQLParameterUnsupportedFieldException if a field in the RSQL string is used but not provided by the
* given {@code fieldNameProvider} * given {@code fieldNameProvider}
* @throws RSQLParameterSyntaxException if the RSQL syntax is wrong * @throws RSQLParameterSyntaxException if the RSQL syntax is wrong
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Slice<Action> findActionsByTarget(@NotNull String rsqlParam, @NotEmpty String controllerId, Slice<Action> findActionsByTarget(@NotNull String rsql, @NotEmpty String controllerId, @NotNull Pageable pageable);
@NotNull Pageable pageable);
/** /**
* Retrieves all {@link Action}s which are referring the given * Retrieves all {@link Action}s which are referring the given {@link Target}.
* {@link Target}.
* *
* @param controllerId the target to find actions for * @param controllerId the target to find actions for
* @param pageable the pageable request to limit, sort the actions * @param pageable the pageable request to limit, sort the actions
@@ -255,16 +235,15 @@ public interface DeploymentManagement {
Slice<Action> findActionsByTarget(@NotEmpty String controllerId, @NotNull Pageable pageable); Slice<Action> findActionsByTarget(@NotEmpty String controllerId, @NotNull Pageable pageable);
/** /**
* Retrieves all the {@link ActionStatus} entries of the given * Retrieves all the {@link ActionStatus} entries of the given {@link Action}.
* {@link Action}.
* *
* @param pageReq pagination parameter
* @param actionId to be filtered on * @param actionId to be filtered on
* @param pageable pagination parameter
* @return the corresponding {@link Page} of {@link ActionStatus} * @return the corresponding {@link Page} of {@link ActionStatus}
* @throws EntityNotFoundException if action with given ID does not exist * @throws EntityNotFoundException if action with given ID does not exist
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Page<ActionStatus> findActionStatusByAction(@NotNull Pageable pageReq, long actionId); Page<ActionStatus> findActionStatusByAction(long actionId, @NotNull Pageable pageable);
/** /**
* Counts all the {@link ActionStatus} entries of the given {@link Action}. * Counts all the {@link ActionStatus} entries of the given {@link Action}.
@@ -277,20 +256,18 @@ public interface DeploymentManagement {
long countActionStatusByAction(long actionId); long countActionStatusByAction(long actionId);
/** /**
* Retrieves all messages for an {@link ActionStatus}. * Retrieves all messages for an {@link ActionStatus}.<p/>
* <p/>
* No entity based access control applied. * No entity based access control applied.
* *
* @param pageable the page request parameter for paging and sorting the result
* @param actionStatusId the id of {@link ActionStatus} to retrieve the messages from * @param actionStatusId the id of {@link ActionStatus} to retrieve the messages from
* @param pageable the page request parameter for paging and sorting the result
* @return a page of messages by a specific {@link ActionStatus} id * @return a page of messages by a specific {@link ActionStatus} id
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Page<String> findMessagesByActionStatusId(@NotNull Pageable pageable, long actionStatusId); Page<String> findMessagesByActionStatusId(long actionStatusId, @NotNull Pageable pageable);
/** /**
* Get the {@link Action} entity for given actionId with all lazy attributes * Get the {@link Action} entity for given actionId with all lazy attributes (i.e. distributionSet, target, target.assignedDs).
* (i.e. distributionSet, target, target.assignedDs).
* *
* @param actionId to be id of the action * @param actionId to be id of the action
* @return the corresponding {@link Action} * @return the corresponding {@link Action}
@@ -301,28 +278,27 @@ public interface DeploymentManagement {
/** /**
* Retrieves all active {@link Action}s of a specific target. * Retrieves all active {@link Action}s of a specific target.
* *
* @param pageable the page request parameter for paging and sorting the result
* @param controllerId the target associated with the actions * @param controllerId the target associated with the actions
* @param pageable the page request parameter for paging and sorting the result
* @return a list of actions associated with the given target * @return a list of actions associated with the given target
* @throws EntityNotFoundException if target with given ID does not exist * @throws EntityNotFoundException if target with given ID does not exist
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Page<Action> findActiveActionsByTarget(@NotNull Pageable pageable, @NotEmpty String controllerId); Page<Action> findActiveActionsByTarget(@NotEmpty String controllerId, @NotNull Pageable pageable);
/** /**
* Retrieves all inactive {@link Action}s of a specific target. * Retrieves all inactive {@link Action}s of a specific target.
* *
* @param pageable the page request parameter for paging and sorting the result
* @param controllerId the target associated with the actions * @param controllerId the target associated with the actions
* @param pageable the page request parameter for paging and sorting the result
* @return a list of actions associated with the given target * @return a list of actions associated with the given target
* @throws EntityNotFoundException if target with given ID does not exist * @throws EntityNotFoundException if target with given ID does not exist
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Page<Action> findInActiveActionsByTarget(@NotNull Pageable pageable, @NotEmpty String controllerId); Page<Action> findInActiveActionsByTarget(@NotEmpty String controllerId, @NotNull Pageable pageable);
/** /**
* Retrieves active {@link Action}s with highest weight that are assigned to a * Retrieves active {@link Action}s with highest weight that are assigned to a {@link Target}.
* {@link Target}.
* *
* @param controllerId identifies the target to retrieve the action from * @param controllerId identifies the target to retrieve the action from
* @param maxActionCount max size of returned list * @param maxActionCount max size of returned list
@@ -332,8 +308,7 @@ public interface DeploymentManagement {
List<Action> findActiveActionsWithHighestWeight(@NotEmpty String controllerId, int maxActionCount); List<Action> findActiveActionsWithHighestWeight(@NotEmpty String controllerId, int maxActionCount);
/** /**
* Get weight of an Action. Returns the default value if the weight is null * Get weight of an Action. Returns the default value if the weight is null according to the properties.
* according to the properties.
* *
* @param action to extract the weight from * @param action to extract the weight from
* @return weight of the action * @return weight of the action
@@ -341,10 +316,8 @@ public interface DeploymentManagement {
int getWeightConsideringDefault(final Action action); int getWeightConsideringDefault(final Action action);
/** /**
* Force cancels given {@link Action} for given {@link Target}. Force * Force cancels given {@link Action} for given {@link Target}. Force canceling means that the action is marked as canceled on the SP server
* canceling means that the action is marked as canceled on the SP server * and a cancel request is sent to the target. But however it's not tracked, if the targets handles the cancel request or not.
* and a cancel request is sent to the target. But however it's not tracked,
* if the targets handles the cancel request or not.
* *
* @param actionId to be canceled * @param actionId to be canceled
* @return quite {@link Action} * @return quite {@link Action}
@@ -355,8 +328,7 @@ public interface DeploymentManagement {
Action forceQuitAction(long actionId); Action forceQuitAction(long actionId);
/** /**
* Updates a {@link Action} and forces the {@link Action} if it's not * Updates a {@link Action} and forces the {@link Action} if it's not already forced.
* already forced.
* *
* @param actionId the ID of the action * @param actionId the ID of the action
* @return the updated or the found {@link Action} * @return the updated or the found {@link Action}
@@ -366,8 +338,7 @@ public interface DeploymentManagement {
Action forceTargetAction(long actionId); Action forceTargetAction(long actionId);
/** /**
* Sets the status of inactive scheduled {@link Action}s for the specified * Sets the status of inactive scheduled {@link Action}s for the specified {@link Target}s to {@link Status#CANCELED}
* {@link Target}s to {@link Status#CANCELED}
* *
* @param targetIds ids of the {@link Target}s the actions belong to * @param targetIds ids of the {@link Target}s the actions belong to
*/ */
@@ -375,15 +346,12 @@ public interface DeploymentManagement {
void cancelInactiveScheduledActionsForTargets(List<Long> targetIds); void cancelInactiveScheduledActionsForTargets(List<Long> targetIds);
/** /**
* Starts all scheduled actions of an RolloutGroup parent. * Starts all scheduled actions of an RolloutGroup parent.<p/>
* <p/>
* No entity based access control applied. * No entity based access control applied.
* *
* @param rolloutId the rollout the actions belong to * @param rolloutId the rollout the actions belong to
* @param distributionSetId to assign * @param distributionSetId to assign
* @param rolloutGroupParentId the parent rollout group the actions should reference. null * @param rolloutGroupParentId the parent rollout group the actions should reference. null references the first group
* references the first group
* @return the amount of started actions
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
void startScheduledActionsByRolloutGroupParent(long rolloutId, long distributionSetId, Long rolloutGroupParentId); void startScheduledActionsByRolloutGroupParent(long rolloutId, long distributionSetId, Long rolloutGroupParentId);
@@ -407,8 +375,7 @@ public interface DeploymentManagement {
Optional<DistributionSet> getAssignedDistributionSet(@NotEmpty String controllerId); Optional<DistributionSet> getAssignedDistributionSet(@NotEmpty String controllerId);
/** /**
* Returns {@link DistributionSet} that is installed on given * Returns {@link DistributionSet} that is installed on given {@link Target}.
* {@link Target}.
* *
* @param controllerId of target * @param controllerId of target
* @return installed {@link DistributionSet} * @return installed {@link DistributionSet}
@@ -418,9 +385,8 @@ public interface DeploymentManagement {
Optional<DistributionSet> getInstalledDistributionSet(@NotEmpty String controllerId); Optional<DistributionSet> getInstalledDistributionSet(@NotEmpty String controllerId);
/** /**
* Deletes actions which match one of the given action status and which have * Deletes actions which match one of the given action status and which have not been modified since the given (absolute) time-stamp.
* not been modified since the given (absolute) time-stamp. Used for obsolete actions cleanup. * Used for obsolete actions cleanup.<p/>
* <p/>
* No entity based access control applied. * No entity based access control applied.
* *
* @param status Set of action status. * @param status Set of action status.
@@ -431,8 +397,7 @@ public interface DeploymentManagement {
int deleteActionsByStatusAndLastModifiedBefore(@NotNull Set<Action.Status> status, long lastModified); int deleteActionsByStatusAndLastModifiedBefore(@NotNull Set<Action.Status> status, long lastModified);
/** /**
* Checks if there is an action for the device with the given controller ID * Checks if there is an action for the device with the given controller ID that is in the {@link Action.Status#CANCELING} state.
* that is in the {@link Action.Status#CANCELING} state.
* *
* @param targetId of target * @param targetId of target
* @return if actions in CANCELING state are present * @return if actions in CANCELING state are present
@@ -441,13 +406,11 @@ public interface DeploymentManagement {
boolean hasPendingCancellations(@NotNull Long targetId); boolean hasPendingCancellations(@NotNull Long targetId);
/** /**
* Cancels all actions that refer to a given distribution set. This method * Cancels all actions that refer to a given distribution set. This method is called when a distribution set is invalidated.
* is called when a distribution set is invalidated.
* *
* @param cancelationType defines if a force or soft cancel is executed * @param cancelationType defines if a force or soft cancel is executed
* @param set the distribution set for that the actions should be canceled * @param set the distribution set for that the actions should be canceled
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
void cancelActionsForDistributionSet(final CancelationType cancelationType, final DistributionSet set); void cancelActionsForDistributionSet(final CancelationType cancelationType, final DistributionSet set);
}
}

View File

@@ -231,13 +231,13 @@ public interface DistributionSetManagement extends RepositoryManagement<Distribu
/** /**
* Finds all {@link DistributionSet}s based on completeness. * Finds all {@link DistributionSet}s based on completeness.
* *
* @param pageable the pagination parameter
* @param complete to <code>true</code> for returning only completed distribution sets or <code>false</code> for only incomplete ones nor * @param complete to <code>true</code> for returning only completed distribution sets or <code>false</code> for only incomplete ones nor
* <code>null</code> to return both. * <code>null</code> to return both.
* @param pageable the pagination parameter
* @return all found {@link DistributionSet}s * @return all found {@link DistributionSet}s
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Slice<DistributionSet> findByCompleted(@NotNull Pageable pageable, Boolean complete); Slice<DistributionSet> findByCompleted(Boolean complete, @NotNull Pageable pageable);
/** /**
* Retrieves {@link DistributionSet}s by filtering on the given parameters. * Retrieves {@link DistributionSet}s by filtering on the given parameters.
@@ -266,14 +266,14 @@ public interface DistributionSetManagement extends RepositoryManagement<Distribu
/** /**
* Retrieves {@link DistributionSet}s by filtering on the given parameters. * Retrieves {@link DistributionSet}s by filtering on the given parameters.
* *
* @param rsqlParam rsql query string * @param rsql rsql query string
* @param tagId of the tag the DS are assigned to * @param tagId of the tag the DS are assigned to
* @param pageable page parameter * @param pageable page parameter
* @return the page of found {@link DistributionSet} * @return the page of found {@link DistributionSet}
* @throws EntityNotFoundException of distribution set tag with given ID does not exist * @throws EntityNotFoundException of distribution set tag with given ID does not exist
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Page<DistributionSet> findByRsqlAndTag(@NotNull String rsqlParam, long tagId, @NotNull Pageable pageable); Page<DistributionSet> findByRsqlAndTag(@NotNull String rsql, long tagId, @NotNull Pageable pageable);
/** /**
* Counts all {@link DistributionSet}s based on completeness. * Counts all {@link DistributionSet}s based on completeness.

View File

@@ -43,13 +43,13 @@ public interface DistributionSetTagManagement extends RepositoryManagement<Distr
/** /**
* Finds all {@link TargetTag} assigned to given {@link Target}. * Finds all {@link TargetTag} assigned to given {@link Target}.
* *
* @param pageable information for page size, offset and sort order.
* @param distributionSetId of the {@link DistributionSet} * @param distributionSetId of the {@link DistributionSet}
* @param pageable information for page size, offset and sort order.
* @return page of the found {@link TargetTag}s * @return page of the found {@link TargetTag}s
* @throws EntityNotFoundException if {@link DistributionSet} with given ID does not exist * @throws EntityNotFoundException if {@link DistributionSet} with given ID does not exist
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Page<DistributionSetTag> findByDistributionSet(@NotNull Pageable pageable, long distributionSetId); Page<DistributionSetTag> findByDistributionSet(long distributionSetId, @NotNull Pageable pageable);
/** /**
* Deletes {@link DistributionSetTag} by given * Deletes {@link DistributionSetTag} by given

View File

@@ -119,7 +119,7 @@ public interface RepositoryManagement<T, C, U> {
/** /**
* Retrieves all {@link BaseEntity}s with a given specification. * Retrieves all {@link BaseEntity}s with a given specification.
* *
* @param rsqlParam filter definition in RSQL syntax * @param rsql filter definition in RSQL syntax
* @param pageable pagination parameter * @param pageable pagination parameter
* @return the found {@link BaseEntity}s * @return the found {@link BaseEntity}s
* @throws RSQLParameterUnsupportedFieldException if a field in the RSQL string is used but not provided by the given * @throws RSQLParameterUnsupportedFieldException if a field in the RSQL string is used but not provided by the given
@@ -127,7 +127,7 @@ public interface RepositoryManagement<T, C, U> {
* @throws RSQLParameterSyntaxException if the RSQL syntax is wrong * @throws RSQLParameterSyntaxException if the RSQL syntax is wrong
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Page<T> findByRsql(@NotNull String rsqlParam, @NotNull Pageable pageable); Page<T> findByRsql(@NotNull String rsql, @NotNull Pageable pageable);
/** /**
* Verifies that {@link BaseEntity} with given ID exists in the repository. * Verifies that {@link BaseEntity} with given ID exists in the repository.

View File

@@ -53,7 +53,7 @@ public interface RolloutGroupManagement {
* Retrieves a page of {@link RolloutGroup}s filtered by a given {@link Rollout} and an RSQL filter. * Retrieves a page of {@link RolloutGroup}s filtered by a given {@link Rollout} and an RSQL filter.
* *
* @param rolloutId the rollout to filter the {@link RolloutGroup}s * @param rolloutId the rollout to filter the {@link RolloutGroup}s
* @param rsqlParam the specification to filter the result set based on attributes of the {@link RolloutGroup} * @param rsql the specification to filter the result set based on attributes of the {@link RolloutGroup}
* @param pageable the page request to sort and limit the result * @param pageable the page request to sort and limit the result
* @return a page of found {@link RolloutGroup}s * @return a page of found {@link RolloutGroup}s
* @throws RSQLParameterUnsupportedFieldException if a field in the RSQL string is used but not provided by the * @throws RSQLParameterUnsupportedFieldException if a field in the RSQL string is used but not provided by the
@@ -61,13 +61,13 @@ public interface RolloutGroupManagement {
* @throws RSQLParameterSyntaxException if the RSQL syntax is wrong * @throws RSQLParameterSyntaxException if the RSQL syntax is wrong
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
Page<RolloutGroup> findByRolloutAndRsql(long rolloutId, @NotNull String rsqlParam, @NotNull Pageable pageable); Page<RolloutGroup> findByRolloutAndRsql(long rolloutId, @NotNull String rsql, @NotNull Pageable pageable);
/** /**
* Retrieves a page of {@link RolloutGroup}s filtered by a given {@link Rollout} and a rsql filter with detailed status. * Retrieves a page of {@link RolloutGroup}s filtered by a given {@link Rollout} and a rsql filter with detailed status.
* *
* @param rolloutId the rollout to filter the {@link RolloutGroup}s * @param rolloutId the rollout to filter the {@link RolloutGroup}s
* @param rsqlParam the specification to filter the result set based on attributes of the {@link RolloutGroup} * @param rsql the specification to filter the result set based on attributes of the {@link RolloutGroup}
* @param pageable the page request to sort and limit the result * @param pageable the page request to sort and limit the result
* @return a page of found {@link RolloutGroup}s * @return a page of found {@link RolloutGroup}s
* @throws RSQLParameterUnsupportedFieldException if a field in the RSQL string is used but not provided by the * @throws RSQLParameterUnsupportedFieldException if a field in the RSQL string is used but not provided by the
@@ -75,7 +75,7 @@ public interface RolloutGroupManagement {
* @throws RSQLParameterSyntaxException if the RSQL syntax is wrong * @throws RSQLParameterSyntaxException if the RSQL syntax is wrong
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
Page<RolloutGroup> findByRolloutAndRsqlWithDetailedStatus(long rolloutId, @NotNull String rsqlParam, @NotNull Pageable pageable); Page<RolloutGroup> findByRolloutAndRsqlWithDetailedStatus(long rolloutId, @NotNull String rsql, @NotNull Pageable pageable);
/** /**
* Retrieves a page of {@link RolloutGroup}s filtered by a given {@link Rollout}. * Retrieves a page of {@link RolloutGroup}s filtered by a given {@link Rollout}.
@@ -110,17 +110,16 @@ public interface RolloutGroupManagement {
/** /**
* Get targets of specified rollout group. * Get targets of specified rollout group.
* *
* @param pageable the page request to sort and limit the result
* @param rolloutGroupId rollout group * @param rolloutGroupId rollout group
* @param rsqlParam the specification for filtering the targets of a rollout group * @param rsql the specification for filtering the targets of a rollout group
* @param pageable the page request to sort and limit the result
* @return Page<Target> list of targets of a rollout group * @return Page<Target> list of targets of a rollout group
* @throws RSQLParameterUnsupportedFieldException if a field in the RSQL string is used but not provided by the * @throws RSQLParameterUnsupportedFieldException if a field in the RSQL string is used but not provided by the
* given {@code fieldNameProvider} * given {@code fieldNameProvider}
* @throws RSQLParameterSyntaxException if the RSQL syntax is wrong * @throws RSQLParameterSyntaxException if the RSQL syntax is wrong
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ_AND_TARGET_READ) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ_AND_TARGET_READ)
Page<Target> findTargetsOfRolloutGroupByRsql(@NotNull Pageable pageable, long rolloutGroupId, Page<Target> findTargetsOfRolloutGroupByRsql(long rolloutGroupId, @NotNull String rsql, @NotNull Pageable pageable);
@NotNull String rsqlParam);
/** /**
* Get {@link RolloutGroup} by id. * Get {@link RolloutGroup} by id.

View File

@@ -180,50 +180,48 @@ public interface RolloutManagement {
/** /**
* Retrieves all rollouts. * Retrieves all rollouts.
* *
* @param pageable the page request to sort and limit the result
* @param deleted flag if deleted rollouts should be included * @param deleted flag if deleted rollouts should be included
* @param pageable the page request to sort and limit the result
* @return a page of found rollouts * @return a page of found rollouts
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
Page<Rollout> findAll(@NotNull Pageable pageable, boolean deleted); Page<Rollout> findAll(boolean deleted, @NotNull Pageable pageable);
/** /**
* Get count of targets in different status in rollout. * Get count of targets in different status in rollout.
* *
* @param pageable the page request to sort and limit the result
* @param deleted flag if deleted rollouts should be included * @param deleted flag if deleted rollouts should be included
* @param pageable the page request to sort and limit the result
* @return a list of rollouts with details of targets count for different * @return a list of rollouts with details of targets count for different
* statuses * statuses
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
Page<Rollout> findAllWithDetailedStatus(@NotNull Pageable pageable, boolean deleted); Page<Rollout> findAllWithDetailedStatus(boolean deleted, @NotNull Pageable pageable);
/** /**
* Retrieves all rollouts found by the given specification. * Retrieves all rollouts found by the given specification.
* *
* @param pageable the page request to sort and limit the result * @param rsql the specification to filter rollouts
* @param rsqlParam the specification to filter rollouts
* @param deleted flag if deleted rollouts should be included * @param deleted flag if deleted rollouts should be included
* @param pageable the page request to sort and limit the result
* @return a page of found rollouts * @return a page of found rollouts
* @throws RSQLParameterUnsupportedFieldException if a field in the RSQL string is used but not provided by the * @throws RSQLParameterUnsupportedFieldException if a field in the RSQL string is used but not provided by the
* given {@code fieldNameProvider} * given {@code fieldNameProvider}
* @throws RSQLParameterSyntaxException if the RSQL syntax is wrong * @throws RSQLParameterSyntaxException if the RSQL syntax is wrong
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
Page<Rollout> findByRsql(@NotNull Pageable pageable, @NotNull String rsqlParam, boolean deleted); Page<Rollout> findByRsql(@NotNull String rsql, boolean deleted, @NotNull Pageable pageable);
/** /**
* Finds rollouts by given text in name or description. * Finds rollouts by given text in name or description.
* *
* @param pageable the page request to sort and limit the result * @param rsql search text which matches name or description of rollout
* @param searchText search text which matches name or description of rollout
* @param deleted flag if deleted rollouts should be included * @param deleted flag if deleted rollouts should be included
* @return the founded rollout or {@code null} if rollout with given ID does * @param pageable the page request to sort and limit the result
* not exists * @return the founded rollout or {@code null} if rollout with given ID does not exists
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
Page<Rollout> findByRsqlWithDetailedStatus(@NotNull Pageable pageable, @NotEmpty String searchText, Page<Rollout> findByRsqlWithDetailedStatus(@NotEmpty String rsql, boolean deleted, @NotNull Pageable pageable);
boolean deleted);
/** /**
* Find rollouts which are still active and needs to be handled. * Find rollouts which are still active and needs to be handled.

View File

@@ -77,13 +77,13 @@ public interface SoftwareModuleManagement extends RepositoryManagement<SoftwareM
/** /**
* Finds all meta-data by the given software module id where {@link SoftwareModuleMetadata#isTargetVisible()}. * Finds all meta-data by the given software module id where {@link SoftwareModuleMetadata#isTargetVisible()}.
* *
* @param pageable the page request to page the result
* @param id the software module id to retrieve the meta-data from * @param id the software module id to retrieve the meta-data from
* @param pageable the page request to page the result
* @return a paged result of all meta-data entries for a given software module id * @return a paged result of all meta-data entries for a given software module id
* @throws EntityNotFoundException if software module with given ID does not exist * @throws EntityNotFoundException if software module with given ID does not exist
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Page<SoftwareModuleMetadata> findMetaDataBySoftwareModuleIdAndTargetVisible(@NotNull Pageable pageable, long id); Page<SoftwareModuleMetadata> findMetaDataBySoftwareModuleIdAndTargetVisible(long id, @NotNull Pageable pageable);
/** /**
* Creates or updates a single software module meta-data entry. * Creates or updates a single software module meta-data entry.

View File

@@ -106,12 +106,12 @@ public interface TargetFilterQueryManagement {
* Retrieves all {@link TargetFilterQuery}s which match the given name * Retrieves all {@link TargetFilterQuery}s which match the given name
* filter. * filter.
* *
* @param pageable pagination parameter
* @param name name filter * @param name name filter
* @param pageable pagination parameter
* @return the page with the found {@link TargetFilterQuery}s * @return the page with the found {@link TargetFilterQuery}s
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Slice<TargetFilterQuery> findByName(@NotNull Pageable pageable, @NotNull String name); Slice<TargetFilterQuery> findByName(@NotNull String name, @NotNull Pageable pageable);
/** /**
* Counts all {@link TargetFilterQuery}s which match the given name filter. * Counts all {@link TargetFilterQuery}s which match the given name filter.
@@ -123,50 +123,47 @@ public interface TargetFilterQueryManagement {
long countByName(@NotNull String name); long countByName(@NotNull String name);
/** /**
* Retrieves all {@link TargetFilterQuery} which match the given RSQL * Retrieves all {@link TargetFilterQuery} which match the given RSQL filter.
* filter.
* *
* @param pageable pagination parameter
* @param rsqlFilter RSQL filter string * @param rsqlFilter RSQL filter string
* @param pageable pagination parameter
* @return the page with the found {@link TargetFilterQuery}s * @return the page with the found {@link TargetFilterQuery}s
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Page<TargetFilterQuery> findByRsql(@NotNull Pageable pageable, @NotNull String rsqlFilter); Page<TargetFilterQuery> findByRsql(@NotNull String rsqlFilter, @NotNull Pageable pageable);
/** /**
* Retrieves all {@link TargetFilterQuery}s which match the given query. * Retrieves all {@link TargetFilterQuery}s which match the given query.
* *
* @param pageable pagination parameter
* @param query the query saved in the target filter query * @param query the query saved in the target filter query
* @param pageable pagination parameter
* @return the page with the found {@link TargetFilterQuery}s * @return the page with the found {@link TargetFilterQuery}s
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Slice<TargetFilterQuery> findByQuery(@NotNull Pageable pageable, @NotNull String query); Slice<TargetFilterQuery> findByQuery(@NotNull String query, @NotNull Pageable pageable);
/** /**
* Retrieves all {@link TargetFilterQuery}s which match the given * Retrieves all {@link TargetFilterQuery}s which match the given auto-assign distribution set ID.
* auto-assign distribution set ID.
* *
* @param pageable pagination parameter
* @param setId the auto assign distribution set * @param setId the auto assign distribution set
* @param pageable pagination parameter
* @return the page with the found {@link TargetFilterQuery}s * @return the page with the found {@link TargetFilterQuery}s
* @throws EntityNotFoundException if DS with given ID does not exist * @throws EntityNotFoundException if DS with given ID does not exist
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Slice<TargetFilterQuery> findByAutoAssignDistributionSetId(@NotNull Pageable pageable, long setId); Slice<TargetFilterQuery> findByAutoAssignDistributionSetId(long setId, @NotNull Pageable pageable);
/** /**
* Retrieves all {@link TargetFilterQuery}s which match the given * Retrieves all {@link TargetFilterQuery}s which match the given auto-assign distribution set and RSQL filter.
* auto-assign distribution set and RSQL filter.
* *
* @param pageable pagination parameter
* @param setId the auto assign distribution set * @param setId the auto assign distribution set
* @param rsqlParam RSQL filter * @param rsql RSQL filter
* @param pageable pagination parameter
* @return the page with the found {@link TargetFilterQuery}s * @return the page with the found {@link TargetFilterQuery}s
* @throws EntityNotFoundException if DS with given ID does not exist * @throws EntityNotFoundException if DS with given ID does not exist
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Page<TargetFilterQuery> findByAutoAssignDSAndRsql(@NotNull Pageable pageable, long setId, String rsqlParam); Page<TargetFilterQuery> findByAutoAssignDSAndRsql(long setId, String rsql, @NotNull Pageable pageable);
/** /**
* Retrieves all {@link TargetFilterQuery}s with an auto-assign distribution set. * Retrieves all {@link TargetFilterQuery}s with an auto-assign distribution set.
@@ -238,4 +235,4 @@ public interface TargetFilterQueryManagement {
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
void cancelAutoAssignmentForDistributionSet(long setId); void cancelAutoAssignmentForDistributionSet(long setId);
} }

View File

@@ -98,44 +98,44 @@ public interface TargetManagement {
/** /**
* Count {@link TargetFilterQuery}s for given target filter query. * Count {@link TargetFilterQuery}s for given target filter query.
* *
* @param rsqlParam filter definition in RSQL syntax * @param rsql filter definition in RSQL syntax
* @return the found number of {@link Target}s * @return the found number of {@link Target}s
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
long countByRsql(@NotEmpty String rsqlParam); long countByRsql(@NotEmpty String rsql);
/** /**
* Count {@link TargetFilterQuery}s for given target filter query with UPDATE permission. * Count {@link TargetFilterQuery}s for given target filter query with UPDATE permission.
* *
* @param rsqlParam filter definition in RSQL syntax * @param rsql filter definition in RSQL syntax
* @return the found number of {@link Target}s * @return the found number of {@link Target}s
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
long countByRsqlAndUpdatable(@NotEmpty String rsqlParam); long countByRsqlAndUpdatable(@NotEmpty String rsql);
/** /**
* Count all targets for given {@link TargetFilterQuery} and that are compatible * Count all targets for given {@link TargetFilterQuery} and that are compatible
* with the passed {@link DistributionSetType}. * with the passed {@link DistributionSetType}.
* *
* @param rsqlParam filter definition in RSQL syntax * @param rsql filter definition in RSQL syntax
* @param distributionSetIdTypeId ID of the {@link DistributionSetType} the targets need to be * @param distributionSetIdTypeId ID of the {@link DistributionSetType} the targets need to be
* compatible with * compatible with
* @return the found number of{@link Target}s * @return the found number of{@link Target}s
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
long countByRsqlAndCompatible(@NotEmpty String rsqlParam, @NotNull Long distributionSetIdTypeId); long countByRsqlAndCompatible(@NotEmpty String rsql, @NotNull Long distributionSetIdTypeId);
/** /**
* Count all targets for given {@link TargetFilterQuery} and that are compatible * Count all targets for given {@link TargetFilterQuery} and that are compatible
* with the passed {@link DistributionSetType} and UPDATE permission. * with the passed {@link DistributionSetType} and UPDATE permission.
* *
* @param rsqlParam filter definition in RSQL syntax * @param rsql filter definition in RSQL syntax
* @param distributionSetIdTypeId ID of the {@link DistributionSetType} the targets need to be * @param distributionSetIdTypeId ID of the {@link DistributionSetType} the targets need to be
* compatible with * compatible with
* @return the found number of{@link Target}s * @return the found number of{@link Target}s
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
long countByRsqlAndCompatibleAndUpdatable(@NotEmpty String rsqlParam, @NotNull Long distributionSetIdTypeId); long countByRsqlAndCompatibleAndUpdatable(@NotEmpty String rsql, @NotNull Long distributionSetIdTypeId);
/** /**
* Count all targets with failed actions for specific Rollout and that are * Count all targets with failed actions for specific Rollout and that are
@@ -174,8 +174,7 @@ public interface TargetManagement {
* @param create to be created * @param create to be created
* @return the created {@link Target} * @return the created {@link Target}
* @throws EntityAlreadyExistsException given target already exists. * @throws EntityAlreadyExistsException given target already exists.
* @throws ConstraintViolationException if fields are not filled as specified. Check {@link TargetCreate} * @throws ConstraintViolationException if fields are not filled as specified. Check {@link TargetCreate} for field constraints.
* for field constraints.
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET)
Target create(@NotNull @Valid TargetCreate create); Target create(@NotNull @Valid TargetCreate create);
@@ -217,15 +216,15 @@ public interface TargetManagement {
* that don't have the specified distribution set in their action history and * that don't have the specified distribution set in their action history and
* are compatible with the passed {@link DistributionSetType}. * are compatible with the passed {@link DistributionSetType}.
* *
* @param pageRequest the pageRequest to enhance the query for paging and sorting
* @param distributionSetId id of the {@link DistributionSet} * @param distributionSetId id of the {@link DistributionSet}
* @param rsqlParam filter definition in RSQL syntax * @param rsql filter definition in RSQL syntax
* @param pageable the pageable to enhance the query for paging and sorting
* @return a page of the found {@link Target}s * @return a page of the found {@link Target}s
* @throws EntityNotFoundException if distribution set with given ID does not exist * @throws EntityNotFoundException if distribution set with given ID does not exist
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET)
Slice<Target> findByTargetFilterQueryAndNonDSAndCompatibleAndUpdatable( Slice<Target> findByTargetFilterQueryAndNonDSAndCompatibleAndUpdatable(
@NotNull Pageable pageRequest, long distributionSetId, @NotNull String rsqlParam); long distributionSetId, @NotNull String rsql, @NotNull Pageable pageable);
/** /**
* Counts all targets for all the given parameter {@link TargetFilterQuery} and * Counts all targets for all the given parameter {@link TargetFilterQuery} and
@@ -233,34 +232,34 @@ public interface TargetManagement {
* are compatible with the passed {@link DistributionSetType}. * are compatible with the passed {@link DistributionSetType}.
* *
* @param distributionSetId id of the {@link DistributionSet} * @param distributionSetId id of the {@link DistributionSet}
* @param rsqlParam filter definition in RSQL syntax * @param rsql filter definition in RSQL syntax
* @return the count of found {@link Target}s * @return the count of found {@link Target}s
* @throws EntityNotFoundException if distribution set with given ID does not exist * @throws EntityNotFoundException if distribution set with given ID does not exist
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET)
long countByRsqlAndNonDSAndCompatibleAndUpdatable(long distributionSetId, @NotNull String rsqlParam); long countByRsqlAndNonDSAndCompatibleAndUpdatable(long distributionSetId, @NotNull String rsql);
/** /**
* Finds all targets for all the given parameter {@link TargetFilterQuery} and * Finds all targets for all the given parameter {@link TargetFilterQuery} and
* that are not assigned to one of the {@link RolloutGroup}s and are compatible * that are not assigned to one of the {@link RolloutGroup}s and are compatible
* with the passed {@link DistributionSetType}. * with the passed {@link DistributionSetType}.
* *
* @param pageRequest the pageRequest to enhance the query for paging and sorting
* @param groups the list of {@link RolloutGroup}s * @param groups the list of {@link RolloutGroup}s
* @param targetFilterQuery filter definition in RSQL syntax * @param targetFilterQuery filter definition in RSQL syntax
* @param distributionSetType type of the {@link DistributionSet} the targets must be compatible * @param distributionSetType type of the {@link DistributionSet} the targets must be compatible
* withs * withs
* @param pageable the pageable to enhance the query for paging and sorting
* @return a page of the found {@link Target}s * @return a page of the found {@link Target}s
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ_AND_TARGET_READ) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ_AND_TARGET_READ)
Slice<Target> findByTargetFilterQueryAndNotInRolloutAndCompatibleAndUpdatable(@NotNull Pageable pageRequest, Slice<Target> findByTargetFilterQueryAndNotInRolloutAndCompatibleAndUpdatable(
@NotEmpty Collection<Long> groups, @NotNull String targetFilterQuery, @NotEmpty Collection<Long> groups, @NotNull String targetFilterQuery, @NotNull DistributionSetType distributionSetType,
@NotNull DistributionSetType distributionSetType); @NotNull Pageable pageable);
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ_AND_TARGET_READ) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ_AND_TARGET_READ)
Slice<Target> findByTargetFilterQueryAndNoOverridingActionsAndNotInRolloutAndCompatibleAndUpdatable( Slice<Target> findByTargetFilterQueryAndNoOverridingActionsAndNotInRolloutAndCompatibleAndUpdatable(
@NotNull Pageable pageRequest, final long rolloutId, final int weight, final long firstGroupId, @NotNull String targetFilterQuery, final long rolloutId, final int weight, final long firstGroupId, @NotNull String targetFilterQuery,
@NotNull DistributionSetType distributionSetType); @NotNull DistributionSetType distributionSetType, @NotNull Pageable pageable);
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ_AND_TARGET_READ) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ_AND_TARGET_READ)
long countByActionsInRolloutGroup(final long rolloutGroupId); long countByActionsInRolloutGroup(final long rolloutGroupId);
@@ -270,29 +269,28 @@ public interface TargetManagement {
* assigned to one of the retried {@link RolloutGroup}s and are compatible with * assigned to one of the retried {@link RolloutGroup}s and are compatible with
* the passed {@link DistributionSetType}. * the passed {@link DistributionSetType}.
* *
* @param pageRequest the pageRequest to enhance the query for paging and sorting
* @param groups the list of {@link RolloutGroup}s
* @param rolloutId rolloutId of the rollout to be retried. * @param rolloutId rolloutId of the rollout to be retried.
* @param groups the list of {@link RolloutGroup}s
* @param pageable the pageable to enhance the query for paging and sorting
* @return a page of the found {@link Target}s * @return a page of the found {@link Target}s
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ_AND_TARGET_READ) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ_AND_TARGET_READ)
Slice<Target> findByFailedRolloutAndNotInRolloutGroups(@NotNull Pageable pageRequest, Slice<Target> findByFailedRolloutAndNotInRolloutGroups(
@NotEmpty Collection<Long> groups, @NotNull String rolloutId); @NotNull String rolloutId, @NotEmpty Collection<Long> groups, @NotNull Pageable pageable);
/** /**
* Counts all targets for all the given parameter {@link TargetFilterQuery} and * Counts all targets for all the given parameter {@link TargetFilterQuery} and
* that are not assigned to one of the {@link RolloutGroup}s and are compatible * that are not assigned to one of the {@link RolloutGroup}s and are compatible
* with the passed {@link DistributionSetType}. * with the passed {@link DistributionSetType}.
* *
* @param rsqlParam filter definition in RSQL syntax * @param rsql filter definition in RSQL syntax
* @param groups the list of {@link RolloutGroup}s * @param groups the list of {@link RolloutGroup}s
* @param distributionSetType type of the {@link DistributionSet} the targets must be compatible * @param distributionSetType type of the {@link DistributionSet} the targets must be compatible with
* with
* @return count of the found {@link Target}s * @return count of the found {@link Target}s
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ_AND_TARGET_READ) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ_AND_TARGET_READ)
long countByRsqlAndNotInRolloutGroupsAndCompatibleAndUpdatable(@NotNull String rsqlParam, @NotEmpty Collection<Long> groups, long countByRsqlAndNotInRolloutGroupsAndCompatibleAndUpdatable(
@NotNull DistributionSetType distributionSetType); @NotNull String rsql, @NotEmpty Collection<Long> groups, @NotNull DistributionSetType distributionSetType);
/** /**
* Counts all targets with failed actions for specific Rollout and that are not * Counts all targets with failed actions for specific Rollout and that are not
@@ -310,32 +308,31 @@ public interface TargetManagement {
* Finds all targets of the provided {@link RolloutGroup} that have no Action * Finds all targets of the provided {@link RolloutGroup} that have no Action
* for the RolloutGroup. * for the RolloutGroup.
* *
* @param pageRequest the pageRequest to enhance the query for paging and sorting
* @param group the {@link RolloutGroup} * @param group the {@link RolloutGroup}
* @param pageable the pageable to enhance the query for paging and sorting
* @return the found {@link Target}s * @return the found {@link Target}s
* @throws EntityNotFoundException if rollout group with given ID does not exist * @throws EntityNotFoundException if rollout group with given ID does not exist
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Slice<Target> findByInRolloutGroupWithoutAction(@NotNull Pageable pageRequest, long group); Slice<Target> findByInRolloutGroupWithoutAction(long group, @NotNull Pageable pageable);
/** /**
* retrieves {@link Target}s by the assigned {@link DistributionSet}. * Retrieves {@link Target}s by the assigned {@link DistributionSet}.
* *
* @param pageReq page parameter
* @param distributionSetId the ID of the {@link DistributionSet} * @param distributionSetId the ID of the {@link DistributionSet}
* @param pageable page parameter
* @return the found {@link Target}s * @return the found {@link Target}s
* @throws EntityNotFoundException if distribution set with given ID does not exist * @throws EntityNotFoundException if distribution set with given ID does not exist
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET)
Page<Target> findByAssignedDistributionSet(@NotNull Pageable pageReq, long distributionSetId); Page<Target> findByAssignedDistributionSet(long distributionSetId, @NotNull Pageable pageable);
/** /**
* Retrieves {@link Target}s by the assigned {@link DistributionSet} possible * Retrieves {@link Target}s by the assigned {@link DistributionSet} possible including additional filtering based on the given {@code spec}.
* including additional filtering based on the given {@code spec}.
* *
* @param pageReq page parameter
* @param distributionSetId the ID of the {@link DistributionSet} * @param distributionSetId the ID of the {@link DistributionSet}
* @param rsqlParam the specification to filter the result set * @param rsql the specification to filter the result set
* @param pageable page parameter
* @return the found {@link Target}s, never {@code null} * @return the found {@link Target}s, never {@code null}
* @throws RSQLParameterUnsupportedFieldException if a field in the RSQL string is used but not provided by the * @throws RSQLParameterUnsupportedFieldException if a field in the RSQL string is used but not provided by the
* given {@code fieldNameProvider} * given {@code fieldNameProvider}
@@ -343,8 +340,7 @@ public interface TargetManagement {
* @throws EntityNotFoundException if distribution set with given ID does not exist * @throws EntityNotFoundException if distribution set with given ID does not exist
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET)
Page<Target> findByAssignedDistributionSetAndRsql(@NotNull Pageable pageReq, long distributionSetId, Page<Target> findByAssignedDistributionSetAndRsql(long distributionSetId, @NotNull String rsql, @NotNull Pageable pageable);
@NotNull String rsqlParam);
/** /**
* Find {@link Target}s based a given IDs. * Find {@link Target}s based a given IDs.
@@ -398,33 +394,33 @@ public interface TargetManagement {
* Filter {@link Target}s for all the given parameters. If all parameters except * Filter {@link Target}s for all the given parameters. If all parameters except
* pageable are null, all available {@link Target}s are returned. * pageable are null, all available {@link Target}s are returned.
* *
* @param pageable page parameters
* @param filterParams the filters to apply; only filters are enabled that have non-null * @param filterParams the filters to apply; only filters are enabled that have non-null
* value; filters are AND-gated * value; filters are AND-gated
* @param pageable page parameters
* @return the found {@link Target}s * @return the found {@link Target}s
* @throws EntityNotFoundException if distribution set with given ID does not exist * @throws EntityNotFoundException if distribution set with given ID does not exist
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Slice<Target> findByFilters(@NotNull Pageable pageable, @NotNull FilterParams filterParams); Slice<Target> findByFilters(@NotNull FilterParams filterParams, @NotNull Pageable pageable);
/** /**
* retrieves {@link Target}s by the installed {@link DistributionSet}. * retrieves {@link Target}s by the installed {@link DistributionSet}.
* *
* @param pageReq page parameter
* @param distributionSetId the ID of the {@link DistributionSet} * @param distributionSetId the ID of the {@link DistributionSet}
* @param pageReq page parameter
* @return the found {@link Target}s * @return the found {@link Target}s
* @throws EntityNotFoundException if distribution set with given ID does not exist * @throws EntityNotFoundException if distribution set with given ID does not exist
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET)
Page<Target> findByInstalledDistributionSet(@NotNull Pageable pageReq, long distributionSetId); Page<Target> findByInstalledDistributionSet(long distributionSetId, @NotNull Pageable pageReq);
/** /**
* retrieves {@link Target}s by the installed {@link DistributionSet} including * retrieves {@link Target}s by the installed {@link DistributionSet} including
* additional filtering based on the given {@code spec}. * additional filtering based on the given {@code spec}.
* *
* @param pageReq page parameter
* @param distributionSetId the ID of the {@link DistributionSet} * @param distributionSetId the ID of the {@link DistributionSet}
* @param rsqlParam the specification to filter the result * @param rsql the specification to filter the result
* @param pageReq page parameter
* @return the found {@link Target}s, never {@code null} * @return the found {@link Target}s, never {@code null}
* @throws RSQLParameterUnsupportedFieldException if a field in the RSQL string is used but not provided by the * @throws RSQLParameterUnsupportedFieldException if a field in the RSQL string is used but not provided by the
* given {@code fieldNameProvider} * given {@code fieldNameProvider}
@@ -432,17 +428,17 @@ public interface TargetManagement {
* @throws EntityNotFoundException if distribution set with given ID does not exist * @throws EntityNotFoundException if distribution set with given ID does not exist
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET)
Page<Target> findByInstalledDistributionSetAndRsql(@NotNull Pageable pageReq, long distributionSetId, @NotNull String rsqlParam); Page<Target> findByInstalledDistributionSetAndRsql(long distributionSetId, @NotNull String rsql, @NotNull Pageable pageReq);
/** /**
* Retrieves the {@link Target} which have a certain {@link TargetUpdateStatus}. * Retrieves the {@link Target} which have a certain {@link TargetUpdateStatus}.
* *
* @param pageable page parameter
* @param status the {@link TargetUpdateStatus} to be filtered on * @param status the {@link TargetUpdateStatus} to be filtered on
* @param pageable page parameter
* @return the found {@link Target}s * @return the found {@link Target}s
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Page<Target> findByUpdateStatus(@NotNull Pageable pageable, @NotNull TargetUpdateStatus status); Page<Target> findByUpdateStatus(@NotNull TargetUpdateStatus status, @NotNull Pageable pageable);
/** /**
* Retrieves all targets. * Retrieves all targets.
@@ -456,21 +452,21 @@ public interface TargetManagement {
/** /**
* Retrieves all targets. * Retrieves all targets.
* *
* @param rsql in RSQL notation
* @param pageable pagination parameter * @param pageable pagination parameter
* @param rsqlParam in RSQL notation
* @return the found {@link Target}s, never {@code null} * @return the found {@link Target}s, never {@code null}
* @throws RSQLParameterUnsupportedFieldException if a field in the RSQL string is used but not provided by the * @throws RSQLParameterUnsupportedFieldException if a field in the RSQL string is used but not provided by the
* given {@code fieldNameProvider} * given {@code fieldNameProvider}
* @throws RSQLParameterSyntaxException if the RSQL syntax is wrong * @throws RSQLParameterSyntaxException if the RSQL syntax is wrong
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Slice<Target> findByRsql(@NotNull Pageable pageable, @NotNull String rsqlParam); Slice<Target> findByRsql(@NotNull String rsql, @NotNull Pageable pageable);
/** /**
* Retrieves all target based on {@link TargetFilterQuery}. * Retrieves all target based on {@link TargetFilterQuery}.
* *
* @param pageable pagination parameter
* @param targetFilterQueryId {@link TargetFilterQuery#getId()} * @param targetFilterQueryId {@link TargetFilterQuery#getId()}
* @param pageable pagination parameter
* @return the found {@link Target}s, never {@code null} * @return the found {@link Target}s, never {@code null}
* @throws EntityNotFoundException if {@link TargetFilterQuery} with given ID does not exist. * @throws EntityNotFoundException if {@link TargetFilterQuery} with given ID does not exist.
* @throws RSQLParameterUnsupportedFieldException if a field in the RSQL string is used but not provided by the * @throws RSQLParameterUnsupportedFieldException if a field in the RSQL string is used but not provided by the
@@ -478,25 +474,25 @@ public interface TargetManagement {
* @throws RSQLParameterSyntaxException if the RSQL syntax is wrong * @throws RSQLParameterSyntaxException if the RSQL syntax is wrong
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Slice<Target> findByTargetFilterQuery(@NotNull Pageable pageable, long targetFilterQueryId); Slice<Target> findByTargetFilterQuery(long targetFilterQueryId, @NotNull Pageable pageable);
/** /**
* Find targets by tag name. * Find targets by tag name.
* *
* @param pageable the page request parameter for paging and sorting the result
* @param tagId tag ID * @param tagId tag ID
* @param pageable the page request parameter for paging and sorting the result
* @return list of matching targets * @return list of matching targets
* @throws EntityNotFoundException if target tag with given ID does not exist * @throws EntityNotFoundException if target tag with given ID does not exist
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Page<Target> findByTag(@NotNull Pageable pageable, long tagId); Page<Target> findByTag(long tagId, @NotNull Pageable pageable);
/** /**
* Find targets by tag name. * Find targets by tag name.
* *
* @param pageable the page request parameter for paging and sorting the result * @param rsql in RSQL notation
* @param tagId tag ID * @param tagId tag ID
* @param rsqlParam in RSQL notation * @param pageable the page request parameter for paging and sorting the result
* @return list of matching targets * @return list of matching targets
* @throws EntityNotFoundException if target tag with given ID does not exist * @throws EntityNotFoundException if target tag with given ID does not exist
* @throws RSQLParameterUnsupportedFieldException if a field in the RSQL string is used but not provided by the * @throws RSQLParameterUnsupportedFieldException if a field in the RSQL string is used but not provided by the
@@ -504,7 +500,7 @@ public interface TargetManagement {
* @throws RSQLParameterSyntaxException if the RSQL syntax is wrong * @throws RSQLParameterSyntaxException if the RSQL syntax is wrong
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Page<Target> findByRsqlAndTag(@NotNull Pageable pageable, @NotNull String rsqlParam, long tagId); Page<Target> findByRsqlAndTag(@NotNull String rsql, long tagId, @NotNull Pageable pageable);
/** /**
* Verify if a target matches a specific target filter query, does not have a * Verify if a target matches a specific target filter query, does not have a
@@ -688,11 +684,11 @@ public interface TargetManagement {
* Retrieves {@link Target}s where * Retrieves {@link Target}s where
* {@link #isControllerAttributesRequested(String)}. * {@link #isControllerAttributesRequested(String)}.
* *
* @param pageReq page parameter * @param pageable page parameter
* @return the found {@link Target}s * @return the found {@link Target}s
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Page<Target> findByControllerAttributesRequested(@NotNull Pageable pageReq); Page<Target> findByControllerAttributesRequested(@NotNull Pageable pageable);
/** /**
* Creates a list of target meta-data entries. * Creates a list of target meta-data entries.

View File

@@ -87,15 +87,14 @@ public interface TargetTagManagement {
/** /**
* Retrieves all target tags based on the given specification. * Retrieves all target tags based on the given specification.
* *
* @param rsql rsql query string
* @param pageable pagination parameter * @param pageable pagination parameter
* @param rsqlParam rsql query string
* @return the found {@link Target}s, never {@code null} * @return the found {@link Target}s, never {@code null}
* @throws RSQLParameterUnsupportedFieldException if a field in the RSQL string is used but not provided by the * @throws RSQLParameterUnsupportedFieldException if a field in the RSQL string is used but not provided by the given {@code fieldNameProvider}
* given {@code fieldNameProvider}
* @throws RSQLParameterSyntaxException if the RSQL syntax is wrong * @throws RSQLParameterSyntaxException if the RSQL syntax is wrong
*/ */
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Page<TargetTag> findByRsql(@NotNull Pageable pageable, @NotNull String rsqlParam); Page<TargetTag> findByRsql(@NotNull String rsql, @NotNull Pageable pageable);
/** /**
* Find {@link TargetTag} based on given Name. * Find {@link TargetTag} based on given Name.

View File

@@ -86,22 +86,22 @@ public interface TargetTypeManagement {
Slice<TargetType> findAll(@NotNull Pageable pageable); Slice<TargetType> findAll(@NotNull Pageable pageable);
/** /**
* @param rsql query param
* @param pageable Page * @param pageable Page
* @param rsqlParam query param
* @return Target type * @return Target type
*/ */
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_READ_TARGET) @PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Page<TargetType> findByRsql(@NotNull Pageable pageable, @NotEmpty String rsqlParam); Page<TargetType> findByRsql(@NotEmpty String rsql, @NotNull Pageable pageable);
/** /**
* Retrieves {@link TargetType}s by filtering on the given parameters. * Retrieves {@link TargetType}s by filtering on the given parameters.
* *
* @param pageable page parameter
* @param name has text of filters to be applied. * @param name has text of filters to be applied.
* @param pageable page parameter
* @return the page of found {@link TargetType} * @return the page of found {@link TargetType}
*/ */
@PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_READ_TARGET) @PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_READ_TARGET)
Slice<TargetType> findByName(@NotNull Pageable pageable, String name); Slice<TargetType> findByName(String name, @NotNull Pageable pageable);
/** /**
* @param id Target type ID * @param id Target type ID

View File

@@ -648,10 +648,10 @@ public class JpaRolloutExecutor implements RolloutExecutor {
final Slice<Target> targets; final Slice<Target> targets;
if (!RolloutHelper.isRolloutRetried(rollout.getTargetFilterQuery())) { if (!RolloutHelper.isRolloutRetried(rollout.getTargetFilterQuery())) {
targets = targetManagement.findByTargetFilterQueryAndNotInRolloutAndCompatibleAndUpdatable( targets = targetManagement.findByTargetFilterQueryAndNotInRolloutAndCompatibleAndUpdatable(
pageRequest, readyGroups, targetFilter, rollout.getDistributionSet().getType()); readyGroups, targetFilter, rollout.getDistributionSet().getType(), pageRequest);
} else { } else {
targets = targetManagement.findByFailedRolloutAndNotInRolloutGroups( targets = targetManagement.findByFailedRolloutAndNotInRolloutGroups(
pageRequest, readyGroups, RolloutHelper.getIdFromRetriedTargetFilter(rollout.getTargetFilterQuery())); RolloutHelper.getIdFromRetriedTargetFilter(rollout.getTargetFilterQuery()), readyGroups, pageRequest);
} }
rolloutTargetGroupRepository.saveAll(targets.stream().map(target -> new RolloutTargetGroup(group, target)).toList()); rolloutTargetGroupRepository.saveAll(targets.stream().map(target -> new RolloutTargetGroup(group, target)).toList());
@@ -772,10 +772,10 @@ public class JpaRolloutExecutor implements RolloutExecutor {
return DeploymentHelper.runInNewTransaction(txManager, "createActionsForRolloutDynamicGroup", status -> { return DeploymentHelper.runInNewTransaction(txManager, "createActionsForRolloutDynamicGroup", status -> {
final PageRequest pageRequest = PageRequest.of(0, Math.toIntExact(limit)); final PageRequest pageRequest = PageRequest.of(0, Math.toIntExact(limit));
final Slice<Target> targets = targetManagement.findByTargetFilterQueryAndNoOverridingActionsAndNotInRolloutAndCompatibleAndUpdatable( final Slice<Target> targets = targetManagement.findByTargetFilterQueryAndNoOverridingActionsAndNotInRolloutAndCompatibleAndUpdatable(
pageRequest, rollout.getId(), rollout.getWeight().orElse(1000), rolloutGroupRepository.findByRolloutOrderByIdAsc(rollout).get(0).getId(),
rollout.getId(), rollout.getWeight().orElse(1000), // Dynamic rollouts shall always have weight! targetFilter, rollout.getDistributionSet().getType(), pageRequest
rolloutGroupRepository.findByRolloutOrderByIdAsc(rollout).get(0).getId(), // Dynamic rollouts shall always have weight!
targetFilter, rollout.getDistributionSet().getType()); );
if (targets.getNumberOfElements() == 0) { if (targets.getNumberOfElements() == 0) {
return 0; return 0;
@@ -835,7 +835,7 @@ public class JpaRolloutExecutor implements RolloutExecutor {
private Long createActionsForTargetsInNewTransaction(final Rollout rollout, final RolloutGroup group) { private Long createActionsForTargetsInNewTransaction(final Rollout rollout, final RolloutGroup group) {
return DeploymentHelper.runInNewTransaction(txManager, "createActionsForTargets", status -> { return DeploymentHelper.runInNewTransaction(txManager, "createActionsForTargets", status -> {
final Slice<Target> targets = targetManagement.findByInRolloutGroupWithoutAction( final Slice<Target> targets = targetManagement.findByInRolloutGroupWithoutAction(
PageRequest.of(0, JpaRolloutExecutor.TRANSACTION_TARGETS), group.getId()); group.getId(), PageRequest.of(0, JpaRolloutExecutor.TRANSACTION_TARGETS));
if (targets.getNumberOfElements() > 0) { if (targets.getNumberOfElements() > 0) {
final DistributionSet distributionSet = rollout.getDistributionSet(); final DistributionSet distributionSet = rollout.getDistributionSet();

View File

@@ -86,8 +86,9 @@ public class AutoAssignChecker extends AbstractAutoAssignExecutor {
do { do {
final List<String> controllerIds = targetManagement final List<String> controllerIds = targetManagement
.findByTargetFilterQueryAndNonDSAndCompatibleAndUpdatable( .findByTargetFilterQueryAndNonDSAndCompatibleAndUpdatable(
PageRequest.of(0, Constants.MAX_ENTRIES_IN_STATEMENT), targetFilterQuery.getAutoAssignDistributionSet().getId(), targetFilterQuery.getQuery(),
targetFilterQuery.getAutoAssignDistributionSet().getId(), targetFilterQuery.getQuery()) PageRequest.of(0, Constants.MAX_ENTRIES_IN_STATEMENT)
)
.getContent().stream().map(Target::getControllerId).toList(); .getContent().stream().map(Target::getControllerId).toList();
log.debug( log.debug(
"Retrieved {} auto assign targets for tenant {} and target filter query id {}, starting with assignment", "Retrieved {} auto assign targets for tenant {} and target filter query id {}, starting with assignment",

View File

@@ -178,11 +178,11 @@ public class JpaArtifactManagement implements ArtifactManagement {
} }
@Override @Override
public Page<Artifact> findBySoftwareModule(final Pageable pageReq, final long softwareModuleId) { public Page<Artifact> findBySoftwareModule(final long softwareModuleId, final Pageable pageable) {
assertSoftwareModuleExists(softwareModuleId); assertSoftwareModuleExists(softwareModuleId);
return localArtifactRepository return localArtifactRepository
.findAll(ArtifactSpecifications.bySoftwareModuleId(softwareModuleId), pageReq) .findAll(ArtifactSpecifications.bySoftwareModuleId(softwareModuleId), pageable)
.map(Artifact.class::cast); .map(Artifact.class::cast);
} }

View File

@@ -326,12 +326,12 @@ public class JpaControllerManagement extends JpaActionManagement implements Cont
} }
@Override @Override
public Page<ActionStatus> findActionStatusByAction(final Pageable pageReq, final long actionId) { public Page<ActionStatus> findActionStatusByAction(final long actionId, final Pageable pageable) {
if (!actionRepository.existsById(actionId)) { if (!actionRepository.existsById(actionId)) {
throw new EntityNotFoundException(Action.class, actionId); throw new EntityNotFoundException(Action.class, actionId);
} }
return actionStatusRepository.findByActionId(pageReq, actionId); return actionStatusRepository.findByActionId(pageable, actionId);
} }
@Override @Override

View File

@@ -271,11 +271,11 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
} }
@Override @Override
public long countActionsByTarget(final String rsqlParam, final String controllerId) { public long countActionsByTarget(final String rsql, final String controllerId) {
assertTargetReadAllowed(controllerId); assertTargetReadAllowed(controllerId);
final List<Specification<JpaAction>> specList = Arrays.asList( final List<Specification<JpaAction>> specList = Arrays.asList(
RSQLUtility.buildRsqlSpecification(rsqlParam, ActionFields.class, virtualPropertyReplacer, database), RSQLUtility.buildRsqlSpecification(rsql, ActionFields.class, virtualPropertyReplacer, database),
ActionSpecifications.byTargetControllerId(controllerId)); ActionSpecifications.byTargetControllerId(controllerId));
return JpaManagementHelper.countBySpec(actionRepository, specList); return JpaManagementHelper.countBySpec(actionRepository, specList);
@@ -287,9 +287,9 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
} }
@Override @Override
public long countActions(final String rsqlParam) { public long countActions(final String rsql) {
final List<Specification<JpaAction>> specList = List.of( final List<Specification<JpaAction>> specList = List.of(
RSQLUtility.buildRsqlSpecification(rsqlParam, ActionFields.class, virtualPropertyReplacer, database)); RSQLUtility.buildRsqlSpecification(rsql, ActionFields.class, virtualPropertyReplacer, database));
return JpaManagementHelper.countBySpec(actionRepository, specList); return JpaManagementHelper.countBySpec(actionRepository, specList);
} }
@@ -312,19 +312,18 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
} }
@Override @Override
public Slice<Action> findActions(final String rsqlParam, final Pageable pageable) { public Slice<Action> findActions(final String rsql, final Pageable pageable) {
final List<Specification<JpaAction>> specList = List.of( final List<Specification<JpaAction>> specList = List.of(
RSQLUtility.buildRsqlSpecification(rsqlParam, ActionFields.class, virtualPropertyReplacer, database)); RSQLUtility.buildRsqlSpecification(rsql, ActionFields.class, virtualPropertyReplacer, database));
return JpaManagementHelper.findAllWithoutCountBySpec(actionRepository, specList, pageable); return JpaManagementHelper.findAllWithoutCountBySpec(actionRepository, specList, pageable);
} }
@Override @Override
public Page<Action> findActionsByTarget(final String rsqlParam, final String controllerId, public Page<Action> findActionsByTarget(final String rsql, final String controllerId, final Pageable pageable) {
final Pageable pageable) {
assertTargetReadAllowed(controllerId); assertTargetReadAllowed(controllerId);
final List<Specification<JpaAction>> specList = Arrays.asList( final List<Specification<JpaAction>> specList = Arrays.asList(
RSQLUtility.buildRsqlSpecification(rsqlParam, ActionFields.class, virtualPropertyReplacer, database), RSQLUtility.buildRsqlSpecification(rsql, ActionFields.class, virtualPropertyReplacer, database),
ActionSpecifications.byTargetControllerId(controllerId)); ActionSpecifications.byTargetControllerId(controllerId));
return JpaManagementHelper.findAllWithCountBySpec(actionRepository, specList, pageable); return JpaManagementHelper.findAllWithCountBySpec(actionRepository, specList, pageable);
@@ -338,10 +337,10 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
} }
@Override @Override
public Page<ActionStatus> findActionStatusByAction(final Pageable pageReq, final long actionId) { public Page<ActionStatus> findActionStatusByAction(final long actionId, final Pageable pageable) {
assertActionExistsAndAccessible(actionId); assertActionExistsAndAccessible(actionId);
return actionStatusRepository.findByActionId(pageReq, actionId); return actionStatusRepository.findByActionId(pageable, actionId);
} }
@Override @Override
@@ -355,7 +354,7 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
// permissions // permissions
// and UI which is to be removed // and UI which is to be removed
@Override @Override
public Page<String> findMessagesByActionStatusId(final Pageable pageable, final long actionStatusId) { public Page<String> findMessagesByActionStatusId(final long actionStatusId, final Pageable pageable) {
final CriteriaBuilder cb = entityManager.getCriteriaBuilder(); final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
final CriteriaQuery<String> msgQuery = cb.createQuery(String.class); final CriteriaQuery<String> msgQuery = cb.createQuery(String.class);
@@ -377,7 +376,7 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
} }
@Override @Override
public Page<Action> findActiveActionsByTarget(final Pageable pageable, final String controllerId) { public Page<Action> findActiveActionsByTarget(final String controllerId, final Pageable pageable) {
assertTargetReadAllowed(controllerId); assertTargetReadAllowed(controllerId);
return actionRepository return actionRepository
.findAll(ActionSpecifications.byTargetControllerIdAndActive(controllerId, true), pageable) .findAll(ActionSpecifications.byTargetControllerIdAndActive(controllerId, true), pageable)
@@ -385,7 +384,7 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
} }
@Override @Override
public Page<Action> findInActiveActionsByTarget(final Pageable pageable, final String controllerId) { public Page<Action> findInActiveActionsByTarget(final String controllerId, final Pageable pageable) {
assertTargetReadAllowed(controllerId); assertTargetReadAllowed(controllerId);
return actionRepository return actionRepository
.findAll(ActionSpecifications.byTargetControllerIdAndActive(controllerId, false), pageable) .findAll(ActionSpecifications.byTargetControllerIdAndActive(controllerId, false), pageable)

View File

@@ -280,9 +280,9 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
} }
@Override @Override
public Page<DistributionSet> findByRsql(final String rsqlParam, final Pageable pageable) { public Page<DistributionSet> findByRsql(final String rsql, final Pageable pageable) {
return JpaManagementHelper.findAllWithCountBySpec(distributionSetRepository, List.of( return JpaManagementHelper.findAllWithCountBySpec(distributionSetRepository, List.of(
RSQLUtility.buildRsqlSpecification(rsqlParam, DistributionSetFields.class, virtualPropertyReplacer, database), RSQLUtility.buildRsqlSpecification(rsql, DistributionSetFields.class, virtualPropertyReplacer, database),
DistributionSetSpecification.isNotDeleted()), pageable); DistributionSetSpecification.isNotDeleted()), pageable);
} }
@@ -511,7 +511,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
} }
@Override @Override
public Slice<DistributionSet> findByCompleted(final Pageable pageReq, final Boolean complete) { public Slice<DistributionSet> findByCompleted(final Boolean complete, final Pageable pageReq) {
final List<Specification<JpaDistributionSet>> specifications = buildSpecsByComplete(complete); final List<Specification<JpaDistributionSet>> specifications = buildSpecsByComplete(complete);
return JpaManagementHelper.findAllWithoutCountBySpec(distributionSetRepository, specifications, pageReq); return JpaManagementHelper.findAllWithoutCountBySpec(distributionSetRepository, specifications, pageReq);
@@ -547,11 +547,11 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
} }
@Override @Override
public Page<DistributionSet> findByRsqlAndTag(final String rsqlParam, final long tagId, final Pageable pageable) { public Page<DistributionSet> findByRsqlAndTag(final String rsql, final long tagId, final Pageable pageable) {
assertDsTagExists(tagId); assertDsTagExists(tagId);
return JpaManagementHelper.findAllWithCountBySpec(distributionSetRepository, List.of( return JpaManagementHelper.findAllWithCountBySpec(distributionSetRepository, List.of(
RSQLUtility.buildRsqlSpecification(rsqlParam, DistributionSetFields.class, virtualPropertyReplacer, RSQLUtility.buildRsqlSpecification(rsql, DistributionSetFields.class, virtualPropertyReplacer,
database), database),
DistributionSetSpecification.hasTag(tagId), DistributionSetSpecification.isNotDeleted()), pageable); DistributionSetSpecification.hasTag(tagId), DistributionSetSpecification.isNotDeleted()), pageable);
} }

View File

@@ -154,9 +154,9 @@ public class JpaDistributionSetTagManagement implements DistributionSetTagManage
} }
@Override @Override
public Page<DistributionSetTag> findByRsql(final String rsqlParam, final Pageable pageable) { public Page<DistributionSetTag> findByRsql(final String rsql, final Pageable pageable) {
final Specification<JpaDistributionSetTag> spec = RSQLUtility.buildRsqlSpecification( final Specification<JpaDistributionSetTag> spec = RSQLUtility.buildRsqlSpecification(
rsqlParam, DistributionSetTagFields.class, virtualPropertyReplacer, database); rsql, DistributionSetTagFields.class, virtualPropertyReplacer, database);
return JpaManagementHelper.findAllWithCountBySpec(distributionSetTagRepository, Collections.singletonList(spec), pageable); return JpaManagementHelper.findAllWithCountBySpec(distributionSetTagRepository, Collections.singletonList(spec), pageable);
} }
@@ -166,7 +166,7 @@ public class JpaDistributionSetTagManagement implements DistributionSetTagManage
} }
@Override @Override
public Page<DistributionSetTag> findByDistributionSet(final Pageable pageable, final long distributionSetId) { public Page<DistributionSetTag> findByDistributionSet(final long distributionSetId, final Pageable pageable) {
if (!distributionSetRepository.existsById(distributionSetId)) { if (!distributionSetRepository.existsById(distributionSetId)) {
throw new EntityNotFoundException(DistributionSet.class, distributionSetId); throw new EntityNotFoundException(DistributionSet.class, distributionSetId);
} }

View File

@@ -196,9 +196,9 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana
} }
@Override @Override
public Page<DistributionSetType> findByRsql(final String rsqlParam, final Pageable pageable) { public Page<DistributionSetType> findByRsql(final String rsql, final Pageable pageable) {
return JpaManagementHelper.findAllWithCountBySpec(distributionSetTypeRepository, List.of( return JpaManagementHelper.findAllWithCountBySpec(distributionSetTypeRepository, List.of(
RSQLUtility.buildRsqlSpecification(rsqlParam, DistributionSetTypeFields.class, virtualPropertyReplacer, database), RSQLUtility.buildRsqlSpecification(rsql, DistributionSetTypeFields.class, virtualPropertyReplacer, database),
DistributionSetTypeSpecification.isNotDeleted()), pageable); DistributionSetTypeSpecification.isNotDeleted()), pageable);
} }

View File

@@ -118,11 +118,11 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement {
} }
@Override @Override
public Page<RolloutGroup> findByRolloutAndRsql(final long rolloutId, final String rsqlParam, final Pageable pageable) { public Page<RolloutGroup> findByRolloutAndRsql(final long rolloutId, final String rsql, final Pageable pageable) {
throwEntityNotFoundExceptionIfRolloutDoesNotExist(rolloutId); throwEntityNotFoundExceptionIfRolloutDoesNotExist(rolloutId);
final List<Specification<JpaRolloutGroup>> specList = Arrays.asList( final List<Specification<JpaRolloutGroup>> specList = Arrays.asList(
RSQLUtility.buildRsqlSpecification(rsqlParam, RolloutGroupFields.class, virtualPropertyReplacer, RSQLUtility.buildRsqlSpecification(rsql, RolloutGroupFields.class, virtualPropertyReplacer,
database), database),
(root, query, cb) -> cb.equal(root.get(JpaRolloutGroup_.rollout).get(AbstractJpaBaseEntity_.id), rolloutId)); (root, query, cb) -> cb.equal(root.get(JpaRolloutGroup_.rollout).get(AbstractJpaBaseEntity_.id), rolloutId));
@@ -130,10 +130,10 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement {
} }
@Override @Override
public Page<RolloutGroup> findByRolloutAndRsqlWithDetailedStatus(final long rolloutId, final String rsqlParam, final Pageable pageable) { public Page<RolloutGroup> findByRolloutAndRsqlWithDetailedStatus(final long rolloutId, final String rsql, final Pageable pageable) {
throwEntityNotFoundExceptionIfRolloutDoesNotExist(rolloutId); throwEntityNotFoundExceptionIfRolloutDoesNotExist(rolloutId);
final Page<RolloutGroup> rolloutGroups = findByRolloutAndRsql(rolloutId, rsqlParam, pageable); final Page<RolloutGroup> rolloutGroups = findByRolloutAndRsql(rolloutId, rsql, pageable);
final List<Long> rolloutGroupIds = rolloutGroups.getContent().stream().map(RolloutGroup::getId).toList(); final List<Long> rolloutGroupIds = rolloutGroups.getContent().stream().map(RolloutGroup::getId).toList();
if (rolloutGroupIds.isEmpty()) { if (rolloutGroupIds.isEmpty()) {
// groups might already have been deleted, so return empty list. // groups might already have been deleted, so return empty list.
@@ -185,11 +185,11 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement {
} }
@Override @Override
public Page<Target> findTargetsOfRolloutGroupByRsql(final Pageable pageable, final long rolloutGroupId, final String rsqlParam) { public Page<Target> findTargetsOfRolloutGroupByRsql(final long rolloutGroupId, final String rsql, final Pageable pageable) {
throwExceptionIfRolloutGroupDoesNotExist(rolloutGroupId); throwExceptionIfRolloutGroupDoesNotExist(rolloutGroupId);
final List<Specification<JpaTarget>> specList = Arrays.asList( final List<Specification<JpaTarget>> specList = Arrays.asList(
RSQLUtility.buildRsqlSpecification(rsqlParam, TargetFields.class, virtualPropertyReplacer, database), RSQLUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database),
(root, query, cb) -> { (root, query, cb) -> {
final ListJoin<JpaTarget, RolloutTargetGroup> rolloutTargetJoin = root.join(JpaTarget_.rolloutTargetGroup); final ListJoin<JpaTarget, RolloutTargetGroup> rolloutTargetJoin = root.join(JpaTarget_.rolloutTargetGroup);
return cb.equal(rolloutTargetJoin.get(RolloutTargetGroup_.rolloutGroup).get(AbstractJpaBaseEntity_.id), rolloutGroupId); return cb.equal(rolloutTargetJoin.get(RolloutTargetGroup_.rolloutGroup).get(AbstractJpaBaseEntity_.id), rolloutGroupId);

View File

@@ -260,20 +260,20 @@ public class JpaRolloutManagement implements RolloutManagement {
} }
@Override @Override
public Page<Rollout> findAll(final Pageable pageable, final boolean deleted) { public Page<Rollout> findAll(final boolean deleted, final Pageable pageable) {
return JpaManagementHelper.convertPage( return JpaManagementHelper.convertPage(
rolloutRepository.findAll(RolloutSpecification.isDeleted(deleted, pageable.getSort()), pageable), pageable); rolloutRepository.findAll(RolloutSpecification.isDeleted(deleted, pageable.getSort()), pageable), pageable);
} }
@Override @Override
public Page<Rollout> findAllWithDetailedStatus(final Pageable pageable, final boolean deleted) { public Page<Rollout> findAllWithDetailedStatus(final boolean deleted, final Pageable pageable) {
return appendStatusDetails(JpaManagementHelper.convertPage( return appendStatusDetails(JpaManagementHelper.convertPage(
rolloutRepository.findAll(RolloutSpecification.isDeleted(deleted, pageable.getSort()), JpaRollout_.GRAPH_ROLLOUT_DS, pageable), rolloutRepository.findAll(RolloutSpecification.isDeleted(deleted, pageable.getSort()), JpaRollout_.GRAPH_ROLLOUT_DS, pageable),
pageable)); pageable));
} }
@Override @Override
public Page<Rollout> findByRsql(final Pageable pageable, final String rsql, final boolean deleted) { public Page<Rollout> findByRsql(final String rsql, final boolean deleted, final Pageable pageable) {
final List<Specification<JpaRollout>> specList = List.of( final List<Specification<JpaRollout>> specList = List.of(
RSQLUtility.buildRsqlSpecification(rsql, RolloutFields.class, virtualPropertyReplacer, database), RSQLUtility.buildRsqlSpecification(rsql, RolloutFields.class, virtualPropertyReplacer, database),
RolloutSpecification.isDeleted(deleted, pageable.getSort())); RolloutSpecification.isDeleted(deleted, pageable.getSort()));
@@ -281,7 +281,7 @@ public class JpaRolloutManagement implements RolloutManagement {
} }
@Override @Override
public Page<Rollout> findByRsqlWithDetailedStatus(final Pageable pageable, final String rsql, final boolean deleted) { public Page<Rollout> findByRsqlWithDetailedStatus(final String rsql, final boolean deleted, final Pageable pageable) {
final List<Specification<JpaRollout>> specList = List.of( final List<Specification<JpaRollout>> specList = List.of(
RSQLUtility.buildRsqlSpecification(rsql, RolloutFields.class, virtualPropertyReplacer, database), RSQLUtility.buildRsqlSpecification(rsql, RolloutFields.class, virtualPropertyReplacer, database),
RolloutSpecification.isDeleted(deleted, pageable.getSort())); RolloutSpecification.isDeleted(deleted, pageable.getSort()));

View File

@@ -259,9 +259,9 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
} }
@Override @Override
public Page<SoftwareModule> findByRsql(final String rsqlParam, final Pageable pageable) { public Page<SoftwareModule> findByRsql(final String rsql, final Pageable pageable) {
return JpaManagementHelper.findAllWithCountBySpec(softwareModuleRepository, List.of( return JpaManagementHelper.findAllWithCountBySpec(softwareModuleRepository, List.of(
RSQLUtility.buildRsqlSpecification(rsqlParam, SoftwareModuleFields.class, virtualPropertyReplacer, RSQLUtility.buildRsqlSpecification(rsql, SoftwareModuleFields.class, virtualPropertyReplacer,
database), database),
SoftwareModuleSpecification.isNotDeleted()), pageable); SoftwareModuleSpecification.isNotDeleted()), pageable);
} }
@@ -303,7 +303,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement {
} }
@Override @Override
public Page<SoftwareModuleMetadata> findMetaDataBySoftwareModuleIdAndTargetVisible(final Pageable pageable, final long id) { public Page<SoftwareModuleMetadata> findMetaDataBySoftwareModuleIdAndTargetVisible(final long id, final Pageable pageable) {
assertSoftwareModuleExists(id); assertSoftwareModuleExists(id);
return JpaManagementHelper.convertPage(softwareModuleMetadataRepository.findBySoftwareModuleIdAndTargetVisible( return JpaManagementHelper.convertPage(softwareModuleMetadataRepository.findBySoftwareModuleIdAndTargetVisible(

View File

@@ -142,9 +142,9 @@ public class JpaSoftwareModuleTypeManagement implements SoftwareModuleTypeManage
} }
@Override @Override
public Page<SoftwareModuleType> findByRsql(final String rsqlParam, final Pageable pageable) { public Page<SoftwareModuleType> findByRsql(final String rsql, final Pageable pageable) {
return JpaManagementHelper.findAllWithCountBySpec(softwareModuleTypeRepository, List.of( return JpaManagementHelper.findAllWithCountBySpec(softwareModuleTypeRepository, List.of(
RSQLUtility.buildRsqlSpecification(rsqlParam, SoftwareModuleTypeFields.class, RSQLUtility.buildRsqlSpecification(rsql, SoftwareModuleTypeFields.class,
virtualPropertyReplacer, database), virtualPropertyReplacer, database),
SoftwareModuleTypeSpecification.isNotDeleted()), pageable SoftwareModuleTypeSpecification.isNotDeleted()), pageable
); );

View File

@@ -172,7 +172,7 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
} }
@Override @Override
public Slice<TargetFilterQuery> findByName(final Pageable pageable, final String name) { public Slice<TargetFilterQuery> findByName(final String name, final Pageable pageable) {
if (ObjectUtils.isEmpty(name)) { if (ObjectUtils.isEmpty(name)) {
return findAll(pageable); return findAll(pageable);
} }
@@ -193,7 +193,7 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
} }
@Override @Override
public Page<TargetFilterQuery> findByRsql(final Pageable pageable, final String rsqlFilter) { public Page<TargetFilterQuery> findByRsql(final String rsqlFilter, final Pageable pageable) {
final List<Specification<JpaTargetFilterQuery>> specList = !ObjectUtils.isEmpty(rsqlFilter) final List<Specification<JpaTargetFilterQuery>> specList = !ObjectUtils.isEmpty(rsqlFilter)
? Collections.singletonList(RSQLUtility.buildRsqlSpecification(rsqlFilter, ? Collections.singletonList(RSQLUtility.buildRsqlSpecification(rsqlFilter,
TargetFilterQueryFields.class, virtualPropertyReplacer, database)) TargetFilterQueryFields.class, virtualPropertyReplacer, database))
@@ -203,7 +203,7 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
} }
@Override @Override
public Slice<TargetFilterQuery> findByQuery(final Pageable pageable, final String query) { public Slice<TargetFilterQuery> findByQuery(final String query, final Pageable pageable) {
final List<Specification<JpaTargetFilterQuery>> specList = !ObjectUtils.isEmpty(query) final List<Specification<JpaTargetFilterQuery>> specList = !ObjectUtils.isEmpty(query)
? Collections.singletonList(TargetFilterQuerySpecification.equalsQuery(query)) ? Collections.singletonList(TargetFilterQuerySpecification.equalsQuery(query))
: Collections.emptyList(); : Collections.emptyList();
@@ -212,8 +212,7 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
} }
@Override @Override
public Slice<TargetFilterQuery> findByAutoAssignDistributionSetId(@NotNull final Pageable pageable, public Slice<TargetFilterQuery> findByAutoAssignDistributionSetId(final long setId, @NotNull final Pageable pageable) {
final long setId) {
final DistributionSet distributionSet = distributionSetManagement.getOrElseThrowException(setId); final DistributionSet distributionSet = distributionSetManagement.getOrElseThrowException(setId);
return JpaManagementHelper.findAllWithoutCountBySpec(targetFilterQueryRepository, return JpaManagementHelper.findAllWithoutCountBySpec(targetFilterQueryRepository,
@@ -222,14 +221,13 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
} }
@Override @Override
public Page<TargetFilterQuery> findByAutoAssignDSAndRsql(final Pageable pageable, final long setId, public Page<TargetFilterQuery> findByAutoAssignDSAndRsql(final long setId, final String rsql, final Pageable pageable) {
final String rsqlFilter) {
final DistributionSet distributionSet = distributionSetManagement.getOrElseThrowException(setId); final DistributionSet distributionSet = distributionSetManagement.getOrElseThrowException(setId);
final List<Specification<JpaTargetFilterQuery>> specList = new ArrayList<>(2); final List<Specification<JpaTargetFilterQuery>> specList = new ArrayList<>(2);
specList.add(TargetFilterQuerySpecification.byAutoAssignDS(distributionSet)); specList.add(TargetFilterQuerySpecification.byAutoAssignDS(distributionSet));
if (!ObjectUtils.isEmpty(rsqlFilter)) { if (!ObjectUtils.isEmpty(rsql)) {
specList.add(RSQLUtility.buildRsqlSpecification(rsqlFilter, TargetFilterQueryFields.class, specList.add(RSQLUtility.buildRsqlSpecification(rsql, TargetFilterQueryFields.class,
virtualPropertyReplacer, database)); virtualPropertyReplacer, database));
} }

View File

@@ -156,33 +156,33 @@ public class JpaTargetManagement implements TargetManagement {
} }
@Override @Override
public long countByRsql(final String targetFilterQuery) { public long countByRsql(final String rsql) {
return JpaManagementHelper.countBySpec( return JpaManagementHelper.countBySpec(
targetRepository, targetRepository,
List.of(RSQLUtility.buildRsqlSpecification(targetFilterQuery, TargetFields.class, virtualPropertyReplacer, database))); List.of(RSQLUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database)));
} }
@Override @Override
public long countByRsqlAndUpdatable(String targetFilterQuery) { public long countByRsqlAndUpdatable(String rsql) {
final List<Specification<JpaTarget>> specList = List.of( final List<Specification<JpaTarget>> specList = List.of(
RSQLUtility.buildRsqlSpecification(targetFilterQuery, TargetFields.class, virtualPropertyReplacer, database)); RSQLUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database));
return targetRepository.count( return targetRepository.count(
AccessController.Operation.UPDATE, AccessController.Operation.UPDATE,
combineWithAnd(specList)); combineWithAnd(specList));
} }
@Override @Override
public long countByRsqlAndCompatible(final String targetFilterQuery, final Long distributionSetIdTypeId) { public long countByRsqlAndCompatible(final String rsql, final Long distributionSetIdTypeId) {
final List<Specification<JpaTarget>> specList = List.of( final List<Specification<JpaTarget>> specList = List.of(
RSQLUtility.buildRsqlSpecification(targetFilterQuery, TargetFields.class, virtualPropertyReplacer, database), RSQLUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database),
TargetSpecifications.isCompatibleWithDistributionSetType(distributionSetIdTypeId)); TargetSpecifications.isCompatibleWithDistributionSetType(distributionSetIdTypeId));
return JpaManagementHelper.countBySpec(targetRepository, specList); return JpaManagementHelper.countBySpec(targetRepository, specList);
} }
@Override @Override
public long countByRsqlAndCompatibleAndUpdatable(String targetFilterQuery, Long distributionSetIdTypeId) { public long countByRsqlAndCompatibleAndUpdatable(String rsql, Long distributionSetIdTypeId) {
final List<Specification<JpaTarget>> specList = List.of( final List<Specification<JpaTarget>> specList = List.of(
RSQLUtility.buildRsqlSpecification(targetFilterQuery, TargetFields.class, virtualPropertyReplacer, database), RSQLUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database),
TargetSpecifications.isCompatibleWithDistributionSetType(distributionSetIdTypeId)); TargetSpecifications.isCompatibleWithDistributionSetType(distributionSetIdTypeId));
return targetRepository.count(AccessController.Operation.UPDATE, combineWithAnd(specList)); return targetRepository.count(AccessController.Operation.UPDATE, combineWithAnd(specList));
} }
@@ -246,8 +246,8 @@ public class JpaTargetManagement implements TargetManagement {
} }
@Override @Override
public Slice<Target> findByTargetFilterQueryAndNonDSAndCompatibleAndUpdatable(final Pageable pageRequest, public Slice<Target> findByTargetFilterQueryAndNonDSAndCompatibleAndUpdatable(final long distributionSetId, final String rsql,
final long distributionSetId, final String targetFilterQuery) { final Pageable pageable) {
final DistributionSet jpaDistributionSet = distributionSetManagement.getOrElseThrowException(distributionSetId); final DistributionSet jpaDistributionSet = distributionSetManagement.getOrElseThrowException(distributionSetId);
final Long distSetTypeId = jpaDistributionSet.getType().getId(); final Long distSetTypeId = jpaDistributionSet.getType().getId();
@@ -255,15 +255,15 @@ public class JpaTargetManagement implements TargetManagement {
.findAllWithoutCount( .findAllWithoutCount(
AccessController.Operation.UPDATE, AccessController.Operation.UPDATE,
combineWithAnd(List.of( combineWithAnd(List.of(
RSQLUtility.buildRsqlSpecification(targetFilterQuery, TargetFields.class, virtualPropertyReplacer, database), RSQLUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database),
TargetSpecifications.hasNotDistributionSetInActions(distributionSetId), TargetSpecifications.hasNotDistributionSetInActions(distributionSetId),
TargetSpecifications.isCompatibleWithDistributionSetType(distSetTypeId))), TargetSpecifications.isCompatibleWithDistributionSetType(distSetTypeId))),
pageRequest) pageable)
.map(Target.class::cast); .map(Target.class::cast);
} }
@Override @Override
public long countByRsqlAndNonDSAndCompatibleAndUpdatable(final long distributionSetId, final String targetFilterQuery) { public long countByRsqlAndNonDSAndCompatibleAndUpdatable(final long distributionSetId, final String rsql) {
final DistributionSet jpaDistributionSet = distributionSetManagement.getOrElseThrowException(distributionSetId); final DistributionSet jpaDistributionSet = distributionSetManagement.getOrElseThrowException(distributionSetId);
final Long distSetTypeId = jpaDistributionSet.getType().getId(); final Long distSetTypeId = jpaDistributionSet.getType().getId();
@@ -271,35 +271,35 @@ public class JpaTargetManagement implements TargetManagement {
AccessController.Operation.UPDATE, AccessController.Operation.UPDATE,
combineWithAnd(List.of( combineWithAnd(List.of(
RSQLUtility.buildRsqlSpecification( RSQLUtility.buildRsqlSpecification(
targetFilterQuery, TargetFields.class, virtualPropertyReplacer, database), rsql, TargetFields.class, virtualPropertyReplacer, database),
TargetSpecifications.hasNotDistributionSetInActions(distributionSetId), TargetSpecifications.hasNotDistributionSetInActions(distributionSetId),
TargetSpecifications.isCompatibleWithDistributionSetType(distSetTypeId)))); TargetSpecifications.isCompatibleWithDistributionSetType(distSetTypeId))));
} }
@Override @Override
public Slice<Target> findByTargetFilterQueryAndNotInRolloutAndCompatibleAndUpdatable( public Slice<Target> findByTargetFilterQueryAndNotInRolloutAndCompatibleAndUpdatable(
final Pageable pageRequest, final Collection<Long> groups, final String targetFilterQuery, final DistributionSetType dsType) { final Collection<Long> groups, final String targetFilterQuery, final DistributionSetType dsType, final Pageable pageable) {
return targetRepository return targetRepository
.findAllWithoutCount(AccessController.Operation.UPDATE, .findAllWithoutCount(AccessController.Operation.UPDATE,
combineWithAnd(List.of( combineWithAnd(List.of(
RSQLUtility.buildRsqlSpecification(targetFilterQuery, TargetFields.class, virtualPropertyReplacer, database), RSQLUtility.buildRsqlSpecification(targetFilterQuery, TargetFields.class, virtualPropertyReplacer, database),
TargetSpecifications.isNotInRolloutGroups(groups), TargetSpecifications.isNotInRolloutGroups(groups),
TargetSpecifications.isCompatibleWithDistributionSetType(dsType.getId()))), TargetSpecifications.isCompatibleWithDistributionSetType(dsType.getId()))),
pageRequest) pageable)
.map(Target.class::cast); .map(Target.class::cast);
} }
@Override @Override
public Slice<Target> findByTargetFilterQueryAndNoOverridingActionsAndNotInRolloutAndCompatibleAndUpdatable( public Slice<Target> findByTargetFilterQueryAndNoOverridingActionsAndNotInRolloutAndCompatibleAndUpdatable(
final Pageable pageRequest, final long rolloutId, final int weight, final long firstGroupId, final String targetFilterQuery, final long rolloutId, final int weight, final long firstGroupId, final String targetFilterQuery,
final DistributionSetType distributionSetType) { final DistributionSetType distributionSetType, final Pageable pageable) {
return targetRepository return targetRepository
.findAllWithoutCount(AccessController.Operation.UPDATE, .findAllWithoutCount(AccessController.Operation.UPDATE,
combineWithAnd(List.of( combineWithAnd(List.of(
RSQLUtility.buildRsqlSpecification(targetFilterQuery, TargetFields.class, virtualPropertyReplacer, database), RSQLUtility.buildRsqlSpecification(targetFilterQuery, TargetFields.class, virtualPropertyReplacer, database),
TargetSpecifications.hasNoOverridingActionsAndNotInRollout(weight, rolloutId), TargetSpecifications.hasNoOverridingActionsAndNotInRollout(weight, rolloutId),
TargetSpecifications.isCompatibleWithDistributionSetType(distributionSetType.getId()))), TargetSpecifications.isCompatibleWithDistributionSetType(distributionSetType.getId()))),
pageRequest) pageable)
.map(Target.class::cast); .map(Target.class::cast);
} }
@@ -309,21 +309,20 @@ public class JpaTargetManagement implements TargetManagement {
} }
@Override @Override
public Slice<Target> findByFailedRolloutAndNotInRolloutGroups(Pageable pageRequest, Collection<Long> groups, public Slice<Target> findByFailedRolloutAndNotInRolloutGroups(String rolloutId, Collection<Long> groups, Pageable pageable) {
String rolloutId) {
final List<Specification<JpaTarget>> specList = List.of( final List<Specification<JpaTarget>> specList = List.of(
TargetSpecifications.failedActionsForRollout(rolloutId), TargetSpecifications.failedActionsForRollout(rolloutId),
TargetSpecifications.isNotInRolloutGroups(groups)); TargetSpecifications.isNotInRolloutGroups(groups));
return JpaManagementHelper.findAllWithCountBySpec(targetRepository, specList, pageRequest); return JpaManagementHelper.findAllWithCountBySpec(targetRepository, specList, pageable);
} }
@Override @Override
public long countByRsqlAndNotInRolloutGroupsAndCompatibleAndUpdatable( public long countByRsqlAndNotInRolloutGroupsAndCompatibleAndUpdatable(
final String targetFilterQuery, final Collection<Long> groups, final DistributionSetType dsType) { final String rsql, final Collection<Long> groups, final DistributionSetType dsType) {
return targetRepository.count(AccessController.Operation.UPDATE, return targetRepository.count(AccessController.Operation.UPDATE,
combineWithAnd(List.of( combineWithAnd(List.of(
RSQLUtility.buildRsqlSpecification(targetFilterQuery, TargetFields.class, virtualPropertyReplacer, database), RSQLUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database),
TargetSpecifications.isNotInRolloutGroups(groups), TargetSpecifications.isNotInRolloutGroups(groups),
TargetSpecifications.isCompatibleWithDistributionSetType(dsType.getId())))); TargetSpecifications.isCompatibleWithDistributionSetType(dsType.getId()))));
} }
@@ -337,33 +336,33 @@ public class JpaTargetManagement implements TargetManagement {
} }
@Override @Override
public Slice<Target> findByInRolloutGroupWithoutAction(final Pageable pageRequest, final long group) { public Slice<Target> findByInRolloutGroupWithoutAction(final long group, final Pageable pageable) {
if (!rolloutGroupRepository.existsById(group)) { if (!rolloutGroupRepository.existsById(group)) {
throw new EntityNotFoundException(RolloutGroup.class, group); throw new EntityNotFoundException(RolloutGroup.class, group);
} }
return JpaManagementHelper.findAllWithoutCountBySpec( return JpaManagementHelper.findAllWithoutCountBySpec(
targetRepository, List.of(TargetSpecifications.hasNoActionInRolloutGroup(group)), pageRequest); targetRepository, List.of(TargetSpecifications.hasNoActionInRolloutGroup(group)), pageable);
} }
@Override @Override
public Page<Target> findByAssignedDistributionSet(final Pageable pageReq, final long distributionSetId) { public Page<Target> findByAssignedDistributionSet(final long distributionSetId, final Pageable pageable) {
final DistributionSet validDistSet = distributionSetManagement.getOrElseThrowException(distributionSetId); final DistributionSet validDistSet = distributionSetManagement.getOrElseThrowException(distributionSetId);
return JpaManagementHelper.findAllWithCountBySpec( return JpaManagementHelper.findAllWithCountBySpec(
targetRepository, targetRepository,
List.of(TargetSpecifications.hasAssignedDistributionSet(validDistSet.getId())), pageReq); List.of(TargetSpecifications.hasAssignedDistributionSet(validDistSet.getId())), pageable);
} }
@Override @Override
public Page<Target> findByAssignedDistributionSetAndRsql(final Pageable pageReq, final long distributionSetId, final String rsqlParam) { public Page<Target> findByAssignedDistributionSetAndRsql(final long distributionSetId, final String rsql, final Pageable pageable) {
final DistributionSet validDistSet = distributionSetManagement.getOrElseThrowException(distributionSetId); final DistributionSet validDistSet = distributionSetManagement.getOrElseThrowException(distributionSetId);
final List<Specification<JpaTarget>> specList = List.of( final List<Specification<JpaTarget>> specList = List.of(
RSQLUtility.buildRsqlSpecification(rsqlParam, TargetFields.class, virtualPropertyReplacer, database), RSQLUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database),
TargetSpecifications.hasAssignedDistributionSet(validDistSet.getId())); TargetSpecifications.hasAssignedDistributionSet(validDistSet.getId()));
return JpaManagementHelper.findAllWithCountBySpec(targetRepository, specList, pageReq); return JpaManagementHelper.findAllWithCountBySpec(targetRepository, specList, pageable);
} }
@Override @Override
@@ -382,13 +381,13 @@ public class JpaTargetManagement implements TargetManagement {
} }
@Override @Override
public Slice<Target> findByFilters(final Pageable pageable, final FilterParams filterParams) { public Slice<Target> findByFilters(final FilterParams filterParams, final Pageable pageable) {
final List<Specification<JpaTarget>> specList = buildSpecificationList(filterParams); final List<Specification<JpaTarget>> specList = buildSpecificationList(filterParams);
return JpaManagementHelper.findAllWithoutCountBySpec(targetRepository, specList, pageable); return JpaManagementHelper.findAllWithoutCountBySpec(targetRepository, specList, pageable);
} }
@Override @Override
public Page<Target> findByInstalledDistributionSet(final Pageable pageReq, final long distributionSetId) { public Page<Target> findByInstalledDistributionSet(final long distributionSetId, final Pageable pageReq) {
final DistributionSet validDistSet = distributionSetManagement.getOrElseThrowException(distributionSetId); final DistributionSet validDistSet = distributionSetManagement.getOrElseThrowException(distributionSetId);
return JpaManagementHelper.findAllWithCountBySpec( return JpaManagementHelper.findAllWithCountBySpec(
@@ -396,18 +395,18 @@ public class JpaTargetManagement implements TargetManagement {
} }
@Override @Override
public Page<Target> findByInstalledDistributionSetAndRsql(final Pageable pageable, final long distributionSetId, final String rsqlParam) { public Page<Target> findByInstalledDistributionSetAndRsql(final long distributionSetId, final String rsql, final Pageable pageable) {
final DistributionSet validDistSet = distributionSetManagement.getOrElseThrowException(distributionSetId); final DistributionSet validDistSet = distributionSetManagement.getOrElseThrowException(distributionSetId);
final List<Specification<JpaTarget>> specList = List.of( final List<Specification<JpaTarget>> specList = List.of(
RSQLUtility.buildRsqlSpecification(rsqlParam, TargetFields.class, virtualPropertyReplacer, database), RSQLUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database),
TargetSpecifications.hasInstalledDistributionSet(validDistSet.getId())); TargetSpecifications.hasInstalledDistributionSet(validDistSet.getId()));
return JpaManagementHelper.findAllWithCountBySpec(targetRepository, specList, pageable); return JpaManagementHelper.findAllWithCountBySpec(targetRepository, specList, pageable);
} }
@Override @Override
public Page<Target> findByUpdateStatus(final Pageable pageable, final TargetUpdateStatus status) { public Page<Target> findByUpdateStatus(final TargetUpdateStatus status, final Pageable pageable) {
return JpaManagementHelper.findAllWithCountBySpec( return JpaManagementHelper.findAllWithCountBySpec(
targetRepository, List.of(TargetSpecifications.hasTargetUpdateStatus(status)), pageable); targetRepository, List.of(TargetSpecifications.hasTargetUpdateStatus(status)), pageable);
} }
@@ -418,15 +417,15 @@ public class JpaTargetManagement implements TargetManagement {
} }
@Override @Override
public Slice<Target> findByRsql(final Pageable pageable, final String targetFilterQuery) { public Slice<Target> findByRsql(final String rsql, final Pageable pageable) {
return JpaManagementHelper.findAllWithoutCountBySpec( return JpaManagementHelper.findAllWithoutCountBySpec(
targetRepository, targetRepository,
List.of(RSQLUtility.buildRsqlSpecification(targetFilterQuery, TargetFields.class, virtualPropertyReplacer, database)), pageable List.of(RSQLUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database)), pageable
); );
} }
@Override @Override
public Slice<Target> findByTargetFilterQuery(final Pageable pageable, final long targetFilterQueryId) { public Slice<Target> findByTargetFilterQuery(final long targetFilterQueryId, final Pageable pageable) {
final TargetFilterQuery targetFilterQuery = targetFilterQueryRepository.findById(targetFilterQueryId) final TargetFilterQuery targetFilterQuery = targetFilterQueryRepository.findById(targetFilterQueryId)
.orElseThrow(() -> new EntityNotFoundException(TargetFilterQuery.class, targetFilterQueryId)); .orElseThrow(() -> new EntityNotFoundException(TargetFilterQuery.class, targetFilterQueryId));
@@ -437,17 +436,17 @@ public class JpaTargetManagement implements TargetManagement {
} }
@Override @Override
public Page<Target> findByTag(final Pageable pageable, final long tagId) { public Page<Target> findByTag(final long tagId, final Pageable pageable) {
throwEntityNotFoundExceptionIfTagDoesNotExist(tagId); throwEntityNotFoundExceptionIfTagDoesNotExist(tagId);
return JpaManagementHelper.findAllWithCountBySpec(targetRepository, List.of(TargetSpecifications.hasTag(tagId)), pageable); return JpaManagementHelper.findAllWithCountBySpec(targetRepository, List.of(TargetSpecifications.hasTag(tagId)), pageable);
} }
@Override @Override
public Page<Target> findByRsqlAndTag(final Pageable pageable, final String rsqlParam, final long tagId) { public Page<Target> findByRsqlAndTag(final String rsql, final long tagId, final Pageable pageable) {
throwEntityNotFoundExceptionIfTagDoesNotExist(tagId); throwEntityNotFoundExceptionIfTagDoesNotExist(tagId);
final List<Specification<JpaTarget>> specList = List.of( final List<Specification<JpaTarget>> specList = List.of(
RSQLUtility.buildRsqlSpecification(rsqlParam, TargetFields.class, virtualPropertyReplacer, database), RSQLUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database),
TargetSpecifications.hasTag(tagId)); TargetSpecifications.hasTag(tagId));
return JpaManagementHelper.findAllWithCountBySpec(targetRepository, specList, pageable); return JpaManagementHelper.findAllWithCountBySpec(targetRepository, specList, pageable);
@@ -665,9 +664,9 @@ public class JpaTargetManagement implements TargetManagement {
} }
@Override @Override
public Page<Target> findByControllerAttributesRequested(final Pageable pageReq) { public Page<Target> findByControllerAttributesRequested(final Pageable pageable) {
return JpaManagementHelper.findAllWithCountBySpec( return JpaManagementHelper.findAllWithCountBySpec(
targetRepository, List.of(TargetSpecifications.hasRequestControllerAttributesTrue()), pageReq); targetRepository, List.of(TargetSpecifications.hasRequestControllerAttributesTrue()), pageable);
} }
@Override @Override

View File

@@ -103,9 +103,9 @@ public class JpaTargetTagManagement implements TargetTagManagement {
} }
@Override @Override
public Page<TargetTag> findByRsql(final Pageable pageable, final String rsqlParam) { public Page<TargetTag> findByRsql(final String rsql, final Pageable pageable) {
return JpaManagementHelper.findAllWithCountBySpec(targetTagRepository, Collections.singletonList( return JpaManagementHelper.findAllWithCountBySpec(targetTagRepository, Collections.singletonList(
RSQLUtility.buildRsqlSpecification(rsqlParam, TargetTagFields.class, virtualPropertyReplacer, database)), pageable); RSQLUtility.buildRsqlSpecification(rsql, TargetTagFields.class, virtualPropertyReplacer, database)), pageable);
} }
@Override @Override

View File

@@ -144,15 +144,15 @@ public class JpaTargetTypeManagement implements TargetTypeManagement {
} }
@Override @Override
public Page<TargetType> findByRsql(final Pageable pageable, final String rsqlParam) { public Page<TargetType> findByRsql(final String rsql, final Pageable pageable) {
return JpaManagementHelper.findAllWithCountBySpec(targetTypeRepository, List.of( return JpaManagementHelper.findAllWithCountBySpec(targetTypeRepository, List.of(
RSQLUtility.buildRsqlSpecification( RSQLUtility.buildRsqlSpecification(
rsqlParam, TargetTypeFields.class, virtualPropertyReplacer, database)), pageable rsql, TargetTypeFields.class, virtualPropertyReplacer, database)), pageable
); );
} }
@Override @Override
public Slice<TargetType> findByName(final Pageable pageable, final String name) { public Slice<TargetType> findByName(final String name, final Pageable pageable) {
return JpaManagementHelper.findAllWithoutCountBySpec(targetTypeRepository, List.of(TargetTypeSpecification.likeName(name)), pageable return JpaManagementHelper.findAllWithoutCountBySpec(targetTypeRepository, List.of(TargetTypeSpecification.likeName(name)), pageable
); );
} }

View File

@@ -78,7 +78,7 @@ class DistributionSetAccessControllerTest extends AbstractAccessControllerTest {
.toList()).containsOnly(permittedActionId); .toList()).containsOnly(permittedActionId);
// verify distributionSetManagement#findByCompleted // verify distributionSetManagement#findByCompleted
assertThat(distributionSetManagement.findByCompleted(Pageable.unpaged(), true).get().map(Identifiable::getId) assertThat(distributionSetManagement.findByCompleted(true, Pageable.unpaged()).get().map(Identifiable::getId)
.toList()).containsOnly(permittedActionId); .toList()).containsOnly(permittedActionId);
// verify distributionSetManagement#findByDistributionSetFilter // verify distributionSetManagement#findByDistributionSetFilter

View File

@@ -68,11 +68,11 @@ class TargetAccessControllerTest extends AbstractAccessControllerTest {
.containsOnly(permittedTarget.getId()); .containsOnly(permittedTarget.getId());
// verify targetManagement#findByRsql // verify targetManagement#findByRsql
assertThat(targetManagement.findByRsql(Pageable.unpaged(), "id==*").get().map(Identifiable::getId).toList()) assertThat(targetManagement.findByRsql("id==*", Pageable.unpaged()).get().map(Identifiable::getId).toList())
.containsOnly(permittedTarget.getId()); .containsOnly(permittedTarget.getId());
// verify targetManagement#findByUpdateStatus // verify targetManagement#findByUpdateStatus
assertThat(targetManagement.findByUpdateStatus(Pageable.unpaged(), TargetUpdateStatus.REGISTERED).get() assertThat(targetManagement.findByUpdateStatus(TargetUpdateStatus.REGISTERED, Pageable.unpaged()).get()
.map(Identifiable::getId).toList()).containsOnly(permittedTarget.getId()); .map(Identifiable::getId).toList()).containsOnly(permittedTarget.getId());
// verify targetManagement#getByControllerID // verify targetManagement#getByControllerID
@@ -105,11 +105,11 @@ class TargetAccessControllerTest extends AbstractAccessControllerTest {
.create(entityFactory.targetFilterQuery().create().name("test").query("id==*")); .create(entityFactory.targetFilterQuery().create().name("test").query("id==*"));
// verify targetManagement#findByTargetFilterQuery // verify targetManagement#findByTargetFilterQuery
assertThat(targetManagement.findByTargetFilterQuery(Pageable.unpaged(), targetFilterQuery.getId()).get() assertThat(targetManagement.findByTargetFilterQuery(targetFilterQuery.getId(), Pageable.unpaged()).get()
.map(Identifiable::getId).toList()).containsOnly(permittedTarget.getId()); .map(Identifiable::getId).toList()).containsOnly(permittedTarget.getId());
// verify targetManagement#findByTargetFilterQuery (used by UI) // verify targetManagement#findByTargetFilterQuery (used by UI)
assertThat(targetManagement.findByFilters(Pageable.unpaged(), new FilterParams(null, null, null, null)).get() assertThat(targetManagement.findByFilters(new FilterParams(null, null, null, null), Pageable.unpaged()).get()
.map(Identifiable::getId).toList()).containsOnly(permittedTarget.getId()); .map(Identifiable::getId).toList()).containsOnly(permittedTarget.getId());
} }
@@ -145,11 +145,11 @@ class TargetAccessControllerTest extends AbstractAccessControllerTest {
// verify targetManagement#findByTag // verify targetManagement#findByTag
assertThat( assertThat(
targetManagement.findByTag(Pageable.unpaged(), myTagId).get().map(Identifiable::getId).toList()) targetManagement.findByTag(myTagId, Pageable.unpaged()).get().map(Identifiable::getId).toList())
.containsOnly(permittedTarget.getId(), readOnlyTarget.getId()); .containsOnly(permittedTarget.getId(), readOnlyTarget.getId());
// verify targetManagement#findByRsqlAndTag // verify targetManagement#findByRsqlAndTag
assertThat(targetManagement.findByRsqlAndTag(Pageable.unpaged(), "id==*", myTagId).get() assertThat(targetManagement.findByRsqlAndTag("id==*", myTagId, Pageable.unpaged()).get()
.map(Identifiable::getId).toList()).containsOnly(permittedTarget.getId(), readOnlyTarget.getId()); .map(Identifiable::getId).toList()).containsOnly(permittedTarget.getId(), readOnlyTarget.getId());
// verify targetManagement#assignTag on permitted target // verify targetManagement#assignTag on permitted target
@@ -228,7 +228,7 @@ class TargetAccessControllerTest extends AbstractAccessControllerTest {
overwriteAccess(AccessController.Operation.READ, permittedTarget); overwriteAccess(AccessController.Operation.READ, permittedTarget);
// verify targetManagement#findByUpdateStatus before assignment // verify targetManagement#findByUpdateStatus before assignment
assertThat(targetManagement.findByUpdateStatus(Pageable.unpaged(), TargetUpdateStatus.REGISTERED).get() assertThat(targetManagement.findByUpdateStatus(TargetUpdateStatus.REGISTERED, Pageable.unpaged()).get()
.map(Identifiable::getId).toList()).containsOnly(permittedTarget.getId()); .map(Identifiable::getId).toList()).containsOnly(permittedTarget.getId());
testAccessControlManger.defineAccessRule( testAccessControlManger.defineAccessRule(
@@ -241,11 +241,11 @@ class TargetAccessControllerTest extends AbstractAccessControllerTest {
assertThatThrownBy(() -> assignDistributionSet(dsId, hiddenTargetControllerId)).isInstanceOf(AssertionError.class); assertThatThrownBy(() -> assignDistributionSet(dsId, hiddenTargetControllerId)).isInstanceOf(AssertionError.class);
// verify targetManagement#findByUpdateStatus(REGISTERED) after assignment // verify targetManagement#findByUpdateStatus(REGISTERED) after assignment
assertThat(targetManagement.findByUpdateStatus(Pageable.unpaged(), TargetUpdateStatus.REGISTERED) assertThat(targetManagement.findByUpdateStatus(TargetUpdateStatus.REGISTERED, Pageable.unpaged())
.getTotalElements()).isZero(); .getTotalElements()).isZero();
// verify targetManagement#findByUpdateStatus(PENDING) after assignment // verify targetManagement#findByUpdateStatus(PENDING) after assignment
assertThat(targetManagement.findByUpdateStatus(Pageable.unpaged(), TargetUpdateStatus.PENDING).get() assertThat(targetManagement.findByUpdateStatus(TargetUpdateStatus.PENDING, Pageable.unpaged()).get()
.map(Identifiable::getId).toList()).containsOnly(permittedTarget.getId()); .map(Identifiable::getId).toList()).containsOnly(permittedTarget.getId());
} }
@@ -364,7 +364,7 @@ class TargetAccessControllerTest extends AbstractAccessControllerTest {
autoAssignChecker.checkAllTargets(); autoAssignChecker.checkAllTargets();
assertThat(targetManagement.findByAssignedDistributionSet(Pageable.unpaged(), distributionSet.getId()) assertThat(targetManagement.findByAssignedDistributionSet(distributionSet.getId(), Pageable.unpaged())
.getContent()) .getContent())
.hasSize(updateTargets.size()) .hasSize(updateTargets.size())
.allMatch(assignedTarget -> updateTargets.stream() .allMatch(assignedTarget -> updateTargets.stream()

View File

@@ -50,14 +50,14 @@ class TargetTypeAccessControllerTest extends AbstractAccessControllerTest {
.containsOnly(permittedTargetType.getId()); .containsOnly(permittedTargetType.getId());
// verify targetTypeManagement#findByRsql // verify targetTypeManagement#findByRsql
assertThat(targetTypeManagement.findByRsql(Pageable.unpaged(), "name==*").get().map(Identifiable::getId).toList()) assertThat(targetTypeManagement.findByRsql("name==*", Pageable.unpaged()).get().map(Identifiable::getId).toList())
.containsOnly(permittedTargetType.getId()); .containsOnly(permittedTargetType.getId());
// verify targetTypeManagement#findByName // verify targetTypeManagement#findByName
assertThat(targetTypeManagement.findByName(Pageable.unpaged(), permittedTargetType.getName()).getContent()) assertThat(targetTypeManagement.findByName(permittedTargetType.getName(), Pageable.unpaged()).getContent())
.hasSize(1).satisfies(results -> .hasSize(1).satisfies(results ->
assertThat(results.get(0).getId()).isEqualTo(permittedTargetType.getId())); assertThat(results.get(0).getId()).isEqualTo(permittedTargetType.getId()));
assertThat(targetTypeManagement.findByName(Pageable.unpaged(), hiddenTargetType.getName())).isEmpty(); assertThat(targetTypeManagement.findByName(hiddenTargetType.getName(), Pageable.unpaged())).isEmpty();
// verify targetTypeManagement#count // verify targetTypeManagement#count
assertThat(targetTypeManagement.count()).isEqualTo(1); assertThat(targetTypeManagement.count()).isEqualTo(1);

View File

@@ -434,7 +434,7 @@ class AutoAssignCheckerIntTest extends AbstractJpaIntegrationTest {
private void verifyThatTargetsHaveDistributionSetAssignedAndActionStatus(final DistributionSet set, private void verifyThatTargetsHaveDistributionSetAssignedAndActionStatus(final DistributionSet set,
final List<Target> targets, final Action.Status status) { final List<Target> targets, final Action.Status status) {
final List<String> targetIds = targets.stream().map(Target::getControllerId).toList(); final List<String> targetIds = targets.stream().map(Target::getControllerId).toList();
final List<Target> targetsWithAssignedDS = targetManagement.findByAssignedDistributionSet(PAGE, set.getId()).getContent(); final List<Target> targetsWithAssignedDS = targetManagement.findByAssignedDistributionSet(set.getId(), PAGE).getContent();
assertThat(targetsWithAssignedDS).isNotEmpty(); assertThat(targetsWithAssignedDS).isNotEmpty();
assertThat(targetsWithAssignedDS).allMatch(target -> targetIds.contains(target.getControllerId())); assertThat(targetsWithAssignedDS).allMatch(target -> targetIds.contains(target.getControllerId()));

View File

@@ -81,7 +81,7 @@ class ArtifactManagementSecurityTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Tests ArtifactManagement#findBySoftwareModule() method") @Description("Tests ArtifactManagement#findBySoftwareModule() method")
void findBySoftwareModulePermissionCheck() { void findBySoftwareModulePermissionCheck() {
assertPermissions(() -> artifactManagement.findBySoftwareModule(PAGE, 1L), List.of(SpPermission.READ_REPOSITORY)); assertPermissions(() -> artifactManagement.findBySoftwareModule(1L, PAGE), List.of(SpPermission.READ_REPOSITORY));
} }
@Test @Test

View File

@@ -94,7 +94,7 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest {
verifyThrownExceptionBy(() -> artifactManagement.delete(NOT_EXIST_IDL), "Artifact"); verifyThrownExceptionBy(() -> artifactManagement.delete(NOT_EXIST_IDL), "Artifact");
verifyThrownExceptionBy(() -> artifactManagement.findBySoftwareModule(PAGE, NOT_EXIST_IDL), "SoftwareModule"); verifyThrownExceptionBy(() -> artifactManagement.findBySoftwareModule(NOT_EXIST_IDL, PAGE), "SoftwareModule");
assertThat(artifactManagement.getByFilename(NOT_EXIST_ID)).isEmpty(); assertThat(artifactManagement.getByFilename(NOT_EXIST_ID)).isEmpty();
verifyThrownExceptionBy(() -> artifactManagement.getByFilenameAndSoftwareModule("xxx", NOT_EXIST_IDL), "SoftwareModule"); verifyThrownExceptionBy(() -> artifactManagement.getByFilenameAndSoftwareModule("xxx", NOT_EXIST_IDL), "SoftwareModule");
@@ -170,7 +170,7 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest {
for (int i = 0; i < maxArtifacts; ++i) { for (int i = 0; i < maxArtifacts; ++i) {
artifactIds.add(createArtifactForSoftwareModule("file" + i, smId, artifactSize).getId()); artifactIds.add(createArtifactForSoftwareModule("file" + i, smId, artifactSize).getId());
} }
assertThat(artifactManagement.findBySoftwareModule(PAGE, smId).getTotalElements()).isEqualTo(maxArtifacts); assertThat(artifactManagement.findBySoftwareModule(smId, PAGE).getTotalElements()).isEqualTo(maxArtifacts);
// create one mode to trigger the quota exceeded error // create one mode to trigger the quota exceeded error
assertThatExceptionOfType(AssignmentQuotaExceededException.class) assertThatExceptionOfType(AssignmentQuotaExceededException.class)
@@ -178,12 +178,12 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest {
// delete one of the artifacts // delete one of the artifacts
artifactManagement.delete(artifactIds.get(0)); artifactManagement.delete(artifactIds.get(0));
assertThat(artifactManagement.findBySoftwareModule(PAGE, smId).getTotalElements()) assertThat(artifactManagement.findBySoftwareModule(smId, PAGE).getTotalElements())
.isEqualTo(maxArtifacts - 1); .isEqualTo(maxArtifacts - 1);
// now we should be able to create an artifact again // now we should be able to create an artifact again
createArtifactForSoftwareModule("fileXYZ", smId, artifactSize); createArtifactForSoftwareModule("fileXYZ", smId, artifactSize);
assertThat(artifactManagement.findBySoftwareModule(PAGE, smId).getTotalElements()).isEqualTo(maxArtifacts); assertThat(artifactManagement.findBySoftwareModule(smId, PAGE).getTotalElements()).isEqualTo(maxArtifacts);
} }
@Test @Test
@@ -410,12 +410,12 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest {
@Description("Searches an artifact through the relations of a software module.") @Description("Searches an artifact through the relations of a software module.")
void findArtifactBySoftwareModule() throws IOException { void findArtifactBySoftwareModule() throws IOException {
final SoftwareModule sm = testdataFactory.createSoftwareModuleOs(); final SoftwareModule sm = testdataFactory.createSoftwareModuleOs();
assertThat(artifactManagement.findBySoftwareModule(PAGE, sm.getId())).isEmpty(); assertThat(artifactManagement.findBySoftwareModule(sm.getId(), PAGE)).isEmpty();
final int artifactSize = 5 * 1024; final int artifactSize = 5 * 1024;
try (final InputStream input = new RandomGeneratedInputStream(artifactSize)) { try (final InputStream input = new RandomGeneratedInputStream(artifactSize)) {
createArtifactForSoftwareModule("file1", sm.getId(), artifactSize, input); createArtifactForSoftwareModule("file1", sm.getId(), artifactSize, input);
assertThat(artifactManagement.findBySoftwareModule(PAGE, sm.getId())).hasSize(1); assertThat(artifactManagement.findBySoftwareModule(sm.getId(), PAGE)).hasSize(1);
} }
} }

View File

@@ -107,7 +107,7 @@ class ConfirmationManagementTest extends AbstractJpaIntegrationTest {
assertThat(confirmationManagement.findActiveActionsWaitingConfirmation(controllerId)).hasSize(1) assertThat(confirmationManagement.findActiveActionsWaitingConfirmation(controllerId)).hasSize(1)
.allMatch(action -> action.getStatus() == Status.WAIT_FOR_CONFIRMATION); .allMatch(action -> action.getStatus() == Status.WAIT_FOR_CONFIRMATION);
assertThat(controllerManagement.findActionStatusByAction(PAGE, actions.get(0).getId())).hasSize(1) assertThat(controllerManagement.findActionStatusByAction(actions.get(0).getId(), PAGE)).hasSize(1)
.allMatch(status -> status.getStatus() == Status.WAIT_FOR_CONFIRMATION); .allMatch(status -> status.getStatus() == Status.WAIT_FOR_CONFIRMATION);
final Action newAction = confirmationManagement.confirmAction(actions.get(0).getId(), null, null); final Action newAction = confirmationManagement.confirmAction(actions.get(0).getId(), null, null);
@@ -118,7 +118,7 @@ class ConfirmationManagementTest extends AbstractJpaIntegrationTest {
assertThat(newAction.getStatus()).isEqualTo(Status.RUNNING); assertThat(newAction.getStatus()).isEqualTo(Status.RUNNING);
// status entry RUNNING should be present in status history // status entry RUNNING should be present in status history
assertThat(controllerManagement.findActionStatusByAction(PAGE, newAction.getId())).hasSize(2) assertThat(controllerManagement.findActionStatusByAction(newAction.getId(), PAGE)).hasSize(2)
.anyMatch(status -> status.getStatus() == Status.RUNNING); .anyMatch(status -> status.getStatus() == Status.RUNNING);
} }
@@ -166,7 +166,7 @@ class ConfirmationManagementTest extends AbstractJpaIntegrationTest {
assertThat(actions).hasSize(1).allMatch(action -> action.getStatus() == Status.WAIT_FOR_CONFIRMATION); assertThat(actions).hasSize(1).allMatch(action -> action.getStatus() == Status.WAIT_FOR_CONFIRMATION);
assertThat(confirmationManagement.findActiveActionsWaitingConfirmation(controllerId)).hasSize(1) assertThat(confirmationManagement.findActiveActionsWaitingConfirmation(controllerId)).hasSize(1)
.allMatch(action -> action.getStatus() == Status.WAIT_FOR_CONFIRMATION); .allMatch(action -> action.getStatus() == Status.WAIT_FOR_CONFIRMATION);
assertThat(controllerManagement.findActionStatusByAction(PAGE, actions.get(0).getId())).hasSize(1) assertThat(controllerManagement.findActionStatusByAction(actions.get(0).getId(), PAGE)).hasSize(1)
.allMatch(status -> status.getStatus() == Status.WAIT_FOR_CONFIRMATION); .allMatch(status -> status.getStatus() == Status.WAIT_FOR_CONFIRMATION);
final Action newAction = confirmationManagement.denyAction(actions.get(0).getId(), null, null); final Action newAction = confirmationManagement.denyAction(actions.get(0).getId(), null, null);
@@ -178,7 +178,7 @@ class ConfirmationManagementTest extends AbstractJpaIntegrationTest {
assertThat(newAction.getStatus()).isEqualTo(Status.WAIT_FOR_CONFIRMATION); assertThat(newAction.getStatus()).isEqualTo(Status.WAIT_FOR_CONFIRMATION);
// no status entry RUNNING should be present in status history // no status entry RUNNING should be present in status history
assertThat(controllerManagement.findActionStatusByAction(PAGE, newAction.getId())).hasSize(2) assertThat(controllerManagement.findActionStatusByAction(newAction.getId(), PAGE)).hasSize(2)
.noneMatch(status -> status.getStatus() == Status.RUNNING); .noneMatch(status -> status.getStatus() == Status.RUNNING);
} }

View File

@@ -18,10 +18,8 @@ import io.qameta.allure.Feature;
import io.qameta.allure.Story; import io.qameta.allure.Story;
import org.eclipse.hawkbit.im.authentication.SpPermission; import org.eclipse.hawkbit.im.authentication.SpPermission;
import org.eclipse.hawkbit.repository.exception.CancelActionNotAllowedException; import org.eclipse.hawkbit.repository.exception.CancelActionNotAllowedException;
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
import org.eclipse.hawkbit.repository.jpa.AbstractJpaIntegrationTest; import org.eclipse.hawkbit.repository.jpa.AbstractJpaIntegrationTest;
import org.eclipse.hawkbit.repository.jpa.model.JpaAction; import org.eclipse.hawkbit.repository.jpa.model.JpaAction;
import org.eclipse.hawkbit.repository.jpa.model.JpaTarget;
import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.Target;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
@@ -87,7 +85,7 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Tests ControllerManagement#findActionStatusByAction() method") @Description("Tests ControllerManagement#findActionStatusByAction() method")
void findActionStatusByActionPermissionsCheck() { void findActionStatusByActionPermissionsCheck() {
assertPermissions(() -> controllerManagement.findActionStatusByAction(Pageable.unpaged(), 1L), assertPermissions(() -> controllerManagement.findActionStatusByAction(1L, Pageable.unpaged()),
List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE)); List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE));
} }

View File

@@ -209,7 +209,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
final List<String> messages = controllerManagement.getActionHistoryMessages(actionId, 2); final List<String> messages = controllerManagement.getActionHistoryMessages(actionId, 2);
assertThat(deploymentManagement.findActionStatusByAction(PAGE, actionId).getTotalElements()) assertThat(deploymentManagement.findActionStatusByAction(actionId, PAGE).getTotalElements())
.as("Two action-states in total").isEqualTo(3L); .as("Two action-states in total").isEqualTo(3L);
assertThat(messages.get(0)).as("Message of action-status").isEqualTo("proceeding message 2"); assertThat(messages.get(0)).as("Message of action-status").isEqualTo("proceeding message 2");
assertThat(messages.get(1)).as("Message of action-status").isEqualTo("proceeding message 1"); assertThat(messages.get(1)).as("Message of action-status").isEqualTo("proceeding message 1");
@@ -304,7 +304,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
Action.Status.DOWNLOAD, true); Action.Status.DOWNLOAD, true);
assertThat(actionStatusRepository.count()).isEqualTo(2); assertThat(actionStatusRepository.count()).isEqualTo(2);
assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(2); assertThat(controllerManagement.findActionStatusByAction(actionId, PAGE).getNumberOfElements()).isEqualTo(2);
assertThat(activeActionExistsForControllerId(DEFAULT_CONTROLLER_ID)).isTrue(); assertThat(activeActionExistsForControllerId(DEFAULT_CONTROLLER_ID)).isTrue();
} }
@@ -357,7 +357,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
() -> controllerManagement.getActionForDownloadByTargetAndSoftwareModule(NOT_EXIST_ID, module.getId()), () -> controllerManagement.getActionForDownloadByTargetAndSoftwareModule(NOT_EXIST_ID, module.getId()),
"Target"); "Target");
verifyThrownExceptionBy(() -> controllerManagement.findActionStatusByAction(PAGE, NOT_EXIST_IDL), "Action"); verifyThrownExceptionBy(() -> controllerManagement.findActionStatusByAction(NOT_EXIST_IDL, PAGE), "Action");
verifyThrownExceptionBy(() -> controllerManagement.hasTargetArtifactAssigned(NOT_EXIST_IDL, "XXX"), "Target"); verifyThrownExceptionBy(() -> controllerManagement.hasTargetArtifactAssigned(NOT_EXIST_IDL, "XXX"), "Target");
verifyThrownExceptionBy(() -> controllerManagement.hasTargetArtifactAssigned(NOT_EXIST_ID, "XXX"), "Target"); verifyThrownExceptionBy(() -> controllerManagement.hasTargetArtifactAssigned(NOT_EXIST_ID, "XXX"), "Target");
@@ -392,7 +392,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
Action.Status.FINISHED, false); Action.Status.FINISHED, false);
assertThat(actionStatusRepository.count()).isEqualTo(7); assertThat(actionStatusRepository.count()).isEqualTo(7);
assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(7); assertThat(controllerManagement.findActionStatusByAction(actionId, PAGE).getNumberOfElements()).isEqualTo(7);
} }
@Test @Test
@@ -424,7 +424,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
.isThrownBy(() -> controllerManagement.addUpdateActionStatus(statusMulipleMessages)); .isThrownBy(() -> controllerManagement.addUpdateActionStatus(statusMulipleMessages));
assertThat(actionStatusRepository.count()).isEqualTo(6); assertThat(actionStatusRepository.count()).isEqualTo(6);
assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(6); assertThat(controllerManagement.findActionStatusByAction(actionId, PAGE).getNumberOfElements()).isEqualTo(6);
} }
@Test @Test
@@ -452,7 +452,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
Action.Status.FINISHED, false); Action.Status.FINISHED, false);
assertThat(actionStatusRepository.count()).isEqualTo(3); assertThat(actionStatusRepository.count()).isEqualTo(3);
assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(3); assertThat(controllerManagement.findActionStatusByAction(actionId, PAGE).getNumberOfElements()).isEqualTo(3);
} }
@Test @Test
@@ -477,7 +477,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
assertActionStatus(actionId, DEFAULT_CONTROLLER_ID, TargetUpdateStatus.PENDING, Action.Status.RUNNING, Action.Status.RUNNING, true); assertActionStatus(actionId, DEFAULT_CONTROLLER_ID, TargetUpdateStatus.PENDING, Action.Status.RUNNING, Action.Status.RUNNING, true);
assertThat(actionStatusRepository.count()).isEqualTo(1); assertThat(actionStatusRepository.count()).isEqualTo(1);
assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(1); assertThat(controllerManagement.findActionStatusByAction(actionId, PAGE).getNumberOfElements()).isEqualTo(1);
} }
@Test @Test
@@ -508,7 +508,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
Action.Status.FINISHED, false); Action.Status.FINISHED, false);
assertThat(actionStatusRepository.count()).isEqualTo(8); assertThat(actionStatusRepository.count()).isEqualTo(8);
assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(8); assertThat(controllerManagement.findActionStatusByAction(actionId, PAGE).getNumberOfElements()).isEqualTo(8);
} }
@Test @Test
@@ -539,7 +539,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
Action.Status.CANCELED, false); Action.Status.CANCELED, false);
assertThat(actionStatusRepository.count()).isEqualTo(8); assertThat(actionStatusRepository.count()).isEqualTo(8);
assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(8); assertThat(controllerManagement.findActionStatusByAction(actionId, PAGE).getNumberOfElements()).isEqualTo(8);
} }
@Test @Test
@@ -571,7 +571,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
Action.Status.CANCEL_REJECTED, true); Action.Status.CANCEL_REJECTED, true);
assertThat(actionStatusRepository.count()).isEqualTo(8); assertThat(actionStatusRepository.count()).isEqualTo(8);
assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(8); assertThat(controllerManagement.findActionStatusByAction(actionId, PAGE).getNumberOfElements()).isEqualTo(8);
} }
@Test @Test
@@ -603,7 +603,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
Action.Status.ERROR, true); Action.Status.ERROR, true);
assertThat(actionStatusRepository.count()).isEqualTo(8); assertThat(actionStatusRepository.count()).isEqualTo(8);
assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(8); assertThat(controllerManagement.findActionStatusByAction(actionId, PAGE).getNumberOfElements()).isEqualTo(8);
} }
@Test @Test
@@ -985,7 +985,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
assertActionStatus(actionId, DEFAULT_CONTROLLER_ID, TargetUpdateStatus.ERROR, Action.Status.ERROR, Action.Status.ERROR, false); assertActionStatus(actionId, DEFAULT_CONTROLLER_ID, TargetUpdateStatus.ERROR, Action.Status.ERROR, Action.Status.ERROR, false);
assertThat(actionStatusRepository.count()).isEqualTo(3); assertThat(actionStatusRepository.count()).isEqualTo(3);
assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(3); assertThat(controllerManagement.findActionStatusByAction(actionId, PAGE).getNumberOfElements()).isEqualTo(3);
} }
@Test @Test
@@ -1018,7 +1018,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
assertActionStatus( assertActionStatus(
actionId, DEFAULT_CONTROLLER_ID, TargetUpdateStatus.IN_SYNC, Action.Status.FINISHED, Action.Status.FINISHED, false); actionId, DEFAULT_CONTROLLER_ID, TargetUpdateStatus.IN_SYNC, Action.Status.FINISHED, Action.Status.FINISHED, false);
assertThat(actionStatusRepository.count()).isEqualTo(3); assertThat(actionStatusRepository.count()).isEqualTo(3);
assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(3); assertThat(controllerManagement.findActionStatusByAction(actionId, PAGE).getNumberOfElements()).isEqualTo(3);
} }
@Test @Test
@@ -1047,7 +1047,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
assertThat(actionRepository.findById(action.getId())) assertThat(actionRepository.findById(action.getId()))
.hasValueSatisfying(a -> assertThat(a.getStatus()).isEqualTo(Status.FINISHED)); .hasValueSatisfying(a -> assertThat(a.getStatus()).isEqualTo(Status.FINISHED));
assertThat(actionStatusRepository.count()).isEqualTo(3); assertThat(actionStatusRepository.count()).isEqualTo(3);
assertThat(controllerManagement.findActionStatusByAction(PAGE, action.getId()).getNumberOfElements()) assertThat(controllerManagement.findActionStatusByAction(action.getId(), PAGE).getNumberOfElements())
.isEqualTo(3); .isEqualTo(3);
} }
@@ -1075,7 +1075,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
assertThat(targetManagement.getByControllerID(DEFAULT_CONTROLLER_ID).get().getUpdateStatus()).isEqualTo(TargetUpdateStatus.IN_SYNC); assertThat(targetManagement.getByControllerID(DEFAULT_CONTROLLER_ID).get().getUpdateStatus()).isEqualTo(TargetUpdateStatus.IN_SYNC);
// however, additional action status has been stored // however, additional action status has been stored
assertThat(actionStatusRepository.findAll(PAGE).getNumberOfElements()).isEqualTo(4); assertThat(actionStatusRepository.findAll(PAGE).getNumberOfElements()).isEqualTo(4);
assertThat(controllerManagement.findActionStatusByAction(PAGE, action.getId()).getNumberOfElements()).isEqualTo(4); assertThat(controllerManagement.findActionStatusByAction(action.getId(), PAGE).getNumberOfElements()).isEqualTo(4);
} }
@Test @Test
@@ -1148,7 +1148,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
actionId, DEFAULT_CONTROLLER_ID, TargetUpdateStatus.IN_SYNC, Action.Status.DOWNLOADED, Action.Status.DOWNLOADED, false); actionId, DEFAULT_CONTROLLER_ID, TargetUpdateStatus.IN_SYNC, Action.Status.DOWNLOADED, Action.Status.DOWNLOADED, false);
assertThat(actionStatusRepository.count()).isEqualTo(2); assertThat(actionStatusRepository.count()).isEqualTo(2);
assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(2); assertThat(controllerManagement.findActionStatusByAction(actionId, PAGE).getNumberOfElements()).isEqualTo(2);
assertThat(activeActionExistsForControllerId(DEFAULT_CONTROLLER_ID)).isFalse(); assertThat(activeActionExistsForControllerId(DEFAULT_CONTROLLER_ID)).isFalse();
} }
@@ -1175,7 +1175,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
Action.Status.FINISHED, false); Action.Status.FINISHED, false);
assertThat(actionStatusRepository.count()).isEqualTo(3); assertThat(actionStatusRepository.count()).isEqualTo(3);
assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(3); assertThat(controllerManagement.findActionStatusByAction(actionId, PAGE).getNumberOfElements()).isEqualTo(3);
assertThat(activeActionExistsForControllerId(DEFAULT_CONTROLLER_ID)).isFalse(); assertThat(activeActionExistsForControllerId(DEFAULT_CONTROLLER_ID)).isFalse();
} }
@@ -1203,7 +1203,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
Status.DOWNLOADED, false); Status.DOWNLOADED, false);
assertThat(actionStatusRepository.count()).isEqualTo(4); assertThat(actionStatusRepository.count()).isEqualTo(4);
assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(4); assertThat(controllerManagement.findActionStatusByAction(actionId, PAGE).getNumberOfElements()).isEqualTo(4);
assertThat(activeActionExistsForControllerId(DEFAULT_CONTROLLER_ID)).isFalse(); assertThat(activeActionExistsForControllerId(DEFAULT_CONTROLLER_ID)).isFalse();
} }
@@ -1627,7 +1627,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
assertThat(targetManagement.getByControllerID(DEFAULT_CONTROLLER_ID).get().getUpdateStatus()) assertThat(targetManagement.getByControllerID(DEFAULT_CONTROLLER_ID).get().getUpdateStatus())
.isEqualTo(TargetUpdateStatus.PENDING); .isEqualTo(TargetUpdateStatus.PENDING);
return deploymentManagement.findActiveActionsByTarget(PAGE, DEFAULT_CONTROLLER_ID).getContent().get(0).getId(); return deploymentManagement.findActiveActionsByTarget(DEFAULT_CONTROLLER_ID, PAGE).getContent().get(0).getId();
} }
@Step @Step
@@ -1637,7 +1637,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
assignDistributionSet(dsId, defaultControllerId, DOWNLOAD_ONLY); assignDistributionSet(dsId, defaultControllerId, DOWNLOAD_ONLY);
assertThat(targetManagement.getByControllerID(defaultControllerId).get().getUpdateStatus()).isEqualTo(TargetUpdateStatus.PENDING); assertThat(targetManagement.getByControllerID(defaultControllerId).get().getUpdateStatus()).isEqualTo(TargetUpdateStatus.PENDING);
final Long id = deploymentManagement.findActiveActionsByTarget(PAGE, defaultControllerId).getContent().get(0).getId(); final Long id = deploymentManagement.findActiveActionsByTarget(defaultControllerId, PAGE).getContent().get(0).getId();
assertThat(id).isNotNull(); assertThat(id).isNotNull();
return id; return id;
} }
@@ -1648,7 +1648,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
assertThat(targetManagement.getByControllerID(defaultControllerId).get().getUpdateStatus()) assertThat(targetManagement.getByControllerID(defaultControllerId).get().getUpdateStatus())
.isEqualTo(TargetUpdateStatus.PENDING); .isEqualTo(TargetUpdateStatus.PENDING);
final Long id = deploymentManagement.findActiveActionsByTarget(PAGE, defaultControllerId).getContent().get(0) final Long id = deploymentManagement.findActiveActionsByTarget(defaultControllerId, PAGE).getContent().get(0)
.getId(); .getId();
assertThat(id).isNotNull(); assertThat(id).isNotNull();
return id; return id;
@@ -1720,7 +1720,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
final Action action = deploymentManagement.findAction(actionId).get(); final Action action = deploymentManagement.findAction(actionId).get();
assertThat(action.getStatus()).isEqualTo(expectedActionActionStatus); assertThat(action.getStatus()).isEqualTo(expectedActionActionStatus);
assertThat(action.isActive()).isEqualTo(actionActive); assertThat(action.isActive()).isEqualTo(actionActive);
final List<ActionStatus> actionStatusList = controllerManagement.findActionStatusByAction(PAGE, actionId).getContent(); final List<ActionStatus> actionStatusList = controllerManagement.findActionStatusByAction(actionId, PAGE).getContent();
assertThat(actionStatusList.get(actionStatusList.size() - 1).getStatus()).isEqualTo(expectedActionStatus); assertThat(actionStatusList.get(actionStatusList.size() - 1).getStatus()).isEqualTo(expectedActionStatus);
if (actionActive) { if (actionActive) {
assertThat(controllerManagement.findActiveActionWithHighestWeight(controllerId).get().getId()).isEqualTo(actionId); assertThat(controllerManagement.findActiveActionWithHighestWeight(controllerId).get().getId()).isEqualTo(actionId);

View File

@@ -122,7 +122,7 @@ class DeploymentManagementSecurityTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
void findActionStatusByActionPermissionsCheck() { void findActionStatusByActionPermissionsCheck() {
assertPermissions(() -> deploymentManagement.findActionStatusByAction(Pageable.unpaged(), 1L), List.of(SpPermission.READ_TARGET)); assertPermissions(() -> deploymentManagement.findActionStatusByAction(1L, Pageable.unpaged()), List.of(SpPermission.READ_TARGET));
} }
@Test @Test
@@ -134,7 +134,7 @@ class DeploymentManagementSecurityTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
void findMessagesByActionStatusIdPermissionsCheck() { void findMessagesByActionStatusIdPermissionsCheck() {
assertPermissions(() -> deploymentManagement.findMessagesByActionStatusId(PAGE, 1L), List.of(SpPermission.READ_TARGET)); assertPermissions(() -> deploymentManagement.findMessagesByActionStatusId(1L, PAGE), List.of(SpPermission.READ_TARGET));
} }
@Test @Test
@@ -146,14 +146,14 @@ class DeploymentManagementSecurityTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
void findActiveActionsByTargetPermissionsCheck() { void findActiveActionsByTargetPermissionsCheck() {
assertPermissions(() -> deploymentManagement.findActiveActionsByTarget(Pageable.unpaged(), "controllerId"), assertPermissions(() -> deploymentManagement.findActiveActionsByTarget("controllerId", Pageable.unpaged()),
List.of(SpPermission.READ_TARGET)); List.of(SpPermission.READ_TARGET));
} }
@Test @Test
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
void findInActiveActionsByTargetPermissionsCheck() { void findInActiveActionsByTargetPermissionsCheck() {
assertPermissions(() -> deploymentManagement.findInActiveActionsByTarget(Pageable.unpaged(), "controllerId"), assertPermissions(() -> deploymentManagement.findInActiveActionsByTarget("controllerId", Pageable.unpaged()),
List.of(SpPermission.READ_TARGET)); List.of(SpPermission.READ_TARGET));
} }

View File

@@ -77,7 +77,6 @@ import org.eclipse.hawkbit.repository.model.DeploymentRequest;
import org.eclipse.hawkbit.repository.model.DeploymentRequestBuilder; import org.eclipse.hawkbit.repository.model.DeploymentRequestBuilder;
import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetAssignmentResult; import org.eclipse.hawkbit.repository.model.DistributionSetAssignmentResult;
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
import org.eclipse.hawkbit.repository.model.DistributionSetType; import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.Target;
@@ -155,8 +154,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
verifyThrownExceptionBy(() -> deploymentManagement.findActionsByTarget(NOT_EXIST_ID, PAGE), "Target"); verifyThrownExceptionBy(() -> deploymentManagement.findActionsByTarget(NOT_EXIST_ID, PAGE), "Target");
verifyThrownExceptionBy(() -> deploymentManagement.findActionsByTarget("id==*", NOT_EXIST_ID, PAGE), "Target"); verifyThrownExceptionBy(() -> deploymentManagement.findActionsByTarget("id==*", NOT_EXIST_ID, PAGE), "Target");
verifyThrownExceptionBy(() -> deploymentManagement.findActiveActionsByTarget(PAGE, NOT_EXIST_ID), "Target"); verifyThrownExceptionBy(() -> deploymentManagement.findActiveActionsByTarget(NOT_EXIST_ID, PAGE), "Target");
verifyThrownExceptionBy(() -> deploymentManagement.findInActiveActionsByTarget(PAGE, NOT_EXIST_ID), "Target"); verifyThrownExceptionBy(() -> deploymentManagement.findInActiveActionsByTarget(NOT_EXIST_ID, PAGE), "Target");
verifyThrownExceptionBy(() -> deploymentManagement.forceQuitAction(NOT_EXIST_IDL), "Action"); verifyThrownExceptionBy(() -> deploymentManagement.forceQuitAction(NOT_EXIST_IDL), "Action");
verifyThrownExceptionBy(() -> deploymentManagement.forceTargetAction(NOT_EXIST_IDL), "Action"); verifyThrownExceptionBy(() -> deploymentManagement.forceTargetAction(NOT_EXIST_IDL), "Action");
} }
@@ -237,7 +236,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
final ActionStatus expectedActionStatus = ((JpaAction) actions.getContent().get(0)).getActionStatus().get(0); final ActionStatus expectedActionStatus = ((JpaAction) actions.getContent().get(0)).getActionStatus().get(0);
// act // act
final Page<ActionStatus> actionStates = deploymentManagement.findActionStatusByAction(PAGE, actionId); final Page<ActionStatus> actionStates = deploymentManagement.findActionStatusByAction(actionId, PAGE);
assertThat(actionStates.getContent()).hasSize(1); assertThat(actionStates.getContent()).hasSize(1);
assertThat(actionStates.getContent().get(0)).as("Action-status of action").isEqualTo(expectedActionStatus); assertThat(actionStates.getContent().get(0)).as("Action-status of action").isEqualTo(expectedActionStatus);
@@ -253,7 +252,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
// create action-status entry with one message // create action-status entry with one message
controllerManagement.addUpdateActionStatus(entityFactory.actionStatus().create(actionId) controllerManagement.addUpdateActionStatus(entityFactory.actionStatus().create(actionId)
.status(Action.Status.FINISHED).messages(Collections.singletonList("finished message"))); .status(Action.Status.FINISHED).messages(Collections.singletonList("finished message")));
final Page<ActionStatus> actionStates = deploymentManagement.findActionStatusByAction(PAGE, actionId); final Page<ActionStatus> actionStates = deploymentManagement.findActionStatusByAction(actionId, PAGE);
// find newly created action-status entry with message // find newly created action-status entry with message
final JpaActionStatus actionStatusWithMessage = actionStates.getContent().stream() final JpaActionStatus actionStatusWithMessage = actionStates.getContent().stream()
@@ -263,7 +262,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
final String expectedMsg = actionStatusWithMessage.getMessages().get(0); final String expectedMsg = actionStatusWithMessage.getMessages().get(0);
// act // act
final Page<String> messages = deploymentManagement.findMessagesByActionStatusId(PAGE, actionStatusWithMessage.getId()); final Page<String> messages = deploymentManagement.findMessagesByActionStatusId(actionStatusWithMessage.getId(), PAGE);
assertThat(actionStates.getTotalElements()).as("Two action-states in total").isEqualTo(2L); assertThat(actionStates.getTotalElements()).as("Two action-states in total").isEqualTo(2L);
assertThat(messages.getContent().get(0)).as("Message of action-status").isEqualTo(expectedMsg); assertThat(messages.getContent().get(0)).as("Message of action-status").isEqualTo(expectedMsg);
@@ -503,9 +502,9 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
.allMatch(action -> !action.isActive()).as("Actions should be initiated by current user") .allMatch(action -> !action.isActive()).as("Actions should be initiated by current user")
.allMatch(a -> a.getInitiatedBy().equals(tenantAware.getCurrentUsername())); .allMatch(a -> a.getInitiatedBy().equals(tenantAware.getCurrentUsername()));
assertThat(targetManagement.findByInstalledDistributionSet(PAGE, ds.getId()).getContent()) assertThat(targetManagement.findByInstalledDistributionSet(ds.getId(), PAGE).getContent())
.usingElementComparator(controllerIdComparator()).containsAll(targets).hasSize(10) .usingElementComparator(controllerIdComparator()).containsAll(targets).hasSize(10)
.containsAll(targetManagement.findByAssignedDistributionSet(PAGE, ds.getId())) .containsAll(targetManagement.findByAssignedDistributionSet(ds.getId(), PAGE))
.as("InstallationDate set").allMatch(target -> target.getInstallationDate() >= current) .as("InstallationDate set").allMatch(target -> target.getInstallationDate() >= current)
.as("TargetUpdateStatus IN_SYNC") .as("TargetUpdateStatus IN_SYNC")
.allMatch(target -> TargetUpdateStatus.IN_SYNC.equals(target.getUpdateStatus())) .allMatch(target -> TargetUpdateStatus.IN_SYNC.equals(target.getUpdateStatus()))
@@ -583,7 +582,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
assertDsExclusivelyAssignedToTargets(targets, ds2.getId(), STATE_ACTIVE, RUNNING); assertDsExclusivelyAssignedToTargets(targets, ds2.getId(), STATE_ACTIVE, RUNNING);
assertDsExclusivelyAssignedToTargets(targets, ds1.getId(), STATE_INACTIVE, Status.CANCELED); assertDsExclusivelyAssignedToTargets(targets, ds1.getId(), STATE_INACTIVE, Status.CANCELED);
assertThat(targetManagement.findByAssignedDistributionSet(PAGE, ds2.getId()).getContent()).hasSize(10) assertThat(targetManagement.findByAssignedDistributionSet(ds2.getId(), PAGE).getContent()).hasSize(10)
.as("InstallationDate not set").allMatch(target -> (target.getInstallationDate() == null)); .as("InstallationDate not set").allMatch(target -> (target.getInstallationDate() == null));
} finally { } finally {
@@ -1050,7 +1049,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
for (final Target myt : savedDeployedTargets) { for (final Target myt : savedDeployedTargets) {
final Target t = targetManagement.getByControllerID(myt.getControllerId()).get(); final Target t = targetManagement.getByControllerID(myt.getControllerId()).get();
final List<Action> activeActionsByTarget = deploymentManagement.findActiveActionsByTarget(PAGE, t.getControllerId()).getContent(); final List<Action> activeActionsByTarget = deploymentManagement.findActiveActionsByTarget(t.getControllerId(), PAGE).getContent();
assertThat(activeActionsByTarget).as("action should not be empty").isNotEmpty(); assertThat(activeActionsByTarget).as("action should not be empty").isNotEmpty();
assertThat(t.getUpdateStatus()).as("wrong target update status").isEqualTo(TargetUpdateStatus.PENDING); assertThat(t.getUpdateStatus()).as("wrong target update status").isEqualTo(TargetUpdateStatus.PENDING);
for (final Action ua : activeActionsByTarget) { for (final Action ua : activeActionsByTarget) {
@@ -1211,7 +1210,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
.as("installed ds is wrong").contains(dsA); .as("installed ds is wrong").contains(dsA);
assertThat(targetManagement.getByControllerID(t.getControllerId()).get().getUpdateStatus()) assertThat(targetManagement.getByControllerID(t.getControllerId()).get().getUpdateStatus())
.as("wrong target info update status").isEqualTo(TargetUpdateStatus.IN_SYNC); .as("wrong target info update status").isEqualTo(TargetUpdateStatus.IN_SYNC);
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, t.getControllerId())) assertThat(deploymentManagement.findActiveActionsByTarget(t.getControllerId(), PAGE))
.as("no actions should be active").isEmpty(); .as("no actions should be active").isEmpty();
} }
@@ -1281,7 +1280,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
} }
// verify that deleted attribute is used correctly // verify that deleted attribute is used correctly
List<DistributionSet> allFoundDS = distributionSetManagement.findByCompleted(PAGE, true).getContent(); List<DistributionSet> allFoundDS = distributionSetManagement.findByCompleted(true, PAGE).getContent();
assertThat(allFoundDS).as("no ds should be founded").isEmpty(); assertThat(allFoundDS).as("no ds should be founded").isEmpty();
assertThat(distributionSetRepository.findAll(SpecificationsBuilder.combineWithAnd(Arrays assertThat(distributionSetRepository.findAll(SpecificationsBuilder.combineWithAnd(Arrays
@@ -1297,7 +1296,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
// has been installed // has been installed
// successfully and no activeAction is referring to created distribution // successfully and no activeAction is referring to created distribution
// sets // sets
allFoundDS = distributionSetManagement.findByCompleted(pageRequest, true).getContent(); allFoundDS = distributionSetManagement.findByCompleted(true, pageRequest).getContent();
assertThat(allFoundDS).as("no ds should be founded").isEmpty(); assertThat(allFoundDS).as("no ds should be founded").isEmpty();
assertThat(distributionSetRepository.findAll(SpecificationsBuilder.combineWithAnd(Arrays assertThat(distributionSetRepository.findAll(SpecificationsBuilder.combineWithAnd(Arrays
.asList(DistributionSetSpecification.isDeleted(true), DistributionSetSpecification.isCompleted(true))), .asList(DistributionSetSpecification.isDeleted(true), DistributionSetSpecification.isCompleted(true))),
@@ -1353,16 +1352,16 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
.isEqualTo(distributionSetManagement.getWithDetails(dsA.getId()).get().getOptLockRevision()); .isEqualTo(distributionSetManagement.getWithDetails(dsA.getId()).get().getOptLockRevision());
// verifying that the assignment is correct // verifying that the assignment is correct
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, targ.getControllerId()).getTotalElements()) assertThat(deploymentManagement.findActiveActionsByTarget(targ.getControllerId(), PAGE).getTotalElements())
.as("Active target actions are wrong").isEqualTo(1); .as("Active target actions are wrong").isEqualTo(1);
assertThat(deploymentManagement.countActionsByTarget(targ.getControllerId())).as("Target actions are wrong") assertThat(deploymentManagement.countActionsByTarget(targ.getControllerId())).as("Target actions are wrong")
.isEqualTo(1); .isEqualTo(1);
assertThat(targ.getUpdateStatus()).as("UpdateStatus of target is wrong").isEqualTo(TargetUpdateStatus.PENDING); assertThat(targ.getUpdateStatus()).as("UpdateStatus of target is wrong").isEqualTo(TargetUpdateStatus.PENDING);
assertThat(deploymentManagement.getAssignedDistributionSet(targ.getControllerId())) assertThat(deploymentManagement.getAssignedDistributionSet(targ.getControllerId()))
.as("Assigned distribution set of target is wrong").contains(dsA); .as("Assigned distribution set of target is wrong").contains(dsA);
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, targ.getControllerId()).getContent().get(0) assertThat(deploymentManagement.findActiveActionsByTarget(targ.getControllerId(), PAGE).getContent().get(0)
.getDistributionSet()).as("Distribution set of action is wrong").isEqualTo(dsA); .getDistributionSet()).as("Distribution set of action is wrong").isEqualTo(dsA);
assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, targ.getControllerId()).getContent().get(0) assertThat(deploymentManagement.findActiveActionsByTarget(targ.getControllerId(), PAGE).getContent().get(0)
.getDistributionSet()).as("Installed distribution set of action should be null").isNotNull(); .getDistributionSet()).as("Installed distribution set of action should be null").isNotNull();
final Slice<Action> updAct = findActionsByDistributionSet(PAGE, dsA.getId()); final Slice<Action> updAct = findActionsByDistributionSet(PAGE, dsA.getId());
@@ -1371,10 +1370,10 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
targ = targetManagement.getByControllerID(targ.getControllerId()).get(); targ = targetManagement.getByControllerID(targ.getControllerId()).get();
assertEquals(0, deploymentManagement.findActiveActionsByTarget(PAGE, targ.getControllerId()).getTotalElements(), assertEquals(0, deploymentManagement.findActiveActionsByTarget(targ.getControllerId(), PAGE).getTotalElements(),
"active target actions are wrong"); "active target actions are wrong");
assertEquals(1, assertEquals(1,
deploymentManagement.findInActiveActionsByTarget(PAGE, targ.getControllerId()).getTotalElements(), deploymentManagement.findInActiveActionsByTarget(targ.getControllerId(), PAGE).getTotalElements(),
"active actions are wrong"); "active actions are wrong");
assertEquals(TargetUpdateStatus.IN_SYNC, targ.getUpdateStatus(), "tagret update status is not correct"); assertEquals(TargetUpdateStatus.IN_SYNC, targ.getUpdateStatus(), "tagret update status is not correct");
@@ -1389,7 +1388,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
targ = targs.iterator().next(); targ = targs.iterator().next();
assertEquals(1, deploymentManagement.findActiveActionsByTarget(PAGE, targ.getControllerId()).getTotalElements(), assertEquals(1, deploymentManagement.findActiveActionsByTarget(targ.getControllerId(), PAGE).getTotalElements(),
"active actions are wrong"); "active actions are wrong");
assertEquals(TargetUpdateStatus.PENDING, assertEquals(TargetUpdateStatus.PENDING,
targetManagement.getByControllerID(targ.getControllerId()).get().getUpdateStatus(), targetManagement.getByControllerID(targ.getControllerId()).get().getUpdateStatus(),
@@ -1399,7 +1398,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
assertEquals(dsA.getId(), assertEquals(dsA.getId(),
deploymentManagement.getInstalledDistributionSet(targ.getControllerId()).get().getId(), deploymentManagement.getInstalledDistributionSet(targ.getControllerId()).get().getId(),
"Installed ds is wrong"); "Installed ds is wrong");
assertEquals(dsB, deploymentManagement.findActiveActionsByTarget(PAGE, targ.getControllerId()).getContent() assertEquals(dsB, deploymentManagement.findActiveActionsByTarget(targ.getControllerId(), PAGE).getContent()
.get(0).getDistributionSet(), "Active ds is wrong"); .get(0).getDistributionSet(), "Active ds is wrong");
} }

View File

@@ -158,7 +158,7 @@ class DistributionSetManagementSecurityTest
@Test @Test
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
void findByCompletedPermissionsCheck() { void findByCompletedPermissionsCheck() {
assertPermissions(() -> distributionSetManagement.findByCompleted(PAGE, true), List.of(SpPermission.READ_REPOSITORY)); assertPermissions(() -> distributionSetManagement.findByCompleted(true, PAGE), List.of(SpPermission.READ_REPOSITORY));
} }
@Test @Test

View File

@@ -579,7 +579,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
void findDistributionSetsWithoutLazy() { void findDistributionSetsWithoutLazy() {
testdataFactory.createDistributionSets(20); testdataFactory.createDistributionSets(20);
assertThat(distributionSetManagement.findByCompleted(PAGE, true)).hasSize(20); assertThat(distributionSetManagement.findByCompleted(true, PAGE)).hasSize(20);
} }
@Test @Test
@@ -729,7 +729,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
distributionSetManagement.delete(ds1.getId()); distributionSetManagement.delete(ds1.getId());
// not assigned so not marked as deleted but fully deleted // not assigned so not marked as deleted but fully deleted
assertThat(distributionSetRepository.findAll()).hasSize(1); assertThat(distributionSetRepository.findAll()).hasSize(1);
assertThat(distributionSetManagement.findByCompleted(PAGE, true)).hasSize(1); assertThat(distributionSetManagement.findByCompleted(true, PAGE)).hasSize(1);
} }
@Test @Test
@@ -791,7 +791,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
// not assigned so not marked as deleted // not assigned so not marked as deleted
assertThat(distributionSetRepository.findAll()).hasSize(4); assertThat(distributionSetRepository.findAll()).hasSize(4);
assertThat(distributionSetManagement.findByCompleted(PAGE, true)).hasSize(2); assertThat(distributionSetManagement.findByCompleted(true, PAGE)).hasSize(2);
assertThat(distributionSetManagement.findAll(PAGE)).hasSize(2); assertThat(distributionSetManagement.findAll(PAGE)).hasSize(2);
assertThat(distributionSetManagement.findByRsql("name==*", PAGE)).hasSize(2); assertThat(distributionSetManagement.findByRsql("name==*", PAGE)).hasSize(2);
assertThat(distributionSetManagement.count()).isEqualTo(2); assertThat(distributionSetManagement.count()).isEqualTo(2);

View File

@@ -52,7 +52,7 @@ class DistributionSetTagManagementSecurityTest extends AbstractRepositoryManagem
@Test @Test
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
void findByDistributionSetPermissionsCheck() { void findByDistributionSetPermissionsCheck() {
assertPermissions(() -> distributionSetTagManagement.findByDistributionSet(Pageable.unpaged(), 1L), assertPermissions(() -> distributionSetTagManagement.findByDistributionSet(1L, Pageable.unpaged()),
List.of(SpPermission.READ_REPOSITORY)); List.of(SpPermission.READ_REPOSITORY));
} }

View File

@@ -68,7 +68,7 @@ class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest {
@Expect(type = TargetTagUpdatedEvent.class, count = 0) }) @Expect(type = TargetTagUpdatedEvent.class, count = 0) })
void entityQueriesReferringToNotExistingEntitiesThrowsException() { void entityQueriesReferringToNotExistingEntitiesThrowsException() {
verifyThrownExceptionBy(() -> distributionSetTagManagement.delete(NOT_EXIST_ID), "DistributionSetTag"); verifyThrownExceptionBy(() -> distributionSetTagManagement.delete(NOT_EXIST_ID), "DistributionSetTag");
verifyThrownExceptionBy(() -> distributionSetTagManagement.findByDistributionSet(PAGE, NOT_EXIST_IDL), verifyThrownExceptionBy(() -> distributionSetTagManagement.findByDistributionSet(NOT_EXIST_IDL, PAGE),
"DistributionSet"); "DistributionSet");
verifyThrownExceptionBy(() -> distributionSetTagManagement.update(entityFactory.tag().update(NOT_EXIST_IDL)), verifyThrownExceptionBy(() -> distributionSetTagManagement.update(entityFactory.tag().update(NOT_EXIST_IDL)),
"DistributionSetTag"); "DistributionSetTag");

View File

@@ -68,7 +68,7 @@ class RolloutGroupManagementSecurityTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
void findTargetsOfRolloutGroupByRsqlPermissionsCheck() { void findTargetsOfRolloutGroupByRsqlPermissionsCheck() {
assertPermissions(() -> rolloutGroupManagement.findTargetsOfRolloutGroupByRsql(PAGE, 1L, "name==*"), assertPermissions(() -> rolloutGroupManagement.findTargetsOfRolloutGroupByRsql(1L, "name==*", PAGE),
List.of(SpPermission.READ_ROLLOUT, SpPermission.READ_TARGET)); List.of(SpPermission.READ_ROLLOUT, SpPermission.READ_TARGET));
} }

View File

@@ -67,7 +67,7 @@ class RolloutGroupManagementTest extends AbstractJpaIntegrationTest {
verifyThrownExceptionBy(() -> rolloutGroupManagement.findByRolloutAndRsql(NOT_EXIST_IDL, "name==*", PAGE), "Rollout"); verifyThrownExceptionBy(() -> rolloutGroupManagement.findByRolloutAndRsql(NOT_EXIST_IDL, "name==*", PAGE), "Rollout");
verifyThrownExceptionBy(() -> rolloutGroupManagement.findTargetsOfRolloutGroup(NOT_EXIST_IDL, PAGE), "RolloutGroup"); verifyThrownExceptionBy(() -> rolloutGroupManagement.findTargetsOfRolloutGroup(NOT_EXIST_IDL, PAGE), "RolloutGroup");
verifyThrownExceptionBy(() -> rolloutGroupManagement.findTargetsOfRolloutGroupByRsql(PAGE, NOT_EXIST_IDL, "name==*"), "RolloutGroup"); verifyThrownExceptionBy(() -> rolloutGroupManagement.findTargetsOfRolloutGroupByRsql(NOT_EXIST_IDL, "name==*", PAGE), "RolloutGroup");
} }
@Test @Test

View File

@@ -27,7 +27,6 @@ import org.eclipse.hawkbit.repository.model.Rollout;
import org.eclipse.hawkbit.repository.model.RolloutGroupConditionBuilder; import org.eclipse.hawkbit.repository.model.RolloutGroupConditionBuilder;
import org.eclipse.hawkbit.repository.test.util.WithUser; import org.eclipse.hawkbit.repository.test.util.WithUser;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.data.domain.PageImpl;
@Slf4j @Slf4j
@Feature("SecurityTests - RolloutManagement") @Feature("SecurityTests - RolloutManagement")
@@ -127,26 +126,26 @@ class RolloutManagementSecurityTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
void findAllPermissionsCheck() { void findAllPermissionsCheck() {
assertPermissions(() -> rolloutManagement.findAll(PAGE, false), List.of(SpPermission.READ_ROLLOUT)); assertPermissions(() -> rolloutManagement.findAll(false, PAGE), List.of(SpPermission.READ_ROLLOUT));
} }
@Test @Test
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
void findByRsqlPermissionsCheck() { void findByRsqlPermissionsCheck() {
assertPermissions(() -> rolloutManagement.findByRsql(PAGE, "id==1", false), List.of(SpPermission.READ_ROLLOUT)); assertPermissions(() -> rolloutManagement.findByRsql("id==1", false, PAGE), List.of(SpPermission.READ_ROLLOUT));
} }
@Test @Test
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
void findAllWithDetailedStatusPermissionsCheck() { void findAllWithDetailedStatusPermissionsCheck() {
assertPermissions(() -> rolloutManagement.findAllWithDetailedStatus(PAGE, false), List.of(SpPermission.READ_ROLLOUT)); assertPermissions(() -> rolloutManagement.findAllWithDetailedStatus(false, PAGE), List.of(SpPermission.READ_ROLLOUT));
} }
@Test @Test
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
void findByRsqlWithDetailedStatusPermissionsCheck() { void findByRsqlWithDetailedStatusPermissionsCheck() {
assertPermissions(() -> assertPermissions(() ->
rolloutManagement.findByRsqlWithDetailedStatus(PAGE, "name==*", false), List.of(SpPermission.READ_ROLLOUT)); rolloutManagement.findByRsqlWithDetailedStatus("name==*", false, PAGE), List.of(SpPermission.READ_ROLLOUT));
} }
@Test @Test

View File

@@ -922,7 +922,7 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
expectedTargetCountStatus.put(TotalTargetCountStatus.Status.FINISHED, 9L); expectedTargetCountStatus.put(TotalTargetCountStatus.Status.FINISHED, 9L);
validateRolloutActionStatus(rolloutTwo.getId(), expectedTargetCountStatus); validateRolloutActionStatus(rolloutTwo.getId(), expectedTargetCountStatus);
changeStatusForAllRunningActions(rolloutTwo, Status.FINISHED); changeStatusForAllRunningActions(rolloutTwo, Status.FINISHED);
final Page<Target> targetPage = targetManagement.findByUpdateStatus(PAGE, TargetUpdateStatus.IN_SYNC); final Page<Target> targetPage = targetManagement.findByUpdateStatus(TargetUpdateStatus.IN_SYNC, PAGE);
final List<Target> targetList = targetPage.getContent(); final List<Target> targetList = targetPage.getContent();
// 15 targets in finished/IN_SYNC status and same DS assigned // 15 targets in finished/IN_SYNC status and same DS assigned
assertThat(targetList).hasSize(amountTargetsForRollout); assertThat(targetList).hasSize(amountTargetsForRollout);
@@ -1050,7 +1050,7 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
rolloutHandler.handleAll(); rolloutHandler.handleAll();
final Slice<Rollout> rolloutPage = rolloutManagement final Slice<Rollout> rolloutPage = rolloutManagement
.findAllWithDetailedStatus(new OffsetBasedPageRequest(0, 100, Sort.by(Direction.ASC, "name")), false); .findAllWithDetailedStatus(false, new OffsetBasedPageRequest(0, 100, Sort.by(Direction.ASC, "name")));
final List<Rollout> rolloutList = rolloutPage.getContent(); final List<Rollout> rolloutList = rolloutPage.getContent();
// validate rolloutA -> 6 running and 6 ready // validate rolloutA -> 6 running and 6 ready
@@ -1113,7 +1113,7 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
} }
final Slice<Rollout> rollout = rolloutManagement.findByRsqlWithDetailedStatus( final Slice<Rollout> rollout = rolloutManagement.findByRsqlWithDetailedStatus(
new OffsetBasedPageRequest(0, 100, Sort.by(Direction.ASC, "name")), "name==Rollout*", false); "name==Rollout*", false, new OffsetBasedPageRequest(0, 100, Sort.by(Direction.ASC, "name")));
final List<Rollout> rolloutList = rollout.getContent(); final List<Rollout> rolloutList = rollout.getContent();
assertThat(rolloutList).hasSize(5); assertThat(rolloutList).hasSize(5);
int i = 1; int i = 1;
@@ -1196,41 +1196,41 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
final String successCondition = "50"; final String successCondition = "50";
final String errorCondition = "80"; final String errorCondition = "80";
final String rolloutName = "MyRollout"; final String rolloutName = "MyRollout";
Rollout myRollout = createTestRolloutWithTargetsAndDistributionSet(amountTargetsForRollout, amountGroups, Rollout myRollout = createTestRolloutWithTargetsAndDistributionSet(
successCondition, errorCondition, rolloutName, rolloutName); amountTargetsForRollout, amountGroups, successCondition, errorCondition, rolloutName, rolloutName);
testdataFactory.createTargets(amountOtherTargets, "others-", "rollout"); testdataFactory.createTargets(amountOtherTargets, "others-", "rollout");
final String rsqlParam = "controllerId==*MyRoll*"; final String rsql = "controllerId==*MyRoll*";
rolloutManagement.start(myRollout.getId()); rolloutManagement.start(myRollout.getId());
// Run here, because scheduler is disabled during tests // Run here, because scheduler is disabled during tests
rolloutHandler.handleAll(); rolloutHandler.handleAll();
final Condition<String> targetBelongsInRollout = new Condition<>(s -> s.startsWith(rolloutName), final Condition<String> targetBelongsInRollout = new Condition<>(s -> s.startsWith(rolloutName), "Target belongs into rollout");
"Target belongs into rollout");
myRollout = reloadRollout(myRollout); myRollout = reloadRollout(myRollout);
final List<RolloutGroup> rolloutGroups = rolloutGroupManagement.findByRollout(myRollout.getId(), PAGE) final List<RolloutGroup> rolloutGroups = rolloutGroupManagement.findByRollout(myRollout.getId(), PAGE).getContent();
.getContent();
Page<Target> targetPage = rolloutGroupManagement.findTargetsOfRolloutGroupByRsql( Page<Target> targetPage = rolloutGroupManagement.findTargetsOfRolloutGroupByRsql(
new OffsetBasedPageRequest(0, 100), rolloutGroups.get(0).getId(), rsqlParam); rolloutGroups.get(0).getId(), rsql, new OffsetBasedPageRequest(0, 100));
final List<Target> targetlistGroup1 = targetPage.getContent(); final List<Target> targetlistGroup1 = targetPage.getContent();
assertThat(targetlistGroup1).hasSize(5); assertThat(targetlistGroup1).hasSize(5);
assertThat(targetlistGroup1.stream().map(Target::getControllerId).toList()) assertThat(targetlistGroup1.stream().map(Target::getControllerId).toList())
.are(targetBelongsInRollout); .are(targetBelongsInRollout);
targetPage = rolloutGroupManagement.findTargetsOfRolloutGroupByRsql(new OffsetBasedPageRequest(0, 100), targetPage = rolloutGroupManagement.findTargetsOfRolloutGroupByRsql(rolloutGroups.get(1).getId(), rsql,
rolloutGroups.get(1).getId(), rsqlParam); new OffsetBasedPageRequest(0, 100)
);
final List<Target> targetlistGroup2 = targetPage.getContent(); final List<Target> targetlistGroup2 = targetPage.getContent();
assertThat(targetlistGroup2).hasSize(5); assertThat(targetlistGroup2).hasSize(5);
assertThat(targetlistGroup2.stream().map(Target::getControllerId).toList()) assertThat(targetlistGroup2.stream().map(Target::getControllerId).toList())
.are(targetBelongsInRollout); .are(targetBelongsInRollout);
targetPage = rolloutGroupManagement.findTargetsOfRolloutGroupByRsql(new OffsetBasedPageRequest(0, 100), targetPage = rolloutGroupManagement.findTargetsOfRolloutGroupByRsql(rolloutGroups.get(2).getId(), rsql,
rolloutGroups.get(2).getId(), rsqlParam); new OffsetBasedPageRequest(0, 100)
);
final List<Target> targetlistGroup3 = targetPage.getContent(); final List<Target> targetlistGroup3 = targetPage.getContent();
assertThat(targetlistGroup3).hasSize(5); assertThat(targetlistGroup3).hasSize(5);
assertThat(targetlistGroup3.stream().map(Target::getControllerId).toList()).are(targetBelongsInRollout); assertThat(targetlistGroup3.stream().map(Target::getControllerId).toList()).are(targetBelongsInRollout);
@@ -1399,6 +1399,7 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
userWithoutHandleRollout, userWithoutHandleRollout,
() -> createRolloutWithStartAt(rolloutName + "_withLongMax", filter, distributionSet, Long.MAX_VALUE)); () -> createRolloutWithStartAt(rolloutName + "_withLongMax", filter, distributionSet, Long.MAX_VALUE));
} }
private Rollout createRolloutWithStartAt(final String rolloutName, final String filter, final DistributionSet distributionSet, private Rollout createRolloutWithStartAt(final String rolloutName, final String filter, final DistributionSet distributionSet,
final Long startAt) { final Long startAt) {
return rolloutManagement.create( return rolloutManagement.create(
@@ -1877,10 +1878,10 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
.isThrownBy(() -> rolloutManagement.update(rolloutUpdate)) .isThrownBy(() -> rolloutManagement.update(rolloutUpdate))
.withMessageContaining("" + createdRollout.getId()); .withMessageContaining("" + createdRollout.getId());
assertThat(rolloutManagement.findAll(PAGE, true).getContent()).hasSize(1); assertThat(rolloutManagement.findAll(true, PAGE).getContent()).hasSize(1);
assertThat(rolloutManagement.findAll(PAGE, false).getContent()).isEmpty(); assertThat(rolloutManagement.findAll(false, PAGE).getContent()).isEmpty();
assertThat(rolloutManagement.findByRsql(PAGE, "name==*", true).getContent()).hasSize(1); assertThat(rolloutManagement.findByRsql("name==*", true, PAGE).getContent()).hasSize(1);
assertThat(rolloutManagement.findByRsql(PAGE, "name==*", false).getContent()).isEmpty(); assertThat(rolloutManagement.findByRsql("name==*", false, PAGE).getContent()).isEmpty();
assertThat(rolloutManagement.count()).isZero(); assertThat(rolloutManagement.count()).isZero();
assertThat(rolloutGroupManagement.findByRolloutWithDetailedStatus(createdRollout.getId(), PAGE).getContent()).hasSize(amountGroups); assertThat(rolloutGroupManagement.findByRolloutWithDetailedStatus(createdRollout.getId(), PAGE).getContent()).hasSize(amountGroups);
@@ -1923,11 +1924,11 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
rolloutReady = reloadRollout(rolloutReady); rolloutReady = reloadRollout(rolloutReady);
final List<Rollout> rolloutsOrderedByStatus = rolloutManagement final List<Rollout> rolloutsOrderedByStatus = rolloutManagement
.findAll(PageRequest.of(0, 500, Sort.by(Direction.ASC, "status")), false).getContent(); .findAll(false, PageRequest.of(0, 500, Sort.by(Direction.ASC, "status"))).getContent();
assertThat(rolloutsOrderedByStatus).containsSubsequence(List.of(rolloutReady, rolloutRunning)); assertThat(rolloutsOrderedByStatus).containsSubsequence(List.of(rolloutReady, rolloutRunning));
final List<Rollout> rolloutsOrderedByName = rolloutManagement final List<Rollout> rolloutsOrderedByName = rolloutManagement
.findAll(PageRequest.of(0, 500, Sort.by(Direction.ASC, "name")), false).getContent(); .findAll(false, PageRequest.of(0, 500, Sort.by(Direction.ASC, "name"))).getContent();
assertThat(rolloutsOrderedByName).containsSubsequence(List.of(rolloutRunning, rolloutReady)); assertThat(rolloutsOrderedByName).containsSubsequence(List.of(rolloutRunning, rolloutReady));
} }
@@ -2298,7 +2299,7 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest {
final List<Target> targets = rolloutGroupManagement.findTargetsOfRolloutGroup(rolloutGroupId, PAGE) final List<Target> targets = rolloutGroupManagement.findTargetsOfRolloutGroup(rolloutGroupId, PAGE)
.getContent(); .getContent();
targets.forEach(target -> { targets.forEach(target -> {
deploymentManagement.findActiveActionsByTarget(PAGE, target.getControllerId()).getContent().stream().map(Identifiable::getId) deploymentManagement.findActiveActionsByTarget(target.getControllerId(), PAGE).getContent().stream().map(Identifiable::getId)
.forEach(actionId -> { .forEach(actionId -> {
deploymentManagement.cancelAction(actionId); deploymentManagement.cancelAction(actionId);
deploymentManagement.forceQuitAction(actionId); deploymentManagement.forceQuitAction(actionId);

View File

@@ -103,7 +103,7 @@ class SoftwareManagementSecurityTest
@Test @Test
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
void findMetaDataBySoftwareModuleIdAndTargetVisiblePermissionsCheck() { void findMetaDataBySoftwareModuleIdAndTargetVisiblePermissionsCheck() {
assertPermissions(() -> softwareModuleManagement.findMetaDataBySoftwareModuleIdAndTargetVisible(PAGE, 1L), assertPermissions(() -> softwareModuleManagement.findMetaDataBySoftwareModuleIdAndTargetVisible(1L, PAGE),
List.of(SpPermission.READ_REPOSITORY)); List.of(SpPermission.READ_REPOSITORY));
} }

View File

@@ -694,9 +694,9 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
assertThat(metadataSw2).hasSize(metadataCountSw2); assertThat(metadataSw2).hasSize(metadataCountSw2);
final Page<SoftwareModuleMetadata> metadataSw1V = softwareModuleManagement.findMetaDataBySoftwareModuleIdAndTargetVisible( final Page<SoftwareModuleMetadata> metadataSw1V = softwareModuleManagement.findMetaDataBySoftwareModuleIdAndTargetVisible(
PAGE_REQUEST_100, sw1.getId()); sw1.getId(), PAGE_REQUEST_100);
final Page<SoftwareModuleMetadata> metadataSw2V = softwareModuleManagement.findMetaDataBySoftwareModuleIdAndTargetVisible( final Page<SoftwareModuleMetadata> metadataSw2V = softwareModuleManagement.findMetaDataBySoftwareModuleIdAndTargetVisible(
PAGE_REQUEST_100, sw2.getId()); sw2.getId(), PAGE_REQUEST_100);
assertThat(metadataSw1V.getNumberOfElements()).isEqualTo(metadataCountSw1); assertThat(metadataSw1V.getNumberOfElements()).isEqualTo(metadataCountSw1);
assertThat(metadataSw1V.getTotalElements()).isEqualTo(metadataCountSw1); assertThat(metadataSw1V.getTotalElements()).isEqualTo(metadataCountSw1);
assertThat(metadataSw2V.getNumberOfElements()).isZero(); assertThat(metadataSw2V.getNumberOfElements()).isZero();

View File

@@ -68,7 +68,7 @@ class TargetFilterQueryManagementSecurityTest extends AbstractJpaIntegrationTest
@Test @Test
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
void findByNamePermissionsCheck() { void findByNamePermissionsCheck() {
assertPermissions(() -> targetFilterQueryManagement.findByName(PAGE, "filterName"), List.of(SpPermission.READ_TARGET)); assertPermissions(() -> targetFilterQueryManagement.findByName("filterName", PAGE), List.of(SpPermission.READ_TARGET));
} }
@Test @Test
@@ -80,26 +80,26 @@ class TargetFilterQueryManagementSecurityTest extends AbstractJpaIntegrationTest
@Test @Test
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
void findByRsqlPermissionsCheck() { void findByRsqlPermissionsCheck() {
assertPermissions(() -> targetFilterQueryManagement.findByRsql(PAGE, "name==id"), List.of(SpPermission.READ_TARGET)); assertPermissions(() -> targetFilterQueryManagement.findByRsql("name==id", PAGE), List.of(SpPermission.READ_TARGET));
} }
@Test @Test
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
void findByQueryPermissionsCheck() { void findByQueryPermissionsCheck() {
assertPermissions(() -> targetFilterQueryManagement.findByQuery(PAGE, "controllerId==id"), List.of(SpPermission.READ_TARGET)); assertPermissions(() -> targetFilterQueryManagement.findByQuery("controllerId==id", PAGE), List.of(SpPermission.READ_TARGET));
} }
@Test @Test
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
void findByAutoAssignDistributionSetIdPermissionsCheck() { void findByAutoAssignDistributionSetIdPermissionsCheck() {
assertPermissions(() -> targetFilterQueryManagement.findByAutoAssignDistributionSetId(PAGE, 1L), assertPermissions(() -> targetFilterQueryManagement.findByAutoAssignDistributionSetId(1L, PAGE),
List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY)); List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY));
} }
@Test @Test
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
void findByAutoAssignDSAndRsqlPermissionsCheck() { void findByAutoAssignDSAndRsqlPermissionsCheck() {
assertPermissions(() -> targetFilterQueryManagement.findByAutoAssignDSAndRsql(PAGE, 1L, "rsqlParam"), assertPermissions(() -> targetFilterQueryManagement.findByAutoAssignDSAndRsql(1L, "rsqlParam", PAGE),
List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY)); List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY));
} }

View File

@@ -87,7 +87,7 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest {
verifyThrownExceptionBy(() -> targetFilterQueryManagement.delete(NOT_EXIST_IDL), "TargetFilterQuery"); verifyThrownExceptionBy(() -> targetFilterQueryManagement.delete(NOT_EXIST_IDL), "TargetFilterQuery");
verifyThrownExceptionBy( verifyThrownExceptionBy(
() -> targetFilterQueryManagement.findByAutoAssignDSAndRsql(PAGE, NOT_EXIST_IDL, "name==*"), () -> targetFilterQueryManagement.findByAutoAssignDSAndRsql(NOT_EXIST_IDL, "name==*", PAGE),
"DistributionSet"); "DistributionSet");
verifyThrownExceptionBy( verifyThrownExceptionBy(
@@ -145,7 +145,7 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest {
entityFactory.targetFilterQuery().create().name("someOtherFilter").query("name==PendingTargets002")); entityFactory.targetFilterQuery().create().name("someOtherFilter").query("name==PendingTargets002"));
final List<TargetFilterQuery> results = targetFilterQueryManagement final List<TargetFilterQuery> results = targetFilterQueryManagement
.findByRsql(PageRequest.of(0, 10), "name==" + filterName).getContent(); .findByRsql("name==" + filterName, PageRequest.of(0, 10)).getContent();
assertEquals(1, results.size(), "Search result should have 1 result"); assertEquals(1, results.size(), "Search result should have 1 result");
assertEquals(targetFilterQuery, results.get(0), "Retrieved newly created custom target filter"); assertEquals(targetFilterQuery, results.get(0), "Retrieved newly created custom target filter");
} }
@@ -155,7 +155,7 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest {
void searchTargetFilterQueryInvalidField() { void searchTargetFilterQueryInvalidField() {
final PageRequest pageRequest = PageRequest.of(0, 10); final PageRequest pageRequest = PageRequest.of(0, 10);
Assertions.assertThatExceptionOfType(RSQLParameterUnsupportedFieldException.class) Assertions.assertThatExceptionOfType(RSQLParameterUnsupportedFieldException.class)
.isThrownBy(() -> targetFilterQueryManagement.findByRsql(pageRequest, "unknownField==testValue")); .isThrownBy(() -> targetFilterQueryManagement.findByRsql("unknownField==testValue", pageRequest));
} }
@Test @Test
@@ -573,7 +573,7 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest {
private void verifyFindByDistributionSetAndRsql(final DistributionSet distributionSet, final String rsql, private void verifyFindByDistributionSetAndRsql(final DistributionSet distributionSet, final String rsql,
final TargetFilterQuery... expectedFilterQueries) { final TargetFilterQuery... expectedFilterQueries) {
final Page<TargetFilterQuery> tfqList = targetFilterQueryManagement final Page<TargetFilterQuery> tfqList = targetFilterQueryManagement
.findByAutoAssignDSAndRsql(PageRequest.of(0, 500), distributionSet.getId(), rsql); .findByAutoAssignDSAndRsql(distributionSet.getId(), rsql, PageRequest.of(0, 500));
assertThat(tfqList.getTotalElements()).isEqualTo(expectedFilterQueries.length); assertThat(tfqList.getTotalElements()).isEqualTo(expectedFilterQueries.length);
verifyExpectedFilterQueriesInList(tfqList, expectedFilterQueries); verifyExpectedFilterQueriesInList(tfqList, expectedFilterQueries);

View File

@@ -47,13 +47,13 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
final List<Target> unassigned = testdataFactory.createTargets(9, "unassigned"); final List<Target> unassigned = testdataFactory.createTargets(9, "unassigned");
final List<Target> assigned = testdataFactory.createTargetsWithType(11, "assigned", testType); final List<Target> assigned = testdataFactory.createTargetsWithType(11, "assigned", testType);
assertThat(targetManagement.findByFilters(PAGE, new FilterParams(null, null, false, testType.getId()))) assertThat(targetManagement.findByFilters(new FilterParams(null, null, false, testType.getId()), PAGE))
.as("Contains the targets with set type").containsAll(assigned) .as("Contains the targets with set type").containsAll(assigned)
.as("and that means the following expected amount").hasSize(11); .as("and that means the following expected amount").hasSize(11);
assertThat(targetManagement.countByFilters(new FilterParams(null, null, false, testType.getId()))) assertThat(targetManagement.countByFilters(new FilterParams(null, null, false, testType.getId())))
.as("Count the targets with set type").isEqualTo(11); .as("Count the targets with set type").isEqualTo(11);
assertThat(targetManagement.findByFilters(PAGE, new FilterParams(null, null, true, null))) assertThat(targetManagement.findByFilters(new FilterParams(null, null, true, null), PAGE))
.as("Contains the targets without a type").containsAll(unassigned) .as("Contains the targets without a type").containsAll(unassigned)
.as("and that means the following expected amount").hasSize(9); .as("and that means the following expected amount").hasSize(9);
assertThat(targetManagement.countByFilters(new FilterParams(null, null, true, null))) assertThat(targetManagement.countByFilters(new FilterParams(null, null, true, null)))
@@ -199,7 +199,7 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
// get final updated version of targets // get final updated version of targets
assignedtargets = targetManagement.getByControllerID(assignedtargets.stream().map(Target::getControllerId).toList()); assignedtargets = targetManagement.getByControllerID(assignedtargets.stream().map(Target::getControllerId).toList());
assertThat(targetManagement.findByAssignedDistributionSet(PAGE, assignedSet.getId())) assertThat(targetManagement.findByAssignedDistributionSet(assignedSet.getId(), PAGE))
.as("Contains the assigned targets").containsAll(assignedtargets) .as("Contains the assigned targets").containsAll(assignedtargets)
.as("and that means the following expected amount").hasSize(10); .as("and that means the following expected amount").hasSize(10);
@@ -217,7 +217,7 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
assignDistributionSet(assignedSet, assignedTargets); assignDistributionSet(assignedSet, assignedTargets);
final List<Target> result = targetManagement final List<Target> result = targetManagement
.findByTargetFilterQueryAndNonDSAndCompatibleAndUpdatable(PAGE, assignedSet.getId(), tfq.getQuery()).getContent(); .findByTargetFilterQueryAndNonDSAndCompatibleAndUpdatable(assignedSet.getId(), tfq.getQuery(), PAGE).getContent();
assertThat(result).as("count of targets").hasSize(unassignedTargets.size()).as("contains all targets") assertThat(result).as("count of targets").hasSize(unassignedTargets.size()).as("contains all targets")
.containsAll(unassignedTargets); .containsAll(unassignedTargets);
@@ -239,7 +239,7 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
// get final updated version of targets // get final updated version of targets
installedtargets = targetManagement.getByControllerID(installedtargets.stream().map(Target::getControllerId).toList()); installedtargets = targetManagement.getByControllerID(installedtargets.stream().map(Target::getControllerId).toList());
assertThat(targetManagement.findByInstalledDistributionSet(PAGE, installedSet.getId())) assertThat(targetManagement.findByInstalledDistributionSet(installedSet.getId(), PAGE))
.as("Contains the assigned targets").containsAll(installedtargets) .as("Contains the assigned targets").containsAll(installedtargets)
.as("and that means the following expected amount").hasSize(10); .as("and that means the following expected amount").hasSize(10);
@@ -258,7 +258,7 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
targetType); targetType);
final List<Target> result = targetManagement final List<Target> result = targetManagement
.findByTargetFilterQueryAndNonDSAndCompatibleAndUpdatable(PAGE, testDs.getId(), tfq.getQuery()).getContent(); .findByTargetFilterQueryAndNonDSAndCompatibleAndUpdatable(testDs.getId(), tfq.getQuery(), PAGE).getContent();
assertThat(result).as("count of targets").hasSize(targets.size() + targetWithCompatibleTypes.size()) assertThat(result).as("count of targets").hasSize(targets.size() + targetWithCompatibleTypes.size())
.as("contains all targets").containsAll(targetWithCompatibleTypes).containsAll(targets); .as("contains all targets").containsAll(targetWithCompatibleTypes).containsAll(targets);
@@ -288,7 +288,7 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
testTargets.addAll(targetsWithCompatibleType); testTargets.addAll(targetsWithCompatibleType);
final List<Target> result = targetManagement final List<Target> result = targetManagement
.findByTargetFilterQueryAndNonDSAndCompatibleAndUpdatable(PAGE, testDs.getId(), tfq.getQuery()).getContent(); .findByTargetFilterQueryAndNonDSAndCompatibleAndUpdatable(testDs.getId(), tfq.getQuery(), PAGE).getContent();
assertThat(result).as("count of targets").hasSize(testTargets.size()).as("contains all compatible targets") assertThat(result).as("count of targets").hasSize(testTargets.size()).as("contains all compatible targets")
.containsExactlyInAnyOrderElementsOf(testTargets).as("does not contain incompatible targets") .containsExactlyInAnyOrderElementsOf(testTargets).as("does not contain incompatible targets")
@@ -300,12 +300,12 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
final List<TargetUpdateStatus> pending, final Target expected) { final List<TargetUpdateStatus> pending, final Target expected) {
final FilterParams filterParams = new FilterParams(pending, null, null, installedSet.getId(), Boolean.FALSE); final FilterParams filterParams = new FilterParams(pending, null, null, installedSet.getId(), Boolean.FALSE);
final String query = "updatestatus==pending and installedds.name==" + installedSet.getName(); final String query = "updatestatus==pending and installedds.name==" + installedSet.getName();
assertThat(targetManagement.findByFilters(PAGE, filterParams).getContent()).as("has number of elements") assertThat(targetManagement.findByFilters(filterParams, PAGE).getContent()).as("has number of elements")
.hasSize(1).as("that number is also returned by count query") .hasSize(1).as("that number is also returned by count query")
.hasSize((int) targetManagement.countByFilters(filterParams)) .hasSize((int) targetManagement.countByFilters(filterParams))
.as("and contains the following elements").containsExactly(expected) .as("and contains the following elements").containsExactly(expected)
.as("and filter query returns the same result") .as("and filter query returns the same result")
.containsAll(targetManagement.findByRsql(PAGE, query).getContent()); .containsAll(targetManagement.findByRsql(query, PAGE).getContent());
} }
@Step @Step
@@ -314,12 +314,12 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
final FilterParams filterParams = new FilterParams(both, null, null, null, Boolean.FALSE, targTagW.getName()); final FilterParams filterParams = new FilterParams(both, null, null, null, Boolean.FALSE, targTagW.getName());
final String query = "(updatestatus==pending or updatestatus==unknown) and tag==" + targTagW.getName(); final String query = "(updatestatus==pending or updatestatus==unknown) and tag==" + targTagW.getName();
assertThat(targetManagement.findByFilters(PAGE, filterParams).getContent()).as("has number of elements") assertThat(targetManagement.findByFilters(filterParams, PAGE).getContent()).as("has number of elements")
.hasSize(200).as("that number is also returned by count query") .hasSize(200).as("that number is also returned by count query")
.hasSize((int) targetManagement.countByFilters(filterParams)) .hasSize((int) targetManagement.countByFilters(filterParams))
.as("and contains the following elements").containsAll(expected) .as("and contains the following elements").containsAll(expected)
.as("and filter query returns the same result") .as("and filter query returns the same result")
.containsAll(targetManagement.findByRsql(PAGE, query).getContent()); .containsAll(targetManagement.findByRsql(query, PAGE).getContent());
} }
@Step @Step
@@ -329,12 +329,12 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
targTagW.getName()); targTagW.getName());
final String query = "updatestatus==pending and tag==" + targTagW.getName(); final String query = "updatestatus==pending and tag==" + targTagW.getName();
assertThat(targetManagement.findByFilters(PAGE, filterParams).getContent()).as("has number of elements") assertThat(targetManagement.findByFilters(filterParams, PAGE).getContent()).as("has number of elements")
.hasSize(2).as("that number is also returned by count query") .hasSize(2).as("that number is also returned by count query")
.hasSize((int) targetManagement.countByFilters(filterParams)) .hasSize((int) targetManagement.countByFilters(filterParams))
.as("and contains the following elements").containsAll(expected) .as("and contains the following elements").containsAll(expected)
.as("and filter query returns the same result") .as("and filter query returns the same result")
.containsAll(targetManagement.findByRsql(PAGE, query).getContent()); .containsAll(targetManagement.findByRsql(query, PAGE).getContent());
} }
@Step @Step
@@ -345,12 +345,12 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
final String query = "updatestatus==pending and (assignedds.name==" + setA.getName() + " or installedds.name==" final String query = "updatestatus==pending and (assignedds.name==" + setA.getName() + " or installedds.name=="
+ setA.getName() + ") and tag==" + targTagW.getName(); + setA.getName() + ") and tag==" + targTagW.getName();
assertThat(targetManagement.findByFilters(PAGE, filterParams).getContent()).as("has number of elements") assertThat(targetManagement.findByFilters(filterParams, PAGE).getContent()).as("has number of elements")
.hasSize(2).as("that number is also returned by count query") .hasSize(2).as("that number is also returned by count query")
.hasSize((int) targetManagement.countByFilters(filterParams)) .hasSize((int) targetManagement.countByFilters(filterParams))
.as("and contains the following elements").containsAll(expected) .as("and contains the following elements").containsAll(expected)
.as("and filter query returns the same result") .as("and filter query returns the same result")
.containsAll(targetManagement.findByRsql(PAGE, query).getContent()); .containsAll(targetManagement.findByRsql(query, PAGE).getContent());
} }
@Step @Step
@@ -361,12 +361,12 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
final String query = "updatestatus==pending and (assignedds.name==" + setA.getName() + " or installedds.name==" final String query = "updatestatus==pending and (assignedds.name==" + setA.getName() + " or installedds.name=="
+ setA.getName() + ") and (name==*targ-B* or description==*targ-B*) and tag==" + targTagW.getName(); + setA.getName() + ") and (name==*targ-B* or description==*targ-B*) and tag==" + targTagW.getName();
assertThat(targetManagement.findByFilters(PAGE, filterParams).getContent()).as("has number of elements") assertThat(targetManagement.findByFilters(filterParams, PAGE).getContent()).as("has number of elements")
.hasSize(1).as("that number is also returned by count query") .hasSize(1).as("that number is also returned by count query")
.hasSize((int) targetManagement.countByFilters(filterParams)) .hasSize((int) targetManagement.countByFilters(filterParams))
.as("and contains the following elements").containsExactly(expected) .as("and contains the following elements").containsExactly(expected)
.as("and filter query returns the same result") .as("and filter query returns the same result")
.containsAll(targetManagement.findByRsql(PAGE, query).getContent()); .containsAll(targetManagement.findByRsql(query, PAGE).getContent());
} }
@Step @Step
@@ -376,12 +376,12 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
final String query = "updatestatus==pending and (assignedds.name==" + setA.getName() + " or installedds.name==" final String query = "updatestatus==pending and (assignedds.name==" + setA.getName() + " or installedds.name=="
+ setA.getName() + ") and (name==*targ-A* or description==*targ-A*)"; + setA.getName() + ") and (name==*targ-A* or description==*targ-A*)";
assertThat(targetManagement.findByFilters(PAGE, filterParams).getContent()).as("has number of elements") assertThat(targetManagement.findByFilters(filterParams, PAGE).getContent()).as("has number of elements")
.hasSize(1).as("that number is also returned by count query") .hasSize(1).as("that number is also returned by count query")
.hasSize((int) targetManagement.countByFilters(filterParams)) .hasSize((int) targetManagement.countByFilters(filterParams))
.as("and contains the following elements").containsExactly(expected) .as("and contains the following elements").containsExactly(expected)
.as("and filter query returns the same result") .as("and filter query returns the same result")
.containsAll(targetManagement.findByRsql(PAGE, query).getContent()); .containsAll(targetManagement.findByRsql(query, PAGE).getContent());
} }
@Step @Step
@@ -391,12 +391,12 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
final String query = "updatestatus==pending and (assignedds.name==" + setA.getName() + " or installedds.name==" final String query = "updatestatus==pending and (assignedds.name==" + setA.getName() + " or installedds.name=="
+ setA.getName() + ")"; + setA.getName() + ")";
assertThat(targetManagement.findByFilters(PAGE, filterParams).getContent()).as("has number of elements") assertThat(targetManagement.findByFilters(filterParams, PAGE).getContent()).as("has number of elements")
.hasSize(3).as("that number is also returned by count query") .hasSize(3).as("that number is also returned by count query")
.hasSize((int) targetManagement.countByFilters(filterParams)) .hasSize((int) targetManagement.countByFilters(filterParams))
.as("and contains the following elements").containsAll(expected) .as("and contains the following elements").containsAll(expected)
.as("and filter query returns the same result") .as("and filter query returns the same result")
.containsAll(targetManagement.findByRsql(PAGE, query).getContent()); .containsAll(targetManagement.findByRsql(query, PAGE).getContent());
} }
@Step @Step
@@ -405,12 +405,12 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
final FilterParams filterParams = new FilterParams(pending, null, null, null, Boolean.FALSE); final FilterParams filterParams = new FilterParams(pending, null, null, null, Boolean.FALSE);
final String query = "updatestatus==pending"; final String query = "updatestatus==pending";
assertThat(targetManagement.findByFilters(PAGE, filterParams).getContent()).as("has number of elements") assertThat(targetManagement.findByFilters(filterParams, PAGE).getContent()).as("has number of elements")
.hasSize(4).as("that number is also returned by count query") .hasSize(4).as("that number is also returned by count query")
.hasSize((int) targetManagement.countByFilters(filterParams)) .hasSize((int) targetManagement.countByFilters(filterParams))
.as("and contains the following elements").containsAll(expected) .as("and contains the following elements").containsAll(expected)
.as("and filter query returns the same result") .as("and filter query returns the same result")
.containsAll(targetManagement.findByRsql(PAGE, query).getContent()); .containsAll(targetManagement.findByRsql(query, PAGE).getContent());
} }
@Step @Step
@@ -421,12 +421,12 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
final String query = "updatestatus==unknown and (name==*targ-B* or description==*targ-B*) and tag==" final String query = "updatestatus==unknown and (name==*targ-B* or description==*targ-B*) and tag=="
+ targTagW.getName(); + targTagW.getName();
assertThat(targetManagement.findByFilters(PAGE, filterParams).getContent()).as("has number of elements") assertThat(targetManagement.findByFilters(filterParams, PAGE).getContent()).as("has number of elements")
.hasSize(99).as("that number is also returned by count query") .hasSize(99).as("that number is also returned by count query")
.hasSize((int) targetManagement.countByFilters(filterParams)) .hasSize((int) targetManagement.countByFilters(filterParams))
.as("and contains the following elements").containsAll(expected) .as("and contains the following elements").containsAll(expected)
.as("and filter query returns the same result") .as("and filter query returns the same result")
.containsAll(targetManagement.findByRsql(PAGE, query).getContent()); .containsAll(targetManagement.findByRsql(query, PAGE).getContent());
} }
@Step @Step
@@ -435,12 +435,12 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
final FilterParams filterParams = new FilterParams(unknown, null, "%targ-A%", null, Boolean.FALSE); final FilterParams filterParams = new FilterParams(unknown, null, "%targ-A%", null, Boolean.FALSE);
final String query = "updatestatus==unknown and (name==*targ-A* or description==*targ-A*)"; final String query = "updatestatus==unknown and (name==*targ-A* or description==*targ-A*)";
assertThat(targetManagement.findByFilters(PAGE, filterParams).getContent()).as("has number of elements") assertThat(targetManagement.findByFilters(filterParams, PAGE).getContent()).as("has number of elements")
.hasSize(99).as("that number is also returned by count query") .hasSize(99).as("that number is also returned by count query")
.hasSize((int) targetManagement.countByFilters(filterParams)) .hasSize((int) targetManagement.countByFilters(filterParams))
.as("and contains the following elements").containsAll(expected) .as("and contains the following elements").containsAll(expected)
.as("and filter query returns the same result") .as("and filter query returns the same result")
.containsAll(targetManagement.findByRsql(PAGE, query).getContent()); .containsAll(targetManagement.findByRsql(query, PAGE).getContent());
} }
@Step @Step
@@ -450,11 +450,11 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
final String query = "updatestatus==unknown and (assignedds.name==" + setA.getName() + " or installedds.name==" final String query = "updatestatus==unknown and (assignedds.name==" + setA.getName() + " or installedds.name=="
+ setA.getName() + ")"; + setA.getName() + ")";
assertThat(targetManagement.findByFilters(PAGE, filterParams).getContent()) assertThat(targetManagement.findByFilters(filterParams, PAGE).getContent())
.as("that number is also returned by count query") .as("that number is also returned by count query")
.hasSize((int) targetManagement.countByFilters(filterParams)) .hasSize((int) targetManagement.countByFilters(filterParams))
.as("and filter query returns the same result") .as("and filter query returns the same result")
.hasSize(targetManagement.findByRsql(PAGE, query).getContent().size()) .hasSize(targetManagement.findByRsql(query, PAGE).getContent().size())
.as("has number of elements") .as("has number of elements")
.isEmpty(); .isEmpty();
} }
@@ -467,12 +467,12 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
final String query = "updatestatus==unknown and (tag==" + targTagY.getName() + " or tag==" + targTagW.getName() final String query = "updatestatus==unknown and (tag==" + targTagY.getName() + " or tag==" + targTagW.getName()
+ ")"; + ")";
assertThat(targetManagement.findByFilters(PAGE, filterParams).getContent()).as("has number of elements") assertThat(targetManagement.findByFilters(filterParams, PAGE).getContent()).as("has number of elements")
.hasSize(198).as("that number is also returned by count query") .hasSize(198).as("that number is also returned by count query")
.hasSize((int) targetManagement.countByFilters(filterParams)) .hasSize((int) targetManagement.countByFilters(filterParams))
.as("and contains the following elements").containsAll(expected) .as("and contains the following elements").containsAll(expected)
.as("and filter query returns the same result") .as("and filter query returns the same result")
.containsAll(targetManagement.findByRsql(PAGE, query).getContent()); .containsAll(targetManagement.findByRsql(query, PAGE).getContent());
} }
@Step @Step
@@ -481,12 +481,12 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
final FilterParams filterParams = new FilterParams(unknown, null, null, null, Boolean.FALSE); final FilterParams filterParams = new FilterParams(unknown, null, null, null, Boolean.FALSE);
final String query = "updatestatus==unknown"; final String query = "updatestatus==unknown";
assertThat(targetManagement.findByFilters(PAGE, filterParams).getContent()).as("has number of elements") assertThat(targetManagement.findByFilters(filterParams, PAGE).getContent()).as("has number of elements")
.hasSize(496).as("that number is also returned by count query") .hasSize(496).as("that number is also returned by count query")
.hasSize((int) targetManagement.countByFilters(filterParams)) .hasSize((int) targetManagement.countByFilters(filterParams))
.as("and contains the following elements").containsAll(expected) .as("and contains the following elements").containsAll(expected)
.as("and filter query returns the same result") .as("and filter query returns the same result")
.containsAll(targetManagement.findByRsql(PAGE, query).getContent()); .containsAll(targetManagement.findByRsql(query, PAGE).getContent());
} }
@Step @Step
@@ -496,12 +496,12 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
// be careful: simple filters are concatenated using AND-gating // be careful: simple filters are concatenated using AND-gating
final String query = "lastcontrollerrequestat=le=${overdue_ts};updatestatus==UNKNOWN"; final String query = "lastcontrollerrequestat=le=${overdue_ts};updatestatus==UNKNOWN";
assertThat(targetManagement.findByFilters(PAGE, filterParams).getContent()).as("has number of elements") assertThat(targetManagement.findByFilters(filterParams, PAGE).getContent()).as("has number of elements")
.hasSize(198).as("that number is also returned by count query") .hasSize(198).as("that number is also returned by count query")
.hasSize((int) targetManagement.countByFilters(filterParams)) .hasSize((int) targetManagement.countByFilters(filterParams))
.as("and contains the following elements").containsAll(expected) .as("and contains the following elements").containsAll(expected)
.as("and filter query returns the same result") .as("and filter query returns the same result")
.containsAll(targetManagement.findByRsql(PAGE, query).getContent()); .containsAll(targetManagement.findByRsql(query, PAGE).getContent());
} }
@Step @Step
@@ -510,12 +510,12 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
final String query = "(name==*targ-A* or description==*targ-A*) and (assignedds.name==" + setA.getName() final String query = "(name==*targ-A* or description==*targ-A*) and (assignedds.name==" + setA.getName()
+ " or installedds.name==" + setA.getName() + ")"; + " or installedds.name==" + setA.getName() + ")";
assertThat(targetManagement.findByFilters(PAGE, filterParams).getContent()).as("has number of elements") assertThat(targetManagement.findByFilters(filterParams, PAGE).getContent()).as("has number of elements")
.hasSize(1).as("that number is also returned by count query") .hasSize(1).as("that number is also returned by count query")
.hasSize((int) targetManagement.countByFilters(filterParams)) .hasSize((int) targetManagement.countByFilters(filterParams))
.as("and contains the following elements").containsExactly(expected) .as("and contains the following elements").containsExactly(expected)
.as("and filter query returns the same result") .as("and filter query returns the same result")
.containsAll(targetManagement.findByRsql(PAGE, query).getContent()); .containsAll(targetManagement.findByRsql(query, PAGE).getContent());
} }
@Step @Step
@@ -523,12 +523,12 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
final FilterParams filterParams = new FilterParams(null, null, null, setA.getId(), Boolean.FALSE); final FilterParams filterParams = new FilterParams(null, null, null, setA.getId(), Boolean.FALSE);
final String query = "assignedds.name==" + setA.getName() + " or installedds.name==" + setA.getName(); final String query = "assignedds.name==" + setA.getName() + " or installedds.name==" + setA.getName();
assertThat(targetManagement.findByFilters(PAGE, filterParams).getContent()).as("has number of elements") assertThat(targetManagement.findByFilters(filterParams, PAGE).getContent()).as("has number of elements")
.hasSize(3).as("that number is also returned by count query") .hasSize(3).as("that number is also returned by count query")
.hasSize((int) targetManagement.countByFilters(filterParams)) .hasSize((int) targetManagement.countByFilters(filterParams))
.as("and contains the following elements").containsAll(expected) .as("and contains the following elements").containsAll(expected)
.as("and filter query returns the same result") .as("and filter query returns the same result")
.containsAll(targetManagement.findByRsql(PAGE, query).getContent()); .containsAll(targetManagement.findByRsql(query, PAGE).getContent());
} }
@Step @Step
@@ -537,11 +537,11 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
targTagX.getName()); targTagX.getName());
final String query = "(name==*targ-C* or description==*targ-C*) and tag==" + targTagX.getName() final String query = "(name==*targ-C* or description==*targ-C*) and tag==" + targTagX.getName()
+ " and (assignedds.name==" + setA.getName() + " or installedds.name==" + setA.getName() + ")"; + " and (assignedds.name==" + setA.getName() + " or installedds.name==" + setA.getName() + ")";
assertThat(targetManagement.findByFilters(PAGE, filterParams).getContent()) assertThat(targetManagement.findByFilters(filterParams, PAGE).getContent())
.as("that number is also returned by count query") .as("that number is also returned by count query")
.hasSize((int) targetManagement.countByFilters(filterParams)) .hasSize((int) targetManagement.countByFilters(filterParams))
.as("and filter query returns the same result") .as("and filter query returns the same result")
.hasSize(targetManagement.findByRsql(PAGE, query).getContent().size()) .hasSize(targetManagement.findByRsql(query, PAGE).getContent().size())
.as("has number of elements") .as("has number of elements")
.isEmpty(); .isEmpty();
} }
@@ -552,10 +552,10 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
targTagW.getName()); targTagW.getName());
final String query = "(name==*targ-A* or description==*targ-A*) and tag==" + targTagW.getName() final String query = "(name==*targ-A* or description==*targ-A*) and tag==" + targTagW.getName()
+ " and (assignedds.name==" + setA.getName() + " or installedds.name==" + setA.getName() + ")"; + " and (assignedds.name==" + setA.getName() + " or installedds.name==" + setA.getName() + ")";
assertThat(targetManagement.findByFilters(PAGE, filterParams).getContent()) assertThat(targetManagement.findByFilters(filterParams, PAGE).getContent())
.hasSize((int) targetManagement.countByFilters(filterParams)) .hasSize((int) targetManagement.countByFilters(filterParams))
.as("and filter query returns the same result") .as("and filter query returns the same result")
.hasSize(targetManagement.findByRsql(PAGE, query).getContent().size()) .hasSize(targetManagement.findByRsql(query, PAGE).getContent().size())
.as("has number of elements") .as("has number of elements")
.isEmpty(); .isEmpty();
} }
@@ -567,23 +567,23 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
targTagW.getName()); targTagW.getName());
final String query = "(name==*targ-c* or description==*targ-C*) and tag==" + targTagW.getName() final String query = "(name==*targ-c* or description==*targ-C*) and tag==" + targTagW.getName()
+ " and (assignedds.name==" + setA.getName() + " or installedds.name==" + setA.getName() + ")"; + " and (assignedds.name==" + setA.getName() + " or installedds.name==" + setA.getName() + ")";
assertThat(targetManagement.findByFilters(PAGE, filterParams).getContent()).as("has number of elements") assertThat(targetManagement.findByFilters(filterParams, PAGE).getContent()).as("has number of elements")
.hasSize(1).as("that number is also returned by count query") .hasSize(1).as("that number is also returned by count query")
.hasSize((int) targetManagement.countByFilters(filterParams)) .hasSize((int) targetManagement.countByFilters(filterParams))
.as("and contains the following elements").containsExactly(expected) .as("and contains the following elements").containsExactly(expected)
.as("and filter query returns the same result") .as("and filter query returns the same result")
.containsAll(targetManagement.findByRsql(PAGE, query).getContent()); .containsAll(targetManagement.findByRsql(query, PAGE).getContent());
} }
@Step @Step
private void verifyThat1TargetHasNameAndId(final String name, final String controllerId) { private void verifyThat1TargetHasNameAndId(final String name, final String controllerId) {
final FilterParams filterParamsByName = new FilterParams(null, null, name, null, Boolean.FALSE); final FilterParams filterParamsByName = new FilterParams(null, null, name, null, Boolean.FALSE);
assertThat(targetManagement.findByFilters(PAGE, filterParamsByName).getContent()).as("has number of elements") assertThat(targetManagement.findByFilters(filterParamsByName, PAGE).getContent()).as("has number of elements")
.hasSize(1).as("that number is also returned by count query") .hasSize(1).as("that number is also returned by count query")
.hasSize((int) targetManagement.countByFilters(filterParamsByName)); .hasSize((int) targetManagement.countByFilters(filterParamsByName));
final FilterParams filterParamsByControllerId = new FilterParams(null, null, controllerId, null, Boolean.FALSE); final FilterParams filterParamsByControllerId = new FilterParams(null, null, controllerId, null, Boolean.FALSE);
assertThat(targetManagement.findByFilters(PAGE, filterParamsByControllerId).getContent()) assertThat(targetManagement.findByFilters(filterParamsByControllerId, PAGE).getContent())
.as("has number of elements").hasSize(1).as("that number is also returned by count query") .as("has number of elements").hasSize(1).as("that number is also returned by count query")
.hasSize((int) targetManagement.countByFilters(filterParamsByControllerId)); .hasSize((int) targetManagement.countByFilters(filterParamsByControllerId));
} }
@@ -595,12 +595,12 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
targTagY.getName(), targTagW.getName()); targTagY.getName(), targTagW.getName());
final String query = "(name==*targ-B* or description==*targ-B*) and (tag==" + targTagY.getName() + " or tag==" final String query = "(name==*targ-B* or description==*targ-B*) and (tag==" + targTagY.getName() + " or tag=="
+ targTagW.getName() + ")"; + targTagW.getName() + ")";
assertThat(targetManagement.findByFilters(PAGE, filterParams).getContent()).as("has number of elements") assertThat(targetManagement.findByFilters(filterParams, PAGE).getContent()).as("has number of elements")
.hasSize(100).as("that number is also returned by count query") .hasSize(100).as("that number is also returned by count query")
.hasSize((int) targetManagement.countByFilters(filterParams)) .hasSize((int) targetManagement.countByFilters(filterParams))
.as("and contains the following elements").containsAll(expected) .as("and contains the following elements").containsAll(expected)
.as("and filter query returns the same result") .as("and filter query returns the same result")
.containsAll(targetManagement.findByRsql(PAGE, query).getContent()); .containsAll(targetManagement.findByRsql(query, PAGE).getContent());
} }
@SafeVarargs @SafeVarargs
@@ -614,18 +614,18 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
private void verifyThat200TargetsHaveTagD(final TargetTag targTagD, final List<Target> expected) { private void verifyThat200TargetsHaveTagD(final TargetTag targTagD, final List<Target> expected) {
final FilterParams filterParams = new FilterParams(null, null, null, null, Boolean.FALSE, targTagD.getName()); final FilterParams filterParams = new FilterParams(null, null, null, null, Boolean.FALSE, targTagD.getName());
final String query = "tag==" + targTagD.getName(); final String query = "tag==" + targTagD.getName();
assertThat(targetManagement.findByFilters(PAGE, filterParams).getContent()).as("Expected number of results is") assertThat(targetManagement.findByFilters(filterParams, PAGE).getContent()).as("Expected number of results is")
.hasSize(200).as("and is expected number of results is equal to ") .hasSize(200).as("and is expected number of results is equal to ")
.hasSize((int) targetManagement.countByFilters(filterParams)) .hasSize((int) targetManagement.countByFilters(filterParams))
.as("and contains the following elements").containsAll(expected) .as("and contains the following elements").containsAll(expected)
.as("and filter query returns the same result") .as("and filter query returns the same result")
.containsAll(targetManagement.findByRsql(PAGE, query).getContent()); .containsAll(targetManagement.findByRsql(query, PAGE).getContent());
} }
@Step @Step
private void verifyThatRepositoryContains500Targets() { private void verifyThatRepositoryContains500Targets() {
final FilterParams filterParams = new FilterParams(null, null, null, null, null); final FilterParams filterParams = new FilterParams(null, null, null, null, null);
assertThat(targetManagement.findByFilters(PAGE, filterParams).getContent()) assertThat(targetManagement.findByFilters(filterParams, PAGE).getContent())
.as("Overall we expect that many targets in the repository").hasSize(500) .as("Overall we expect that many targets in the repository").hasSize(500)
.as("which is also reflected by repository count").hasSize((int) targetManagement.count()) .as("which is also reflected by repository count").hasSize((int) targetManagement.count())
.as("which is also reflected by call without specification") .as("which is also reflected by call without specification")
@@ -636,7 +636,7 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
private void verifyThat1TargetHasTypeAndDSAssigned(final TargetType type, final DistributionSet set, private void verifyThat1TargetHasTypeAndDSAssigned(final TargetType type, final DistributionSet set,
final Target expected) { final Target expected) {
final FilterParams filterParams = new FilterParams(null, set.getId(), Boolean.FALSE, type.getId()); final FilterParams filterParams = new FilterParams(null, set.getId(), Boolean.FALSE, type.getId());
assertThat(targetManagement.findByFilters(PAGE, filterParams).getContent()).as("has number of elements") assertThat(targetManagement.findByFilters(filterParams, PAGE).getContent()).as("has number of elements")
.hasSize(1).as("that number is also returned by count query") .hasSize(1).as("that number is also returned by count query")
.hasSize((int) targetManagement.countByFilters(filterParams)) .hasSize((int) targetManagement.countByFilters(filterParams))
.as("and contains the following elements").containsExactly(expected); .as("and contains the following elements").containsExactly(expected);
@@ -646,7 +646,7 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
private void verifyThatTargetsHasNoTypeAndDSAssignedOrInstalled(final DistributionSet set, private void verifyThatTargetsHasNoTypeAndDSAssignedOrInstalled(final DistributionSet set,
final List<Target> expected) { final List<Target> expected) {
final FilterParams filterParams = new FilterParams(null, set.getId(), Boolean.TRUE, null); final FilterParams filterParams = new FilterParams(null, set.getId(), Boolean.TRUE, null);
assertThat(targetManagement.findByFilters(PAGE, filterParams).getContent()).as("has number of elements") assertThat(targetManagement.findByFilters(filterParams, PAGE).getContent()).as("has number of elements")
.hasSize(expected.size()).as("that number is also returned by count query") .hasSize(expected.size()).as("that number is also returned by count query")
.hasSize((int) targetManagement.countByFilters(filterParams)) .hasSize((int) targetManagement.countByFilters(filterParams))
.as("and contains the following elements").containsAll(expected); .as("and contains the following elements").containsAll(expected);
@@ -656,7 +656,7 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
private void verifyThat100TargetsContainsGivenTextAndHaveTypeAssigned(final TargetType targetType, private void verifyThat100TargetsContainsGivenTextAndHaveTypeAssigned(final TargetType targetType,
final List<Target> expected) { final List<Target> expected) {
final FilterParams filterParams = new FilterParams("%targ-E%", null, Boolean.FALSE, targetType.getId()); final FilterParams filterParams = new FilterParams("%targ-E%", null, Boolean.FALSE, targetType.getId());
final List<Target> filteredTargets = targetManagement.findByFilters(PAGE, filterParams).getContent(); final List<Target> filteredTargets = targetManagement.findByFilters(filterParams, PAGE).getContent();
assertThat(filteredTargets).as("has number of elements").hasSize(100) assertThat(filteredTargets).as("has number of elements").hasSize(100)
.as("that number is also returned by count query") .as("that number is also returned by count query")
.hasSize((int) targetManagement.countByFilters(filterParams)); .hasSize((int) targetManagement.countByFilters(filterParams));
@@ -670,7 +670,7 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
@Step @Step
private void verifyThat400TargetsContainsGivenTextAndHaveNoTypeAssigned(final List<Target> expected) { private void verifyThat400TargetsContainsGivenTextAndHaveNoTypeAssigned(final List<Target> expected) {
final FilterParams filterParams = new FilterParams("%targ-%", null, Boolean.TRUE, null); final FilterParams filterParams = new FilterParams("%targ-%", null, Boolean.TRUE, null);
assertThat(targetManagement.findByFilters(PAGE, filterParams).getContent()).as("has number of elements") assertThat(targetManagement.findByFilters(filterParams, PAGE).getContent()).as("has number of elements")
.hasSize(400).as("that number is also returned by count query") .hasSize(400).as("that number is also returned by count query")
.hasSize((int) targetManagement.countByFilters(filterParams)) .hasSize((int) targetManagement.countByFilters(filterParams))
.as("and contains the following elements").containsAll(expected); .as("and contains the following elements").containsAll(expected);

View File

@@ -134,7 +134,7 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
void findByTargetFilterQueryAndNonDSAndCompatibleAndUpdatablePermissionsCheck() { void findByTargetFilterQueryAndNonDSAndCompatibleAndUpdatablePermissionsCheck() {
assertPermissions(() -> targetManagement.findByTargetFilterQueryAndNonDSAndCompatibleAndUpdatable(PAGE, 1L, "controllerId==id"), assertPermissions(() -> targetManagement.findByTargetFilterQueryAndNonDSAndCompatibleAndUpdatable(1L, "controllerId==id", PAGE),
List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY)); List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY));
} }
@@ -149,9 +149,9 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest {
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
void findByTargetFilterQueryAndNotInRolloutAndCompatibleAndUpdatablePermissionsCheck() { void findByTargetFilterQueryAndNotInRolloutAndCompatibleAndUpdatablePermissionsCheck() {
assertPermissions( assertPermissions(
() -> targetManagement.findByTargetFilterQueryAndNotInRolloutAndCompatibleAndUpdatable(PAGE, List.of(1L), () -> targetManagement.findByTargetFilterQueryAndNotInRolloutAndCompatibleAndUpdatable(List.of(1L), "controllerId==id",
"controllerId==id", entityFactory.distributionSetType().create().build(), PAGE
entityFactory.distributionSetType().create().build()), List.of(SpPermission.READ_TARGET, SpPermission.READ_ROLLOUT)); ), List.of(SpPermission.READ_TARGET, SpPermission.READ_ROLLOUT));
} }
@Test @Test
@@ -171,7 +171,7 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
void findByFailedRolloutAndNotInRolloutGroupsPermissionsCheck() { void findByFailedRolloutAndNotInRolloutGroupsPermissionsCheck() {
assertPermissions(() -> targetManagement.findByFailedRolloutAndNotInRolloutGroups(PAGE, List.of(1L), "1"), assertPermissions(() -> targetManagement.findByFailedRolloutAndNotInRolloutGroups("1", List.of(1L), PAGE),
List.of(SpPermission.READ_TARGET, SpPermission.READ_ROLLOUT)); List.of(SpPermission.READ_TARGET, SpPermission.READ_ROLLOUT));
} }
@@ -185,20 +185,20 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
void findByInRolloutGroupWithoutActionPermissionsCheck() { void findByInRolloutGroupWithoutActionPermissionsCheck() {
assertPermissions(() -> targetManagement.findByInRolloutGroupWithoutAction(PAGE, 1L), List.of(SpPermission.READ_TARGET)); assertPermissions(() -> targetManagement.findByInRolloutGroupWithoutAction(1L, PAGE), List.of(SpPermission.READ_TARGET));
} }
@Test @Test
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
void findByAssignedDistributionSetPermissionsCheck() { void findByAssignedDistributionSetPermissionsCheck() {
assertPermissions(() -> targetManagement.findByAssignedDistributionSet(PAGE, 1L), assertPermissions(() -> targetManagement.findByAssignedDistributionSet(1L, PAGE),
List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY)); List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY));
} }
@Test @Test
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
void findByAssignedDistributionSetAndRsqlPermissionsCheck() { void findByAssignedDistributionSetAndRsqlPermissionsCheck() {
assertPermissions(() -> targetManagement.findByAssignedDistributionSetAndRsql(PAGE, 1L, "controllerId==id"), assertPermissions(() -> targetManagement.findByAssignedDistributionSetAndRsql(1L, "controllerId==id", PAGE),
List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY)); List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY));
} }
@@ -217,28 +217,28 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
void findByFiltersPermissionsCheck() { void findByFiltersPermissionsCheck() {
assertPermissions(() -> targetManagement.findByFilters(PAGE, new FilterParams(null, null, null, null, null, null)), assertPermissions(() -> targetManagement.findByFilters(new FilterParams(null, null, null, null, null, null), PAGE),
List.of(SpPermission.READ_TARGET)); List.of(SpPermission.READ_TARGET));
} }
@Test @Test
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
void findByInstalledDistributionSetPermissionsCheck() { void findByInstalledDistributionSetPermissionsCheck() {
assertPermissions(() -> targetManagement.findByInstalledDistributionSet(PAGE, 1L), assertPermissions(() -> targetManagement.findByInstalledDistributionSet(1L, PAGE),
List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY)); List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY));
} }
@Test @Test
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
void findByInstalledDistributionSetAndRsqlPermissionsCheck() { void findByInstalledDistributionSetAndRsqlPermissionsCheck() {
assertPermissions(() -> targetManagement.findByInstalledDistributionSetAndRsql(PAGE, 1L, "controllerId==id"), assertPermissions(() -> targetManagement.findByInstalledDistributionSetAndRsql(1L, "controllerId==id", PAGE),
List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY)); List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY));
} }
@Test @Test
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
void findByUpdateStatusPermissionsCheck() { void findByUpdateStatusPermissionsCheck() {
assertPermissions(() -> targetManagement.findByUpdateStatus(PAGE, TargetUpdateStatus.IN_SYNC), List.of(SpPermission.READ_TARGET)); assertPermissions(() -> targetManagement.findByUpdateStatus(TargetUpdateStatus.IN_SYNC, PAGE), List.of(SpPermission.READ_TARGET));
} }
@Test @Test
@@ -250,25 +250,25 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
void findByRsqlPermissionsCheck() { void findByRsqlPermissionsCheck() {
assertPermissions(() -> targetManagement.findByRsql(PAGE, "controllerId==id"), List.of(SpPermission.READ_TARGET)); assertPermissions(() -> targetManagement.findByRsql("controllerId==id", PAGE), List.of(SpPermission.READ_TARGET));
} }
@Test @Test
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
void findByTargetFilterQueryPermissionsCheck() { void findByTargetFilterQueryPermissionsCheck() {
assertPermissions(() -> targetManagement.findByTargetFilterQuery(PAGE, 1L), List.of(SpPermission.READ_TARGET)); assertPermissions(() -> targetManagement.findByTargetFilterQuery(1L, PAGE), List.of(SpPermission.READ_TARGET));
} }
@Test @Test
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
void findByTagPermissionsCheck() { void findByTagPermissionsCheck() {
assertPermissions(() -> targetManagement.findByTag(PAGE, 1L), List.of(SpPermission.READ_TARGET)); assertPermissions(() -> targetManagement.findByTag(1L, PAGE), List.of(SpPermission.READ_TARGET));
} }
@Test @Test
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
void findByRsqlAndTagPermissionsCheck() { void findByRsqlAndTagPermissionsCheck() {
assertPermissions(() -> targetManagement.findByRsqlAndTag(PAGE, "controllerId==id", 1L), List.of(SpPermission.READ_TARGET)); assertPermissions(() -> targetManagement.findByRsqlAndTag("controllerId==id", 1L, PAGE), List.of(SpPermission.READ_TARGET));
} }
@Test @Test

View File

@@ -113,8 +113,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
() -> targetManagement.assignTag(Collections.singletonList(target.getControllerId()), NOT_EXIST_IDL), "TargetTag"); () -> targetManagement.assignTag(Collections.singletonList(target.getControllerId()), NOT_EXIST_IDL), "TargetTag");
verifyThrownExceptionBy(() -> targetManagement.assignTag(Collections.singletonList(NOT_EXIST_ID), tag.getId()), "Target"); verifyThrownExceptionBy(() -> targetManagement.assignTag(Collections.singletonList(NOT_EXIST_ID), tag.getId()), "Target");
verifyThrownExceptionBy(() -> targetManagement.findByTag(PAGE, NOT_EXIST_IDL), "TargetTag"); verifyThrownExceptionBy(() -> targetManagement.findByTag(NOT_EXIST_IDL, PAGE), "TargetTag");
verifyThrownExceptionBy(() -> targetManagement.findByRsqlAndTag(PAGE, "name==*", NOT_EXIST_IDL), "TargetTag"); verifyThrownExceptionBy(() -> targetManagement.findByRsqlAndTag("name==*", NOT_EXIST_IDL, PAGE), "TargetTag");
verifyThrownExceptionBy(() -> targetManagement.countByAssignedDistributionSet(NOT_EXIST_IDL), "DistributionSet"); verifyThrownExceptionBy(() -> targetManagement.countByAssignedDistributionSet(NOT_EXIST_IDL), "DistributionSet");
verifyThrownExceptionBy(() -> targetManagement.countByInstalledDistributionSet(NOT_EXIST_IDL), "DistributionSet"); verifyThrownExceptionBy(() -> targetManagement.countByInstalledDistributionSet(NOT_EXIST_IDL), "DistributionSet");
@@ -128,16 +128,16 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
verifyThrownExceptionBy(() -> targetManagement.delete(Collections.singletonList(NOT_EXIST_IDL)), "Target"); verifyThrownExceptionBy(() -> targetManagement.delete(Collections.singletonList(NOT_EXIST_IDL)), "Target");
verifyThrownExceptionBy( verifyThrownExceptionBy(
() -> targetManagement.findByTargetFilterQueryAndNonDSAndCompatibleAndUpdatable(PAGE, NOT_EXIST_IDL, "name==*"), () -> targetManagement.findByTargetFilterQueryAndNonDSAndCompatibleAndUpdatable(NOT_EXIST_IDL, "name==*", PAGE),
"DistributionSet"); "DistributionSet");
verifyThrownExceptionBy(() -> targetManagement.findByInRolloutGroupWithoutAction(PAGE, NOT_EXIST_IDL), "RolloutGroup"); verifyThrownExceptionBy(() -> targetManagement.findByInRolloutGroupWithoutAction(NOT_EXIST_IDL, PAGE), "RolloutGroup");
verifyThrownExceptionBy(() -> targetManagement.findByAssignedDistributionSet(PAGE, NOT_EXIST_IDL), "DistributionSet"); verifyThrownExceptionBy(() -> targetManagement.findByAssignedDistributionSet(NOT_EXIST_IDL, PAGE), "DistributionSet");
verifyThrownExceptionBy( verifyThrownExceptionBy(
() -> targetManagement.findByAssignedDistributionSetAndRsql(PAGE, NOT_EXIST_IDL, "name==*"), "DistributionSet"); () -> targetManagement.findByAssignedDistributionSetAndRsql(NOT_EXIST_IDL, "name==*", PAGE), "DistributionSet");
verifyThrownExceptionBy(() -> targetManagement.findByInstalledDistributionSet(PAGE, NOT_EXIST_IDL), "DistributionSet"); verifyThrownExceptionBy(() -> targetManagement.findByInstalledDistributionSet(NOT_EXIST_IDL, PAGE), "DistributionSet");
verifyThrownExceptionBy( verifyThrownExceptionBy(
() -> targetManagement.findByInstalledDistributionSetAndRsql(PAGE, NOT_EXIST_IDL, "name==*"), "DistributionSet"); () -> targetManagement.findByInstalledDistributionSetAndRsql(NOT_EXIST_IDL, "name==*", PAGE), "DistributionSet");
verifyThrownExceptionBy(() -> targetManagement verifyThrownExceptionBy(() -> targetManagement
.assignTag(Collections.singletonList(target.getControllerId()), Long.parseLong(NOT_EXIST_ID)), "TargetTag"); .assignTag(Collections.singletonList(target.getControllerId()), Long.parseLong(NOT_EXIST_ID)), "TargetTag");
@@ -238,17 +238,17 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
final TargetTag findTargetTag = targetTagManagement.getByName("Tag1").orElseThrow(IllegalStateException::new); final TargetTag findTargetTag = targetTagManagement.getByName("Tag1").orElseThrow(IllegalStateException::new);
assertThat(assignedTargets).as("Assigned targets are wrong") assertThat(assignedTargets).as("Assigned targets are wrong")
.hasSize(targetManagement.findByTag(PAGE, targetTag.getId()).getNumberOfElements()); .hasSize(targetManagement.findByTag(targetTag.getId(), PAGE).getNumberOfElements());
final Target unAssignTarget = targetManagement.unassignTag(List.of("targetId123"), findTargetTag.getId()).get(0); final Target unAssignTarget = targetManagement.unassignTag(List.of("targetId123"), findTargetTag.getId()).get(0);
assertThat(unAssignTarget.getControllerId()).as("Controller id is wrong").isEqualTo("targetId123"); assertThat(unAssignTarget.getControllerId()).as("Controller id is wrong").isEqualTo("targetId123");
assertThat(getTargetTags(unAssignTarget.getControllerId())).as("Tag size is wrong") assertThat(getTargetTags(unAssignTarget.getControllerId())).as("Tag size is wrong")
.isEmpty(); .isEmpty();
targetTagManagement.getByName("Tag1").orElseThrow(NoSuchElementException::new); targetTagManagement.getByName("Tag1").orElseThrow(NoSuchElementException::new);
assertThat(targetManagement.findByTag(PAGE, targetTag.getId())).as("Assigned targets are wrong").hasSize(3); assertThat(targetManagement.findByTag(targetTag.getId(), PAGE)).as("Assigned targets are wrong").hasSize(3);
assertThat(targetManagement.findByRsqlAndTag(PAGE, "controllerId==targetId123", targetTag.getId())) assertThat(targetManagement.findByRsqlAndTag("controllerId==targetId123", targetTag.getId(), PAGE))
.as("Assigned targets are wrong").isEmpty(); .as("Assigned targets are wrong").isEmpty();
assertThat(targetManagement.findByRsqlAndTag(PAGE, "controllerId==targetId1234", targetTag.getId())) assertThat(targetManagement.findByRsqlAndTag("controllerId==targetId1234", targetTag.getId(), PAGE))
.as("Assigned targets are wrong").hasSize(1); .as("Assigned targets are wrong").hasSize(1);
} }
@@ -657,7 +657,7 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
final String[] tagNames = null; final String[] tagNames = null;
final List<Target> targetsListWithNoTag = targetManagement final List<Target> targetsListWithNoTag = targetManagement
.findByFilters(PAGE, new FilterParams(null, null, null, null, Boolean.TRUE, tagNames)).getContent(); .findByFilters(new FilterParams(null, null, null, null, Boolean.TRUE, tagNames), PAGE).getContent();
assertThat(targetManagement.count()).as("Total targets").isEqualTo(50L); assertThat(targetManagement.count()).as("Total targets").isEqualTo(50L);
assertThat(targetsListWithNoTag).as("Targets with no tag").hasSize(25); assertThat(targetsListWithNoTag).as("Targets with no tag").hasSize(25);
@@ -694,7 +694,7 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
testdataFactory.createTargets(25, "target-id-B", "first description"); testdataFactory.createTargets(25, "target-id-B", "first description");
final Slice<Target> foundTargets = targetManagement.findByRsql(PAGE, rsqlFilter); final Slice<Target> foundTargets = targetManagement.findByRsql(rsqlFilter, PAGE);
final long foundTargetsCount = targetManagement.countByRsql(rsqlFilter); final long foundTargetsCount = targetManagement.countByRsql(rsqlFilter);
assertThat(targetManagement.count()).as("Total targets").isEqualTo(50L); assertThat(targetManagement.count()).as("Total targets").isEqualTo(50L);
@@ -1159,7 +1159,7 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
final Slice<Target> matching = final Slice<Target> matching =
targetManagement.findByTargetFilterQueryAndNoOverridingActionsAndNotInRolloutAndCompatibleAndUpdatable( targetManagement.findByTargetFilterQueryAndNoOverridingActionsAndNotInRolloutAndCompatibleAndUpdatable(
PAGE, rollout.getId(), 10, Long.MAX_VALUE, "controllerid==dyn_action_filter_*", distributionSet.getType()); rollout.getId(), 10, Long.MAX_VALUE, "controllerid==dyn_action_filter_*", distributionSet.getType(), PAGE);
assertThat(matching.getNumberOfElements()).isEqualTo(expected.size()); assertThat(matching.getNumberOfElements()).isEqualTo(expected.size());
assertThat(matching.stream() assertThat(matching.stream()
@@ -1449,7 +1449,7 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
} }
private void validateFoundTargetsByRsql(final String rsqlFilter, final String... controllerIds) { private void validateFoundTargetsByRsql(final String rsqlFilter, final String... controllerIds) {
final Slice<Target> foundTargetsByMetadataAndControllerId = targetManagement.findByRsql(PAGE, rsqlFilter); final Slice<Target> foundTargetsByMetadataAndControllerId = targetManagement.findByRsql(rsqlFilter, PAGE);
final long foundTargetsByMetadataAndControllerIdCount = targetManagement.countByRsql(rsqlFilter); final long foundTargetsByMetadataAndControllerIdCount = targetManagement.countByRsql(rsqlFilter);
assertThat(foundTargetsByMetadataAndControllerId.getNumberOfElements()) assertThat(foundTargetsByMetadataAndControllerId.getNumberOfElements())

View File

@@ -61,7 +61,7 @@ class TargetTagManagementSecurityTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
void findByRsqlPermissionsCheck() { void findByRsqlPermissionsCheck() {
assertPermissions(() -> targetTagManagement.findByRsql(PAGE, "name==tag"), List.of(SpPermission.READ_TARGET)); assertPermissions(() -> targetTagManagement.findByRsql("name==tag", PAGE), List.of(SpPermission.READ_TARGET));
} }
@Test @Test

View File

@@ -129,7 +129,7 @@ class TargetTagManagementTest extends AbstractJpaIntegrationTest {
.containsAll( .containsAll(
targetManagement.getByControllerID(groupA.stream().map(Target::getControllerId).toList())) targetManagement.getByControllerID(groupA.stream().map(Target::getControllerId).toList()))
.size().isEqualTo(20); .size().isEqualTo(20);
assertThat(targetManagement.findByTag(Pageable.unpaged(), tag.getId()).getContent().stream().map(Target::getControllerId).sorted() assertThat(targetManagement.findByTag(tag.getId(), Pageable.unpaged()).getContent().stream().map(Target::getControllerId).sorted()
.toList()) .toList())
.isEqualTo(groupA.stream().map(Target::getControllerId).sorted().toList()); .isEqualTo(groupA.stream().map(Target::getControllerId).sorted().toList());
@@ -140,7 +140,7 @@ class TargetTagManagementTest extends AbstractJpaIntegrationTest {
.containsAll( .containsAll(
targetManagement.getByControllerID(groupAB.stream().map(Target::getControllerId).toList())) targetManagement.getByControllerID(groupAB.stream().map(Target::getControllerId).toList()))
.size().isEqualTo(40); .size().isEqualTo(40);
assertThat(targetManagement.findByTag(Pageable.unpaged(), tag.getId()).getContent().stream().map(Target::getControllerId).sorted() assertThat(targetManagement.findByTag(tag.getId(), Pageable.unpaged()).getContent().stream().map(Target::getControllerId).sorted()
.toList()) .toList())
.isEqualTo(groupAB.stream().map(Target::getControllerId).sorted().toList()); .isEqualTo(groupAB.stream().map(Target::getControllerId).sorted().toList());
@@ -149,7 +149,7 @@ class TargetTagManagementTest extends AbstractJpaIntegrationTest {
assertThat(result) assertThat(result)
.containsAll(targetManagement.getByControllerID(groupAB.stream().map(Target::getControllerId).toList())) .containsAll(targetManagement.getByControllerID(groupAB.stream().map(Target::getControllerId).toList()))
.size().isEqualTo(40); .size().isEqualTo(40);
assertThat(targetManagement.findByTag(Pageable.unpaged(), tag.getId()).getContent()).isEmpty(); assertThat(targetManagement.findByTag(tag.getId(), Pageable.unpaged()).getContent()).isEmpty();
} }
@Test @Test

View File

@@ -81,13 +81,13 @@ class TargetTypeManagementSecurityTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
void findByRsqlPermissionsCheck() { void findByRsqlPermissionsCheck() {
assertPermissions(() -> targetTypeManagement.findByRsql(PAGE, "name==tag"), List.of(SpPermission.READ_TARGET)); assertPermissions(() -> targetTypeManagement.findByRsql("name==tag", PAGE), List.of(SpPermission.READ_TARGET));
} }
@Test @Test
@Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.")
void findByNamePermissionsCheck() { void findByNamePermissionsCheck() {
assertPermissions(() -> targetTypeManagement.findByName(PAGE, "name"), List.of(SpPermission.READ_TARGET)); assertPermissions(() -> targetTypeManagement.findByName("name", PAGE), List.of(SpPermission.READ_TARGET));
} }
@Test @Test

View File

@@ -107,10 +107,10 @@ class RSQLActionFieldsTest extends AbstractJpaIntegrationTest {
return newAction; return newAction;
} }
private void assertRSQLQuery(final String rsqlParam, final long expectedEntities) { private void assertRSQLQuery(final String rsql, final long expectedEntities) {
final Slice<Action> findEntity = deploymentManagement.findActionsByTarget(rsqlParam, target.getControllerId(), final Slice<Action> findEntity = deploymentManagement.findActionsByTarget(rsql, target.getControllerId(),
PageRequest.of(0, 100)); PageRequest.of(0, 100));
final long countAllEntities = deploymentManagement.countActionsByTarget(rsqlParam, target.getControllerId()); final long countAllEntities = deploymentManagement.countActionsByTarget(rsql, target.getControllerId());
assertThat(findEntity).isNotNull(); assertThat(findEntity).isNotNull();
assertThat(findEntity.getContent()).hasSize((int)expectedEntities); assertThat(findEntity.getContent()).hasSize((int)expectedEntities);
assertThat(countAllEntities).isEqualTo(expectedEntities); assertThat(countAllEntities).isEqualTo(expectedEntities);

View File

@@ -84,8 +84,8 @@ class RSQLRolloutGroupFieldTest extends AbstractJpaIntegrationTest {
assertRSQLQuery(RolloutGroupFields.DESCRIPTION.name() + "=out=(group-1,notexist)", 3); assertRSQLQuery(RolloutGroupFields.DESCRIPTION.name() + "=out=(group-1,notexist)", 3);
} }
private void assertRSQLQuery(final String rsqlParam, final long expectedTargets) { private void assertRSQLQuery(final String rsql, final long expectedTargets) {
final Page<RolloutGroup> findTargetPage = rolloutGroupManagement.findByRolloutAndRsql(rollout.getId(), rsqlParam, PageRequest.of(0, 100) final Page<RolloutGroup> findTargetPage = rolloutGroupManagement.findByRolloutAndRsql(rollout.getId(), rsql, PageRequest.of(0, 100)
); );
final long countTargetsAll = findTargetPage.getTotalElements(); final long countTargetsAll = findTargetPage.getTotalElements();
assertThat(findTargetPage).isNotNull(); assertThat(findTargetPage).isNotNull();

View File

@@ -149,10 +149,10 @@ class RSQLSoftwareModuleFieldTest extends AbstractJpaIntegrationTest {
} }
private void assertRSQLQuery(final String rsqlParam, final long expectedEntity) { private void assertRSQLQuery(final String rsql, final long expectedEntity) {
final Page<SoftwareModule> find = softwareModuleManagement.findByRsql(rsqlParam, PageRequest.of(0, 100)); final Page<SoftwareModule> find = softwareModuleManagement.findByRsql(rsql, PageRequest.of(0, 100));
final long countAll = find.getTotalElements(); final long countAll = find.getTotalElements();
assertThat(find).isNotNull(); assertThat(find).isNotNull();
assertThat(countAll).isEqualTo(expectedEntity); assertThat(countAll).isEqualTo(expectedEntity);
} }
} }

View File

@@ -77,11 +77,10 @@ class RSQLSoftwareModuleTypeFieldsTest extends AbstractJpaIntegrationTest {
assertRSQLQuery(SoftwareModuleTypeFields.MAXASSIGNMENTS.name() + "!=1", 1); assertRSQLQuery(SoftwareModuleTypeFields.MAXASSIGNMENTS.name() + "!=1", 1);
} }
private void assertRSQLQuery(final String rsqlParam, final long excpectedEntity) { private void assertRSQLQuery(final String rsql, final long expectedEntity) {
final Page<SoftwareModuleType> find = softwareModuleTypeManagement.findByRsql(rsqlParam, PageRequest.of(0, 100) final Page<SoftwareModuleType> find = softwareModuleTypeManagement.findByRsql(rsql, PageRequest.of(0, 100));
);
final long countAll = find.getTotalElements(); final long countAll = find.getTotalElements();
assertThat(find).isNotNull(); assertThat(find).isNotNull();
assertThat(countAll).isEqualTo(excpectedEntity); assertThat(countAll).isEqualTo(expectedEntity);
} }
} }

View File

@@ -117,20 +117,17 @@ class RSQLTagFieldsTest extends AbstractJpaIntegrationTest {
assertRSQLQueryDistributionSet(TagFields.COLOUR.name() + "=out=(red,notexist)", 2); assertRSQLQueryDistributionSet(TagFields.COLOUR.name() + "=out=(red,notexist)", 2);
} }
private void assertRSQLQueryDistributionSet(final String rsqlParam, final long expectedEntities) { private void assertRSQLQueryDistributionSet(final String rsql, final long expectedEntities) {
final Page<DistributionSetTag> findEnitity = distributionSetTagManagement.findByRsql(rsql, PageRequest.of(0, 100));
final Page<DistributionSetTag> findEnitity = distributionSetTagManagement.findByRsql(rsqlParam, PageRequest.of(0, 100)
);
final long countAllEntities = findEnitity.getTotalElements(); final long countAllEntities = findEnitity.getTotalElements();
assertThat(findEnitity).isNotNull(); assertThat(findEnitity).isNotNull();
assertThat(countAllEntities).isEqualTo(expectedEntities); assertThat(countAllEntities).isEqualTo(expectedEntities);
} }
private void assertRSQLQueryTarget(final String rsqlParam, final long expectedEntities) { private void assertRSQLQueryTarget(final String rsql, final long expectedEntities) {
final Page<TargetTag> findEntity = targetTagManagement.findByRsql(rsql, PageRequest.of(0, 100));
final Page<TargetTag> findEnitity = targetTagManagement.findByRsql(PageRequest.of(0, 100), rsqlParam); final long countAllEntities = findEntity.getTotalElements();
final long countAllEntities = findEnitity.getTotalElements(); assertThat(findEntity).isNotNull();
assertThat(findEnitity).isNotNull();
assertThat(countAllEntities).isEqualTo(expectedEntities); assertThat(countAllEntities).isEqualTo(expectedEntities);
} }
} }

View File

@@ -413,16 +413,16 @@ class RSQLTargetFieldTest extends AbstractJpaIntegrationTest {
.isThrownBy(() -> assertRSQLQuery("targettype.description==Description", 0)); .isThrownBy(() -> assertRSQLQuery("targettype.description==Description", 0));
} }
private void assertRSQLQuery(final String rsqlParam, final long expectedTargets) { private void assertRSQLQuery(final String rsql, final long expectedTargets) {
final Slice<Target> findTargetPage = targetManagement.findByRsql(PAGE, rsqlParam); final Slice<Target> findTargetPage = targetManagement.findByRsql(rsql, PAGE);
assertThat(findTargetPage).isNotNull(); assertThat(findTargetPage).isNotNull();
assertThat(findTargetPage.getNumberOfElements()).isEqualTo(expectedTargets); assertThat(findTargetPage.getNumberOfElements()).isEqualTo(expectedTargets);
assertThat(targetManagement.countByRsql(rsqlParam)).isEqualTo(expectedTargets); assertThat(targetManagement.countByRsql(rsql)).isEqualTo(expectedTargets);
} }
private void assertRSQLQueryThrowsException(final String rsqlParam) { private void assertRSQLQueryThrowsException(final String rsql) {
assertThatExceptionOfType(RSQLParameterUnsupportedFieldException.class) assertThatExceptionOfType(RSQLParameterUnsupportedFieldException.class)
.isThrownBy(() -> RSQLUtility.validateRsqlFor( .isThrownBy(() -> RSQLUtility.validateRsqlFor(
rsqlParam, TargetFields.class, JpaTarget.class, virtualPropertyReplacer, entityManager)); rsql, TargetFields.class, JpaTarget.class, virtualPropertyReplacer, entityManager));
} }
} }

View File

@@ -109,10 +109,9 @@ class RSQLTargetFilterQueryFieldsTest extends AbstractJpaIntegrationTest {
+ TestdataFactory.DEFAULT_VERSION + ",notexist)", 1); + TestdataFactory.DEFAULT_VERSION + ",notexist)", 1);
} }
private void assertRSQLQuery(final String rsqlParam, final long expectedFilterQueriesSize) { private void assertRSQLQuery(final String rsql, final long expectedFilterQueriesSize) {
final Page<TargetFilterQuery> findTargetFilterQueryPage = targetFilterQueryManagement.findByRsql(PAGE, final Page<TargetFilterQuery> findTargetFilterQueryPage = targetFilterQueryManagement.findByRsql(rsql, PAGE);
rsqlParam);
assertThat(findTargetFilterQueryPage).isNotNull(); assertThat(findTargetFilterQueryPage).isNotNull();
assertThat(findTargetFilterQueryPage.getTotalElements()).isEqualTo(expectedFilterQueriesSize); assertThat(findTargetFilterQueryPage.getTotalElements()).isEqualTo(expectedFilterQueriesSize);
} }
} }

View File

@@ -191,6 +191,6 @@ class MultiTenancyEntityTest extends AbstractJpaIntegrationTest {
} }
private Slice<DistributionSet> findDistributionSetForTenant(final String tenant) throws Exception { private Slice<DistributionSet> findDistributionSetForTenant(final String tenant) throws Exception {
return runAsTenant(tenant, () -> distributionSetManagement.findByCompleted(PAGE, true)); return runAsTenant(tenant, () -> distributionSetManagement.findByCompleted(true, PAGE));
} }
} }

View File

@@ -425,7 +425,7 @@ public abstract class AbstractIntegrationTest {
final DistributionSet ds = testdataFactory.createDistributionSet(distributionSet, isRequiredMigrationStep); final DistributionSet ds = testdataFactory.createDistributionSet(distributionSet, isRequiredMigrationStep);
Target savedTarget = testdataFactory.createTarget(controllerId); Target savedTarget = testdataFactory.createTarget(controllerId);
savedTarget = getFirstAssignedTarget(assignDistributionSet(ds.getId(), savedTarget.getControllerId(), ActionType.FORCED)); savedTarget = getFirstAssignedTarget(assignDistributionSet(ds.getId(), savedTarget.getControllerId(), ActionType.FORCED));
final Action savedAction = deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId()).getContent().get(0); final Action savedAction = deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE).getContent().get(0);
if (savedAction.getStatus() == Action.Status.WAIT_FOR_CONFIRMATION) { if (savedAction.getStatus() == Action.Status.WAIT_FOR_CONFIRMATION) {
confirmationManagement.confirmAction(savedAction.getId(), null, null); confirmationManagement.confirmAction(savedAction.getId(), null, null);