diff --git a/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiCancelActionTest.java b/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiCancelActionTest.java index 14818d0f6..691d152b5 100644 --- a/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiCancelActionTest.java +++ b/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiCancelActionTest.java @@ -173,13 +173,13 @@ class DdiCancelActionTest extends AbstractDDiApiIntegrationTest { // Retrieved is reported List activeActionsByTarget = deploymentManagement - .findActiveActionsByTarget(PAGE, savedTarget.getControllerId()).getContent(); + .findActiveActionsByTarget(savedTarget.getControllerId(), PAGE).getContent(); assertThat(activeActionsByTarget).hasSize(1); assertThat(activeActionsByTarget.get(0).getStatus()).isEqualTo(Status.RUNNING); final Action cancelAction = deploymentManagement.cancelAction(actionId); - activeActionsByTarget = deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId()) + activeActionsByTarget = deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE) .getContent(); // the canceled action should still be active! @@ -219,7 +219,7 @@ class DdiCancelActionTest extends AbstractDDiApiIntegrationTest { .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); - activeActionsByTarget = deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId()) + activeActionsByTarget = deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE) .getContent(); assertThat(activeActionsByTarget).isEmpty(); final Action canceledAction = deploymentManagement.findAction(cancelAction.getId()).get(); @@ -279,7 +279,7 @@ class DdiCancelActionTest extends AbstractDDiApiIntegrationTest { final Action cancelAction = deploymentManagement.cancelAction(actionId); 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/" + cancelAction.getId() + "/feedback", tenantAware.getCurrentTenant()) .content(getJsonProceedingCancelActionFeedback()).contentType(MediaType.APPLICATION_JSON) @@ -287,7 +287,7 @@ class DdiCancelActionTest extends AbstractDDiApiIntegrationTest { .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); - assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(1); + assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE)).hasSize(1); assertThat(countActionStatusAll()).isEqualTo(3); mvc.perform(post("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/cancelAction/" @@ -296,7 +296,7 @@ class DdiCancelActionTest extends AbstractDDiApiIntegrationTest { .accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); - assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(1); + assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE)).hasSize(1); assertThat(countActionStatusAll()).isEqualTo(4); mvc.perform(post("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/cancelAction/" @@ -306,10 +306,10 @@ class DdiCancelActionTest extends AbstractDDiApiIntegrationTest { .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); 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 - 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/" + cancelAction.getId() + "/feedback", tenantAware.getCurrentTenant()) .content(getJsonCanceledCancelActionFeedback()).contentType(MediaType.APPLICATION_JSON) @@ -317,13 +317,13 @@ class DdiCancelActionTest extends AbstractDDiApiIntegrationTest { .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); 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 // it // with finished or // 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/" + cancelAction.getId() + "/feedback", tenantAware.getCurrentTenant()) .content(getJsonRejectedCancelActionFeedback()).contentType(MediaType.APPLICATION_JSON) @@ -331,7 +331,7 @@ class DdiCancelActionTest extends AbstractDDiApiIntegrationTest { .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); 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 mvc.perform(post("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/deploymentBase/" @@ -341,7 +341,7 @@ class DdiCancelActionTest extends AbstractDDiApiIntegrationTest { .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); assertThat(countActionStatusAll()).isEqualTo(8); - assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).isEmpty(); + assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE)).isEmpty(); } @Test @@ -366,12 +366,12 @@ class DdiCancelActionTest extends AbstractDDiApiIntegrationTest { assertThat(countActionStatusAll()).isEqualTo(3); // 3 update actions, 0 cancel actions - assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(3); - assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(3); + assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE)).hasSize(3); + assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE)).hasSize(3); final Action cancelAction = deploymentManagement.cancelAction(actionId); 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); mvc.perform(get("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/cancelAction/" + cancelAction.getId(), tenantAware.getCurrentTenant()).accept(MediaType.APPLICATION_JSON)) @@ -402,7 +402,7 @@ class DdiCancelActionTest extends AbstractDDiApiIntegrationTest { assertThat(countActionStatusAll()).isEqualTo(7); // 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); mvc.perform(get("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/cancelAction/" + cancelAction2.getId(), tenantAware.getCurrentTenant()).accept(MediaType.APPLICATION_JSON)) @@ -442,12 +442,12 @@ class DdiCancelActionTest extends AbstractDDiApiIntegrationTest { assertThat(countActionStatusAll()).isEqualTo(10); // 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); // 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.getAssignedDistributionSet(TestdataFactory.DEFAULT_CONTROLLER_ID).get()) .isEqualTo(ds3); @@ -471,7 +471,7 @@ class DdiCancelActionTest extends AbstractDDiApiIntegrationTest { assertThat(countActionStatusAll()).isEqualTo(13); // final status - assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).isEmpty(); + assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE)).isEmpty(); assertThat(deploymentManagement.countActionsByTarget(savedTarget.getControllerId())).isEqualTo(3); } diff --git a/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiConfirmationBaseTest.java b/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiConfirmationBaseTest.java index cb0f53a75..ad106f85f 100644 --- a/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiConfirmationBaseTest.java +++ b/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiConfirmationBaseTest.java @@ -82,7 +82,7 @@ class DdiConfirmationBaseTest extends AbstractDDiApiIntegrationTest { nextBytes(ARTIFACT_SIZE), getOsModule(ds), "test1.signature", ARTIFACT_SIZE); 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 targetsAssignedToDs = assignDistributionSet( ds.getId(), savedTarget.getControllerId(), Action.ActionType.FORCED).getAssignedEntity().stream() @@ -90,18 +90,18 @@ class DdiConfirmationBaseTest extends AbstractDDiApiIntegrationTest { .toList(); 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); 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); - 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(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(2); + assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE)).hasSize(2); // Run test final long current = System.currentTimeMillis(); @@ -129,7 +129,7 @@ class DdiConfirmationBaseTest extends AbstractDDiApiIntegrationTest { // Retrieved is reported final Iterable 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) .allMatch(status -> status.getStatus() == Action.Status.WAIT_FOR_CONFIRMATION); } @@ -146,7 +146,7 @@ class DdiConfirmationBaseTest extends AbstractDDiApiIntegrationTest { 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 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())); 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)) .andDo(MockMvcResultPrinter.print()) @@ -190,7 +190,7 @@ class DdiConfirmationBaseTest extends AbstractDDiApiIntegrationTest { 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)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) @@ -219,7 +219,7 @@ class DdiConfirmationBaseTest extends AbstractDDiApiIntegrationTest { 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 disableConfirmationFlow(); @@ -268,7 +268,7 @@ class DdiConfirmationBaseTest extends AbstractDDiApiIntegrationTest { String controllerId = savedTarget.getControllerId(); - final Action savedAction = deploymentManagement.findActiveActionsByTarget(PAGE, controllerId).getContent() + final Action savedAction = deploymentManagement.findActiveActionsByTarget(controllerId, PAGE).getContent() .get(0); sendConfirmationFeedback( @@ -286,7 +286,7 @@ class DdiConfirmationBaseTest extends AbstractDDiApiIntegrationTest { final String controllerId = testdataFactory.createTarget("989").getControllerId(); 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( "/%s/controller/v1/%s/confirmationBase/%d", @@ -387,7 +387,7 @@ class DdiConfirmationBaseTest extends AbstractDDiApiIntegrationTest { Target savedTarget = testdataFactory.createTarget("989"); savedTarget = getFirstAssignedTarget(assignDistributionSet(ds.getId(), 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( savedTarget, savedAction, DdiConfirmationFeedback.Confirmation.DENIED, 10, "Action denied message.") @@ -432,7 +432,7 @@ class DdiConfirmationBaseTest extends AbstractDDiApiIntegrationTest { 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 Integer confirmedCode = 10; sendConfirmationFeedback( diff --git a/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiDeploymentBaseTest.java b/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiDeploymentBaseTest.java index 58a6182e6..a0be82d09 100644 --- a/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiDeploymentBaseTest.java +++ b/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiDeploymentBaseTest.java @@ -92,7 +92,7 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest { testdataFactory.createArtifacts(softwareModuleId); 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 performGet(DEPLOYMENT_BASE, MediaType.parseMediaType(DdiRestConstants.MEDIA_TYPE_CBOR), status().isOk(), @@ -153,18 +153,18 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest { .toList(); 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); 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); - 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(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(2); + assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE)).hasSize(2); // Run test final long current = System.currentTimeMillis(); @@ -187,7 +187,7 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest { // Retrieved is reported final Iterable 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); final ActionStatus actionStatusMessage = actionStatusMessages.iterator().next(); assertThat(actionStatusMessage.getStatus()).isEqualTo(Status.RETRIEVED); @@ -253,17 +253,17 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest { final List saved = assignDistributionSet(ds.getId(), savedTarget.getControllerId(), ActionType.SOFT) .getAssignedEntity().stream().map(Action::getTarget).toList(); 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); 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); - 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(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(2); + assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE)).hasSize(2); // Run test final long current = System.currentTimeMillis(); @@ -286,7 +286,7 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest { // Retrieved is reported final List 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); final ActionStatus actionStatusMessage = actionStatusMessages.iterator().next(); assertThat(actionStatusMessage.getStatus()).isEqualTo(Status.RETRIEVED); @@ -308,17 +308,17 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest { final List saved = assignDistributionSet(ds.getId(), savedTarget.getControllerId(), ActionType.TIMEFORCED).getAssignedEntity().stream().map(Action::getTarget).toList(); 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); assignDistributionSet(ds2, saved).getAssignedEntity(); - assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(2); + assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE)).hasSize(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(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(2); + assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE)).hasSize(2); // Run test final long current = System.currentTimeMillis(); @@ -344,7 +344,7 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest { // Retrieved is reported final Iterable 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); final ActionStatus actionStatusMessage = actionStatusMessages.iterator().next(); assertThat(actionStatusMessage.getStatus()).isEqualTo(Status.RETRIEVED); @@ -372,17 +372,17 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest { .map(Action::getTarget) .toList(); 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); 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); - 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(deploymentManagement.findActiveActionsByTarget(PAGE, savedTarget.getControllerId())).hasSize(2); + assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE)).hasSize(2); // Run test @@ -405,7 +405,7 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest { // Retrieved is reported final List 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); final ActionStatus actionStatusMessage = actionStatusMessages.iterator().next(); assertThat(actionStatusMessage.getStatus()).isEqualTo(Status.RETRIEVED); @@ -512,7 +512,7 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest { implicitLock(ds3); 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 postDeploymentFeedback(DEFAULT_CONTROLLER_ID, actionId1, getJsonClosedDeploymentActionFeedback(), status().isOk()); @@ -557,15 +557,15 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest { // redo ds = distributionSetManagement.getWithDetails(ds.getId()).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()); findTargetAndAssertUpdateStatus(Optional.of(ds), TargetUpdateStatus.IN_SYNC, 0, Optional.of(ds)); 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(deploymentManagement.findActionStatusByAction(PAGE, action.getId()).getContent()) + assertThat(deploymentManagement.findActionStatusByAction(action.getId(), PAGE).getContent()) .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)); } @@ -605,8 +605,8 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest { assertActionStatusCount(10, 7, 1, 1, 1); assertTargetCountByStatus(0, 0, 1); - assertThat(targetManagement.findByInstalledDistributionSet(PAGE, ds.getId())).hasSize(1); - assertThat(targetManagement.findByAssignedDistributionSet(PAGE, ds.getId())).hasSize(1); + assertThat(targetManagement.findByInstalledDistributionSet(ds.getId(), PAGE)).hasSize(1); + assertThat(targetManagement.findByAssignedDistributionSet(ds.getId(), PAGE)).hasSize(1); } @Test @@ -626,7 +626,7 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest { assignDistributionSet(savedSet, Collections.singletonList(savedTarget)).getAssignedEntity().iterator().next(); 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 postDeploymentFeedback("4713", updateAction.getId(), getJsonActionFeedback(DdiStatus.ExecutionStatus.PROCEEDING, @@ -740,7 +740,7 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest { 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(findActionStatusAll(PAGE).getContent()) .haveAtLeast(minActionStatusCountInPage, new ActionStatusCondition(Status.RUNNING)); @@ -748,7 +748,7 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest { private Target createTargetAndAssertNoActiveActions() { 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(countActionStatusAll()).isZero(); return savedTarget; @@ -767,15 +767,15 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest { final Optional installedDs) { final Target myT = targetManagement.getByControllerID(DdiDeploymentBaseTest.DEFAULT_CONTROLLER_ID).get(); 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.getInstalledDistributionSet(myT.getControllerId())).isEqualTo(installedDs); } 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(PageRequest.of(0, 10), TargetUpdateStatus.ERROR)).hasSize(error); - assertThat(targetManagement.findByUpdateStatus(PageRequest.of(0, 10), TargetUpdateStatus.IN_SYNC)).hasSize(inSync); + assertThat(targetManagement.findByUpdateStatus(TargetUpdateStatus.PENDING, PageRequest.of(0, 10))).hasSize(pending); + assertThat(targetManagement.findByUpdateStatus(TargetUpdateStatus.ERROR, PageRequest.of(0, 10))).hasSize(error); + 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) { @@ -789,7 +789,7 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest { private void assertStatusAndActiveActionsCount(final TargetUpdateStatus status, final int activeActions) { final Target target = targetManagement.getByControllerID(DdiDeploymentBaseTest.DEFAULT_CONTROLLER_ID).get(); assertThat(target.getUpdateStatus()).isEqualTo(status); - assertThat(deploymentManagement.findActiveActionsByTarget(PAGE, target.getControllerId())).hasSize(activeActions); + assertThat(deploymentManagement.findActiveActionsByTarget(target.getControllerId(), PAGE)).hasSize(activeActions); } private Page findActionStatusAll(final Pageable pageable) { diff --git a/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiInstalledBaseTest.java b/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiInstalledBaseTest.java index 460790538..894d20e23 100644 --- a/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiInstalledBaseTest.java +++ b/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiInstalledBaseTest.java @@ -452,7 +452,7 @@ class DdiInstalledBaseTest extends AbstractDDiApiIntegrationTest { // Action is still finished after calling installedBase final Iterable 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); final ActionStatus actionStatusMessage = actionStatusMessages.iterator().next(); assertThat(actionStatusMessage.getStatus()).isEqualTo(Action.Status.FINISHED); @@ -538,7 +538,7 @@ class DdiInstalledBaseTest extends AbstractDDiApiIntegrationTest { final DistributionSet ds = testdataFactory.createDistributionSet(""); Target savedTarget = testdataFactory.createTarget("911"); 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(), getJsonActionFeedback(DdiStatus.ExecutionStatus.SCHEDULED, DdiResult.FinalResult.NONE, @@ -633,7 +633,7 @@ class DdiInstalledBaseTest extends AbstractDDiApiIntegrationTest { private Target createTargetAndAssertNoActiveActions() { 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(actionStatusRepository.count()).isZero(); return savedTarget; diff --git a/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiRootControllerTest.java b/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiRootControllerTest.java index 8865bce2b..2abaddbcd 100644 --- a/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiRootControllerTest.java +++ b/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiRootControllerTest.java @@ -241,7 +241,7 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest { assignDistributionSet(ds.getId(), controllerId); - final Action updateAction = deploymentManagement.findActiveActionsByTarget(PAGE, target.getControllerId()) + final Action updateAction = deploymentManagement.findActiveActionsByTarget(target.getControllerId(), PAGE) .getContent().get(0); final String etagWithFirstUpdate = mvc .perform(get(CONTROLLER_BASE, tenantAware.getCurrentTenant(), controllerId) @@ -287,7 +287,7 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest { 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) .header("If-None-Match", etagAfterInstallation).accept(MediaType.APPLICATION_JSON) @@ -398,7 +398,7 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest { final DistributionSet ds = testdataFactory.createDistributionSet(""); Target savedTarget = testdataFactory.createTarget("911"); 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); sendDeploymentActionFeedback(savedTarget, savedAction, "proceeding", null) .andDo(MockMvcResultPrinter.print()) @@ -460,7 +460,7 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest { final DistributionSet ds = testdataFactory.createDistributionSet(""); Target savedTarget = testdataFactory.createTarget("911"); 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); sendDeploymentActionFeedback(savedTarget, savedAction, "scheduled", null, TARGET_SCHEDULED_INSTALLATION_MSG) @@ -504,7 +504,7 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest { final DistributionSet ds = testdataFactory.createDistributionSet(""); Target savedTarget = testdataFactory.createTarget("911"); 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) .andDo(MockMvcResultPrinter.print()) @@ -548,7 +548,7 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest { final DistributionSet ds = testdataFactory.createDistributionSet(""); Target savedTarget = testdataFactory.createTarget("911"); 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); 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")) .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()) .accept(MediaType.APPLICATION_JSON)) @@ -658,7 +658,7 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest { mvc.perform(get(CONTROLLER_BASE, "default-tenant", "1911")) .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()) .accept(MediaType.APPLICATION_JSON)) @@ -695,7 +695,7 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest { @Step private void assertAttributesUpdateNotRequestedAfterFailedDeployment(Target target, final DistributionSet ds) throws Exception { 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") .andExpect(status().isOk()); assertThatAttributesUpdateIsNotRequested(target.getControllerId()); @@ -704,7 +704,7 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest { @Step private void assertAttributesUpdateRequestedAfterSuccessfulDeployment(Target target, final DistributionSet ds) throws Exception { 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) .andExpect(status().isOk()); assertThatAttributesUpdateIsRequested(target.getControllerId()); diff --git a/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DosFilterTest.java b/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DosFilterTest.java index 5ae9a8ce9..2ae56106f 100644 --- a/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DosFilterTest.java +++ b/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DosFilterTest.java @@ -163,9 +163,9 @@ class DosFilterTest extends AbstractDDiApiIntegrationTest { final List toAssign = Collections.singletonList(target); 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(); } diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherService.java b/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherService.java index 8a34242ed..963fe86b3 100644 --- a/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherService.java +++ b/hawkbit-dmf/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherService.java @@ -593,7 +593,7 @@ public class AmqpMessageDispatcherService extends BaseAmqpService { private List getSoftwareModuleMetadata(final SoftwareModule module) { 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( diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpMessageHandlerServiceIntegrationTest.java b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpMessageHandlerServiceIntegrationTest.java index dd0583794..3a7e4dd14 100644 --- a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpMessageHandlerServiceIntegrationTest.java +++ b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpMessageHandlerServiceIntegrationTest.java @@ -1146,12 +1146,12 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr try { SecurityContextSwitch.runAsPrivileged(() -> { final List actionStatusList = deploymentManagement - .findActionStatusByAction(PAGE, actionId).getContent(); + .findActionStatusByAction(actionId, PAGE).getContent(); // Check correlation ID final List messagesFromServer = actionStatusList.stream() .flatMap(actionStatus -> deploymentManagement - .findMessagesByActionStatusId(PAGE, actionStatus.getId()).getContent().stream()) + .findMessagesByActionStatusId(actionStatus.getId(), PAGE).getContent().stream()) .filter(Objects::nonNull) .filter(message -> message .startsWith(RepositoryConstants.SERVER_MESSAGE_PREFIX + "DMF message")) @@ -1184,7 +1184,7 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr try { SecurityContextSwitch.runAsPrivileged(() -> { final List actionStatusList = deploymentManagement - .findActionStatusByAction(PAGE, actionId).getContent(); + .findActionStatusByAction(actionId, PAGE).getContent(); assertThat(actionStatusList).hasSize(statusListCount); final List status = actionStatusList.stream().map(ActionStatus::getStatus) diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResource.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResource.java index 99bdf554d..e04fd02d6 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResource.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResource.java @@ -200,9 +200,9 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi { final Pageable pageable = PagingUtility.toPageable(pagingOffsetParam, pagingLimitParam, sanitizeDistributionSetSortParam(sortParam)); final Page targetsAssignedDS; if (rsqlParam != null) { - targetsAssignedDS = this.targetManagement.findByAssignedDistributionSetAndRsql(pageable, distributionSetId, rsqlParam); + targetsAssignedDS = this.targetManagement.findByAssignedDistributionSetAndRsql(distributionSetId, rsqlParam, pageable); } else { - targetsAssignedDS = this.targetManagement.findByAssignedDistributionSet(pageable, distributionSetId); + targetsAssignedDS = this.targetManagement.findByAssignedDistributionSet(distributionSetId, pageable); } return ResponseEntity.ok(new PagedList<>( @@ -218,9 +218,9 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi { final Pageable pageable = PagingUtility.toPageable(pagingOffsetParam, pagingLimitParam, sanitizeDistributionSetSortParam(sortParam)); final Page targetsInstalledDS; if (rsqlParam != null) { - targetsInstalledDS = this.targetManagement.findByInstalledDistributionSetAndRsql(pageable, distributionSetId, rsqlParam); + targetsInstalledDS = this.targetManagement.findByInstalledDistributionSetAndRsql(distributionSetId, rsqlParam, pageable); } else { - targetsInstalledDS = this.targetManagement.findByInstalledDistributionSet(pageable, distributionSetId); + targetsInstalledDS = this.targetManagement.findByInstalledDistributionSet(distributionSetId, pageable); } return ResponseEntity.ok(new PagedList<>( @@ -233,7 +233,7 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi { final int pagingOffsetParam, final int pagingLimitParam, final String sortParam) { final Pageable pageable = PagingUtility.toPageable(pagingOffsetParam, pagingLimitParam, sanitizeDistributionSetSortParam(sortParam)); final Page targetFilterQueries = targetFilterQueryManagement - .findByAutoAssignDSAndRsql(pageable, distributionSetId, rsqlParam); + .findByAutoAssignDSAndRsql(distributionSetId, rsqlParam, pageable); return ResponseEntity.ok(new PagedList<>( MgmtTargetFilterQueryMapper.toResponse(targetFilterQueries.getContent(), tenantConfigHelper.isConfirmationFlowEnabled(), false), diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutResource.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutResource.java index bfa5af011..620042f7a 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutResource.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutResource.java @@ -94,13 +94,13 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi { final List rest; if (isFullMode) { rollouts = rsqlParam == null - ? rolloutManagement.findAllWithDetailedStatus(pageable, false) - : rolloutManagement.findByRsqlWithDetailedStatus(pageable, rsqlParam, false); + ? rolloutManagement.findAllWithDetailedStatus(false, pageable) + : rolloutManagement.findByRsqlWithDetailedStatus(rsqlParam, false, pageable); rest = MgmtRolloutMapper.toResponseRolloutWithDetails(rollouts.getContent()); } else { rollouts = rsqlParam == null - ? rolloutManagement.findAll(pageable, false) - : rolloutManagement.findByRsql(pageable, rsqlParam, false); + ? rolloutManagement.findAll(false, pageable) + : rolloutManagement.findByRsql(rsqlParam, false, pageable); rest = MgmtRolloutMapper.toResponseRollout(rollouts.getContent()); } return ResponseEntity.ok(new PagedList<>(rest, rollouts.getTotalElements())); @@ -256,7 +256,7 @@ public class MgmtRolloutResource implements MgmtRolloutRestApi { if (rsqlParam == null) { rolloutGroupTargets = this.rolloutGroupManagement.findTargetsOfRolloutGroup(groupId, pageable); } else { - rolloutGroupTargets = this.rolloutGroupManagement.findTargetsOfRolloutGroupByRsql(pageable, groupId, rsqlParam); + rolloutGroupTargets = this.rolloutGroupManagement.findTargetsOfRolloutGroupByRsql(groupId, rsqlParam, pageable); } final List rest = MgmtTargetMapper.toResponse(rolloutGroupTargets.getContent(), tenantConfigHelper); return ResponseEntity.ok(new PagedList<>(rest, rolloutGroupTargets.getTotalElements())); diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetFilterQueryResource.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetFilterQueryResource.java index 957b9bb2f..333672741 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetFilterQueryResource.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetFilterQueryResource.java @@ -80,7 +80,7 @@ public class MgmtTargetFilterQueryResource implements MgmtTargetFilterQueryRestA final Slice findTargetFiltersAll; final long countTargetsAll; if (rsqlParam != null) { - final Page findFilterPage = filterManagement.findByRsql(pageable, rsqlParam); + final Page findFilterPage = filterManagement.findByRsql(rsqlParam, pageable); countTargetsAll = findFilterPage.getTotalElements(); findTargetFiltersAll = findFilterPage; } else { diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResource.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResource.java index 3dfd9437f..68b2654d6 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResource.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResource.java @@ -118,7 +118,7 @@ public class MgmtTargetResource implements MgmtTargetRestApi { final Slice findTargetsAll; final long countTargetsAll; if (rsqlParam != null) { - findTargetsAll = targetManagement.findByRsql(pageable, rsqlParam); + findTargetsAll = targetManagement.findByRsql(rsqlParam, pageable); countTargetsAll = targetManagement.countByRsql(rsqlParam); } else { findTargetsAll = targetManagement.findAll(pageable); @@ -340,7 +340,7 @@ public class MgmtTargetResource implements MgmtTargetRestApi { return ResponseEntity.notFound().build(); } final Pageable pageable = PagingUtility.toPageable(pagingOffsetParam, pagingLimitParam, sanitizeActionStatusSortParam(sortParam)); - final Page statusList = this.deploymentManagement.findActionStatusByAction(pageable, action.getId()); + final Page statusList = this.deploymentManagement.findActionStatusByAction(action.getId(), pageable); return ResponseEntity.ok(new PagedList<>( MgmtTargetMapper.toActionStatusRestResponse(statusList.getContent(), deploymentManagement), diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTagResource.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTagResource.java index bd8f9cb83..6bce77868 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTagResource.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTagResource.java @@ -70,7 +70,7 @@ public class MgmtTargetTagResource implements MgmtTargetTagRestApi { if (rsqlParam == null) { findTargetsAll = this.tagManagement.findAll(pageable); } else { - findTargetsAll = this.tagManagement.findByRsql(pageable, rsqlParam); + findTargetsAll = this.tagManagement.findByRsql(rsqlParam, pageable); } final List rest = MgmtTagMapper.toResponse(findTargetsAll.getContent()); @@ -128,9 +128,9 @@ public class MgmtTargetTagResource implements MgmtTargetTagRestApi { final Pageable pageable = PagingUtility.toPageable(pagingOffsetParam, pagingLimitParam, sanitizeTagSortParam(sortParam)); final Page findTargetsAll; if (rsqlParam == null) { - findTargetsAll = targetManagement.findByTag(pageable, targetTagId); + findTargetsAll = targetManagement.findByTag(targetTagId, pageable); } else { - findTargetsAll = targetManagement.findByRsqlAndTag(pageable, rsqlParam, targetTagId); + findTargetsAll = targetManagement.findByRsqlAndTag(rsqlParam, targetTagId, pageable); } final List rest = MgmtTargetMapper.toResponse(findTargetsAll.getContent(), tenantConfigHelper); diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTypeResource.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTypeResource.java index 60dd9e903..6ea09d4b9 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTypeResource.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTypeResource.java @@ -58,7 +58,7 @@ public class MgmtTargetTypeResource implements MgmtTargetTypeRestApi { final Slice findTargetTypesAll; long countTargetTypesAll; if (rsqlParam != null) { - findTargetTypesAll = targetTypeManagement.findByRsql(pageable, rsqlParam); + findTargetTypesAll = targetTypeManagement.findByRsql(rsqlParam, pageable); countTargetTypesAll = ((Page) findTargetTypesAll).getTotalElements(); } else { findTargetTypesAll = targetTypeManagement.findAll(pageable); diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtTargetMapper.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtTargetMapper.java index 92c9a21b2..652c2e6c5 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtTargetMapper.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/mapper/MgmtTargetMapper.java @@ -206,7 +206,7 @@ public final class MgmtTargetMapper { return actionStatus.stream() .map(status -> toResponse(status, deploymentManagement.findMessagesByActionStatusId( - PageRequest.of(0, MgmtRestConstants.REQUEST_PARAMETER_PAGING_MAX_LIMIT), status.getId()) + status.getId(), PageRequest.of(0, MgmtRestConstants.REQUEST_PARAMETER_PAGING_MAX_LIMIT)) .getContent())) .toList(); } diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResourceTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResourceTest.java index 104e69453..f15d6b3e4 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResourceTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResourceTest.java @@ -311,7 +311,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe .andExpect(jsonPath("$.alreadyAssigned", equalTo(1))) .andExpect(jsonPath("$.total", equalTo(knownTargetIds.length))); - assertThat(targetManagement.findByAssignedDistributionSet(PAGE, createdDs.getId()).getContent()) + assertThat(targetManagement.findByAssignedDistributionSet(createdDs.getId(), PAGE).getContent()) .as("Five targets in repository have DS assigned").hasSize(5); } @@ -398,7 +398,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe .contentType(MediaType.APPLICATION_JSON).content(payload.toString())) .andExpect(status().isForbidden()); - assertThat(targetManagement.findByAssignedDistributionSet(PAGE, ds.getId()).getContent()).isEmpty(); + assertThat(targetManagement.findByAssignedDistributionSet(ds.getId(), PAGE).getContent()).isEmpty(); } @Test @@ -451,10 +451,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe .andExpect(jsonPath("$.alreadyAssigned", equalTo(1))) .andExpect(jsonPath("$.total", equalTo(targets.size()))); - assertThat(targetManagement.findByAssignedDistributionSet(PAGE, createdDs.getId()).getContent()) + assertThat(targetManagement.findByAssignedDistributionSet(createdDs.getId(), PAGE).getContent()) .as("Five targets in repository have DS assigned").hasSize(5); - assertThat(targetManagement.findByInstalledDistributionSet(PAGE, createdDs.getId()).getContent()).hasSize(4); + assertThat(targetManagement.findByInstalledDistributionSet(createdDs.getId(), PAGE).getContent()).hasSize(4); } @Test @@ -789,7 +789,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe @Description("Ensures that multiple DS requested are listed with expected payload.") void getDistributionSets() throws Exception { // prepare test data - assertThat(distributionSetManagement.findByCompleted(PAGE, true)).isEmpty(); + assertThat(distributionSetManagement.findByCompleted(true, PAGE)).isEmpty(); DistributionSet set = testdataFactory.createDistributionSet("one"); set = distributionSetManagement.update(entityFactory.distributionSet().update(set.getId()) @@ -798,7 +798,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe // load also lazy stuff set = distributionSetManagement.getWithDetails(set.getId()).get(); - assertThat(distributionSetManagement.findByCompleted(PAGE, true)).hasSize(1); + assertThat(distributionSetManagement.findByCompleted(true, PAGE)).hasSize(1); // perform request mvc.perform(get("/rest/v1/distributionsets").accept(MediaType.APPLICATION_JSON)) @@ -864,7 +864,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe @WithUser(principal = "uploadTester", allSpPermissions = true) @Description("Ensures that multipe DS posted to API are created in the repository.") void createDistributionSets() throws Exception { - assertThat(distributionSetManagement.findByCompleted(PAGE, true)).isEmpty(); + assertThat(distributionSetManagement.findByCompleted(true, PAGE)).isEmpty(); final SoftwareModule ah = testdataFactory.createSoftwareModule(TestdataFactory.SM_TYPE_APP); final SoftwareModule jvm = testdataFactory.createSoftwareModule(TestdataFactory.SM_TYPE_RT); final SoftwareModule os = testdataFactory.createSoftwareModule(TestdataFactory.SM_TYPE_OS); @@ -907,7 +907,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe .hasToString(String.valueOf(three.getId())); // check in database - assertThat(distributionSetManagement.findByCompleted(PAGE, true)).hasSize(3); + assertThat(distributionSetManagement.findByCompleted(true, PAGE)).hasSize(3); assertThat(one.isRequiredMigrationStep()).isFalse(); assertThat(two.isRequiredMigrationStep()).isFalse(); assertThat(three.isRequiredMigrationStep()).isTrue(); @@ -921,11 +921,11 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe @Description("Ensures that DS deletion request to API is reflected by the repository.") void deleteUnassignedistributionSet() throws Exception { // prepare test data - assertThat(distributionSetManagement.findByCompleted(PAGE, true)).isEmpty(); + assertThat(distributionSetManagement.findByCompleted(true, PAGE)).isEmpty(); final DistributionSet set = testdataFactory.createDistributionSet("one"); - assertThat(distributionSetManagement.findByCompleted(PAGE, true)).hasSize(1); + assertThat(distributionSetManagement.findByCompleted(true, PAGE)).hasSize(1); // perform request mvc.perform(delete("/rest/v1/distributionsets/{smId}", set.getId())) @@ -933,7 +933,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe .andExpect(status().isOk()); // check repository content - assertThat(distributionSetManagement.findByCompleted(PAGE, true)).isEmpty(); + assertThat(distributionSetManagement.findByCompleted(true, PAGE)).isEmpty(); assertThat(distributionSetManagement.count()).isZero(); } @@ -949,13 +949,13 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe @Description("Ensures that assigned DS deletion request to API is reflected by the repository by means of deleted flag set.") void deleteAssignedDistributionSet() throws Exception { // prepare test data - assertThat(distributionSetManagement.findByCompleted(PAGE, true)).isEmpty(); + assertThat(distributionSetManagement.findByCompleted(true, PAGE)).isEmpty(); final DistributionSet set = testdataFactory.createDistributionSet("one"); testdataFactory.createTarget("test"); assignDistributionSet(set.getId(), "test"); - assertThat(distributionSetManagement.findByCompleted(PAGE, true)).hasSize(1); + assertThat(distributionSetManagement.findByCompleted(true, PAGE)).hasSize(1); mvc.perform(get("/rest/v1/distributionsets/{dsId}", set.getId())) .andDo(MockMvcResultPrinter.print()) @@ -972,14 +972,14 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe .andExpect(jsonPath("$.deleted", equalTo(true))); // check repository content - assertThat(distributionSetManagement.findByCompleted(PAGE, true)).isEmpty(); + assertThat(distributionSetManagement.findByCompleted(true, PAGE)).isEmpty(); } @Test @Description("Ensures that DS property update request to API is reflected by the repository.") void updateDistributionSet() throws Exception { // prepare test data - assertThat(distributionSetManagement.findByCompleted(PAGE, true)).isEmpty(); + assertThat(distributionSetManagement.findByCompleted(true, PAGE)).isEmpty(); final DistributionSet set = testdataFactory.createDistributionSet("one"); assertThat(distributionSetManagement.count()).isEqualTo(1); @@ -1009,7 +1009,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe void updateRequiredMigrationStepFailsIfDistributionSetisInUse() throws Exception { // prepare test data - assertThat(distributionSetManagement.findByCompleted(PAGE, true)).isEmpty(); + assertThat(distributionSetManagement.findByCompleted(true, PAGE)).isEmpty(); final DistributionSet set = testdataFactory.createDistributionSet("one"); assignDistributionSet(set.getId(), testdataFactory.createTarget().getControllerId()); @@ -1310,7 +1310,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe .andExpect(jsonPath("$.alreadyAssigned", equalTo(1))) .andExpect(jsonPath("$.total", equalTo(knownTargetIds.length))); - assertThat(targetManagement.findByAssignedDistributionSet(PAGE, createdDs.getId()).getContent()) + assertThat(targetManagement.findByAssignedDistributionSet(createdDs.getId(), PAGE).getContent()) .as("Five targets in repository have DS assigned").hasSize(5); } @@ -1604,7 +1604,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe @Description("Tests the lock. It is verified that the distribution set can be marked as locked through update operation.") void lockDistributionSet() throws Exception { // prepare test data - assertThat(distributionSetManagement.findByCompleted(PAGE, true)).isEmpty(); + assertThat(distributionSetManagement.findByCompleted(true, PAGE)).isEmpty(); final DistributionSet set = testdataFactory.createDistributionSet("one"); assertThat(distributionSetManagement.count()).isEqualTo(1); @@ -1626,7 +1626,7 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe @Description("Tests the unlock.") void unlockDistributionSet() throws Exception { // prepare test data - assertThat(distributionSetManagement.findByCompleted(PAGE, true)).isEmpty(); + assertThat(distributionSetManagement.findByCompleted(true, PAGE)).isEmpty(); final DistributionSet set = testdataFactory.createDistributionSet("one"); assertThat(distributionSetManagement.count()).isEqualTo(1); diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutResourceTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutResourceTest.java index f1a5ab311..5fce771ae 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutResourceTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutResourceTest.java @@ -459,7 +459,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { rolloutHandler.handleAll(); - final Rollout rollout = rolloutManagement.findByRsql(PAGE, "name==rollout1", false).getContent().get(0); + final Rollout rollout = rolloutManagement.findByRsql("name==rollout1", false, PAGE).getContent().get(0); rolloutManagement.start(rollout.getId()); rolloutHandler.handleAll(); @@ -766,7 +766,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { final DistributionSet dsA = testdataFactory.createDistributionSet(""); postRollout("rollout1", 5, dsA.getId(), "id==target*", 20, Action.ActionType.FORCED); - final List content = rolloutManagement.findAll(PAGE, false).getContent(); + final List content = rolloutManagement.findAll(false, PAGE).getContent(); assertThat(content).hasSizeGreaterThan(0).allSatisfy(rollout -> { assertThat(rolloutGroupManagement.findByRollout(rollout.getId(), PAGE)) .describedAs("Confirmation required flag depends on feature active.") @@ -803,7 +803,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { .andExpect(status().isCreated()) .andReturn(); - final List content = rolloutManagement.findAll(PAGE, false).getContent(); + final List content = rolloutManagement.findAll(false, PAGE).getContent(); assertThat(content).hasSize(1).allSatisfy(rollout -> { final List groups = rolloutGroupManagement.findByRollout(rollout.getId(), PAGE).getContent(); assertThat(groups).hasSize(2).allMatch(group -> { @@ -846,7 +846,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { .andExpect(status().isCreated()) .andReturn(); - final List content = rolloutManagement.findAll(PAGE, false).getContent(); + final List content = rolloutManagement.findAll(false, PAGE).getContent(); assertThat(content).hasSize(1).allSatisfy(rollout -> { final List groups = rolloutGroupManagement.findByRollout(rollout.getId(), PAGE).getContent(); assertThat(groups).hasSize(2).allMatch(group -> { @@ -1552,7 +1552,7 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { .andDo(MockMvcResultPrinter.print()) .andExpect(status().isCreated()); - final List rollouts = rolloutManagement.findAll(PAGE, false).getContent(); + final List rollouts = rolloutManagement.findAll(false, PAGE).getContent(); assertThat(rollouts).hasSize(2); assertThat(rollouts.get(0).getWeight()).get().isEqualTo(weight); } diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetFilterQueryResourceTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetFilterQueryResourceTest.java index cd047aa55..55c843746 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetFilterQueryResourceTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetFilterQueryResourceTest.java @@ -275,8 +275,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte + filterQuery.getId(); final String distributionsetHrefPrefix = "http://localhost" + MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING; - final String dsQuery = "?offset=0&limit=50&q=name==" + set.getName() + ";" + "version==" + set.getVersion(); - + final String dsQuery = "?q=name==" + set.getName() + ";" + "version==" + set.getVersion() + "&offset=0&limit=50"; mvc.perform( post(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + filterQuery.getId() + "/autoAssignDS") .content("{\"id\":" + set.getId() + "}").contentType(MediaType.APPLICATION_JSON)) diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResourceTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResourceTest.java index 851cc0960..e1fae0fa0 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResourceTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResourceTest.java @@ -376,7 +376,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final PageRequest pageRequest = PageRequest.of(0, 1000, Direction.ASC, ActionFields.ID.getJpaEntityFieldName()); final Action action = deploymentManagement.findActionsByTarget(knownTargetId, pageRequest).getContent().get(0); - final ActionStatus status = deploymentManagement.findActionStatusByAction(PAGE, action.getId()).getContent() + final ActionStatus status = deploymentManagement.findActionStatusByAction(action.getId(), PAGE).getContent() .stream().sorted((e1, e2) -> Long.compare(e2.getId(), e1.getId())).toList().get(0); mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" @@ -1337,7 +1337,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final String knownTargetId = "targetId"; final Action action = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId).get(0); // retrieve list in default descending order for actionstaus entries - final List actionStatus = deploymentManagement.findActionStatusByAction(PAGE, action.getId()) + final List actionStatus = deploymentManagement.findActionStatusByAction(action.getId(), PAGE) .getContent().stream().sorted((e1, e2) -> Long.compare(e2.getId(), e1.getId())) .toList(); @@ -1365,7 +1365,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { void getActionsStatusSortedByReportedAt() throws Exception { final String knownTargetId = "targetId"; final Action action = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId).get(0); - final List actionStatus = deploymentManagement.findActionStatusByAction(PAGE, action.getId()) + final List actionStatus = deploymentManagement.findActionStatusByAction(action.getId(), PAGE) .getContent().stream().sorted(Comparator.comparingLong(Identifiable::getId)) .toList(); @@ -1414,7 +1414,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final String knownTargetId = "targetId"; final Action action = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId).get(0); - final List actionStatus = deploymentManagement.findActionStatusByAction(PAGE, action.getId()) + final List actionStatus = deploymentManagement.findActionStatusByAction(action.getId(), PAGE) .getContent().stream().sorted((e1, e2) -> Long.compare(e1.getId(), e2.getId())) .toList(); @@ -1668,7 +1668,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { implicitLock(set); final List findActiveActionsByTarget = deploymentManagement - .findActiveActionsByTarget(PAGE, target.getControllerId()).getContent(); + .findActiveActionsByTarget(target.getControllerId(), PAGE).getContent(); assertThat(findActiveActionsByTarget).hasSize(1); assertThat(findActiveActionsByTarget.get(0).getActionType()).isEqualTo(ActionType.TIMEFORCED); assertThat(findActiveActionsByTarget.get(0).getForcedTime()).isEqualTo(forceTime); diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTagResourceTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTagResourceTest.java index 9d6a1fe89..e5ea7b55a 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTagResourceTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTagResourceTest.java @@ -22,12 +22,10 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. import java.util.ArrayList; import java.util.Arrays; -import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Random; -import java.util.stream.Collectors; import io.qameta.allure.Description; import io.qameta.allure.Feature; @@ -49,9 +47,6 @@ import org.eclipse.hawkbit.repository.test.matcher.ExpectEvents; import org.eclipse.hawkbit.rest.json.model.ExceptionInfo; import org.eclipse.hawkbit.rest.util.JsonBuilder; import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter; -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; import org.junit.jupiter.api.Test; import org.springframework.http.MediaType; import org.springframework.test.web.servlet.ResultActions; @@ -163,11 +158,11 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT .andExpect(status().isCreated()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)); - final Tag createdOne = targetTagManagement.findByRsql(PAGE, "name==thetest1").getContent().get(0); + final Tag createdOne = targetTagManagement.findByRsql("name==thetest1", PAGE).getContent().get(0); assertThat(createdOne.getName()).isEqualTo(tagOne.getName()); assertThat(createdOne.getDescription()).isEqualTo(tagOne.getDescription()); assertThat(createdOne.getColour()).isEqualTo(tagOne.getColour()); - final Tag createdTwo = targetTagManagement.findByRsql(PAGE, "name==thetest2").getContent().get(0); + final Tag createdTwo = targetTagManagement.findByRsql("name==thetest2", PAGE).getContent().get(0); assertThat(createdTwo.getName()).isEqualTo(tagTwo.getName()); assertThat(createdTwo.getDescription()).isEqualTo(tagTwo.getDescription()); assertThat(createdTwo.getColour()).isEqualTo(tagTwo.getColour()); @@ -196,7 +191,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)); - final Tag updated = targetTagManagement.findByRsql(PAGE, "name==updatedName").getContent().get(0); + final Tag updated = targetTagManagement.findByRsql("name==updatedName", PAGE).getContent().get(0); assertThat(updated.getName()).isEqualTo(update.getName()); assertThat(updated.getDescription()).isEqualTo(update.getDescription()); assertThat(updated.getColour()).isEqualTo(update.getColour()); @@ -303,7 +298,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); - final List updated = targetManagement.findByTag(PAGE, tag.getId()).getContent(); + final List updated = targetManagement.findByTag(tag.getId(), PAGE).getContent(); assertThat(updated.stream().map(Target::getControllerId).toList()).containsOnly(assigned.getControllerId()); } @@ -325,7 +320,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); - final List updated = targetManagement.findByTag(PAGE, tag.getId()).getContent(); + final List updated = targetManagement.findByTag(tag.getId(), PAGE).getContent(); assertThat(updated.stream().map(Target::getControllerId).toList()) .containsOnly(assigned0.getControllerId(), assigned1.getControllerId()); } @@ -366,7 +361,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT Collections.sort(notFound); assertThat(notFound).isEqualTo(missing); }); - assertThat(targetManagement.findByTag(PAGE, tag.getId()).getContent()).isEmpty(); + assertThat(targetManagement.findByTag(tag.getId(), PAGE).getContent()).isEmpty(); } @Test @@ -407,7 +402,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT Collections.sort(notFound); assertThat(notFound).isEqualTo(missing); }); - assertThat(targetManagement.findByTag(PAGE, tag.getId()).getContent().stream().map(Target::getControllerId).sorted().toList()) + assertThat(targetManagement.findByTag(tag.getId(), PAGE).getContent().stream().map(Target::getControllerId).sorted().toList()) .isEqualTo(targets.stream().sorted().toList()); } @@ -440,7 +435,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT .contentType(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); - assertThat(targetManagement.findByTag(PAGE, tag.getId()).getContent().stream().map(Target::getControllerId).sorted().toList()) + assertThat(targetManagement.findByTag(tag.getId(), PAGE).getContent().stream().map(Target::getControllerId).sorted().toList()) .isEqualTo(targets.stream().sorted().toList()); } @@ -463,7 +458,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); - final List updated = targetManagement.findByTag(PAGE, tag.getId()).getContent(); + final List updated = targetManagement.findByTag(tag.getId(), PAGE).getContent(); assertThat(updated.stream().map(Target::getControllerId).toList()) .containsOnly(assigned.getControllerId()); } @@ -489,7 +484,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); - final List updated = targetManagement.findByTag(PAGE, tag.getId()).getContent(); + final List updated = targetManagement.findByTag(tag.getId(), PAGE).getContent(); assertThat(updated.stream().map(Target::getControllerId).toList()) .containsOnly(assigned.getControllerId()); } @@ -533,7 +528,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT Collections.sort(notFound); assertThat(notFound).isEqualTo(missing); }); - assertThat(targetManagement.findByTag(PAGE, tag.getId()).getContent().stream().map(Target::getControllerId).sorted().toList()) + assertThat(targetManagement.findByTag(tag.getId(), PAGE).getContent().stream().map(Target::getControllerId).sorted().toList()) .isEqualTo(targets.stream().sorted().toList()); } @@ -577,7 +572,7 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT Collections.sort(notFound); assertThat(notFound).isEqualTo(missing); }); - assertThat(targetManagement.findByTag(PAGE, tag.getId()).getContent()).isEmpty(); + assertThat(targetManagement.findByTag(tag.getId(), PAGE).getContent()).isEmpty(); } @Test @@ -611,6 +606,6 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT .contentType(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); - assertThat(targetManagement.findByTag(PAGE, tag.getId()).getContent()).isEmpty(); + assertThat(targetManagement.findByTag(tag.getId(), PAGE).getContent()).isEmpty(); } } \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-api/README.md b/hawkbit-repository/hawkbit-repository-api/README.md index 7b108d5eb..aac9de33f 100644 --- a/hawkbit-repository/hawkbit-repository-api/README.md +++ b/hawkbit-repository/hawkbit-repository-api/README.md @@ -45,6 +45,6 @@ List getByControllerID(@NotEmpty Collection controllerId); Optional findFirstByDescription(@NotEmpty String description); // Query/search repository (page might be empty, no EntityNotFoundException) (note: pageReq always first in signature) -Page findByAssignedDistributionSet(@NotNull Pageable pageReq, @NotNull Long distributionSetID); +Page findByAssignedDistributionSet(@NotNull Long distributionSetID, @NotNull Pageable pageable); ``` \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/ArtifactManagement.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/ArtifactManagement.java index dd8ffe46f..d1090907e 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/ArtifactManagement.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/ArtifactManagement.java @@ -114,13 +114,13 @@ public interface ArtifactManagement { /** * Get local artifact for a base software module. * - * @param pageReq Pageable parameter * @param softwareModuleId software module id + * @param pageable Pageable parameter * @return Page * @throws EntityNotFoundException if software module with given ID does not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - Page findBySoftwareModule(@NotNull Pageable pageReq, long softwareModuleId); + Page findBySoftwareModule(long softwareModuleId, @NotNull Pageable pageable); /** * Count local artifacts for a base software module. diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/ControllerManagement.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/ControllerManagement.java index 32218c302..13b09c4cb 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/ControllerManagement.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/ControllerManagement.java @@ -138,13 +138,13 @@ public interface ControllerManagement { /** * Retrieves all the {@link ActionStatus} entries of the given {@link Action}. * - * @param pageReq pagination parameter * @param actionId to be filtered on + * @param pageable pagination parameter * @return the corresponding {@link Page} of {@link ActionStatus} * @throws EntityNotFoundException if action with given ID does not exist */ @PreAuthorize(SpringEvalExpressions.IS_CONTROLLER) - Page findActionStatusByAction(@NotNull Pageable pageReq, long actionId); + Page 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 diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java index 1e5bbdad8..8e969710d 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java @@ -46,14 +46,12 @@ import org.springframework.data.domain.Slice; import org.springframework.security.access.prepost.PreAuthorize; /** - * A DeploymentManagement service provides operations for the deployment of - * {@link DistributionSet}s to {@link Target}s. + * A DeploymentManagement service provides operations for the deployment of {@link DistributionSet}s to {@link Target}s. */ public interface DeploymentManagement { /** - * build a {@link DeploymentRequest} for a target distribution set - * assignment + * build a {@link DeploymentRequest} for a target distribution set assignment * * @param controllerId ID of target * @param distributionSetId ID of distribution set @@ -64,26 +62,23 @@ public interface DeploymentManagement { } /** - * Assigns {@link DistributionSet}s to {@link Target}s according to the - * {@link DeploymentRequest}. + * Assigns {@link DistributionSet}s to {@link Target}s according to the {@link DeploymentRequest}. * * @param deploymentRequests information about all target-ds-assignments that shall be made * @return the list of assignment results * @throws IncompleteDistributionSetException if mandatory {@link SoftwareModuleType} are not assigned as * defined by the {@link DistributionSetType}. - * @throws EntityNotFoundException if either provided {@link DistributionSet} or {@link Target}s - * do not exist + * @throws EntityNotFoundException if either provided {@link DistributionSet} or {@link Target}s do not exist * @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 - * target and multiassignment is disabled + * target and multi-assignment is disabled */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_UPDATE_TARGET) List assignDistributionSets(@Valid @NotEmpty List deploymentRequests); /** - * Assigns {@link DistributionSet}s to {@link Target}s according to the - * {@link DeploymentRequest}. + * Assigns {@link DistributionSet}s to {@link Target}s according to the {@link DeploymentRequest}. * * @param initiatedBy the username of the user who initiated the assignment * @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 * @throws IncompleteDistributionSetException if mandatory {@link SoftwareModuleType} are not assigned as * defined by the {@link DistributionSetType}. - * @throws EntityNotFoundException if either provided {@link DistributionSet} or {@link Target}s - * do not exist + * @throws EntityNotFoundException if either provided {@link DistributionSet} or {@link Target}s do not exist * @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 - * target and multiassignment is disabled + * target and multi-assignment is disabled */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_UPDATE_TARGET) - List assignDistributionSets(String initiatedBy, - @Valid @NotEmpty List deploymentRequests, String actionMessage); + List assignDistributionSets( + String initiatedBy, @Valid @NotEmpty List deploymentRequests, String actionMessage); /** - * Registers "offline" assignments. "offline" assignment means adding a - * completed action for a {@link DistributionSet} to a {@link Target}. - * + * Registers "offline" assignments. "offline" assignment means adding a completed action for a {@link DistributionSet} to a {@link Target}. * The handling differs to hawkBit-managed updates by means that:
* *
    @@ -117,17 +109,14 @@ public interface DeploymentManagement { *
  1. does not send a {@link TargetAssignDistributionSetEvent}.
  2. *
* - * @param assignments target IDs with the respective distribution set ID which they - * are supposed to be assigned to + * @param assignments target IDs with the respective distribution set ID which they are supposed to be assigned to * @return the assignment results * @throws IncompleteDistributionSetException if mandatory {@link SoftwareModuleType} are not assigned as * defined by the {@link DistributionSetType}. - * @throws EntityNotFoundException if either provided {@link DistributionSet} or {@link Target}s - * do not exist - * @throws AssignmentQuotaExceededException if the maximum number of targets the distribution set can be - * assigned to at once is exceeded + * @throws EntityNotFoundException if either provided {@link DistributionSet} or {@link Target}s do not exist + * @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 - * target and multiassignment is disabled + * target and multi-assignment is disabled */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_UPDATE_TARGET) List offlineAssignedDistributionSets(Collection> assignments, String initiatedBy); @@ -136,14 +125,12 @@ public interface DeploymentManagement { List offlineAssignedDistributionSets(Collection> assignments); /** - * Cancels the {@link Action} with the given ID. The method will immediately - * add a {@link Status#CANCELED} status to the action. However, it might be - * possible that the controller will continue to work on the cancellation. + * Cancels the {@link Action} with the given ID. The method will immediately add a {@link Status#CANCELED} status to the action. + * However, it might be possible that the controller will continue to work on the cancellation. * * @param actionId to be canceled * @return canceled {@link Action} - * @throws CancelActionNotAllowedException in case the given action is not active or is already a cancel - * action + * @throws CancelActionNotAllowedException in case the given action is not active or is already a cancel action * @throws EntityNotFoundException if action with given ID does not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET) @@ -152,7 +139,7 @@ public interface DeploymentManagement { /** * 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 * @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 @@ -161,11 +148,10 @@ public interface DeploymentManagement { * @throws EntityNotFoundException if target with given ID does not exist */ @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

* No access control applied. * * @return the total amount of stored actions @@ -174,15 +160,14 @@ public interface DeploymentManagement { long countActionsAll(); /** - * Counts the actions which match the given query. - *

+ * Counts the actions which match the given query.

* No access control applied. * - * @param rsqlParam RSQL query. + * @param rsql RSQL query. * @return the total number of actions matching the given RSQL query. */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - long countActions(@NotNull String rsqlParam); + long countActions(@NotNull String rsql); /** * Counts all actions associated to a specific target. @@ -215,37 +200,32 @@ public interface DeploymentManagement { Slice 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.

* 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 * @return a paged list of {@link Action}s. */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - Slice findActions(@NotNull String rsqlParam, @NotNull Pageable pageable); + Slice findActions(@NotNull String rsql, @NotNull Pageable pageable); /** - * Retrieves all {@link Action}s assigned to a specific {@link Target} and a - * given specification. + * Retrieves all {@link Action}s assigned to a specific {@link Target} and a given specification. * - * @param rsqlParam rsql query string + * @param rsql rsql query string * @param controllerId the target which must be assigned to the actions * @param pageable the page request - * @return a slice of actions assigned to the specific target and the - * specification + * @return a slice of actions assigned to the specific target and the specification * @throws RSQLParameterUnsupportedFieldException if a field in the RSQL string is used but not provided by the * given {@code fieldNameProvider} * @throws RSQLParameterSyntaxException if the RSQL syntax is wrong */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - Slice findActionsByTarget(@NotNull String rsqlParam, @NotEmpty String controllerId, - @NotNull Pageable pageable); + Slice findActionsByTarget(@NotNull String rsql, @NotEmpty String controllerId, @NotNull Pageable pageable); /** - * Retrieves all {@link Action}s which are referring the given - * {@link Target}. + * Retrieves all {@link Action}s which are referring the given {@link Target}. * * @param controllerId the target to find actions for * @param pageable the pageable request to limit, sort the actions @@ -255,16 +235,15 @@ public interface DeploymentManagement { Slice findActionsByTarget(@NotEmpty String controllerId, @NotNull Pageable pageable); /** - * 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 pageable pagination parameter * @return the corresponding {@link Page} of {@link ActionStatus} * @throws EntityNotFoundException if action with given ID does not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - Page findActionStatusByAction(@NotNull Pageable pageReq, long actionId); + Page findActionStatusByAction(long actionId, @NotNull Pageable pageable); /** * Counts all the {@link ActionStatus} entries of the given {@link Action}. @@ -277,20 +256,18 @@ public interface DeploymentManagement { long countActionStatusByAction(long actionId); /** - * Retrieves all messages for an {@link ActionStatus}. - *

+ * Retrieves all messages for an {@link ActionStatus}.

* 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 pageable the page request parameter for paging and sorting the result * @return a page of messages by a specific {@link ActionStatus} id */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - Page findMessagesByActionStatusId(@NotNull Pageable pageable, long actionStatusId); + Page findMessagesByActionStatusId(long actionStatusId, @NotNull Pageable pageable); /** - * Get the {@link Action} entity for given actionId with all lazy attributes - * (i.e. distributionSet, target, target.assignedDs). + * Get the {@link Action} entity for given actionId with all lazy attributes (i.e. distributionSet, target, target.assignedDs). * * @param actionId to be id of the action * @return the corresponding {@link Action} @@ -301,28 +278,27 @@ public interface DeploymentManagement { /** * 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 pageable the page request parameter for paging and sorting the result * @return a list of actions associated with the given target * @throws EntityNotFoundException if target with given ID does not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - Page findActiveActionsByTarget(@NotNull Pageable pageable, @NotEmpty String controllerId); + Page findActiveActionsByTarget(@NotEmpty String controllerId, @NotNull Pageable pageable); /** * 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 pageable the page request parameter for paging and sorting the result * @return a list of actions associated with the given target * @throws EntityNotFoundException if target with given ID does not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - Page findInActiveActionsByTarget(@NotNull Pageable pageable, @NotEmpty String controllerId); + Page findInActiveActionsByTarget(@NotEmpty String controllerId, @NotNull Pageable pageable); /** - * Retrieves active {@link Action}s with highest weight that are assigned to a - * {@link Target}. + * Retrieves active {@link Action}s with highest weight that are assigned to a {@link Target}. * * @param controllerId identifies the target to retrieve the action from * @param maxActionCount max size of returned list @@ -332,8 +308,7 @@ public interface DeploymentManagement { List findActiveActionsWithHighestWeight(@NotEmpty String controllerId, int maxActionCount); /** - * Get weight of an Action. Returns the default value if the weight is null - * according to the properties. + * Get weight of an Action. Returns the default value if the weight is null according to the properties. * * @param action to extract the weight from * @return weight of the action @@ -341,10 +316,8 @@ public interface DeploymentManagement { int getWeightConsideringDefault(final Action action); /** - * Force cancels given {@link Action} for given {@link Target}. Force - * 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. + * Force cancels given {@link Action} for given {@link Target}. Force 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. * * @param actionId to be canceled * @return quite {@link Action} @@ -355,8 +328,7 @@ public interface DeploymentManagement { Action forceQuitAction(long actionId); /** - * Updates a {@link Action} and forces the {@link Action} if it's not - * already forced. + * Updates a {@link Action} and forces the {@link Action} if it's not already forced. * * @param actionId the ID of the action * @return the updated or the found {@link Action} @@ -366,8 +338,7 @@ public interface DeploymentManagement { Action forceTargetAction(long actionId); /** - * Sets the status of inactive scheduled {@link Action}s for the specified - * {@link Target}s to {@link Status#CANCELED} + * Sets the status of inactive scheduled {@link Action}s for the specified {@link Target}s to {@link Status#CANCELED} * * @param targetIds ids of the {@link Target}s the actions belong to */ @@ -375,15 +346,12 @@ public interface DeploymentManagement { void cancelInactiveScheduledActionsForTargets(List targetIds); /** - * Starts all scheduled actions of an RolloutGroup parent. - *

+ * Starts all scheduled actions of an RolloutGroup parent.

* No entity based access control applied. * * @param rolloutId the rollout the actions belong to * @param distributionSetId to assign - * @param rolloutGroupParentId the parent rollout group the actions should reference. null - * references the first group - * @return the amount of started actions + * @param rolloutGroupParentId the parent rollout group the actions should reference. null references the first group */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) void startScheduledActionsByRolloutGroupParent(long rolloutId, long distributionSetId, Long rolloutGroupParentId); @@ -407,8 +375,7 @@ public interface DeploymentManagement { Optional getAssignedDistributionSet(@NotEmpty String controllerId); /** - * Returns {@link DistributionSet} that is installed on given - * {@link Target}. + * Returns {@link DistributionSet} that is installed on given {@link Target}. * * @param controllerId of target * @return installed {@link DistributionSet} @@ -418,9 +385,8 @@ public interface DeploymentManagement { Optional getInstalledDistributionSet(@NotEmpty String controllerId); /** - * Deletes actions which match one of the given action status and which have - * not been modified since the given (absolute) time-stamp. Used for obsolete actions cleanup. - *

+ * Deletes actions which match one of the given action status and which have not been modified since the given (absolute) time-stamp. + * Used for obsolete actions cleanup.

* No entity based access control applied. * * @param status Set of action status. @@ -431,8 +397,7 @@ public interface DeploymentManagement { int deleteActionsByStatusAndLastModifiedBefore(@NotNull Set status, long lastModified); /** - * Checks if there is an action for the device with the given controller ID - * that is in the {@link Action.Status#CANCELING} state. + * Checks if there is an action for the device with the given controller ID that is in the {@link Action.Status#CANCELING} state. * * @param targetId of target * @return if actions in CANCELING state are present @@ -441,13 +406,11 @@ public interface DeploymentManagement { boolean hasPendingCancellations(@NotNull Long targetId); /** - * Cancels all actions that refer to a given distribution set. This method - * is called when a distribution set is invalidated. + * Cancels all actions that refer to a given distribution set. This method is called when a distribution set is invalidated. * * @param cancelationType defines if a force or soft cancel is executed * @param set the distribution set for that the actions should be canceled */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET) void cancelActionsForDistributionSet(final CancelationType cancelationType, final DistributionSet set); - -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/DistributionSetManagement.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/DistributionSetManagement.java index 2b6c6c808..46b83e1a7 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/DistributionSetManagement.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/DistributionSetManagement.java @@ -231,13 +231,13 @@ public interface DistributionSetManagement extends RepositoryManagementtrue for returning only completed distribution sets or false for only incomplete ones nor * null to return both. + * @param pageable the pagination parameter * @return all found {@link DistributionSet}s */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - Slice findByCompleted(@NotNull Pageable pageable, Boolean complete); + Slice findByCompleted(Boolean complete, @NotNull Pageable pageable); /** * Retrieves {@link DistributionSet}s by filtering on the given parameters. @@ -266,14 +266,14 @@ public interface DistributionSetManagement extends RepositoryManagement findByRsqlAndTag(@NotNull String rsqlParam, long tagId, @NotNull Pageable pageable); + Page findByRsqlAndTag(@NotNull String rsql, long tagId, @NotNull Pageable pageable); /** * Counts all {@link DistributionSet}s based on completeness. diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/DistributionSetTagManagement.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/DistributionSetTagManagement.java index 697908b01..ba426a3b1 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/DistributionSetTagManagement.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/DistributionSetTagManagement.java @@ -43,13 +43,13 @@ public interface DistributionSetTagManagement extends RepositoryManagement findByDistributionSet(@NotNull Pageable pageable, long distributionSetId); + Page findByDistributionSet(long distributionSetId, @NotNull Pageable pageable); /** * Deletes {@link DistributionSetTag} by given diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/RepositoryManagement.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/RepositoryManagement.java index db3b9dba0..94bdefe49 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/RepositoryManagement.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/RepositoryManagement.java @@ -119,7 +119,7 @@ public interface RepositoryManagement { /** * 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 * @return the found {@link BaseEntity}s * @throws RSQLParameterUnsupportedFieldException if a field in the RSQL string is used but not provided by the given @@ -127,7 +127,7 @@ public interface RepositoryManagement { * @throws RSQLParameterSyntaxException if the RSQL syntax is wrong */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - Page findByRsql(@NotNull String rsqlParam, @NotNull Pageable pageable); + Page findByRsql(@NotNull String rsql, @NotNull Pageable pageable); /** * Verifies that {@link BaseEntity} with given ID exists in the repository. diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/RolloutGroupManagement.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/RolloutGroupManagement.java index a8e9406b4..c90956c14 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/RolloutGroupManagement.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/RolloutGroupManagement.java @@ -53,7 +53,7 @@ public interface RolloutGroupManagement { * 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 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 * @return a page of found {@link RolloutGroup}s * @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 */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) - Page findByRolloutAndRsql(long rolloutId, @NotNull String rsqlParam, @NotNull Pageable pageable); + Page 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. * * @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 * @return a page of found {@link RolloutGroup}s * @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 */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) - Page findByRolloutAndRsqlWithDetailedStatus(long rolloutId, @NotNull String rsqlParam, @NotNull Pageable pageable); + Page findByRolloutAndRsqlWithDetailedStatus(long rolloutId, @NotNull String rsql, @NotNull Pageable pageable); /** * 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. * - * @param pageable the page request to sort and limit the result * @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 list of targets of a rollout group * @throws RSQLParameterUnsupportedFieldException if a field in the RSQL string is used but not provided by the * given {@code fieldNameProvider} * @throws RSQLParameterSyntaxException if the RSQL syntax is wrong */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ_AND_TARGET_READ) - Page findTargetsOfRolloutGroupByRsql(@NotNull Pageable pageable, long rolloutGroupId, - @NotNull String rsqlParam); + Page findTargetsOfRolloutGroupByRsql(long rolloutGroupId, @NotNull String rsql, @NotNull Pageable pageable); /** * Get {@link RolloutGroup} by id. diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/RolloutManagement.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/RolloutManagement.java index 71c88cabd..b1d63b477 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/RolloutManagement.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/RolloutManagement.java @@ -180,50 +180,48 @@ public interface RolloutManagement { /** * Retrieves all rollouts. * - * @param pageable the page request to sort and limit the result * @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 */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) - Page findAll(@NotNull Pageable pageable, boolean deleted); + Page findAll(boolean deleted, @NotNull Pageable pageable); /** * 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 pageable the page request to sort and limit the result * @return a list of rollouts with details of targets count for different * statuses */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) - Page findAllWithDetailedStatus(@NotNull Pageable pageable, boolean deleted); + Page findAllWithDetailedStatus(boolean deleted, @NotNull Pageable pageable); /** * Retrieves all rollouts found by the given specification. * - * @param pageable the page request to sort and limit the result - * @param rsqlParam the specification to filter rollouts + * @param rsql the specification to filter rollouts * @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 * @throws RSQLParameterUnsupportedFieldException if a field in the RSQL string is used but not provided by the * given {@code fieldNameProvider} * @throws RSQLParameterSyntaxException if the RSQL syntax is wrong */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) - Page findByRsql(@NotNull Pageable pageable, @NotNull String rsqlParam, boolean deleted); + Page findByRsql(@NotNull String rsql, boolean deleted, @NotNull Pageable pageable); /** * Finds rollouts by given text in name or description. * - * @param pageable the page request to sort and limit the result - * @param searchText search text which matches name or description of rollout + * @param rsql search text which matches name or description of rollout * @param deleted flag if deleted rollouts should be included - * @return the founded rollout or {@code null} if rollout with given ID does - * not exists + * @param pageable the page request to sort and limit the result + * @return the founded rollout or {@code null} if rollout with given ID does not exists */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ) - Page findByRsqlWithDetailedStatus(@NotNull Pageable pageable, @NotEmpty String searchText, - boolean deleted); + Page findByRsqlWithDetailedStatus(@NotEmpty String rsql, boolean deleted, @NotNull Pageable pageable); /** * Find rollouts which are still active and needs to be handled. diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/SoftwareModuleManagement.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/SoftwareModuleManagement.java index f1e339a81..5a1f75156 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/SoftwareModuleManagement.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/SoftwareModuleManagement.java @@ -77,13 +77,13 @@ public interface SoftwareModuleManagement extends RepositoryManagement findMetaDataBySoftwareModuleIdAndTargetVisible(@NotNull Pageable pageable, long id); + Page findMetaDataBySoftwareModuleIdAndTargetVisible(long id, @NotNull Pageable pageable); /** * Creates or updates a single software module meta-data entry. diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/TargetFilterQueryManagement.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/TargetFilterQueryManagement.java index 3a0d16da2..81523f616 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/TargetFilterQueryManagement.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/TargetFilterQueryManagement.java @@ -106,12 +106,12 @@ public interface TargetFilterQueryManagement { * Retrieves all {@link TargetFilterQuery}s which match the given name * filter. * - * @param pageable pagination parameter * @param name name filter + * @param pageable pagination parameter * @return the page with the found {@link TargetFilterQuery}s */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - Slice findByName(@NotNull Pageable pageable, @NotNull String name); + Slice findByName(@NotNull String name, @NotNull Pageable pageable); /** * Counts all {@link TargetFilterQuery}s which match the given name filter. @@ -123,50 +123,47 @@ public interface TargetFilterQueryManagement { long countByName(@NotNull String name); /** - * Retrieves all {@link TargetFilterQuery} which match the given RSQL - * filter. + * Retrieves all {@link TargetFilterQuery} which match the given RSQL filter. * - * @param pageable pagination parameter * @param rsqlFilter RSQL filter string + * @param pageable pagination parameter * @return the page with the found {@link TargetFilterQuery}s */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - Page findByRsql(@NotNull Pageable pageable, @NotNull String rsqlFilter); + Page findByRsql(@NotNull String rsqlFilter, @NotNull Pageable pageable); /** * 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 pageable pagination parameter * @return the page with the found {@link TargetFilterQuery}s */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - Slice findByQuery(@NotNull Pageable pageable, @NotNull String query); + Slice findByQuery(@NotNull String query, @NotNull Pageable pageable); /** - * Retrieves all {@link TargetFilterQuery}s which match the given - * auto-assign distribution set ID. + * Retrieves all {@link TargetFilterQuery}s which match the given auto-assign distribution set ID. * - * @param pageable pagination parameter * @param setId the auto assign distribution set + * @param pageable pagination parameter * @return the page with the found {@link TargetFilterQuery}s * @throws EntityNotFoundException if DS with given ID does not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - Slice findByAutoAssignDistributionSetId(@NotNull Pageable pageable, long setId); + Slice findByAutoAssignDistributionSetId(long setId, @NotNull Pageable pageable); /** - * Retrieves all {@link TargetFilterQuery}s which match the given - * auto-assign distribution set and RSQL filter. + * Retrieves all {@link TargetFilterQuery}s which match the given auto-assign distribution set and RSQL filter. * - * @param pageable pagination parameter * @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 * @throws EntityNotFoundException if DS with given ID does not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - Page findByAutoAssignDSAndRsql(@NotNull Pageable pageable, long setId, String rsqlParam); + Page findByAutoAssignDSAndRsql(long setId, String rsql, @NotNull Pageable pageable); /** * Retrieves all {@link TargetFilterQuery}s with an auto-assign distribution set. @@ -238,4 +235,4 @@ public interface TargetFilterQueryManagement { */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET) void cancelAutoAssignmentForDistributionSet(long setId); -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/TargetManagement.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/TargetManagement.java index 07998da27..7c2ae735a 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/TargetManagement.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/TargetManagement.java @@ -98,44 +98,44 @@ public interface TargetManagement { /** * 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 */ @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. * - * @param rsqlParam filter definition in RSQL syntax + * @param rsql filter definition in RSQL syntax * @return the found number of {@link Target}s */ @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 * 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 * compatible with * @return the found number of{@link Target}s */ @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 * 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 * compatible with * @return the found number of{@link Target}s */ @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 @@ -174,8 +174,7 @@ public interface TargetManagement { * @param create to be created * @return the created {@link Target} * @throws EntityAlreadyExistsException given target already exists. - * @throws ConstraintViolationException if fields are not filled as specified. Check {@link TargetCreate} - * for field constraints. + * @throws ConstraintViolationException if fields are not filled as specified. Check {@link TargetCreate} for field constraints. */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET) 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 * 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 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 * @throws EntityNotFoundException if distribution set with given ID does not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET) Slice 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 @@ -233,34 +232,34 @@ public interface TargetManagement { * are compatible with the passed {@link DistributionSetType}. * * @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 * @throws EntityNotFoundException if distribution set with given ID does not exist */ @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 * that are not assigned to one of the {@link RolloutGroup}s and are compatible * 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 targetFilterQuery filter definition in RSQL syntax * @param distributionSetType type of the {@link DistributionSet} the targets must be compatible * withs + * @param pageable the pageable to enhance the query for paging and sorting * @return a page of the found {@link Target}s */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ_AND_TARGET_READ) - Slice findByTargetFilterQueryAndNotInRolloutAndCompatibleAndUpdatable(@NotNull Pageable pageRequest, - @NotEmpty Collection groups, @NotNull String targetFilterQuery, - @NotNull DistributionSetType distributionSetType); + Slice findByTargetFilterQueryAndNotInRolloutAndCompatibleAndUpdatable( + @NotEmpty Collection groups, @NotNull String targetFilterQuery, @NotNull DistributionSetType distributionSetType, + @NotNull Pageable pageable); @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ_AND_TARGET_READ) Slice findByTargetFilterQueryAndNoOverridingActionsAndNotInRolloutAndCompatibleAndUpdatable( - @NotNull Pageable pageRequest, final long rolloutId, final int weight, final long firstGroupId, @NotNull String targetFilterQuery, - @NotNull DistributionSetType distributionSetType); + final long rolloutId, final int weight, final long firstGroupId, @NotNull String targetFilterQuery, + @NotNull DistributionSetType distributionSetType, @NotNull Pageable pageable); @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ_AND_TARGET_READ) 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 * 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 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 */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ_AND_TARGET_READ) - Slice findByFailedRolloutAndNotInRolloutGroups(@NotNull Pageable pageRequest, - @NotEmpty Collection groups, @NotNull String rolloutId); + Slice findByFailedRolloutAndNotInRolloutGroups( + @NotNull String rolloutId, @NotEmpty Collection groups, @NotNull Pageable pageable); /** * 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 * 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 distributionSetType type of the {@link DistributionSet} the targets must be compatible - * with + * @param distributionSetType type of the {@link DistributionSet} the targets must be compatible with * @return count of the found {@link Target}s */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ_AND_TARGET_READ) - long countByRsqlAndNotInRolloutGroupsAndCompatibleAndUpdatable(@NotNull String rsqlParam, @NotEmpty Collection groups, - @NotNull DistributionSetType distributionSetType); + long countByRsqlAndNotInRolloutGroupsAndCompatibleAndUpdatable( + @NotNull String rsql, @NotEmpty Collection groups, @NotNull DistributionSetType distributionSetType); /** * 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 * for the RolloutGroup. * - * @param pageRequest the pageRequest to enhance the query for paging and sorting * @param group the {@link RolloutGroup} + * @param pageable the pageable to enhance the query for paging and sorting * @return the found {@link Target}s * @throws EntityNotFoundException if rollout group with given ID does not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - Slice findByInRolloutGroupWithoutAction(@NotNull Pageable pageRequest, long group); + Slice 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 pageable page parameter * @return the found {@link Target}s * @throws EntityNotFoundException if distribution set with given ID does not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET) - Page findByAssignedDistributionSet(@NotNull Pageable pageReq, long distributionSetId); + Page findByAssignedDistributionSet(long distributionSetId, @NotNull Pageable pageable); /** - * Retrieves {@link Target}s by the assigned {@link DistributionSet} possible - * including additional filtering based on the given {@code spec}. + * Retrieves {@link Target}s by the assigned {@link DistributionSet} possible including additional filtering based on the given {@code spec}. * - * @param pageReq page parameter * @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} * @throws RSQLParameterUnsupportedFieldException if a field in the RSQL string is used but not provided by the * given {@code fieldNameProvider} @@ -343,8 +340,7 @@ public interface TargetManagement { * @throws EntityNotFoundException if distribution set with given ID does not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET) - Page findByAssignedDistributionSetAndRsql(@NotNull Pageable pageReq, long distributionSetId, - @NotNull String rsqlParam); + Page findByAssignedDistributionSetAndRsql(long distributionSetId, @NotNull String rsql, @NotNull Pageable pageable); /** * 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 * 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 * value; filters are AND-gated + * @param pageable page parameters * @return the found {@link Target}s * @throws EntityNotFoundException if distribution set with given ID does not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - Slice findByFilters(@NotNull Pageable pageable, @NotNull FilterParams filterParams); + Slice findByFilters(@NotNull FilterParams filterParams, @NotNull Pageable pageable); /** * retrieves {@link Target}s by the installed {@link DistributionSet}. * - * @param pageReq page parameter * @param distributionSetId the ID of the {@link DistributionSet} + * @param pageReq page parameter * @return the found {@link Target}s * @throws EntityNotFoundException if distribution set with given ID does not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET) - Page findByInstalledDistributionSet(@NotNull Pageable pageReq, long distributionSetId); + Page findByInstalledDistributionSet(long distributionSetId, @NotNull Pageable pageReq); /** * retrieves {@link Target}s by the installed {@link DistributionSet} including * additional filtering based on the given {@code spec}. * - * @param pageReq page parameter * @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} * @throws RSQLParameterUnsupportedFieldException if a field in the RSQL string is used but not provided by the * given {@code fieldNameProvider} @@ -432,17 +428,17 @@ public interface TargetManagement { * @throws EntityNotFoundException if distribution set with given ID does not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET) - Page findByInstalledDistributionSetAndRsql(@NotNull Pageable pageReq, long distributionSetId, @NotNull String rsqlParam); + Page findByInstalledDistributionSetAndRsql(long distributionSetId, @NotNull String rsql, @NotNull Pageable pageReq); /** * Retrieves the {@link Target} which have a certain {@link TargetUpdateStatus}. * - * @param pageable page parameter * @param status the {@link TargetUpdateStatus} to be filtered on + * @param pageable page parameter * @return the found {@link Target}s */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - Page findByUpdateStatus(@NotNull Pageable pageable, @NotNull TargetUpdateStatus status); + Page findByUpdateStatus(@NotNull TargetUpdateStatus status, @NotNull Pageable pageable); /** * Retrieves all targets. @@ -456,21 +452,21 @@ public interface TargetManagement { /** * Retrieves all targets. * + * @param rsql in RSQL notation * @param pageable pagination parameter - * @param rsqlParam in RSQL notation * @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 * given {@code fieldNameProvider} * @throws RSQLParameterSyntaxException if the RSQL syntax is wrong */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - Slice findByRsql(@NotNull Pageable pageable, @NotNull String rsqlParam); + Slice findByRsql(@NotNull String rsql, @NotNull Pageable pageable); /** * Retrieves all target based on {@link TargetFilterQuery}. * - * @param pageable pagination parameter * @param targetFilterQueryId {@link TargetFilterQuery#getId()} + * @param pageable pagination parameter * @return the found {@link Target}s, never {@code null} * @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 @@ -478,25 +474,25 @@ public interface TargetManagement { * @throws RSQLParameterSyntaxException if the RSQL syntax is wrong */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - Slice findByTargetFilterQuery(@NotNull Pageable pageable, long targetFilterQueryId); + Slice findByTargetFilterQuery(long targetFilterQueryId, @NotNull Pageable pageable); /** * Find targets by tag name. * - * @param pageable the page request parameter for paging and sorting the result * @param tagId tag ID + * @param pageable the page request parameter for paging and sorting the result * @return list of matching targets * @throws EntityNotFoundException if target tag with given ID does not exist */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - Page findByTag(@NotNull Pageable pageable, long tagId); + Page findByTag(long tagId, @NotNull Pageable pageable); /** * 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 rsqlParam in RSQL notation + * @param pageable the page request parameter for paging and sorting the result * @return list of matching targets * @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 @@ -504,7 +500,7 @@ public interface TargetManagement { * @throws RSQLParameterSyntaxException if the RSQL syntax is wrong */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - Page findByRsqlAndTag(@NotNull Pageable pageable, @NotNull String rsqlParam, long tagId); + Page findByRsqlAndTag(@NotNull String rsql, long tagId, @NotNull Pageable pageable); /** * 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 * {@link #isControllerAttributesRequested(String)}. * - * @param pageReq page parameter + * @param pageable page parameter * @return the found {@link Target}s */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - Page findByControllerAttributesRequested(@NotNull Pageable pageReq); + Page findByControllerAttributesRequested(@NotNull Pageable pageable); /** * Creates a list of target meta-data entries. diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/TargetTagManagement.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/TargetTagManagement.java index 1b4e1f25d..9fe96c724 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/TargetTagManagement.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/TargetTagManagement.java @@ -87,15 +87,14 @@ public interface TargetTagManagement { /** * Retrieves all target tags based on the given specification. * + * @param rsql rsql query string * @param pageable pagination parameter - * @param rsqlParam rsql query string * @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 - * given {@code fieldNameProvider} + * @throws RSQLParameterUnsupportedFieldException if a field in the RSQL string is used but not provided by the given {@code fieldNameProvider} * @throws RSQLParameterSyntaxException if the RSQL syntax is wrong */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) - Page findByRsql(@NotNull Pageable pageable, @NotNull String rsqlParam); + Page findByRsql(@NotNull String rsql, @NotNull Pageable pageable); /** * Find {@link TargetTag} based on given Name. diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/TargetTypeManagement.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/TargetTypeManagement.java index 2889fb763..27050d31b 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/TargetTypeManagement.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/TargetTypeManagement.java @@ -86,22 +86,22 @@ public interface TargetTypeManagement { Slice findAll(@NotNull Pageable pageable); /** + * @param rsql query param * @param pageable Page - * @param rsqlParam query param * @return Target type */ @PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_READ_TARGET) - Page findByRsql(@NotNull Pageable pageable, @NotEmpty String rsqlParam); + Page findByRsql(@NotEmpty String rsql, @NotNull Pageable pageable); /** * Retrieves {@link TargetType}s by filtering on the given parameters. * - * @param pageable page parameter * @param name has text of filters to be applied. + * @param pageable page parameter * @return the page of found {@link TargetType} */ @PreAuthorize(SpPermission.SpringEvalExpressions.HAS_AUTH_READ_TARGET) - Slice findByName(@NotNull Pageable pageable, String name); + Slice findByName(String name, @NotNull Pageable pageable); /** * @param id Target type ID diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaRolloutExecutor.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaRolloutExecutor.java index 7c97a4d82..a01d716df 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaRolloutExecutor.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaRolloutExecutor.java @@ -648,10 +648,10 @@ public class JpaRolloutExecutor implements RolloutExecutor { final Slice targets; if (!RolloutHelper.isRolloutRetried(rollout.getTargetFilterQuery())) { targets = targetManagement.findByTargetFilterQueryAndNotInRolloutAndCompatibleAndUpdatable( - pageRequest, readyGroups, targetFilter, rollout.getDistributionSet().getType()); + readyGroups, targetFilter, rollout.getDistributionSet().getType(), pageRequest); } else { 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()); @@ -772,10 +772,10 @@ public class JpaRolloutExecutor implements RolloutExecutor { return DeploymentHelper.runInNewTransaction(txManager, "createActionsForRolloutDynamicGroup", status -> { final PageRequest pageRequest = PageRequest.of(0, Math.toIntExact(limit)); final Slice targets = targetManagement.findByTargetFilterQueryAndNoOverridingActionsAndNotInRolloutAndCompatibleAndUpdatable( - pageRequest, - rollout.getId(), rollout.getWeight().orElse(1000), // Dynamic rollouts shall always have weight! - rolloutGroupRepository.findByRolloutOrderByIdAsc(rollout).get(0).getId(), - targetFilter, rollout.getDistributionSet().getType()); + rollout.getId(), rollout.getWeight().orElse(1000), rolloutGroupRepository.findByRolloutOrderByIdAsc(rollout).get(0).getId(), + targetFilter, rollout.getDistributionSet().getType(), pageRequest + // Dynamic rollouts shall always have weight! + ); if (targets.getNumberOfElements() == 0) { return 0; @@ -835,7 +835,7 @@ public class JpaRolloutExecutor implements RolloutExecutor { private Long createActionsForTargetsInNewTransaction(final Rollout rollout, final RolloutGroup group) { return DeploymentHelper.runInNewTransaction(txManager, "createActionsForTargets", status -> { final Slice targets = targetManagement.findByInRolloutGroupWithoutAction( - PageRequest.of(0, JpaRolloutExecutor.TRANSACTION_TARGETS), group.getId()); + group.getId(), PageRequest.of(0, JpaRolloutExecutor.TRANSACTION_TARGETS)); if (targets.getNumberOfElements() > 0) { final DistributionSet distributionSet = rollout.getDistributionSet(); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/autoassign/AutoAssignChecker.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/autoassign/AutoAssignChecker.java index 9d904b521..c860ab324 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/autoassign/AutoAssignChecker.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/autoassign/AutoAssignChecker.java @@ -86,8 +86,9 @@ public class AutoAssignChecker extends AbstractAutoAssignExecutor { do { final List controllerIds = targetManagement .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(); log.debug( "Retrieved {} auto assign targets for tenant {} and target filter query id {}, starting with assignment", diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaArtifactManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaArtifactManagement.java index 2e02f9078..1a00651b7 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaArtifactManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaArtifactManagement.java @@ -178,11 +178,11 @@ public class JpaArtifactManagement implements ArtifactManagement { } @Override - public Page findBySoftwareModule(final Pageable pageReq, final long softwareModuleId) { + public Page findBySoftwareModule(final long softwareModuleId, final Pageable pageable) { assertSoftwareModuleExists(softwareModuleId); return localArtifactRepository - .findAll(ArtifactSpecifications.bySoftwareModuleId(softwareModuleId), pageReq) + .findAll(ArtifactSpecifications.bySoftwareModuleId(softwareModuleId), pageable) .map(Artifact.class::cast); } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaControllerManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaControllerManagement.java index d0d109f8d..f3b040646 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaControllerManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaControllerManagement.java @@ -326,12 +326,12 @@ public class JpaControllerManagement extends JpaActionManagement implements Cont } @Override - public Page findActionStatusByAction(final Pageable pageReq, final long actionId) { + public Page findActionStatusByAction(final long actionId, final Pageable pageable) { if (!actionRepository.existsById(actionId)) { throw new EntityNotFoundException(Action.class, actionId); } - return actionStatusRepository.findByActionId(pageReq, actionId); + return actionStatusRepository.findByActionId(pageable, actionId); } @Override diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaDeploymentManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaDeploymentManagement.java index 3a264abb0..c59cba7d1 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaDeploymentManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaDeploymentManagement.java @@ -271,11 +271,11 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl } @Override - public long countActionsByTarget(final String rsqlParam, final String controllerId) { + public long countActionsByTarget(final String rsql, final String controllerId) { assertTargetReadAllowed(controllerId); final List> specList = Arrays.asList( - RSQLUtility.buildRsqlSpecification(rsqlParam, ActionFields.class, virtualPropertyReplacer, database), + RSQLUtility.buildRsqlSpecification(rsql, ActionFields.class, virtualPropertyReplacer, database), ActionSpecifications.byTargetControllerId(controllerId)); return JpaManagementHelper.countBySpec(actionRepository, specList); @@ -287,9 +287,9 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl } @Override - public long countActions(final String rsqlParam) { + public long countActions(final String rsql) { final List> specList = List.of( - RSQLUtility.buildRsqlSpecification(rsqlParam, ActionFields.class, virtualPropertyReplacer, database)); + RSQLUtility.buildRsqlSpecification(rsql, ActionFields.class, virtualPropertyReplacer, database)); return JpaManagementHelper.countBySpec(actionRepository, specList); } @@ -312,19 +312,18 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl } @Override - public Slice findActions(final String rsqlParam, final Pageable pageable) { + public Slice findActions(final String rsql, final Pageable pageable) { final List> specList = List.of( - RSQLUtility.buildRsqlSpecification(rsqlParam, ActionFields.class, virtualPropertyReplacer, database)); + RSQLUtility.buildRsqlSpecification(rsql, ActionFields.class, virtualPropertyReplacer, database)); return JpaManagementHelper.findAllWithoutCountBySpec(actionRepository, specList, pageable); } @Override - public Page findActionsByTarget(final String rsqlParam, final String controllerId, - final Pageable pageable) { + public Page findActionsByTarget(final String rsql, final String controllerId, final Pageable pageable) { assertTargetReadAllowed(controllerId); final List> specList = Arrays.asList( - RSQLUtility.buildRsqlSpecification(rsqlParam, ActionFields.class, virtualPropertyReplacer, database), + RSQLUtility.buildRsqlSpecification(rsql, ActionFields.class, virtualPropertyReplacer, database), ActionSpecifications.byTargetControllerId(controllerId)); return JpaManagementHelper.findAllWithCountBySpec(actionRepository, specList, pageable); @@ -338,10 +337,10 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl } @Override - public Page findActionStatusByAction(final Pageable pageReq, final long actionId) { + public Page findActionStatusByAction(final long actionId, final Pageable pageable) { assertActionExistsAndAccessible(actionId); - return actionStatusRepository.findByActionId(pageReq, actionId); + return actionStatusRepository.findByActionId(pageable, actionId); } @Override @@ -355,7 +354,7 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl // permissions // and UI which is to be removed @Override - public Page findMessagesByActionStatusId(final Pageable pageable, final long actionStatusId) { + public Page findMessagesByActionStatusId(final long actionStatusId, final Pageable pageable) { final CriteriaBuilder cb = entityManager.getCriteriaBuilder(); final CriteriaQuery msgQuery = cb.createQuery(String.class); @@ -377,7 +376,7 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl } @Override - public Page findActiveActionsByTarget(final Pageable pageable, final String controllerId) { + public Page findActiveActionsByTarget(final String controllerId, final Pageable pageable) { assertTargetReadAllowed(controllerId); return actionRepository .findAll(ActionSpecifications.byTargetControllerIdAndActive(controllerId, true), pageable) @@ -385,7 +384,7 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl } @Override - public Page findInActiveActionsByTarget(final Pageable pageable, final String controllerId) { + public Page findInActiveActionsByTarget(final String controllerId, final Pageable pageable) { assertTargetReadAllowed(controllerId); return actionRepository .findAll(ActionSpecifications.byTargetControllerIdAndActive(controllerId, false), pageable) diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaDistributionSetManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaDistributionSetManagement.java index 552d37d59..816201648 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaDistributionSetManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaDistributionSetManagement.java @@ -280,9 +280,9 @@ public class JpaDistributionSetManagement implements DistributionSetManagement { } @Override - public Page findByRsql(final String rsqlParam, final Pageable pageable) { + public Page findByRsql(final String rsql, final Pageable pageable) { return JpaManagementHelper.findAllWithCountBySpec(distributionSetRepository, List.of( - RSQLUtility.buildRsqlSpecification(rsqlParam, DistributionSetFields.class, virtualPropertyReplacer, database), + RSQLUtility.buildRsqlSpecification(rsql, DistributionSetFields.class, virtualPropertyReplacer, database), DistributionSetSpecification.isNotDeleted()), pageable); } @@ -511,7 +511,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement { } @Override - public Slice findByCompleted(final Pageable pageReq, final Boolean complete) { + public Slice findByCompleted(final Boolean complete, final Pageable pageReq) { final List> specifications = buildSpecsByComplete(complete); return JpaManagementHelper.findAllWithoutCountBySpec(distributionSetRepository, specifications, pageReq); @@ -547,11 +547,11 @@ public class JpaDistributionSetManagement implements DistributionSetManagement { } @Override - public Page findByRsqlAndTag(final String rsqlParam, final long tagId, final Pageable pageable) { + public Page findByRsqlAndTag(final String rsql, final long tagId, final Pageable pageable) { assertDsTagExists(tagId); return JpaManagementHelper.findAllWithCountBySpec(distributionSetRepository, List.of( - RSQLUtility.buildRsqlSpecification(rsqlParam, DistributionSetFields.class, virtualPropertyReplacer, + RSQLUtility.buildRsqlSpecification(rsql, DistributionSetFields.class, virtualPropertyReplacer, database), DistributionSetSpecification.hasTag(tagId), DistributionSetSpecification.isNotDeleted()), pageable); } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaDistributionSetTagManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaDistributionSetTagManagement.java index e5d6e2c02..5ee47066e 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaDistributionSetTagManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaDistributionSetTagManagement.java @@ -154,9 +154,9 @@ public class JpaDistributionSetTagManagement implements DistributionSetTagManage } @Override - public Page findByRsql(final String rsqlParam, final Pageable pageable) { + public Page findByRsql(final String rsql, final Pageable pageable) { final Specification spec = RSQLUtility.buildRsqlSpecification( - rsqlParam, DistributionSetTagFields.class, virtualPropertyReplacer, database); + rsql, DistributionSetTagFields.class, virtualPropertyReplacer, database); return JpaManagementHelper.findAllWithCountBySpec(distributionSetTagRepository, Collections.singletonList(spec), pageable); } @@ -166,7 +166,7 @@ public class JpaDistributionSetTagManagement implements DistributionSetTagManage } @Override - public Page findByDistributionSet(final Pageable pageable, final long distributionSetId) { + public Page findByDistributionSet(final long distributionSetId, final Pageable pageable) { if (!distributionSetRepository.existsById(distributionSetId)) { throw new EntityNotFoundException(DistributionSet.class, distributionSetId); } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaDistributionSetTypeManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaDistributionSetTypeManagement.java index 9442e80dd..d9eaab7bc 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaDistributionSetTypeManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaDistributionSetTypeManagement.java @@ -196,9 +196,9 @@ public class JpaDistributionSetTypeManagement implements DistributionSetTypeMana } @Override - public Page findByRsql(final String rsqlParam, final Pageable pageable) { + public Page findByRsql(final String rsql, final Pageable pageable) { return JpaManagementHelper.findAllWithCountBySpec(distributionSetTypeRepository, List.of( - RSQLUtility.buildRsqlSpecification(rsqlParam, DistributionSetTypeFields.class, virtualPropertyReplacer, database), + RSQLUtility.buildRsqlSpecification(rsql, DistributionSetTypeFields.class, virtualPropertyReplacer, database), DistributionSetTypeSpecification.isNotDeleted()), pageable); } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaRolloutGroupManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaRolloutGroupManagement.java index f4cc9dc88..d4c63f9ac 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaRolloutGroupManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaRolloutGroupManagement.java @@ -118,11 +118,11 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement { } @Override - public Page findByRolloutAndRsql(final long rolloutId, final String rsqlParam, final Pageable pageable) { + public Page findByRolloutAndRsql(final long rolloutId, final String rsql, final Pageable pageable) { throwEntityNotFoundExceptionIfRolloutDoesNotExist(rolloutId); final List> specList = Arrays.asList( - RSQLUtility.buildRsqlSpecification(rsqlParam, RolloutGroupFields.class, virtualPropertyReplacer, + RSQLUtility.buildRsqlSpecification(rsql, RolloutGroupFields.class, virtualPropertyReplacer, database), (root, query, cb) -> cb.equal(root.get(JpaRolloutGroup_.rollout).get(AbstractJpaBaseEntity_.id), rolloutId)); @@ -130,10 +130,10 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement { } @Override - public Page findByRolloutAndRsqlWithDetailedStatus(final long rolloutId, final String rsqlParam, final Pageable pageable) { + public Page findByRolloutAndRsqlWithDetailedStatus(final long rolloutId, final String rsql, final Pageable pageable) { throwEntityNotFoundExceptionIfRolloutDoesNotExist(rolloutId); - final Page rolloutGroups = findByRolloutAndRsql(rolloutId, rsqlParam, pageable); + final Page rolloutGroups = findByRolloutAndRsql(rolloutId, rsql, pageable); final List rolloutGroupIds = rolloutGroups.getContent().stream().map(RolloutGroup::getId).toList(); if (rolloutGroupIds.isEmpty()) { // groups might already have been deleted, so return empty list. @@ -185,11 +185,11 @@ public class JpaRolloutGroupManagement implements RolloutGroupManagement { } @Override - public Page findTargetsOfRolloutGroupByRsql(final Pageable pageable, final long rolloutGroupId, final String rsqlParam) { + public Page findTargetsOfRolloutGroupByRsql(final long rolloutGroupId, final String rsql, final Pageable pageable) { throwExceptionIfRolloutGroupDoesNotExist(rolloutGroupId); final List> specList = Arrays.asList( - RSQLUtility.buildRsqlSpecification(rsqlParam, TargetFields.class, virtualPropertyReplacer, database), + RSQLUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database), (root, query, cb) -> { final ListJoin rolloutTargetJoin = root.join(JpaTarget_.rolloutTargetGroup); return cb.equal(rolloutTargetJoin.get(RolloutTargetGroup_.rolloutGroup).get(AbstractJpaBaseEntity_.id), rolloutGroupId); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaRolloutManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaRolloutManagement.java index ed4ba435f..0c6aba00f 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaRolloutManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaRolloutManagement.java @@ -260,20 +260,20 @@ public class JpaRolloutManagement implements RolloutManagement { } @Override - public Page findAll(final Pageable pageable, final boolean deleted) { + public Page findAll(final boolean deleted, final Pageable pageable) { return JpaManagementHelper.convertPage( rolloutRepository.findAll(RolloutSpecification.isDeleted(deleted, pageable.getSort()), pageable), pageable); } @Override - public Page findAllWithDetailedStatus(final Pageable pageable, final boolean deleted) { + public Page findAllWithDetailedStatus(final boolean deleted, final Pageable pageable) { return appendStatusDetails(JpaManagementHelper.convertPage( rolloutRepository.findAll(RolloutSpecification.isDeleted(deleted, pageable.getSort()), JpaRollout_.GRAPH_ROLLOUT_DS, pageable), pageable)); } @Override - public Page findByRsql(final Pageable pageable, final String rsql, final boolean deleted) { + public Page findByRsql(final String rsql, final boolean deleted, final Pageable pageable) { final List> specList = List.of( RSQLUtility.buildRsqlSpecification(rsql, RolloutFields.class, virtualPropertyReplacer, database), RolloutSpecification.isDeleted(deleted, pageable.getSort())); @@ -281,7 +281,7 @@ public class JpaRolloutManagement implements RolloutManagement { } @Override - public Page findByRsqlWithDetailedStatus(final Pageable pageable, final String rsql, final boolean deleted) { + public Page findByRsqlWithDetailedStatus(final String rsql, final boolean deleted, final Pageable pageable) { final List> specList = List.of( RSQLUtility.buildRsqlSpecification(rsql, RolloutFields.class, virtualPropertyReplacer, database), RolloutSpecification.isDeleted(deleted, pageable.getSort())); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaSoftwareModuleManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaSoftwareModuleManagement.java index 7e71ddf7c..a37b72eef 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaSoftwareModuleManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaSoftwareModuleManagement.java @@ -259,9 +259,9 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement { } @Override - public Page findByRsql(final String rsqlParam, final Pageable pageable) { + public Page findByRsql(final String rsql, final Pageable pageable) { return JpaManagementHelper.findAllWithCountBySpec(softwareModuleRepository, List.of( - RSQLUtility.buildRsqlSpecification(rsqlParam, SoftwareModuleFields.class, virtualPropertyReplacer, + RSQLUtility.buildRsqlSpecification(rsql, SoftwareModuleFields.class, virtualPropertyReplacer, database), SoftwareModuleSpecification.isNotDeleted()), pageable); } @@ -303,7 +303,7 @@ public class JpaSoftwareModuleManagement implements SoftwareModuleManagement { } @Override - public Page findMetaDataBySoftwareModuleIdAndTargetVisible(final Pageable pageable, final long id) { + public Page findMetaDataBySoftwareModuleIdAndTargetVisible(final long id, final Pageable pageable) { assertSoftwareModuleExists(id); return JpaManagementHelper.convertPage(softwareModuleMetadataRepository.findBySoftwareModuleIdAndTargetVisible( diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaSoftwareModuleTypeManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaSoftwareModuleTypeManagement.java index 49014cce0..2616920ef 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaSoftwareModuleTypeManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaSoftwareModuleTypeManagement.java @@ -142,9 +142,9 @@ public class JpaSoftwareModuleTypeManagement implements SoftwareModuleTypeManage } @Override - public Page findByRsql(final String rsqlParam, final Pageable pageable) { + public Page findByRsql(final String rsql, final Pageable pageable) { return JpaManagementHelper.findAllWithCountBySpec(softwareModuleTypeRepository, List.of( - RSQLUtility.buildRsqlSpecification(rsqlParam, SoftwareModuleTypeFields.class, + RSQLUtility.buildRsqlSpecification(rsql, SoftwareModuleTypeFields.class, virtualPropertyReplacer, database), SoftwareModuleTypeSpecification.isNotDeleted()), pageable ); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaTargetFilterQueryManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaTargetFilterQueryManagement.java index bbc946af1..0cf6cb2b6 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaTargetFilterQueryManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaTargetFilterQueryManagement.java @@ -172,7 +172,7 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme } @Override - public Slice findByName(final Pageable pageable, final String name) { + public Slice findByName(final String name, final Pageable pageable) { if (ObjectUtils.isEmpty(name)) { return findAll(pageable); } @@ -193,7 +193,7 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme } @Override - public Page findByRsql(final Pageable pageable, final String rsqlFilter) { + public Page findByRsql(final String rsqlFilter, final Pageable pageable) { final List> specList = !ObjectUtils.isEmpty(rsqlFilter) ? Collections.singletonList(RSQLUtility.buildRsqlSpecification(rsqlFilter, TargetFilterQueryFields.class, virtualPropertyReplacer, database)) @@ -203,7 +203,7 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme } @Override - public Slice findByQuery(final Pageable pageable, final String query) { + public Slice findByQuery(final String query, final Pageable pageable) { final List> specList = !ObjectUtils.isEmpty(query) ? Collections.singletonList(TargetFilterQuerySpecification.equalsQuery(query)) : Collections.emptyList(); @@ -212,8 +212,7 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme } @Override - public Slice findByAutoAssignDistributionSetId(@NotNull final Pageable pageable, - final long setId) { + public Slice findByAutoAssignDistributionSetId(final long setId, @NotNull final Pageable pageable) { final DistributionSet distributionSet = distributionSetManagement.getOrElseThrowException(setId); return JpaManagementHelper.findAllWithoutCountBySpec(targetFilterQueryRepository, @@ -222,14 +221,13 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme } @Override - public Page findByAutoAssignDSAndRsql(final Pageable pageable, final long setId, - final String rsqlFilter) { + public Page findByAutoAssignDSAndRsql(final long setId, final String rsql, final Pageable pageable) { final DistributionSet distributionSet = distributionSetManagement.getOrElseThrowException(setId); final List> specList = new ArrayList<>(2); specList.add(TargetFilterQuerySpecification.byAutoAssignDS(distributionSet)); - if (!ObjectUtils.isEmpty(rsqlFilter)) { - specList.add(RSQLUtility.buildRsqlSpecification(rsqlFilter, TargetFilterQueryFields.class, + if (!ObjectUtils.isEmpty(rsql)) { + specList.add(RSQLUtility.buildRsqlSpecification(rsql, TargetFilterQueryFields.class, virtualPropertyReplacer, database)); } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaTargetManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaTargetManagement.java index f5e250866..e2de12697 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaTargetManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaTargetManagement.java @@ -156,33 +156,33 @@ public class JpaTargetManagement implements TargetManagement { } @Override - public long countByRsql(final String targetFilterQuery) { + public long countByRsql(final String rsql) { return JpaManagementHelper.countBySpec( targetRepository, - List.of(RSQLUtility.buildRsqlSpecification(targetFilterQuery, TargetFields.class, virtualPropertyReplacer, database))); + List.of(RSQLUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database))); } @Override - public long countByRsqlAndUpdatable(String targetFilterQuery) { + public long countByRsqlAndUpdatable(String rsql) { final List> specList = List.of( - RSQLUtility.buildRsqlSpecification(targetFilterQuery, TargetFields.class, virtualPropertyReplacer, database)); + RSQLUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database)); return targetRepository.count( AccessController.Operation.UPDATE, combineWithAnd(specList)); } @Override - public long countByRsqlAndCompatible(final String targetFilterQuery, final Long distributionSetIdTypeId) { + public long countByRsqlAndCompatible(final String rsql, final Long distributionSetIdTypeId) { final List> specList = List.of( - RSQLUtility.buildRsqlSpecification(targetFilterQuery, TargetFields.class, virtualPropertyReplacer, database), + RSQLUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database), TargetSpecifications.isCompatibleWithDistributionSetType(distributionSetIdTypeId)); return JpaManagementHelper.countBySpec(targetRepository, specList); } @Override - public long countByRsqlAndCompatibleAndUpdatable(String targetFilterQuery, Long distributionSetIdTypeId) { + public long countByRsqlAndCompatibleAndUpdatable(String rsql, Long distributionSetIdTypeId) { final List> specList = List.of( - RSQLUtility.buildRsqlSpecification(targetFilterQuery, TargetFields.class, virtualPropertyReplacer, database), + RSQLUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database), TargetSpecifications.isCompatibleWithDistributionSetType(distributionSetIdTypeId)); return targetRepository.count(AccessController.Operation.UPDATE, combineWithAnd(specList)); } @@ -246,8 +246,8 @@ public class JpaTargetManagement implements TargetManagement { } @Override - public Slice findByTargetFilterQueryAndNonDSAndCompatibleAndUpdatable(final Pageable pageRequest, - final long distributionSetId, final String targetFilterQuery) { + public Slice findByTargetFilterQueryAndNonDSAndCompatibleAndUpdatable(final long distributionSetId, final String rsql, + final Pageable pageable) { final DistributionSet jpaDistributionSet = distributionSetManagement.getOrElseThrowException(distributionSetId); final Long distSetTypeId = jpaDistributionSet.getType().getId(); @@ -255,15 +255,15 @@ public class JpaTargetManagement implements TargetManagement { .findAllWithoutCount( AccessController.Operation.UPDATE, combineWithAnd(List.of( - RSQLUtility.buildRsqlSpecification(targetFilterQuery, TargetFields.class, virtualPropertyReplacer, database), + RSQLUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database), TargetSpecifications.hasNotDistributionSetInActions(distributionSetId), TargetSpecifications.isCompatibleWithDistributionSetType(distSetTypeId))), - pageRequest) + pageable) .map(Target.class::cast); } @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 Long distSetTypeId = jpaDistributionSet.getType().getId(); @@ -271,35 +271,35 @@ public class JpaTargetManagement implements TargetManagement { AccessController.Operation.UPDATE, combineWithAnd(List.of( RSQLUtility.buildRsqlSpecification( - targetFilterQuery, TargetFields.class, virtualPropertyReplacer, database), + rsql, TargetFields.class, virtualPropertyReplacer, database), TargetSpecifications.hasNotDistributionSetInActions(distributionSetId), TargetSpecifications.isCompatibleWithDistributionSetType(distSetTypeId)))); } @Override public Slice findByTargetFilterQueryAndNotInRolloutAndCompatibleAndUpdatable( - final Pageable pageRequest, final Collection groups, final String targetFilterQuery, final DistributionSetType dsType) { + final Collection groups, final String targetFilterQuery, final DistributionSetType dsType, final Pageable pageable) { return targetRepository .findAllWithoutCount(AccessController.Operation.UPDATE, combineWithAnd(List.of( RSQLUtility.buildRsqlSpecification(targetFilterQuery, TargetFields.class, virtualPropertyReplacer, database), TargetSpecifications.isNotInRolloutGroups(groups), TargetSpecifications.isCompatibleWithDistributionSetType(dsType.getId()))), - pageRequest) + pageable) .map(Target.class::cast); } @Override public Slice findByTargetFilterQueryAndNoOverridingActionsAndNotInRolloutAndCompatibleAndUpdatable( - final Pageable pageRequest, final long rolloutId, final int weight, final long firstGroupId, final String targetFilterQuery, - final DistributionSetType distributionSetType) { + final long rolloutId, final int weight, final long firstGroupId, final String targetFilterQuery, + final DistributionSetType distributionSetType, final Pageable pageable) { return targetRepository .findAllWithoutCount(AccessController.Operation.UPDATE, combineWithAnd(List.of( RSQLUtility.buildRsqlSpecification(targetFilterQuery, TargetFields.class, virtualPropertyReplacer, database), TargetSpecifications.hasNoOverridingActionsAndNotInRollout(weight, rolloutId), TargetSpecifications.isCompatibleWithDistributionSetType(distributionSetType.getId()))), - pageRequest) + pageable) .map(Target.class::cast); } @@ -309,21 +309,20 @@ public class JpaTargetManagement implements TargetManagement { } @Override - public Slice findByFailedRolloutAndNotInRolloutGroups(Pageable pageRequest, Collection groups, - String rolloutId) { + public Slice findByFailedRolloutAndNotInRolloutGroups(String rolloutId, Collection groups, Pageable pageable) { final List> specList = List.of( TargetSpecifications.failedActionsForRollout(rolloutId), TargetSpecifications.isNotInRolloutGroups(groups)); - return JpaManagementHelper.findAllWithCountBySpec(targetRepository, specList, pageRequest); + return JpaManagementHelper.findAllWithCountBySpec(targetRepository, specList, pageable); } @Override public long countByRsqlAndNotInRolloutGroupsAndCompatibleAndUpdatable( - final String targetFilterQuery, final Collection groups, final DistributionSetType dsType) { + final String rsql, final Collection groups, final DistributionSetType dsType) { return targetRepository.count(AccessController.Operation.UPDATE, combineWithAnd(List.of( - RSQLUtility.buildRsqlSpecification(targetFilterQuery, TargetFields.class, virtualPropertyReplacer, database), + RSQLUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database), TargetSpecifications.isNotInRolloutGroups(groups), TargetSpecifications.isCompatibleWithDistributionSetType(dsType.getId())))); } @@ -337,33 +336,33 @@ public class JpaTargetManagement implements TargetManagement { } @Override - public Slice findByInRolloutGroupWithoutAction(final Pageable pageRequest, final long group) { + public Slice findByInRolloutGroupWithoutAction(final long group, final Pageable pageable) { if (!rolloutGroupRepository.existsById(group)) { throw new EntityNotFoundException(RolloutGroup.class, group); } return JpaManagementHelper.findAllWithoutCountBySpec( - targetRepository, List.of(TargetSpecifications.hasNoActionInRolloutGroup(group)), pageRequest); + targetRepository, List.of(TargetSpecifications.hasNoActionInRolloutGroup(group)), pageable); } @Override - public Page findByAssignedDistributionSet(final Pageable pageReq, final long distributionSetId) { + public Page findByAssignedDistributionSet(final long distributionSetId, final Pageable pageable) { final DistributionSet validDistSet = distributionSetManagement.getOrElseThrowException(distributionSetId); return JpaManagementHelper.findAllWithCountBySpec( targetRepository, - List.of(TargetSpecifications.hasAssignedDistributionSet(validDistSet.getId())), pageReq); + List.of(TargetSpecifications.hasAssignedDistributionSet(validDistSet.getId())), pageable); } @Override - public Page findByAssignedDistributionSetAndRsql(final Pageable pageReq, final long distributionSetId, final String rsqlParam) { + public Page findByAssignedDistributionSetAndRsql(final long distributionSetId, final String rsql, final Pageable pageable) { final DistributionSet validDistSet = distributionSetManagement.getOrElseThrowException(distributionSetId); final List> specList = List.of( - RSQLUtility.buildRsqlSpecification(rsqlParam, TargetFields.class, virtualPropertyReplacer, database), + RSQLUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database), TargetSpecifications.hasAssignedDistributionSet(validDistSet.getId())); - return JpaManagementHelper.findAllWithCountBySpec(targetRepository, specList, pageReq); + return JpaManagementHelper.findAllWithCountBySpec(targetRepository, specList, pageable); } @Override @@ -382,13 +381,13 @@ public class JpaTargetManagement implements TargetManagement { } @Override - public Slice findByFilters(final Pageable pageable, final FilterParams filterParams) { + public Slice findByFilters(final FilterParams filterParams, final Pageable pageable) { final List> specList = buildSpecificationList(filterParams); return JpaManagementHelper.findAllWithoutCountBySpec(targetRepository, specList, pageable); } @Override - public Page findByInstalledDistributionSet(final Pageable pageReq, final long distributionSetId) { + public Page findByInstalledDistributionSet(final long distributionSetId, final Pageable pageReq) { final DistributionSet validDistSet = distributionSetManagement.getOrElseThrowException(distributionSetId); return JpaManagementHelper.findAllWithCountBySpec( @@ -396,18 +395,18 @@ public class JpaTargetManagement implements TargetManagement { } @Override - public Page findByInstalledDistributionSetAndRsql(final Pageable pageable, final long distributionSetId, final String rsqlParam) { + public Page findByInstalledDistributionSetAndRsql(final long distributionSetId, final String rsql, final Pageable pageable) { final DistributionSet validDistSet = distributionSetManagement.getOrElseThrowException(distributionSetId); final List> specList = List.of( - RSQLUtility.buildRsqlSpecification(rsqlParam, TargetFields.class, virtualPropertyReplacer, database), + RSQLUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database), TargetSpecifications.hasInstalledDistributionSet(validDistSet.getId())); return JpaManagementHelper.findAllWithCountBySpec(targetRepository, specList, pageable); } @Override - public Page findByUpdateStatus(final Pageable pageable, final TargetUpdateStatus status) { + public Page findByUpdateStatus(final TargetUpdateStatus status, final Pageable pageable) { return JpaManagementHelper.findAllWithCountBySpec( targetRepository, List.of(TargetSpecifications.hasTargetUpdateStatus(status)), pageable); } @@ -418,15 +417,15 @@ public class JpaTargetManagement implements TargetManagement { } @Override - public Slice findByRsql(final Pageable pageable, final String targetFilterQuery) { + public Slice findByRsql(final String rsql, final Pageable pageable) { return JpaManagementHelper.findAllWithoutCountBySpec( targetRepository, - List.of(RSQLUtility.buildRsqlSpecification(targetFilterQuery, TargetFields.class, virtualPropertyReplacer, database)), pageable + List.of(RSQLUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database)), pageable ); } @Override - public Slice findByTargetFilterQuery(final Pageable pageable, final long targetFilterQueryId) { + public Slice findByTargetFilterQuery(final long targetFilterQueryId, final Pageable pageable) { final TargetFilterQuery targetFilterQuery = targetFilterQueryRepository.findById(targetFilterQueryId) .orElseThrow(() -> new EntityNotFoundException(TargetFilterQuery.class, targetFilterQueryId)); @@ -437,17 +436,17 @@ public class JpaTargetManagement implements TargetManagement { } @Override - public Page findByTag(final Pageable pageable, final long tagId) { + public Page findByTag(final long tagId, final Pageable pageable) { throwEntityNotFoundExceptionIfTagDoesNotExist(tagId); return JpaManagementHelper.findAllWithCountBySpec(targetRepository, List.of(TargetSpecifications.hasTag(tagId)), pageable); } @Override - public Page findByRsqlAndTag(final Pageable pageable, final String rsqlParam, final long tagId) { + public Page findByRsqlAndTag(final String rsql, final long tagId, final Pageable pageable) { throwEntityNotFoundExceptionIfTagDoesNotExist(tagId); final List> specList = List.of( - RSQLUtility.buildRsqlSpecification(rsqlParam, TargetFields.class, virtualPropertyReplacer, database), + RSQLUtility.buildRsqlSpecification(rsql, TargetFields.class, virtualPropertyReplacer, database), TargetSpecifications.hasTag(tagId)); return JpaManagementHelper.findAllWithCountBySpec(targetRepository, specList, pageable); @@ -665,9 +664,9 @@ public class JpaTargetManagement implements TargetManagement { } @Override - public Page findByControllerAttributesRequested(final Pageable pageReq) { + public Page findByControllerAttributesRequested(final Pageable pageable) { return JpaManagementHelper.findAllWithCountBySpec( - targetRepository, List.of(TargetSpecifications.hasRequestControllerAttributesTrue()), pageReq); + targetRepository, List.of(TargetSpecifications.hasRequestControllerAttributesTrue()), pageable); } @Override diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaTargetTagManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaTargetTagManagement.java index 363d4581d..db2f157aa 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaTargetTagManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaTargetTagManagement.java @@ -103,9 +103,9 @@ public class JpaTargetTagManagement implements TargetTagManagement { } @Override - public Page findByRsql(final Pageable pageable, final String rsqlParam) { + public Page findByRsql(final String rsql, final Pageable pageable) { return JpaManagementHelper.findAllWithCountBySpec(targetTagRepository, Collections.singletonList( - RSQLUtility.buildRsqlSpecification(rsqlParam, TargetTagFields.class, virtualPropertyReplacer, database)), pageable); + RSQLUtility.buildRsqlSpecification(rsql, TargetTagFields.class, virtualPropertyReplacer, database)), pageable); } @Override diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaTargetTypeManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaTargetTypeManagement.java index 654cf8a6b..ef49d4535 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaTargetTypeManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaTargetTypeManagement.java @@ -144,15 +144,15 @@ public class JpaTargetTypeManagement implements TargetTypeManagement { } @Override - public Page findByRsql(final Pageable pageable, final String rsqlParam) { + public Page findByRsql(final String rsql, final Pageable pageable) { return JpaManagementHelper.findAllWithCountBySpec(targetTypeRepository, List.of( RSQLUtility.buildRsqlSpecification( - rsqlParam, TargetTypeFields.class, virtualPropertyReplacer, database)), pageable + rsql, TargetTypeFields.class, virtualPropertyReplacer, database)), pageable ); } @Override - public Slice findByName(final Pageable pageable, final String name) { + public Slice findByName(final String name, final Pageable pageable) { return JpaManagementHelper.findAllWithoutCountBySpec(targetTypeRepository, List.of(TargetTypeSpecification.likeName(name)), pageable ); } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/acm/controller/DistributionSetAccessControllerTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/acm/controller/DistributionSetAccessControllerTest.java index 5c9658652..b6e963738 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/acm/controller/DistributionSetAccessControllerTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/acm/controller/DistributionSetAccessControllerTest.java @@ -78,7 +78,7 @@ class DistributionSetAccessControllerTest extends AbstractAccessControllerTest { .toList()).containsOnly(permittedActionId); // 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); // verify distributionSetManagement#findByDistributionSetFilter diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/acm/controller/TargetAccessControllerTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/acm/controller/TargetAccessControllerTest.java index eee8a7ce0..ac5a30fc0 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/acm/controller/TargetAccessControllerTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/acm/controller/TargetAccessControllerTest.java @@ -68,11 +68,11 @@ class TargetAccessControllerTest extends AbstractAccessControllerTest { .containsOnly(permittedTarget.getId()); // 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()); // 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()); // verify targetManagement#getByControllerID @@ -105,11 +105,11 @@ class TargetAccessControllerTest extends AbstractAccessControllerTest { .create(entityFactory.targetFilterQuery().create().name("test").query("id==*")); // 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()); // 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()); } @@ -145,11 +145,11 @@ class TargetAccessControllerTest extends AbstractAccessControllerTest { // verify targetManagement#findByTag 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()); // 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()); // verify targetManagement#assignTag on permitted target @@ -228,7 +228,7 @@ class TargetAccessControllerTest extends AbstractAccessControllerTest { overwriteAccess(AccessController.Operation.READ, permittedTarget); // 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()); testAccessControlManger.defineAccessRule( @@ -241,11 +241,11 @@ class TargetAccessControllerTest extends AbstractAccessControllerTest { assertThatThrownBy(() -> assignDistributionSet(dsId, hiddenTargetControllerId)).isInstanceOf(AssertionError.class); // verify targetManagement#findByUpdateStatus(REGISTERED) after assignment - assertThat(targetManagement.findByUpdateStatus(Pageable.unpaged(), TargetUpdateStatus.REGISTERED) + assertThat(targetManagement.findByUpdateStatus(TargetUpdateStatus.REGISTERED, Pageable.unpaged()) .getTotalElements()).isZero(); // 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()); } @@ -364,7 +364,7 @@ class TargetAccessControllerTest extends AbstractAccessControllerTest { autoAssignChecker.checkAllTargets(); - assertThat(targetManagement.findByAssignedDistributionSet(Pageable.unpaged(), distributionSet.getId()) + assertThat(targetManagement.findByAssignedDistributionSet(distributionSet.getId(), Pageable.unpaged()) .getContent()) .hasSize(updateTargets.size()) .allMatch(assignedTarget -> updateTargets.stream() diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/acm/controller/TargetTypeAccessControllerTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/acm/controller/TargetTypeAccessControllerTest.java index c734bda47..03fa19ff6 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/acm/controller/TargetTypeAccessControllerTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/acm/controller/TargetTypeAccessControllerTest.java @@ -50,14 +50,14 @@ class TargetTypeAccessControllerTest extends AbstractAccessControllerTest { .containsOnly(permittedTargetType.getId()); // 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()); // verify targetTypeManagement#findByName - assertThat(targetTypeManagement.findByName(Pageable.unpaged(), permittedTargetType.getName()).getContent()) + assertThat(targetTypeManagement.findByName(permittedTargetType.getName(), Pageable.unpaged()).getContent()) .hasSize(1).satisfies(results -> 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 assertThat(targetTypeManagement.count()).isEqualTo(1); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/autoassign/AutoAssignCheckerIntTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/autoassign/AutoAssignCheckerIntTest.java index 4596e1571..e20443568 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/autoassign/AutoAssignCheckerIntTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/autoassign/AutoAssignCheckerIntTest.java @@ -434,7 +434,7 @@ class AutoAssignCheckerIntTest extends AbstractJpaIntegrationTest { private void verifyThatTargetsHaveDistributionSetAssignedAndActionStatus(final DistributionSet set, final List targets, final Action.Status status) { final List targetIds = targets.stream().map(Target::getControllerId).toList(); - final List targetsWithAssignedDS = targetManagement.findByAssignedDistributionSet(PAGE, set.getId()).getContent(); + final List targetsWithAssignedDS = targetManagement.findByAssignedDistributionSet(set.getId(), PAGE).getContent(); assertThat(targetsWithAssignedDS).isNotEmpty(); assertThat(targetsWithAssignedDS).allMatch(target -> targetIds.contains(target.getControllerId())); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ArtifactManagementSecurityTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ArtifactManagementSecurityTest.java index 6d9d65675..e0e2dedae 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ArtifactManagementSecurityTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ArtifactManagementSecurityTest.java @@ -81,7 +81,7 @@ class ArtifactManagementSecurityTest extends AbstractJpaIntegrationTest { @Test @Description("Tests ArtifactManagement#findBySoftwareModule() method") void findBySoftwareModulePermissionCheck() { - assertPermissions(() -> artifactManagement.findBySoftwareModule(PAGE, 1L), List.of(SpPermission.READ_REPOSITORY)); + assertPermissions(() -> artifactManagement.findBySoftwareModule(1L, PAGE), List.of(SpPermission.READ_REPOSITORY)); } @Test diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ArtifactManagementTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ArtifactManagementTest.java index 339d4284d..16ce65614 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ArtifactManagementTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ArtifactManagementTest.java @@ -94,7 +94,7 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest { 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(); verifyThrownExceptionBy(() -> artifactManagement.getByFilenameAndSoftwareModule("xxx", NOT_EXIST_IDL), "SoftwareModule"); @@ -170,7 +170,7 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest { for (int i = 0; i < maxArtifacts; ++i) { 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 assertThatExceptionOfType(AssignmentQuotaExceededException.class) @@ -178,12 +178,12 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest { // delete one of the artifacts artifactManagement.delete(artifactIds.get(0)); - assertThat(artifactManagement.findBySoftwareModule(PAGE, smId).getTotalElements()) + assertThat(artifactManagement.findBySoftwareModule(smId, PAGE).getTotalElements()) .isEqualTo(maxArtifacts - 1); // now we should be able to create an artifact again createArtifactForSoftwareModule("fileXYZ", smId, artifactSize); - assertThat(artifactManagement.findBySoftwareModule(PAGE, smId).getTotalElements()).isEqualTo(maxArtifacts); + assertThat(artifactManagement.findBySoftwareModule(smId, PAGE).getTotalElements()).isEqualTo(maxArtifacts); } @Test @@ -410,12 +410,12 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest { @Description("Searches an artifact through the relations of a software module.") void findArtifactBySoftwareModule() throws IOException { final SoftwareModule sm = testdataFactory.createSoftwareModuleOs(); - assertThat(artifactManagement.findBySoftwareModule(PAGE, sm.getId())).isEmpty(); + assertThat(artifactManagement.findBySoftwareModule(sm.getId(), PAGE)).isEmpty(); final int artifactSize = 5 * 1024; try (final InputStream input = new RandomGeneratedInputStream(artifactSize)) { createArtifactForSoftwareModule("file1", sm.getId(), artifactSize, input); - assertThat(artifactManagement.findBySoftwareModule(PAGE, sm.getId())).hasSize(1); + assertThat(artifactManagement.findBySoftwareModule(sm.getId(), PAGE)).hasSize(1); } } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ConfirmationManagementTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ConfirmationManagementTest.java index d415156e4..37ff2c950 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ConfirmationManagementTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ConfirmationManagementTest.java @@ -107,7 +107,7 @@ class ConfirmationManagementTest extends AbstractJpaIntegrationTest { assertThat(confirmationManagement.findActiveActionsWaitingConfirmation(controllerId)).hasSize(1) .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); 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); // 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); } @@ -166,7 +166,7 @@ class ConfirmationManagementTest extends AbstractJpaIntegrationTest { assertThat(actions).hasSize(1).allMatch(action -> action.getStatus() == Status.WAIT_FOR_CONFIRMATION); assertThat(confirmationManagement.findActiveActionsWaitingConfirmation(controllerId)).hasSize(1) .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); 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); // 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); } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ControllerManagementSecurityTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ControllerManagementSecurityTest.java index 89e99ee8e..07c63dab2 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ControllerManagementSecurityTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ControllerManagementSecurityTest.java @@ -18,10 +18,8 @@ import io.qameta.allure.Feature; import io.qameta.allure.Story; import org.eclipse.hawkbit.im.authentication.SpPermission; 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.model.JpaAction; -import org.eclipse.hawkbit.repository.jpa.model.JpaTarget; import org.eclipse.hawkbit.repository.model.Target; import org.junit.jupiter.api.Test; import org.springframework.data.domain.Pageable; @@ -87,7 +85,7 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest { @Test @Description("Tests ControllerManagement#findActionStatusByAction() method") void findActionStatusByActionPermissionsCheck() { - assertPermissions(() -> controllerManagement.findActionStatusByAction(Pageable.unpaged(), 1L), + assertPermissions(() -> controllerManagement.findActionStatusByAction(1L, Pageable.unpaged()), List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE)); } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ControllerManagementTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ControllerManagementTest.java index 28c1c7ddd..a1ab1311d 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ControllerManagementTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ControllerManagementTest.java @@ -209,7 +209,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { final List 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); 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"); @@ -304,7 +304,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { Action.Status.DOWNLOAD, true); 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(); } @@ -357,7 +357,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { () -> controllerManagement.getActionForDownloadByTargetAndSoftwareModule(NOT_EXIST_ID, module.getId()), "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_ID, "XXX"), "Target"); @@ -392,7 +392,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { Action.Status.FINISHED, false); assertThat(actionStatusRepository.count()).isEqualTo(7); - assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(7); + assertThat(controllerManagement.findActionStatusByAction(actionId, PAGE).getNumberOfElements()).isEqualTo(7); } @Test @@ -424,7 +424,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { .isThrownBy(() -> controllerManagement.addUpdateActionStatus(statusMulipleMessages)); assertThat(actionStatusRepository.count()).isEqualTo(6); - assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(6); + assertThat(controllerManagement.findActionStatusByAction(actionId, PAGE).getNumberOfElements()).isEqualTo(6); } @Test @@ -452,7 +452,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { Action.Status.FINISHED, false); assertThat(actionStatusRepository.count()).isEqualTo(3); - assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(3); + assertThat(controllerManagement.findActionStatusByAction(actionId, PAGE).getNumberOfElements()).isEqualTo(3); } @Test @@ -477,7 +477,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { assertActionStatus(actionId, DEFAULT_CONTROLLER_ID, TargetUpdateStatus.PENDING, Action.Status.RUNNING, Action.Status.RUNNING, true); assertThat(actionStatusRepository.count()).isEqualTo(1); - assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(1); + assertThat(controllerManagement.findActionStatusByAction(actionId, PAGE).getNumberOfElements()).isEqualTo(1); } @Test @@ -508,7 +508,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { Action.Status.FINISHED, false); assertThat(actionStatusRepository.count()).isEqualTo(8); - assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(8); + assertThat(controllerManagement.findActionStatusByAction(actionId, PAGE).getNumberOfElements()).isEqualTo(8); } @Test @@ -539,7 +539,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { Action.Status.CANCELED, false); assertThat(actionStatusRepository.count()).isEqualTo(8); - assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(8); + assertThat(controllerManagement.findActionStatusByAction(actionId, PAGE).getNumberOfElements()).isEqualTo(8); } @Test @@ -571,7 +571,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { Action.Status.CANCEL_REJECTED, true); assertThat(actionStatusRepository.count()).isEqualTo(8); - assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(8); + assertThat(controllerManagement.findActionStatusByAction(actionId, PAGE).getNumberOfElements()).isEqualTo(8); } @Test @@ -603,7 +603,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { Action.Status.ERROR, true); assertThat(actionStatusRepository.count()).isEqualTo(8); - assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(8); + assertThat(controllerManagement.findActionStatusByAction(actionId, PAGE).getNumberOfElements()).isEqualTo(8); } @Test @@ -985,7 +985,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { assertActionStatus(actionId, DEFAULT_CONTROLLER_ID, TargetUpdateStatus.ERROR, Action.Status.ERROR, Action.Status.ERROR, false); assertThat(actionStatusRepository.count()).isEqualTo(3); - assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(3); + assertThat(controllerManagement.findActionStatusByAction(actionId, PAGE).getNumberOfElements()).isEqualTo(3); } @Test @@ -1018,7 +1018,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { assertActionStatus( actionId, DEFAULT_CONTROLLER_ID, TargetUpdateStatus.IN_SYNC, Action.Status.FINISHED, Action.Status.FINISHED, false); assertThat(actionStatusRepository.count()).isEqualTo(3); - assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(3); + assertThat(controllerManagement.findActionStatusByAction(actionId, PAGE).getNumberOfElements()).isEqualTo(3); } @Test @@ -1047,7 +1047,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { assertThat(actionRepository.findById(action.getId())) .hasValueSatisfying(a -> assertThat(a.getStatus()).isEqualTo(Status.FINISHED)); assertThat(actionStatusRepository.count()).isEqualTo(3); - assertThat(controllerManagement.findActionStatusByAction(PAGE, action.getId()).getNumberOfElements()) + assertThat(controllerManagement.findActionStatusByAction(action.getId(), PAGE).getNumberOfElements()) .isEqualTo(3); } @@ -1075,7 +1075,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { assertThat(targetManagement.getByControllerID(DEFAULT_CONTROLLER_ID).get().getUpdateStatus()).isEqualTo(TargetUpdateStatus.IN_SYNC); // however, additional action status has been stored 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 @@ -1148,7 +1148,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { actionId, DEFAULT_CONTROLLER_ID, TargetUpdateStatus.IN_SYNC, Action.Status.DOWNLOADED, Action.Status.DOWNLOADED, false); 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(); } @@ -1175,7 +1175,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { Action.Status.FINISHED, false); 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(); } @@ -1203,7 +1203,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { Status.DOWNLOADED, false); 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(); } @@ -1627,7 +1627,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { assertThat(targetManagement.getByControllerID(DEFAULT_CONTROLLER_ID).get().getUpdateStatus()) .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 @@ -1637,7 +1637,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { assignDistributionSet(dsId, defaultControllerId, DOWNLOAD_ONLY); 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(); return id; } @@ -1648,7 +1648,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { assertThat(targetManagement.getByControllerID(defaultControllerId).get().getUpdateStatus()) .isEqualTo(TargetUpdateStatus.PENDING); - final Long id = deploymentManagement.findActiveActionsByTarget(PAGE, defaultControllerId).getContent().get(0) + final Long id = deploymentManagement.findActiveActionsByTarget(defaultControllerId, PAGE).getContent().get(0) .getId(); assertThat(id).isNotNull(); return id; @@ -1720,7 +1720,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { final Action action = deploymentManagement.findAction(actionId).get(); assertThat(action.getStatus()).isEqualTo(expectedActionActionStatus); assertThat(action.isActive()).isEqualTo(actionActive); - final List actionStatusList = controllerManagement.findActionStatusByAction(PAGE, actionId).getContent(); + final List actionStatusList = controllerManagement.findActionStatusByAction(actionId, PAGE).getContent(); assertThat(actionStatusList.get(actionStatusList.size() - 1).getStatus()).isEqualTo(expectedActionStatus); if (actionActive) { assertThat(controllerManagement.findActiveActionWithHighestWeight(controllerId).get().getId()).isEqualTo(actionId); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DeploymentManagementSecurityTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DeploymentManagementSecurityTest.java index 37b53e3cf..2d6293dc2 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DeploymentManagementSecurityTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DeploymentManagementSecurityTest.java @@ -122,7 +122,7 @@ class DeploymentManagementSecurityTest extends AbstractJpaIntegrationTest { @Test @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") 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 @@ -134,7 +134,7 @@ class DeploymentManagementSecurityTest extends AbstractJpaIntegrationTest { @Test @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") void findMessagesByActionStatusIdPermissionsCheck() { - assertPermissions(() -> deploymentManagement.findMessagesByActionStatusId(PAGE, 1L), List.of(SpPermission.READ_TARGET)); + assertPermissions(() -> deploymentManagement.findMessagesByActionStatusId(1L, PAGE), List.of(SpPermission.READ_TARGET)); } @Test @@ -146,14 +146,14 @@ class DeploymentManagementSecurityTest extends AbstractJpaIntegrationTest { @Test @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") void findActiveActionsByTargetPermissionsCheck() { - assertPermissions(() -> deploymentManagement.findActiveActionsByTarget(Pageable.unpaged(), "controllerId"), + assertPermissions(() -> deploymentManagement.findActiveActionsByTarget("controllerId", Pageable.unpaged()), List.of(SpPermission.READ_TARGET)); } @Test @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") void findInActiveActionsByTargetPermissionsCheck() { - assertPermissions(() -> deploymentManagement.findInActiveActionsByTarget(Pageable.unpaged(), "controllerId"), + assertPermissions(() -> deploymentManagement.findInActiveActionsByTarget("controllerId", Pageable.unpaged()), List.of(SpPermission.READ_TARGET)); } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DeploymentManagementTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DeploymentManagementTest.java index 43c258ea5..4a8181b44 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DeploymentManagementTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DeploymentManagementTest.java @@ -77,7 +77,6 @@ import org.eclipse.hawkbit.repository.model.DeploymentRequest; import org.eclipse.hawkbit.repository.model.DeploymentRequestBuilder; import org.eclipse.hawkbit.repository.model.DistributionSet; 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.SoftwareModule; 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("id==*", NOT_EXIST_ID, PAGE), "Target"); - verifyThrownExceptionBy(() -> deploymentManagement.findActiveActionsByTarget(PAGE, NOT_EXIST_ID), "Target"); - verifyThrownExceptionBy(() -> deploymentManagement.findInActiveActionsByTarget(PAGE, NOT_EXIST_ID), "Target"); + verifyThrownExceptionBy(() -> deploymentManagement.findActiveActionsByTarget(NOT_EXIST_ID, PAGE), "Target"); + verifyThrownExceptionBy(() -> deploymentManagement.findInActiveActionsByTarget(NOT_EXIST_ID, PAGE), "Target"); verifyThrownExceptionBy(() -> deploymentManagement.forceQuitAction(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); // act - final Page actionStates = deploymentManagement.findActionStatusByAction(PAGE, actionId); + final Page actionStates = deploymentManagement.findActionStatusByAction(actionId, PAGE); assertThat(actionStates.getContent()).hasSize(1); 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 controllerManagement.addUpdateActionStatus(entityFactory.actionStatus().create(actionId) .status(Action.Status.FINISHED).messages(Collections.singletonList("finished message"))); - final Page actionStates = deploymentManagement.findActionStatusByAction(PAGE, actionId); + final Page actionStates = deploymentManagement.findActionStatusByAction(actionId, PAGE); // find newly created action-status entry with message final JpaActionStatus actionStatusWithMessage = actionStates.getContent().stream() @@ -263,7 +262,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { final String expectedMsg = actionStatusWithMessage.getMessages().get(0); // act - final Page messages = deploymentManagement.findMessagesByActionStatusId(PAGE, actionStatusWithMessage.getId()); + final Page messages = deploymentManagement.findMessagesByActionStatusId(actionStatusWithMessage.getId(), PAGE); assertThat(actionStates.getTotalElements()).as("Two action-states in total").isEqualTo(2L); 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(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) - .containsAll(targetManagement.findByAssignedDistributionSet(PAGE, ds.getId())) + .containsAll(targetManagement.findByAssignedDistributionSet(ds.getId(), PAGE)) .as("InstallationDate set").allMatch(target -> target.getInstallationDate() >= current) .as("TargetUpdateStatus IN_SYNC") .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, 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)); } finally { @@ -1050,7 +1049,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { for (final Target myt : savedDeployedTargets) { final Target t = targetManagement.getByControllerID(myt.getControllerId()).get(); - final List activeActionsByTarget = deploymentManagement.findActiveActionsByTarget(PAGE, t.getControllerId()).getContent(); + final List activeActionsByTarget = deploymentManagement.findActiveActionsByTarget(t.getControllerId(), PAGE).getContent(); assertThat(activeActionsByTarget).as("action should not be empty").isNotEmpty(); assertThat(t.getUpdateStatus()).as("wrong target update status").isEqualTo(TargetUpdateStatus.PENDING); for (final Action ua : activeActionsByTarget) { @@ -1211,7 +1210,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { .as("installed ds is wrong").contains(dsA); assertThat(targetManagement.getByControllerID(t.getControllerId()).get().getUpdateStatus()) .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(); } @@ -1281,7 +1280,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { } // verify that deleted attribute is used correctly - List allFoundDS = distributionSetManagement.findByCompleted(PAGE, true).getContent(); + List allFoundDS = distributionSetManagement.findByCompleted(true, PAGE).getContent(); assertThat(allFoundDS).as("no ds should be founded").isEmpty(); assertThat(distributionSetRepository.findAll(SpecificationsBuilder.combineWithAnd(Arrays @@ -1297,7 +1296,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { // has been installed // successfully and no activeAction is referring to created distribution // sets - allFoundDS = distributionSetManagement.findByCompleted(pageRequest, true).getContent(); + allFoundDS = distributionSetManagement.findByCompleted(true, pageRequest).getContent(); assertThat(allFoundDS).as("no ds should be founded").isEmpty(); assertThat(distributionSetRepository.findAll(SpecificationsBuilder.combineWithAnd(Arrays .asList(DistributionSetSpecification.isDeleted(true), DistributionSetSpecification.isCompleted(true))), @@ -1353,16 +1352,16 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { .isEqualTo(distributionSetManagement.getWithDetails(dsA.getId()).get().getOptLockRevision()); // 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); assertThat(deploymentManagement.countActionsByTarget(targ.getControllerId())).as("Target actions are wrong") .isEqualTo(1); assertThat(targ.getUpdateStatus()).as("UpdateStatus of target is wrong").isEqualTo(TargetUpdateStatus.PENDING); assertThat(deploymentManagement.getAssignedDistributionSet(targ.getControllerId())) .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); - 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(); final Slice updAct = findActionsByDistributionSet(PAGE, dsA.getId()); @@ -1371,10 +1370,10 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { 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"); assertEquals(1, - deploymentManagement.findInActiveActionsByTarget(PAGE, targ.getControllerId()).getTotalElements(), + deploymentManagement.findInActiveActionsByTarget(targ.getControllerId(), PAGE).getTotalElements(), "active actions are wrong"); assertEquals(TargetUpdateStatus.IN_SYNC, targ.getUpdateStatus(), "tagret update status is not correct"); @@ -1389,7 +1388,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { targ = targs.iterator().next(); - assertEquals(1, deploymentManagement.findActiveActionsByTarget(PAGE, targ.getControllerId()).getTotalElements(), + assertEquals(1, deploymentManagement.findActiveActionsByTarget(targ.getControllerId(), PAGE).getTotalElements(), "active actions are wrong"); assertEquals(TargetUpdateStatus.PENDING, targetManagement.getByControllerID(targ.getControllerId()).get().getUpdateStatus(), @@ -1399,7 +1398,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { assertEquals(dsA.getId(), deploymentManagement.getInstalledDistributionSet(targ.getControllerId()).get().getId(), "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"); } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetManagementSecurityTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetManagementSecurityTest.java index 6090c55a5..149d93579 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetManagementSecurityTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetManagementSecurityTest.java @@ -158,7 +158,7 @@ class DistributionSetManagementSecurityTest @Test @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") void findByCompletedPermissionsCheck() { - assertPermissions(() -> distributionSetManagement.findByCompleted(PAGE, true), List.of(SpPermission.READ_REPOSITORY)); + assertPermissions(() -> distributionSetManagement.findByCompleted(true, PAGE), List.of(SpPermission.READ_REPOSITORY)); } @Test diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetManagementTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetManagementTest.java index 665601c57..98e54d48c 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetManagementTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetManagementTest.java @@ -579,7 +579,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest { void findDistributionSetsWithoutLazy() { testdataFactory.createDistributionSets(20); - assertThat(distributionSetManagement.findByCompleted(PAGE, true)).hasSize(20); + assertThat(distributionSetManagement.findByCompleted(true, PAGE)).hasSize(20); } @Test @@ -729,7 +729,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest { distributionSetManagement.delete(ds1.getId()); // not assigned so not marked as deleted but fully deleted assertThat(distributionSetRepository.findAll()).hasSize(1); - assertThat(distributionSetManagement.findByCompleted(PAGE, true)).hasSize(1); + assertThat(distributionSetManagement.findByCompleted(true, PAGE)).hasSize(1); } @Test @@ -791,7 +791,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest { // not assigned so not marked as deleted 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.findByRsql("name==*", PAGE)).hasSize(2); assertThat(distributionSetManagement.count()).isEqualTo(2); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetTagManagementSecurityTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetTagManagementSecurityTest.java index 1beb795e3..91e1a2249 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetTagManagementSecurityTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetTagManagementSecurityTest.java @@ -52,7 +52,7 @@ class DistributionSetTagManagementSecurityTest extends AbstractRepositoryManagem @Test @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") void findByDistributionSetPermissionsCheck() { - assertPermissions(() -> distributionSetTagManagement.findByDistributionSet(Pageable.unpaged(), 1L), + assertPermissions(() -> distributionSetTagManagement.findByDistributionSet(1L, Pageable.unpaged()), List.of(SpPermission.READ_REPOSITORY)); } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetTagManagementTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetTagManagementTest.java index 4b5b57356..e9f80a4be 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetTagManagementTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetTagManagementTest.java @@ -68,7 +68,7 @@ class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest { @Expect(type = TargetTagUpdatedEvent.class, count = 0) }) void entityQueriesReferringToNotExistingEntitiesThrowsException() { verifyThrownExceptionBy(() -> distributionSetTagManagement.delete(NOT_EXIST_ID), "DistributionSetTag"); - verifyThrownExceptionBy(() -> distributionSetTagManagement.findByDistributionSet(PAGE, NOT_EXIST_IDL), + verifyThrownExceptionBy(() -> distributionSetTagManagement.findByDistributionSet(NOT_EXIST_IDL, PAGE), "DistributionSet"); verifyThrownExceptionBy(() -> distributionSetTagManagement.update(entityFactory.tag().update(NOT_EXIST_IDL)), "DistributionSetTag"); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/RolloutGroupManagementSecurityTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/RolloutGroupManagementSecurityTest.java index 17cc3e120..5fd16ce13 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/RolloutGroupManagementSecurityTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/RolloutGroupManagementSecurityTest.java @@ -68,7 +68,7 @@ class RolloutGroupManagementSecurityTest extends AbstractJpaIntegrationTest { @Test @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") void findTargetsOfRolloutGroupByRsqlPermissionsCheck() { - assertPermissions(() -> rolloutGroupManagement.findTargetsOfRolloutGroupByRsql(PAGE, 1L, "name==*"), + assertPermissions(() -> rolloutGroupManagement.findTargetsOfRolloutGroupByRsql(1L, "name==*", PAGE), List.of(SpPermission.READ_ROLLOUT, SpPermission.READ_TARGET)); } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/RolloutGroupManagementTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/RolloutGroupManagementTest.java index 2f5cb0e92..594f3e641 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/RolloutGroupManagementTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/RolloutGroupManagementTest.java @@ -67,7 +67,7 @@ class RolloutGroupManagementTest extends AbstractJpaIntegrationTest { verifyThrownExceptionBy(() -> rolloutGroupManagement.findByRolloutAndRsql(NOT_EXIST_IDL, "name==*", PAGE), "Rollout"); 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 diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/RolloutManagementSecurityTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/RolloutManagementSecurityTest.java index b0542afac..e037cb3a1 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/RolloutManagementSecurityTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/RolloutManagementSecurityTest.java @@ -27,7 +27,6 @@ import org.eclipse.hawkbit.repository.model.Rollout; import org.eclipse.hawkbit.repository.model.RolloutGroupConditionBuilder; import org.eclipse.hawkbit.repository.test.util.WithUser; import org.junit.jupiter.api.Test; -import org.springframework.data.domain.PageImpl; @Slf4j @Feature("SecurityTests - RolloutManagement") @@ -127,26 +126,26 @@ class RolloutManagementSecurityTest extends AbstractJpaIntegrationTest { @Test @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") void findAllPermissionsCheck() { - assertPermissions(() -> rolloutManagement.findAll(PAGE, false), List.of(SpPermission.READ_ROLLOUT)); + assertPermissions(() -> rolloutManagement.findAll(false, PAGE), List.of(SpPermission.READ_ROLLOUT)); } @Test @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") 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 @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") void findAllWithDetailedStatusPermissionsCheck() { - assertPermissions(() -> rolloutManagement.findAllWithDetailedStatus(PAGE, false), List.of(SpPermission.READ_ROLLOUT)); + assertPermissions(() -> rolloutManagement.findAllWithDetailedStatus(false, PAGE), List.of(SpPermission.READ_ROLLOUT)); } @Test @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") void findByRsqlWithDetailedStatusPermissionsCheck() { assertPermissions(() -> - rolloutManagement.findByRsqlWithDetailedStatus(PAGE, "name==*", false), List.of(SpPermission.READ_ROLLOUT)); + rolloutManagement.findByRsqlWithDetailedStatus("name==*", false, PAGE), List.of(SpPermission.READ_ROLLOUT)); } @Test diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/RolloutManagementTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/RolloutManagementTest.java index 185914d0f..438f80892 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/RolloutManagementTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/RolloutManagementTest.java @@ -922,7 +922,7 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { expectedTargetCountStatus.put(TotalTargetCountStatus.Status.FINISHED, 9L); validateRolloutActionStatus(rolloutTwo.getId(), expectedTargetCountStatus); changeStatusForAllRunningActions(rolloutTwo, Status.FINISHED); - final Page targetPage = targetManagement.findByUpdateStatus(PAGE, TargetUpdateStatus.IN_SYNC); + final Page targetPage = targetManagement.findByUpdateStatus(TargetUpdateStatus.IN_SYNC, PAGE); final List targetList = targetPage.getContent(); // 15 targets in finished/IN_SYNC status and same DS assigned assertThat(targetList).hasSize(amountTargetsForRollout); @@ -1050,7 +1050,7 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { rolloutHandler.handleAll(); final Slice 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 rolloutList = rolloutPage.getContent(); // validate rolloutA -> 6 running and 6 ready @@ -1113,7 +1113,7 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { } final Slice 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 rolloutList = rollout.getContent(); assertThat(rolloutList).hasSize(5); int i = 1; @@ -1196,41 +1196,41 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { final String successCondition = "50"; final String errorCondition = "80"; final String rolloutName = "MyRollout"; - Rollout myRollout = createTestRolloutWithTargetsAndDistributionSet(amountTargetsForRollout, amountGroups, - successCondition, errorCondition, rolloutName, rolloutName); + Rollout myRollout = createTestRolloutWithTargetsAndDistributionSet( + amountTargetsForRollout, amountGroups, successCondition, errorCondition, rolloutName, rolloutName); testdataFactory.createTargets(amountOtherTargets, "others-", "rollout"); - final String rsqlParam = "controllerId==*MyRoll*"; + final String rsql = "controllerId==*MyRoll*"; rolloutManagement.start(myRollout.getId()); // Run here, because scheduler is disabled during tests rolloutHandler.handleAll(); - final Condition targetBelongsInRollout = new Condition<>(s -> s.startsWith(rolloutName), - "Target belongs into rollout"); + final Condition targetBelongsInRollout = new Condition<>(s -> s.startsWith(rolloutName), "Target belongs into rollout"); myRollout = reloadRollout(myRollout); - final List rolloutGroups = rolloutGroupManagement.findByRollout(myRollout.getId(), PAGE) - .getContent(); + final List rolloutGroups = rolloutGroupManagement.findByRollout(myRollout.getId(), PAGE).getContent(); Page targetPage = rolloutGroupManagement.findTargetsOfRolloutGroupByRsql( - new OffsetBasedPageRequest(0, 100), rolloutGroups.get(0).getId(), rsqlParam); + rolloutGroups.get(0).getId(), rsql, new OffsetBasedPageRequest(0, 100)); final List targetlistGroup1 = targetPage.getContent(); assertThat(targetlistGroup1).hasSize(5); assertThat(targetlistGroup1.stream().map(Target::getControllerId).toList()) .are(targetBelongsInRollout); - targetPage = rolloutGroupManagement.findTargetsOfRolloutGroupByRsql(new OffsetBasedPageRequest(0, 100), - rolloutGroups.get(1).getId(), rsqlParam); + targetPage = rolloutGroupManagement.findTargetsOfRolloutGroupByRsql(rolloutGroups.get(1).getId(), rsql, + new OffsetBasedPageRequest(0, 100) + ); final List targetlistGroup2 = targetPage.getContent(); assertThat(targetlistGroup2).hasSize(5); assertThat(targetlistGroup2.stream().map(Target::getControllerId).toList()) .are(targetBelongsInRollout); - targetPage = rolloutGroupManagement.findTargetsOfRolloutGroupByRsql(new OffsetBasedPageRequest(0, 100), - rolloutGroups.get(2).getId(), rsqlParam); + targetPage = rolloutGroupManagement.findTargetsOfRolloutGroupByRsql(rolloutGroups.get(2).getId(), rsql, + new OffsetBasedPageRequest(0, 100) + ); final List targetlistGroup3 = targetPage.getContent(); assertThat(targetlistGroup3).hasSize(5); assertThat(targetlistGroup3.stream().map(Target::getControllerId).toList()).are(targetBelongsInRollout); @@ -1399,6 +1399,7 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { userWithoutHandleRollout, () -> createRolloutWithStartAt(rolloutName + "_withLongMax", filter, distributionSet, Long.MAX_VALUE)); } + private Rollout createRolloutWithStartAt(final String rolloutName, final String filter, final DistributionSet distributionSet, final Long startAt) { return rolloutManagement.create( @@ -1877,10 +1878,10 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { .isThrownBy(() -> rolloutManagement.update(rolloutUpdate)) .withMessageContaining("" + createdRollout.getId()); - assertThat(rolloutManagement.findAll(PAGE, true).getContent()).hasSize(1); - assertThat(rolloutManagement.findAll(PAGE, false).getContent()).isEmpty(); - assertThat(rolloutManagement.findByRsql(PAGE, "name==*", true).getContent()).hasSize(1); - assertThat(rolloutManagement.findByRsql(PAGE, "name==*", false).getContent()).isEmpty(); + assertThat(rolloutManagement.findAll(true, PAGE).getContent()).hasSize(1); + assertThat(rolloutManagement.findAll(false, PAGE).getContent()).isEmpty(); + assertThat(rolloutManagement.findByRsql("name==*", true, PAGE).getContent()).hasSize(1); + assertThat(rolloutManagement.findByRsql("name==*", false, PAGE).getContent()).isEmpty(); assertThat(rolloutManagement.count()).isZero(); assertThat(rolloutGroupManagement.findByRolloutWithDetailedStatus(createdRollout.getId(), PAGE).getContent()).hasSize(amountGroups); @@ -1923,11 +1924,11 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { rolloutReady = reloadRollout(rolloutReady); final List 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)); final List 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)); } @@ -2298,7 +2299,7 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { final List targets = rolloutGroupManagement.findTargetsOfRolloutGroup(rolloutGroupId, PAGE) .getContent(); 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 -> { deploymentManagement.cancelAction(actionId); deploymentManagement.forceQuitAction(actionId); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/SoftwareManagementSecurityTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/SoftwareManagementSecurityTest.java index 882ab8f3c..dc9720ffc 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/SoftwareManagementSecurityTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/SoftwareManagementSecurityTest.java @@ -103,7 +103,7 @@ class SoftwareManagementSecurityTest @Test @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") void findMetaDataBySoftwareModuleIdAndTargetVisiblePermissionsCheck() { - assertPermissions(() -> softwareModuleManagement.findMetaDataBySoftwareModuleIdAndTargetVisible(PAGE, 1L), + assertPermissions(() -> softwareModuleManagement.findMetaDataBySoftwareModuleIdAndTargetVisible(1L, PAGE), List.of(SpPermission.READ_REPOSITORY)); } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/SoftwareModuleManagementTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/SoftwareModuleManagementTest.java index b50d207a2..da5694f82 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/SoftwareModuleManagementTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/SoftwareModuleManagementTest.java @@ -694,9 +694,9 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest { assertThat(metadataSw2).hasSize(metadataCountSw2); final Page metadataSw1V = softwareModuleManagement.findMetaDataBySoftwareModuleIdAndTargetVisible( - PAGE_REQUEST_100, sw1.getId()); + sw1.getId(), PAGE_REQUEST_100); final Page metadataSw2V = softwareModuleManagement.findMetaDataBySoftwareModuleIdAndTargetVisible( - PAGE_REQUEST_100, sw2.getId()); + sw2.getId(), PAGE_REQUEST_100); assertThat(metadataSw1V.getNumberOfElements()).isEqualTo(metadataCountSw1); assertThat(metadataSw1V.getTotalElements()).isEqualTo(metadataCountSw1); assertThat(metadataSw2V.getNumberOfElements()).isZero(); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetFilterQueryManagementSecurityTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetFilterQueryManagementSecurityTest.java index edcd5fd83..3074bb3a9 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetFilterQueryManagementSecurityTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetFilterQueryManagementSecurityTest.java @@ -68,7 +68,7 @@ class TargetFilterQueryManagementSecurityTest extends AbstractJpaIntegrationTest @Test @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") void findByNamePermissionsCheck() { - assertPermissions(() -> targetFilterQueryManagement.findByName(PAGE, "filterName"), List.of(SpPermission.READ_TARGET)); + assertPermissions(() -> targetFilterQueryManagement.findByName("filterName", PAGE), List.of(SpPermission.READ_TARGET)); } @Test @@ -80,26 +80,26 @@ class TargetFilterQueryManagementSecurityTest extends AbstractJpaIntegrationTest @Test @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") 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 @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") 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 @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") void findByAutoAssignDistributionSetIdPermissionsCheck() { - assertPermissions(() -> targetFilterQueryManagement.findByAutoAssignDistributionSetId(PAGE, 1L), + assertPermissions(() -> targetFilterQueryManagement.findByAutoAssignDistributionSetId(1L, PAGE), List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY)); } @Test @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") void findByAutoAssignDSAndRsqlPermissionsCheck() { - assertPermissions(() -> targetFilterQueryManagement.findByAutoAssignDSAndRsql(PAGE, 1L, "rsqlParam"), + assertPermissions(() -> targetFilterQueryManagement.findByAutoAssignDSAndRsql(1L, "rsqlParam", PAGE), List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY)); } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetFilterQueryManagementTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetFilterQueryManagementTest.java index ec2e2aba2..66af9aa73 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetFilterQueryManagementTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetFilterQueryManagementTest.java @@ -87,7 +87,7 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest { verifyThrownExceptionBy(() -> targetFilterQueryManagement.delete(NOT_EXIST_IDL), "TargetFilterQuery"); verifyThrownExceptionBy( - () -> targetFilterQueryManagement.findByAutoAssignDSAndRsql(PAGE, NOT_EXIST_IDL, "name==*"), + () -> targetFilterQueryManagement.findByAutoAssignDSAndRsql(NOT_EXIST_IDL, "name==*", PAGE), "DistributionSet"); verifyThrownExceptionBy( @@ -145,7 +145,7 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest { entityFactory.targetFilterQuery().create().name("someOtherFilter").query("name==PendingTargets002")); final List 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(targetFilterQuery, results.get(0), "Retrieved newly created custom target filter"); } @@ -155,7 +155,7 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest { void searchTargetFilterQueryInvalidField() { final PageRequest pageRequest = PageRequest.of(0, 10); Assertions.assertThatExceptionOfType(RSQLParameterUnsupportedFieldException.class) - .isThrownBy(() -> targetFilterQueryManagement.findByRsql(pageRequest, "unknownField==testValue")); + .isThrownBy(() -> targetFilterQueryManagement.findByRsql("unknownField==testValue", pageRequest)); } @Test @@ -573,7 +573,7 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest { private void verifyFindByDistributionSetAndRsql(final DistributionSet distributionSet, final String rsql, final TargetFilterQuery... expectedFilterQueries) { final Page tfqList = targetFilterQueryManagement - .findByAutoAssignDSAndRsql(PageRequest.of(0, 500), distributionSet.getId(), rsql); + .findByAutoAssignDSAndRsql(distributionSet.getId(), rsql, PageRequest.of(0, 500)); assertThat(tfqList.getTotalElements()).isEqualTo(expectedFilterQueries.length); verifyExpectedFilterQueriesInList(tfqList, expectedFilterQueries); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetManagementSearchTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetManagementSearchTest.java index 7ef784834..2aa67ea5b 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetManagementSearchTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetManagementSearchTest.java @@ -47,13 +47,13 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest { final List unassigned = testdataFactory.createTargets(9, "unassigned"); final List 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("and that means the following expected amount").hasSize(11); assertThat(targetManagement.countByFilters(new FilterParams(null, null, false, testType.getId()))) .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("and that means the following expected amount").hasSize(9); assertThat(targetManagement.countByFilters(new FilterParams(null, null, true, null))) @@ -199,7 +199,7 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest { // get final updated version of targets 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("and that means the following expected amount").hasSize(10); @@ -217,7 +217,7 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest { assignDistributionSet(assignedSet, assignedTargets); final List 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") .containsAll(unassignedTargets); @@ -239,7 +239,7 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest { // get final updated version of targets 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("and that means the following expected amount").hasSize(10); @@ -258,7 +258,7 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest { targetType); final List 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()) .as("contains all targets").containsAll(targetWithCompatibleTypes).containsAll(targets); @@ -288,7 +288,7 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest { testTargets.addAll(targetsWithCompatibleType); final List 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") .containsExactlyInAnyOrderElementsOf(testTargets).as("does not contain incompatible targets") @@ -300,12 +300,12 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest { final List pending, final Target expected) { final FilterParams filterParams = new FilterParams(pending, null, null, installedSet.getId(), Boolean.FALSE); 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((int) targetManagement.countByFilters(filterParams)) .as("and contains the following elements").containsExactly(expected) .as("and filter query returns the same result") - .containsAll(targetManagement.findByRsql(PAGE, query).getContent()); + .containsAll(targetManagement.findByRsql(query, PAGE).getContent()); } @Step @@ -314,12 +314,12 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest { 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(); - 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((int) targetManagement.countByFilters(filterParams)) .as("and contains the following elements").containsAll(expected) .as("and filter query returns the same result") - .containsAll(targetManagement.findByRsql(PAGE, query).getContent()); + .containsAll(targetManagement.findByRsql(query, PAGE).getContent()); } @Step @@ -329,12 +329,12 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest { 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((int) targetManagement.countByFilters(filterParams)) .as("and contains the following elements").containsAll(expected) .as("and filter query returns the same result") - .containsAll(targetManagement.findByRsql(PAGE, query).getContent()); + .containsAll(targetManagement.findByRsql(query, PAGE).getContent()); } @Step @@ -345,12 +345,12 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest { final String query = "updatestatus==pending and (assignedds.name==" + setA.getName() + " or installedds.name==" + 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((int) targetManagement.countByFilters(filterParams)) .as("and contains the following elements").containsAll(expected) .as("and filter query returns the same result") - .containsAll(targetManagement.findByRsql(PAGE, query).getContent()); + .containsAll(targetManagement.findByRsql(query, PAGE).getContent()); } @Step @@ -361,12 +361,12 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest { 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(); - 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((int) targetManagement.countByFilters(filterParams)) .as("and contains the following elements").containsExactly(expected) .as("and filter query returns the same result") - .containsAll(targetManagement.findByRsql(PAGE, query).getContent()); + .containsAll(targetManagement.findByRsql(query, PAGE).getContent()); } @Step @@ -376,12 +376,12 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest { final String query = "updatestatus==pending and (assignedds.name==" + setA.getName() + " or installedds.name==" + 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((int) targetManagement.countByFilters(filterParams)) .as("and contains the following elements").containsExactly(expected) .as("and filter query returns the same result") - .containsAll(targetManagement.findByRsql(PAGE, query).getContent()); + .containsAll(targetManagement.findByRsql(query, PAGE).getContent()); } @Step @@ -391,12 +391,12 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest { final String query = "updatestatus==pending 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(3).as("that number is also returned by count query") .hasSize((int) targetManagement.countByFilters(filterParams)) .as("and contains the following elements").containsAll(expected) .as("and filter query returns the same result") - .containsAll(targetManagement.findByRsql(PAGE, query).getContent()); + .containsAll(targetManagement.findByRsql(query, PAGE).getContent()); } @Step @@ -405,12 +405,12 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest { final FilterParams filterParams = new FilterParams(pending, null, null, null, Boolean.FALSE); 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((int) targetManagement.countByFilters(filterParams)) .as("and contains the following elements").containsAll(expected) .as("and filter query returns the same result") - .containsAll(targetManagement.findByRsql(PAGE, query).getContent()); + .containsAll(targetManagement.findByRsql(query, PAGE).getContent()); } @Step @@ -421,12 +421,12 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest { final String query = "updatestatus==unknown 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(99).as("that number is also returned by count query") .hasSize((int) targetManagement.countByFilters(filterParams)) .as("and contains the following elements").containsAll(expected) .as("and filter query returns the same result") - .containsAll(targetManagement.findByRsql(PAGE, query).getContent()); + .containsAll(targetManagement.findByRsql(query, PAGE).getContent()); } @Step @@ -435,12 +435,12 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest { 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*)"; - 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((int) targetManagement.countByFilters(filterParams)) .as("and contains the following elements").containsAll(expected) .as("and filter query returns the same result") - .containsAll(targetManagement.findByRsql(PAGE, query).getContent()); + .containsAll(targetManagement.findByRsql(query, PAGE).getContent()); } @Step @@ -450,11 +450,11 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest { final String query = "updatestatus==unknown 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") .hasSize((int) targetManagement.countByFilters(filterParams)) .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") .isEmpty(); } @@ -467,12 +467,12 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest { 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((int) targetManagement.countByFilters(filterParams)) .as("and contains the following elements").containsAll(expected) .as("and filter query returns the same result") - .containsAll(targetManagement.findByRsql(PAGE, query).getContent()); + .containsAll(targetManagement.findByRsql(query, PAGE).getContent()); } @Step @@ -481,12 +481,12 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest { final FilterParams filterParams = new FilterParams(unknown, null, null, null, Boolean.FALSE); 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((int) targetManagement.countByFilters(filterParams)) .as("and contains the following elements").containsAll(expected) .as("and filter query returns the same result") - .containsAll(targetManagement.findByRsql(PAGE, query).getContent()); + .containsAll(targetManagement.findByRsql(query, PAGE).getContent()); } @Step @@ -496,12 +496,12 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest { // be careful: simple filters are concatenated using AND-gating 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((int) targetManagement.countByFilters(filterParams)) .as("and contains the following elements").containsAll(expected) .as("and filter query returns the same result") - .containsAll(targetManagement.findByRsql(PAGE, query).getContent()); + .containsAll(targetManagement.findByRsql(query, PAGE).getContent()); } @Step @@ -510,12 +510,12 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest { final String query = "(name==*targ-A* or description==*targ-A*) 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((int) targetManagement.countByFilters(filterParams)) .as("and contains the following elements").containsExactly(expected) .as("and filter query returns the same result") - .containsAll(targetManagement.findByRsql(PAGE, query).getContent()); + .containsAll(targetManagement.findByRsql(query, PAGE).getContent()); } @Step @@ -523,12 +523,12 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest { final FilterParams filterParams = new FilterParams(null, null, null, setA.getId(), Boolean.FALSE); 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((int) targetManagement.countByFilters(filterParams)) .as("and contains the following elements").containsAll(expected) .as("and filter query returns the same result") - .containsAll(targetManagement.findByRsql(PAGE, query).getContent()); + .containsAll(targetManagement.findByRsql(query, PAGE).getContent()); } @Step @@ -537,11 +537,11 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest { 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() + ")"; - assertThat(targetManagement.findByFilters(PAGE, filterParams).getContent()) + assertThat(targetManagement.findByFilters(filterParams, PAGE).getContent()) .as("that number is also returned by count query") .hasSize((int) targetManagement.countByFilters(filterParams)) .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") .isEmpty(); } @@ -552,10 +552,10 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest { 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() + ")"; - assertThat(targetManagement.findByFilters(PAGE, filterParams).getContent()) + assertThat(targetManagement.findByFilters(filterParams, PAGE).getContent()) .hasSize((int) targetManagement.countByFilters(filterParams)) .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") .isEmpty(); } @@ -567,23 +567,23 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest { 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() + ")"; - 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((int) targetManagement.countByFilters(filterParams)) .as("and contains the following elements").containsExactly(expected) .as("and filter query returns the same result") - .containsAll(targetManagement.findByRsql(PAGE, query).getContent()); + .containsAll(targetManagement.findByRsql(query, PAGE).getContent()); } @Step private void verifyThat1TargetHasNameAndId(final String name, final String controllerId) { 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((int) targetManagement.countByFilters(filterParamsByName)); 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") .hasSize((int) targetManagement.countByFilters(filterParamsByControllerId)); } @@ -595,12 +595,12 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest { targTagY.getName(), targTagW.getName()); final String query = "(name==*targ-B* or description==*targ-B*) 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(100).as("that number is also returned by count query") .hasSize((int) targetManagement.countByFilters(filterParams)) .as("and contains the following elements").containsAll(expected) .as("and filter query returns the same result") - .containsAll(targetManagement.findByRsql(PAGE, query).getContent()); + .containsAll(targetManagement.findByRsql(query, PAGE).getContent()); } @SafeVarargs @@ -614,18 +614,18 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest { private void verifyThat200TargetsHaveTagD(final TargetTag targTagD, final List expected) { final FilterParams filterParams = new FilterParams(null, null, null, null, Boolean.FALSE, 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((int) targetManagement.countByFilters(filterParams)) .as("and contains the following elements").containsAll(expected) .as("and filter query returns the same result") - .containsAll(targetManagement.findByRsql(PAGE, query).getContent()); + .containsAll(targetManagement.findByRsql(query, PAGE).getContent()); } @Step private void verifyThatRepositoryContains500Targets() { 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("which is also reflected by repository count").hasSize((int) targetManagement.count()) .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, final Target expected) { 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((int) targetManagement.countByFilters(filterParams)) .as("and contains the following elements").containsExactly(expected); @@ -646,7 +646,7 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest { private void verifyThatTargetsHasNoTypeAndDSAssignedOrInstalled(final DistributionSet set, final List expected) { 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((int) targetManagement.countByFilters(filterParams)) .as("and contains the following elements").containsAll(expected); @@ -656,7 +656,7 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest { private void verifyThat100TargetsContainsGivenTextAndHaveTypeAssigned(final TargetType targetType, final List expected) { final FilterParams filterParams = new FilterParams("%targ-E%", null, Boolean.FALSE, targetType.getId()); - final List filteredTargets = targetManagement.findByFilters(PAGE, filterParams).getContent(); + final List filteredTargets = targetManagement.findByFilters(filterParams, PAGE).getContent(); assertThat(filteredTargets).as("has number of elements").hasSize(100) .as("that number is also returned by count query") .hasSize((int) targetManagement.countByFilters(filterParams)); @@ -670,7 +670,7 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest { @Step private void verifyThat400TargetsContainsGivenTextAndHaveNoTypeAssigned(final List expected) { 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((int) targetManagement.countByFilters(filterParams)) .as("and contains the following elements").containsAll(expected); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetManagementSecurityTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetManagementSecurityTest.java index 88535be37..aa5f3086a 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetManagementSecurityTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetManagementSecurityTest.java @@ -134,7 +134,7 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest { @Test @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") void findByTargetFilterQueryAndNonDSAndCompatibleAndUpdatablePermissionsCheck() { - assertPermissions(() -> targetManagement.findByTargetFilterQueryAndNonDSAndCompatibleAndUpdatable(PAGE, 1L, "controllerId==id"), + assertPermissions(() -> targetManagement.findByTargetFilterQueryAndNonDSAndCompatibleAndUpdatable(1L, "controllerId==id", PAGE), 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.") void findByTargetFilterQueryAndNotInRolloutAndCompatibleAndUpdatablePermissionsCheck() { assertPermissions( - () -> targetManagement.findByTargetFilterQueryAndNotInRolloutAndCompatibleAndUpdatable(PAGE, List.of(1L), - "controllerId==id", - entityFactory.distributionSetType().create().build()), List.of(SpPermission.READ_TARGET, SpPermission.READ_ROLLOUT)); + () -> targetManagement.findByTargetFilterQueryAndNotInRolloutAndCompatibleAndUpdatable(List.of(1L), "controllerId==id", + entityFactory.distributionSetType().create().build(), PAGE + ), List.of(SpPermission.READ_TARGET, SpPermission.READ_ROLLOUT)); } @Test @@ -171,7 +171,7 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest { @Test @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") 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)); } @@ -185,20 +185,20 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest { @Test @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") void findByInRolloutGroupWithoutActionPermissionsCheck() { - assertPermissions(() -> targetManagement.findByInRolloutGroupWithoutAction(PAGE, 1L), List.of(SpPermission.READ_TARGET)); + assertPermissions(() -> targetManagement.findByInRolloutGroupWithoutAction(1L, PAGE), List.of(SpPermission.READ_TARGET)); } @Test @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") void findByAssignedDistributionSetPermissionsCheck() { - assertPermissions(() -> targetManagement.findByAssignedDistributionSet(PAGE, 1L), + assertPermissions(() -> targetManagement.findByAssignedDistributionSet(1L, PAGE), List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY)); } @Test @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") void findByAssignedDistributionSetAndRsqlPermissionsCheck() { - assertPermissions(() -> targetManagement.findByAssignedDistributionSetAndRsql(PAGE, 1L, "controllerId==id"), + assertPermissions(() -> targetManagement.findByAssignedDistributionSetAndRsql(1L, "controllerId==id", PAGE), List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY)); } @@ -217,28 +217,28 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest { @Test @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") 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)); } @Test @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") void findByInstalledDistributionSetPermissionsCheck() { - assertPermissions(() -> targetManagement.findByInstalledDistributionSet(PAGE, 1L), + assertPermissions(() -> targetManagement.findByInstalledDistributionSet(1L, PAGE), List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY)); } @Test @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") void findByInstalledDistributionSetAndRsqlPermissionsCheck() { - assertPermissions(() -> targetManagement.findByInstalledDistributionSetAndRsql(PAGE, 1L, "controllerId==id"), + assertPermissions(() -> targetManagement.findByInstalledDistributionSetAndRsql(1L, "controllerId==id", PAGE), List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY)); } @Test @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") 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 @@ -250,25 +250,25 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest { @Test @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") 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 @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") void findByTargetFilterQueryPermissionsCheck() { - assertPermissions(() -> targetManagement.findByTargetFilterQuery(PAGE, 1L), List.of(SpPermission.READ_TARGET)); + assertPermissions(() -> targetManagement.findByTargetFilterQuery(1L, PAGE), List.of(SpPermission.READ_TARGET)); } @Test @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") void findByTagPermissionsCheck() { - assertPermissions(() -> targetManagement.findByTag(PAGE, 1L), List.of(SpPermission.READ_TARGET)); + assertPermissions(() -> targetManagement.findByTag(1L, PAGE), List.of(SpPermission.READ_TARGET)); } @Test @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") 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 diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetManagementTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetManagementTest.java index dead17069..781ec7580 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetManagementTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetManagementTest.java @@ -113,8 +113,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest { () -> targetManagement.assignTag(Collections.singletonList(target.getControllerId()), NOT_EXIST_IDL), "TargetTag"); verifyThrownExceptionBy(() -> targetManagement.assignTag(Collections.singletonList(NOT_EXIST_ID), tag.getId()), "Target"); - verifyThrownExceptionBy(() -> targetManagement.findByTag(PAGE, NOT_EXIST_IDL), "TargetTag"); - verifyThrownExceptionBy(() -> targetManagement.findByRsqlAndTag(PAGE, "name==*", NOT_EXIST_IDL), "TargetTag"); + verifyThrownExceptionBy(() -> targetManagement.findByTag(NOT_EXIST_IDL, PAGE), "TargetTag"); + verifyThrownExceptionBy(() -> targetManagement.findByRsqlAndTag("name==*", NOT_EXIST_IDL, PAGE), "TargetTag"); verifyThrownExceptionBy(() -> targetManagement.countByAssignedDistributionSet(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.findByTargetFilterQueryAndNonDSAndCompatibleAndUpdatable(PAGE, NOT_EXIST_IDL, "name==*"), + () -> targetManagement.findByTargetFilterQueryAndNonDSAndCompatibleAndUpdatable(NOT_EXIST_IDL, "name==*", PAGE), "DistributionSet"); - verifyThrownExceptionBy(() -> targetManagement.findByInRolloutGroupWithoutAction(PAGE, NOT_EXIST_IDL), "RolloutGroup"); - verifyThrownExceptionBy(() -> targetManagement.findByAssignedDistributionSet(PAGE, NOT_EXIST_IDL), "DistributionSet"); + verifyThrownExceptionBy(() -> targetManagement.findByInRolloutGroupWithoutAction(NOT_EXIST_IDL, PAGE), "RolloutGroup"); + verifyThrownExceptionBy(() -> targetManagement.findByAssignedDistributionSet(NOT_EXIST_IDL, PAGE), "DistributionSet"); 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( - () -> targetManagement.findByInstalledDistributionSetAndRsql(PAGE, NOT_EXIST_IDL, "name==*"), "DistributionSet"); + () -> targetManagement.findByInstalledDistributionSetAndRsql(NOT_EXIST_IDL, "name==*", PAGE), "DistributionSet"); verifyThrownExceptionBy(() -> targetManagement .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); 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); assertThat(unAssignTarget.getControllerId()).as("Controller id is wrong").isEqualTo("targetId123"); assertThat(getTargetTags(unAssignTarget.getControllerId())).as("Tag size is wrong") .isEmpty(); targetTagManagement.getByName("Tag1").orElseThrow(NoSuchElementException::new); - assertThat(targetManagement.findByTag(PAGE, targetTag.getId())).as("Assigned targets are wrong").hasSize(3); - assertThat(targetManagement.findByRsqlAndTag(PAGE, "controllerId==targetId123", targetTag.getId())) + assertThat(targetManagement.findByTag(targetTag.getId(), PAGE)).as("Assigned targets are wrong").hasSize(3); + assertThat(targetManagement.findByRsqlAndTag("controllerId==targetId123", targetTag.getId(), PAGE)) .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); } @@ -657,7 +657,7 @@ class TargetManagementTest extends AbstractJpaIntegrationTest { final String[] tagNames = null; final List 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(targetsListWithNoTag).as("Targets with no tag").hasSize(25); @@ -694,7 +694,7 @@ class TargetManagementTest extends AbstractJpaIntegrationTest { testdataFactory.createTargets(25, "target-id-B", "first description"); - final Slice foundTargets = targetManagement.findByRsql(PAGE, rsqlFilter); + final Slice foundTargets = targetManagement.findByRsql(rsqlFilter, PAGE); final long foundTargetsCount = targetManagement.countByRsql(rsqlFilter); assertThat(targetManagement.count()).as("Total targets").isEqualTo(50L); @@ -1159,7 +1159,7 @@ class TargetManagementTest extends AbstractJpaIntegrationTest { final Slice matching = 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.stream() @@ -1449,7 +1449,7 @@ class TargetManagementTest extends AbstractJpaIntegrationTest { } private void validateFoundTargetsByRsql(final String rsqlFilter, final String... controllerIds) { - final Slice foundTargetsByMetadataAndControllerId = targetManagement.findByRsql(PAGE, rsqlFilter); + final Slice foundTargetsByMetadataAndControllerId = targetManagement.findByRsql(rsqlFilter, PAGE); final long foundTargetsByMetadataAndControllerIdCount = targetManagement.countByRsql(rsqlFilter); assertThat(foundTargetsByMetadataAndControllerId.getNumberOfElements()) diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetTagManagementSecurityTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetTagManagementSecurityTest.java index bd9caf4f2..14c21dd1a 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetTagManagementSecurityTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetTagManagementSecurityTest.java @@ -61,7 +61,7 @@ class TargetTagManagementSecurityTest extends AbstractJpaIntegrationTest { @Test @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") 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 diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetTagManagementTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetTagManagementTest.java index ce9cd04d3..af37c61a0 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetTagManagementTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetTagManagementTest.java @@ -129,7 +129,7 @@ class TargetTagManagementTest extends AbstractJpaIntegrationTest { .containsAll( targetManagement.getByControllerID(groupA.stream().map(Target::getControllerId).toList())) .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()) .isEqualTo(groupA.stream().map(Target::getControllerId).sorted().toList()); @@ -140,7 +140,7 @@ class TargetTagManagementTest extends AbstractJpaIntegrationTest { .containsAll( targetManagement.getByControllerID(groupAB.stream().map(Target::getControllerId).toList())) .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()) .isEqualTo(groupAB.stream().map(Target::getControllerId).sorted().toList()); @@ -149,7 +149,7 @@ class TargetTagManagementTest extends AbstractJpaIntegrationTest { assertThat(result) .containsAll(targetManagement.getByControllerID(groupAB.stream().map(Target::getControllerId).toList())) .size().isEqualTo(40); - assertThat(targetManagement.findByTag(Pageable.unpaged(), tag.getId()).getContent()).isEmpty(); + assertThat(targetManagement.findByTag(tag.getId(), Pageable.unpaged()).getContent()).isEmpty(); } @Test diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetTypeManagementSecurityTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetTypeManagementSecurityTest.java index 67cf9b1a2..47c88a675 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetTypeManagementSecurityTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetTypeManagementSecurityTest.java @@ -81,13 +81,13 @@ class TargetTypeManagementSecurityTest extends AbstractJpaIntegrationTest { @Test @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") 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 @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") void findByNamePermissionsCheck() { - assertPermissions(() -> targetTypeManagement.findByName(PAGE, "name"), List.of(SpPermission.READ_TARGET)); + assertPermissions(() -> targetTypeManagement.findByName("name", PAGE), List.of(SpPermission.READ_TARGET)); } @Test diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLActionFieldsTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLActionFieldsTest.java index 450924cb5..96b43bc7e 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLActionFieldsTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLActionFieldsTest.java @@ -107,10 +107,10 @@ class RSQLActionFieldsTest extends AbstractJpaIntegrationTest { return newAction; } - private void assertRSQLQuery(final String rsqlParam, final long expectedEntities) { - final Slice findEntity = deploymentManagement.findActionsByTarget(rsqlParam, target.getControllerId(), + private void assertRSQLQuery(final String rsql, final long expectedEntities) { + final Slice findEntity = deploymentManagement.findActionsByTarget(rsql, target.getControllerId(), 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.getContent()).hasSize((int)expectedEntities); assertThat(countAllEntities).isEqualTo(expectedEntities); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLRolloutGroupFieldTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLRolloutGroupFieldTest.java index abed72d88..954699f82 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLRolloutGroupFieldTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLRolloutGroupFieldTest.java @@ -84,8 +84,8 @@ class RSQLRolloutGroupFieldTest extends AbstractJpaIntegrationTest { assertRSQLQuery(RolloutGroupFields.DESCRIPTION.name() + "=out=(group-1,notexist)", 3); } - private void assertRSQLQuery(final String rsqlParam, final long expectedTargets) { - final Page findTargetPage = rolloutGroupManagement.findByRolloutAndRsql(rollout.getId(), rsqlParam, PageRequest.of(0, 100) + private void assertRSQLQuery(final String rsql, final long expectedTargets) { + final Page findTargetPage = rolloutGroupManagement.findByRolloutAndRsql(rollout.getId(), rsql, PageRequest.of(0, 100) ); final long countTargetsAll = findTargetPage.getTotalElements(); assertThat(findTargetPage).isNotNull(); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLSoftwareModuleFieldTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLSoftwareModuleFieldTest.java index e01d0bc41..d5402844b 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLSoftwareModuleFieldTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLSoftwareModuleFieldTest.java @@ -149,10 +149,10 @@ class RSQLSoftwareModuleFieldTest extends AbstractJpaIntegrationTest { } - private void assertRSQLQuery(final String rsqlParam, final long expectedEntity) { - final Page find = softwareModuleManagement.findByRsql(rsqlParam, PageRequest.of(0, 100)); + private void assertRSQLQuery(final String rsql, final long expectedEntity) { + final Page find = softwareModuleManagement.findByRsql(rsql, PageRequest.of(0, 100)); final long countAll = find.getTotalElements(); assertThat(find).isNotNull(); assertThat(countAll).isEqualTo(expectedEntity); } -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLSoftwareModuleTypeFieldsTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLSoftwareModuleTypeFieldsTest.java index b334eb9da..40198bbff 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLSoftwareModuleTypeFieldsTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLSoftwareModuleTypeFieldsTest.java @@ -77,11 +77,10 @@ class RSQLSoftwareModuleTypeFieldsTest extends AbstractJpaIntegrationTest { assertRSQLQuery(SoftwareModuleTypeFields.MAXASSIGNMENTS.name() + "!=1", 1); } - private void assertRSQLQuery(final String rsqlParam, final long excpectedEntity) { - final Page find = softwareModuleTypeManagement.findByRsql(rsqlParam, PageRequest.of(0, 100) - ); + private void assertRSQLQuery(final String rsql, final long expectedEntity) { + final Page find = softwareModuleTypeManagement.findByRsql(rsql, PageRequest.of(0, 100)); final long countAll = find.getTotalElements(); assertThat(find).isNotNull(); - assertThat(countAll).isEqualTo(excpectedEntity); + assertThat(countAll).isEqualTo(expectedEntity); } } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLTagFieldsTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLTagFieldsTest.java index 9b6c0bbbe..321d4742a 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLTagFieldsTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLTagFieldsTest.java @@ -117,20 +117,17 @@ class RSQLTagFieldsTest extends AbstractJpaIntegrationTest { assertRSQLQueryDistributionSet(TagFields.COLOUR.name() + "=out=(red,notexist)", 2); } - private void assertRSQLQueryDistributionSet(final String rsqlParam, final long expectedEntities) { - - final Page findEnitity = distributionSetTagManagement.findByRsql(rsqlParam, PageRequest.of(0, 100) - ); + private void assertRSQLQueryDistributionSet(final String rsql, final long expectedEntities) { + final Page findEnitity = distributionSetTagManagement.findByRsql(rsql, PageRequest.of(0, 100)); final long countAllEntities = findEnitity.getTotalElements(); assertThat(findEnitity).isNotNull(); assertThat(countAllEntities).isEqualTo(expectedEntities); } - private void assertRSQLQueryTarget(final String rsqlParam, final long expectedEntities) { - - final Page findEnitity = targetTagManagement.findByRsql(PageRequest.of(0, 100), rsqlParam); - final long countAllEntities = findEnitity.getTotalElements(); - assertThat(findEnitity).isNotNull(); + private void assertRSQLQueryTarget(final String rsql, final long expectedEntities) { + final Page findEntity = targetTagManagement.findByRsql(rsql, PageRequest.of(0, 100)); + final long countAllEntities = findEntity.getTotalElements(); + assertThat(findEntity).isNotNull(); assertThat(countAllEntities).isEqualTo(expectedEntities); } -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLTargetFieldTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLTargetFieldTest.java index 3bdca0aea..28eb039d4 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLTargetFieldTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLTargetFieldTest.java @@ -413,16 +413,16 @@ class RSQLTargetFieldTest extends AbstractJpaIntegrationTest { .isThrownBy(() -> assertRSQLQuery("targettype.description==Description", 0)); } - private void assertRSQLQuery(final String rsqlParam, final long expectedTargets) { - final Slice findTargetPage = targetManagement.findByRsql(PAGE, rsqlParam); + private void assertRSQLQuery(final String rsql, final long expectedTargets) { + final Slice findTargetPage = targetManagement.findByRsql(rsql, PAGE); assertThat(findTargetPage).isNotNull(); 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) .isThrownBy(() -> RSQLUtility.validateRsqlFor( - rsqlParam, TargetFields.class, JpaTarget.class, virtualPropertyReplacer, entityManager)); + rsql, TargetFields.class, JpaTarget.class, virtualPropertyReplacer, entityManager)); } } \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLTargetFilterQueryFieldsTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLTargetFilterQueryFieldsTest.java index d63193913..099f25c13 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLTargetFilterQueryFieldsTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLTargetFilterQueryFieldsTest.java @@ -109,10 +109,9 @@ class RSQLTargetFilterQueryFieldsTest extends AbstractJpaIntegrationTest { + TestdataFactory.DEFAULT_VERSION + ",notexist)", 1); } - private void assertRSQLQuery(final String rsqlParam, final long expectedFilterQueriesSize) { - final Page findTargetFilterQueryPage = targetFilterQueryManagement.findByRsql(PAGE, - rsqlParam); + private void assertRSQLQuery(final String rsql, final long expectedFilterQueriesSize) { + final Page findTargetFilterQueryPage = targetFilterQueryManagement.findByRsql(rsql, PAGE); assertThat(findTargetFilterQueryPage).isNotNull(); assertThat(findTargetFilterQueryPage.getTotalElements()).isEqualTo(expectedFilterQueriesSize); } -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/tenancy/MultiTenancyEntityTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/tenancy/MultiTenancyEntityTest.java index bb50421bd..59ee22040 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/tenancy/MultiTenancyEntityTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/tenancy/MultiTenancyEntityTest.java @@ -191,6 +191,6 @@ class MultiTenancyEntityTest extends AbstractJpaIntegrationTest { } private Slice findDistributionSetForTenant(final String tenant) throws Exception { - return runAsTenant(tenant, () -> distributionSetManagement.findByCompleted(PAGE, true)); + return runAsTenant(tenant, () -> distributionSetManagement.findByCompleted(true, PAGE)); } } diff --git a/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/AbstractIntegrationTest.java b/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/AbstractIntegrationTest.java index 77c3387fa..d793814e0 100644 --- a/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/AbstractIntegrationTest.java +++ b/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/AbstractIntegrationTest.java @@ -425,7 +425,7 @@ public abstract class AbstractIntegrationTest { final DistributionSet ds = testdataFactory.createDistributionSet(distributionSet, isRequiredMigrationStep); Target savedTarget = testdataFactory.createTarget(controllerId); 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) { confirmationManagement.confirmAction(savedAction.getId(), null, null);