diff --git a/hawkbit-ddi/hawkbit-ddi-api/src/main/java/org/eclipse/hawkbit/ddi/rest/api/DdiRestConstants.java b/hawkbit-ddi/hawkbit-ddi-api/src/main/java/org/eclipse/hawkbit/ddi/rest/api/DdiRestConstants.java index d7ebad75e..43ec541ef 100644 --- a/hawkbit-ddi/hawkbit-ddi-api/src/main/java/org/eclipse/hawkbit/ddi/rest/api/DdiRestConstants.java +++ b/hawkbit-ddi/hawkbit-ddi-api/src/main/java/org/eclipse/hawkbit/ddi/rest/api/DdiRestConstants.java @@ -22,60 +22,48 @@ public final class DdiRestConstants { * The base URL mapping of the direct device integration rest resources. */ public static final String BASE_V1_REQUEST_MAPPING = "/{tenant}/controller/v1"; - /** * Deployment action resources. */ public static final String DEPLOYMENT_BASE_ACTION = "deploymentBase"; - /** * Confirmation base resource. */ public static final String CONFIRMATION_BASE = "confirmationBase"; - /** * Activate auto-confirm */ public static final String AUTO_CONFIRM_ACTIVATE = "activateAutoConfirm"; - /** * Deactivate auto-confirm */ public static final String AUTO_CONFIRM_DEACTIVATE = "deactivateAutoConfirm"; - /** * Installed action resources. */ public static final String INSTALLED_BASE_ACTION = "installedBase"; - /** * Cancel action resources. */ public static final String CANCEL_ACTION = "cancelAction"; - /** * Feedback channel. */ public static final String FEEDBACK = "feedback"; - /** * File suffix for MDH hash download (see Linux md5sum). */ public static final String ARTIFACT_MD5_DWNL_SUFFIX = ".MD5SUM"; - /** * Config data action resources. */ public static final String CONFIG_DATA_ACTION = "configData"; - /** - * Default value specifying that no action history to be sent as part of - * response to deploymentBase + * Default value specifying that no action history to be sent as part of response to deploymentBase * {@link DdiRootControllerRestApi#getControllerDeploymentBaseAction}. * {@link DdiRootControllerRestApi#getConfirmationBaseAction}. */ public static final String NO_ACTION_HISTORY = "0"; - /** * Media type for CBOR content. Unfortunately, there is no other constant we * can reuse - even the Jackson data converter simply hardcodes this. diff --git a/hawkbit-ddi/hawkbit-ddi-api/src/main/java/org/eclipse/hawkbit/ddi/rest/api/DdiRootControllerRestApi.java b/hawkbit-ddi/hawkbit-ddi-api/src/main/java/org/eclipse/hawkbit/ddi/rest/api/DdiRootControllerRestApi.java index 7e3f689ac..8e7049e3b 100644 --- a/hawkbit-ddi/hawkbit-ddi-api/src/main/java/org/eclipse/hawkbit/ddi/rest/api/DdiRootControllerRestApi.java +++ b/hawkbit-ddi/hawkbit-ddi-api/src/main/java/org/eclipse/hawkbit/ddi/rest/api/DdiRootControllerRestApi.java @@ -158,8 +158,8 @@ public interface DdiRootControllerRestApi { " and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = DdiRestConstants.BASE_V1_REQUEST_MAPPING - + "/{controllerId}/softwaremodules/{softwareModuleId}/artifacts/{fileName}") + @GetMapping(value = DdiRestConstants.BASE_V1_REQUEST_MAPPING + + "/{controllerId}/softwaremodules/{softwareModuleId}/artifacts/{fileName}") ResponseEntity downloadArtifact(@PathVariable("tenant") final String tenant, @PathVariable("controllerId") final String controllerId, @PathVariable("softwareModuleId") final Long softwareModuleId, @@ -315,7 +315,8 @@ public interface DdiRootControllerRestApi { }) @PostMapping(value = DdiRestConstants.BASE_V1_REQUEST_MAPPING + "/{controllerId}/" + DdiRestConstants.DEPLOYMENT_BASE_ACTION + "/{actionId}/" + DdiRestConstants.FEEDBACK, consumes = { MediaType.APPLICATION_JSON_VALUE, DdiRestConstants.MEDIA_TYPE_CBOR }) - ResponseEntity postDeploymentBaseActionFeedback(@Valid final DdiActionFeedback feedback, + ResponseEntity postDeploymentBaseActionFeedback( + @Valid final DdiActionFeedback feedback, @PathVariable("tenant") final String tenant, @PathVariable("controllerId") final String controllerId, @PathVariable("actionId") @NotNull final Long actionId); @@ -488,7 +489,8 @@ public interface DdiRootControllerRestApi { }) @GetMapping(value = DdiRestConstants.BASE_V1_REQUEST_MAPPING + "/{controllerId}/" + DdiRestConstants.INSTALLED_BASE_ACTION + "/{actionId}", produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE, DdiRestConstants.MEDIA_TYPE_CBOR }) - ResponseEntity getControllerInstalledAction(@PathVariable("tenant") final String tenant, + ResponseEntity getControllerInstalledAction( + @PathVariable("tenant") final String tenant, @PathVariable("controllerId") @NotEmpty final String controllerId, @PathVariable("actionId") @NotNull final Long actionId, @RequestParam( @@ -496,10 +498,8 @@ public interface DdiRootControllerRestApi { defaultValue = DdiRestConstants.NO_ACTION_HISTORY) final Integer actionHistoryMessageCount); /** - * Returns the confirmation base with the current auto-confirmation state - * for a given controllerId and toggle links. In case there are actions - * present where the confirmation is required, a reference to it will be - * returned as well. + * Returns the confirmation base with the current auto-confirmation state for a given controllerId and toggle links. In case there are + * actions present where the confirmation is required, a reference to it will be returned as well. * * @param tenant the controllerId is corresponding too * @param controllerId to check the state for @@ -582,9 +582,8 @@ public interface DdiRootControllerRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = DdiRestConstants.BASE_V1_REQUEST_MAPPING + "/{controllerId}/" - + DdiRestConstants.CONFIRMATION_BASE + "/{actionId}", produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE, DdiRestConstants.MEDIA_TYPE_CBOR }) + @GetMapping(value = DdiRestConstants.BASE_V1_REQUEST_MAPPING + "/{controllerId}/" + DdiRestConstants.CONFIRMATION_BASE + "/{actionId}", + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE, DdiRestConstants.MEDIA_TYPE_CBOR }) ResponseEntity getConfirmationBaseAction(@PathVariable("tenant") final String tenant, @PathVariable("controllerId") @NotEmpty final String controllerId, @PathVariable("actionId") @NotNull final Long actionId, @@ -635,7 +634,8 @@ public interface DdiRootControllerRestApi { content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) @PostMapping(value = DdiRestConstants.BASE_V1_REQUEST_MAPPING + "/{controllerId}/" + DdiRestConstants.CONFIRMATION_BASE + "/{actionId}/" + - DdiRestConstants.FEEDBACK, consumes = { MediaType.APPLICATION_JSON_VALUE, DdiRestConstants.MEDIA_TYPE_CBOR }) + DdiRestConstants.FEEDBACK, + consumes = { MediaType.APPLICATION_JSON_VALUE, DdiRestConstants.MEDIA_TYPE_CBOR }) ResponseEntity postConfirmationActionFeedback( @Valid final DdiConfirmationFeedback feedback, @PathVariable("tenant") final String tenant, @@ -772,7 +772,7 @@ public interface DdiRootControllerRestApi { }) @PutMapping(value = DdiRestConstants.BASE_V1_REQUEST_MAPPING + "/{controllerId}/" + DdiRestConstants.INSTALLED_BASE_ACTION, consumes = { MediaType.APPLICATION_JSON_VALUE, DdiRestConstants.MEDIA_TYPE_CBOR }) - ResponseEntity setAsssignedOfflineVersion( + ResponseEntity setAssignedOfflineVersion( @Valid DdiAssignedVersion ddiAssignedVersion, @PathVariable("tenant") final String tenant, @PathVariable("controllerId") final String controllerId); diff --git a/hawkbit-ddi/hawkbit-ddi-resource/src/main/java/org/eclipse/hawkbit/ddi/rest/resource/DdiRootController.java b/hawkbit-ddi/hawkbit-ddi-resource/src/main/java/org/eclipse/hawkbit/ddi/rest/resource/DdiRootController.java index 946c61253..0b847cb7c 100644 --- a/hawkbit-ddi/hawkbit-ddi-resource/src/main/java/org/eclipse/hawkbit/ddi/rest/resource/DdiRootController.java +++ b/hawkbit-ddi/hawkbit-ddi-resource/src/main/java/org/eclipse/hawkbit/ddi/rest/resource/DdiRootController.java @@ -466,7 +466,7 @@ public class DdiRootController implements DdiRootControllerRestApi { } @Override - public ResponseEntity setAsssignedOfflineVersion( + public ResponseEntity setAssignedOfflineVersion( @Valid @RequestBody DdiAssignedVersion ddiAssignedVersion, @PathVariable("tenant") final String tenant, @PathVariable("controllerId") final String controllerId) { diff --git a/hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/amqp/api/EventTopic.java b/hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/amqp/api/EventTopic.java index 32fdffbac..5e6956cd9 100644 --- a/hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/amqp/api/EventTopic.java +++ b/hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/amqp/api/EventTopic.java @@ -58,4 +58,4 @@ public enum EventTopic { * Topic when confirmation of an action is requested. */ CONFIRM -} +} \ No newline at end of file diff --git a/hawkbit-dmf/hawkbit-dmf-rabbitmq-test/src/main/java/org/eclipse/hawkbit/rabbitmq/test/AbstractAmqpIntegrationTest.java b/hawkbit-dmf/hawkbit-dmf-rabbitmq-test/src/main/java/org/eclipse/hawkbit/rabbitmq/test/AbstractAmqpIntegrationTest.java index 1565f8f69..5c1fd682c 100644 --- a/hawkbit-dmf/hawkbit-dmf-rabbitmq-test/src/main/java/org/eclipse/hawkbit/rabbitmq/test/AbstractAmqpIntegrationTest.java +++ b/hawkbit-dmf/hawkbit-dmf-rabbitmq-test/src/main/java/org/eclipse/hawkbit/rabbitmq/test/AbstractAmqpIntegrationTest.java @@ -36,11 +36,9 @@ import org.springframework.test.context.ContextConfiguration; @Slf4j @RabbitAvailable -@ContextConfiguration(classes = { RepositoryApplicationConfiguration.class, AmqpTestConfiguration.class, - TestConfiguration.class }) +@ContextConfiguration(classes = { RepositoryApplicationConfiguration.class, AmqpTestConfiguration.class, TestConfiguration.class }) @Import(TestChannelBinderConfiguration.class) -// Dirty context is necessary to create a new vhost and recreate all necessary -// beans after every test class. +// Dirty context is necessary to create a new vhost and recreate all necessary beans after every test class. @DirtiesContext(classMode = ClassMode.AFTER_CLASS) public abstract class AbstractAmqpIntegrationTest extends AbstractIntegrationTest { @@ -48,7 +46,6 @@ public abstract class AbstractAmqpIntegrationTest extends AbstractIntegrationTes @Autowired private ConnectionFactory connectionFactory; - @Autowired private RabbitAdmin rabbitAdmin; @@ -109,5 +106,4 @@ public abstract class AbstractAmqpIntegrationTest extends AbstractIntegrationTes template.setExchange(getExchange()); return template; } - -} +} \ No newline at end of file diff --git a/hawkbit-dmf/hawkbit-dmf-rabbitmq-test/src/main/java/org/eclipse/hawkbit/rabbitmq/test/AmqpTestConfiguration.java b/hawkbit-dmf/hawkbit-dmf-rabbitmq-test/src/main/java/org/eclipse/hawkbit/rabbitmq/test/AmqpTestConfiguration.java index 1a15d1ad4..8a815a47c 100644 --- a/hawkbit-dmf/hawkbit-dmf-rabbitmq-test/src/main/java/org/eclipse/hawkbit/rabbitmq/test/AmqpTestConfiguration.java +++ b/hawkbit-dmf/hawkbit-dmf-rabbitmq-test/src/main/java/org/eclipse/hawkbit/rabbitmq/test/AmqpTestConfiguration.java @@ -9,8 +9,6 @@ */ package org.eclipse.hawkbit.rabbitmq.test; -import java.net.MalformedURLException; -import java.net.URL; import java.util.concurrent.Executor; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; diff --git a/hawkbit-dmf/hawkbit-dmf-rabbitmq-test/src/main/java/org/eclipse/hawkbit/rabbitmq/test/RabbitMqSetupService.java b/hawkbit-dmf/hawkbit-dmf-rabbitmq-test/src/main/java/org/eclipse/hawkbit/rabbitmq/test/RabbitMqSetupService.java index 38fa52080..1d856dc9b 100644 --- a/hawkbit-dmf/hawkbit-dmf-rabbitmq-test/src/main/java/org/eclipse/hawkbit/rabbitmq/test/RabbitMqSetupService.java +++ b/hawkbit-dmf/hawkbit-dmf-rabbitmq-test/src/main/java/org/eclipse/hawkbit/rabbitmq/test/RabbitMqSetupService.java @@ -24,8 +24,7 @@ import org.springframework.amqp.rabbit.junit.BrokerRunningSupport; import org.springframework.util.ObjectUtils; /** - * Creates and deletes a new virtual host if the rabbit mq management api is - * available. + * Creates and deletes a new virtual host if the rabbit mq management api is available. */ // exception squid:S2068 - Test instance passwd @SuppressWarnings("squid:S2068") @@ -39,8 +38,7 @@ public class RabbitMqSetupService { private String virtualHost; public RabbitMqSetupService() { - - BrokerRunningSupport brokerSupport = BrokerRunningSupport.isRunning(); + final BrokerRunningSupport brokerSupport = BrokerRunningSupport.isRunning(); connectionFactory = brokerSupport.getConnectionFactory(); hostname = brokerSupport.getHostName(); username = brokerSupport.getUser(); @@ -99,4 +97,4 @@ public class RabbitMqSetupService { permissions.setWrite(".*"); return permissions; } -} +} \ No newline at end of file diff --git a/hawkbit-dmf/hawkbit-dmf-rabbitmq-test/src/main/java/org/eclipse/hawkbit/rabbitmq/test/listener/TestRabbitListener.java b/hawkbit-dmf/hawkbit-dmf-rabbitmq-test/src/main/java/org/eclipse/hawkbit/rabbitmq/test/listener/TestRabbitListener.java index 2f2b8f9b1..fd1e9f43d 100644 --- a/hawkbit-dmf/hawkbit-dmf-rabbitmq-test/src/main/java/org/eclipse/hawkbit/rabbitmq/test/listener/TestRabbitListener.java +++ b/hawkbit-dmf/hawkbit-dmf-rabbitmq-test/src/main/java/org/eclipse/hawkbit/rabbitmq/test/listener/TestRabbitListener.java @@ -20,4 +20,4 @@ public interface TestRabbitListener { * @param message the message */ void handleMessage(Message message); -} +} \ No newline at end of file diff --git a/hawkbit-dmf/hawkbit-dmf-server/src/main/java/org/eclipse/hawkbit/app/dmf/DMFStart.java b/hawkbit-dmf/hawkbit-dmf-server/src/main/java/org/eclipse/hawkbit/app/dmf/DMFStart.java index c532beb4e..fc9f4effa 100644 --- a/hawkbit-dmf/hawkbit-dmf-server/src/main/java/org/eclipse/hawkbit/app/dmf/DMFStart.java +++ b/hawkbit-dmf/hawkbit-dmf-server/src/main/java/org/eclipse/hawkbit/app/dmf/DMFStart.java @@ -27,4 +27,4 @@ public class DMFStart { public static void main(final String[] args) { SpringApplication.run(DMFStart.class, args); } -} +} \ No newline at end of file diff --git a/hawkbit-dmf/hawkbit-dmf-starter/src/main/java/org/eclipse/hawkbit/autoconfigure/dmf/amqp/DmfApiAutoConfiguration.java b/hawkbit-dmf/hawkbit-dmf-starter/src/main/java/org/eclipse/hawkbit/autoconfigure/dmf/amqp/DmfApiAutoConfiguration.java index 8aa6b17ec..d81d52445 100644 --- a/hawkbit-dmf/hawkbit-dmf-starter/src/main/java/org/eclipse/hawkbit/autoconfigure/dmf/amqp/DmfApiAutoConfiguration.java +++ b/hawkbit-dmf/hawkbit-dmf-starter/src/main/java/org/eclipse/hawkbit/autoconfigure/dmf/amqp/DmfApiAutoConfiguration.java @@ -36,4 +36,4 @@ public class DmfApiAutoConfiguration { public ErrorHandler errorHandler() { return new ConditionalRejectingErrorHandler(); } -} +} \ No newline at end of file diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/MgmtNamedEntity.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/MgmtNamedEntity.java index 1a4620ac0..9ab37c713 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/MgmtNamedEntity.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/MgmtNamedEntity.java @@ -28,6 +28,7 @@ public abstract class MgmtNamedEntity extends MgmtBaseEntity { @JsonProperty(required = true) @Schema(example = "Name of entity") private String name; + @JsonProperty @Schema(example = "Description of entity") private String description; diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/PagedList.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/PagedList.java index 35b0e52fe..6f0f0ae95 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/PagedList.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/PagedList.java @@ -41,8 +41,10 @@ public class PagedList extends RepresentationModel> { @JsonProperty private final List content; + @JsonProperty private final long total; + private final int size; /** diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/action/MgmtActionStatus.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/action/MgmtActionStatus.java index 26eb428b2..e043964de 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/action/MgmtActionStatus.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/action/MgmtActionStatus.java @@ -17,7 +17,6 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonProperty; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; -import lombok.ToString; import lombok.experimental.Accessors; /** @@ -25,7 +24,6 @@ import lombok.experimental.Accessors; */ @Data @Accessors(chain = true) -@ToString @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) public class MgmtActionStatus { @@ -33,14 +31,18 @@ public class MgmtActionStatus { @JsonProperty("id") @Schema(example = "21") private Long statusId; + @JsonProperty @Schema(example = "running") private String type; + @JsonProperty private List messages; + @JsonProperty @Schema(example = "1691065929524") private Long reportedAt; + @JsonProperty @Schema(example = "200") private Integer code; diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/artifact/MgmtArtifactHash.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/artifact/MgmtArtifactHash.java index c0135c9d8..38493e4f0 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/artifact/MgmtArtifactHash.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/artifact/MgmtArtifactHash.java @@ -28,9 +28,11 @@ public class MgmtArtifactHash { @JsonProperty @Schema(description = "SHA1 hash of the artifact", example = "2d86c2a659e364e9abba49ea6ffcd53dd5559f05") private String sha1; + @JsonProperty @Schema(description = "MD5 hash of the artifact.", example = "0d1b08c34858921bc7c662b228acb7ba") private String md5; + @JsonProperty @Schema(description = "SHA256 hash of the artifact", example = "a03b221c6c6eae7122ca51695d456d5222e524889136394944b2f9763b483615") private String sha256; diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/auth/MgmtUserInfo.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/auth/MgmtUserInfo.java index 6b859f894..4300abeca 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/auth/MgmtUserInfo.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/auth/MgmtUserInfo.java @@ -10,7 +10,6 @@ package org.eclipse.hawkbit.mgmt.json.model.auth; import lombok.Data; -import lombok.ToString; import lombok.experimental.Accessors; /** @@ -18,7 +17,6 @@ import lombok.experimental.Accessors; */ @Data @Accessors(chain = true) -@ToString public class MgmtUserInfo { private String tenant; diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtDistributionSet.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtDistributionSet.java index a5aac561a..33ddefd41 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtDistributionSet.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtDistributionSet.java @@ -165,8 +165,7 @@ public class MgmtDistributionSet extends MgmtNamedEntity { private boolean deleted; @JsonProperty - @Schema(description = "True by default and false after the distribution set is invalidated by the user", - example = "true") + @Schema(description = "True by default and false after the distribution set is invalidated by the user", example = "true") private boolean valid; @JsonProperty diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtDistributionSetRequestBodyPost.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtDistributionSetRequestBodyPost.java index 69e13187b..c6fabd66c 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtDistributionSetRequestBodyPost.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtDistributionSetRequestBodyPost.java @@ -20,7 +20,7 @@ import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; import lombok.experimental.Accessors; -import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleAssigment; +import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleAssignment; /** * A json annotated rest model for DistributionSet for POST. @@ -33,20 +33,23 @@ import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleAssi @JsonIgnoreProperties(ignoreUnknown = true) public class MgmtDistributionSetRequestBodyPost extends MgmtDistributionSetRequestBodyPut { - // deprecated format from the time where os, application and runtime where - // statically defined + // deprecated format from the time where os, application and runtime where statically defined @JsonProperty @Schema(hidden = true) - private MgmtSoftwareModuleAssigment os; + private MgmtSoftwareModuleAssignment os; + @JsonProperty @Schema(hidden = true) - private MgmtSoftwareModuleAssigment runtime; + private MgmtSoftwareModuleAssignment runtime; + @JsonProperty @Schema(hidden = true) - private MgmtSoftwareModuleAssigment application; + private MgmtSoftwareModuleAssignment application; + // deprecated format - END @JsonProperty - private List modules; + private List modules; + @JsonProperty @Schema(description = "The type of the distribution set", example = "test_default_ds_type") private String type; diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtDistributionSetStatistics.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtDistributionSetStatistics.java index 77df2ed6d..6a2746492 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtDistributionSetStatistics.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtDistributionSetStatistics.java @@ -34,8 +34,10 @@ public class MgmtDistributionSetStatistics { @JsonProperty("actions") private Map totalActionsPerStatus; + @JsonProperty("rollouts") private Map totalRolloutsPerStatus; + @JsonProperty private Long totalAutoAssignments; diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtInvalidateDistributionSetRequestBody.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtInvalidateDistributionSetRequestBody.java index 98e277efb..a7b48a876 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtInvalidateDistributionSetRequestBody.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtInvalidateDistributionSetRequestBody.java @@ -27,6 +27,7 @@ public class MgmtInvalidateDistributionSetRequestBody { @JsonProperty @Schema(description = "Type of cancelation for actions referring to the given distribution set") private MgmtCancelationType actionCancelationType; + @JsonProperty @Schema(description = "Defines if rollouts referring to this distribution set should be canceled", example = "true") private boolean cancelRollouts; diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtTargetAssignmentRequestBody.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtTargetAssignmentRequestBody.java index 836b15028..196841af0 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtTargetAssignmentRequestBody.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtTargetAssignmentRequestBody.java @@ -27,14 +27,19 @@ public class MgmtTargetAssignmentRequestBody { @Schema(description = "The technical identifier of the entity", example = "target4") private String id; + @Schema(description = "Forcetime in milliseconds", example = "1682408575278") private long forcetime; + @Schema(description = "The type of the assignment") private MgmtActionType type; + @Schema(description = "Separation of download and install by defining a maintenance window for the installation") private MgmtMaintenanceWindowRequestBody maintenanceWindow; + @Schema(description = "Importance of the assignment", example = "100") private Integer weight; + @Schema(description = "(Available with user consent flow active) Defines, if the confirmation is required for " + "an action. Confirmation is required per default") private Boolean confirmationRequired; diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtTargetAssignmentResponseBody.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtTargetAssignmentResponseBody.java index 56889907b..a590ff731 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtTargetAssignmentResponseBody.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtTargetAssignmentResponseBody.java @@ -37,6 +37,7 @@ public class MgmtTargetAssignmentResponseBody extends RepresentationModel assignedActions; diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionsettype/MgmtDistributionSetTypeAssignment.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionsettype/MgmtDistributionSetTypeAssignment.java index e202c45aa..b9716b214 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionsettype/MgmtDistributionSetTypeAssignment.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionsettype/MgmtDistributionSetTypeAssignment.java @@ -18,5 +18,4 @@ import org.eclipse.hawkbit.mgmt.json.model.MgmtId; */ @Accessors(chain = true) @JsonIgnoreProperties(ignoreUnknown = true) -public class MgmtDistributionSetTypeAssignment extends MgmtId { -} +public class MgmtDistributionSetTypeAssignment extends MgmtId {} diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionsettype/MgmtDistributionSetTypeRequestBodyPost.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionsettype/MgmtDistributionSetTypeRequestBodyPost.java index f173c004f..ca7d0f69d 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionsettype/MgmtDistributionSetTypeRequestBodyPost.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionsettype/MgmtDistributionSetTypeRequestBodyPost.java @@ -17,7 +17,7 @@ import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; import lombok.experimental.Accessors; -import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleTypeAssigment; +import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleTypeAssignment; /** * Request Body for DistributionSetType POST. @@ -38,10 +38,11 @@ public class MgmtDistributionSetTypeRequestBodyPost extends MgmtDistributionSetT @JsonProperty @Schema(description = "Mandatory module type IDs") - private List mandatorymodules; + private List mandatorymodules; + @JsonProperty @Schema(description = "Optional module type IDs") - private List optionalmodules; + private List optionalmodules; @Override public MgmtDistributionSetTypeRequestBodyPost setDescription(final String description) { diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionsettype/MgmtDistributionSetTypeRequestBodyPut.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionsettype/MgmtDistributionSetTypeRequestBodyPut.java index 226f8175b..5d853b0de 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionsettype/MgmtDistributionSetTypeRequestBodyPut.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionsettype/MgmtDistributionSetTypeRequestBodyPut.java @@ -26,6 +26,7 @@ public class MgmtDistributionSetTypeRequestBodyPut { @JsonProperty @Schema(description = "The description of the entity", example = "Example description") private String description; + @JsonProperty @Schema(description = "The colour of the entity", example = "rgb(86,37,99)") private String colour; diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/rollout/MgmtRolloutCondition.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/rollout/MgmtRolloutCondition.java index 8fe69f856..57e0a93b2 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/rollout/MgmtRolloutCondition.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/rollout/MgmtRolloutCondition.java @@ -28,8 +28,8 @@ public class MgmtRolloutCondition { @Schema(description = "The type of the condition") private Condition condition = Condition.THRESHOLD; - @Schema(description = "The expression according to the condition, e.g. the value of threshold in percentage", - example = "50") + + @Schema(description = "The expression according to the condition, e.g. the value of threshold in percentage", example = "50") private String expression = "100"; public MgmtRolloutCondition(final Condition condition, final String expression) { diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/rollout/MgmtRolloutErrorAction.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/rollout/MgmtRolloutErrorAction.java index ef554ce3a..656d4d254 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/rollout/MgmtRolloutErrorAction.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/rollout/MgmtRolloutErrorAction.java @@ -31,6 +31,7 @@ public class MgmtRolloutErrorAction { @Schema(description = "The error action to execute") private ErrorAction action = ErrorAction.PAUSE; + @Schema(description = "The expression for the error action", example = "80") private String expression; diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/rollout/MgmtRolloutRestRequestBodyPut.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/rollout/MgmtRolloutRestRequestBodyPut.java index b95a43efc..19cf39afd 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/rollout/MgmtRolloutRestRequestBodyPut.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/rollout/MgmtRolloutRestRequestBodyPut.java @@ -34,5 +34,4 @@ import org.eclipse.hawkbit.mgmt.json.model.MgmtNamedEntity; "name" : "exampleRollout", "description" : "Rollout for all named targets" }""") -public class MgmtRolloutRestRequestBodyPut extends MgmtNamedEntity { -} \ No newline at end of file +public class MgmtRolloutRestRequestBodyPut extends MgmtNamedEntity {} \ No newline at end of file diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/rollout/MgmtRolloutSuccessAction.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/rollout/MgmtRolloutSuccessAction.java index 22311f76a..d3ab0f694 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/rollout/MgmtRolloutSuccessAction.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/rollout/MgmtRolloutSuccessAction.java @@ -28,6 +28,7 @@ public class MgmtRolloutSuccessAction { @Schema(description = "The success action to execute") private SuccessAction action = SuccessAction.NEXTGROUP; + @Schema(description = "The expression for the success action") private String expression; diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/softwaremodule/MgmtSoftwareModuleAssigment.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/softwaremodule/MgmtSoftwareModuleAssignment.java similarity index 90% rename from hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/softwaremodule/MgmtSoftwareModuleAssigment.java rename to hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/softwaremodule/MgmtSoftwareModuleAssignment.java index b0e55db33..7c638f3b0 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/softwaremodule/MgmtSoftwareModuleAssigment.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/softwaremodule/MgmtSoftwareModuleAssignment.java @@ -16,6 +16,4 @@ import org.eclipse.hawkbit.mgmt.json.model.MgmtId; * Request Body of SoftwareModule for assignment operations (ID only). */ @JsonIgnoreProperties(ignoreUnknown = true) -public class MgmtSoftwareModuleAssigment extends MgmtId { - -} +public class MgmtSoftwareModuleAssignment extends MgmtId {} diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/softwaremodule/MgmtSoftwareModuleMetadataBodyPut.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/softwaremodule/MgmtSoftwareModuleMetadataBodyPut.java index 5b6dd50dc..66b00241e 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/softwaremodule/MgmtSoftwareModuleMetadataBodyPut.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/softwaremodule/MgmtSoftwareModuleMetadataBodyPut.java @@ -31,7 +31,8 @@ public class MgmtSoftwareModuleMetadataBodyPut { @JsonProperty @Schema(example = "newValue") private String value; + @JsonProperty @Schema(example = "true") private Boolean targetVisible; -} +} \ No newline at end of file diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/softwaremoduletype/MgmtSoftwareModuleTypeAssigment.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/softwaremoduletype/MgmtSoftwareModuleTypeAssignment.java similarity index 90% rename from hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/softwaremoduletype/MgmtSoftwareModuleTypeAssigment.java rename to hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/softwaremoduletype/MgmtSoftwareModuleTypeAssignment.java index 2e22cd689..4ad8ce758 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/softwaremoduletype/MgmtSoftwareModuleTypeAssigment.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/softwaremoduletype/MgmtSoftwareModuleTypeAssignment.java @@ -16,5 +16,4 @@ import org.eclipse.hawkbit.mgmt.json.model.MgmtId; * Request Body of SoftwareModuleType for assignment operations (ID only). */ @JsonIgnoreProperties(ignoreUnknown = true) -public class MgmtSoftwareModuleTypeAssigment extends MgmtId { -} +public class MgmtSoftwareModuleTypeAssignment extends MgmtId {} diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/softwaremoduletype/MgmtSoftwareModuleTypeRequestBodyPost.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/softwaremoduletype/MgmtSoftwareModuleTypeRequestBodyPost.java index 16072aeff..def7f15e0 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/softwaremoduletype/MgmtSoftwareModuleTypeRequestBodyPost.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/softwaremoduletype/MgmtSoftwareModuleTypeRequestBodyPost.java @@ -28,9 +28,11 @@ public class MgmtSoftwareModuleTypeRequestBodyPost extends MgmtSoftwareModuleTyp @JsonProperty(required = true) @Schema(example = "Example name") private String name; + @JsonProperty(required = true) @Schema(example = "Example key") private String key; + @JsonProperty @Schema(example = "1") private int maxAssignments; diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/softwaremoduletype/MgmtSoftwareModuleTypeRequestBodyPut.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/softwaremoduletype/MgmtSoftwareModuleTypeRequestBodyPut.java index 1225a66a8..250c9b54d 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/softwaremoduletype/MgmtSoftwareModuleTypeRequestBodyPut.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/softwaremoduletype/MgmtSoftwareModuleTypeRequestBodyPut.java @@ -26,6 +26,7 @@ public class MgmtSoftwareModuleTypeRequestBodyPut { @JsonProperty @Schema(example = "Example description") private String description; + @JsonProperty @Schema(example = "rgb(0,0,255") private String colour; diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/systemmanagement/MgmtSystemStatisticsRest.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/systemmanagement/MgmtSystemStatisticsRest.java index a140e50c5..8c5c94212 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/systemmanagement/MgmtSystemStatisticsRest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/systemmanagement/MgmtSystemStatisticsRest.java @@ -16,14 +16,12 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Data; -import lombok.ToString; import lombok.experimental.Accessors; /** * Body for system statistics. */ @Data -@ToString @Accessors(chain = true) @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/target/MgmtTargetAutoConfirmUpdate.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/target/MgmtTargetAutoConfirmUpdate.java index 0157e3d2c..f81a19ff3 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/target/MgmtTargetAutoConfirmUpdate.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/target/MgmtTargetAutoConfirmUpdate.java @@ -39,8 +39,8 @@ public class MgmtTargetAutoConfirmUpdate { * @param remark can be null */ @JsonCreator - public MgmtTargetAutoConfirmUpdate(@JsonProperty(value = "initiator") final String initiator, - @JsonProperty(value = "remark") final String remark) { + public MgmtTargetAutoConfirmUpdate( + @JsonProperty(value = "initiator") final String initiator, @JsonProperty(value = "remark") final String remark) { this.initiator = initiator; this.remark = remark; } diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/targetfilter/MgmtDistributionSetAutoAssignment.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/targetfilter/MgmtDistributionSetAutoAssignment.java index 9602b9539..ed1a87640 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/targetfilter/MgmtDistributionSetAutoAssignment.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/targetfilter/MgmtDistributionSetAutoAssignment.java @@ -29,8 +29,10 @@ public class MgmtDistributionSetAutoAssignment extends MgmtId { @JsonProperty private MgmtActionType type; + @JsonProperty private Integer weight; + @JsonProperty private Boolean confirmationRequired; } \ No newline at end of file diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/targetfilter/MgmtTargetFilterQueryRequestBody.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/targetfilter/MgmtTargetFilterQueryRequestBody.java index 04d78ec8e..a498b7067 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/targetfilter/MgmtTargetFilterQueryRequestBody.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/targetfilter/MgmtTargetFilterQueryRequestBody.java @@ -26,6 +26,7 @@ public class MgmtTargetFilterQueryRequestBody { @JsonProperty(required = true) @Schema(example = "filterName") private String name; + @JsonProperty(required = true) @Schema(example = "controllerId==example-target-*") private String query; diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtActionRestApi.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtActionRestApi.java index bd054a254..2c8cc2bb1 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtActionRestApi.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtActionRestApi.java @@ -35,18 +35,13 @@ public interface MgmtActionRestApi { /** * Handles the GET request of retrieving all actions. * - * @param pagingOffsetParam the offset of list of actions for pagination, might not be - * present in the rest request then default value will be applied - * @param pagingLimitParam the limit of the paged request, might not be present in the - * rest request then default value will be applied - * @param sortParam the sorting parameter in the request URL, syntax - * {@code field:direction, field:direction} - * @param rsqlParam the search parameter in the request URL, syntax - * {@code q=distributionSet.id==1} - * @param representationModeParam the representation mode parameter specifying whether a compact - * or a full representation shall be returned - * @return a list of all actions for a defined or default page request with - * status OK. The response is always paged. In any failure the + * @param pagingOffsetParam the offset of list of actions for pagination, might not be present in the rest request then default value will + * be applied + * @param pagingLimitParam the limit of the paged request, might not be present in the rest request then default value will be applied + * @param sortParam the sorting parameter in the request URL, syntax {@code field:direction, field:direction} + * @param rsqlParam the search parameter in the request URL, syntax {@code q=distributionSet.id==1} + * @param representationModeParam the representation mode parameter specifying whether a compact or a full representation shall be returned + * @return a list of all actions for a defined or default page request with status OK. The response is always paged. In any failure the * JsonResponseExceptionHandler is handling the response. */ @Operation(summary = "Return all actions", description = "Handles the GET request of retrieving all actions.") @@ -67,8 +62,7 @@ public interface MgmtActionRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = MgmtRestConstants.ACTION_V1_REQUEST_MAPPING, produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = MgmtRestConstants.ACTION_V1_REQUEST_MAPPING, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> getActions( @RequestParam( value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, @@ -101,8 +95,7 @@ public interface MgmtActionRestApi { String representationModeParam); /** - * Handles the GET request of retrieving a specific {@link MgmtAction} by - * its actionId. + * Handles the GET request of retrieving a specific {@link MgmtAction} by its actionId. * * @param actionId The ID of the requested action * @return the {@link MgmtAction} @@ -123,7 +116,7 @@ public interface MgmtActionRestApi { " and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "/{actionId}", produces = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "/{actionId}", + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity getAction(@PathVariable("actionId") Long actionId); } \ No newline at end of file diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtBasicAuthRestApi.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtBasicAuthRestApi.java index 63c3ecc91..1737d32b4 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtBasicAuthRestApi.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtBasicAuthRestApi.java @@ -29,7 +29,6 @@ public interface MgmtBasicAuthRestApi { * * @return the userinfo with status OK. */ - @GetMapping(value = MgmtRestConstants.AUTH_V1_REQUEST_MAPPING, produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = MgmtRestConstants.AUTH_V1_REQUEST_MAPPING, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity validateBasicAuth(); } diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetRestApi.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetRestApi.java index 9d7d48b24..74b351e1d 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetRestApi.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetRestApi.java @@ -30,7 +30,7 @@ import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtInvalidateDistrib import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtTargetAssignmentRequestBody; import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtTargetAssignmentResponseBody; import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModule; -import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleAssigment; +import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleAssignment; import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTarget; import org.eclipse.hawkbit.mgmt.json.model.targetfilter.MgmtTargetFilterQuery; import org.eclipse.hawkbit.rest.json.model.ExceptionInfo; @@ -54,16 +54,12 @@ public interface MgmtDistributionSetRestApi { /** * Handles the GET request of retrieving all DistributionSets . * - * @param pagingOffsetParam the offset of list of sets for pagination, might not be - * present in the rest request then default value will be applied - * @param pagingLimitParam the limit of the paged request, might not be present in the - * rest request then default value will be applied - * @param sortParam the sorting parameter in the request URL, syntax - * {@code field:direction, field:direction} - * @param rsqlParam the search parameter in the request URL, syntax - * {@code q=name==abc} - * @return a list of all set for a defined or default page request with - * status OK. The response is always paged. In any failure the + * @param pagingOffsetParam the offset of list of sets for pagination, might not be present in the rest request then default value will + * be applied + * @param pagingLimitParam the limit of the paged request, might not be present in the rest request then default value will be applied + * @param sortParam the sorting parameter in the request URL, syntax {@code field:direction, field:direction} + * @param rsqlParam the search parameter in the request URL, syntax {@code q=name==abc} + * @return a list of all set for a defined or default page request with status OK. The response is always paged. In any failure the * JsonResponseExceptionHandler is handling the response. */ @Operation(summary = "Return all Distribution Sets", description = "Handles the GET request of retrieving all " + @@ -85,8 +81,8 @@ public interface MgmtDistributionSetRestApi { "attempts and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING, produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING, + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> getDistributionSets( @RequestParam( value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, @@ -138,19 +134,16 @@ public interface MgmtDistributionSetRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}", produces = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}", + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity getDistributionSet(@PathVariable("distributionSetId") Long distributionSetId); /** - * Handles the POST request of creating new distribution sets . The request - * body must always be a list of sets. + * Handles the POST request of creating new distribution sets . The request body must always be a list of sets. * * @param sets the DistributionSets to be created. - * @return In case all sets could successful created the ResponseEntity with - * status code 201 - Created but without ResponseBody. In any - * failure the JsonResponseExceptionHandler is handling the - * response. + * @return In case all sets could successful created the ResponseEntity with status code 201 - Created but without ResponseBody. In any + * failure the JsonResponseExceptionHandler is handling the response. */ @Operation(summary = "Creates new Distribution Sets", description = "Handles the POST request of creating new " + "distribution sets within Hawkbit. The request body must always be a list of sets. " + @@ -178,9 +171,9 @@ public interface MgmtDistributionSetRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PostMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING, consumes = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) + @PostMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING, + consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> createDistributionSets(List sets); /** @@ -247,28 +240,22 @@ public interface MgmtDistributionSetRestApi { "attempts and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PutMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}", consumes = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, produces = { - MediaType.APPLICATION_JSON_VALUE, MediaTypes.HAL_JSON_VALUE }) + @PutMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}", + consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, + produces = { MediaType.APPLICATION_JSON_VALUE, MediaTypes.HAL_JSON_VALUE }) ResponseEntity updateDistributionSet(@PathVariable("distributionSetId") Long distributionSetId, MgmtDistributionSetRequestBodyPut toUpdate); /** - * Handles the GET request of retrieving assigned targets to a specific - * distribution set. + * Handles the GET request of retrieving assigned targets to a specific distribution set. * - * @param distributionSetId the ID of the distribution set to retrieve the assigned - * targets - * @param pagingOffsetParam the offset of list of targets for pagination, might not be - * present in the rest request then default value will be applied - * @param pagingLimitParam the limit of the paged request, might not be present in the - * rest request then default value will be applied - * @param sortParam the sorting parameter in the request URL, syntax - * {@code field:direction, field:direction} - * @param rsqlParam the search parameter in the request URL, syntax - * {@code q=name==abc} - * @return status OK if get request is successful with the paged list of - * targets + * @param distributionSetId the ID of the distribution set to retrieve the assigned targets + * @param pagingOffsetParam the offset of list of targets for pagination, might not be present in the rest request then default value will + * be applied + * @param pagingLimitParam the limit of the paged request, might not be present in the rest request then default value will be applied + * @param sortParam the sorting parameter in the request URL, syntax {@code field:direction, field:direction} + * @param rsqlParam the search parameter in the request URL, syntax {@code q=name==abc} + * @return status OK if get request is successful with the paged list of targets */ @Operation(summary = "Return assigned targets to a specific distribution set", description = "Handles the GET " + "request for retrieving assigned targets of a single distribution set. " + @@ -292,9 +279,8 @@ public interface MgmtDistributionSetRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING - + "/{distributionSetId}/assignedTargets", produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/assignedTargets", + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> getAssignedTargets(@PathVariable("distributionSetId") Long distributionSetId, @RequestParam( value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, @@ -320,14 +306,12 @@ public interface MgmtDistributionSetRestApi { String rsqlParam); /** - * Handles the GET request of retrieving installed targets to a specific - * distribution set. + * Handles the GET request of retrieving installed targets to a specific distribution set. * * @param distributionSetId the ID of the distribution set to retrieve the assigned targets - * @param pagingOffsetParam the offset of list of targets for pagination, might not be - * present in the rest request then default value will be applied - * @param pagingLimitParam the limit of the paged request, might not be present in the - * rest request then default value will be applied + * @param pagingOffsetParam the offset of list of targets for pagination, might not be present in the rest request then default value will + * be applied + * @param pagingLimitParam the limit of the paged request, might not be present in the rest request then default value will be applied * @param sortParam the sorting parameter in the request URL, syntax {@code field:direction, field:direction} * @param rsqlParam the search parameter in the request URL, syntax {@code q=name==abc} * @return status OK if get request is successful with the paged list of targets @@ -354,9 +338,8 @@ public interface MgmtDistributionSetRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING - + "/{distributionSetId}/installedTargets", produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/installedTargets", + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> getInstalledTargets(@PathVariable("distributionSetId") Long distributionSetId, @RequestParam( value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, @@ -382,21 +365,15 @@ public interface MgmtDistributionSetRestApi { String rsqlParam); /** - * Handles the GET request to retrieve target filter queries that have the - * given distribution set as auto assign DS. + * Handles the GET request to retrieve target filter queries that have the given distribution set as auto assign DS. * - * @param distributionSetId the ID of the distribution set to retrieve the assigned - * targets - * @param pagingOffsetParam the offset of list of targets for pagination, might not be - * present in the rest request then default value will be applied - * @param pagingLimitParam the limit of the paged request, might not be present in the - * rest request then default value will be applied - * @param sortParam the sorting parameter in the request URL, syntax - * {@code field:direction, field:direction} - * @param rsqlParam the search name parameter in the request URL, syntax - * {@code q=myFilter} - * @return status OK if get request is successful with the paged list of - * targets + * @param distributionSetId the ID of the distribution set to retrieve the assigned targets + * @param pagingOffsetParam the offset of list of targets for pagination, might not be present in the rest request then default value will + * be applied + * @param pagingLimitParam the limit of the paged request, might not be present in the rest request then default value will be applied + * @param sortParam the sorting parameter in the request URL, syntax {@code field:direction, field:direction} + * @param rsqlParam the search name parameter in the request URL, syntax {@code q=myFilter} + * @return status OK if get request is successful with the paged list of targets */ @Operation(summary = "Return target filter queries that have the given distribution set as auto assign DS", description = "Handles the GET request for retrieving assigned target filter queries of a single " + @@ -420,9 +397,8 @@ public interface MgmtDistributionSetRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING - + "/{distributionSetId}/autoAssignTargetFilters", produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/autoAssignTargetFilters", + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> getAutoAssignTargetFilterQueries( @PathVariable("distributionSetId") Long distributionSetId, @RequestParam( @@ -449,16 +425,12 @@ public interface MgmtDistributionSetRestApi { String rsqlParam); /** - * Handles the POST request of assigning multiple targets to a single - * distribution set. + * Handles the POST request of assigning multiple targets to a single distribution set. * * @param distributionSetId the ID of the distribution set within the URL path parameter - * @param targetIds the IDs of the target which should get assigned to the - * distribution set given in the response body - * @param offline to true if update was executed offline, i.e. not - * managed by hawkBit. - * @return status OK if the assignment of the targets was successful and a - * complex return body which contains information about the assigned + * @param targetIds the IDs of the target which should get assigned to the distribution set given in the response body + * @param offline to true if update was executed offline, i.e. not managed by hawkBit. + * @return status OK if the assignment of the targets was successful and a complex return body which contains information about the assigned * targets and the already assigned targets counters */ @Operation(summary = "Assigning multiple targets to a single distribution set", description = "Handles the POST " + @@ -501,10 +473,9 @@ public interface MgmtDistributionSetRestApi { * Gets a paged list of meta-data for a distribution set. * * @param distributionSetId the ID of the distribution set for the meta-data - * @param pagingOffsetParam the offset of list of targets for pagination, might not be - * present in the rest request then default value will be applied - * @param pagingLimitParam the limit of the paged request, might not be present in the - * rest request then default value will be applied + * @param pagingOffsetParam the offset of list of targets for pagination, might not be present in the rest request then default value will + * be applied + * @param pagingLimitParam the limit of the paged request, might not be present in the rest request then default value will be applied * @param sortParam the sorting parameter in the request URL, syntax {@code field:direction, field:direction} * @param rsqlParam the search parameter in the request URL, syntax {@code q=key==abc} * @return status OK if get request is successful with the paged list of meta data @@ -530,9 +501,8 @@ public interface MgmtDistributionSetRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING - + "/{distributionSetId}/metadata", produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/metadata", + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> getMetadata(@PathVariable("distributionSetId") Long distributionSetId, @RequestParam( value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, @@ -562,8 +532,7 @@ public interface MgmtDistributionSetRestApi { * * @param distributionSetId the ID of the distribution set to get the meta data from * @param metadataKey the key of the meta data entry to retrieve the value from - * @return status OK if get request is successful with the value of the meta - * data + * @return status OK if get request is successful with the value of the meta data */ @Operation(summary = "Return single meta data value for a specific key of a Distribution Set", description = "Get a single meta data value for a meta data key. Required permission: READ_REPOSITORY") @@ -586,8 +555,8 @@ public interface MgmtDistributionSetRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING - + "/{distributionSetId}/metadata/{metadataKey}", produces = { MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/metadata/{metadataKey}", + produces = { MediaType.APPLICATION_JSON_VALUE }) ResponseEntity getMetadataValue(@PathVariable("distributionSetId") Long distributionSetId, @PathVariable("metadataKey") String metadataKey); @@ -597,8 +566,7 @@ public interface MgmtDistributionSetRestApi { * @param distributionSetId the ID of the distribution set to update the meta data entry * @param metadataKey the key of the meta data to update the value * @param metadata update body - * @return status OK if the update request is successful and the updated - * meta data result + * @return status OK if the update request is successful and the updated meta data result */ @Operation(summary = "Update single meta data value of a distribution set", description = "Update a single meta " + "data value for speficic key. Required permission: UPDATE_REPOSITORY") @@ -627,9 +595,8 @@ public interface MgmtDistributionSetRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PutMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING - + "/{distributionSetId}/metadata/{metadataKey}", produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) + @PutMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/metadata/{metadataKey}", + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity updateMetadata(@PathVariable("distributionSetId") Long distributionSetId, @PathVariable("metadataKey") String metadataKey, MgmtMetadataBodyPut metadata); @@ -661,9 +628,9 @@ public interface MgmtDistributionSetRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @DeleteMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING - + "/{distributionSetId}/metadata/{metadataKey}") - ResponseEntity deleteMetadata(@PathVariable("distributionSetId") Long distributionSetId, + @DeleteMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/metadata/{metadataKey}") + ResponseEntity deleteMetadata( + @PathVariable("distributionSetId") Long distributionSetId, @PathVariable("metadataKey") String metadataKey); /** @@ -671,8 +638,7 @@ public interface MgmtDistributionSetRestApi { * * @param distributionSetId the ID of the distribution set to create meta data for * @param metadataRest the list of meta data entries to create - * @return status created if post request is successful with the value of - * the created meta data + * @return status created if post request is successful with the value of the created meta data */ @Operation(summary = "Create a list of meta data for a specific distribution set", description = "Create a list " + "of meta data entries Required permissions: READ_REPOSITORY and UPDATE_TARGET") @@ -701,11 +667,11 @@ public interface MgmtDistributionSetRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PostMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING - + "/{distributionSetId}/metadata", consumes = { MediaType.APPLICATION_JSON_VALUE, - MediaTypes.HAL_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity> createMetadata(@PathVariable("distributionSetId") Long distributionSetId, + @PostMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/metadata", + consumes = { MediaType.APPLICATION_JSON_VALUE, MediaTypes.HAL_JSON_VALUE }, + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + ResponseEntity> createMetadata( + @PathVariable("distributionSetId") Long distributionSetId, List metadataRest); /** @@ -744,20 +710,18 @@ public interface MgmtDistributionSetRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PostMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING - + "/{distributionSetId}/assignedSM", consumes = { MediaType.APPLICATION_JSON_VALUE, - MediaTypes.HAL_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity assignSoftwareModules(@PathVariable("distributionSetId") Long distributionSetId, - List softwareModuleIDs); + @PostMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/assignedSM", + consumes = { MediaType.APPLICATION_JSON_VALUE, MediaTypes.HAL_JSON_VALUE }, + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + ResponseEntity assignSoftwareModules( + @PathVariable("distributionSetId") Long distributionSetId, + List softwareModuleIDs); /** * Deletes the assignment of the software module form the distribution set. * - * @param distributionSetId the ID of the distribution set to reject the software module - * for - * @param softwareModuleId the software module id to get rejected form the distribution - * set + * @param distributionSetId the ID of the distribution set to reject the software module for + * @param softwareModuleId the software module id to get rejected form the distribution set * @return status OK if rejection was successful. */ @Operation(summary = "Delete the assignment of the software module from the distribution set", @@ -781,9 +745,9 @@ public interface MgmtDistributionSetRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @DeleteMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING - + "/{distributionSetId}/assignedSM/{softwareModuleId}") - ResponseEntity deleteAssignSoftwareModules(@PathVariable("distributionSetId") Long distributionSetId, + @DeleteMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/assignedSM/{softwareModuleId}") + ResponseEntity deleteAssignSoftwareModules( + @PathVariable("distributionSetId") Long distributionSetId, @PathVariable("softwareModuleId") Long softwareModuleId); /** @@ -791,14 +755,11 @@ public interface MgmtDistributionSetRestApi { * specific distribution set. * * @param distributionSetId the ID of the distribution to retrieve - * @param pagingOffsetParam the offset of list of sets for pagination, might not be - * present in the rest request then default value will be applied - * @param pagingLimitParam the limit of the paged request, might not be present in the - * rest request then default value will be applied - * @param sortParam the sorting parameter in the request URL, syntax - * {@code field:direction, field:direction} - * @return a list of the assigned software modules of a distribution set - * with status OK, if none is assigned than {@code null} + * @param pagingOffsetParam the offset of list of sets for pagination, might not be present in the rest request then default value will + * be applied + * @param pagingLimitParam the limit of the paged request, might not be present in the rest request then default value will be applied + * @param sortParam the sorting parameter in the request URL, syntax {@code field:direction, field:direction} + * @return a list of the assigned software modules of a distribution set with status OK, if none is assigned than {@code null} */ @Operation(summary = "Return the assigned software modules of a specific distribution set", description = "Handles the GET request of retrieving a single distribution set. " + @@ -822,9 +783,8 @@ public interface MgmtDistributionSetRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING - + "/{distributionSetId}/assignedSM", produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/assignedSM", + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> getAssignedSoftwareModules( @PathVariable("distributionSetId") Long distributionSetId, @RequestParam( @@ -846,8 +806,7 @@ public interface MgmtDistributionSetRestApi { String sortParam); /** - * Handles the GET request of retrieving Rollouts count by Status - * for Distribution Set. + * Handles the GET request of retrieving Rollouts count by Status for Distribution Set. * * @param distributionSetId the ID of the set to retrieve * @return a DistributionSetStatistics with status OK. @@ -873,8 +832,8 @@ public interface MgmtDistributionSetRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/statistics/rollouts", produces = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/statistics/rollouts", + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity getRolloutsCountByStatusForDistributionSet( @PathVariable("distributionSetId") Long distributionSetId); @@ -912,8 +871,7 @@ public interface MgmtDistributionSetRestApi { @PathVariable("distributionSetId") Long distributionSetId); /** - * Handles the GET request of retrieving Auto Assignments count - * for Distribution Set. + * Handles the GET request of retrieving Auto Assignments count for Distribution Set. * * @param distributionSetId the ID of the set to retrieve * @return a DistributionSetStatistics with status OK. @@ -945,8 +903,7 @@ public interface MgmtDistributionSetRestApi { @PathVariable("distributionSetId") Long distributionSetId); /** - * Handles the GET request of retrieving Rollouts, Actions and - * Auto Assignments counts by Status for Distribution Set. + * Handles the GET request of retrieving Rollouts, Actions and Auto Assignments counts by Status for Distribution Set. * * @param distributionSetId the ID of the set to retrieve * @return a DistributionSetStatistics with status OK. @@ -973,8 +930,8 @@ public interface MgmtDistributionSetRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/statistics", produces = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/statistics", + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity getStatisticsForDistributionSet(@PathVariable("distributionSetId") Long distributionSetId); /** @@ -1015,10 +972,10 @@ public interface MgmtDistributionSetRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PostMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING - + "/{distributionSetId}/invalidate", consumes = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity invalidateDistributionSet(@PathVariable("distributionSetId") Long distributionSetId, + @PostMapping(value = MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/invalidate", + consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + ResponseEntity invalidateDistributionSet( + @PathVariable("distributionSetId") Long distributionSetId, @Valid MgmtInvalidateDistributionSetRequestBody invalidateRequestBody); } diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetTagRestApi.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetTagRestApi.java index 202f32664..16c9d31ea 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetTagRestApi.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetTagRestApi.java @@ -45,17 +45,12 @@ public interface MgmtDistributionSetTagRestApi { /** * Handles the GET request of retrieving all DistributionSet tags. * - * @param pagingOffsetParam the offset of list of DistributionSet tags for pagination, - * might not be present in the rest request then default value - * will be applied - * @param pagingLimitParam the limit of the paged request, might not be present in the - * rest request then default value will be applied - * @param sortParam the sorting parameter in the request URL, syntax - * {@code field:direction, field:direction} - * @param rsqlParam the search parameter in the request URL, syntax - * {@code q=name==abc} - * @return a list of all target tags for a defined or default page request - * with status OK. The response is always paged. In any failure the + * @param pagingOffsetParam the offset of list of DistributionSet tags for pagination, might not be present in the rest request then default + * value will be applied + * @param pagingLimitParam the limit of the paged request, might not be present in the rest request then default value will be applied + * @param sortParam the sorting parameter in the request URL, syntax {@code field:direction, field:direction} + * @param rsqlParam the search parameter in the request URL, syntax {@code q=name==abc} + * @return a list of all target tags for a defined or default page request with status OK. The response is always paged. In any failure the * JsonResponseExceptionHandler is handling the response. */ @Operation(summary = "Return all Distribution Set Tags", description = "Handles the GET request of retrieving " + @@ -78,8 +73,8 @@ public interface MgmtDistributionSetTagRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING, produces = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING, + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> getDistributionSetTags( @RequestParam( value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, @@ -132,17 +127,15 @@ public interface MgmtDistributionSetTagRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING - + "/{distributionsetTagId}", produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/{distributionsetTagId}", + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity getDistributionSetTag(@PathVariable("distributionsetTagId") Long distributionsetTagId); /** - * Handles the POST request of creating new distribution set tag. The - * request body must always be a list of tags. + * Handles the POST request of creating new distribution set tag. The request body must always be a list of tags. * * @param tags the distribution set tags to be created. - * @return In case all modules could successful created the ResponseEntity - * with status code 201 - Created. The Response Body contains the + * @return In case all modules could successful created the ResponseEntity with status code 201 - Created. The Response Body contains the * created distribution set tags but without details. */ @Operation(summary = "Creates new Distribution Set Tags", description = "Handles the POST request of creating " + @@ -171,9 +164,9 @@ public interface MgmtDistributionSetTagRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PostMapping(value = MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING, consumes = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) + @PostMapping(value = MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING, + consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> createDistributionSetTags(List tags); /** @@ -181,8 +174,7 @@ public interface MgmtDistributionSetTagRestApi { * * @param distributionsetTagId the ID of the distribution set tag * @param restDSTagRest the request body to be updated - * @return status OK if update is successful and the updated distribution - * set tag. + * @return status OK if update is successful and the updated distribution set tag. */ @Operation(summary = "Update Distribution Set Tag", description = "Handles the PUT request of updating a distribution set tag.") @@ -212,11 +204,11 @@ public interface MgmtDistributionSetTagRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PutMapping(value = MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING - + "/{distributionsetTagId}", consumes = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity updateDistributionSetTag(@PathVariable("distributionsetTagId") Long distributionsetTagId, + @PutMapping(value = MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/{distributionsetTagId}", + consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + ResponseEntity updateDistributionSetTag( + @PathVariable("distributionsetTagId") Long distributionsetTagId, MgmtTagRequestBodyPut restDSTagRest); /** @@ -257,18 +249,14 @@ public interface MgmtDistributionSetTagRestApi { ResponseEntity deleteDistributionSetTag(@PathVariable("distributionsetTagId") Long distributionsetTagId); /** - * Handles the GET request of retrieving all assigned distribution sets by - * the given tag id. + * Handles the GET request of retrieving all assigned distribution sets by the given tag id. * * @param distributionsetTagId the ID of the distribution set tag - * @param pagingOffsetParam the offset of list of target tags for pagination, might not be - * present in the rest request then default value will be applied - * @param pagingLimitParam the limit of the paged request, might not be present in the - * rest request then default value will be applied - * @param sortParam the sorting parameter in the request URL, syntax - * {@code field:direction, field:direction} - * @param rsqlParam the search parameter in the request URL, syntax - * {@code q=name==abc} + * @param pagingOffsetParam the offset of list of target tags for pagination, might not be present in the rest request then default value + * will be applied + * @param pagingLimitParam the limit of the paged request, might not be present in the rest request then default value will be applied + * @param sortParam the sorting parameter in the request URL, syntax {@code field:direction, field:direction} + * @param rsqlParam the search parameter in the request URL, syntax {@code q=name==abc} * @return the list of assigned distribution sets. */ @Operation(summary = "Return all assigned distribution sets by given tag Id", @@ -293,9 +281,8 @@ public interface MgmtDistributionSetTagRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING - + MgmtRestConstants.DISTRIBUTIONSET_TAG_DISTRIBUTIONSETS_REQUEST_MAPPING, produces = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + MgmtRestConstants.DISTRIBUTIONSET_TAG_DISTRIBUTIONSETS_REQUEST_MAPPING, + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> getAssignedDistributionSets( @PathVariable("distributionsetTagId") Long distributionsetTagId, @RequestParam( @@ -329,8 +316,7 @@ public interface MgmtDistributionSetTagRestApi { * @return the list of assigned distribution set. */ @Operation(summary = "Assign distribution set to the given tag id", - description = "Handles the POST request of distribution assignment. Already assigned distribution will " + - "be ignored.") + description = "Handles the POST request of distribution assignment. Already assigned distribution will be ignored.") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Successfully retrieved"), @ApiResponse(responseCode = "400", description = "Bad Request - e.g. invalid parameters", @@ -355,8 +341,7 @@ public interface MgmtDistributionSetTagRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PostMapping(value = MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + - MgmtRestConstants.DISTRIBUTIONSET_TAG_DISTRIBUTIONSETS_REQUEST_MAPPING + "/{distributionsetId}") + @PostMapping(value = MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + MgmtRestConstants.DISTRIBUTIONSET_TAG_DISTRIBUTIONSETS_REQUEST_MAPPING + "/{distributionsetId}") ResponseEntity assignDistributionSet( @PathVariable("distributionsetTagId") Long distributionsetTagId, @PathVariable("distributionsetId") Long distributionsetId); @@ -369,8 +354,7 @@ public interface MgmtDistributionSetTagRestApi { * @return the list of assigned distribution set. */ @Operation(summary = "Assign distribution sets to the given tag id", - description = "Handles the POST request of distribution assignment. Already assigned distribution will " + - "be ignored.") + description = "Handles the POST request of distribution assignment. Already assigned distribution will be ignored.") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Successfully retrieved"), @ApiResponse(responseCode = "400", description = "Bad Request - e.g. invalid parameters", @@ -397,10 +381,9 @@ public interface MgmtDistributionSetTagRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PutMapping(value = MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING - + MgmtRestConstants.DISTRIBUTIONSET_TAG_DISTRIBUTIONSETS_REQUEST_MAPPING, consumes = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, produces = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @PutMapping(value = MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + MgmtRestConstants.DISTRIBUTIONSET_TAG_DISTRIBUTIONSETS_REQUEST_MAPPING, + consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity assignDistributionSets( @PathVariable("distributionsetTagId") Long distributionsetTagId, @RequestBody List distributionsetIds); @@ -481,9 +464,8 @@ public interface MgmtDistributionSetTagRestApi { * * @param distributionsetTagId the ID of the distribution set tag to retrieve * @param assignedDSRequestBodies list of distribution set ids to be toggled - * @return the list of assigned distribution sets and unassigned - * distribution sets. - * @deprecated since 0.6.0 with toggle assigment deprecation + * @return the list of assigned distribution sets and unassigned distribution sets. + * @deprecated since 0.6.0 with toggle assignment deprecation */ @Operation(summary = "[DEPRECATED] Toggle the assignment of distribution sets by the given tag id", description = "Handles the POST request of toggle distribution assignment. The request body must " + @@ -512,8 +494,8 @@ public interface MgmtDistributionSetTagRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PostMapping(value = MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING - + MgmtRestConstants.DISTRIBUTIONSET_TAG_DISTRIBUTIONSETS_REQUEST_MAPPING + "/toggleTagAssignment") + @PostMapping(value = MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + + MgmtRestConstants.DISTRIBUTIONSET_TAG_DISTRIBUTIONSETS_REQUEST_MAPPING + "/toggleTagAssignment") @Deprecated(forRemoval = true, since = "0.6.0") ResponseEntity toggleTagAssignment( @PathVariable("distributionsetTagId") Long distributionsetTagId, @@ -554,10 +536,9 @@ public interface MgmtDistributionSetTagRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PostMapping(value = MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING - + MgmtRestConstants.DISTRIBUTIONSET_TAG_DISTRIBUTIONSETS_REQUEST_MAPPING, consumes = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, produces = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @PostMapping(value = MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + MgmtRestConstants.DISTRIBUTIONSET_TAG_DISTRIBUTIONSETS_REQUEST_MAPPING, + consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) @Deprecated(forRemoval = true, since = "0.6.0") ResponseEntity> assignDistributionSetsByRequestBody( @PathVariable("distributionsetTagId") Long distributionsetTagId, diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetTypeRestApi.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetTypeRestApi.java index a0bdd6b55..b48968818 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetTypeRestApi.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDistributionSetTypeRestApi.java @@ -44,18 +44,13 @@ public interface MgmtDistributionSetTypeRestApi { /** * Handles the GET request of retrieving all DistributionSetTypes. * - * @param pagingOffsetParam the offset of list of modules for pagination, might not be - * present in the rest request then default value will be applied - * @param pagingLimitParam the limit of the paged request, might not be present in the - * rest request then default value will be applied - * @param sortParam the sorting parameter in the request URL, syntax - * {@code field:direction, field:direction} - * @param rsqlParam the search parameter in the request URL, syntax - * {@code q=name==abc} - * @return a list of all DistributionSetType for a defined or default page - * request with status OK. The response is always paged. In any - * failure the JsonResponseExceptionHandler is handling the - * response. + * @param pagingOffsetParam the offset of list of modules for pagination, might not be present in the rest request then default value will + * be applied + * @param pagingLimitParam the limit of the paged request, might not be present in the rest request then default value will be applied + * @param sortParam the sorting parameter in the request URL, syntax {@code field:direction, field:direction} + * @param rsqlParam the search parameter in the request URL, syntax {@code q=name==abc} + * @return a list of all DistributionSetType for a defined or default page request with status OK. The response is always paged. In any + * failure the JsonResponseExceptionHandler is handling the response. */ @Operation(summary = "Return all Distribution Set Types", description = "Handles the GET request of " + "retrieving all distribution set types. Required Permission: READ_REPOSITORY") @@ -77,8 +72,8 @@ public interface MgmtDistributionSetTypeRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING, produces = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING, + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> getDistributionSetTypes( @RequestParam( value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, @@ -104,8 +99,7 @@ public interface MgmtDistributionSetTypeRestApi { String rsqlParam); /** - * Handles the GET request of retrieving a single DistributionSetType - * within. + * Handles the GET request of retrieving a single DistributionSetType within. * * @param distributionSetTypeId the ID of the DS type to retrieve * @return a single DS type with status OK. @@ -132,8 +126,8 @@ public interface MgmtDistributionSetTypeRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING - + "/{distributionSetTypeId}", produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/{distributionSetTypeId}", + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity getDistributionSetType( @PathVariable("distributionSetTypeId") Long distributionSetTypeId); @@ -203,23 +197,19 @@ public interface MgmtDistributionSetTypeRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PutMapping(value = MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING - + "/{distributionSetTypeId}", consumes = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) + @PutMapping(value = MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/{distributionSetTypeId}", + consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity updateDistributionSetType( @PathVariable("distributionSetTypeId") Long distributionSetTypeId, MgmtDistributionSetTypeRequestBodyPut restDistributionSetType); /** - * Handles the POST request of creating new DistributionSetTypes. The - * request body must always be a list of types. + * Handles the POST request of creating new DistributionSetTypes. The request body must always be a list of types. * * @param distributionSetTypes the modules to be created. - * @return In case all modules could successful created the ResponseEntity - * with status code 201 - Created but without ResponseBody. In any - * failure the JsonResponseExceptionHandler is handling the - * response. + * @return In case all modules could successful created the ResponseEntity with status code 201 - Created but without ResponseBody. In any + * failure the JsonResponseExceptionHandler is handling the response. */ @Operation(summary = "Create new distribution set types", description = "Handles the POST request for creating " + "new distribution set types. The request body must always be a list of types. " + @@ -248,15 +238,14 @@ public interface MgmtDistributionSetTypeRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PostMapping(value = MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING, consumes = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) + @PostMapping(value = MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING, + consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> createDistributionSetTypes( List distributionSetTypes); /** - * Handles the GET request of retrieving the list of mandatory software - * module types in that distribution set type. + * Handles the GET request of retrieving the list of mandatory software module types in that distribution set type. * * @param distributionSetTypeId of the DistributionSetType. * @return Unpaged list of module types and OK in case of success. @@ -284,9 +273,9 @@ public interface MgmtDistributionSetTypeRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/{distributionSetTypeId}/" - + MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_MANDATORY_MODULE_TYPES, produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/{distributionSetTypeId}/" + + MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_MANDATORY_MODULE_TYPES, + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> getMandatoryModules( @PathVariable("distributionSetTypeId") Long distributionSetTypeId); @@ -321,16 +310,15 @@ public interface MgmtDistributionSetTypeRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/{distributionSetTypeId}/" - + MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_MANDATORY_MODULE_TYPES - + "/{softwareModuleTypeId}", produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/{distributionSetTypeId}/" + + MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_MANDATORY_MODULE_TYPES + "/{softwareModuleTypeId}", + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity getMandatoryModule( @PathVariable("distributionSetTypeId") Long distributionSetTypeId, @PathVariable("softwareModuleTypeId") Long softwareModuleTypeId); /** - * Handles the GET request of retrieving the single optional software module - * type in that distribution set type. + * Handles the GET request of retrieving the single optional software module type in that distribution set type. * * @param distributionSetTypeId of the DistributionSetType. * @param softwareModuleTypeId of SoftwareModuleType. @@ -359,16 +347,15 @@ public interface MgmtDistributionSetTypeRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/{distributionSetTypeId}/" - + MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_OPTIONAL_MODULE_TYPES - + "/{softwareModuleTypeId}", produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/{distributionSetTypeId}/" + + MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_OPTIONAL_MODULE_TYPES + "/{softwareModuleTypeId}", + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity getOptionalModule( @PathVariable("distributionSetTypeId") Long distributionSetTypeId, @PathVariable("softwareModuleTypeId") Long softwareModuleTypeId); /** - * Handles the GET request of retrieving the list of optional software - * module types in that distribution set type. + * Handles the GET request of retrieving the list of optional software module types in that distribution set type. * * @param distributionSetTypeId of the DistributionSetType. * @return Unpaged list of module types and OK in case of success. @@ -396,15 +383,14 @@ public interface MgmtDistributionSetTypeRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/{distributionSetTypeId}/" - + MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_OPTIONAL_MODULE_TYPES, produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/{distributionSetTypeId}/" + + MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_OPTIONAL_MODULE_TYPES, + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> getOptionalModules( @PathVariable("distributionSetTypeId") Long distributionSetTypeId); /** - * Handles DELETE request for removing a mandatory module from the - * DistributionSetType. + * Handles DELETE request for removing a mandatory module from the DistributionSetType. * * @param distributionSetTypeId of the DistributionSetType. * @param softwareModuleTypeId of the SoftwareModuleType to remove @@ -433,14 +419,13 @@ public interface MgmtDistributionSetTypeRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @DeleteMapping(value = MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/{distributionSetTypeId}/" - + MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_MANDATORY_MODULE_TYPES + "/{softwareModuleTypeId}") + @DeleteMapping(value = MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/{distributionSetTypeId}/" + + MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_MANDATORY_MODULE_TYPES + "/{softwareModuleTypeId}") ResponseEntity removeMandatoryModule(@PathVariable("distributionSetTypeId") Long distributionSetTypeId, @PathVariable("softwareModuleTypeId") Long softwareModuleTypeId); /** - * Handles DELETE request for removing an optional module from the - * DistributionSetType. + * Handles DELETE request for removing an optional module from the DistributionSetType. * * @param distributionSetTypeId of the DistributionSetType. * @param softwareModuleTypeId of the SoftwareModuleType to remove @@ -470,14 +455,13 @@ public interface MgmtDistributionSetTypeRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @DeleteMapping(value = MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/{distributionSetTypeId}/" - + MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_OPTIONAL_MODULE_TYPES + "/{softwareModuleTypeId}") + @DeleteMapping(value = MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/{distributionSetTypeId}/" + + MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_OPTIONAL_MODULE_TYPES + "/{softwareModuleTypeId}") ResponseEntity removeOptionalModule(@PathVariable("distributionSetTypeId") Long distributionSetTypeId, @PathVariable("softwareModuleTypeId") Long softwareModuleTypeId); /** - * Handles the POST request for adding a mandatory software module type to a - * distribution set type. + * Handles the POST request for adding a mandatory software module type to a distribution set type. * * @param distributionSetTypeId of the DistributionSetType. * @param smtId of the SoftwareModuleType to add @@ -513,15 +497,13 @@ public interface MgmtDistributionSetTypeRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PostMapping(value = MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/{distributionSetTypeId}/" - + MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_MANDATORY_MODULE_TYPES, consumes = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity addMandatoryModule(@PathVariable("distributionSetTypeId") Long distributionSetTypeId, - MgmtId smtId); + @PostMapping(value = MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/{distributionSetTypeId}/" + + MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_MANDATORY_MODULE_TYPES, + consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + ResponseEntity addMandatoryModule(@PathVariable("distributionSetTypeId") Long distributionSetTypeId, MgmtId smtId); /** - * Handles the POST request for adding an optional software module type to a - * distribution set type. + * Handles the POST request for adding an optional software module type to a distribution set type. * * @param distributionSetTypeId of the DistributionSetType. * @param smtId of the SoftwareModuleType to add @@ -557,9 +539,8 @@ public interface MgmtDistributionSetTypeRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PostMapping(value = MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/{distributionSetTypeId}/" - + MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_OPTIONAL_MODULE_TYPES, consumes = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity addOptionalModule(@PathVariable("distributionSetTypeId") Long distributionSetTypeId, - MgmtId smtId); + @PostMapping(value = MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/{distributionSetTypeId}/" + + MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_OPTIONAL_MODULE_TYPES, + consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + ResponseEntity addOptionalModule(@PathVariable("distributionSetTypeId") Long distributionSetTypeId, MgmtId smtId); } \ No newline at end of file diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDownloadArtifactRestApi.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDownloadArtifactRestApi.java index 5c783b0da..c4d06a5b7 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDownloadArtifactRestApi.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtDownloadArtifactRestApi.java @@ -32,10 +32,8 @@ public interface MgmtDownloadArtifactRestApi { * @param artifactId of the related LocalArtifact * @return responseEntity with status ok if successful */ - @GetMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING - + "/{softwareModuleId}/artifacts/{artifactId}/download") + @GetMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/artifacts/{artifactId}/download") @ResponseBody ResponseEntity downloadArtifact(@PathVariable("softwareModuleId") Long softwareModuleId, @PathVariable("artifactId") Long artifactId); - } \ No newline at end of file diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtRepresentationMode.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtRepresentationMode.java index bdef367ed..90972cbb6 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtRepresentationMode.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtRepresentationMode.java @@ -23,7 +23,7 @@ public enum MgmtRepresentationMode { private final String mode; - private MgmtRepresentationMode(final String mode) { + MgmtRepresentationMode(final String mode) { this.mode = mode; } @@ -35,5 +35,4 @@ public enum MgmtRepresentationMode { public String toString() { return mode; } - -} +} \ No newline at end of file diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtRestConstants.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtRestConstants.java index c40628a60..8d21f5e70 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtRestConstants.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtRestConstants.java @@ -22,12 +22,10 @@ public final class MgmtRestConstants { * API version definition. We are using only major versions. */ public static final String API_VERSION = "v1"; - /** * The base URL mapping of the SP rest resources. */ public static final String BASE_REST_MAPPING = "/rest"; - /** * The base URL mapping of the SP rest resources. */ @@ -165,23 +163,19 @@ public final class MgmtRestConstants { */ public static final String DISTRIBUTIONSET_TAG_DISTRIBUTIONSETS_REQUEST_MAPPING = "/{distributionsetTagId}/assigned"; /** - * The default offset parameter in case the offset parameter is not present - * in the request. + * The default offset parameter in case the offset parameter is not present in the request. * * @see #REQUEST_PARAMETER_PAGING_OFFSET */ public static final String REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET = "0"; /** - * The default offset parameter in case the offset parameter is not present - * in the request. + * The default offset parameter in case the offset parameter is not present in the request. * * @see #REQUEST_PARAMETER_PAGING_OFFSET */ - public static final int REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET_VALUE = Integer - .parseInt(REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET); + public static final int REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET_VALUE = Integer.parseInt(REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET); /** - * Limit http parameter for the limitation of returned values for a paged - * request. + * Limit http parameter for the limitation of returned values for a paged request. */ public static final String REQUEST_PARAMETER_PAGING_LIMIT = "limit"; /** @@ -193,20 +187,16 @@ public final class MgmtRestConstants { */ public static final String REQUEST_PARAMETER_PAGING_OFFSET = "offset"; /** - * The request parameter for sorting. The value of the sort parameter must - * be in the following pattern. Example: - * http://www.bosch.com/iap/sp/rest/targets?sort=field_1:ASC,field_2:DESC, - * field_3:ASC + * The request parameter for sorting. The value of the sort parameter must be in the following pattern. Example: + * http://www.bosch.com/iap/sp/rest/targets?sort=field_1:ASC,field_2:DESC,field_3:ASC */ public static final String REQUEST_PARAMETER_SORTING = "sort"; /** - * The request parameter for searching. The value of the search parameter - * must be in the FIQL syntax. + * The request parameter for searching. The value of the search parameter must be in the FIQL syntax. */ public static final String REQUEST_PARAMETER_SEARCH = "q"; /** - * The request parameter for specifying the representation mode. The value - * of this parameter can either be "full" or "compact". + * The request parameter for specifying the representation mode. The value of this parameter can either be "full" or "compact". */ public static final String REQUEST_PARAMETER_REPRESENTATION_MODE = "representation"; /** diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtRolloutRestApi.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtRolloutRestApi.java index 586bdc845..f39e0d0e3 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtRolloutRestApi.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtRolloutRestApi.java @@ -43,18 +43,13 @@ public interface MgmtRolloutRestApi { /** * Handles the GET request of retrieving all rollouts. * - * @param pagingOffsetParam the offset of list of rollouts for pagination, might not be - * present in the rest request then default value will be applied - * @param pagingLimitParam the limit of the paged request, might not be present in the - * rest request then default value will be applied - * @param sortParam the sorting parameter in the request URL, syntax - * {@code field:direction, field:direction} - * @param rsqlParam the search parameter in the request URL, syntax - * {@code q=name==abc} - * @param representationModeParam the representation mode parameter specifying whether a compact - * or a full representation shall be returned - * @return a list of all rollouts for a defined or default page request with - * status OK. The response is always paged. In any failure the + * @param pagingOffsetParam the offset of list of rollouts for pagination, might not be present in the rest request then default value will + * be applied + * @param pagingLimitParam the limit of the paged request, might not be present in the rest request then default value will be applied + * @param sortParam the sorting parameter in the request URL, syntax {@code field:direction, field:direction} + * @param rsqlParam the search parameter in the request URL, syntax {@code q=name==abc} + * @param representationModeParam the representation mode parameter specifying whether a compact or a full representation shall be returned + * @return a list of all rollouts for a defined or default page request with status OK. The response is always paged. In any failure the * JsonResponseExceptionHandler is handling the response. */ @Operation(summary = "Return all Rollouts", description = "Handles the GET request of retrieving all rollouts. " + @@ -77,8 +72,8 @@ public interface MgmtRolloutRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING, produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING, + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> getRollouts( @RequestParam( value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, @@ -134,18 +129,16 @@ public interface MgmtRolloutRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}", produces = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}", + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity getRollout(@PathVariable("rolloutId") Long rolloutId); /** * Handles the POST request for creating rollout. * * @param rolloutCreateBody the rollout body to be created. - * @return In case rollout could successful created the ResponseEntity with - * status code 201 with the successfully created rollout. In any - * failure the JsonResponseExceptionHandler is handling the - * response. + * @return In case rollout could successful created the ResponseEntity with status code 201 with the successfully created rollout. In any + * failure the JsonResponseExceptionHandler is handling the response. */ @Operation(summary = "Create a new Rollout", description = "Handles the POST request of creating new rollout. Required Permission: CREATE_ROLLOUT") @@ -173,19 +166,17 @@ public interface MgmtRolloutRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PostMapping(value = MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING, consumes = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) + @PostMapping(value = MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING, + consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity create(MgmtRolloutRestRequestBodyPost rolloutCreateBody); /** * Handles the POST request for creating rollout. * * @param rolloutUpdateBody the rollout body with details for update. - * @return In case rollout could successful updated the ResponseEntity with - * status code 200 with the successfully created rollout. In any - * failure the JsonResponseExceptionHandler is handling the - * response. + * @return In case rollout could successful updated the ResponseEntity with status code 200 with the successfully created rollout. In any + * failure the JsonResponseExceptionHandler is handling the response. */ @Operation(summary = "Update Rollout", description = "Handles the UPDATE request for a single " + "Rollout. Required permission: UPDATE_ROLLOUT") @@ -214,10 +205,11 @@ public interface MgmtRolloutRestApi { "attempts and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PutMapping(value = MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}", consumes = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, produces = { - MediaType.APPLICATION_JSON_VALUE, MediaTypes.HAL_JSON_VALUE }) - ResponseEntity update(@PathVariable("rolloutId") Long rolloutId, + @PutMapping(value = MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}", + consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, + produces = { MediaType.APPLICATION_JSON_VALUE, MediaTypes.HAL_JSON_VALUE }) + ResponseEntity update( + @PathVariable("rolloutId") Long rolloutId, @RequestBody MgmtRolloutRestRequestBodyPut rolloutUpdateBody); /** @@ -225,8 +217,7 @@ public interface MgmtRolloutRestApi { * * @param rolloutId the ID of the rollout to be approved. * @param remark an optional remark on the approval decision - * @return OK response (200) if rollout is approved now. In case of any - * exception the corresponding errors occur. + * @return OK response (200) if rollout is approved now. In case of any exception the corresponding errors occur. */ @Operation(summary = "Approve a Rollout", description = "Handles the POST request of approving a created rollout. Only possible if approval " + @@ -250,9 +241,10 @@ public interface MgmtRolloutRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PostMapping(value = MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/approve", produces = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity approve(@PathVariable("rolloutId") Long rolloutId, + @PostMapping(value = MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/approve", + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + ResponseEntity approve( + @PathVariable("rolloutId") Long rolloutId, @RequestParam(value = "remark", required = false) String remark); /** @@ -260,8 +252,7 @@ public interface MgmtRolloutRestApi { * * @param rolloutId the ID of the rollout to be denied. * @param remark an optional remark on the denial decision - * @return OK response (200) if rollout is denied now. In case of any - * exception the corresponding errors occur. + * @return OK response (200) if rollout is denied now. In case of any exception the corresponding errors occur. */ @Operation(summary = "Deny a Rollout", description = "Handles the POST request of denying a created rollout. " + "Only possible if approval workflow is enabled in system configuration and rollout is in state " + @@ -284,17 +275,17 @@ public interface MgmtRolloutRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PostMapping(value = MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/deny", produces = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity deny(@PathVariable("rolloutId") Long rolloutId, + @PostMapping(value = MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/deny", + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + ResponseEntity deny( + @PathVariable("rolloutId") Long rolloutId, @RequestParam(value = "remark", required = false) String remark); /** * Handles the POST request for starting a rollout. * * @param rolloutId the ID of the rollout to be started. - * @return OK response (200) if rollout could be started. In case of any - * exception the corresponding errors occur. + * @return OK response (200) if rollout could be started. In case of any exception the corresponding errors occur. */ @Operation(summary = "Start a Rollout", description = "Handles the POST request of starting a created rollout. " + "Required Permission: HANDLE_ROLLOUT") @@ -316,16 +307,15 @@ public interface MgmtRolloutRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PostMapping(value = MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/start", produces = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @PostMapping(value = MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/start", + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity start(@PathVariable("rolloutId") Long rolloutId); /** * Handles the POST request for pausing a rollout. * * @param rolloutId the ID of the rollout to be paused. - * @return OK response (200) if rollout could be paused. In case of any - * exception the corresponding errors occur. + * @return OK response (200) if rollout could be paused. In case of any exception the corresponding errors occur. */ @Operation(summary = "Pause a Rollout", description = "Handles the POST request of pausing a running rollout. " + "Required Permission: HANDLE_ROLLOUT") @@ -347,8 +337,8 @@ public interface MgmtRolloutRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PostMapping(value = MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/pause", produces = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @PostMapping(value = MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/pause", + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity pause(@PathVariable("rolloutId") Long rolloutId); /** @@ -380,16 +370,15 @@ public interface MgmtRolloutRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @DeleteMapping(value = MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}", produces = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @DeleteMapping(value = MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}", + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity delete(@PathVariable("rolloutId") Long rolloutId); /** * Handles the POST request for resuming a rollout. * * @param rolloutId the ID of the rollout to be resumed. - * @return OK response (200) if rollout could be resumed. In case of any - * exception the corresponding errors occur. + * @return OK response (200) if rollout could be resumed. In case of any exception the corresponding errors occur. */ @Operation(summary = "Resume a Rollout", description = "Handles the POST request of resuming a paused rollout. " + "Required Permission: HANDLE_ROLLOUT") @@ -411,29 +400,21 @@ public interface MgmtRolloutRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PostMapping(value = MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/resume", produces = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @PostMapping(value = MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/resume", + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity resume(@PathVariable("rolloutId") Long rolloutId); /** - * Handles the GET request of retrieving all rollout groups referred to a - * rollout. + * Handles the GET request of retrieving all rollout groups referred to a rollout. * - * @param pagingOffsetParam the offset of list of rollout groups for pagination, might not - * be present in the rest request then default value will be - * applied - * @param pagingLimitParam the limit of the paged request, might not be present in the - * rest request then default value will be applied - * @param sortParam the sorting parameter in the request URL, syntax - * {@code field:direction, field:direction} - * @param rsqlParam the search parameter in the request URL, syntax - * {@code q=name==abc} - * @param representationModeParam the representation mode parameter specifying whether a compact - * or a full representation shall be returned - * @return a list of all rollout groups referred to a rollout for a defined - * or default page request with status OK. The response is always - * paged. In any failure the JsonResponseExceptionHandler is - * handling the response. + * @param pagingOffsetParam the offset of list of rollout groups for pagination, might not be present in the rest request then default value + * will be applied + * @param pagingLimitParam the limit of the paged request, might not be present in the rest request then default value will be applied + * @param sortParam the sorting parameter in the request URL, syntax {@code field:direction, field:direction} + * @param rsqlParam the search parameter in the request URL, syntax {@code q=name==abc} + * @param representationModeParam the representation mode parameter specifying whether a compact or a full representation shall be returned + * @return a list of all rollout groups referred to a rollout for a defined or default page request with status OK. The response is always + * paged. In any failure the JsonResponseExceptionHandler is handling the response. */ @Operation(summary = "Return all rollout groups referred to a Rollout", description = "Handles the GET request of " + "retrieving all deploy groups of a specific rollout. Required Permission: READ_ROLLOUT") @@ -457,8 +438,8 @@ public interface MgmtRolloutRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/deploygroups", produces = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/deploygroups", + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> getRolloutGroups(@PathVariable("rolloutId") Long rolloutId, @RequestParam( value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, @@ -515,10 +496,10 @@ public interface MgmtRolloutRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING - + "/{rolloutId}/deploygroups/{groupId}", produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity getRolloutGroup(@PathVariable("rolloutId") Long rolloutId, + @GetMapping(value = MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/deploygroups/{groupId}", + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + ResponseEntity getRolloutGroup( + @PathVariable("rolloutId") Long rolloutId, @PathVariable("groupId") Long groupId); /** @@ -526,17 +507,12 @@ public interface MgmtRolloutRestApi { * * @param rolloutId the ID of the rollout * @param groupId the ID of the rollout group - * @param pagingOffsetParam the offset of list of rollout groups for pagination, might not - * be present in the rest request then default value will be - * applied - * @param pagingLimitParam the limit of the paged request, might not be present in the - * rest request then default value will be applied - * @param sortParam the sorting parameter in the request URL, syntax - * {@code field:direction, field:direction} - * @param rsqlParam the search parameter in the request URL, syntax - * {@code q=name==abc} - * @return a paged list of targets related to a specific rollout and rollout - * group. + * @param pagingOffsetParam the offset of list of rollout groups for pagination, might not be present in the rest request then default value + * will be applied + * @param pagingLimitParam the limit of the paged request, might not be present in the rest request then default value will be applied + * @param sortParam the sorting parameter in the request URL, syntax {@code field:direction, field:direction} + * @param rsqlParam the search parameter in the request URL, syntax {@code q=name==abc} + * @return a paged list of targets related to a specific rollout and rollout group. */ @Operation(summary = "Return all targets related to a specific rollout group", description = "Handles the GET request of retrieving all targets of a single deploy group of a specific " + @@ -561,10 +537,10 @@ public interface MgmtRolloutRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING - + "/{rolloutId}/deploygroups/{groupId}/targets", produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity> getRolloutGroupTargets(@PathVariable("rolloutId") Long rolloutId, + @GetMapping(value = MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/deploygroups/{groupId}/targets", + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + ResponseEntity> getRolloutGroupTargets( + @PathVariable("rolloutId") Long rolloutId, @PathVariable("groupId") Long groupId, @RequestParam( value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, @@ -590,12 +566,10 @@ public interface MgmtRolloutRestApi { String rsqlParam); /** - * Handles the POST request to force trigger processing next group of a - * rollout even success threshold isn't yet met + * Handles the POST request to force trigger processing next group of a rollout even success threshold isn't yet met * * @param rolloutId the ID of the rollout to trigger next group. - * @return OK response (200). In case of any exception the corresponding - * errors occur. + * @return OK response (200). In case of any exception the corresponding errors occur. */ @Operation(summary = "Force trigger processing next group of a Rollout", description = "Handles the POST request " + "of triggering the next group of a rollout. Required Permission: UPDATE_ROLLOUT") @@ -617,16 +591,15 @@ public interface MgmtRolloutRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PostMapping(value = MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/triggerNextGroup", produces = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @PostMapping(value = MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/triggerNextGroup", + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity triggerNextGroup(@PathVariable("rolloutId") Long rolloutId); /** * Handles the POST request to retry a rollout * * @param rolloutId the ID of the rollout to be retried. - * @return OK response (200). In case of any exception the corresponding - * errors occur. + * @return OK response (200). In case of any exception the corresponding errors occur. */ @Operation(summary = "Retry a rollout", description = "Handles the POST request of retrying a rollout. " + "Required Permission: CREATE_ROLLOUT") @@ -650,8 +623,7 @@ public interface MgmtRolloutRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PostMapping(value = MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/retry", produces = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @PostMapping(value = MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/retry", + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity retryRollout(@PathVariable("rolloutId") final Long rolloutId); - } \ No newline at end of file diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSoftwareModuleRestApi.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSoftwareModuleRestApi.java index e5e99a735..59b27f99e 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSoftwareModuleRestApi.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSoftwareModuleRestApi.java @@ -55,10 +55,8 @@ public interface MgmtSoftwareModuleRestApi { * @param md5Sum checksum for uploaded content check * @param sha1Sum checksum for uploaded content check * @param sha256sum checksum for uploaded content check - * @return In case all sets could successful be created the ResponseEntity - * with status code 201 - Created but without ResponseBody. In any - * failure the JsonResponseExceptionHandler is handling the - * response. + * @return In case all sets could successful be created the ResponseEntity with status code 201 - Created but without ResponseBody. In any + * failure the JsonResponseExceptionHandler is handling the response. */ @Operation(summary = "Upload artifact", description = "Handles POST request for artifact upload. Required Permission: CREATE_REPOSITORY") @ApiResponses(value = { @@ -83,10 +81,10 @@ public interface MgmtSoftwareModuleRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PostMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING - + "/{softwareModuleId}/artifacts", consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity uploadArtifact(@PathVariable("softwareModuleId") final Long softwareModuleId, + @PostMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/artifacts", + consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + ResponseEntity uploadArtifact( + @PathVariable("softwareModuleId") final Long softwareModuleId, @RequestPart("file") final MultipartFile file, @RequestParam(value = "filename", required = false) final String optionalFileName, @RequestParam(value = "md5sum", required = false) final String md5Sum, @@ -94,16 +92,14 @@ public interface MgmtSoftwareModuleRestApi { @RequestParam(value = "sha256sum", required = false) final String sha256sum); /** - * Handles the GET request of retrieving all meta data of artifacts assigned - * to a software module. + * Handles the GET request of retrieving all metadata of artifacts assigned to a software module. * * @param softwareModuleId of the parent SoftwareModule - * @return a list of all artifacts for a defined or default page request - * with status OK. The response is always paged. In any failure the + * @return a list of all artifacts for a defined or default page request with status OK. The response is always paged. In any failure the * JsonResponseExceptionHandler is handling the response. */ - @Operation(summary = "Return all meta data of artifacts assigned to a software module", - description = "Handles the GET request of retrieving all meta data of artifacts assigned to a " + + @Operation(summary = "Return all metadata of artifacts assigned to a software module", + description = "Handles the GET request of retrieving all metadata of artifacts assigned to a " + "software module. Required Permission: READ_REPOSITORY") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Successfully retrieved"), @@ -125,22 +121,21 @@ public interface MgmtSoftwareModuleRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING - + "/{softwareModuleId}/artifacts", produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity> getArtifacts(@PathVariable("softwareModuleId") final Long softwareModuleId, + @GetMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/artifacts", + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + ResponseEntity> getArtifacts( + @PathVariable("softwareModuleId") final Long softwareModuleId, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_REPRESENTATION_MODE, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_REPRESENTATION_MODE_DEFAULT) String representationModeParam, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_USE_ARTIFACT_URL_HANDLER, required = false) final Boolean useArtifactUrlHandler); /** - * Handles the GET request of retrieving a single Artifact meta data - * request. + * Handles the GET request of retrieving a single Artifact metadata request. * * @param softwareModuleId of the parent SoftwareModule * @param artifactId of the related LocalArtifact * @return responseEntity with status ok if successful */ - @Operation(summary = "Return single Artifact meta data", description = "Handles the GET request of retrieving a single Artifact meta data request. Required Permission: READ_REPOSITORY") + @Operation(summary = "Return single Artifact metadata", description = "Handles the GET request of retrieving a single Artifact metadata request. Required Permission: READ_REPOSITORY") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Successfully retrieved"), @ApiResponse(responseCode = "400", description = "Bad Request - e.g. invalid parameters", @@ -160,9 +155,8 @@ public interface MgmtSoftwareModuleRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING - + "/{softwareModuleId}/artifacts/{artifactId}", produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/artifacts/{artifactId}", + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) @ResponseBody ResponseEntity getArtifact( @PathVariable("softwareModuleId") final Long softwareModuleId, @@ -196,25 +190,21 @@ public interface MgmtSoftwareModuleRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @DeleteMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING - + "/{softwareModuleId}/artifacts/{artifactId}") + @DeleteMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/artifacts/{artifactId}") @ResponseBody - ResponseEntity deleteArtifact(@PathVariable("softwareModuleId") final Long softwareModuleId, + ResponseEntity deleteArtifact( + @PathVariable("softwareModuleId") final Long softwareModuleId, @PathVariable("artifactId") final Long artifactId); /** - * Handles the GET request of retrieving all softwaremodules. + * Handles the GET request of retrieving all software modules. * - * @param pagingOffsetParam the offset of list of modules for pagination, might not be - * present in the rest request then default value will be applied - * @param pagingLimitParam the limit of the paged request, might not be present in the - * rest request then default value will be applied - * @param sortParam the sorting parameter in the request URL, syntax - * {@code field:direction, field:direction} - * @param rsqlParam the search parameter in the request URL, syntax - * {@code q=name==abc} - * @return a list of all modules for a defined or default page request with - * status OK. The response is always paged. In any failure the + * @param pagingOffsetParam the offset of list of modules for pagination, might not be present in the rest request then default value will + * be applied + * @param pagingLimitParam the limit of the paged request, might not be present in the rest request then default value will be applied + * @param sortParam the sorting parameter in the request URL, syntax {@code field:direction, field:direction} + * @param rsqlParam the search parameter in the request URL, syntax {@code q=name==abc} + * @return a list of all modules for a defined or default page request with status OK. The response is always paged. In any failure the * JsonResponseExceptionHandler is handling the response. */ @Operation(summary = "Return all Software modules", description = "Handles the GET request of retrieving all softwaremodules. Required Permission: READ_REPOSITORY") @@ -236,8 +226,8 @@ public interface MgmtSoftwareModuleRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING, produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING, + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> getSoftwareModules( @RequestParam( value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, @@ -289,19 +279,16 @@ public interface MgmtSoftwareModuleRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}", produces = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}", + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity getSoftwareModule(@PathVariable("softwareModuleId") final Long softwareModuleId); /** - * Handles the POST request of creating new softwaremodules. The request - * body must always be a list of modules. + * Handles the POST request of creating new software modules. The request body must always be a list of modules. * * @param softwareModules the modules to be created. - * @return In case all modules could successful created the ResponseEntity - * with status code 201 - Created but without ResponseBody. In any - * failure the JsonResponseExceptionHandler is handling the - * response. + * @return In case all modules could successful created the ResponseEntity with status code 201 - Created but without ResponseBody. In any + * failure the JsonResponseExceptionHandler is handling the response. */ @Operation(summary = "Create Software Module(s)", description = "Handles the POST request of creating new software modules. The request body must always be a list of modules. Required Permission: CREATE_REPOSITORY") @ApiResponses(value = { @@ -325,11 +312,10 @@ public interface MgmtSoftwareModuleRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PostMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING, consumes = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity> createSoftwareModules( - final List softwareModules); + @PostMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING, + consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + ResponseEntity> createSoftwareModules(final List softwareModules); /** * Handles the PUT request of updating a software module. @@ -364,9 +350,9 @@ public interface MgmtSoftwareModuleRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PutMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}", consumes = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) + @PutMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}", + consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity updateSoftwareModule( @PathVariable("softwareModuleId") final Long softwareModuleId, final MgmtSoftwareModuleRequestBodyPut restSoftwareModule); @@ -401,21 +387,17 @@ public interface MgmtSoftwareModuleRestApi { ResponseEntity deleteSoftwareModule(@PathVariable("softwareModuleId") final Long softwareModuleId); /** - * Gets a paged list of meta data for a software module. + * Gets a paged list of metadata for a software module. * - * @param softwareModuleId the ID of the software module for the meta data - * @param pagingOffsetParam the offset of list of meta data for pagination, might not be - * present in the rest request then default value will be applied - * @param pagingLimitParam the limit of the paged request, might not be present in the - * rest request then default value will be applied - * @param sortParam the sorting parameter in the request URL, syntax - * {@code field:direction, field:direction} - * @param rsqlParam the search parameter in the request URL, syntax - * {@code q=key==abc} - * @return status OK if get request is successful with the paged list of - * meta data + * @param softwareModuleId the ID of the software module for the metadata + * @param pagingOffsetParam the offset of list of metadata for pagination, might not be present in the rest request then default value will + * be applied + * @param pagingLimitParam the limit of the paged request, might not be present in the rest request then default value will be applied + * @param sortParam the sorting parameter in the request URL, syntax {@code field:direction, field:direction} + * @param rsqlParam the search parameter in the request URL, syntax {@code q=key==abc} + * @return status OK if get request is successful with the paged list of metadata */ - @Operation(summary = "Return meta data for a Software Module", description = "Get a paged list of meta data for a software module. Required Permission: READ_REPOSITORY") + @Operation(summary = "Return metadata for a Software Module", description = "Get a paged list of metadata for a software module. Required Permission: READ_REPOSITORY") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Successfully retrieved"), @ApiResponse(responseCode = "400", description = "Bad Request - e.g. invalid parameters", @@ -436,9 +418,8 @@ public interface MgmtSoftwareModuleRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING - + "/{softwareModuleId}/metadata", produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/metadata", + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> getMetadata( @PathVariable("softwareModuleId") final Long softwareModuleId, @RequestParam( @@ -465,14 +446,13 @@ public interface MgmtSoftwareModuleRestApi { String rsqlParam); /** - * Gets a single meta data value for a specific key of a software module. + * Gets a single metadata value for a specific key of a software module. * - * @param softwareModuleId the ID of the software module to get the meta data from - * @param metadataKey the key of the meta data entry to retrieve the value from - * @return status OK if get request is successful with the value of the meta - * data + * @param softwareModuleId the ID of the software module to get the metadata from + * @param metadataKey the key of the metadata entry to retrieve the value from + * @return status OK if get request is successful with the value of the metadata */ - @Operation(summary = "Return single meta data value for a specific key of a Software Module", description = "Get a single meta data value for a meta data key. Required Permission: READ_REPOSITORY") + @Operation(summary = "Return single metadata value for a specific key of a Software Module", description = "Get a single metadata value for a metadata key. Required Permission: READ_REPOSITORY") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Successfully retrieved"), @ApiResponse(responseCode = "400", description = "Bad Request - e.g. invalid parameters", @@ -493,23 +473,21 @@ public interface MgmtSoftwareModuleRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING - + "/{softwareModuleId}/metadata/{metadataKey}", produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/metadata/{metadataKey}", + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity getMetadataValue( @PathVariable("softwareModuleId") final Long softwareModuleId, @PathVariable("metadataKey") final String metadataKey); /** - * Updates a single meta data value of a software module. + * Updates a single metadata value of a software module. * - * @param softwareModuleId the ID of the software module to update the meta data entry - * @param metadataKey the key of the meta data to update the value + * @param softwareModuleId the ID of the software module to update the metadata entry + * @param metadataKey the key of the metadata to update the value * @param metadata body to update - * @return status OK if the update request is successful and the updated - * meta data result + * @return status OK if the update request is successful and the updated metadata result */ - @Operation(summary = "Update a single meta data value of a Software Module", description = "Update a single meta data value for speficic key. Required Permission: UPDATE_REPOSITORY") + @Operation(summary = "Update a single metadata value of a Software Module", description = "Update a single metadata value for speficic key. Required Permission: UPDATE_REPOSITORY") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Successfully retrieved"), @ApiResponse(responseCode = "400", description = "Bad Request - e.g. invalid parameters", @@ -529,21 +507,20 @@ public interface MgmtSoftwareModuleRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PutMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING - + "/{softwareModuleId}/metadata/{metadataKey}", produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) + @PutMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/metadata/{metadataKey}", + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity updateMetadata( @PathVariable("softwareModuleId") final Long softwareModuleId, @PathVariable("metadataKey") final String metadataKey, final MgmtSoftwareModuleMetadataBodyPut metadata); /** - * Deletes a single meta data entry from the software module. + * Deletes a single metadata entry from the software module. * - * @param softwareModuleId the ID of the software module to delete the meta data entry - * @param metadataKey the key of the meta data to delete + * @param softwareModuleId the ID of the software module to delete the metadata entry + * @param metadataKey the key of the metadata to delete * @return status OK if the delete request is successful */ - @Operation(summary = "Delete single meta data entry from the software module", description = "Delete a single meta data. Required Permission: UPDATE_REPOSITORY") + @Operation(summary = "Delete single metadata entry from the software module", description = "Delete a single metadata. Required Permission: UPDATE_REPOSITORY") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Successfully retrieved"), @ApiResponse(responseCode = "400", description = "Bad Request - e.g. invalid parameters", @@ -563,20 +540,19 @@ public interface MgmtSoftwareModuleRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @DeleteMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING - + "/{softwareModuleId}/metadata/{metadataKey}") - ResponseEntity deleteMetadata(@PathVariable("softwareModuleId") final Long softwareModuleId, + @DeleteMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/metadata/{metadataKey}") + ResponseEntity deleteMetadata( + @PathVariable("softwareModuleId") final Long softwareModuleId, @PathVariable("metadataKey") final String metadataKey); /** - * Creates a list of meta data for a specific software module. + * Creates a list of metadata for a specific software module. * - * @param softwareModuleId the ID of the distribution set to create meta data for - * @param metadataRest the list of meta data entries to create - * @return status created if post request is successful with the value of - * the created meta data + * @param softwareModuleId the ID of the distribution set to create metadata for + * @param metadataRest the list of metadata entries to create + * @return status created if post request is successful with the value of the created metadata */ - @Operation(summary = "Creates a list of meta data for a specific Software Module", description = "Create a list of meta data entries Required Permission: UPDATE_REPOSITORY") + @Operation(summary = "Creates a list of metadata for a specific Software Module", description = "Create a list of metadata entries Required Permission: UPDATE_REPOSITORY") @ApiResponses(value = { @ApiResponse(responseCode = "201", description = "Successfully created"), @ApiResponse(responseCode = "400", description = "Bad Request - e.g. invalid parameters", @@ -602,12 +578,10 @@ public interface MgmtSoftwareModuleRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PostMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING - + "/{softwareModuleId}/metadata", consumes = { MediaType.APPLICATION_JSON_VALUE, - MediaTypes.HAL_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) + @PostMapping(value = MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/metadata", + consumes = { MediaType.APPLICATION_JSON_VALUE, MediaTypes.HAL_JSON_VALUE }, + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> createMetadata( @PathVariable("softwareModuleId") final Long softwareModuleId, final List metadataRest); - -} +} \ No newline at end of file diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSoftwareModuleTypeRestApi.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSoftwareModuleTypeRestApi.java index 6d881e9f4..f9e58b366 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSoftwareModuleTypeRestApi.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSoftwareModuleTypeRestApi.java @@ -43,21 +43,16 @@ public interface MgmtSoftwareModuleTypeRestApi { /** * Handles the GET request of retrieving all SoftwareModuleTypes . * - * @param pagingOffsetParam the offset of list of modules for pagination, might not be - * present in the rest request then default value will be applied - * @param pagingLimitParam the limit of the paged request, might not be present in the - * rest request then default value will be applied - * @param sortParam the sorting parameter in the request URL, syntax - * {@code field:direction, field:direction} - * @param rsqlParam the search parameter in the request URL, syntax - * {@code q=name==abc} - * @return a list of all module type for a defined or default page request - * with status OK. The response is always paged. In any failure the + * @param pagingOffsetParam the offset of list of modules for pagination, might not be present in the rest request then default value will + * be applied + * @param pagingLimitParam the limit of the paged request, might not be present in the rest request then default value will be applied + * @param sortParam the sorting parameter in the request URL, syntax {@code field:direction, field:direction} + * @param rsqlParam the search parameter in the request URL, syntax {@code q=name==abc} + * @return a list of all module type for a defined or default page request with status OK. The response is always paged. In any failure the * JsonResponseExceptionHandler is handling the response. */ @Operation(summary = "Return all Software Module Types", - description = "Handles the GET request of retrieving all software module types. " + - "Required Permission: READ_REPOSITORY") + description = "Handles the GET request of retrieving all software module types. Required Permission: READ_REPOSITORY") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Successfully retrieved"), @ApiResponse(responseCode = "400", description = "Bad Request - e.g. invalid parameters", @@ -76,8 +71,8 @@ public interface MgmtSoftwareModuleTypeRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = MgmtRestConstants.SOFTWAREMODULETYPE_V1_REQUEST_MAPPING, produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = MgmtRestConstants.SOFTWAREMODULETYPE_V1_REQUEST_MAPPING, + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> getTypes( @RequestParam( value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, @@ -109,8 +104,7 @@ public interface MgmtSoftwareModuleTypeRestApi { * @return a single softwareModule with status OK. */ @Operation(summary = "Return single Software Module Type", - description = "Handles the GET request of retrieving a single software module type. " + - "Required Permission: READ_REPOSITORY") + description = "Handles the GET request of retrieving a single software module type. Required Permission: READ_REPOSITORY") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Successfully retrieved"), @ApiResponse(responseCode = "400", description = "Bad Request - e.g. invalid parameters", @@ -131,8 +125,8 @@ public interface MgmtSoftwareModuleTypeRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = MgmtRestConstants.SOFTWAREMODULETYPE_V1_REQUEST_MAPPING - + "/{softwareModuleTypeId}", produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = MgmtRestConstants.SOFTWAREMODULETYPE_V1_REQUEST_MAPPING + "/{softwareModuleTypeId}", + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity getSoftwareModuleType( @PathVariable("softwareModuleTypeId") Long softwareModuleTypeId); @@ -143,8 +137,7 @@ public interface MgmtSoftwareModuleTypeRestApi { * @return status OK if delete as successfully. */ @Operation(summary = "Delete Software Module Type by Id", - description = "Handles the DELETE request for a single software module type. " + - "Required Permission: DELETE_REPOSITORY") + description = "Handles the DELETE request for a single software module type. Required Permission: DELETE_REPOSITORY") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Successfully retrieved"), @ApiResponse(responseCode = "400", description = "Bad Request - e.g. invalid parameters", @@ -176,8 +169,7 @@ public interface MgmtSoftwareModuleTypeRestApi { * @return status OK if update is successful */ @Operation(summary = "Update Software Module Type", - description = "Handles the PUT request for a single software module type. " + - "Required Permission: UPDATE_REPOSITORY") + description = "Handles the PUT request for a single software module type. Required Permission: UPDATE_REPOSITORY") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Successfully retrieved"), @ApiResponse(responseCode = "400", description = "Bad Request - e.g. invalid parameters", @@ -204,23 +196,19 @@ public interface MgmtSoftwareModuleTypeRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PutMapping(value = MgmtRestConstants.SOFTWAREMODULETYPE_V1_REQUEST_MAPPING - + "/{softwareModuleTypeId}", consumes = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) + @PutMapping(value = MgmtRestConstants.SOFTWAREMODULETYPE_V1_REQUEST_MAPPING + "/{softwareModuleTypeId}", + consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity updateSoftwareModuleType( @PathVariable("softwareModuleTypeId") Long softwareModuleTypeId, MgmtSoftwareModuleTypeRequestBodyPut restSoftwareModuleType); /** - * Handles the POST request of creating new SoftwareModuleTypes. The request - * body must always be a list of types. + * Handles the POST request of creating new SoftwareModuleTypes. The request body must always be a list of types. * * @param softwareModuleTypes the modules to be created. - * @return In case all modules could successful created the ResponseEntity - * with status code 201 - Created but without ResponseBody. In any - * failure the JsonResponseExceptionHandler is handling the - * response. + * @return In case all modules could successful created the ResponseEntity with status code 201 - Created but without ResponseBody. In any + * failure the JsonResponseExceptionHandler is handling the response. */ @Operation(summary = "Creates new Software Module Types", description = "Handles the POST request of creating new software module types. The request body must " + @@ -251,10 +239,8 @@ public interface MgmtSoftwareModuleTypeRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PostMapping(value = MgmtRestConstants.SOFTWAREMODULETYPE_V1_REQUEST_MAPPING, consumes = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity> createSoftwareModuleTypes( - List softwareModuleTypes); - + @PostMapping(value = MgmtRestConstants.SOFTWAREMODULETYPE_V1_REQUEST_MAPPING, + consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + ResponseEntity> createSoftwareModuleTypes(List softwareModuleTypes); } \ No newline at end of file diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSystemManagementRestApi.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSystemManagementRestApi.java index d37d52325..6e9965884 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSystemManagementRestApi.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtSystemManagementRestApi.java @@ -41,8 +41,8 @@ public interface MgmtSystemManagementRestApi { * * @return system usage statistics */ - @GetMapping(value = MgmtRestConstants.SYSTEM_ADMIN_MAPPING + "/usage", produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = MgmtRestConstants.SYSTEM_ADMIN_MAPPING + "/usage", + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity getSystemUsageStats(); /** @@ -50,8 +50,8 @@ public interface MgmtSystemManagementRestApi { * * @return a list of caches for all tenants */ - @GetMapping(value = MgmtRestConstants.SYSTEM_ADMIN_MAPPING + "/caches", produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = MgmtRestConstants.SYSTEM_ADMIN_MAPPING + "/caches", + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> getCaches(); /** @@ -61,5 +61,4 @@ public interface MgmtSystemManagementRestApi { */ @DeleteMapping(value = MgmtRestConstants.SYSTEM_ADMIN_MAPPING + "/caches") ResponseEntity> invalidateCaches(); - } diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetFilterQueryRestApi.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetFilterQueryRestApi.java index b1398df26..e129384e4 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetFilterQueryRestApi.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetFilterQueryRestApi.java @@ -68,23 +68,19 @@ public interface MgmtTargetFilterQueryRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/{filterId}", produces = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/{filterId}", + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity getFilter(@PathVariable("filterId") Long filterId); /** * Handles the GET request of retrieving all filters. * - * @param pagingOffsetParam the offset of list of targets for pagination, might not be - * present in the rest request then default value will be applied - * @param pagingLimitParam the limit of the paged request, might not be present in the - * rest request then default value will be applied - * @param sortParam the sorting parameter in the request URL, syntax - * {@code field:direction, field:direction} - * @param rsqlParam the search parameter in the request URL, syntax - * {@code q=name==abc} - * @return a list of all targets for a defined or default page request with - * status OK. The response is always paged. In any failure the + * @param pagingOffsetParam the offset of list of targets for pagination, might not be present in the rest request then default value will + * be applied + * @param pagingLimitParam the limit of the paged request, might not be present in the rest request then default value will be applied + * @param sortParam the sorting parameter in the request URL, syntax {@code field:direction, field:direction} + * @param rsqlParam the search parameter in the request URL, syntax {@code q=name==abc} + * @return a list of all targets for a defined or default page reque status OK. The response is always paged. In any failure the * JsonResponseExceptionHandler is handling the response. */ @Operation(summary = "Return all target filter queries", description = "Handles the GET request of retrieving all target filter queries. Required permission: READ_TARGET") @@ -106,8 +102,8 @@ public interface MgmtTargetFilterQueryRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING, produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING, + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> getFilters( @RequestParam( value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, @@ -134,14 +130,11 @@ public interface MgmtTargetFilterQueryRestApi { @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_REPRESENTATION_MODE, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_REPRESENTATION_MODE_DEFAULT) String representationModeParam); /** - * Handles the POST request of creating new target filters. The request body - * must always be a list of target filters. + * Handles the POST request of creating new target filters. The request body must always be a list of target filters. * * @param filter the filters to be created. - * @return In case all filters were successfully created the ResponseEntity - * with status code 201 with a list of successfully created entities - * is returned. In any failure the JsonResponseExceptionHandler is - * handling the response. + * @return In case all filters were successfully created the ResponseEntity with status code 201 with a list of successfully created entities + * is returned. In any failure the JsonResponseExceptionHandler is handling the response. */ @Operation(summary = "Create target filter", description = "Handles the POST request to create a new target filter query. Required permission: CREATE_TARGET") @ApiResponses(value = { @@ -168,22 +161,19 @@ public interface MgmtTargetFilterQueryRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PostMapping(value = MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING, consumes = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) + @PostMapping(value = MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING, + consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity createFilter(@RequestBody MgmtTargetFilterQueryRequestBody filter); /** - * Handles the PUT request of updating a target filter. The ID is within the - * URL path of the request. A given ID in the request body is ignored. It's - * not possible to set fields to {@code null} values. + * Handles the PUT request of updating a target filter. The ID is within the URL path of the request. A given ID in the request body is + * ignored. It's not possible to set fields to {@code null} values. * * @param filterId the path parameter which contains the ID of the target filter - * @param targetFilterRest the request body which contains the fields which should be - * updated, fields which are not given are ignored for the - * update. - * @return the updated target filter response which contains all fields - * including fields which have not been updated + * @param targetFilterRest the request body which contains the fields which should be updated, fields which are not given are ignored for + * the update. + * @return the updated target filter response which contains all fields including fields which have not been updated */ @Operation(summary = "Updates target filter query by id", description = "Handles the PUT request of updating a target filter query. Required permission: UPDATE_TARGET") @ApiResponses(value = { @@ -214,15 +204,15 @@ public interface MgmtTargetFilterQueryRestApi { @PutMapping(value = MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/{filterId}", consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity updateFilter(@PathVariable("filterId") Long filterId, + ResponseEntity updateFilter( + @PathVariable("filterId") Long filterId, @RequestBody MgmtTargetFilterQueryRequestBody targetFilterRest); /** * Handles the DELETE request of deleting a target filter. * * @param filterId the ID of the target filter to be deleted - * @return If the given controllerId could exists and could be deleted Http - * OK. In any failure the JsonResponseExceptionHandler is handling + * @return If the given controllerId could exists and could be deleted Http OK. In any failure the JsonResponseExceptionHandler is handling * the response. */ @Operation(summary = "Delete target filter by id", description = "Handles the DELETE request of deleting a target filter query. Required permission: DELETE_TARGET") @@ -245,17 +235,15 @@ public interface MgmtTargetFilterQueryRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @DeleteMapping(value = MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/{filterId}", produces = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @DeleteMapping(value = MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/{filterId}", + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity deleteFilter(@PathVariable("filterId") Long filterId); /** - * Handles the GET request of retrieving the distribution set for auto - * assignment of an specific target filter. + * Handles the GET request of retrieving the distribution set for auto assignment of an specific target filter. * * @param filterId the ID of the target to retrieve the assigned distribution - * @return the assigned distribution set with status OK, if none is assigned - * than {@code null} content (e.g. "{}") + * @return the assigned distribution set with status OK, if none is assigned than {@code null} content (e.g. "{}") */ @Operation(summary = "Return distribution set for auto assignment of a specific target filter", description = "Handles the GET request of retrieving the auto assign distribution set. Required permission: READ_TARGET") @ApiResponses(value = { @@ -276,17 +264,15 @@ public interface MgmtTargetFilterQueryRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/{filterId}/autoAssignDS", produces = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/{filterId}/autoAssignDS", + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity getAssignedDistributionSet(@PathVariable("filterId") Long filterId); /** - * Handles the POST request for changing distribution set for auto - * assignment of a target filter. + * Handles the POST request for changing distribution set for auto assignment of a target filter. * * @param filterId of the target to change - * @param dsIdWithActionType id of the distribution set and the action type for auto - * assignment + * @param dsIdWithActionType id of the distribution set and the action type for auto assignment * @return http status */ @Operation(summary = "Set auto assignment of distribution set for a target filter query", @@ -318,15 +304,15 @@ public interface MgmtTargetFilterQueryRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PostMapping(value = MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/{filterId}/autoAssignDS", consumes = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity postAssignedDistributionSet(@PathVariable("filterId") Long filterId, + @PostMapping(value = MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/{filterId}/autoAssignDS", + consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + ResponseEntity postAssignedDistributionSet( + @PathVariable("filterId") Long filterId, @RequestBody MgmtDistributionSetAutoAssignment dsIdWithActionType); /** - * Handles the DELETE request for removing the distribution set for auto - * assignment of a target filter. + * Handles the DELETE request for removing the distribution set for auto assignment of a target filter. * * @param filterId of the target to change * @return http status diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetRestApi.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetRestApi.java index 321dbf72f..27b92092d 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetRestApi.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetRestApi.java @@ -82,23 +82,19 @@ public interface MgmtTargetRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}", produces = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}", + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity getTarget(@PathVariable("targetId") String targetId); /** * Handles the GET request of retrieving all targets. * - * @param pagingOffsetParam the offset of list of targets for pagination, might not be - * present in the rest request then default value will be applied - * @param pagingLimitParam the limit of the paged request, might not be present in the - * rest request then default value will be applied - * @param sortParam the sorting parameter in the request URL, syntax - * {@code field:direction, field:direction} - * @param rsqlParam the search parameter in the request URL, syntax - * {@code q=name==abc} - * @return a list of all targets for a defined or default page request with - * status OK. The response is always paged. In any failure the + * @param pagingOffsetParam the offset of list of targets for pagination, might not be present in the rest request then default value will + * be applied + * @param pagingLimitParam the limit of the paged request, might not be present in the rest request then default value will be applied + * @param sortParam the sorting parameter in the request URL, syntax {@code field:direction, field:direction} + * @param rsqlParam the search parameter in the request URL, syntax {@code q=name==abc} + * @return a list of all targets for a defined or default page request with status OK. The response is always paged. In any failure the * JsonResponseExceptionHandler is handling the response. */ @Operation(summary = "Return all targets", description = "Handles the GET request of retrieving all targets. Required permission: READ_TARGET") @@ -120,8 +116,8 @@ public interface MgmtTargetRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING, produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING, + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> getTargets( @RequestParam( value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, @@ -147,14 +143,11 @@ public interface MgmtTargetRestApi { String rsqlParam); /** - * Handles the POST request of creating new targets. The request body must - * always be a list of targets. + * Handles the POST request of creating new targets. The request body must always be a list of targets. * * @param targets the targets to be created. - * @return In case all targets could successful created the ResponseEntity - * with status code 201 with a list of successfully created - * entities. In any failure the JsonResponseExceptionHandler is - * handling the response. + * @return In case all targets could successful created the ResponseEntity with status code 201 with a list of successfully created + * entities. In any failure the JsonResponseExceptionHandler is handling the response. */ @Operation(summary = "Create target(s)", description = "Handles the POST request of creating new targets. The request body must always be a list of targets. Required Permission: CREATE_TARGET") @ApiResponses(value = { @@ -181,22 +174,19 @@ public interface MgmtTargetRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PostMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING, consumes = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) + @PostMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING, + consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> createTargets(List targets); /** - * Handles the PUT request of updating a target. The ID is within the URL - * path of the request. A given ID in the request body is ignored. It's not - * possible to set fields to {@code null} values. + * Handles the PUT request of updating a target. The ID is within the URL path of the request. A given ID in the request body is ignored. + * It's not possible to set fields to {@code null} values. * * @param targetId the path parameter which contains the ID of the target - * @param targetRest the request body which contains the fields which should be - * updated, fields which are not given are ignored for the - * udpate. - * @return the updated target response which contains all fields also fields - * which have not updated + * @param targetRest the request body which contains the fields which should be updated, fields which are not given are ignored for the + * update. + * @return the updated target response which contains all fields also fields which have not updated */ @Operation(summary = "Update target by id", description = "Handles the PUT request of updating a target. Required Permission: UPDATE_TARGET") @ApiResponses(value = { @@ -224,18 +214,16 @@ public interface MgmtTargetRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PutMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}", consumes = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity updateTarget(@PathVariable("targetId") String targetId, - MgmtTargetRequestBody targetRest); + @PutMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}", + consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + ResponseEntity updateTarget(@PathVariable("targetId") String targetId, MgmtTargetRequestBody targetRest); /** * Handles the DELETE request of deleting a target. * * @param targetId the ID of the target to be deleted - * @return If the given targetId could exists and could be deleted Http OK. - * In any failure the JsonResponseExceptionHandler is handling the + * @return If the given targetId could exists and could be deleted Http OK. In any failure the JsonResponseExceptionHandler is handling the * response. */ @Operation(summary = "Delete target by id", description = "Handles the DELETE request of deleting a single target. Required Permission: DELETE_TARGET") @@ -265,8 +253,7 @@ public interface MgmtTargetRestApi { * Handles the DELETE (unassign) request of a target type. * * @param targetId the ID of the target - * @return If the given targetId could exists and could be unassign Http OK. - * In any failure the JsonResponseExceptionHandler is handling the + * @return If the given targetId could exists and could be unassign Http OK. In any failure the JsonResponseExceptionHandler is handling the * response. */ @Operation(summary = "Unassign target type from target.", description = "Remove the target type from a target. The target type will be set to null. Required permission: UPDATE_TARGET") @@ -286,16 +273,14 @@ public interface MgmtTargetRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @DeleteMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING - + MgmtRestConstants.TARGET_TARGET_TYPE_V1_REQUEST_MAPPING) + @DeleteMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + MgmtRestConstants.TARGET_TARGET_TYPE_V1_REQUEST_MAPPING) ResponseEntity unassignTargetType(@PathVariable("targetId") String targetId); /** * Handles the POST (assign) request of a target type. * * @param targetId the ID of the target - * @return If the given targetId could exists and could be assign Http OK. - * In any failure the JsonResponseExceptionHandler is handling the + * @return If the given targetId could exists and could be assign Http OK. In any failure the JsonResponseExceptionHandler is handling the * response. */ @Operation(summary = "Assign target type to a target", description = "Assign or update the target type of a target. Required permission: UPDATE_TARGET") @@ -315,14 +300,12 @@ public interface MgmtTargetRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PostMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING - + MgmtRestConstants.TARGET_TARGET_TYPE_V1_REQUEST_MAPPING, consumes = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) + @PostMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + MgmtRestConstants.TARGET_TARGET_TYPE_V1_REQUEST_MAPPING, + consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity assignTargetType(@PathVariable("targetId") String targetId, MgmtId targetTypeId); /** - * Handles the GET request of retrieving the attributes of a specific - * target. + * Handles the GET request of retrieving the attributes of a specific target. * * @param targetId the ID of the target to retrieve the attributes. * @return the target attributes as map response with status OK @@ -347,24 +330,20 @@ public interface MgmtTargetRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/attributes", produces = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/attributes", + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity getAttributes(@PathVariable("targetId") String targetId); /** * Handles the GET request of retrieving the Actions of a specific target. * * @param targetId to load actions for - * @param pagingOffsetParam the offset of list of targets for pagination, might not be - * present in the rest request then default value will be applied - * @param pagingLimitParam the limit of the paged request, might not be present in the - * rest request then default value will be applied - * @param sortParam the sorting parameter in the request URL, syntax - * {@code field:direction, field:direction} - * @param rsqlParam the search parameter in the request URL, syntax - * {@code q=status==pending} - * @return a list of all Actions for a defined or default page request with - * status OK. The response is always paged. In any failure the + * @param pagingOffsetParam the offset of list of targets for pagination, might not be present in the rest request then default value will + * be applied + * @param pagingLimitParam the limit of the paged request, might not be present in the rest request then default value will be applied + * @param sortParam the sorting parameter in the request URL, syntax {@code field:direction, field:direction} + * @param rsqlParam the search parameter in the request URL, syntax {@code q=status==pending} + * @return a list of all Actions for a defined or default page request with status OK. The response is always paged. In any failure the * JsonResponseExceptionHandler is handling the response. */ @Operation(summary = "Return actions for a specific target", description = "Handles the GET request of retrieving the full action history of a specific target. Required Permission: READ_TARGET") @@ -387,9 +366,10 @@ public interface MgmtTargetRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions", produces = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity> getActionHistory(@PathVariable("targetId") String targetId, + @GetMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions", + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + ResponseEntity> getActionHistory( + @PathVariable("targetId") String targetId, @RequestParam( value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) @@ -414,8 +394,7 @@ public interface MgmtTargetRestApi { String rsqlParam); /** - * Handles the GET request of retrieving a specific Actions of a specific - * Target. + * Handles the GET request of retrieving a specific Actions of a specific Target. * * @param targetId to load the action for * @param actionId to load @@ -441,14 +420,12 @@ public interface MgmtTargetRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions/{actionId}", produces = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity getAction(@PathVariable("targetId") String targetId, - @PathVariable("actionId") Long actionId); + @GetMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions/{actionId}", + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + ResponseEntity getAction(@PathVariable("targetId") String targetId, @PathVariable("actionId") Long actionId); /** - * Handles the DELETE request of canceling an specific Actions of a specific - * Target. + * Handles the DELETE request of canceling an specific Actions of a specific Target. * * @param targetId the ID of the target in the URL path parameter * @param actionId the ID of the action in the URL path parameter @@ -476,7 +453,8 @@ public interface MgmtTargetRestApi { content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) @DeleteMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions/{actionId}") - ResponseEntity cancelAction(@PathVariable("targetId") String targetId, + ResponseEntity cancelAction( + @PathVariable("targetId") String targetId, @PathVariable("actionId") Long actionId, @RequestParam(value = "force", required = false, defaultValue = "false") boolean force); @@ -514,26 +492,23 @@ public interface MgmtTargetRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PutMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions/{actionId}", consumes = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity updateAction(@PathVariable("targetId") String targetId, + @PutMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions/{actionId}", + consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + ResponseEntity updateAction( + @PathVariable("targetId") String targetId, @PathVariable("actionId") Long actionId, MgmtActionRequestBodyPut actionUpdate); /** - * Handles the GET request of retrieving the ActionStatus of a specific - * target and action. + * Handles the GET request of retrieving the ActionStatus of a specific target and action. * - * @param targetId of the the action + * @param targetId of the action * @param actionId of the status we are intend to load - * @param pagingOffsetParam the offset of list of targets for pagination, might not be - * present in the rest request then default value will be applied - * @param pagingLimitParam the limit of the paged request, might not be present in the - * rest request then default value will be applied - * @param sortParam the sorting parameter in the request URL, syntax - * {@code field:direction, field:direction} - * @return a list of all ActionStatus for a defined or default page request - * with status OK. The response is always paged. In any failure the + * @param pagingOffsetParam the offset of list of targets for pagination, might not be present in the rest request then default value will + * be applied + * @param pagingLimitParam the limit of the paged request, might not be present in the rest request then default value will be applied + * @param sortParam the sorting parameter in the request URL, syntax {@code field:direction, field:direction} + * @return a list of all ActionStatus for a defined or default page request with status OK. The response is always paged. In any failure the * JsonResponseExceptionHandler is handling the response. */ @Operation(summary = "Return status of a specific action on a specific target", description = "Handles the GET request of retrieving a specific action on a specific target. Required Permission: READ_TARGET") @@ -556,22 +531,20 @@ public interface MgmtTargetRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING - + "/{targetId}/actions/{actionId}/status", produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity> getActionStatusList(@PathVariable("targetId") String targetId, + @GetMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions/{actionId}/status", + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + ResponseEntity> getActionStatusList( + @PathVariable("targetId") String targetId, @PathVariable("actionId") Long actionId, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) int pagingOffsetParam, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) int pagingLimitParam, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) String sortParam); /** - * Handles the GET request of retrieving the assigned distribution set of a - * specific target. + * Handles the GET request of retrieving the assigned distribution set of a specific target. * * @param targetId the ID of the target to retrieve the assigned distribution - * @return the assigned distribution set with status OK, if none is assigned - * than {@code null} content (e.g. "{}") + * @return the assigned distribution set with status OK, if none is assigned than {@code null} content (e.g. "{}") */ @Operation(summary = "Return the assigned distribution set of a specific target", description = "Handles the GET request of retrieving the assigned distribution set of an specific target. Required Permission: READ_TARGET") @ApiResponses(value = { @@ -593,8 +566,8 @@ public interface MgmtTargetRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/assignedDS", produces = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/assignedDS", + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity getAssignedDistributionSet(@PathVariable("targetId") String targetId); /** @@ -602,10 +575,8 @@ public interface MgmtTargetRestApi { * * @param targetId of the target to change * @param dsAssignments the requested Assignments that shall be made - * @param offline to true if update was executed offline, i.e. not - * managed by hawkBit. - * @return status OK if the assignment of the targets was successful and a - * complex return body which contains information about the assigned + * @param offline to true if update was executed offline, i.e. not managed by hawkBit. + * @return status OK if the assignment of the targets was successful and a complex return body which contains information about the assigned * targets and the already assigned targets counters */ @Operation(summary = "Assigns a distribution set to a specific target", description = "Handles the POST request for assigning a distribution set to a specific target. Required Permission: READ_REPOSITORY and UPDATE_TARGET") @@ -634,9 +605,9 @@ public interface MgmtTargetRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PostMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/assignedDS", consumes = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) + @PostMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/assignedDS", + consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity postAssignedDistributionSet( @PathVariable("targetId") String targetId, @Valid MgmtDistributionSetAssignments dsAssignments, @@ -649,12 +620,10 @@ public interface MgmtTargetRestApi { Boolean offline); /** - * Handles the GET request of retrieving the installed distribution set of - * a specific target. + * Handles the GET request of retrieving the installed distribution set of a specific target. * * @param targetId the ID of the target to retrieve - * @return the assigned installed set with status OK, if none is installed - * than {@code null} content (e.g. "{}") + * @return the assigned installed set with status OK, if none is installed than {@code null} content (e.g. "{}") */ @Operation(summary = "Return installed distribution set of a specific target", description = "Handles the GET request of retrieving the installed distribution set of an specific target. Required Permission: READ_TARGET") @ApiResponses(value = { @@ -676,14 +645,14 @@ public interface MgmtTargetRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/installedDS", produces = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/installedDS", + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity getInstalledDistributionSet(@PathVariable("targetId") String targetId); /** - * Gets a paged list of meta data for a target. + * Gets a paged list of metadata for a target. * - * @param targetId the ID of the target for the meta data + * @param targetId the ID of the target for the metadata */ @Operation(summary = "Return tags for specific target", description = "Get a paged list of tags for a target. Required permission: READ_REPOSITORY") @ApiResponses(value = { @@ -703,26 +672,22 @@ public interface MgmtTargetRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/tags", produces = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/tags", + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> getTags(@PathVariable("targetId") String targetId); /** - * Gets a paged list of meta data for a target. + * Gets a paged list of metadata for a target. * - * @param targetId the ID of the target for the meta data - * @param pagingOffsetParam the offset of list of targets for pagination, might not be - * present in the rest request then default value will be applied - * @param pagingLimitParam the limit of the paged request, might not be present in the - * rest request then default value will be applied - * @param sortParam the sorting parameter in the request URL, syntax - * {@code field:direction, field:direction} - * @param rsqlParam the search parameter in the request URL, syntax - * {@code q=key==abc} - * @return status OK if get request is successful with the paged list of - * meta data + * @param targetId the ID of the target for the metadata + * @param pagingOffsetParam the offset of list of targets for pagination, might not be present in the rest request then default value will + * be applied + * @param pagingLimitParam the limit of the paged request, might not be present in the rest request then default value will be applied + * @param sortParam the sorting parameter in the request URL, syntax {@code field:direction, field:direction} + * @param rsqlParam the search parameter in the request URL, syntax {@code q=key==abc} + * @return status OK if get request is successful with the paged list of metadata */ - @Operation(summary = "Return metadata for specific target", description = "Get a paged list of meta data for a target. Required permission: READ_REPOSITORY") + @Operation(summary = "Return metadata for specific target", description = "Get a paged list of metadata for a target. Required permission: READ_REPOSITORY") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Successfully retrieved"), @ApiResponse(responseCode = "400", description = "Bad Request - e.g. invalid parameters", @@ -769,14 +734,13 @@ public interface MgmtTargetRestApi { String rsqlParam); /** - * Gets a single meta data value for a specific key of a target. + * Gets a single metadata value for a specific key of a target. * - * @param targetId the ID of the target to get the meta data from - * @param metadataKey the key of the meta data entry to retrieve the value from - * @return status OK if get request is successful with the value of the meta - * data + * @param targetId the ID of the target to get the metadata from + * @param metadataKey the key of the metadata entry to retrieve the value from + * @return status OK if get request is successful with the value of the metadata */ - @Operation(summary = "Return single metadata value for a specific key of a target", description = "Get a single meta data value for a meta data key. Required permission: READ_REPOSITORY") + @Operation(summary = "Return single metadata value for a specific key of a target", description = "Get a single metadata value for a metadata key. Required permission: READ_REPOSITORY") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Successfully retrieved"), @ApiResponse(responseCode = "400", description = "Bad Request - e.g. invalid parameters", @@ -796,21 +760,21 @@ public interface MgmtTargetRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/metadata/{metadataKey}", produces = { - MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity getMetadataValue(@PathVariable("targetId") String targetId, + @GetMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/metadata/{metadataKey}", + produces = { MediaType.APPLICATION_JSON_VALUE }) + ResponseEntity getMetadataValue( + @PathVariable("targetId") String targetId, @PathVariable("metadataKey") String metadataKey); /** - * Updates a single meta data value of a target. + * Updates a single metadata value of a target. * - * @param targetId the ID of the target to update the meta data entry - * @param metadataKey the key of the meta data to update the value + * @param targetId the ID of the target to update the metadata entry + * @param metadataKey the key of the metadata to update the value * @param metadata update body - * @return status OK if the update request is successful and the updated - * meta data result + * @return status OK if the update request is successful and the updated metadata result */ - @Operation(summary = "Updates a single meta data value of a target", description = "Update a single meta data value for speficic key. Required permission: UPDATE_REPOSITORY") + @Operation(summary = "Updates a single metadata value of a target", description = "Update a single metadata value for speficic key. Required permission: UPDATE_REPOSITORY") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Successfully retrieved"), @ApiResponse(responseCode = "400", description = "Bad Request - e.g. invalid parameters", @@ -836,19 +800,20 @@ public interface MgmtTargetRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PutMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/metadata/{metadataKey}", produces = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity updateMetadata(@PathVariable("targetId") String targetId, + @PutMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/metadata/{metadataKey}", + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + ResponseEntity updateMetadata( + @PathVariable("targetId") String targetId, @PathVariable("metadataKey") String metadataKey, MgmtMetadataBodyPut metadata); /** - * Deletes a single meta data entry from the target. + * Deletes a single metadata entry from the target. * - * @param targetId the ID of the target to delete the meta data entry - * @param metadataKey the key of the meta data to delete + * @param targetId the ID of the target to delete the metadata entry + * @param metadataKey the key of the metadata to delete * @return status OK if the delete request is successful */ - @Operation(summary = "Deletes a single meta data entry from a target", description = "Delete a single meta data. Required permission: UPDATE_REPOSITORY") + @Operation(summary = "Deletes a single metadata entry from a target", description = "Delete a single metadata. Required permission: UPDATE_REPOSITORY") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Successfully retrieved"), @ApiResponse(responseCode = "400", description = "Bad Request - e.g. invalid parameters", @@ -869,18 +834,18 @@ public interface MgmtTargetRestApi { content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) @DeleteMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/metadata/{metadataKey}") - ResponseEntity deleteMetadata(@PathVariable("targetId") String targetId, + ResponseEntity deleteMetadata( + @PathVariable("targetId") String targetId, @PathVariable("metadataKey") String metadataKey); /** - * Creates a list of meta data for a specific target. + * Creates a list of metadata for a specific target. * - * @param targetId the ID of the targetId to create meta data for - * @param metadataRest the list of meta data entries to create - * @return status created if post request is successful with the value of - * the created meta data + * @param targetId the ID of the targetId to create metadata for + * @param metadataRest the list of metadata entries to create + * @return status created if post request is successful with the value of the created metadata */ - @Operation(summary = "Create a list of meta data for a specific target", description = "Create a list of meta data entries Required permissions: READ_REPOSITORY and UPDATE_TARGET") + @Operation(summary = "Create a list of metadata for a specific target", description = "Create a list of metadata entries Required permissions: READ_REPOSITORY and UPDATE_TARGET") @ApiResponses(value = { @ApiResponse(responseCode = "201", description = "Successfully created"), @ApiResponse(responseCode = "400", description = "Bad Request - e.g. invalid parameters", @@ -906,11 +871,10 @@ public interface MgmtTargetRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PostMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/metadata", consumes = { - MediaType.APPLICATION_JSON_VALUE, - MediaTypes.HAL_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity> createMetadata(@PathVariable("targetId") String targetId, - List metadataRest); + @PostMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/metadata", + consumes = { MediaType.APPLICATION_JSON_VALUE, MediaTypes.HAL_JSON_VALUE }, + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + ResponseEntity> createMetadata(@PathVariable("targetId") String targetId, List metadataRest); /** * Get the current auto-confirm state for a specific target. @@ -938,8 +902,8 @@ public interface MgmtTargetRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/autoConfirm", produces = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/autoConfirm", + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity getAutoConfirmStatus(@PathVariable("targetId") String targetId); /** @@ -947,8 +911,7 @@ public interface MgmtTargetRestApi { * * @param targetId to activate auto-confirm on * @param update properties to update - * @return {@link org.springframework.http.HttpStatus#OK} in case of a - * success + * @return {@link org.springframework.http.HttpStatus#OK} in case of a success */ @Operation(summary = "Activate auto-confirm on a specific target", description = "Handles the POST request to activate auto-confirmation for a specific target. As a result all current active as well as future actions will automatically be confirmed by mentioning the initiator as triggered person. Actions will be automatically confirmed, as long as auto-confirmation is active. Required Permission: UPDATE_TARGET") @ApiResponses(value = { @@ -977,15 +940,15 @@ public interface MgmtTargetRestApi { content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) @PostMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/autoConfirm/activate") - ResponseEntity activateAutoConfirm(@PathVariable("targetId") String targetId, + ResponseEntity activateAutoConfirm( + @PathVariable("targetId") String targetId, @RequestBody(required = false) MgmtTargetAutoConfirmUpdate update); /** * Deactivate auto-confirm on a specific target. * * @param targetId to deactivate auto-confirm on - * @return {@link org.springframework.http.HttpStatus#OK} in case of a - * success + * @return {@link org.springframework.http.HttpStatus#OK} in case of a success */ @Operation(summary = "Deactivate auto-confirm on a specific target", description = "Handles the POST request to deactivate auto-confirmation for a specific target. All active actions will remain unchanged while all future actions need to be confirmed, before processing with the deployment. Required Permission: UPDATE_TARGET") @ApiResponses(value = { @@ -1015,5 +978,4 @@ public interface MgmtTargetRestApi { }) @PostMapping(value = MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/autoConfirm/deactivate") ResponseEntity deactivateAutoConfirm(@PathVariable("targetId") String targetId); - -} +} \ No newline at end of file diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetTagRestApi.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetTagRestApi.java index 85f399838..fd84e7425 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetTagRestApi.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetTagRestApi.java @@ -45,16 +45,12 @@ public interface MgmtTargetTagRestApi { /** * Handles the GET request of retrieving all target tags. * - * @param pagingOffsetParam the offset of list of target tags for pagination, might not be - * present in the rest request then default value will be applied - * @param pagingLimitParam the limit of the paged request, might not be present in the - * rest request then default value will be applied - * @param sortParam the sorting parameter in the request URL, syntax - * {@code field:direction, field:direction} - * @param rsqlParam the search parameter in the request URL, syntax - * {@code q=name==abc} - * @return a list of all target tags for a defined or default page request - * with status OK. The response is always paged. In any failure the + * @param pagingOffsetParam the offset of list of target tags for pagination, might not be present in the rest request then default value + * will be applied + * @param pagingLimitParam the limit of the paged request, might not be present in the rest request then default value will be applied + * @param sortParam the sorting parameter in the request URL, syntax {@code field:direction, field:direction} + * @param rsqlParam the search parameter in the request URL, syntax {@code q=name==abc} + * @return a list of all target tags for a defined or default page request with status OK. The response is always paged. In any failure the * JsonResponseExceptionHandler is handling the response. */ @Operation(summary = "Return all target tags", @@ -71,8 +67,8 @@ public interface MgmtTargetTagRestApi { @ApiResponse(responseCode = "429", description = "Too many requests. The server will refuse further attempts " + "and the client has to wait another second.") }) - @GetMapping(value = MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING, produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING, + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> getTargetTags( @RequestParam( value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, @@ -119,17 +115,15 @@ public interface MgmtTargetTagRestApi { @ApiResponse(responseCode = "429", description = "Too many requests. The server will refuse further attempts " + "and the client has to wait another second.") }) - @GetMapping(value = MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/{targetTagId}", produces = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/{targetTagId}", + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity getTargetTag(@PathVariable("targetTagId") Long targetTagId); /** - * Handles the POST request of creating new target tag. The request body - * must always be a list of tags. + * Handles the POST request of creating new target tag. The request body must always be a list of tags. * * @param tags the target tags to be created. - * @return In case all modules could successful created the ResponseEntity - * with status code 201 - Created. The Response Body are the created + * @return In case all modules could successful created the ResponseEntity with status code 201 - Created. The Response Body are the created * target tags but without ResponseBody. */ @Operation(summary = "Create target tag(s)", description = "Handles the POST request of creating new target tag. " + @@ -150,13 +144,13 @@ public interface MgmtTargetTagRestApi { @ApiResponse(responseCode = "429", description = "Too many requests. The server will refuse further attempts " + "and the client has to wait another second.") }) - @PostMapping(value = MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING, consumes = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) + @PostMapping(value = MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING, + consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> createTargetTags(List tags); /** - * Handles the PUT request of updating a single targetr tag. + * Handles the PUT request of updating a single target tag. * * @param targetTagId the ID of the target tag * @param restTargetTagRest the request body to be updated @@ -181,11 +175,10 @@ public interface MgmtTargetTagRestApi { @ApiResponse(responseCode = "429", description = "Too many requests. The server will refuse further attempts " + "and the client has to wait another second.") }) - @PutMapping(value = MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/{targetTagId}", consumes = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity updateTargetTag(@PathVariable("targetTagId") Long targetTagId, - MgmtTagRequestBodyPut restTargetTagRest); + @PutMapping(value = MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/{targetTagId}", + consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + ResponseEntity updateTargetTag(@PathVariable("targetTagId") Long targetTagId, MgmtTagRequestBodyPut restTargetTagRest); /** * Handles the DELETE request for a single target tag. @@ -213,18 +206,14 @@ public interface MgmtTargetTagRestApi { ResponseEntity deleteTargetTag(@PathVariable("targetTagId") Long targetTagId); /** - * Handles the GET request of retrieving all assigned targets by the given - * tag id. + * Handles the GET request of retrieving all assigned targets by the given tag id. * * @param targetTagId the ID of the target tag to retrieve - * @param pagingOffsetParam the offset of list of target tags for pagination, might not be - * present in the rest request then default value will be applied - * @param pagingLimitParam the limit of the paged request, might not be present in the - * rest request then default value will be applied - * @param sortParam the sorting parameter in the request URL, syntax - * {@code field:direction, field:direction} - * @param rsqlParam the search parameter in the request URL, syntax - * {@code q=name==abc} + * @param pagingOffsetParam the offset of list of target tags for pagination, might not be present in the rest request then default value + * will be applied + * @param pagingLimitParam the limit of the paged request, might not be present in the rest request then default value will be applied + * @param sortParam the sorting parameter in the request URL, syntax {@code field:direction, field:direction} + * @param rsqlParam the search parameter in the request URL, syntax {@code q=name==abc} * @return the list of assigned targets. */ @Operation(summary = "Return assigned targets for tag", @@ -243,10 +232,10 @@ public interface MgmtTargetTagRestApi { @ApiResponse(responseCode = "429", description = "Too many requests. The server will refuse further attempts " + "and the client has to wait another second.") }) - @GetMapping(value = MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING - + MgmtRestConstants.TARGET_TAG_TARGETS_REQUEST_MAPPING, produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity> getAssignedTargets(@PathVariable("targetTagId") Long targetTagId, + @GetMapping(value = MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + MgmtRestConstants.TARGET_TAG_TARGETS_REQUEST_MAPPING, + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + ResponseEntity> getAssignedTargets( + @PathVariable("targetTagId") Long targetTagId, @RequestParam( value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) @@ -398,8 +387,7 @@ public interface MgmtTargetTagRestApi { @RequestBody List controllerId); /** - * Handles the POST request to toggle the assignment of targets by the given - * tag id. + * Handles the POST request to toggle the assignment of targets by the given tag id. * * @param targetTagId the ID of the target tag to retrieve * @param assignedTargetRequestBodies list of controller ids to be toggled @@ -423,10 +411,10 @@ public interface MgmtTargetTagRestApi { "supported by the server for this resource."), @ApiResponse(responseCode = "429", description = "Too many requests. The server will refuse further attempts and the client has to wait another second.") }) - @PostMapping(value = MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING - + MgmtRestConstants.TARGET_TAG_TARGETS_REQUEST_MAPPING + "/toggleTagAssignment", consumes = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, produces = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @PostMapping(value = MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + + MgmtRestConstants.TARGET_TAG_TARGETS_REQUEST_MAPPING + "/toggleTagAssignment", + consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) @Deprecated(forRemoval = true, since = "0.6.0") ResponseEntity toggleTagAssignment(@PathVariable("targetTagId") Long targetTagId, List assignedTargetRequestBodies); @@ -457,10 +445,9 @@ public interface MgmtTargetTagRestApi { @ApiResponse(responseCode = "429", description = "Too many requests. The server will refuse further attempts " + "and the client has to wait another second.") }) - @PostMapping(value = MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING - + MgmtRestConstants.TARGET_TAG_TARGETS_REQUEST_MAPPING, consumes = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) + @PostMapping(value = MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + MgmtRestConstants.TARGET_TAG_TARGETS_REQUEST_MAPPING, + consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) @Deprecated(forRemoval = true, since = "0.6.0") ResponseEntity> assignTargetsByRequestBody(@PathVariable("targetTagId") Long targetTagId, List assignedTargetRequestBodies); diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetTypeRestApi.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetTypeRestApi.java index 4332d5ccd..dc4bef565 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetTypeRestApi.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTargetTypeRestApi.java @@ -44,17 +44,12 @@ public interface MgmtTargetTypeRestApi { /** * Handles the GET request of retrieving all TargetTypes. * - * @param pagingOffsetParam the offset of list of target types for pagination, might not - * be present in the rest request then default value will be - * applied - * @param pagingLimitParam the limit of the paged request, might not be present in the - * rest request then default value will be applied - * @param sortParam the sorting parameter in the request URL, syntax - * {@code field:direction, field:direction} - * @param rsqlParam the search parameter in the request URL, syntax - * {@code q=name==abc} - * @return a list of all TargetTypes for a defined or default page request - * with status OK. The response is always paged. In any failure the + * @param pagingOffsetParam the offset of list of target types for pagination, might not be present in the rest request then default value + * will be applied + * @param pagingLimitParam the limit of the paged request, might not be present in the rest request then default value will be applied + * @param sortParam the sorting parameter in the request URL, syntax {@code field:direction, field:direction} + * @param rsqlParam the search parameter in the request URL, syntax {@code q=name==abc} + * @return a list of all TargetTypes for a defined or default page request with status OK. The response is always paged. In any failure the * JsonResponseExceptionHandler is handling the response. */ @Operation(summary = "Return all target types", description = "Handles the GET request of retrieving all target types.") @@ -76,8 +71,8 @@ public interface MgmtTargetTypeRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = MgmtRestConstants.TARGETTYPE_V1_REQUEST_MAPPING, produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = MgmtRestConstants.TARGETTYPE_V1_REQUEST_MAPPING, + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> getTargetTypes( @RequestParam( value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, @@ -130,8 +125,8 @@ public interface MgmtTargetTypeRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = MgmtRestConstants.TARGETTYPE_V1_REQUEST_MAPPING + "/{targetTypeId}", produces = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = MgmtRestConstants.TARGETTYPE_V1_REQUEST_MAPPING + "/{targetTypeId}", + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity getTargetType(@PathVariable("targetTypeId") Long targetTypeId); /** @@ -200,21 +195,19 @@ public interface MgmtTargetTypeRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PutMapping(value = MgmtRestConstants.TARGETTYPE_V1_REQUEST_MAPPING + "/{targetTypeId}", consumes = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity updateTargetType(@PathVariable("targetTypeId") Long targetTypeId, + @PutMapping(value = MgmtRestConstants.TARGETTYPE_V1_REQUEST_MAPPING + "/{targetTypeId}", + consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + ResponseEntity updateTargetType( + @PathVariable("targetTypeId") Long targetTypeId, MgmtTargetTypeRequestBodyPut restTargetType); /** - * Handles the POST request of creating new Target Types. The request body - * must always be a list of types. + * Handles the POST request of creating new Target Types. The request body must always be a list of types. * * @param targetTypes the target types to be created. - * @return In case all target types could be successfully created the - * ResponseEntity with status code 201 - Created but without - * ResponseBody. In any failure the JsonResponseExceptionHandler is - * handling the response. + * @return In case all target types could be successfully created the ResponseEntity with status code 201 - Created but without + * ResponseBody. In any failure the JsonResponseExceptionHandler is handling the response. */ @Operation(summary = "Create target types", description = "Handles the POST request for creating new target " + "types. The request body must always be a list of types. Required Permission: CREATE_TARGET") @@ -244,14 +237,13 @@ public interface MgmtTargetTypeRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PostMapping(value = MgmtRestConstants.TARGETTYPE_V1_REQUEST_MAPPING, consumes = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) + @PostMapping(value = MgmtRestConstants.TARGETTYPE_V1_REQUEST_MAPPING, + consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> createTargetTypes(List targetTypes); /** - * Handles the GET request of retrieving the list of compatible distribution - * set types in that target type. + * Handles the GET request of retrieving the list of compatible distribution set types in that target type. * * @param targetTypeId of the TargetType. * @return Unpaged list of distribution set types and OK in case of success. @@ -279,15 +271,12 @@ public interface MgmtTargetTypeRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = MgmtRestConstants.TARGETTYPE_V1_REQUEST_MAPPING + "/{targetTypeId}/" - + MgmtRestConstants.TARGETTYPE_V1_DS_TYPES, produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity> getCompatibleDistributionSets( - @PathVariable("targetTypeId") Long targetTypeId); + @GetMapping(value = MgmtRestConstants.TARGETTYPE_V1_REQUEST_MAPPING + "/{targetTypeId}/" + MgmtRestConstants.TARGETTYPE_V1_DS_TYPES, + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + ResponseEntity> getCompatibleDistributionSets(@PathVariable("targetTypeId") Long targetTypeId); /** - * Handles DELETE request for removing the compatibility of a distribution - * set type from the target type. + * Handles DELETE request for removing the compatibility of a distribution set type from the target type. * * @param targetTypeId of the TargetType. * @param distributionSetTypeId of the DistributionSetType. @@ -316,14 +305,14 @@ public interface MgmtTargetTypeRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @DeleteMapping(value = MgmtRestConstants.TARGETTYPE_V1_REQUEST_MAPPING + "/{targetTypeId}/" - + MgmtRestConstants.TARGETTYPE_V1_DS_TYPES + "/{distributionSetTypeId}") - ResponseEntity removeCompatibleDistributionSet(@PathVariable("targetTypeId") Long targetTypeId, + @DeleteMapping(value = MgmtRestConstants.TARGETTYPE_V1_REQUEST_MAPPING + "/{targetTypeId}/" + + MgmtRestConstants.TARGETTYPE_V1_DS_TYPES + "/{distributionSetTypeId}") + ResponseEntity removeCompatibleDistributionSet( + @PathVariable("targetTypeId") Long targetTypeId, @PathVariable("distributionSetTypeId") Long distributionSetTypeId); /** - * Handles the POST request for adding the compatibility of a distribution - * set type to a target type. + * Handles the POST request for adding the compatibility of a distribution set type to a target type. * * @param targetTypeId of the TargetType. * @param distributionSetTypeIds of the DistributionSetTypes as a List. @@ -358,9 +347,8 @@ public interface MgmtTargetTypeRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PostMapping(value = MgmtRestConstants.TARGETTYPE_V1_REQUEST_MAPPING + "/{targetTypeId}/" - + MgmtRestConstants.TARGETTYPE_V1_DS_TYPES, consumes = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) + @PostMapping(value = MgmtRestConstants.TARGETTYPE_V1_REQUEST_MAPPING + "/{targetTypeId}/" + MgmtRestConstants.TARGETTYPE_V1_DS_TYPES, + consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity addCompatibleDistributionSets(@PathVariable("targetTypeId") final Long targetTypeId, final List distributionSetTypeIds); } \ No newline at end of file diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTenantManagementRestApi.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTenantManagementRestApi.java index 871c0f9e0..0b54061d4 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTenantManagementRestApi.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/rest/api/MgmtTenantManagementRestApi.java @@ -39,8 +39,7 @@ import org.springframework.web.bind.annotation.RequestBody; public interface MgmtTenantManagementRestApi { /** - * Handles the GET request for receiving all tenant specific configuration - * values. + * Handles the GET request for receiving all tenant specific configuration values. * * @return a map of all configuration values. */ @@ -64,17 +63,15 @@ public interface MgmtTenantManagementRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs", produces = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @GetMapping(value = MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs", + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> getTenantConfiguration(); /** - * Handles the DELETE request of deleting a tenant specific configuration - * value. + * Handles the DELETE request of deleting a tenant specific configuration value. * * @param keyName the Name of the configuration key - * @return if the given configuration value exists and could be deleted HTTP - * OK. In any failure the JsonResponseExceptionHandler is handling + * @return if the given configuration value exists and could be deleted HTTP OK. In any failure the JsonResponseExceptionHandler is handling * the response. */ @Operation(summary = "Delete a tenant specific configuration value", description = "The DELETE request removes a " + @@ -98,17 +95,15 @@ public interface MgmtTenantManagementRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @DeleteMapping(value = MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}", produces = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + @DeleteMapping(value = MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}", + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity deleteTenantConfigurationValue(@PathVariable("keyName") String keyName); /** - * Handles the GET request of receiving a tenant specific configuration - * value. + * Handles the GET request of receiving a tenant specific configuration value. * * @param keyName the name of the configuration key - * @return if the given configuration value exists and could be get HTTP OK. - * In any failure the JsonResponseExceptionHandler is handling the + * @return if the given configuration value exists and could be get HTTP OK. In any failure the JsonResponseExceptionHandler is handling the * response. */ @Operation(summary = "Return a tenant specific configuration value", description = "The GET request returns the " + @@ -134,19 +129,16 @@ public interface MgmtTenantManagementRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @GetMapping(value = MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}", produces = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) - ResponseEntity getTenantConfigurationValue( - @PathVariable("keyName") String keyName); + @GetMapping(value = MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}", + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) + ResponseEntity getTenantConfigurationValue(@PathVariable("keyName") String keyName); /** - * Handles the PUT request for updating a tenant specific configuration - * value. + * Handles the PUT request for updating a tenant specific configuration value. * * @param keyName the name of the configuration key * @param configurationValueRest the new value for the configuration - * @return if the given configuration value exists and could be get HTTP OK. - * In any failure the JsonResponseExceptionHandler is handling the + * @return if the given configuration value exists and could be get HTTP OK. In any failure the JsonResponseExceptionHandler is handling the * response. */ @Operation(summary = "Update a tenant specific configuration value.", description = "The PUT request changes a " + @@ -178,9 +170,9 @@ public interface MgmtTenantManagementRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PutMapping(value = MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}", consumes = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) + @PutMapping(value = MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}", + consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity updateTenantConfigurationValue( @PathVariable("keyName") String keyName, MgmtSystemTenantConfigurationValueRequest configurationValueRest); @@ -188,9 +180,8 @@ public interface MgmtTenantManagementRestApi { * Handles the PUT request for updating a batch of tenant specific configurations * * @param configurationValueMap a Map of name - value pairs for the configurations - * @return if the given configurations values exists and could be get HTTP OK. - * In any failure the JsonResponseExceptionHandler is handling the - * response. + * @return if the given configurations values exists and could be get HTTP OK. In any failure the JsonResponseExceptionHandler is handling + * the response. */ @Operation(summary = "Batch update of tenant configuration.", description = "The PUT request updates the whole " + "configuration for the tenant. Required Permission: TENANT_CONFIGURATION") @@ -218,9 +209,9 @@ public interface MgmtTenantManagementRestApi { "and the client has to wait another second.", content = @Content(mediaType = "application/json", schema = @Schema(hidden = true))) }) - @PutMapping(value = MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs", consumes = { - MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, produces = { MediaTypes.HAL_JSON_VALUE, - MediaType.APPLICATION_JSON_VALUE }) + @PutMapping(value = MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs", + consumes = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, + produces = { MediaTypes.HAL_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) ResponseEntity> updateTenantConfiguration( @RequestBody Map configurationValueMap); } \ No newline at end of file diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/test/java/org/eclipse/hawkbit/mgmt/json/model/PagedListTest.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/test/java/org/eclipse/hawkbit/mgmt/json/model/PagedListTest.java index 0d342143c..35f453f37 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/test/java/org/eclipse/hawkbit/mgmt/json/model/PagedListTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/test/java/org/eclipse/hawkbit/mgmt/json/model/PagedListTest.java @@ -10,6 +10,7 @@ package org.eclipse.hawkbit.mgmt.json.model; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import java.util.ArrayList; import java.util.List; @@ -17,7 +18,6 @@ import java.util.List; import io.qameta.allure.Description; import io.qameta.allure.Feature; import io.qameta.allure.Story; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @Feature("Unit Tests - Management API") @@ -25,13 +25,10 @@ import org.junit.jupiter.api.Test; public class PagedListTest { @Test - @Description("Ensures that a null payload entitiy throws an exception.") + @Description("Ensures that a null payload entity throws an exception.") public void createListWithNullContentThrowsException() { - try { - new PagedList<>(null, 0); - Assertions.fail("as content is null"); - } catch (final NullPointerException e) { - } + assertThatThrownBy(() -> new PagedList<>(null, 0)) + .isInstanceOf(NullPointerException.class); } @Test @@ -61,4 +58,4 @@ public class PagedListTest { assertThat(pagedList.getTotal()).as("total size is wrong").isEqualTo(knownTotal); assertThat(pagedList.getSize()).as("list size is wrong").isEqualTo(knownContentList.size()); } -} +} \ No newline at end of file diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/test/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtTargetAssignmentResponseBodyTest.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/test/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtTargetAssignmentResponseBodyTest.java index 5dfa23283..df3ca4f08 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/test/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtTargetAssignmentResponseBodyTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/test/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtTargetAssignmentResponseBodyTest.java @@ -76,4 +76,4 @@ public class MgmtTargetAssignmentResponseBodyTest { response.setAlreadyAssigned(ALREADY_ASSIGNED_COUNT); return response; } -} +} \ No newline at end of file diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/pom.xml b/hawkbit-mgmt/hawkbit-mgmt-resource/pom.xml index d62d5288b..51c1edfa8 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/pom.xml +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/pom.xml @@ -47,6 +47,7 @@ org.springframework spring-context + jakarta.servlet jakarta.servlet-api diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtActionResource.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtActionResource.java index 73e3df9c0..c1e6aec80 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtActionResource.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtActionResource.java @@ -38,8 +38,9 @@ public class MgmtActionResource implements MgmtActionRestApi { } @Override - public ResponseEntity> getActions(final int pagingOffsetParam, final int pagingLimitParam, - final String sortParam, final String rsqlParam, final String representationModeParam) { + public ResponseEntity> getActions( + final int pagingOffsetParam, final int pagingLimitParam, final String sortParam, final String rsqlParam, + final String representationModeParam) { final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam); final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam); diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtApiConfiguration.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtApiConfiguration.java index 574ba4a00..4e26ab016 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtApiConfiguration.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtApiConfiguration.java @@ -26,6 +26,4 @@ import org.springframework.stereotype.Controller; @ComponentScan @Import({ RestConfiguration.class, OpenApiConfiguration.class }) @PropertySource("classpath:/hawkbit-mgmt-api-defaults.properties") -public class MgmtApiConfiguration { - -} +public class MgmtApiConfiguration {} diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtBasicAuthResource.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtBasicAuthResource.java index e28088340..0b9ec000d 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtBasicAuthResource.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtBasicAuthResource.java @@ -23,12 +23,7 @@ public class MgmtBasicAuthResource implements MgmtBasicAuthRestApi { private final TenantAware tenantAware; - /** - * Default constructor - * - * @param tenantAware tenantAware - */ - public MgmtBasicAuthResource(TenantAware tenantAware) { + public MgmtBasicAuthResource(final TenantAware tenantAware) { this.tenantAware = tenantAware; } @@ -39,4 +34,4 @@ public class MgmtBasicAuthResource implements MgmtBasicAuthRestApi { userInfo.setTenant(tenantAware.getCurrentTenant()); return ResponseEntity.ok(userInfo); } -} +} \ No newline at end of file diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDeploymentRequestMapper.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDeploymentRequestMapper.java index 12240df09..e17d615ad 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDeploymentRequestMapper.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDeploymentRequestMapper.java @@ -9,6 +9,8 @@ */ package org.eclipse.hawkbit.mgmt.rest.resource; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; import org.eclipse.hawkbit.mgmt.json.model.MgmtMaintenanceWindowRequestBody; import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtActionType; import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtTargetAssignmentRequestBody; @@ -20,12 +22,9 @@ import org.eclipse.hawkbit.repository.model.DeploymentRequestBuilder; /** * A mapper for assignment requests */ +@NoArgsConstructor(access = AccessLevel.PRIVATE) public final class MgmtDeploymentRequestMapper { - private MgmtDeploymentRequestMapper() { - // Utility class - } - /** * Convert assignment information to an {@link DeploymentRequestBuilder} * @@ -67,4 +66,4 @@ public final class MgmtDeploymentRequestMapper { } return request; } -} +} \ No newline at end of file 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 43548b886..2d8278da0 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 @@ -33,7 +33,7 @@ import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtInvalidateDistrib import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtTargetAssignmentRequestBody; import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtTargetAssignmentResponseBody; import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModule; -import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleAssigment; +import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleAssignment; import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTarget; import org.eclipse.hawkbit.mgmt.json.model.targetfilter.MgmtTargetFilterQuery; import org.eclipse.hawkbit.mgmt.rest.api.MgmtDistributionSetRestApi; @@ -81,30 +81,21 @@ import org.springframework.web.bind.annotation.RestController; public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi { private final SoftwareModuleManagement softwareModuleManagement; - private final TargetManagement targetManagement; - private final TargetFilterQueryManagement targetFilterQueryManagement; - - private final DeploymentManagement deployManagament; - + private final DeploymentManagement deployManagement; private final SystemManagement systemManagement; - private final EntityFactory entityFactory; - private final DistributionSetManagement distributionSetManagement; - private final DistributionSetTypeManagement distributionSetTypeManagement; - private final SystemSecurityContext systemSecurityContext; - private final DistributionSetInvalidationManagement distributionSetInvalidationManagement; - private final TenantConfigHelper tenantConfigHelper; - MgmtDistributionSetResource(final SoftwareModuleManagement softwareModuleManagement, + MgmtDistributionSetResource( + final SoftwareModuleManagement softwareModuleManagement, final TargetManagement targetManagement, final TargetFilterQueryManagement targetFilterQueryManagement, - final DeploymentManagement deployManagament, final SystemManagement systemManagement, + final DeploymentManagement deployManagement, final SystemManagement systemManagement, final EntityFactory entityFactory, final DistributionSetManagement distributionSetManagement, final DistributionSetTypeManagement distributionSetTypeManagement, final SystemSecurityContext systemSecurityContext, final DistributionSetInvalidationManagement distributionSetInvalidationManagement, @@ -112,7 +103,7 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi { this.softwareModuleManagement = softwareModuleManagement; this.targetManagement = targetManagement; this.targetFilterQueryManagement = targetFilterQueryManagement; - this.deployManagament = deployManagament; + this.deployManagement = deployManagement; this.systemManagement = systemManagement; this.entityFactory = entityFactory; this.distributionSetManagement = distributionSetManagement; @@ -185,8 +176,7 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi { .create(MgmtDistributionSetMapper.dsFromRequest(sets, entityFactory)); log.debug("{} distribution sets created, return status {}", sets.size(), HttpStatus.CREATED); - return new ResponseEntity<>(MgmtDistributionSetMapper.toResponseDistributionSets(createdDSets), - HttpStatus.CREATED); + return new ResponseEntity<>(MgmtDistributionSetMapper.toResponseDistributionSets(createdDSets), HttpStatus.CREATED); } @Override @@ -254,8 +244,7 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi { final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting); final Page targetsInstalledDS; if (rsqlParam != null) { - targetsInstalledDS = this.targetManagement.findByInstalledDistributionSetAndRsql(pageable, - distributionSetId, rsqlParam); + targetsInstalledDS = this.targetManagement.findByInstalledDistributionSetAndRsql(pageable, distributionSetId, rsqlParam); } else { targetsInstalledDS = this.targetManagement.findByInstalledDistributionSet(pageable, distributionSetId); } @@ -295,7 +284,7 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi { .map(assignment -> new SimpleEntry<>(assignment.getId(), distributionSetId)) .collect(Collectors.toList()); return ResponseEntity.ok(MgmtDistributionSetMapper - .toResponse(deployManagament.offlineAssignedDistributionSets(offlineAssignments))); + .toResponse(deployManagement.offlineAssignedDistributionSets(offlineAssignments))); } final List deploymentRequests = assignments.stream().map(dsAssignment -> { @@ -306,7 +295,7 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi { .setConfirmationRequired(isConfirmationRequired).build(); }).collect(Collectors.toList()); - final List assignmentResults = deployManagament + final List assignmentResults = deployManagement .assignDistributionSets(deploymentRequests); return ResponseEntity.ok(MgmtDistributionSetMapper.toResponse(assignmentResults)); } @@ -342,30 +331,28 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi { public ResponseEntity getMetadataValue( @PathVariable("distributionSetId") final Long distributionSetId, @PathVariable("metadataKey") final String metadataKey) { - // check if distribution set exists otherwise throw exception - // immediately + // check if distribution set exists otherwise throw exception immediately final DistributionSetMetadata findOne = distributionSetManagement .getMetaDataByDistributionSetId(distributionSetId, metadataKey) - .orElseThrow(() -> new EntityNotFoundException(DistributionSetMetadata.class, distributionSetId, - metadataKey)); + .orElseThrow(() -> new EntityNotFoundException(DistributionSetMetadata.class, distributionSetId, metadataKey)); return ResponseEntity.ok(MgmtDistributionSetMapper.toResponseDsMetadata(findOne)); } @Override - public ResponseEntity updateMetadata(@PathVariable("distributionSetId") final Long distributionSetId, + public ResponseEntity updateMetadata( + @PathVariable("distributionSetId") final Long distributionSetId, @PathVariable("metadataKey") final String metadataKey, @RequestBody final MgmtMetadataBodyPut metadata) { - // check if distribution set exists otherwise throw exception - // immediately + // check if distribution set exists otherwise throw exception immediately final DistributionSetMetadata updated = distributionSetManagement.updateMetaData(distributionSetId, entityFactory.generateDsMetadata(metadataKey, metadata.getValue())); return ResponseEntity.ok(MgmtDistributionSetMapper.toResponseDsMetadata(updated)); } @Override - public ResponseEntity deleteMetadata(@PathVariable("distributionSetId") final Long distributionSetId, + public ResponseEntity deleteMetadata( + @PathVariable("distributionSetId") final Long distributionSetId, @PathVariable("metadataKey") final String metadataKey) { - // check if distribution set exists otherwise throw exception - // immediately + // check if distribution set exists otherwise throw exception immediately distributionSetManagement.deleteMetaData(distributionSetId, metadataKey); return ResponseEntity.ok().build(); } @@ -374,8 +361,7 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi { public ResponseEntity> createMetadata( @PathVariable("distributionSetId") final Long distributionSetId, @RequestBody final List metadataRest) { - // check if distribution set exists otherwise throw exception - // immediately + // check if distribution set exists otherwise throw exception immediately final List created = distributionSetManagement.createMetaData(distributionSetId, MgmtDistributionSetMapper.fromRequestDsMetadata(metadataRest, entityFactory)); return new ResponseEntity<>(MgmtDistributionSetMapper.toResponseDsMetadata(created), HttpStatus.CREATED); @@ -383,11 +369,11 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi { } @Override - public ResponseEntity assignSoftwareModules(@PathVariable("distributionSetId") final Long distributionSetId, - @RequestBody final List softwareModuleIDs) { - + public ResponseEntity assignSoftwareModules( + @PathVariable("distributionSetId") final Long distributionSetId, + @RequestBody final List softwareModuleIDs) { distributionSetManagement.assignSoftwareModules(distributionSetId, - softwareModuleIDs.stream().map(MgmtSoftwareModuleAssigment::getId).collect(Collectors.toList())); + softwareModuleIDs.stream().map(MgmtSoftwareModuleAssignment::getId).collect(Collectors.toList())); return ResponseEntity.ok().build(); } @@ -460,4 +446,4 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi { invalidateRequestBody.isCancelRollouts())); return ResponseEntity.ok().build(); } -} +} \ No newline at end of file diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTagResource.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTagResource.java index 13cd6c380..1e98f20fb 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTagResource.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTagResource.java @@ -49,12 +49,11 @@ import org.springframework.web.bind.annotation.RestController; public class MgmtDistributionSetTagResource implements MgmtDistributionSetTagRestApi { private final DistributionSetTagManagement distributionSetTagManagement; - private final DistributionSetManagement distributionSetManagement; - private final EntityFactory entityFactory; - MgmtDistributionSetTagResource(final DistributionSetTagManagement distributionSetTagManagement, + MgmtDistributionSetTagResource( + final DistributionSetTagManagement distributionSetTagManagement, final DistributionSetManagement distributionSetManagement, final EntityFactory entityFactory) { this.distributionSetTagManagement = distributionSetTagManagement; this.distributionSetManagement = distributionSetManagement; @@ -67,7 +66,6 @@ public class MgmtDistributionSetTagResource implements MgmtDistributionSetTagRes @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam) { - final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam); final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam); final Sort sorting = PagingUtility.sanitizeTagSortParam(sortParam); @@ -78,12 +76,10 @@ public class MgmtDistributionSetTagResource implements MgmtDistributionSetTagRes if (rsqlParam == null) { distributionSetTags = distributionSetTagManagement.findAll(pageable); count = distributionSetTagManagement.count(); - } else { final Page page = distributionSetTagManagement.findByRsql(pageable, rsqlParam); distributionSetTags = page; count = page.getTotalElements(); - } final List rest = MgmtTagMapper.toResponseDistributionSetTag(distributionSetTags.getContent()); @@ -106,8 +102,7 @@ public class MgmtDistributionSetTagResource implements MgmtDistributionSetTagRes @RequestBody final List tags) { log.debug("creating {} ds tags", tags.size()); - final List createdTags = distributionSetTagManagement - .create(MgmtTagMapper.mapTagFromRequest(entityFactory, tags)); + final List createdTags = distributionSetTagManagement.create(MgmtTagMapper.mapTagFromRequest(entityFactory, tags)); return new ResponseEntity<>(MgmtTagMapper.toResponseDistributionSetTag(createdTags), HttpStatus.CREATED); } @@ -153,13 +148,11 @@ public class MgmtDistributionSetTagResource implements MgmtDistributionSetTagRes Page findDistrAll; if (rsqlParam == null) { findDistrAll = distributionSetManagement.findByTag(pageable, distributionsetTagId); - } else { findDistrAll = distributionSetManagement.findByRsqlAndTag(pageable, rsqlParam, distributionsetTagId); } - final List rest = MgmtDistributionSetMapper - .toResponseFromDsList(findDistrAll.getContent()); + final List rest = MgmtDistributionSetMapper.toResponseFromDsList(findDistrAll.getContent()); return ResponseEntity.ok(new PagedList<>(rest, findDistrAll.getTotalElements())); } @@ -173,12 +166,9 @@ public class MgmtDistributionSetTagResource implements MgmtDistributionSetTagRes } @Override - public ResponseEntity assignDistributionSets( - final Long distributionsetTagId, - final List distributionsetIds) { + public ResponseEntity assignDistributionSets(final Long distributionsetTagId, final List distributionsetIds) { log.debug("Assign DistributionSet {} for ds tag {}", distributionsetIds.size(), distributionsetTagId); - final List assignedDs = this.distributionSetManagement - .assignTag(distributionsetIds, distributionsetTagId); + final List assignedDs = this.distributionSetManagement.assignTag(distributionsetIds, distributionsetTagId); log.debug("Assigned DistributionSet {}", assignedDs.size()); return ResponseEntity.ok().build(); } @@ -197,8 +187,7 @@ public class MgmtDistributionSetTagResource implements MgmtDistributionSetTagRes @PathVariable("distributionsetTagId") final Long distributionsetTagId, @RequestBody final List distributionsetIds) { log.debug("Unassign DistributionSet {} for ds tag {}", distributionsetIds.size(), distributionsetTagId); - final List assignedDs = this.distributionSetManagement - .unassignTag(distributionsetIds, distributionsetTagId); + final List assignedDs = this.distributionSetManagement.unassignTag(distributionsetIds, distributionsetTagId); log.debug("Unassigned DistributionSet {}", assignedDs.size()); return ResponseEntity.ok().build(); } @@ -207,8 +196,7 @@ public class MgmtDistributionSetTagResource implements MgmtDistributionSetTagRes public ResponseEntity toggleTagAssignment( @PathVariable("distributionsetTagId") final Long distributionsetTagId, @RequestBody final List assignedDSRequestBodies) { - log.debug("Toggle distribution set assignment {} for ds tag {}", assignedDSRequestBodies.size(), - distributionsetTagId); + log.debug("Toggle distribution set assignment {} for ds tag {}", assignedDSRequestBodies.size(), distributionsetTagId); final DistributionSetTag tag = findDistributionTagById(distributionsetTagId); @@ -221,8 +209,7 @@ public class MgmtDistributionSetTagResource implements MgmtDistributionSetTagRes tagAssigmentResultRest.setUnassignedDistributionSets( MgmtDistributionSetMapper.toResponseDistributionSets(assigmentResult.getUnassignedEntity())); - log.debug("Toggled assignedDS {} and unassignedDS{}", assigmentResult.getAssigned(), - assigmentResult.getUnassigned()); + log.debug("Toggled assignedDS {} and unassignedDS{}", assigmentResult.getAssigned(), assigmentResult.getUnassigned()); return ResponseEntity.ok(tagAssigmentResultRest); } diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeMapper.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeMapper.java index 1a79fb217..61f26dc08 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeMapper.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeMapper.java @@ -20,7 +20,7 @@ import java.util.stream.Collectors; import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionSetType; import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionSetTypeRequestBodyPost; -import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleTypeAssigment; +import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleTypeAssignment; import org.eclipse.hawkbit.mgmt.rest.api.MgmtDistributionSetTypeRestApi; import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; import org.eclipse.hawkbit.repository.EntityFactory; @@ -87,13 +87,13 @@ final class MgmtDistributionSetTypeMapper { private static Collection getMandatoryModules(final MgmtDistributionSetTypeRequestBodyPost smsRest) { return Optional.ofNullable(smsRest.getMandatorymodules()).map( - modules -> modules.stream().map(MgmtSoftwareModuleTypeAssigment::getId).collect(Collectors.toList())) + modules -> modules.stream().map(MgmtSoftwareModuleTypeAssignment::getId).collect(Collectors.toList())) .orElse(Collections.emptyList()); } private static Collection getOptionalmodules(final MgmtDistributionSetTypeRequestBodyPost smsRest) { return Optional.ofNullable(smsRest.getOptionalmodules()).map( - modules -> modules.stream().map(MgmtSoftwareModuleTypeAssigment::getId).collect(Collectors.toList())) + modules -> modules.stream().map(MgmtSoftwareModuleTypeAssignment::getId).collect(Collectors.toList())) .orElse(Collections.emptyList()); } diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeResource.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeResource.java index d5b89fa8c..deb26a313 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeResource.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeResource.java @@ -9,7 +9,7 @@ */ package org.eclipse.hawkbit.mgmt.rest.resource; -import java.util.Arrays; +import java.util.Collections; import java.util.List; import org.eclipse.hawkbit.mgmt.json.model.MgmtId; @@ -47,12 +47,11 @@ import org.springframework.web.bind.annotation.RestController; public class MgmtDistributionSetTypeResource implements MgmtDistributionSetTypeRestApi { private final SoftwareModuleTypeManagement softwareModuleTypeManagement; - private final DistributionSetTypeManagement distributionSetTypeManagement; - private final EntityFactory entityFactory; - MgmtDistributionSetTypeResource(final SoftwareModuleTypeManagement softwareModuleTypeManagement, + MgmtDistributionSetTypeResource( + final SoftwareModuleTypeManagement softwareModuleTypeManagement, final DistributionSetTypeManagement distributionSetTypeManagement, final EntityFactory entityFactory) { this.softwareModuleTypeManagement = softwareModuleTypeManagement; this.distributionSetTypeManagement = distributionSetTypeManagement; @@ -81,8 +80,7 @@ public class MgmtDistributionSetTypeResource implements MgmtDistributionSetTypeR countModulesAll = distributionSetTypeManagement.count(); } - final List rest = MgmtDistributionSetTypeMapper - .toListResponse(findModuleTypessAll.getContent()); + final List rest = MgmtDistributionSetTypeMapper.toListResponse(findModuleTypessAll.getContent()); return ResponseEntity.ok(new PagedList<>(rest, countModulesAll)); } @@ -92,15 +90,14 @@ public class MgmtDistributionSetTypeResource implements MgmtDistributionSetTypeR final DistributionSetType foundType = findDistributionSetTypeWithExceptionIfNotFound(distributionSetTypeId); - final MgmtDistributionSetType reponse = MgmtDistributionSetTypeMapper.toResponse(foundType); - MgmtDistributionSetTypeMapper.addLinks(reponse); + final MgmtDistributionSetType response = MgmtDistributionSetTypeMapper.toResponse(foundType); + MgmtDistributionSetTypeMapper.addLinks(response); - return ResponseEntity.ok(reponse); + return ResponseEntity.ok(response); } @Override - public ResponseEntity deleteDistributionSetType( - @PathVariable("distributionSetTypeId") final Long distributionSetTypeId) { + public ResponseEntity deleteDistributionSetType(@PathVariable("distributionSetTypeId") final Long distributionSetTypeId) { distributionSetTypeManagement.delete(distributionSetTypeId); return ResponseEntity.ok().build(); @@ -110,21 +107,19 @@ public class MgmtDistributionSetTypeResource implements MgmtDistributionSetTypeR public ResponseEntity updateDistributionSetType( @PathVariable("distributionSetTypeId") final Long distributionSetTypeId, @RequestBody final MgmtDistributionSetTypeRequestBodyPut restDistributionSetType) { - final DistributionSetType updated = distributionSetTypeManagement.update(entityFactory.distributionSetType() .update(distributionSetTypeId).description(restDistributionSetType.getDescription()) .colour(restDistributionSetType.getColour())); - final MgmtDistributionSetType reponse = MgmtDistributionSetTypeMapper.toResponse(updated); - MgmtDistributionSetTypeMapper.addLinks(reponse); + final MgmtDistributionSetType response = MgmtDistributionSetTypeMapper.toResponse(updated); + MgmtDistributionSetTypeMapper.addLinks(response); - return ResponseEntity.ok(reponse); + return ResponseEntity.ok(response); } @Override public ResponseEntity> createDistributionSetTypes( @RequestBody final List distributionSetTypes) { - final List createdSoftwareModules = distributionSetTypeManagement .create(MgmtDistributionSetTypeMapper.smFromRequest(entityFactory, distributionSetTypes)); @@ -135,7 +130,6 @@ public class MgmtDistributionSetTypeResource implements MgmtDistributionSetTypeR @Override public ResponseEntity> getMandatoryModules( @PathVariable("distributionSetTypeId") final Long distributionSetTypeId) { - final DistributionSetType foundType = findDistributionSetTypeWithExceptionIfNotFound(distributionSetTypeId); return ResponseEntity.ok(MgmtSoftwareModuleTypeMapper.toTypesResponse(foundType.getMandatoryModuleTypes())); } @@ -144,7 +138,6 @@ public class MgmtDistributionSetTypeResource implements MgmtDistributionSetTypeR public ResponseEntity getMandatoryModule( @PathVariable("distributionSetTypeId") final Long distributionSetTypeId, @PathVariable("softwareModuleTypeId") final Long softwareModuleTypeId) { - final DistributionSetType foundType = findDistributionSetTypeWithExceptionIfNotFound(distributionSetTypeId); final SoftwareModuleType foundSmType = findSoftwareModuleTypeWithExceptionIfNotFound(softwareModuleTypeId); @@ -159,7 +152,6 @@ public class MgmtDistributionSetTypeResource implements MgmtDistributionSetTypeR public ResponseEntity getOptionalModule( @PathVariable("distributionSetTypeId") final Long distributionSetTypeId, @PathVariable("softwareModuleTypeId") final Long softwareModuleTypeId) { - final DistributionSetType foundType = findDistributionSetTypeWithExceptionIfNotFound(distributionSetTypeId); final SoftwareModuleType foundSmType = findSoftwareModuleTypeWithExceptionIfNotFound(softwareModuleTypeId); @@ -173,7 +165,6 @@ public class MgmtDistributionSetTypeResource implements MgmtDistributionSetTypeR @Override public ResponseEntity> getOptionalModules( @PathVariable("distributionSetTypeId") final Long distributionSetTypeId) { - final DistributionSetType foundType = findDistributionSetTypeWithExceptionIfNotFound(distributionSetTypeId); return ResponseEntity.ok(MgmtSoftwareModuleTypeMapper.toTypesResponse(foundType.getOptionalModuleTypes())); } @@ -191,26 +182,20 @@ public class MgmtDistributionSetTypeResource implements MgmtDistributionSetTypeR public ResponseEntity removeOptionalModule( @PathVariable("distributionSetTypeId") final Long distributionSetTypeId, @PathVariable("softwareModuleTypeId") final Long softwareModuleTypeId) { - return removeMandatoryModule(distributionSetTypeId, softwareModuleTypeId); } @Override public ResponseEntity addMandatoryModule( @PathVariable("distributionSetTypeId") final Long distributionSetTypeId, @RequestBody final MgmtId smtId) { - - distributionSetTypeManagement.assignMandatorySoftwareModuleTypes(distributionSetTypeId, - Arrays.asList(smtId.getId())); - + distributionSetTypeManagement.assignMandatorySoftwareModuleTypes(distributionSetTypeId, Collections.singletonList(smtId.getId())); return ResponseEntity.ok().build(); } @Override public ResponseEntity addOptionalModule( @PathVariable("distributionSetTypeId") final Long distributionSetTypeId, @RequestBody final MgmtId smtId) { - - distributionSetTypeManagement.assignOptionalSoftwareModuleTypes(distributionSetTypeId, - Arrays.asList(smtId.getId())); + distributionSetTypeManagement.assignOptionalSoftwareModuleTypes(distributionSetTypeId, Collections.singletonList(smtId.getId())); return ResponseEntity.ok().build(); } @@ -221,8 +206,7 @@ public class MgmtDistributionSetTypeResource implements MgmtDistributionSetTypeR } private SoftwareModuleType findSoftwareModuleTypeWithExceptionIfNotFound(final Long softwareModuleTypeId) { - return softwareModuleTypeManagement.get(softwareModuleTypeId) .orElseThrow(() -> new EntityNotFoundException(SoftwareModuleType.class, softwareModuleTypeId)); } -} +} \ No newline at end of file diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDownloadArtifactResource.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDownloadArtifactResource.java index adf8e4e4a..07bd02aad 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDownloadArtifactResource.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDownloadArtifactResource.java @@ -43,7 +43,6 @@ public class MgmtDownloadArtifactResource implements MgmtDownloadArtifactRestApi @Autowired private SoftwareModuleManagement softwareModuleManagement; - @Autowired private ArtifactManagement artifactManagement; @@ -55,9 +54,9 @@ public class MgmtDownloadArtifactResource implements MgmtDownloadArtifactRestApi * @return responseEntity with status ok if successful */ @Override - public ResponseEntity downloadArtifact(@PathVariable("softwareModuleId") final Long softwareModuleId, + public ResponseEntity downloadArtifact( + @PathVariable("softwareModuleId") final Long softwareModuleId, @PathVariable("artifactId") final Long artifactId) { - final SoftwareModule module = softwareModuleManagement.get(softwareModuleId) .orElseThrow(() -> new EntityNotFoundException(SoftwareModule.class, softwareModuleId)); if (module.isDeleted()) { diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRestModelMapper.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRestModelMapper.java index c34708e09..e1ca61ee7 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRestModelMapper.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRestModelMapper.java @@ -9,6 +9,8 @@ */ package org.eclipse.hawkbit.mgmt.rest.resource; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; import org.eclipse.hawkbit.mgmt.json.model.MgmtBaseEntity; import org.eclipse.hawkbit.mgmt.json.model.MgmtNamedEntity; import org.eclipse.hawkbit.mgmt.json.model.MgmtTypeEntity; @@ -21,19 +23,13 @@ import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity; import org.eclipse.hawkbit.repository.model.Type; /** - * A mapper which maps repository model to RESTful model representation and - * back. + * A mapper which maps repository model to RESTful model representation and back. */ +@NoArgsConstructor(access = AccessLevel.PRIVATE) public final class MgmtRestModelMapper { - // private constructor, utility class - private MgmtRestModelMapper() { - - } - /** - * Convert the given {@link MgmtActionType} into a corresponding repository - * {@link ActionType}. + * Convert the given {@link MgmtActionType} into a corresponding repository {@link ActionType}. * * @param actionTypeRest the REST representation of the action type * @return or the repository action type @@ -43,23 +39,16 @@ public final class MgmtRestModelMapper { return null; } - switch (actionTypeRest) { - case SOFT: - return ActionType.SOFT; - case FORCED: - return ActionType.FORCED; - case TIMEFORCED: - return ActionType.TIMEFORCED; - case DOWNLOAD_ONLY: - return ActionType.DOWNLOAD_ONLY; - default: - throw new IllegalStateException("Action Type is not supported"); - } + return switch (actionTypeRest) { + case SOFT -> ActionType.SOFT; + case FORCED -> ActionType.FORCED; + case TIMEFORCED -> ActionType.TIMEFORCED; + case DOWNLOAD_ONLY -> ActionType.DOWNLOAD_ONLY; + }; } /** - * Converts the given repository {@link ActionType} into a corresponding - * {@link MgmtActionType}. + * Converts the given repository {@link ActionType} into a corresponding {@link MgmtActionType}. * * @param actionType the repository representation of the action type * @return or the REST action type @@ -69,23 +58,16 @@ public final class MgmtRestModelMapper { return null; } - switch (actionType) { - case SOFT: - return MgmtActionType.SOFT; - case FORCED: - return MgmtActionType.FORCED; - case TIMEFORCED: - return MgmtActionType.TIMEFORCED; - case DOWNLOAD_ONLY: - return MgmtActionType.DOWNLOAD_ONLY; - default: - throw new IllegalStateException("Action Type is not supported"); - } + return switch (actionType) { + case SOFT -> MgmtActionType.SOFT; + case FORCED -> MgmtActionType.FORCED; + case TIMEFORCED -> MgmtActionType.TIMEFORCED; + case DOWNLOAD_ONLY -> MgmtActionType.DOWNLOAD_ONLY; + }; } /** - * Converts the given repository {@link CancelationType} into a - * corresponding {@link MgmtCancelationType}. + * Converts the given repository {@link CancelationType} into a corresponding {@link MgmtCancelationType}. * * @param cancelationType the repository representation of the cancellation type * @return or the REST cancellation type @@ -95,16 +77,11 @@ public final class MgmtRestModelMapper { return null; } - switch (cancelationType) { - case SOFT: - return CancelationType.SOFT; - case FORCE: - return CancelationType.FORCE; - case NONE: - return CancelationType.NONE; - default: - throw new IllegalStateException("Action Cancelation Type is not supported"); - } + return switch (cancelationType) { + case SOFT -> CancelationType.SOFT; + case FORCE -> CancelationType.FORCE; + case NONE -> CancelationType.NONE; + }; } static void mapBaseToBase(final MgmtBaseEntity response, final TenantAwareBaseEntity base) { @@ -132,4 +109,4 @@ public final class MgmtRestModelMapper { response.setColour(base.getColour()); response.setDeleted(base.isDeleted()); } -} +} \ No newline at end of file diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutMapper.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutMapper.java index 1fe391948..be190717f 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutMapper.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutMapper.java @@ -17,6 +17,8 @@ import java.util.List; import java.util.Optional; import java.util.stream.Collectors; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; import org.eclipse.hawkbit.mgmt.json.model.rollout.AbstractMgmtRolloutConditionsEntity; import org.eclipse.hawkbit.mgmt.json.model.rollout.MgmtRolloutCondition; import org.eclipse.hawkbit.mgmt.json.model.rollout.MgmtRolloutCondition.Condition; @@ -50,17 +52,13 @@ import org.eclipse.hawkbit.repository.model.RolloutGroupConditions; import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus; /** - * A mapper which maps repository model to RESTful model representation and - * back. + * A mapper which maps repository model to RESTful model representation and back. */ +@NoArgsConstructor(access = AccessLevel.PRIVATE) final class MgmtRolloutMapper { private static final String NOT_SUPPORTED = " is not supported"; - private MgmtRolloutMapper() { - // Utility class - } - static List toResponseRollout(final List rollouts) { return toResponseRollout(rollouts, false); } @@ -314,4 +312,4 @@ final class MgmtRolloutMapper { private static String createIllegalArgumentLiteral(final Condition condition) { return "Condition " + condition + NOT_SUPPORTED; } -} +} \ No newline at end of file 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 840975604..eda9d0cb4 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 @@ -65,17 +65,14 @@ import org.springframework.web.bind.annotation.RestController; public class MgmtRolloutResource implements MgmtRolloutRestApi { private final RolloutManagement rolloutManagement; - private final RolloutGroupManagement rolloutGroupManagement; - private final DistributionSetManagement distributionSetManagement; - private final TargetFilterQueryManagement targetFilterQueryManagement; - private final EntityFactory entityFactory; private final TenantConfigHelper tenantConfigHelper; - MgmtRolloutResource(final RolloutManagement rolloutManagement, final RolloutGroupManagement rolloutGroupManagement, + MgmtRolloutResource( + final RolloutManagement rolloutManagement, final RolloutGroupManagement rolloutGroupManagement, final DistributionSetManagement distributionSetManagement, final TargetFilterQueryManagement targetFilterQueryManagement, final EntityFactory entityFactory, final SystemSecurityContext systemSecurityContext, diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleMapper.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleMapper.java index 61fcc6b0f..67a6a05c6 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleMapper.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleMapper.java @@ -42,8 +42,7 @@ import org.eclipse.hawkbit.rest.json.model.ResponseList; import org.springframework.hateoas.Link; /** - * A mapper which maps repository model to RESTful model representation and - * back. + * A mapper which maps repository model to RESTful model representation and back. */ @NoArgsConstructor(access = AccessLevel.PRIVATE) public final class MgmtSoftwareModuleMapper { diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResource.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResource.java index fa66404b1..76a4272fd 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResource.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResource.java @@ -73,7 +73,8 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi { private final SystemManagement systemManagement; private final EntityFactory entityFactory; - MgmtSoftwareModuleResource(final ArtifactManagement artifactManagement, final SoftwareModuleManagement softwareModuleManagement, + MgmtSoftwareModuleResource( + final ArtifactManagement artifactManagement, final SoftwareModuleManagement softwareModuleManagement, final SoftwareModuleTypeManagement softwareModuleTypeManagement, final ArtifactUrlHandler artifactUrlHandler, final SystemManagement systemManagement, final EntityFactory entityFactory) { @@ -86,7 +87,8 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi { } @Override - public ResponseEntity uploadArtifact(@PathVariable("softwareModuleId") final Long softwareModuleId, + public ResponseEntity uploadArtifact( + @PathVariable("softwareModuleId") final Long softwareModuleId, @RequestPart("file") final MultipartFile file, @RequestParam(value = "filename", required = false) final String optionalFileName, @RequestParam(value = "md5sum", required = false) final String md5Sum, @@ -137,13 +139,14 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi { return ResponseEntity.ok(new ResponseList<>(response)); } - @Override - @ResponseBody // Exception squid:S3655 - Optional access is checked in // findSoftwareModuleWithExceptionIfNotFound // subroutine @SuppressWarnings("squid:S3655") - public ResponseEntity getArtifact(@PathVariable("softwareModuleId") final Long softwareModuleId, + @Override + @ResponseBody + public ResponseEntity getArtifact( + @PathVariable("softwareModuleId") final Long softwareModuleId, @PathVariable("artifactId") final Long artifactId, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_USE_ARTIFACT_URL_HANDLER, required = false) final Boolean useArtifactUrlHandler) { final SoftwareModule module = findSoftwareModuleWithExceptionIfNotFound(softwareModuleId, artifactId); @@ -163,9 +166,9 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi { @Override @ResponseBody - public ResponseEntity deleteArtifact(@PathVariable("softwareModuleId") final Long softwareModuleId, + public ResponseEntity deleteArtifact( + @PathVariable("softwareModuleId") final Long softwareModuleId, @PathVariable("artifactId") final Long artifactId) { - findSoftwareModuleWithExceptionIfNotFound(softwareModuleId, artifactId); artifactManagement.delete(artifactId); @@ -178,7 +181,6 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi { @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam) { - final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam); final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam); final Sort sorting = PagingUtility.sanitizeSoftwareModuleSortParam(sortParam); @@ -200,9 +202,7 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi { } @Override - public ResponseEntity getSoftwareModule( - @PathVariable("softwareModuleId") final Long softwareModuleId) { - + public ResponseEntity getSoftwareModule(@PathVariable("softwareModuleId") final Long softwareModuleId) { final SoftwareModule module = findSoftwareModuleWithExceptionIfNotFound(softwareModuleId, null); final MgmtSoftwareModule response = MgmtSoftwareModuleMapper.toResponse(module); @@ -214,7 +214,6 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi { @Override public ResponseEntity> createSoftwareModules( @RequestBody final List softwareModules) { - log.debug("creating {} softwareModules", softwareModules.size()); for (final MgmtSoftwareModuleRequestBodyPost sm : softwareModules) { @@ -285,8 +284,7 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi { } return ResponseEntity - .ok(new PagedList<>(MgmtSoftwareModuleMapper.toResponseSwMetadata(metaDataPage.getContent()), - metaDataPage.getTotalElements())); + .ok(new PagedList<>(MgmtSoftwareModuleMapper.toResponseSwMetadata(metaDataPage.getContent()), metaDataPage.getTotalElements())); } @Override @@ -346,10 +344,10 @@ public class MgmtSoftwareModuleResource implements MgmtSoftwareModuleRestApi { final SoftwareModule module = softwareModuleManagement.get(softwareModuleId) .orElseThrow(() -> new EntityNotFoundException(SoftwareModule.class, softwareModuleId)); - if (artifactId != null && !module.getArtifact(artifactId).isPresent()) { + if (artifactId != null && module.getArtifact(artifactId).isEmpty()) { throw new EntityNotFoundException(Artifact.class, artifactId); } return module; } -} +} \ No newline at end of file diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeMapper.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeMapper.java index e39d1ff1f..b3c304eac 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeMapper.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeMapper.java @@ -17,6 +17,8 @@ import java.util.Collections; import java.util.List; import java.util.stream.Collectors; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleType; import org.eclipse.hawkbit.mgmt.json.model.softwaremoduletype.MgmtSoftwareModuleTypeRequestBodyPost; import org.eclipse.hawkbit.mgmt.rest.api.MgmtSoftwareModuleTypeRestApi; @@ -26,16 +28,11 @@ import org.eclipse.hawkbit.repository.model.SoftwareModuleType; import org.eclipse.hawkbit.rest.json.model.ResponseList; /** - * A mapper which maps repository model to RESTful model representation and - * back. + * A mapper which maps repository model to RESTful model representation and back. */ +@NoArgsConstructor(access = AccessLevel.PRIVATE) final class MgmtSoftwareModuleTypeMapper { - // private constructor, utility class - private MgmtSoftwareModuleTypeMapper() { - - } - static List smFromRequest(final EntityFactory entityFactory, final Collection smTypesRest) { if (smTypesRest == null) { @@ -50,8 +47,7 @@ final class MgmtSoftwareModuleTypeMapper { return Collections.emptyList(); } - return new ResponseList<>( - types.stream().map(MgmtSoftwareModuleTypeMapper::toResponse).collect(Collectors.toList())); + return new ResponseList<>(types.stream().map(MgmtSoftwareModuleTypeMapper::toResponse).collect(Collectors.toList())); } static MgmtSoftwareModuleType toResponse(final SoftwareModuleType type) { @@ -73,5 +69,4 @@ final class MgmtSoftwareModuleTypeMapper { .description(smsRest.getDescription()).colour(smsRest.getColour()) .maxAssignments(smsRest.getMaxAssignments()); } - -} +} \ No newline at end of file diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeResource.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeResource.java index 9af12f9ff..0ee1efddc 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeResource.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeResource.java @@ -41,11 +41,9 @@ import org.springframework.web.bind.annotation.RestController; public class MgmtSoftwareModuleTypeResource implements MgmtSoftwareModuleTypeRestApi { private final SoftwareModuleTypeManagement softwareModuleTypeManagement; - private final EntityFactory entityFactory; - MgmtSoftwareModuleTypeResource(final SoftwareModuleTypeManagement softwareModuleTypeManagement, - final EntityFactory entityFactory) { + MgmtSoftwareModuleTypeResource(final SoftwareModuleTypeManagement softwareModuleTypeManagement, final EntityFactory entityFactory) { this.softwareModuleTypeManagement = softwareModuleTypeManagement; this.entityFactory = entityFactory; } @@ -56,7 +54,6 @@ public class MgmtSoftwareModuleTypeResource implements MgmtSoftwareModuleTypeRes @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam) { - final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam); final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam); final Sort sorting = PagingUtility.sanitizeSoftwareModuleTypeSortParam(sortParam); @@ -64,7 +61,7 @@ public class MgmtSoftwareModuleTypeResource implements MgmtSoftwareModuleTypeRes final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting); final Slice findModuleTypessAll; - Long countModulesAll; + final long countModulesAll; if (rsqlParam != null) { findModuleTypessAll = softwareModuleTypeManagement.findByRsql(pageable, rsqlParam); countModulesAll = ((Page) findModuleTypessAll).getTotalElements(); @@ -73,8 +70,7 @@ public class MgmtSoftwareModuleTypeResource implements MgmtSoftwareModuleTypeRes countModulesAll = softwareModuleTypeManagement.count(); } - final List rest = MgmtSoftwareModuleTypeMapper - .toTypesResponse(findModuleTypessAll.getContent()); + final List rest = MgmtSoftwareModuleTypeMapper.toTypesResponse(findModuleTypessAll.getContent()); return ResponseEntity.ok(new PagedList<>(rest, countModulesAll)); } @@ -97,7 +93,6 @@ public class MgmtSoftwareModuleTypeResource implements MgmtSoftwareModuleTypeRes public ResponseEntity updateSoftwareModuleType( @PathVariable("softwareModuleTypeId") final Long softwareModuleTypeId, @RequestBody final MgmtSoftwareModuleTypeRequestBodyPut restSoftwareModuleType) { - final SoftwareModuleType updatedSoftwareModuleType = softwareModuleTypeManagement.update(entityFactory .softwareModuleType().update(softwareModuleTypeId).description(restSoftwareModuleType.getDescription()) .colour(restSoftwareModuleType.getColour())); @@ -108,17 +103,14 @@ public class MgmtSoftwareModuleTypeResource implements MgmtSoftwareModuleTypeRes @Override public ResponseEntity> createSoftwareModuleTypes( @RequestBody final List softwareModuleTypes) { - final List createdSoftwareModules = softwareModuleTypeManagement .create(MgmtSoftwareModuleTypeMapper.smFromRequest(entityFactory, softwareModuleTypes)); - return new ResponseEntity<>(MgmtSoftwareModuleTypeMapper.toTypesResponse(createdSoftwareModules), - HttpStatus.CREATED); + return new ResponseEntity<>(MgmtSoftwareModuleTypeMapper.toTypesResponse(createdSoftwareModules), HttpStatus.CREATED); } private SoftwareModuleType findSoftwareModuleTypeWithExceptionIfNotFound(final Long softwareModuleTypeId) { return softwareModuleTypeManagement.get(softwareModuleTypeId) .orElseThrow(() -> new EntityNotFoundException(SoftwareModuleType.class, softwareModuleTypeId)); } - -} +} \ No newline at end of file diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSystemManagementResource.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSystemManagementResource.java index 189202d8c..3028cb1d4 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSystemManagementResource.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSystemManagementResource.java @@ -37,7 +37,6 @@ import org.springframework.web.bind.annotation.RestController; public class MgmtSystemManagementResource implements MgmtSystemManagementRestApi { private final SystemManagement systemManagement; - private final CacheManager cacheManager; MgmtSystemManagementResource(final SystemManagement systemManagement, final CacheManager cacheManager) { diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTagMapper.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTagMapper.java index da4a94f3f..f20c05314 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTagMapper.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTagMapper.java @@ -59,8 +59,7 @@ final class MgmtTagMapper { mapTag(response, targetTag); - response.add( - linkTo(methodOn(MgmtTargetTagRestApi.class).getTargetTag(targetTag.getId())).withSelfRel().expand()); + response.add(linkTo(methodOn(MgmtTargetTagRestApi.class).getTargetTag(targetTag.getId())).withSelfRel().expand()); return response; } @@ -70,7 +69,6 @@ final class MgmtTagMapper { MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET_VALUE, MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE, null, null)).withRel("assignedTargets") .expand()); - } static List toResponseDistributionSetTag(final List distributionSetTags) { @@ -109,8 +107,7 @@ final class MgmtTagMapper { .withRel("assignedDistributionSets").expand()); } - static List mapTagFromRequest(final EntityFactory entityFactory, - final Collection tags) { + static List mapTagFromRequest(final EntityFactory entityFactory, final Collection tags) { return tags.stream() .map(tagRest -> entityFactory.tag().create().name(tagRest.getName()) .description(tagRest.getDescription()).colour(tagRest.getColour())) @@ -122,4 +119,4 @@ final class MgmtTagMapper { response.setTagId(tag.getId()); response.setColour(tag.getColour()); } -} +} \ No newline at end of file diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetFilterQueryMapper.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetFilterQueryMapper.java index 269f1949d..65632d55c 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetFilterQueryMapper.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetFilterQueryMapper.java @@ -16,6 +16,8 @@ import java.util.Collections; import java.util.List; import java.util.stream.Collectors; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; import org.eclipse.hawkbit.mgmt.json.model.targetfilter.MgmtDistributionSetAutoAssignment; import org.eclipse.hawkbit.mgmt.json.model.targetfilter.MgmtTargetFilterQuery; import org.eclipse.hawkbit.mgmt.json.model.targetfilter.MgmtTargetFilterQueryRequestBody; @@ -31,15 +33,11 @@ import org.eclipse.hawkbit.repository.model.TargetFilterQuery; import org.springframework.util.CollectionUtils; /** - * A mapper which maps repository model to RESTful model representation and - * back. + * A mapper which maps repository model to RESTful model representation and back. */ +@NoArgsConstructor(access = AccessLevel.PRIVATE) public final class MgmtTargetFilterQueryMapper { - private MgmtTargetFilterQueryMapper() { - // Utility class - } - static List toResponse(final List filters, final boolean confirmationFlowEnabled, final boolean isRepresentationFull) { if (CollectionUtils.isEmpty(filters)) { @@ -49,7 +47,7 @@ public final class MgmtTargetFilterQueryMapper { } static MgmtTargetFilterQuery toResponse(final TargetFilterQuery filter, final boolean confirmationFlowEnabled, - final boolean isReprentationFull) { + final boolean isRepresentationFull) { final MgmtTargetFilterQuery targetRest = new MgmtTargetFilterQuery(); targetRest.setFilterId(filter.getId()); targetRest.setName(filter.getName()); @@ -73,7 +71,7 @@ public final class MgmtTargetFilterQueryMapper { targetRest.add( linkTo(methodOn(MgmtTargetFilterQueryRestApi.class).getFilter(filter.getId())).withSelfRel().expand()); - if (isReprentationFull && distributionSet != null) { + if (isRepresentationFull && distributionSet != null) { targetRest.add( linkTo(methodOn(MgmtDistributionSetRestApi.class).getDistributionSets( Integer.parseInt(MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET), @@ -89,9 +87,7 @@ public final class MgmtTargetFilterQueryMapper { .postAssignedDistributionSet(targetRest.getFilterId(), null)).withRel("autoAssignDS").expand()); } - static TargetFilterQueryCreate fromRequest(final EntityFactory entityFactory, - final MgmtTargetFilterQueryRequestBody filterRest) { - + static TargetFilterQueryCreate fromRequest(final EntityFactory entityFactory, final MgmtTargetFilterQueryRequestBody filterRest) { return entityFactory.targetFilterQuery().create().name(filterRest.getName()).query(filterRest.getQuery()); } @@ -102,5 +98,4 @@ public final class MgmtTargetFilterQueryMapper { return entityFactory.targetFilterQuery().updateAutoAssign(filterId).ds(assignRest.getId()).actionType(type) .weight(assignRest.getWeight()); } - -} +} \ No newline at end of file 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 23672d425..fb089595a 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 @@ -50,9 +50,7 @@ import org.springframework.web.bind.annotation.RestController; public class MgmtTargetFilterQueryResource implements MgmtTargetFilterQueryRestApi { private final TargetFilterQueryManagement filterManagement; - private final EntityFactory entityFactory; - private final TenantConfigHelper tenantConfigHelper; MgmtTargetFilterQueryResource(final TargetFilterQueryManagement filterManagement, final EntityFactory entityFactory, @@ -81,14 +79,13 @@ public class MgmtTargetFilterQueryResource implements MgmtTargetFilterQueryRestA @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_REPRESENTATION_MODE, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_REPRESENTATION_MODE_DEFAULT) String representationModeParam) { - final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam); final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam); final Sort sorting = PagingUtility.sanitizeTargetFilterQuerySortParam(sortParam); final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting); final Slice findTargetFiltersAll; - final Long countTargetsAll; + final long countTargetsAll; if (rsqlParam != null) { final Page findFilterPage = filterManagement.findByRsql(pageable, rsqlParam); countTargetsAll = findFilterPage.getTotalElements(); @@ -142,8 +139,7 @@ public class MgmtTargetFilterQueryResource implements MgmtTargetFilterQueryRestA } @Override - public ResponseEntity getAssignedDistributionSet( - @PathVariable("filterId") final Long filterId) { + public ResponseEntity getAssignedDistributionSet(@PathVariable("filterId") final Long filterId) { final TargetFilterQuery filter = findFilterWithExceptionIfNotFound(filterId); final DistributionSet autoAssignDistributionSet = filter.getAutoAssignDistributionSet(); @@ -197,5 +193,4 @@ public class MgmtTargetFilterQueryResource implements MgmtTargetFilterQueryRestA return filterManagement.get(filterId) .orElseThrow(() -> new EntityNotFoundException(TargetFilterQuery.class, filterId)); } - -} +} \ No newline at end of file diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetMapper.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetMapper.java index 9a140e2c1..c50e42bf7 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetMapper.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetMapper.java @@ -21,6 +21,8 @@ import java.util.List; import java.util.function.Function; import java.util.stream.Collectors; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; import org.eclipse.hawkbit.mgmt.json.model.MgmtMaintenanceWindow; import org.eclipse.hawkbit.mgmt.json.model.MgmtMetadata; import org.eclipse.hawkbit.mgmt.json.model.MgmtPollStatus; @@ -57,15 +59,11 @@ import org.springframework.data.domain.PageRequest; import org.springframework.util.ObjectUtils; /** - * A mapper which maps repository model to RESTful model representation and - * back. + * A mapper which maps repository model to RESTful model representation and back. */ +@NoArgsConstructor(access = AccessLevel.PRIVATE) public final class MgmtTargetMapper { - private MgmtTargetMapper() { - // Utility class - } - /** * Add links to a target response. * @@ -243,9 +241,7 @@ public final class MgmtTargetMapper { result.setDetailStatus(action.getStatus().toString().toLowerCase()); - action.getLastActionStatusCode().ifPresent(statusCode -> { - result.setLastStatusCode(statusCode); - }); + action.getLastActionStatusCode().ifPresent(result::setLastStatusCode); final Rollout rollout = action.getRollout(); if (rollout != null) { @@ -270,8 +266,7 @@ public final class MgmtTargetMapper { MgmtRestModelMapper.mapBaseToBase(result, action); - result.add( - linkTo(methodOn(MgmtTargetRestApi.class).getAction(targetId, action.getId())).withSelfRel().expand()); + result.add(linkTo(methodOn(MgmtTargetRestApi.class).getAction(targetId, action.getId())).withSelfRel().expand()); return result; } @@ -365,4 +360,4 @@ public final class MgmtTargetMapper { return result; } -} +} \ No newline at end of file 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 f7ce5c3a7..fb4b3e2a6 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 @@ -79,13 +79,9 @@ public class MgmtTargetResource implements MgmtTargetRestApi { private static final String ACTION_TARGET_MISSING_ASSIGN_WARN = "given action ({}) is not assigned to given target ({})."; private final TargetManagement targetManagement; - private final ConfirmationManagement confirmationManagement; - private final DeploymentManagement deploymentManagement; - private final EntityFactory entityFactory; - private final TenantConfigHelper tenantConfigHelper; MgmtTargetResource(final TargetManagement targetManagement, final DeploymentManagement deploymentManagement, @@ -115,7 +111,6 @@ public class MgmtTargetResource implements MgmtTargetRestApi { @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam) { - final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam); final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam); final Sort sorting = PagingUtility.sanitizeTargetSortParam(sortParam); @@ -146,9 +141,9 @@ public class MgmtTargetResource implements MgmtTargetRestApi { } @Override - public ResponseEntity updateTarget(@PathVariable("targetId") final String targetId, + public ResponseEntity updateTarget( + @PathVariable("targetId") final String targetId, @RequestBody final MgmtTargetRequestBody targetRest) { - if (targetRest.getRequestAttributes() != null) { if (targetRest.getRequestAttributes()) { targetManagement.requestControllerAttributes(targetId); @@ -157,8 +152,7 @@ public class MgmtTargetResource implements MgmtTargetRestApi { } } - Target updateTarget; - + final Target updateTarget; if (targetRest.getTargetType() != null && targetRest.getTargetType() == -1L) { // if targetType in request is -1 - unassign targetType from target this.targetManagement.unassignType(targetId); @@ -216,7 +210,8 @@ public class MgmtTargetResource implements MgmtTargetRestApi { } @Override - public ResponseEntity> getActionHistory(@PathVariable("targetId") final String targetId, + public ResponseEntity> getActionHistory( + @PathVariable("targetId") final String targetId, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, @@ -230,7 +225,7 @@ public class MgmtTargetResource implements MgmtTargetRestApi { final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting); final Slice activeActions; - final Long totalActionCount; + final long totalActionCount; if (rsqlParam != null) { activeActions = this.deploymentManagement.findActionsByTarget(rsqlParam, targetId, pageable); totalActionCount = this.deploymentManagement.countActionsByTarget(rsqlParam, targetId); @@ -239,14 +234,13 @@ public class MgmtTargetResource implements MgmtTargetRestApi { totalActionCount = this.deploymentManagement.countActionsByTarget(targetId); } - return ResponseEntity.ok( - new PagedList<>(MgmtTargetMapper.toResponse(targetId, activeActions.getContent()), totalActionCount)); + return ResponseEntity.ok(new PagedList<>(MgmtTargetMapper.toResponse(targetId, activeActions.getContent()), totalActionCount)); } @Override - public ResponseEntity getAction(@PathVariable("targetId") final String targetId, + public ResponseEntity getAction( + @PathVariable("targetId") final String targetId, @PathVariable("actionId") final Long actionId) { - final Action action = deploymentManagement.findAction(actionId) .orElseThrow(() -> new EntityNotFoundException(Action.class, actionId)); if (!action.getTarget().getControllerId().equals(targetId)) { @@ -258,7 +252,8 @@ public class MgmtTargetResource implements MgmtTargetRestApi { } @Override - public ResponseEntity cancelAction(@PathVariable("targetId") final String targetId, + public ResponseEntity cancelAction( + @PathVariable("targetId") final String targetId, @PathVariable("actionId") final Long actionId, @RequestParam(value = "force", required = false, defaultValue = "false") final boolean force) { final Action action = deploymentManagement.findAction(actionId) @@ -281,7 +276,8 @@ public class MgmtTargetResource implements MgmtTargetRestApi { } @Override - public ResponseEntity updateAction(@PathVariable("targetId") final String targetId, + public ResponseEntity updateAction( + @PathVariable("targetId") final String targetId, @PathVariable("actionId") final Long actionId, @RequestBody final MgmtActionRequestBodyPut actionUpdate) { Action action = deploymentManagement.findAction(actionId) @@ -327,12 +323,10 @@ public class MgmtTargetResource implements MgmtTargetRestApi { return ResponseEntity.ok(new PagedList<>( MgmtTargetMapper.toActionStatusRestResponse(statusList.getContent(), deploymentManagement), statusList.getTotalElements())); - } @Override - public ResponseEntity getAssignedDistributionSet( - @PathVariable("targetId") final String targetId) { + public ResponseEntity getAssignedDistributionSet(@PathVariable("targetId") final String targetId) { final MgmtDistributionSet distributionSetRest = deploymentManagement.getAssignedDistributionSet(targetId) .map(ds -> { final MgmtDistributionSet response = MgmtDistributionSetMapper.toResponse(ds); @@ -375,8 +369,7 @@ public class MgmtTargetResource implements MgmtTargetRestApi { } @Override - public ResponseEntity getInstalledDistributionSet( - @PathVariable("targetId") final String targetId) { + public ResponseEntity getInstalledDistributionSet(@PathVariable("targetId") final String targetId) { final MgmtDistributionSet distributionSetRest = deploymentManagement.getInstalledDistributionSet(targetId) .map(set -> { final MgmtDistributionSet response = MgmtDistributionSetMapper.toResponse(set); @@ -395,17 +388,16 @@ public class MgmtTargetResource implements MgmtTargetRestApi { @Override public ResponseEntity> getTags(@PathVariable("targetId") String targetId) { final Set tags = targetManagement.getTagsByControllerId(targetId); - return ResponseEntity.ok( - MgmtTagMapper.toResponse(tags == null ? Collections.emptyList() : tags.stream().toList())); + return ResponseEntity.ok(MgmtTagMapper.toResponse(tags == null ? Collections.emptyList() : tags.stream().toList())); } @Override - public ResponseEntity> getMetadata(@PathVariable("targetId") final String targetId, + public ResponseEntity> getMetadata( + @PathVariable("targetId") final String targetId, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam) { - final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam); final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam); final Sort sorting = PagingUtility.sanitizeDistributionSetMetadataSortParam(sortParam); @@ -424,7 +416,8 @@ public class MgmtTargetResource implements MgmtTargetRestApi { } @Override - public ResponseEntity getMetadataValue(@PathVariable("targetId") final String targetId, + public ResponseEntity getMetadataValue( + @PathVariable("targetId") final String targetId, @PathVariable("metadataKey") final String metadataKey) { final TargetMetadata findOne = targetManagement.getMetaDataByControllerId(targetId, metadataKey) .orElseThrow(() -> new EntityNotFoundException(TargetMetadata.class, targetId, metadataKey)); @@ -432,7 +425,8 @@ public class MgmtTargetResource implements MgmtTargetRestApi { } @Override - public ResponseEntity updateMetadata(@PathVariable("targetId") final String targetId, + public ResponseEntity updateMetadata( + @PathVariable("targetId") final String targetId, @PathVariable("metadataKey") final String metadataKey, @RequestBody final MgmtMetadataBodyPut metadata) { final TargetMetadata updated = targetManagement.updateMetadata(targetId, entityFactory.generateTargetMetadata(metadataKey, metadata.getValue())); @@ -440,14 +434,16 @@ public class MgmtTargetResource implements MgmtTargetRestApi { } @Override - public ResponseEntity deleteMetadata(@PathVariable("targetId") final String targetId, + public ResponseEntity deleteMetadata( + @PathVariable("targetId") final String targetId, @PathVariable("metadataKey") final String metadataKey) { targetManagement.deleteMetaData(targetId, metadataKey); return ResponseEntity.ok().build(); } @Override - public ResponseEntity> createMetadata(@PathVariable("targetId") final String targetId, + public ResponseEntity> createMetadata( + @PathVariable("targetId") final String targetId, @RequestBody final List metadataRest) { final List created = targetManagement.createMetaData(targetId, MgmtTargetMapper.fromRequestTargetMetadata(metadataRest, entityFactory)); @@ -462,7 +458,8 @@ public class MgmtTargetResource implements MgmtTargetRestApi { } @Override - public ResponseEntity activateAutoConfirm(@PathVariable("targetId") final String targetId, + public ResponseEntity activateAutoConfirm( + @PathVariable("targetId") final String targetId, @RequestBody(required = false) final MgmtTargetAutoConfirmUpdate update) { final String initiator = getNullIfEmpty(update, MgmtTargetAutoConfirmUpdate::getInitiator); final String remark = getNullIfEmpty(update, MgmtTargetAutoConfirmUpdate::getRemark); @@ -484,5 +481,4 @@ public class MgmtTargetResource implements MgmtTargetRestApi { private R getNullIfEmpty(final T object, final Function extractMethod) { return object == null ? null : extractMethod.apply(object); } - -} +} \ No newline at end of file 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 ffe641cf9..2ba31bbcd 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 @@ -53,14 +53,12 @@ import org.springframework.web.bind.annotation.RestController; public class MgmtTargetTagResource implements MgmtTargetTagRestApi { private final TargetTagManagement tagManagement; - private final TargetManagement targetManagement; - private final EntityFactory entityFactory; - private final TenantConfigHelper tenantConfigHelper; - MgmtTargetTagResource(final TargetTagManagement tagManagement, final TargetManagement targetManagement, + MgmtTargetTagResource( + final TargetTagManagement tagManagement, final TargetManagement targetManagement, final EntityFactory entityFactory, final SystemSecurityContext securityContext, final TenantConfigurationManagement configurationManagement) { this.tagManagement = tagManagement; @@ -75,19 +73,16 @@ public class MgmtTargetTagResource implements MgmtTargetTagRestApi { @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam) { - final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam); final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam); final Sort sorting = PagingUtility.sanitizeTagSortParam(sortParam); final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting); - Page findTargetsAll; + final Page findTargetsAll; if (rsqlParam == null) { findTargetsAll = this.tagManagement.findAll(pageable); - } else { findTargetsAll = this.tagManagement.findByRsql(pageable, rsqlParam); - } final List rest = MgmtTagMapper.toResponse(findTargetsAll.getContent()); @@ -107,13 +102,13 @@ public class MgmtTargetTagResource implements MgmtTargetTagRestApi { @Override public ResponseEntity> createTargetTags(@RequestBody final List tags) { log.debug("creating {} target tags", tags.size()); - final List createdTargetTags = this.tagManagement - .create(MgmtTagMapper.mapTagFromRequest(entityFactory, tags)); + final List createdTargetTags = this.tagManagement.create(MgmtTagMapper.mapTagFromRequest(entityFactory, tags)); return new ResponseEntity<>(MgmtTagMapper.toResponse(createdTargetTags), HttpStatus.CREATED); } @Override - public ResponseEntity updateTargetTag(@PathVariable("targetTagId") final Long targetTagId, + public ResponseEntity updateTargetTag( + @PathVariable("targetTagId") final Long targetTagId, @RequestBody final MgmtTagRequestBodyPut restTargetTagRest) { log.debug("update {} target tag", restTargetTagRest); @@ -145,7 +140,6 @@ public class MgmtTargetTagResource implements MgmtTargetTagRestApi { @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam) { - final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam); final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam); final Sort sorting = PagingUtility.sanitizeTargetSortParam(sortParam); @@ -170,8 +164,8 @@ public class MgmtTargetTagResource implements MgmtTargetTagRestApi { } @Override - public ResponseEntity assignTargets(final Long targetTagId, final OnNotFoundPolicy onNotFoundPolicy, - final List controllerIds) { + public ResponseEntity assignTargets( + final Long targetTagId, final OnNotFoundPolicy onNotFoundPolicy, final List controllerIds) { log.debug("Assign {} targets for target tag {}", controllerIds.size(), targetTagId); if (onNotFoundPolicy == OnNotFoundPolicy.FAIL) { this.targetManagement.assignTag(controllerIds, targetTagId); @@ -189,8 +183,7 @@ public class MgmtTargetTagResource implements MgmtTargetTagRestApi { } @Override - public ResponseEntity unassignTarget(final Long targetTagId, - @PathVariable("controllerId") final String controllerId) { + public ResponseEntity unassignTarget(final Long targetTagId, @PathVariable("controllerId") final String controllerId) { log.debug("Unassign target {} for target tag {}", controllerId, targetTagId); this.targetManagement.unassignTag(controllerId, targetTagId); return ResponseEntity.ok().build(); @@ -234,7 +227,8 @@ public class MgmtTargetTagResource implements MgmtTargetTagRestApi { } @Override - public ResponseEntity> assignTargetsByRequestBody(@PathVariable("targetTagId") final Long targetTagId, + public ResponseEntity> assignTargetsByRequestBody( + @PathVariable("targetTagId") final Long targetTagId, @RequestBody final List assignedTargetRequestBodies) { log.debug("Assign targets {} for target tag {}", assignedTargetRequestBodies, targetTagId); final List assignedTarget = this.targetManagement diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTypeMapper.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTypeMapper.java index 5bed68e3a..57016b9e6 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTypeMapper.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTypeMapper.java @@ -18,6 +18,8 @@ import java.util.List; import java.util.Optional; import java.util.stream.Collectors; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionSetTypeAssignment; import org.eclipse.hawkbit.mgmt.json.model.targettype.MgmtTargetType; import org.eclipse.hawkbit.mgmt.json.model.targettype.MgmtTargetTypeRequestBodyPost; @@ -31,18 +33,16 @@ import org.eclipse.hawkbit.rest.json.model.ResponseList; /** * A mapper which maps repository model to RESTful model representation and back. */ +@NoArgsConstructor(access = AccessLevel.PRIVATE) public final class MgmtTargetTypeMapper { - // private constructor, utility class - private MgmtTargetTypeMapper() { - } - - static List targetFromRequest(final EntityFactory entityFactory, - final Collection targetTypesRest) { + static List targetFromRequest( + final EntityFactory entityFactory, final Collection targetTypesRest) { if (targetTypesRest == null) { return Collections.emptyList(); } - return targetTypesRest.stream().map(targetRest -> fromRequest(entityFactory, targetRest)) + return targetTypesRest.stream() + .map(targetRest -> fromRequest(entityFactory, targetRest)) .collect(Collectors.toList()); } 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 5de5ff44d..5a9c56c8c 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 @@ -59,7 +59,6 @@ public class MgmtTargetTypeResource implements MgmtTargetTypeRestApi { @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam) { - final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam); final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam); final Sort sorting = PagingUtility.sanitizeTargetTypeSortParam(sortParam); @@ -95,9 +94,9 @@ public class MgmtTargetTypeResource implements MgmtTargetTypeRestApi { } @Override - public ResponseEntity updateTargetType(@PathVariable("targetTypeId") final Long targetTypeId, + public ResponseEntity updateTargetType( + @PathVariable("targetTypeId") final Long targetTypeId, @RequestBody final MgmtTargetTypeRequestBodyPut restTargetType) { - final TargetType updated = targetTypeManagement .update(entityFactory.targetType().update(targetTypeId).name(restTargetType.getName()) .description(restTargetType.getDescription()).colour(restTargetType.getColour())); @@ -107,8 +106,7 @@ public class MgmtTargetTypeResource implements MgmtTargetTypeRestApi { } @Override - public ResponseEntity> createTargetTypes( - @RequestBody final List targetTypes) { + public ResponseEntity> createTargetTypes(@RequestBody final List targetTypes) { final List createdTargetTypes = targetTypeManagement .create(MgmtTargetTypeMapper.targetFromRequest(entityFactory, targetTypes)); @@ -118,26 +116,24 @@ public class MgmtTargetTypeResource implements MgmtTargetTypeRestApi { @Override public ResponseEntity> getCompatibleDistributionSets( @PathVariable("targetTypeId") final Long targetTypeId) { - final TargetType foundType = findTargetTypeWithExceptionIfNotFound(targetTypeId); - return ResponseEntity - .ok(MgmtDistributionSetTypeMapper.toListResponse(foundType.getCompatibleDistributionSetTypes())); + return ResponseEntity.ok(MgmtDistributionSetTypeMapper.toListResponse(foundType.getCompatibleDistributionSetTypes())); } @Override - public ResponseEntity removeCompatibleDistributionSet(@PathVariable("targetTypeId") final Long targetTypeId, + public ResponseEntity removeCompatibleDistributionSet( + @PathVariable("targetTypeId") final Long targetTypeId, @PathVariable("distributionSetTypeId") final Long distributionSetTypeId) { - targetTypeManagement.unassignDistributionSetType(targetTypeId, distributionSetTypeId); return ResponseEntity.ok().build(); } @Override - public ResponseEntity addCompatibleDistributionSets(@PathVariable("targetTypeId") final Long targetTypeId, + public ResponseEntity addCompatibleDistributionSets( + @PathVariable("targetTypeId") final Long targetTypeId, @RequestBody final List distributionSetTypeIds) { - - targetTypeManagement.assignCompatibleDistributionSetTypes(targetTypeId, distributionSetTypeIds.stream() - .map(MgmtDistributionSetTypeAssignment::getId).collect(Collectors.toList())); + targetTypeManagement.assignCompatibleDistributionSetTypes( + targetTypeId, distributionSetTypeIds.stream().map(MgmtDistributionSetTypeAssignment::getId).collect(Collectors.toList())); return ResponseEntity.ok().build(); } @@ -145,5 +141,4 @@ public class MgmtTargetTypeResource implements MgmtTargetTypeRestApi { return targetTypeManagement.get(targetTypeId) .orElseThrow(() -> new EntityNotFoundException(TargetType.class, targetTypeId)); } - -} +} \ No newline at end of file diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTenantManagementMapper.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTenantManagementMapper.java index c04a5bf75..f44b88c33 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTenantManagementMapper.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTenantManagementMapper.java @@ -12,22 +12,21 @@ package org.eclipse.hawkbit.mgmt.rest.resource; import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo; import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; import org.eclipse.hawkbit.mgmt.json.model.system.MgmtSystemTenantConfigurationValue; import org.eclipse.hawkbit.repository.model.TenantConfigurationValue; /** - * A mapper which maps repository model to RESTful model representation and - * back. + * A mapper which maps repository model to RESTful model representation and back. */ +@NoArgsConstructor(access = AccessLevel.PRIVATE) public final class MgmtTenantManagementMapper { public static String DEFAULT_DISTRIBUTION_SET_TYPE_KEY = "default.ds.type"; - private MgmtTenantManagementMapper() { - // Utility class - } - - public static MgmtSystemTenantConfigurationValue toResponseTenantConfigurationValue(String key, TenantConfigurationValue repoConfValue) { + public static MgmtSystemTenantConfigurationValue toResponseTenantConfigurationValue( + final String key, final TenantConfigurationValue repoConfValue) { final MgmtSystemTenantConfigurationValue restConfValue = new MgmtSystemTenantConfigurationValue(); restConfValue.setValue(repoConfValue.getValue()); restConfValue.setGlobal(repoConfValue.isGlobal()); @@ -35,12 +34,11 @@ public final class MgmtTenantManagementMapper { restConfValue.setCreatedBy(repoConfValue.getCreatedBy()); restConfValue.setLastModifiedAt(repoConfValue.getLastModifiedAt()); restConfValue.setLastModifiedBy(repoConfValue.getLastModifiedBy()); - restConfValue.add(linkTo(methodOn(MgmtTenantManagementResource.class).getTenantConfigurationValue(key)) - .withSelfRel().expand()); + restConfValue.add(linkTo(methodOn(MgmtTenantManagementResource.class).getTenantConfigurationValue(key)).withSelfRel().expand()); return restConfValue; } - public static MgmtSystemTenantConfigurationValue toResponseDefaultDsType(Long defaultDistributionSetType) { + public static MgmtSystemTenantConfigurationValue toResponseDefaultDsType(final Long defaultDistributionSetType) { final MgmtSystemTenantConfigurationValue restConfValue = new MgmtSystemTenantConfigurationValue(); restConfValue.setValue(defaultDistributionSetType); restConfValue.setGlobal(Boolean.FALSE); diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTenantManagementResource.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTenantManagementResource.java index db81ffd8e..12fd2f227 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTenantManagementResource.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTenantManagementResource.java @@ -22,9 +22,9 @@ import org.eclipse.hawkbit.mgmt.rest.api.MgmtTenantManagementRestApi; import org.eclipse.hawkbit.repository.SystemManagement; import org.eclipse.hawkbit.repository.TenantConfigurationManagement; import org.eclipse.hawkbit.repository.exception.InsufficientPermissionException; +import org.eclipse.hawkbit.repository.exception.TenantConfigurationValidatorException; import org.eclipse.hawkbit.repository.model.TenantConfigurationValue; import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties; -import org.eclipse.hawkbit.repository.exception.TenantConfigurationValidatorException; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PathVariable; @@ -42,7 +42,8 @@ public class MgmtTenantManagementResource implements MgmtTenantManagementRestApi private final TenantConfigurationProperties tenantConfigurationProperties; private final SystemManagement systemManagement; - MgmtTenantManagementResource(final TenantConfigurationManagement tenantConfigurationManagement, + MgmtTenantManagementResource( + final TenantConfigurationManagement tenantConfigurationManagement, final TenantConfigurationProperties tenantConfigurationProperties, final SystemManagement systemManagement) { this.tenantConfigurationManagement = tenantConfigurationManagement; @@ -74,7 +75,6 @@ public class MgmtTenantManagementResource implements MgmtTenantManagementRestApi @Override public ResponseEntity deleteTenantConfigurationValue(@PathVariable("keyName") final String keyName) { - //Default DistributionSet Type cannot be deleted as is part of TenantMetadata if (isDefaultDistributionSetTypeKey(keyName)) { return ResponseEntity.badRequest().build(); @@ -111,17 +111,16 @@ public class MgmtTenantManagementResource implements MgmtTenantManagementRestApi @Override public ResponseEntity> updateTenantConfiguration( - Map configurationValueMap) { - - boolean containsNull = configurationValueMap.keySet().stream() - .anyMatch(Objects::isNull); + final Map configurationValueMap) { + final boolean containsNull = configurationValueMap.keySet().stream().anyMatch(Objects::isNull); if (containsNull) { return ResponseEntity.badRequest().build(); } //Try update TenantMetadata first - Serializable defaultDsTypeValueUpdate = configurationValueMap.remove(MgmtTenantManagementMapper.DEFAULT_DISTRIBUTION_SET_TYPE_KEY); + final Serializable defaultDsTypeValueUpdate = configurationValueMap.remove( + MgmtTenantManagementMapper.DEFAULT_DISTRIBUTION_SET_TYPE_KEY); Long oldDefaultDsType = null; MgmtSystemTenantConfigurationValue updatedDefaultDsType = null; if (defaultDsTypeValueUpdate != null) { @@ -129,7 +128,7 @@ public class MgmtTenantManagementResource implements MgmtTenantManagementRestApi updatedDefaultDsType = updateDefaultDsType(defaultDsTypeValueUpdate); } //try update TenantConfiguration, in case of Error -> rollback TenantMetadata - Map> tenantConfigurationValues; + final Map> tenantConfigurationValues; try { tenantConfigurationValues = tenantConfigurationManagement.addOrUpdateConfiguration(configurationValueMap); } catch (Exception ex) { @@ -140,7 +139,7 @@ public class MgmtTenantManagementResource implements MgmtTenantManagementRestApi throw ex; } - List tenantConfigurationListUpdated = new java.util.ArrayList<>( + final List tenantConfigurationListUpdated = new java.util.ArrayList<>( tenantConfigurationValues.entrySet().stream() .map(entry -> MgmtTenantManagementMapper.toResponseTenantConfigurationValue(entry.getKey(), entry.getValue())) .toList()); @@ -156,9 +155,8 @@ public class MgmtTenantManagementResource implements MgmtTenantManagementRestApi } private MgmtSystemTenantConfigurationValue loadTenantConfigurationValueBy(String keyName) { - //Check if requested key is TenantConfiguration or TenantMetadata, load it and return it as rest response - MgmtSystemTenantConfigurationValue response; + final MgmtSystemTenantConfigurationValue response; if (isDefaultDistributionSetTypeKey(keyName)) { response = MgmtTenantManagementMapper.toResponseDefaultDsType(systemManagement.getTenantMetadata().getDefaultDsType().getId()); } else { @@ -169,7 +167,7 @@ public class MgmtTenantManagementResource implements MgmtTenantManagementRestApi } private MgmtSystemTenantConfigurationValue updateDefaultDsType(Serializable defaultDsType) { - long updateDefaultDsType; + final long updateDefaultDsType; try { updateDefaultDsType = ((Number) defaultDsType).longValue(); } catch (ClassCastException cce) { @@ -179,5 +177,4 @@ public class MgmtTenantManagementResource implements MgmtTenantManagementRestApi systemManagement.updateTenantMetadata(updateDefaultDsType); return MgmtTenantManagementMapper.toResponseDefaultDsType(updateDefaultDsType); } - -} +} \ No newline at end of file diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/util/PagingUtility.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/util/PagingUtility.java index 702c33d6f..6cf237773 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/util/PagingUtility.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/util/PagingUtility.java @@ -9,6 +9,8 @@ */ package org.eclipse.hawkbit.mgmt.rest.resource.util; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; import org.eclipse.hawkbit.repository.ActionFields; import org.eclipse.hawkbit.repository.ActionStatusFields; @@ -30,14 +32,9 @@ import org.springframework.data.domain.Sort.Direction; /** * Utility class for for paged body generation. */ +@NoArgsConstructor(access = AccessLevel.PRIVATE) public final class PagingUtility { - /* - * utility constructor private. - */ - private PagingUtility() { - } - public static int sanitizeOffsetParam(final int offset) { if (offset < 0) { return MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET_VALUE; @@ -167,4 +164,4 @@ public final class PagingUtility { } return Sort.by(SortUtility.parse(RolloutGroupFields.class, sortParam)); } -} +} \ No newline at end of file diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/AbstractManagementApiIntegrationTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/AbstractManagementApiIntegrationTest.java index 35d19e702..c7c468616 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/AbstractManagementApiIntegrationTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/AbstractManagementApiIntegrationTest.java @@ -25,7 +25,6 @@ import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.test.TestConfiguration; import org.eclipse.hawkbit.rest.AbstractRestIntegrationTest; import org.eclipse.hawkbit.rest.RestConfiguration; -import org.json.JSONException; import org.json.JSONObject; import org.springframework.cloud.stream.binder.test.TestChannelBinderConfiguration; import org.springframework.context.annotation.Import; @@ -33,14 +32,13 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; import org.springframework.test.web.servlet.ResultMatcher; -@ContextConfiguration(classes = { MgmtApiConfiguration.class, RestConfiguration.class, - RepositoryApplicationConfiguration.class, TestConfiguration.class }) +@ContextConfiguration( + classes = { MgmtApiConfiguration.class, RestConfiguration.class, RepositoryApplicationConfiguration.class, TestConfiguration.class }) @Import(TestChannelBinderConfiguration.class) @TestPropertySource(locations = "classpath:/mgmt-test.properties") public abstract class AbstractManagementApiIntegrationTest extends AbstractRestIntegrationTest { - protected static ResultMatcher applyBaseEntityMatcherOnArrayResult(final BaseEntity entity, - final String arrayElement) throws Exception { + protected static ResultMatcher applyBaseEntityMatcherOnArrayResult(final BaseEntity entity, final String arrayElement) { return mvcResult -> { jsonPath("$." + arrayElement + ".[?(@.id==" + entity.getId() + ")].createdBy", contains(entity.getCreatedBy())).match(mvcResult); @@ -53,8 +51,7 @@ public abstract class AbstractManagementApiIntegrationTest extends AbstractRestI }; } - protected static ResultMatcher applyTargetEntityMatcherOnArrayResult(final Target entity, final String arrayElement) - throws Exception { + protected static ResultMatcher applyTargetEntityMatcherOnArrayResult(final Target entity, final String arrayElement) { return mvcResult -> { jsonPath("$." + arrayElement + ".[?(@.controllerId=='" + entity.getControllerId() + "')].createdBy", contains(entity.getCreatedBy())).match(mvcResult); @@ -67,57 +64,46 @@ public abstract class AbstractManagementApiIntegrationTest extends AbstractRestI }; } - protected static ResultMatcher applyBaseEntityMatcherOnPagedResult(final BaseEntity entity) throws Exception { + protected static ResultMatcher applyBaseEntityMatcherOnPagedResult(final BaseEntity entity) { return applyBaseEntityMatcherOnArrayResult(entity, "content"); } - protected static ResultMatcher applyNamedEntityMatcherOnPagedResult(final NamedEntity entity) throws Exception { + protected static ResultMatcher applyNamedEntityMatcherOnPagedResult(final NamedEntity entity) { return mvcResult -> { applyBaseEntityMatcherOnPagedResult(entity).match(mvcResult); jsonPath("$.content.[?(@.id==" + entity.getId() + ")].name", contains(entity.getName())).match(mvcResult); - jsonPath("$.content.[?(@.id==" + entity.getId() + ")].description", contains(entity.getDescription())) - .match(mvcResult); + jsonPath("$.content.[?(@.id==" + entity.getId() + ")].description", contains(entity.getDescription())).match(mvcResult); }; - } - protected static ResultMatcher applyNamedVersionedEntityMatcherOnPagedResult(final NamedVersionedEntity entity) - throws Exception { + protected static ResultMatcher applyNamedVersionedEntityMatcherOnPagedResult(final NamedVersionedEntity entity) { return mvcResult -> { applyNamedEntityMatcherOnPagedResult(entity).match(mvcResult); - jsonPath("$.content.[?(@.id==" + entity.getId() + ")].version", contains(entity.getVersion())) - .match(mvcResult); + jsonPath("$.content.[?(@.id==" + entity.getId() + ")].version", contains(entity.getVersion())).match(mvcResult); }; } - protected static ResultMatcher applyTagMatcherOnPagedResult(final Tag entity) throws Exception { + protected static ResultMatcher applyTagMatcherOnPagedResult(final Tag entity) { return mvcResult -> { applyNamedEntityMatcherOnPagedResult(entity).match(mvcResult); - jsonPath("$.content.[?(@.id==" + entity.getId() + ")].colour", contains(entity.getColour())) - .match(mvcResult); + jsonPath("$.content.[?(@.id==" + entity.getId() + ")].colour", contains(entity.getColour())).match(mvcResult); }; } - protected static ResultMatcher applySelfLinkMatcherOnPagedResult(final BaseEntity entity, final String link) - throws Exception { - - return mvcResult -> { - jsonPath("$.content.[?(@.id==" + entity.getId() + ")]._links.self.href", contains(link)).match(mvcResult); - }; + protected static ResultMatcher applySelfLinkMatcherOnPagedResult(final BaseEntity entity, final String link) { + return mvcResult -> jsonPath("$.content.[?(@.id==" + entity.getId() + ")]._links.self.href", contains(link)).match(mvcResult); } - protected static ResultMatcher applyBaseEntityMatcherOnArrayResult(final BaseEntity entity) throws Exception { + protected static ResultMatcher applyBaseEntityMatcherOnArrayResult(final BaseEntity entity) { return mvcResult -> { jsonPath("$.[?(@.id==" + entity.getId() + ")].createdBy", contains(entity.getCreatedBy())).match(mvcResult); jsonPath("$.[?(@.id==" + entity.getId() + ")].createdAt", contains(entity.getCreatedAt())).match(mvcResult); - jsonPath("$.[?(@.id==" + entity.getId() + ")].lastModifiedBy", contains(entity.getLastModifiedBy())) - .match(mvcResult); - jsonPath("$.[?(@.id==" + entity.getId() + ")].lastModifiedAt", contains(entity.getLastModifiedAt())) - .match(mvcResult); + jsonPath("$.[?(@.id==" + entity.getId() + ")].lastModifiedBy", contains(entity.getLastModifiedBy())).match(mvcResult); + jsonPath("$.[?(@.id==" + entity.getId() + ")].lastModifiedAt", contains(entity.getLastModifiedAt())).match(mvcResult); }; } - protected static ResultMatcher applyTargetEntityMatcherOnArrayResult(final Target entity) throws Exception { + protected static ResultMatcher applyTargetEntityMatcherOnArrayResult(final Target entity) { return mvcResult -> { jsonPath("$.[?(@.controllerId=='" + entity.getControllerId() + "')].createdBy", contains(entity.getCreatedBy())).match(mvcResult); @@ -130,18 +116,16 @@ public abstract class AbstractManagementApiIntegrationTest extends AbstractRestI }; } - protected static ResultMatcher applyNamedEntityMatcherOnArrayResult(final NamedEntity entity) throws Exception { + protected static ResultMatcher applyNamedEntityMatcherOnArrayResult(final NamedEntity entity) { return mvcResult -> { applyBaseEntityMatcherOnPagedResult(entity); jsonPath("$.[?(@.id=='" + entity.getId() + "')].name", contains(entity.getName())).match(mvcResult); - jsonPath("$.[?(@.id=='" + entity.getId() + "')].description", contains(entity.getDescription())) - .match(mvcResult); + jsonPath("$.[?(@.id=='" + entity.getId() + "')].description", contains(entity.getDescription())).match(mvcResult); }; } - protected static ResultMatcher applyNamedVersionedEntityMatcherOnArrayResult(final NamedVersionedEntity entity) - throws Exception { + protected static ResultMatcher applyNamedVersionedEntityMatcherOnArrayResult(final NamedVersionedEntity entity) { return mvcResult -> { applyNamedEntityMatcherOnPagedResult(entity); @@ -149,7 +133,7 @@ public abstract class AbstractManagementApiIntegrationTest extends AbstractRestI }; } - protected static ResultMatcher applyTagMatcherOnArrayResult(final Tag entity) throws Exception { + protected static ResultMatcher applyTagMatcherOnArrayResult(final Tag entity) { return mvcResult -> { applyNamedEntityMatcherOnPagedResult(entity); @@ -157,14 +141,11 @@ public abstract class AbstractManagementApiIntegrationTest extends AbstractRestI }; } - protected static ResultMatcher applySelfLinkMatcherOnArrayResult(final BaseEntity entity, final String link) - throws Exception { - return mvcResult -> { - jsonPath("$.[?(@.id=='" + entity.getId() + "')]._links.self.href", contains(link)).match(mvcResult); - }; + protected static ResultMatcher applySelfLinkMatcherOnArrayResult(final BaseEntity entity, final String link) { + return mvcResult -> jsonPath("$.[?(@.id=='" + entity.getId() + "')]._links.self.href", contains(link)).match(mvcResult); } - protected static ResultMatcher applyBaseEntityMatcherOnSingleResult(final BaseEntity entity) throws Exception { + protected static ResultMatcher applyBaseEntityMatcherOnSingleResult(final BaseEntity entity) { return mvcResult -> { jsonPath("createdBy", equalTo(entity.getCreatedBy())).match(mvcResult); jsonPath("createdAt", equalTo(entity.getCreatedAt())).match(mvcResult); @@ -173,7 +154,7 @@ public abstract class AbstractManagementApiIntegrationTest extends AbstractRestI }; } - protected static ResultMatcher applyNamedEntityMatcherOnSingleResult(final NamedEntity entity) throws Exception { + protected static ResultMatcher applyNamedEntityMatcherOnSingleResult(final NamedEntity entity) { return mvcResult -> { applyBaseEntityMatcherOnSingleResult(entity); @@ -182,8 +163,7 @@ public abstract class AbstractManagementApiIntegrationTest extends AbstractRestI }; } - protected static ResultMatcher applyNamedVersionedEntityMatcherOnSingleResult(final NamedVersionedEntity entity) - throws Exception { + protected static ResultMatcher applyNamedVersionedEntityMatcherOnSingleResult(final NamedVersionedEntity entity) { return mvcResult -> { applyNamedEntityMatcherOnSingleResult(entity); @@ -191,7 +171,7 @@ public abstract class AbstractManagementApiIntegrationTest extends AbstractRestI }; } - protected static ResultMatcher applyTagMatcherOnSingleResult(final Tag entity) throws Exception { + protected static ResultMatcher applyTagMatcherOnSingleResult(final Tag entity) { return mvcResult -> { applyNamedEntityMatcherOnSingleResult(entity); @@ -199,34 +179,22 @@ public abstract class AbstractManagementApiIntegrationTest extends AbstractRestI }; } - protected static ResultMatcher applySelfLinkMatcherOnSingleResult(final String link) throws Exception { - return mvcResult -> { - jsonPath("_links.self.href", equalTo(link)).match(mvcResult); - }; + protected static ResultMatcher applySelfLinkMatcherOnSingleResult(final String link) { + return mvcResult -> jsonPath("_links.self.href", equalTo(link)).match(mvcResult); } protected static JSONObject getAssignmentObject(final Object id, final MgmtActionType type) { final JSONObject obj = new JSONObject(); - try { - obj.put("id", id); - obj.put("type", type.getName()); - } catch (final JSONException e) { - e.printStackTrace(); - } + obj.put("id", id); + obj.put("type", type.getName()); return obj; } protected static JSONObject getAssignmentObject(final Object id, final MgmtActionType type, final int weight) { - try { - return getAssignmentObject(id, type).put("weight", weight); - } catch (final JSONException e) { - e.printStackTrace(); - } - return new JSONObject(); + return getAssignmentObject(id, type).put("weight", weight); } - // the set is a candidate for implicitly locking. So, lock it if not already locked - // set lock flag to true to avoid re-locking + // the set is a candidate for implicitly locking. So, lock it if not already locked set lock flag to true to avoid re-locking static void implicitLock(final DistributionSet set) { if (!set.isLocked()) { ((JpaDistributionSet) set).setOptLockRevision(set.getOptLockRevision() + 1); diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtActionResourceTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtActionResourceTest.java index 2b01c16e6..ec9f2369a 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtActionResourceTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtActionResourceTest.java @@ -91,25 +91,32 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { // pending status one result mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlPendingStatus)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()).andExpect(jsonPath("total", equalTo(1))) - .andExpect(jsonPath("size", equalTo(1))).andExpect(jsonPath("content[0].status", equalTo("pending"))); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("total", equalTo(1))) + .andExpect(jsonPath("size", equalTo(1))) + .andExpect(jsonPath("content[0].status", equalTo("pending"))); // finished status none result mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlFinishedStatus)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()).andExpect(jsonPath("total", equalTo(0))) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("total", equalTo(0))) .andExpect(jsonPath("size", equalTo(0))); // pending or finished status one result mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlPendingOrFinishedStatus)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()).andExpect(jsonPath("total", equalTo(1))) - .andExpect(jsonPath("size", equalTo(1))).andExpect(jsonPath("content[0].status", equalTo("pending"))); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("total", equalTo(1))) + .andExpect(jsonPath("size", equalTo(1))) + .andExpect(jsonPath("content[0].status", equalTo("pending"))); } @Test @Description("Verifies that actions can be filtered based on the detailed action status.") void filterActionsByDetailStatus() throws Exception { - // prepare test final DistributionSet dsA = testdataFactory.createDistributionSet(""); assignDistributionSet(dsA, Collections.singletonList(testdataFactory.createTarget("knownTargetId"))); @@ -120,23 +127,28 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { // running status one result mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlPendingStatus)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()).andExpect(jsonPath("total", equalTo(1))) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("total", equalTo(1))) .andExpect(jsonPath("size", equalTo(1))) .andExpect(jsonPath("content[0].detailStatus", equalTo("running"))) .andExpect(jsonPath("content[0].status", equalTo("pending"))); // finished status none result mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlFinishedStatus)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()).andExpect(jsonPath("total", equalTo(0))) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("total", equalTo(0))) .andExpect(jsonPath("size", equalTo(0))); // running or finished status one result mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlPendingOrFinishedStatus)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()).andExpect(jsonPath("total", equalTo(1))) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("total", equalTo(1))) .andExpect(jsonPath("size", equalTo(1))) .andExpect(jsonPath("content[0].detailStatus", equalTo("running"))) .andExpect(jsonPath("content[0].status", equalTo("pending"))); - } @Test @@ -162,7 +174,8 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { // pending status one result mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlExtRef)) .andDo(MockMvcResultPrinter.print()) - .andExpect(status().isOk()).andExpect(jsonPath("total", equalTo(1))) + .andExpect(status().isOk()) + .andExpect(jsonPath("total", equalTo(1))) .andExpect(jsonPath("size", equalTo(1))) .andExpect(jsonPath("content[0].externalRef", equalTo(externalRefs.get(0)))); @@ -184,7 +197,6 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { @Test @Description("Verifies that actions can be filtered based on the action status code that was reported last.") void filterActionsByLastStatusCode() throws Exception { - // assign a distribution set to three targets final DistributionSet dsA = testdataFactory.createDistributionSet(""); final DistributionSetAssignmentResult assignmentResult = assignDistributionSet(dsA, @@ -201,21 +213,25 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { // status code 200 final String rsqlStatusCode = "lastStatusCode==200"; mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlStatusCode)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()).andExpect(jsonPath("total", equalTo(1))) - .andExpect(jsonPath("size", equalTo(1))).andExpect(jsonPath("content[0].status", equalTo("finished"))); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("total", equalTo(1))) + .andExpect(jsonPath("size", equalTo(1))) + .andExpect(jsonPath("content[0].status", equalTo("finished"))); // verify no result is returned if we filter for a non-existing status // code final String rsqlWrongStatusCode = "lastStatusCode==999"; mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlWrongStatusCode)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()).andExpect(jsonPath("total", equalTo(0))) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("total", equalTo(0))) .andExpect(jsonPath("size", equalTo(0))); } @Test @Description("Verifies that actions can be filtered based on distribution set fields.") void filterActionsByDistributionSet() throws Exception { - // prepare test final DistributionSet ds = testdataFactory.createDistributionSet(""); assignDistributionSet(ds, Collections.singletonList(testdataFactory.createTarget("knownTargetId"))); @@ -226,31 +242,41 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlDsName) .param(MgmtRestConstants.REQUEST_PARAMETER_REPRESENTATION_MODE, MgmtRepresentationMode.FULL.toString())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()).andExpect(jsonPath("total", equalTo(1))) - .andExpect(jsonPath("size", equalTo(1))).andExpect(jsonPath("content.[0]._links.distributionset.name", + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("total", equalTo(1))) + .andExpect(jsonPath("size", equalTo(1))) + .andExpect(jsonPath("content.[0]._links.distributionset.name", equalTo(ds.getName() + ":" + ds.getVersion()))); mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlDsVersion)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()).andExpect(jsonPath("total", equalTo(1))) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("total", equalTo(1))) .andExpect(jsonPath("size", equalTo(1))); mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlDsName + "," + rsqlDsVersion)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()).andExpect(jsonPath("total", equalTo(1))) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("total", equalTo(1))) .andExpect(jsonPath("size", equalTo(1))); mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=distributionSet.name==FooBar")) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()).andExpect(jsonPath("total", equalTo(0))) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("total", equalTo(0))) .andExpect(jsonPath("size", equalTo(0))); mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlDsId)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()).andExpect(jsonPath("total", equalTo(1))) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("total", equalTo(1))) .andExpect(jsonPath("size", equalTo(1))); } @Test @Description("Verifies that actions can be filtered based on rollout fields.") void filterActionsByRollout() throws Exception { - // prepare test final DistributionSet ds = testdataFactory.createDistributionSet(); final Target target0 = testdataFactory.createTarget("t0"); @@ -270,23 +296,28 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlRolloutName) .param(MgmtRestConstants.REQUEST_PARAMETER_REPRESENTATION_MODE, MgmtRepresentationMode.FULL.toString())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()).andExpect(jsonPath("total", equalTo(1))) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("total", equalTo(1))) .andExpect(jsonPath("size", equalTo(1))) - .andExpect(jsonPath("content.[0]._links.target.name", equalTo(target1.getName()))).andExpect(jsonPath( + .andExpect(jsonPath("content.[0]._links.target.name", equalTo(target1.getName()))) + .andExpect(jsonPath( "content.[0]._links.distributionset.name", equalTo(ds.getName() + ":" + ds.getVersion()))); mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlRolloutId) .param(MgmtRestConstants.REQUEST_PARAMETER_REPRESENTATION_MODE, MgmtRepresentationMode.FULL.toString())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()).andExpect(jsonPath("total", equalTo(1))) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("total", equalTo(1))) .andExpect(jsonPath("size", equalTo(1))) - .andExpect(jsonPath("content.[0]._links.target.name", equalTo(target1.getName()))).andExpect(jsonPath( + .andExpect(jsonPath("content.[0]._links.target.name", equalTo(target1.getName()))) + .andExpect(jsonPath( "content.[0]._links.distributionset.name", equalTo(ds.getName() + ":" + ds.getVersion()))); } @Test @Description("Verifies that actions can be filtered based on target fields.") void filterActionsByTargetProperties() throws Exception { - // prepare test final Target target = testdataFactory.createTarget("knownTargetId", "knownTargetName", "http://0.0.0.0"); final DistributionSet ds = testdataFactory.createDistributionSet(""); @@ -326,7 +357,8 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING) .param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC") .param(MgmtRestConstants.REQUEST_PARAMETER_REPRESENTATION_MODE, MgmtRepresentationMode.FULL.toString())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) // verify action 1 .andExpect(jsonPath("content.[1].id", equalTo(action1.getId().intValue()))) @@ -359,9 +391,12 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { @Test @Description("Verifies that the get request for actions returns an empty collection if no assignments have been done yet.") void getActionsWithEmptyResult() throws Exception { - mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING)).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isOk()).andExpect(jsonPath("size", equalTo(0))) - .andExpect(jsonPath("content", hasSize(0))).andExpect(jsonPath("total", equalTo(0))); + mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("size", equalTo(0))) + .andExpect(jsonPath("content", hasSize(0))) + .andExpect(jsonPath("total", equalTo(0))); } @Test @@ -374,7 +409,8 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { final Action action0 = actions.get(0); mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING) .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(1)) - .param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC")).andDo(MockMvcResultPrinter.print()) + .param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC")) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) // verify action 0 @@ -396,7 +432,8 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(1)) .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(1)) .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(1)) - .param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC")).andDo(MockMvcResultPrinter.print()) + .param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC")) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) // verify action 1 @@ -422,11 +459,14 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { final Long actionId = actions.get(0).getId(); // not allowed methods - mvc.perform(post(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING)).andDo(MockMvcResultPrinter.print()) + mvc.perform(post(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isMethodNotAllowed()); - mvc.perform(put(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING)).andDo(MockMvcResultPrinter.print()) + mvc.perform(put(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isMethodNotAllowed()); - mvc.perform(delete(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING)).andDo(MockMvcResultPrinter.print()) + mvc.perform(delete(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isMethodNotAllowed()); } @@ -439,20 +479,22 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { final Long actionId = actions.get(0).getId(); mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "/" + actionId)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath(JSON_PATH_ACTION_ID, equalTo(actionId.intValue()))); } @Test @Description("Verifies that NOT_FOUND is returned when there is no such action.") void requestActionThatDoesNotExistsLeadsToNotFound() throws Exception { - mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "/" + 101)).andDo(MockMvcResultPrinter.print()) + mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "/" + 101)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNotFound()); } private static String generateActionLink(final String targetId, final Long actionId) { - return "http://localhost" + MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + targetId + "/" - + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actionId; + return "http://localhost" + MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + targetId + "/" + + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actionId; } private static String generateTargetLink(final String targetId) { @@ -465,14 +507,17 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { } @Step - private void verifyResultsByTargetPropertyFilter(final Target target, final DistributionSet ds, - final String rsqlTargetFilter) throws Exception { + private void verifyResultsByTargetPropertyFilter(final Target target, final DistributionSet ds, final String rsqlTargetFilter) + throws Exception { // pending status one result mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "?q=" + rsqlTargetFilter) .param(MgmtRestConstants.REQUEST_PARAMETER_REPRESENTATION_MODE, MgmtRepresentationMode.FULL.toString())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()).andExpect(jsonPath("total", equalTo(1))) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("total", equalTo(1))) .andExpect(jsonPath("size", equalTo(1))) - .andExpect(jsonPath("content.[0]._links.target.name", equalTo(target.getName()))).andExpect(jsonPath( + .andExpect(jsonPath("content.[0]._links.target.name", equalTo(target.getName()))) + .andExpect(jsonPath( "content.[0]._links.distributionset.name", equalTo(ds.getName() + ":" + ds.getVersion()))); } @@ -492,9 +537,8 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { } final ResultActions resultActions = - mvc.perform( - get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING) - .param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC")) + mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING) + .param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC")) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) // verify action 1 @@ -596,4 +640,4 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { assertThat(actions).hasSize(2); return actions; } -} +} \ No newline at end of file diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtBasicAuthResourceTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtBasicAuthResourceTest.java index 92b898dc8..6bafafe86 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtBasicAuthResourceTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtBasicAuthResourceTest.java @@ -86,7 +86,8 @@ public class MgmtBasicAuthResourceTest { @Description("Test of userinfo api with basic auth validation") @WithUser(principal = TEST_USER) public void validateBasicAuthWithUserDetails() throws Exception { - withSecurityMock().perform(get(MgmtRestConstants.AUTH_V1_REQUEST_MAPPING)).andDo(MockMvcResultPrinter.print()) + withSecurityMock().perform(get(MgmtRestConstants.AUTH_V1_REQUEST_MAPPING)) + .andDo(MockMvcResultPrinter.print()) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(content().contentType(MediaTypes.HAL_JSON_VALUE)) @@ -114,4 +115,4 @@ public class MgmtBasicAuthResourceTest { private DefaultMockMvcBuilder createMvcWebAppContext(final WebApplicationContext context) { return MockMvcBuilders.webAppContextSetup(context); } -} +} \ No newline at end of file diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtContentTypeTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtContentTypeTest.java index f6e0dcb20..a6c43f126 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtContentTypeTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtContentTypeTest.java @@ -16,7 +16,7 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -import java.util.Arrays; +import java.util.Collections; import io.qameta.allure.Description; import io.qameta.allure.Feature; @@ -59,9 +59,13 @@ public class MgmtContentTypeTest extends AbstractManagementApiIntegrationTest { @Description("The response of a POST request shall contain charset=utf-8") public void postDistributionSet_ContentTypeJsonUtf8_woAccept() throws Exception { final MvcResult result = mvc.perform( - post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING).content(JsonBuilder.distributionSets(Arrays.asList(ds))) - .contentType(MediaType.APPLICATION_JSON_UTF8)).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isCreated()).andExpect(jsonPath("[0]name", equalTo(dsName))).andReturn(); + post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING).content(JsonBuilder.distributionSets( + Collections.singletonList(ds))) + .contentType(MediaType.APPLICATION_JSON_UTF8)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isCreated()) + .andExpect(jsonPath("[0]name", equalTo(dsName))) + .andReturn(); assertEquals(MediaTypes.HAL_JSON_VALUE + ";charset=UTF-8", getResponseHeaderContentType(result)); } @@ -70,10 +74,13 @@ public class MgmtContentTypeTest extends AbstractManagementApiIntegrationTest { @Description("The response of a POST request shall contain charset=utf-8") public void postDistributionSet_ContentTypeJsonUtf8_wAcceptJson() throws Exception { final MvcResult result = mvc.perform( - post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING).content(JsonBuilder.distributionSets(Arrays.asList(ds))) + post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING).content(JsonBuilder.distributionSets( + Collections.singletonList(ds))) .contentType(MediaType.APPLICATION_JSON_UTF8).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated()) - .andExpect(jsonPath("[0]name", equalTo(dsName))).andReturn(); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isCreated()) + .andExpect(jsonPath("[0]name", equalTo(dsName))) + .andReturn(); assertEquals(MediaType.APPLICATION_JSON_UTF8_VALUE, getResponseHeaderContentType(result)); } @@ -82,10 +89,13 @@ public class MgmtContentTypeTest extends AbstractManagementApiIntegrationTest { @Description("The response of a POST request shall contain charset=utf-8") public void postDistributionSet_ContentTypeJsonUtf8_wAcceptJsonUtf8() throws Exception { final MvcResult result = mvc.perform( - post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING).content(JsonBuilder.distributionSets(Arrays.asList(ds))) + post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING).content(JsonBuilder.distributionSets( + Collections.singletonList(ds))) .contentType(MediaType.APPLICATION_JSON_UTF8).accept(MediaType.APPLICATION_JSON_UTF8)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated()) - .andExpect(jsonPath("[0]name", equalTo(dsName))).andReturn(); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isCreated()) + .andExpect(jsonPath("[0]name", equalTo(dsName))) + .andReturn(); assertEquals(MediaType.APPLICATION_JSON_UTF8_VALUE, getResponseHeaderContentType(result)); } @@ -94,10 +104,13 @@ public class MgmtContentTypeTest extends AbstractManagementApiIntegrationTest { @Description("The response of a POST request shall contain charset=utf-8") public void postDistributionSet_ContentTypeJsonUtf8_wAcceptHalJson() throws Exception { final MvcResult result = mvc.perform( - post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING).content(JsonBuilder.distributionSets(Arrays.asList(ds))) + post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING).content(JsonBuilder.distributionSets( + Collections.singletonList(ds))) .contentType(MediaType.APPLICATION_JSON_UTF8).accept(MediaTypes.HAL_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated()) - .andExpect(jsonPath("[0]name", equalTo(dsName))).andReturn(); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isCreated()) + .andExpect(jsonPath("[0]name", equalTo(dsName))) + .andReturn(); assertEquals(MediaTypes.HAL_JSON_VALUE + ";charset=UTF-8", getResponseHeaderContentType(result)); } @@ -106,10 +119,13 @@ public class MgmtContentTypeTest extends AbstractManagementApiIntegrationTest { @Description("The response of a POST request shall contain charset=utf-8") public void postDistributionSet_ContentTypeJson_woAccept() throws Exception { final MvcResult result = mvc.perform( - post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING).content(JsonBuilder.distributionSets(Arrays.asList(ds))) - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING).content(JsonBuilder.distributionSets( + Collections.singletonList(ds))) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isCreated()) - .andExpect(jsonPath("[0]name", equalTo(dsName))).andReturn(); + .andExpect(jsonPath("[0]name", equalTo(dsName))) + .andReturn(); assertEquals(MediaTypes.HAL_JSON_VALUE + ";charset=UTF-8", getResponseHeaderContentType(result)); } @@ -118,10 +134,13 @@ public class MgmtContentTypeTest extends AbstractManagementApiIntegrationTest { @Description("The response of a POST request shall contain charset=utf-8") public void postDistributionSet_ContentTypeJson_wAcceptJson() throws Exception { final MvcResult result = mvc.perform( - post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING).content(JsonBuilder.distributionSets(Arrays.asList(ds))) + post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING).content(JsonBuilder.distributionSets( + Collections.singletonList(ds))) .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated()) - .andExpect(jsonPath("[0]name", equalTo(dsName))).andReturn(); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isCreated()) + .andExpect(jsonPath("[0]name", equalTo(dsName))) + .andReturn(); assertEquals(MediaType.APPLICATION_JSON_UTF8_VALUE, getResponseHeaderContentType(result)); } @@ -130,10 +149,12 @@ public class MgmtContentTypeTest extends AbstractManagementApiIntegrationTest { @Description("The response of a POST request shall contain charset=utf-8") public void postDistributionSet_ContentTypeJson_wAcceptJsonUtf8() throws Exception { final MvcResult result = mvc.perform(post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING) - .content(JsonBuilder.distributionSets(Arrays.asList(ds))).contentType(MediaType.APPLICATION_JSON) - .accept(MediaType.APPLICATION_JSON_UTF8)).andDo(MockMvcResultPrinter.print()) + .content(JsonBuilder.distributionSets(Collections.singletonList(ds))).contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON_UTF8)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isCreated()) - .andExpect(jsonPath("[0]name", equalTo(dsName))).andReturn(); + .andExpect(jsonPath("[0]name", equalTo(dsName))) + .andReturn(); assertEquals(MediaType.APPLICATION_JSON_UTF8_VALUE, getResponseHeaderContentType(result)); } @@ -142,10 +163,12 @@ public class MgmtContentTypeTest extends AbstractManagementApiIntegrationTest { @Description("The response of a POST request shall contain charset=utf-8") public void postDistributionSet_ContentTypeJson_wAcceptHalJson() throws Exception { final MvcResult result = mvc.perform(post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING) - .content(JsonBuilder.distributionSets(Arrays.asList(ds))).contentType(MediaType.APPLICATION_JSON) - .accept(MediaTypes.HAL_JSON)).andDo(MockMvcResultPrinter.print()) + .content(JsonBuilder.distributionSets(Collections.singletonList(ds))).contentType(MediaType.APPLICATION_JSON) + .accept(MediaTypes.HAL_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isCreated()) - .andExpect(jsonPath("[0]name", equalTo(dsName))).andReturn(); + .andExpect(jsonPath("[0]name", equalTo(dsName))) + .andReturn(); assertEquals(MediaTypes.HAL_JSON_VALUE + ";charset=UTF-8", getResponseHeaderContentType(result)); } @@ -153,7 +176,8 @@ public class MgmtContentTypeTest extends AbstractManagementApiIntegrationTest { @Test @Description("The response of a GET request shall contain charset=utf-8") public void getDistributionSet_woAccept() throws Exception { - final MvcResult result = mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING)).andDo(MockMvcResultPrinter.print()) + final MvcResult result = mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andReturn(); @@ -164,7 +188,8 @@ public class MgmtContentTypeTest extends AbstractManagementApiIntegrationTest { @Description("The response of a GET request shall contain charset=utf-8") public void getDistributionSet_wAcceptJson() throws Exception { final MvcResult result = mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andReturn(); assertEquals(MediaType.APPLICATION_JSON_UTF8_VALUE, getResponseHeaderContentType(result)); @@ -174,7 +199,8 @@ public class MgmtContentTypeTest extends AbstractManagementApiIntegrationTest { @Description("The response of a GET request shall contain charset=utf-8") public void getDistributionSet_wAcceptJsonUtf8() throws Exception { final MvcResult result = mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING).accept(MediaType.APPLICATION_JSON_UTF8)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andReturn(); assertEquals(MediaType.APPLICATION_JSON_UTF8_VALUE, getResponseHeaderContentType(result)); @@ -184,7 +210,8 @@ public class MgmtContentTypeTest extends AbstractManagementApiIntegrationTest { @Description("The response of a GET request shall contain charset=utf-8") public void getDistributionSet_wAcceptHalJson() throws Exception { final MvcResult result = mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING).accept(MediaTypes.HAL_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andReturn(); assertEquals(MediaTypes.HAL_JSON_VALUE + ";charset=UTF-8", getResponseHeaderContentType(result)); @@ -193,4 +220,4 @@ public class MgmtContentTypeTest extends AbstractManagementApiIntegrationTest { private String getResponseHeaderContentType(MvcResult result) { return result.getResponse().getHeader("Content-Type"); } -} +} \ No newline at end of file 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 b5f7749d8..935e73340 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 @@ -94,7 +94,8 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr // Create DistributionSet with three software modules final DistributionSet set = testdataFactory.createDistributionSet("SMTest"); mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + set.getId() + "/assignedSM")) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath("$.size", equalTo(set.getModules().size()))); } @@ -106,14 +107,15 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr // post assignment mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + set.getId() + "/assignedSM") .param("offset", "1").param("limit", "2").param("sort", "version:DESC").param("q", "name==one*") - .accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .accept(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)); } @Test @Description("This test verifies the deletion of a assigned Software Module of a Distribution Set can not be achieved when that Distribution Set has been assigned or installed to a target.") public void deleteFailureWhenDistributionSetInUse() throws Exception { - // create DisSet final DistributionSet disSet = testdataFactory.createDistributionSetWithNoSoftwareModules("Eris", "560a"); final List smIDs = new ArrayList<>(); @@ -121,11 +123,12 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr smIDs.add(sm.getId()); final JSONArray smList = new JSONArray(); for (final Long smID : smIDs) { - smList.put(new JSONObject().put("id", Long.valueOf(smID))); + smList.put(new JSONObject().put("id", smID)); } // post assignment mvc.perform(post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM") - .contentType(MediaType.APPLICATION_JSON).content(smList.toString())).andDo(MockMvcResultPrinter.print()) + .contentType(MediaType.APPLICATION_JSON).content(smList.toString())) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); // create targets and assign DisSet to target @@ -139,7 +142,8 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr mvc.perform( post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedTargets") .contentType(MediaType.APPLICATION_JSON).content(list.toString())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath("$.assigned", equalTo(knownTargetIds.length - 1))) .andExpect(jsonPath("$.alreadyAssigned", equalTo(1))) .andExpect(jsonPath("$.total", equalTo(knownTargetIds.length))); @@ -147,7 +151,8 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr // try to delete the Software Module from DistSet that has been assigned // to the target. mvc.perform(delete(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM/" - + smIDs.get(0)).contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + + smIDs.get(0)).contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isForbidden()) .andExpect(jsonPath("$.errorCode", equalTo("hawkbit.server.error.entityreadonly"))); } @@ -155,7 +160,6 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr @Test @Description("This test verifies that the assignment of a Software Module to a Distribution Set can not be achieved when that Distribution Set has been assigned or installed to a target.") public void assignmentFailureWhenAssigningToUsedDistributionSet() throws Exception { - // create DisSet final DistributionSet disSet = testdataFactory.createDistributionSetWithNoSoftwareModules("Mars", "686,980"); final List smIDs = new ArrayList<>(); @@ -163,11 +167,12 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr smIDs.add(sm.getId()); final JSONArray smList = new JSONArray(); for (final Long smID : smIDs) { - smList.put(new JSONObject().put("id", Long.valueOf(smID))); + smList.put(new JSONObject().put("id", smID)); } // post assignment mvc.perform(post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM") - .contentType(MediaType.APPLICATION_JSON).content(smList.toString())).andDo(MockMvcResultPrinter.print()) + .contentType(MediaType.APPLICATION_JSON).content(smList.toString())) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); // create Targets @@ -175,10 +180,10 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr final JSONArray list = createTargetAndJsonArray(null, null, null, null, null, knownTargetIds); // assign DisSet to target and test assignment assignDistributionSet(disSet.getId(), knownTargetIds[0]); - mvc.perform( - post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedTargets") - .contentType(MediaType.APPLICATION_JSON).content(list.toString())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + mvc.perform(post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedTargets") + .contentType(MediaType.APPLICATION_JSON).content(list.toString())) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath("$.assigned", equalTo(knownTargetIds.length - 1))) .andExpect(jsonPath("$.alreadyAssigned", equalTo(1))) .andExpect(jsonPath("$.total", equalTo(knownTargetIds.length))); @@ -190,19 +195,20 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr mvc.perform(post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM") .contentType(MediaType.APPLICATION_JSON).content(smList2.toString())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isForbidden()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isForbidden()) .andExpect(jsonPath("$.errorCode", equalTo("hawkbit.server.error.entityreadonly"))); } @Test @Description("This test verifies the assignment of Software Modules to a Distribution Set through the RESTful API.") public void assignSoftwareModuleToDistributionSet() throws Exception { - // create DisSet final DistributionSet disSet = testdataFactory.createDistributionSetWithNoSoftwareModules("Jupiter", "398,88"); // Test if size is 0 mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM")) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath("$.size", equalTo(disSet.getModules().size()))); // create Software Modules final List smIDs = Arrays.asList(testdataFactory.createSoftwareModuleOs().getId(), @@ -211,10 +217,12 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr // post assignment mvc.perform(post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM") .contentType(MediaType.APPLICATION_JSON).content(JsonBuilder.ids(smIDs))) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()); // Test if size is 3 mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM")) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath("$.size", equalTo(smIDs.size()))); // verify quota enforcement @@ -227,18 +235,22 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr // post assignment final String jsonIDs = JsonBuilder.ids(moduleIDs.subList(0, maxSoftwareModules - smIDs.size())); mvc.perform(post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM") - .contentType(MediaType.APPLICATION_JSON).content(jsonIDs)).andDo(MockMvcResultPrinter.print()) + .contentType(MediaType.APPLICATION_JSON).content(jsonIDs)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); // test if size corresponds with quota mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() - + "/assignedSM?limit={limit}", maxSoftwareModules * 2)).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isOk()).andExpect(jsonPath("$.size", equalTo(maxSoftwareModules))); + + "/assignedSM?limit={limit}", maxSoftwareModules * 2)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.size", equalTo(maxSoftwareModules))); // post one more to cause the quota to be exceeded mvc.perform(post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM") .contentType(MediaType.APPLICATION_JSON) .content(JsonBuilder.ids(Collections.singletonList(moduleIDs.get(moduleIDs.size() - 1))))) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isForbidden()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isForbidden()) .andExpect(jsonPath("$.exceptionClass", equalTo(AssignmentQuotaExceededException.class.getName()))) .andExpect(jsonPath("$.errorCode", equalTo(SpServerError.SP_QUOTA_EXCEEDED.getKey()))); @@ -246,13 +258,15 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr final DistributionSet disSet2 = testdataFactory.createDistributionSetWithNoSoftwareModules("Saturn", "4.0"); mvc.perform(post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet2.getId() + "/assignedSM") .contentType(MediaType.APPLICATION_JSON).content(JsonBuilder.ids(moduleIDs))) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isForbidden()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isForbidden()) .andExpect(jsonPath("$.exceptionClass", equalTo(AssignmentQuotaExceededException.class.getName()))) .andExpect(jsonPath("$.errorCode", equalTo(SpServerError.SP_QUOTA_EXCEEDED.getKey()))); // verify size is still 0 mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet2.getId() + "/assignedSM")) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath("$.size", equalTo(0))); } @@ -260,12 +274,12 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr @Test @Description("This test verifies the removal of Software Modules of a Distribution Set through the RESTful API.") public void unassignSoftwareModuleFromDistributionSet() throws Exception { - // Create DistributionSet with three software modules final DistributionSet set = testdataFactory.createDistributionSet("Venus"); int amountOfSM = set.getModules().size(); mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + set.getId() + "/assignedSM")) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath("$.size", equalTo(amountOfSM))); // test the removal of all software modules one by one for (final Iterator iter = set.getModules().iterator(); iter.hasNext(); ) { @@ -274,7 +288,8 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + set.getId() + "/assignedSM/" + smId)) .andExpect(status().isOk()); mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + set.getId() + "/assignedSM")) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath("$.size", equalTo(--amountOfSM))); } } @@ -293,7 +308,8 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr mvc.perform(post( MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/assignedTargets") .contentType(MediaType.APPLICATION_JSON).content(list.toString())) - .andExpect(status().isOk()).andExpect(jsonPath("$.assigned", equalTo(knownTargetIds.length - 1))) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.assigned", equalTo(knownTargetIds.length - 1))) .andExpect(jsonPath("$.alreadyAssigned", equalTo(1))) .andExpect(jsonPath("$.total", equalTo(knownTargetIds.length))); @@ -353,10 +369,11 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr "stanTest", "2", reloaded, Collections.singletonList(softwareModule)); final MvcResult mvcResult = mvc .perform(post("/rest/v1/distributionsets") - .content(JsonBuilder.distributionSets(Arrays.asList(generated))) + .content(JsonBuilder.distributionSets(Collections.singletonList(generated))) .contentType(MediaType.APPLICATION_JSON) .accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isBadRequest()).andReturn(); + .andExpect(status().isBadRequest()) + .andReturn(); final ExceptionInfo exceptionInfo = ResourceUtility.convertException(mvcResult.getResponse().getContentAsString()); assertEquals("jakarta.validation.ValidationException", exceptionInfo.getExceptionClass()); @@ -380,7 +397,8 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr }); mvc.perform(post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + ds.getId() + "/assignedTargets") - .contentType(MediaType.APPLICATION_JSON).content(payload.toString())).andExpect(status().isForbidden()); + .contentType(MediaType.APPLICATION_JSON).content(payload.toString())) + .andExpect(status().isForbidden()); assertThat(targetManagement.findByAssignedDistributionSet(PAGE, ds.getId()).getContent()).isEmpty(); } @@ -407,7 +425,8 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr // the 'max actions per target' quota is exceeded final String json = new JSONArray().put(new JSONObject().put("id", testTarget.getControllerId())).toString(); mvc.perform(post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + ds3.getId() + "/assignedTargets") - .contentType(MediaType.APPLICATION_JSON).content(json)).andExpect(status().isForbidden()); + .contentType(MediaType.APPLICATION_JSON).content(json)) + .andExpect(status().isForbidden()); } @Test @@ -429,7 +448,8 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr mvc.perform(post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/assignedTargets?offline=true").contentType(MediaType.APPLICATION_JSON).content(list.toString())) - .andExpect(status().isOk()).andExpect(jsonPath("$.assigned", equalTo(targets.size() - 1))) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.assigned", equalTo(targets.size() - 1))) .andExpect(jsonPath("$.alreadyAssigned", equalTo(1))) .andExpect(jsonPath("$.total", equalTo(targets.size()))); @@ -550,8 +570,10 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr mvc.perform(post( MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/assignedTargets") .contentType(MediaType.APPLICATION_JSON).content(assignTargetJson.toString())) - .andExpect(status().isOk()).andExpect(jsonPath("$.alreadyAssigned", equalTo(1))) - .andExpect(jsonPath("$.assigned", equalTo(2))).andExpect(jsonPath("$.total", equalTo(3))); + .andExpect(status().isOk()) + .andExpect(jsonPath("$.alreadyAssigned", equalTo(1))) + .andExpect(jsonPath("$.assigned", equalTo(2))) + .andExpect(jsonPath("$.total", equalTo(3))); } @Test @@ -564,7 +586,8 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr assignDistributionSet(createdDs.getId(), knownTargetId); mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/assignedTargets")) - .andExpect(status().isOk()).andExpect(jsonPath("$.size", equalTo(1))) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.size", equalTo(1))) .andExpect(jsonPath("$.content[0].controllerId", equalTo(knownTargetId))); } @@ -591,7 +614,8 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr final DistributionSet createdDs = testdataFactory.createDistributionSet(); mvc.perform(get( MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/assignedTargets")) - .andExpect(status().isOk()).andExpect(jsonPath("$.size", equalTo(0))) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.size", equalTo(0))) .andExpect(jsonPath("$.total", equalTo(0))); } @@ -608,12 +632,13 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr // assign knownTargetId to distribution set assignDistributionSet(createdDs.getId(), knownTargetId); // make it in install state - testdataFactory.sendUpdateActionStatusToTargets(Arrays.asList(createTarget), Status.FINISHED, + testdataFactory.sendUpdateActionStatusToTargets(Collections.singletonList(createTarget), Status.FINISHED, Collections.singletonList("some message")); mvc.perform(get( MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/installedTargets")) - .andExpect(status().isOk()).andExpect(jsonPath("$.size", equalTo(1))) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.size", equalTo(1))) .andExpect(jsonPath("$.content[0].controllerId", equalTo(knownTargetId))); } @@ -650,7 +675,9 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr targetFilterQueryManagement.create(entityFactory.targetFilterQuery().create().name("c").query("name==y")); mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() - + "/autoAssignTargetFilters")).andExpect(status().isOk()).andExpect(jsonPath("$.size", equalTo(1))) + + "/autoAssignTargetFilters")) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.size", equalTo(1))) .andExpect(jsonPath("$.content[0].name", equalTo(knownFilterName))); } @@ -693,7 +720,8 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/autoAssignTargetFilters").param(MgmtRestConstants.REQUEST_PARAMETER_SEARCH, query)) - .andExpect(status().isOk()).andExpect(jsonPath("$.size", equalTo(2))) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.size", equalTo(2))) .andExpect(jsonPath("$.content[0].name", equalTo(filterNamePrefix + "1"))) .andExpect(jsonPath("$.content[1].name", equalTo(filterNamePrefix + "2"))); } @@ -709,7 +737,8 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/autoAssignTargetFilters").param(MgmtRestConstants.REQUEST_PARAMETER_SEARCH, query)) - .andExpect(status().isOk()).andExpect(jsonPath("$.size", equalTo(0))); + .andExpect(status().isOk()) + .andExpect(jsonPath("$.size", equalTo(0))); } @Test @@ -717,7 +746,8 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr public void getDistributionSetsWithoutAdditionalRequestParameters() throws Exception { final int sets = 5; createDistributionSetsAlphabetical(sets); - mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING)).andDo(MockMvcResultPrinter.print()) + mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(sets))) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_SIZE, equalTo(sets))) @@ -732,7 +762,8 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr createDistributionSetsAlphabetical(sets); mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING) .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(limitSize))) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(sets))) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_SIZE, equalTo(limitSize))) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(limitSize))); @@ -748,7 +779,8 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING) .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(offsetParam)) .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(sets))) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(sets))) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_SIZE, equalTo(expectedSize))) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(expectedSize))); @@ -772,7 +804,8 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr // perform request mvc.perform(get("/rest/v1/distributionsets").accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$.content.[0]._links.self.href", equalTo("http://localhost/rest/v1/distributionsets/" + set.getId()))) @@ -803,7 +836,8 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr // perform request mvc.perform(get("/rest/v1/distributionsets/{dsId}", set.getId()).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$._links.self.href", equalTo("http://localhost/rest/v1/distributionsets/" + set.getId()))) @@ -899,7 +933,8 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr assertThat(distributionSetManagement.findByCompleted(PAGE, true)).hasSize(1); // perform request - mvc.perform(delete("/rest/v1/distributionsets/{smId}", set.getId())).andDo(MockMvcResultPrinter.print()) + mvc.perform(delete("/rest/v1/distributionsets/{smId}", set.getId())) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); // check repository content @@ -910,7 +945,8 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr @Test @Description("Ensures that DS deletion request to API on an entity that does not exist results in NOT_FOUND.") public void deleteDistributionSetThatDoesNotExistLeadsToNotFound() throws Exception { - mvc.perform(delete("/rest/v1/distributionsets/1234")).andDo(MockMvcResultPrinter.print()) + mvc.perform(delete("/rest/v1/distributionsets/1234")) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNotFound()); } @@ -926,14 +962,19 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr assertThat(distributionSetManagement.findByCompleted(PAGE, true)).hasSize(1); - mvc.perform(get("/rest/v1/distributionsets/{dsId}", set.getId())).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isOk()).andExpect(jsonPath("$.deleted", equalTo(false))); + mvc.perform(get("/rest/v1/distributionsets/{dsId}", set.getId())) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.deleted", equalTo(false))); - mvc.perform(delete("/rest/v1/distributionsets/{dsId}", set.getId())).andDo(MockMvcResultPrinter.print()) + mvc.perform(delete("/rest/v1/distributionsets/{dsId}", set.getId())) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); - mvc.perform(get("/rest/v1/distributionsets/{dsId}", set.getId())).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isOk()).andExpect(jsonPath("$.deleted", equalTo(true))); + mvc.perform(get("/rest/v1/distributionsets/{dsId}", set.getId())) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.deleted", equalTo(true))); // check repository content assertThat(distributionSetManagement.findByCompleted(PAGE, true)).hasSize(0); @@ -953,7 +994,8 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr mvc.perform(put("/rest/v1/distributionsets/{dsId}", set.getId()).content(body) .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath("$.version", equalTo("anotherVersion"))) .andExpect(jsonPath("$.requiredMigrationStep", equalTo(true))) .andExpect(jsonPath("$.locked", equalTo(false))) @@ -982,7 +1024,8 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr mvc.perform(put("/rest/v1/distributionsets/{dsId}", set.getId()) .content("{\"version\":\"anotherVersion\",\"requiredMigrationStep\":\"true\"}") .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isForbidden()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isForbidden()); final DistributionSet setupdated = distributionSetManagement.get(set.getId()).get(); @@ -1000,45 +1043,55 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr sets.add(set); // SM does not exist - mvc.perform(get("/rest/v1/distributionsets/12345678")).andDo(MockMvcResultPrinter.print()) + mvc.perform(get("/rest/v1/distributionsets/12345678")) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNotFound()); - mvc.perform(delete("/rest/v1/distributionsets/12345678")).andDo(MockMvcResultPrinter.print()) + mvc.perform(delete("/rest/v1/distributionsets/12345678")) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNotFound()); // bad request - no content mvc.perform(post("/rest/v1/distributionsets").contentType(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isBadRequest()); // bad request - bad content mvc.perform(post("/rest/v1/distributionsets").content("sdfjsdlkjfskdjf".getBytes()) - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isBadRequest()); final DistributionSet missingName = entityFactory.distributionSet().create().build(); - mvc.perform(post("/rest/v1/distributionsets").content(JsonBuilder.distributionSets(Arrays.asList(missingName))) - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + mvc.perform(post("/rest/v1/distributionsets").content(JsonBuilder.distributionSets(Collections.singletonList(missingName))) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isBadRequest()); final DistributionSet toLongName = testdataFactory .generateDistributionSet(RandomStringUtils.randomAlphanumeric(NamedEntity.NAME_MAX_SIZE + 1)); - mvc.perform(post("/rest/v1/distributionsets").content(JsonBuilder.distributionSets(Arrays.asList(toLongName))) - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + mvc.perform(post("/rest/v1/distributionsets").content(JsonBuilder.distributionSets(Collections.singletonList(toLongName))) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isBadRequest()); // unsupported media type mvc.perform(post("/rest/v1/distributionsets").content(JsonBuilder.distributionSets(sets)) - .contentType(MediaType.APPLICATION_OCTET_STREAM)).andDo(MockMvcResultPrinter.print()) + .contentType(MediaType.APPLICATION_OCTET_STREAM)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isUnsupportedMediaType()); // not allowed methods - mvc.perform(post("/rest/v1/distributionsets/{smId}", set.getId())).andDo(MockMvcResultPrinter.print()) + mvc.perform(post("/rest/v1/distributionsets/{smId}", set.getId())) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isMethodNotAllowed()); - mvc.perform(put("/rest/v1/distributionsets")).andDo(MockMvcResultPrinter.print()) + mvc.perform(put("/rest/v1/distributionsets")) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isMethodNotAllowed()); - mvc.perform(delete("/rest/v1/distributionsets")).andDo(MockMvcResultPrinter.print()) + mvc.perform(delete("/rest/v1/distributionsets")) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isMethodNotAllowed()); } @@ -1060,9 +1113,11 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr mvc.perform(post("/rest/v1/distributionsets/{dsId}/metadata", testDS.getId()).accept(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON).content(metaData1.toString())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isCreated()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) - .andExpect(jsonPath("[0]key", equalTo(knownKey1))).andExpect(jsonPath("[0]value", equalTo(knownValue1))) + .andExpect(jsonPath("[0]key", equalTo(knownKey1))) + .andExpect(jsonPath("[0]value", equalTo(knownValue1))) .andExpect(jsonPath("[1]key", equalTo(knownKey2))) .andExpect(jsonPath("[1]value", equalTo(knownValue2))); @@ -1084,7 +1139,8 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr mvc.perform(post("/rest/v1/distributionsets/{dsId}/metadata", testDS.getId()).accept(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON).content(metaData2.toString())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isForbidden()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isForbidden()); // verify that the number of meta data entries has not changed // (we cannot use the PAGE constant here as it tries to sort by ID) @@ -1109,9 +1165,12 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr mvc.perform(put("/rest/v1/distributionsets/{dsId}/metadata/{key}", testDS.getId(), knownKey) .accept(MediaType.APPLICATION_JSON).contentType(MediaType.APPLICATION_JSON) - .content(jsonObject.toString())).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .content(jsonObject.toString())) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) - .andExpect(jsonPath("key", equalTo(knownKey))).andExpect(jsonPath("value", equalTo(updateValue))); + .andExpect(jsonPath("key", equalTo(knownKey))) + .andExpect(jsonPath("value", equalTo(updateValue))); final DistributionSetMetadata assertDS = distributionSetManagement .getMetaDataByDistributionSetId(testDS.getId(), knownKey).get(); @@ -1130,7 +1189,8 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr createDistributionSetMetadata(testDS.getId(), entityFactory.generateDsMetadata(knownKey, knownValue)); mvc.perform(delete("/rest/v1/distributionsets/{dsId}/metadata/{key}", testDS.getId(), knownKey)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()); assertThat(distributionSetManagement.getMetaDataByDistributionSetId(testDS.getId(), knownKey)).isNotPresent(); } @@ -1146,10 +1206,12 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr createDistributionSetMetadata(testDS.getId(), entityFactory.generateDsMetadata(knownKey, knownValue)); mvc.perform(delete("/rest/v1/distributionsets/{dsId}/metadata/XXX", testDS.getId(), knownKey)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isNotFound()); mvc.perform(delete("/rest/v1/distributionsets/1234/metadata/{key}", knownKey)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isNotFound()); assertThat(distributionSetManagement.getMetaDataByDistributionSetId(testDS.getId(), knownKey)).isPresent(); } @@ -1164,8 +1226,10 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr createDistributionSetMetadata(testDS.getId(), entityFactory.generateDsMetadata(knownKey, knownValue)); mvc.perform(get("/rest/v1/distributionsets/{dsId}/metadata/{key}", testDS.getId(), knownKey)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(jsonPath("key", equalTo(knownKey))).andExpect(jsonPath("value", equalTo(knownValue))); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("key", equalTo(knownKey))) + .andExpect(jsonPath("value", equalTo(knownValue))); } @Test @@ -1203,8 +1267,11 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr } mvc.perform(get("/rest/v1/distributionsets/{dsId}/metadata?offset=" + offsetParam + "&limit=" + limitParam, - testDS.getId())).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(jsonPath("size", equalTo(limitParam))).andExpect(jsonPath("total", equalTo(totalMetadata))) + testDS.getId())) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("size", equalTo(limitParam))) + .andExpect(jsonPath("total", equalTo(totalMetadata))) .andExpect(jsonPath("content[0].key", equalTo("knownKey0"))) .andExpect(jsonPath("content[0].value", equalTo("knownValue0"))); @@ -1221,9 +1288,12 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr final String rsqlFindLikeDs1OrDs2 = "name==DS1test,name==DS2test"; - mvc.perform(get("/rest/v1/distributionsets?q=" + rsqlFindLikeDs1OrDs2)).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isOk()).andExpect(jsonPath("size", equalTo(2))) - .andExpect(jsonPath("total", equalTo(2))).andExpect(jsonPath("content[0].name", equalTo("DS1test"))) + mvc.perform(get("/rest/v1/distributionsets?q=" + rsqlFindLikeDs1OrDs2)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("size", equalTo(2))) + .andExpect(jsonPath("total", equalTo(2))) + .andExpect(jsonPath("content[0].name", equalTo("DS1test"))) .andExpect(jsonPath("content[1].name", equalTo("DS2test"))); } @@ -1238,8 +1308,10 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr final String rsqlFindLikeDs1OrDs2 = "complete==" + Boolean.TRUE; - mvc.perform(get("/rest/v1/distributionsets?q=" + rsqlFindLikeDs1OrDs2)).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isOk()).andExpect(jsonPath("size", equalTo(10))) + mvc.perform(get("/rest/v1/distributionsets?q=" + rsqlFindLikeDs1OrDs2)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("size", equalTo(10))) .andExpect(jsonPath("total", equalTo(10))); } @@ -1262,8 +1334,10 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/assignedTargets?q=" + rsqlFindTargetId1).contentType(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()).andExpect(jsonPath("total", equalTo(1))) - .andExpect(jsonPath("size", equalTo(1))).andExpect(jsonPath("content[0].controllerId", equalTo("1"))); + .andExpect(status().isOk()) + .andExpect(jsonPath("total", equalTo(1))) + .andExpect(jsonPath("size", equalTo(1))) + .andExpect(jsonPath("content[0].controllerId", equalTo("1"))); } @Test @@ -1281,8 +1355,11 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr final String rsqlSearchValue1 = "value==knownValue1"; mvc.perform(get("/rest/v1/distributionsets/{dsId}/metadata?q=" + rsqlSearchValue1, testDS.getId())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()).andExpect(jsonPath("size", equalTo(1))) - .andExpect(jsonPath("total", equalTo(1))).andExpect(jsonPath("content[0].key", equalTo("knownKey1"))) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("size", equalTo(1))) + .andExpect(jsonPath("total", equalTo(1))) + .andExpect(jsonPath("content[0].key", equalTo("knownKey1"))) .andExpect(jsonPath("content[0].value", equalTo("knownValue1"))); } @@ -1299,7 +1376,8 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr assignDistributionSet(createdDs.getId(), knownTargetIds[0], Action.ActionType.DOWNLOAD_ONLY); mvc.perform(post("/rest/v1/distributionsets/{ds}/assignedTargets", createdDs.getId()) - .contentType(MediaType.APPLICATION_JSON).content(list.toString())).andExpect(status().isOk()) + .contentType(MediaType.APPLICATION_JSON).content(list.toString())) + .andExpect(status().isOk()) .andExpect(jsonPath("$.assigned", equalTo(knownTargetIds.length - 1))) .andExpect(jsonPath("$.alreadyAssigned", equalTo(1))) .andExpect(jsonPath("$.total", equalTo(knownTargetIds.length))); @@ -1324,8 +1402,10 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr final JSONArray list = createTargetAndJsonArray(null, null, null, null, confirmationRequired, targetId); mvc.perform(post("/rest/v1/distributionsets/{ds}/assignedTargets", createdDs.getId()) - .contentType(MediaType.APPLICATION_JSON).content(list.toString())).andExpect(status().isOk()) - .andExpect(jsonPath("$.assigned", equalTo(1))).andExpect(jsonPath("$.alreadyAssigned", equalTo(0))) + .contentType(MediaType.APPLICATION_JSON).content(list.toString())) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.assigned", equalTo(1))) + .andExpect(jsonPath("$.alreadyAssigned", equalTo(0))) .andExpect(jsonPath("$.total", equalTo(1))); assertThat( @@ -1352,7 +1432,8 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr body.put(getAssignmentObject(targetId, MgmtActionType.FORCED)); mvc.perform(post("/rest/v1/distributionsets/{ds}/assignedTargets", dsId).content(body.toString()) - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isBadRequest()); } @@ -1367,7 +1448,9 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr body.put(getAssignmentObject(targetId, MgmtActionType.FORCED)); mvc.perform(post("/rest/v1/distributionsets/{ds}/assignedTargets", dsId).content(body.toString()) - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath("total", equalTo(1))); } @@ -1386,7 +1469,9 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr enableMultiAssignments(); mvc.perform(post("/rest/v1/distributionsets/{ds}/assignedTargets", dsId).content(body.toString()) - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath("total", equalTo(body.length()))); } @@ -1402,15 +1487,18 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr .put(getAssignmentObject(targetId, MgmtActionType.FORCED, Action.WEIGHT_MIN - 1)); mvc.perform(post("/rest/v1/distributionsets/{ds}/assignedTargets", dsId).content(bodyValide.toString()) - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); enableMultiAssignments(); mvc.perform(post("/rest/v1/distributionsets/{ds}/assignedTargets", dsId).content(bodyInvalide.toString()) - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isBadRequest()) .andExpect(jsonPath("$.errorCode", equalTo("hawkbit.server.error.repo.constraintViolation"))); mvc.perform(post("/rest/v1/distributionsets/{ds}/assignedTargets", dsId).content(bodyValide.toString()) - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); final List actions = deploymentManagement.findActionsAll(PAGE).get().collect(Collectors.toList()); @@ -1567,7 +1655,8 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr jsonObject.put("cancelRollouts", true); mvc.perform(post("/rest/v1/distributionsets/{ds}/invalidate", distributionSet.getId()) - .content(jsonObject.toString()).contentType(MediaType.APPLICATION_JSON)).andExpect(status().isOk()); + .content(jsonObject.toString()).contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()); assertThat(targetFilterQueryManagement.get(targetFilterQuery.getId()).get().getAutoAssignDistributionSet()) .isNull(); @@ -1689,7 +1778,8 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr .perform(post("/rest/v1/distributionsets") .content(JsonBuilder.distributionSets(Arrays.asList(one, two, three))) .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isCreated()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("[0]name", equalTo(one.getName()))) .andExpect(jsonPath("[0]description", equalTo(one.getDescription()))) @@ -1729,7 +1819,8 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr contains(three.findFirstModuleByType(appType).get().getId().intValue()))) .andExpect(jsonPath("[2].modules.[?(@.type=='" + osType.getKey() + "')].id", contains(three.findFirstModuleByType(osType).get().getId().intValue()))) - .andExpect(jsonPath("[2]requiredMigrationStep", equalTo(three.isRequiredMigrationStep()))).andReturn(); + .andExpect(jsonPath("[2]requiredMigrationStep", equalTo(three.isRequiredMigrationStep()))) + .andReturn(); } private Set createDistributionSetsAlphabetical(final int amount) { diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTagResourceTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTagResourceTest.java index e52072cf7..3f4cb805d 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTagResourceTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTagResourceTest.java @@ -48,7 +48,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.JSONException; import org.junit.jupiter.api.Test; import org.springframework.http.MediaType; import org.springframework.test.web.servlet.ResultActions; @@ -57,8 +56,7 @@ import org.springframework.test.web.servlet.ResultActions; @Story("Distribution Set Tag Resource") public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegrationTest { - private static final String DISTRIBUTIONSETTAGS_ROOT = "http://localhost" - + MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/"; + private static final String DISTRIBUTIONSETTAGS_ROOT = "http://localhost" + MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/"; private static final Random RND = new Random(); @Test @@ -70,7 +68,8 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt final DistributionSetTag unassigned = tags.get(1); mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(applyBaseEntityMatcherOnPagedResult(assigned)) .andExpect(applyBaseEntityMatcherOnPagedResult(unassigned)) @@ -108,7 +107,8 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING) .queryParam(MgmtRestConstants.REQUEST_PARAMETER_SEARCH, "distributionset.id==" + distributionSet1.getId()) .accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(applyBaseEntityMatcherOnPagedResult(tag1)) .andExpect(applyBaseEntityMatcherOnPagedResult(tag2)) @@ -121,7 +121,8 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING) .queryParam(MgmtRestConstants.REQUEST_PARAMETER_SEARCH, "distributionset.id==" + distributionSet2.getId()) .accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(applyBaseEntityMatcherOnPagedResult(tag1)) .andExpect(applySelfLinkMatcherOnPagedResult(tag1, DISTRIBUTIONSETTAGS_ROOT + tag1.getId())) @@ -148,7 +149,8 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt + "?" + MgmtRestConstants.REQUEST_PARAMETER_SEARCH + "=distributionset.id==" + distributionSet1.getId() + ";description==" + tag1.getDescription()) .accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(applyBaseEntityMatcherOnPagedResult(tag1)) .andExpect(applySelfLinkMatcherOnPagedResult(tag1, DISTRIBUTIONSETTAGS_ROOT + tag1.getId())) @@ -165,7 +167,9 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt final DistributionSetTag assigned = tags.get(0); mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/" + assigned.getId()) - .accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .accept(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(applyTagMatcherOnSingleResult(assigned)) .andExpect(applySelfLinkMatcherOnSingleResult(DISTRIBUTIONSETTAGS_ROOT + assigned.getId())) @@ -176,7 +180,7 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt @Test @Description("Verifies that created DS tags are stored in the repository as send to the API.") @ExpectEvents({ @Expect(type = DistributionSetTagCreatedEvent.class, count = 2) }) - public void createDistributionSetTags() throws JSONException, Exception { + public void createDistributionSetTags() throws Exception { final Tag tagOne = entityFactory.tag().create().colour("testcol1").description("its a test1").name("thetest1") .build(); final Tag tagTwo = entityFactory.tag().create().colour("testcol2").description("its a test2").name("thetest2") @@ -186,7 +190,8 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt .perform(post(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING) .content(JsonBuilder.tags(Arrays.asList(tagOne, tagTwo))) .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isCreated()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)); final Tag createdOne = distributionSetTagManagement.findByRsql(PAGE, "name==thetest1").getContent().get(0); @@ -198,7 +203,8 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt assertThat(createdTwo.getDescription()).isEqualTo(tagTwo.getDescription()); assertThat(createdTwo.getColour()).isEqualTo(tagTwo.getColour()); - result.andExpect(applyTagMatcherOnArrayResult(createdOne)).andExpect(applyTagMatcherOnArrayResult(createdTwo)); + result.andExpect(applyTagMatcherOnArrayResult(createdOne)) + .andExpect(applyTagMatcherOnArrayResult(createdTwo)); } @Test @@ -216,7 +222,8 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt .perform(put(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/" + original.getId()) .content(JsonBuilder.tag(update)).contentType(MediaType.APPLICATION_JSON) .accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)); final Tag updated = distributionSetTagManagement.findByRsql(PAGE, "name==updatedName").getContent().get(0); @@ -224,7 +231,8 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt assertThat(updated.getDescription()).isEqualTo(update.getDescription()); assertThat(updated.getColour()).isEqualTo(update.getColour()); - result.andExpect(applyTagMatcherOnArrayResult(updated)).andExpect(applyTagMatcherOnArrayResult(updated)); + result.andExpect(applyTagMatcherOnArrayResult(updated)) + .andExpect(applyTagMatcherOnArrayResult(updated)); } @Test @@ -236,7 +244,8 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt final DistributionSetTag original = tags.get(0); mvc.perform(delete(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/" + original.getId())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()); assertThat(distributionSetTagManagement.get(original.getId())).isNotPresent(); } @@ -253,7 +262,8 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt distributionSetManagement.assignTag(sets.stream().map(BaseEntity::getId).collect(Collectors.toList()), tag.getId()); mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned")) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(setsAssigned))) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_SIZE, equalTo(setsAssigned))) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(setsAssigned))); @@ -273,7 +283,8 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned") .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(limitSize))) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(setsAssigned))) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_SIZE, equalTo(limitSize))) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(limitSize))); @@ -296,7 +307,8 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned") .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(offsetParam)) .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(setsAssigned))) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(setsAssigned))) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_SIZE, equalTo(expectedSize))) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(expectedSize))); @@ -346,7 +358,8 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt mvc.perform(post(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned/" + set.getId())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()); final List updated = distributionSetManagement.findByTag(PAGE, tag.getId()).getContent(); assertThat(updated.stream().map(DistributionSet::getId).collect(Collectors.toList())) @@ -367,7 +380,8 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt put(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned") .content(JsonBuilder.toArray(sets.stream().map(DistributionSet::getId).collect(Collectors.toList()))) .contentType(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()); final List updated = distributionSetManagement.findByTag(PAGE, tag.getId()).getContent(); assertThat(updated.stream().map(DistributionSet::getId).collect(Collectors.toList())) @@ -390,7 +404,8 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt mvc.perform(delete(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned/" + unassigned.getId())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()); final List updated = distributionSetManagement.findByTag(PAGE, tag.getId()).getContent(); assertThat(updated.stream().map(DistributionSet::getId).collect(Collectors.toList())) @@ -415,7 +430,8 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt mvc.perform(delete(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned") .content(JsonBuilder.toArray(List.of(unassigned0.getId(), unassigned1.getId()))) .contentType(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()); final List updated = distributionSetManagement.findByTag(PAGE, tag.getId()).getContent(); assertThat(updated.stream().map(DistributionSet::getId).collect(Collectors.toList())) @@ -478,7 +494,8 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt .content(JsonBuilder .ids(sets.stream().map(DistributionSet::getId).collect(Collectors.toList()))) .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)); final List updated = distributionSetManagement.findByTag(PAGE, tag.getId()).getContent(); @@ -498,7 +515,8 @@ public class MgmtDistributionSetTagResourceTest extends AbstractManagementApiInt + "/assigned/toggleTagAssignment").content( JsonBuilder.ids(sets.stream().map(DistributionSet::getId).collect(Collectors.toList()))) .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)); } } diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeResourceTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeResourceTest.java index 9795f86d8..266535e08 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeResourceTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeResourceTest.java @@ -60,7 +60,6 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn @WithUser(principal = "uploadTester", allSpPermissions = true) @Description("Checks the correct behaviour of /rest/v1/distributionsettypes GET requests.") public void getDistributionSetTypes() throws Exception { - DistributionSetType testType = distributionSetTypeManagement.create(entityFactory.distributionSetType().create() .key("test123").name("TestName123").description("Desc123").colour("col12")); testType = distributionSetTypeManagement @@ -69,7 +68,8 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn // 4 types overall (2 hawkbit tenant default, 1 test default and 1 // generated in this test) mvc.perform(get("/rest/v1/distributionsettypes").accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$.content.[?(@.key=='" + standardDsType.getKey() + "')].name", contains(standardDsType.getName()))) @@ -104,8 +104,10 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn // descending mvc.perform(get("/rest/v1/distributionsettypes").accept(MediaType.APPLICATION_JSON) - .param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "KEY:DESC")).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "KEY:DESC")) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$.content.[0].id", equalTo(testType.getId().intValue()))) .andExpect(jsonPath("$.content.[0].name", equalTo("TestName123"))) .andExpect(jsonPath("$.content.[0].description", equalTo("Desc1234"))) @@ -119,8 +121,10 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn // ascending mvc.perform(get("/rest/v1/distributionsettypes").accept(MediaType.APPLICATION_JSON) - .param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "KEY:ASC")).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "KEY:ASC")) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$.content.[4].id", equalTo(testType.getId().intValue()))) .andExpect(jsonPath("$.content.[4].name", equalTo("TestName123"))) .andExpect(jsonPath("$.content.[4].description", equalTo("Desc1234"))) @@ -155,7 +159,8 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn mvc.perform(post("/rest/v1/distributionsettypes/{dstID}/mandatorymoduletypes", testType.getId()) .content("{\"id\":" + osType.getId() + "}").contentType(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()); testType = distributionSetTypeManagement.get(testType.getId()).get(); assertThat(testType.getLastModifiedBy()).isEqualTo("uploadTester"); @@ -174,7 +179,8 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn mvc.perform(post("/rest/v1/distributionsettypes/{dstID}/optionalmoduletypes", testType.getId()) .content("{\"id\":" + osType.getId() + "}").contentType(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()); testType = distributionSetTypeManagement.get(testType.getId()).get(); assertThat(testType.getLastModifiedBy()).isEqualTo("uploadTester"); @@ -188,7 +194,6 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn @WithUser(principal = "uploadTester", allSpPermissions = true) @Description("Verifies quota enforcement for /rest/v1/distributionsettypes/{ID}/optionalmoduletypes POST requests.") public void assignModuleTypesToDistributionSetTypeUntilQuotaExceeded() throws Exception { - // create software module types final int maxSoftwareModuleTypes = quotaManagement.getMaxSoftwareModuleTypesPerDistributionSetType(); final List moduleTypeIds = new ArrayList<>(); @@ -207,12 +212,14 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn for (int i = 0; i < moduleTypeIds.size() - 1; ++i) { mvc.perform(post("/rest/v1/distributionsettypes/{dstID}/optionalmoduletypes", testType.getId()) .content("{\"id\":" + moduleTypeIds.get(i) + "}").contentType(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()); } mvc.perform(post("/rest/v1/distributionsettypes/{dstID}/optionalmoduletypes", testType.getId()) .content("{\"id\":" + moduleTypeIds.get(moduleTypeIds.size() - 1) + "}") - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isForbidden()) .andExpect(jsonPath("$.exceptionClass", equalTo(AssignmentQuotaExceededException.class.getName()))) .andExpect(jsonPath("$.errorCode", equalTo(SpServerError.SP_QUOTA_EXCEEDED.getKey()))); @@ -226,16 +233,17 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn for (int i = 0; i < moduleTypeIds.size() - 1; ++i) { mvc.perform(post("/rest/v1/distributionsettypes/{dstID}/mandatorymoduletypes", testType2.getId()) .content("{\"id\":" + moduleTypeIds.get(i) + "}").contentType(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()); } mvc.perform(post("/rest/v1/distributionsettypes/{dstID}/mandatorymoduletypes", testType2.getId()) .content("{\"id\":" + moduleTypeIds.get(moduleTypeIds.size() - 1) + "}") - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isForbidden()) .andExpect(jsonPath("$.exceptionClass", equalTo(AssignmentQuotaExceededException.class.getName()))) .andExpect(jsonPath("$.errorCode", equalTo(SpServerError.SP_QUOTA_EXCEEDED.getKey()))); - } @Test @@ -245,11 +253,14 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn final DistributionSetType testType = generateTestType(); mvc.perform(get("/rest/v1/distributionsettypes/{dstID}/mandatorymoduletypes", testType.getId()) - .accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .accept(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("[0].name", equalTo(osType.getName()))) .andExpect(jsonPath("[0].description", equalTo(osType.getDescription()))) - .andExpect(jsonPath("[0].maxAssignments", equalTo(1))).andExpect(jsonPath("[0].key", equalTo("os"))); + .andExpect(jsonPath("[0].maxAssignments", equalTo(1))) + .andExpect(jsonPath("[0].key", equalTo("os"))); } @Test @@ -259,7 +270,9 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn final DistributionSetType testType = generateTestType(); mvc.perform(get("/rest/v1/distributionsettypes/{dstID}/optionalmoduletypes", testType.getId()) - .accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .accept(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("[0].name", equalTo(appType.getName()))) .andExpect(jsonPath("[0].description", equalTo(appType.getDescription()))) @@ -274,8 +287,10 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn final DistributionSetType testType = generateTestType(); mvc.perform(get("/rest/v1/distributionsettypes/{dstID}/mandatorymoduletypes/{smtId}", testType.getId(), - osType.getId()).contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isOk()).andExpect(jsonPath("$.id", equalTo(osType.getId().intValue()))) + osType.getId()).contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.id", equalTo(osType.getId().intValue()))) .andExpect(jsonPath("$.name", equalTo(osType.getName()))) .andExpect(jsonPath("$.description", equalTo(osType.getDescription()))) .andExpect(jsonPath("$.createdBy", equalTo(osType.getCreatedBy()))) @@ -291,8 +306,10 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn final DistributionSetType testType = generateTestType(); mvc.perform(get("/rest/v1/distributionsettypes/{dstID}/optionalmoduletypes/{smtId}", testType.getId(), - appType.getId()).contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isOk()).andExpect(jsonPath("$.id", equalTo(appType.getId().intValue()))) + appType.getId()).contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.id", equalTo(appType.getId().intValue()))) .andExpect(jsonPath("$.name", equalTo(appType.getName()))) .andExpect(jsonPath("$.description", equalTo(appType.getDescription()))) .andExpect(jsonPath("$.createdBy", equalTo(appType.getCreatedBy()))) @@ -308,7 +325,8 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn DistributionSetType testType = generateTestType(); mvc.perform(delete("/rest/v1/distributionsettypes/{dstID}/mandatorymoduletypes/{smtId}", testType.getId(), - osType.getId()).contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + osType.getId()).contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); testType = distributionSetTypeManagement.get(testType.getId()).get(); @@ -325,7 +343,8 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn DistributionSetType testType = generateTestType(); mvc.perform(delete("/rest/v1/distributionsettypes/{dstID}/optionalmoduletypes/{smtId}", testType.getId(), - appType.getId()).contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + appType.getId()).contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); testType = distributionSetTypeManagement.get(testType.getId()).get(); @@ -339,14 +358,14 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn @WithUser(principal = "uploadTester", allSpPermissions = true) @Description("Checks the correct behaviour of /rest/v1/distributionsettypes/{ID} GET requests.") public void getDistributionSetType() throws Exception { - DistributionSetType testType = distributionSetTypeManagement.create(entityFactory.distributionSetType().create() .key("test123").name("TestName123").description("Desc123")); testType = distributionSetTypeManagement .update(entityFactory.distributionSetType().update(testType.getId()).description("Desc1234")); mvc.perform(get("/rest/v1/distributionsettypes/{dstId}", testType.getId()).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$.name", equalTo("TestName123"))) .andExpect(jsonPath("$.description", equalTo("Desc1234"))) @@ -376,7 +395,8 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn assertThat(distributionSetTypeManagement.count()).isEqualTo(DEFAULT_DS_TYPES + 1); mvc.perform(delete("/rest/v1/distributionsettypes/{dsId}", testType.getId())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()); assertThat(distributionSetTypeManagement.count()).isEqualTo(DEFAULT_DS_TYPES); } @@ -384,7 +404,8 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn @Test @Description("Ensures that DS type deletion request to API on an entity that does not exist results in NOT_FOUND.") public void deleteDistributionSetTypeThatDoesNotExistLeadsToNotFound() throws Exception { - mvc.perform(delete("/rest/v1/distributionsettypes/1234")).andDo(MockMvcResultPrinter.print()) + mvc.perform(delete("/rest/v1/distributionsettypes/1234")) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNotFound()); } @@ -401,14 +422,19 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn assertThat(distributionSetTypeManagement.count()).isEqualTo(DEFAULT_DS_TYPES + 1); assertThat(distributionSetManagement.count()).isEqualTo(1); - mvc.perform(get("/rest/v1/distributionsettypes/{dstId}", testType.getId())).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isOk()).andExpect(jsonPath("$.deleted", equalTo(false))); + mvc.perform(get("/rest/v1/distributionsettypes/{dstId}", testType.getId())) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.deleted", equalTo(false))); mvc.perform(delete("/rest/v1/distributionsettypes/{dstId}", testType.getId())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()); - mvc.perform(get("/rest/v1/distributionsettypes/{dstId}", testType.getId())).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isOk()).andExpect(jsonPath("$.deleted", equalTo(true))); + mvc.perform(get("/rest/v1/distributionsettypes/{dstId}", testType.getId())) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.deleted", equalTo(true))); assertThat(distributionSetManagement.count()).isEqualTo(1); assertThat(distributionSetTypeManagement.count()).isEqualTo(DEFAULT_DS_TYPES); @@ -425,11 +451,14 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn .put("name", "nameShouldNotBeChanged").toString(); mvc.perform(put("/rest/v1/distributionsettypes/{smId}", testType.getId()).content(body) - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath("$.id", equalTo(testType.getId().intValue()))) .andExpect(jsonPath("$.description", equalTo("foobardesc"))) .andExpect(jsonPath("$.colour", equalTo("updatedColour"))) - .andExpect(jsonPath("$.name", equalTo("TestName123"))).andReturn(); + .andExpect(jsonPath("$.name", equalTo("TestName123"))) + .andReturn(); } @Test @@ -457,7 +486,9 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn final String body = new JSONObject().put("id", testType.getId()).put("deleted", true).toString(); mvc.perform(put("/rest/v1/distributionsettypes/{dstId}", testType.getId()).content(body) - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath("$.id", equalTo(testType.getId().intValue()))) .andExpect(jsonPath("$.deleted", equalTo(false))); } @@ -468,7 +499,8 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn // 4 types overall (3 hawkbit tenant default, 1 test default final int types = 4; - mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING)).andDo(MockMvcResultPrinter.print()) + mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(types))) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_SIZE, equalTo(types))) @@ -483,7 +515,8 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn final int limitSize = 1; mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING) .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(limitSize))) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(types))) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_SIZE, equalTo(limitSize))) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(limitSize))); @@ -492,14 +525,14 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn @Test @Description("Checks the correct behaviour of /rest/v1/distributionsettypes GET requests with paging.") public void getDistributionSetTypesWithPagingLimitAndOffsetRequestParameter() throws Exception { - final int types = DEFAULT_DS_TYPES; final int offsetParam = 2; final int expectedSize = types - offsetParam; mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING) .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(offsetParam)) .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(types))) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(types))) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_SIZE, equalTo(expectedSize))) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(expectedSize))); @@ -512,85 +545,108 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn .create(entityFactory.softwareModuleType().create().key("test123").name("TestName123")); // DST does not exist - mvc.perform(get("/rest/v1/distributionsettypes/12345678")).andDo(MockMvcResultPrinter.print()) + mvc.perform(get("/rest/v1/distributionsettypes/12345678")) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNotFound()); mvc.perform(get("/rest/v1/distributionsettypes/12345678/mandatorymoduletypes")) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isNotFound()); mvc.perform(get("/rest/v1/distributionsettypes/12345678/optionalmoduletypes")) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isNotFound()); - mvc.perform(delete("/rest/v1/distributionsettypes/12345678")).andDo(MockMvcResultPrinter.print()) + mvc.perform(delete("/rest/v1/distributionsettypes/12345678")) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNotFound()); // Module types incorrect mvc.perform(get("/rest/v1/distributionsettypes/" + standardDsType.getId() + "/mandatorymoduletypes")) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()); mvc.perform(get("/rest/v1/distributionsettypes/" + standardDsType.getId() + "/mandatorymoduletypes/565765656")) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isNotFound()); mvc.perform(get("/rest/v1/distributionsettypes/" + standardDsType.getId() + "/optionalmoduletypes/565765656")) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isNotFound()); mvc.perform(get( "/rest/v1/distributionsettypes/" + standardDsType.getId() + "/mandatorymoduletypes/" + osType.getId())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()); mvc.perform(get("/rest/v1/distributionsettypes/" + standardDsType.getId() + "/mandatorymoduletypes/" - + testSmType.getId())).andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound()); + + testSmType.getId())) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isNotFound()); mvc.perform(get( "/rest/v1/distributionsettypes/" + standardDsType.getId() + "/optionalmoduletypes/" + osType.getId())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isNotFound()); mvc.perform(get( "/rest/v1/distributionsettypes/" + standardDsType.getId() + "/optionalmoduletypes/" + appType.getId())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()); mvc.perform(get("/rest/v1/distributionsettypes/" + standardDsType.getId() + "/optionalmoduletypes/" - + testSmType.getId())).andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound()); + + testSmType.getId())) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isNotFound()); // Modules types at creation time invalid final DistributionSetType testNewType = entityFactory.distributionSetType().create().key("test123") - .name("TestName123").description("Desc123").colour("col").mandatory(Arrays.asList(osType.getId())) + .name("TestName123").description("Desc123").colour("col").mandatory(Collections.singletonList(osType.getId())) .optional(Collections.emptyList()).build(); mvc.perform(post("/rest/v1/distributionsettypes") - .content(JsonBuilder.distributionSetTypes(Arrays.asList(testNewType))) - .contentType(MediaType.APPLICATION_OCTET_STREAM)).andDo(MockMvcResultPrinter.print()) + .content(JsonBuilder.distributionSetTypes(Collections.singletonList(testNewType))) + .contentType(MediaType.APPLICATION_OCTET_STREAM)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isUnsupportedMediaType()); // bad request - no content mvc.perform(post("/rest/v1/distributionsettypes").contentType(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isBadRequest()); // bad request - bad content mvc.perform(post("/rest/v1/distributionsettypes").content("sdfjsdlkjfskdjf".getBytes()) - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isBadRequest()); // Missing mandatory field name mvc.perform(post("/rest/v1/distributionsettypes").content("[{\"description\":\"Desc123\",\"key\":\"test123\"}]") - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isBadRequest()); final DistributionSetType toLongName = entityFactory.distributionSetType().create().key("test123") .name(RandomStringUtils.randomAlphanumeric(NamedEntity.NAME_MAX_SIZE + 1)).build(); mvc.perform(post("/rest/v1/distributionsettypes") - .content(JsonBuilder.distributionSetTypes(Arrays.asList(toLongName))) - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .content(JsonBuilder.distributionSetTypes(Collections.singletonList(toLongName))) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isBadRequest()); // not allowed methods - mvc.perform(put("/rest/v1/distributionsettypes")).andDo(MockMvcResultPrinter.print()) + mvc.perform(put("/rest/v1/distributionsettypes")) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isMethodNotAllowed()); - mvc.perform(delete("/rest/v1/distributionsettypes")).andDo(MockMvcResultPrinter.print()) + mvc.perform(delete("/rest/v1/distributionsettypes")) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isMethodNotAllowed()); mvc.perform(put("/rest/v1/distributionsettypes/" + standardDsType.getId() + "/mandatorymoduletypes")) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isMethodNotAllowed()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isMethodNotAllowed()); mvc.perform(put( "/rest/v1/distributionsettypes/" + standardDsType.getId() + "/optionalmoduletypes/" + osType.getId())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isMethodNotAllowed()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isMethodNotAllowed()); } @Test @@ -603,9 +659,12 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn final String rsqlFindLikeDs1OrDs2 = "name==TestName123,name==TestName1234"; - mvc.perform(get("/rest/v1/distributionsettypes?q=" + rsqlFindLikeDs1OrDs2)).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isOk()).andExpect(jsonPath("size", equalTo(2))) - .andExpect(jsonPath("total", equalTo(2))).andExpect(jsonPath("content[0].name", equalTo("TestName123"))) + mvc.perform(get("/rest/v1/distributionsettypes?q=" + rsqlFindLikeDs1OrDs2)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("size", equalTo(2))) + .andExpect(jsonPath("total", equalTo(2))) + .andExpect(jsonPath("content[0].name", equalTo("TestName123"))) .andExpect(jsonPath("content[1].name", equalTo("TestName1234"))); } @@ -638,7 +697,8 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn return mvc .perform(post("/rest/v1/distributionsettypes").content(JsonBuilder.distributionSetTypes(types)) .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isCreated()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("[0].name", equalTo("TestName1"))) .andExpect(jsonPath("[0].key", equalTo("testKey1"))) @@ -653,7 +713,8 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn .andExpect(jsonPath("[2].key", equalTo("testKey3"))) .andExpect(jsonPath("[2].description", equalTo("Desc3"))) .andExpect(jsonPath("[2].createdBy", equalTo("uploadTester"))) - .andExpect(jsonPath("[2].createdAt", not(equalTo(0)))).andReturn(); + .andExpect(jsonPath("[2].createdAt", not(equalTo(0)))) + .andReturn(); } @Step @@ -662,8 +723,8 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn return Arrays.asList( entityFactory.distributionSetType().create().key("testKey1").name("TestName1").description("Desc1") - .colour("col").mandatory(Arrays.asList(osType.getId())) - .optional(Arrays.asList(runtimeType.getId())).build(), + .colour("col").mandatory(Collections.singletonList(osType.getId())) + .optional(Collections.singletonList(runtimeType.getId())).build(), entityFactory.distributionSetType().create().key("testKey2").name("TestName2").description("Desc2") .colour("col").optional(Arrays.asList(runtimeType.getId(), osType.getId(), appType.getId())) .build(), @@ -674,7 +735,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn private DistributionSetType generateTestType() { final DistributionSetType testType = distributionSetTypeManagement.create(entityFactory.distributionSetType() .create().key("test123").name("TestName123").description("Desc123").colour("col") - .mandatory(Arrays.asList(osType.getId())).optional(Arrays.asList(appType.getId()))); + .mandatory(Collections.singletonList(osType.getId())).optional(Collections.singletonList(appType.getId()))); assertThat(testType.getOptLockRevision()).isEqualTo(1); assertThat(testType.getOptionalModuleTypes()).containsExactly(appType); assertThat(testType.getMandatoryModuleTypes()).containsExactly(osType); @@ -690,5 +751,4 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn character++; } } - -} +} \ No newline at end of file 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 7f640b51c..1c3dd3e27 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 @@ -89,10 +89,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { @Autowired private RolloutManagement rolloutManagement; - @Autowired private RolloutGroupManagement rolloutGroupManagement; - @Autowired private RolloutTestApprovalStrategy approvalStrategy; @@ -196,12 +194,15 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { rolloutHandler.handleAll(); - mvc.perform(get("/rest/v1/rollouts/{rolloutid}", rollout.getId())).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isOk()).andExpect(jsonPath("$.status", equalTo("waiting_for_approval"))); + mvc.perform(get("/rest/v1/rollouts/{rolloutid}", rollout.getId())) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.status", equalTo("waiting_for_approval"))); rolloutManagement.approveOrDeny(rollout.getId(), Rollout.ApprovalDecision.APPROVED, remark); - mvc.perform(get("/rest/v1/rollouts/{rolloutid}", rollout.getId())).andDo(MockMvcResultPrinter.print()) + mvc.perform(get("/rest/v1/rollouts/{rolloutid}", rollout.getId())) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("$.status", equalTo("ready"))) .andExpect(jsonPath("$.approvalRemark", equalTo(remark))) @@ -250,7 +251,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { } //retry rollout - mvc.perform(post("/rest/v1/rollouts/{rolloutId}/retry", rollout.getId())).andDo(MockMvcResultPrinter.print()) + mvc.perform(post("/rest/v1/rollouts/{rolloutId}/retry", rollout.getId())) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().is(201)); //search for _retried suffix @@ -292,14 +294,16 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { // no scheduler so invoke here rolloutHandler.handleAll(); - mvc.perform(post("/rest/v1/rollouts/{rolloutId}/retry", rollout.getId())).andDo(MockMvcResultPrinter.print()) + mvc.perform(post("/rest/v1/rollouts/{rolloutId}/retry", rollout.getId())) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isBadRequest()); } @Test @Description("Retrying a non-existing rollout should lead to NOT FOUND.") public void retryNonExistingRolloutShouldLeadToNotFound() throws Exception { - mvc.perform(post("/rest/v1/rollouts/{rolloutId}/retry", 6782623)).andDo(MockMvcResultPrinter.print()) + mvc.perform(post("/rest/v1/rollouts/{rolloutId}/retry", 6782623)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNotFound()); } @@ -307,7 +311,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { @Description("Testing that creating rollout with wrong body returns bad request") void createRolloutWithInvalidBodyReturnsBadRequest() throws Exception { mvc.perform(post("/rest/v1/rollouts").content("invalid body").contentType(MediaType.APPLICATION_JSON) - .accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .accept(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isBadRequest()) .andExpect(jsonPath("errorCode", equalTo("hawkbit.server.error.rest.body.notReadable"))); } @@ -320,7 +325,9 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { mvc.perform(post("/rest/v1/rollouts") .content(JsonBuilder.rollout("name", "desc", 10, dsA.getId(), "name==test", null)) .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().is(403)).andReturn(); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().is(403)) + .andReturn(); } @Test @@ -328,7 +335,9 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { void createRolloutWithNotExistingDistributionSetReturnsNotFound() throws Exception { mvc.perform(post("/rest/v1/rollouts").content(JsonBuilder.rollout("name", "desc", 10, 1234, "name==test", null)) .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound()).andReturn(); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isNotFound()) + .andReturn(); } @Test @@ -338,7 +347,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { mvc.perform(post("/rest/v1/rollouts") .content(JsonBuilder.rollout("name", "desc", 5, dsA.getId(), "name=test", null)) .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isBadRequest()) .andExpect(jsonPath("errorCode", equalTo("hawkbit.server.error.rest.param.rsqlParamSyntax"))) .andReturn(); } @@ -353,7 +363,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { mvc.perform(post("/rest/v1/rollouts") .content(JsonBuilder.rollout("rollout1", "desc", 10, dsA.getId(), targetFilterQuery, null)) .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isBadRequest()) .andExpect(jsonPath("errorCode", equalTo("hawkbit.server.error.rest.param.rsqlParamSyntax"))) .andReturn(); @@ -380,7 +391,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { testdataFactory.createDistributionSet("ds").getId(), "id==target*", new RolloutGroupConditionBuilder().withDefaults().build())) .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isForbidden()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isForbidden()) .andExpect(jsonPath("$.exceptionClass", equalTo(AssignmentQuotaExceededException.class.getName()))) .andExpect(jsonPath("$.errorCode", equalTo(SpServerError.SP_QUOTA_EXCEEDED.getKey()))); @@ -398,7 +410,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { testdataFactory.createDistributionSet("ds").getId(), "id==target*", new RolloutGroupConditionBuilder().withDefaults().build())) .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isForbidden()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isForbidden()) .andExpect(jsonPath("$.exceptionClass", equalTo(AssignmentQuotaExceededException.class.getName()))) .andExpect(jsonPath("$.errorCode", equalTo(SpServerError.SP_QUOTA_EXCEEDED.getKey()))); @@ -427,7 +440,9 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { .content(JsonBuilder.rolloutWithGroups("rollout2", "desc", null, dsA.getId(), "id==ro-target*", rolloutGroupConditions, rolloutGroups)) .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated()).andReturn(); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isCreated()) + .andReturn(); } @@ -450,9 +465,11 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { rolloutHandler.handleAll(); mvc.perform(get("/rest/v1/rollouts?representation=full").accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) - .andExpect(jsonPath("$.content", hasSize(1))).andExpect(jsonPath("$.total", equalTo(1))) + .andExpect(jsonPath("$.content", hasSize(1))) + .andExpect(jsonPath("$.total", equalTo(1))) .andExpect(jsonPath("content[0].id", equalTo(rollout.getId().intValue()))) .andExpect(jsonPath("content[0].name", equalTo("rollout1"))) .andExpect(jsonPath("content[0].status", equalTo("running"))) @@ -489,9 +506,11 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { } mvc.perform(get("/rest/v1/rollouts?representation=full").accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) - .andExpect(jsonPath("$.content", hasSize(1))).andExpect(jsonPath("$.total", equalTo(1))) + .andExpect(jsonPath("$.content", hasSize(1))) + .andExpect(jsonPath("$.total", equalTo(1))) .andExpect(jsonPath("content[0].id", equalTo(rollout.getId().intValue()))) .andExpect(jsonPath("content[0].name", equalTo("rollout1"))) .andExpect(jsonPath("content[0].status", equalTo("running"))) @@ -530,7 +549,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { .content(JsonBuilder.rolloutWithGroups("rollout4", "desc", null, dsA.getId(), "id==ro-target*", rolloutGroupConditions, rolloutGroups)) .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isBadRequest()) .andExpect(jsonPath("$.errorCode", equalTo("hawkbit.server.error.repo.constraintViolation"))); } @@ -555,7 +575,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { .content(JsonBuilder.rolloutWithGroups("rollout4", "desc", null, dsA.getId(), "id==ro-target*", rolloutGroupConditions, rolloutGroups)) .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isBadRequest()) .andExpect(jsonPath("$.errorCode", equalTo("hawkbit.server.error.repo.constraintViolation"))); } @@ -579,7 +600,9 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { mvc.perform(put("/rest/v1/rollouts/" + rollout.getId()).content( new JSONObject().put("name", "newName").put("description", "newDesc").toString() ).contentType(MediaType.APPLICATION_JSON) - .accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .accept(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath("$.name", equalTo("newName"))) .andExpect(jsonPath("$.description", equalTo("newDesc"))); } @@ -587,9 +610,12 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { @Test @Description("Testing the empty list is returned if no rollout exists") void noRolloutReturnsEmptyList() throws Exception { - mvc.perform(get("/rest/v1/rollouts").accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) - .andExpect(jsonPath("$.content", hasSize(0))).andExpect(jsonPath("$.total", equalTo(0))); + mvc.perform(get("/rest/v1/rollouts").accept(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(jsonPath("$.content", hasSize(0))) + .andExpect(jsonPath("$.total", equalTo(0))); } @Test @@ -630,9 +656,11 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { // request the list of rollouts with full representation mvc.perform(get("/rest/v1/rollouts?representation=full").accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) - .andExpect(jsonPath("$.content", hasSize(1))).andExpect(jsonPath("$.total", equalTo(1))) + .andExpect(jsonPath("$.content", hasSize(1))) + .andExpect(jsonPath("$.total", equalTo(1))) .andExpect(jsonPath("content[0].id", equalTo(rollout.getId().intValue()))) .andExpect(jsonPath("content[0].name", equalTo("rollout1"))) .andExpect(jsonPath("content[0].status", equalTo("running"))) @@ -676,9 +704,11 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { // request the list of rollouts with full representation mvc.perform(get("/rest/v1/rollouts?q=name==rollout1&representation=full").accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) - .andExpect(jsonPath("$.content", hasSize(1))).andExpect(jsonPath("$.total", equalTo(1))) + .andExpect(jsonPath("$.content", hasSize(1))) + .andExpect(jsonPath("$.total", equalTo(1))) .andExpect(jsonPath("content[0].id", equalTo(rollout.getId().intValue()))) .andExpect(jsonPath("content[0].name", equalTo("rollout1"))) .andExpect(jsonPath("content[0].status", equalTo("running"))) @@ -716,7 +746,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { .successCondition(RolloutGroupSuccessCondition.THRESHOLD, "100").build()); mvc.perform(get("/rest/v1/rollouts/" + rollout.getId()).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$.id", equalTo(rollout.getId().intValue()))) .andExpect(jsonPath("$.confirmationRequired").doesNotExist()); @@ -768,7 +799,9 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { .content(JsonBuilder.rollout("rollout2", "desc", null, dsA.getId(), "id==ro-target*", rolloutGroupConditions, rolloutGroups, null, null, null, null, false)) .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated()).andReturn(); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isCreated()) + .andReturn(); final List content = rolloutManagement.findAll(PAGE, false).getContent(); assertThat(content).hasSize(1).allSatisfy(rollout -> { @@ -809,7 +842,9 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { .content(JsonBuilder.rollout("rollout2", "desc", null, dsA.getId(), "id==ro-target*", rolloutGroupConditions, rolloutGroups, null, null, null, null, null)) .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated()).andReturn(); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isCreated()) + .andReturn(); final List content = rolloutManagement.findAll(PAGE, false).getContent(); assertThat(content).hasSize(1).allSatisfy(rollout -> { @@ -839,9 +874,12 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { // Run here, because Scheduler is disabled during tests rolloutHandler.handleAll(); - mvc.perform(get("/rest/v1/rollouts").accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) - .andExpect(jsonPath("$.content", hasSize(2))).andExpect(jsonPath("$.total", equalTo(2))) + mvc.perform(get("/rest/v1/rollouts").accept(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(jsonPath("$.content", hasSize(2))) + .andExpect(jsonPath("$.total", equalTo(2))) .andExpect(jsonPath("content[0].name", equalTo("rollout1"))) .andExpect(jsonPath("content[0].status", equalTo("ready"))) .andExpect(jsonPath("content[0].targetFilterQuery", equalTo("id==target*"))) @@ -917,9 +955,11 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { rolloutHandler.handleAll(); mvc.perform(get("/rest/v1/rollouts?limit=1").accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) - .andExpect(jsonPath("$.content", hasSize(1))).andExpect(jsonPath("$.total", equalTo(2))); + .andExpect(jsonPath("$.content", hasSize(1))) + .andExpect(jsonPath("$.total", equalTo(2))); } @ParameterizedTest @@ -943,9 +983,11 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { // retrieve rollout groups from created rollout mvc.perform( get("/rest/v1/rollouts/{rolloutId}/deploygroups", rollout.getId()).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) - .andExpect(jsonPath("$.content", hasSize(4))).andExpect(jsonPath("$.total", equalTo(4))) + .andExpect(jsonPath("$.content", hasSize(4))) + .andExpect(jsonPath("$.total", equalTo(4))) .andExpect(jsonPath("$.content[0].status", equalTo("ready"))) .andExpect(jsonPath("$.content[1].status", equalTo("ready"))) .andExpect(jsonPath("$.content[2].status", equalTo("ready"))) @@ -988,7 +1030,9 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { // make request for firstGroupId and the rolloutId of the second rollout (the one with no groups) mvc.perform(get("/rest/v1/rollouts/{rolloutId}/deploygroups/{groupId}", rollout2.getId(), firstGroup.getId()) - .accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound()); + .accept(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isNotFound()); } @Test @@ -1003,12 +1047,14 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { final Rollout rollout = createRollout("rollout1", 4, dsA.getId(), "controllerId==rollout*"); // starting rollout - mvc.perform(post("/rest/v1/rollouts/{rolloutId}/start", rollout.getId())).andDo(MockMvcResultPrinter.print()) + mvc.perform(post("/rest/v1/rollouts/{rolloutId}/start", rollout.getId())) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); // check rollout is in starting state mvc.perform(get("/rest/v1/rollouts/{rolloutId}", rollout.getId()).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("id", equalTo(rollout.getId().intValue()))) .andExpect(jsonPath("status", equalTo("starting"))); @@ -1018,7 +1064,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { // check rollout is in running state mvc.perform(get("/rest/v1/rollouts/{rolloutId}", rollout.getId()).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("id", equalTo(rollout.getId().intValue()))) .andExpect(jsonPath("status", equalTo("running"))); @@ -1036,19 +1083,22 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { final Rollout rollout = createRollout("rollout1", 4, dsA.getId(), "controllerId==rollout*"); // starting rollout - mvc.perform(post("/rest/v1/rollouts/{rolloutId}/start", rollout.getId())).andDo(MockMvcResultPrinter.print()) + mvc.perform(post("/rest/v1/rollouts/{rolloutId}/start", rollout.getId())) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); // Run here, because scheduler is disabled during tests rolloutHandler.handleAll(); // pausing rollout - mvc.perform(post("/rest/v1/rollouts/{rolloutId}/pause", rollout.getId())).andDo(MockMvcResultPrinter.print()) + mvc.perform(post("/rest/v1/rollouts/{rolloutId}/pause", rollout.getId())) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); // check rollout is in running state mvc.perform(get("/rest/v1/rollouts/{rolloutId}", rollout.getId()).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("id", equalTo(rollout.getId().intValue()))) .andExpect(jsonPath("status", equalTo("paused"))); @@ -1066,23 +1116,27 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { final Rollout rollout = createRollout("rollout1", 4, dsA.getId(), "controllerId==rollout*"); // starting rollout - mvc.perform(post("/rest/v1/rollouts/{rolloutId}/start", rollout.getId())).andDo(MockMvcResultPrinter.print()) + mvc.perform(post("/rest/v1/rollouts/{rolloutId}/start", rollout.getId())) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); // Run here, because scheduler is disabled during tests rolloutHandler.handleAll(); // pausing rollout - mvc.perform(post("/rest/v1/rollouts/{rolloutId}/pause", rollout.getId())).andDo(MockMvcResultPrinter.print()) + mvc.perform(post("/rest/v1/rollouts/{rolloutId}/pause", rollout.getId())) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); // resume rollout - mvc.perform(post("/rest/v1/rollouts/{rolloutId}/resume", rollout.getId())).andDo(MockMvcResultPrinter.print()) + mvc.perform(post("/rest/v1/rollouts/{rolloutId}/resume", rollout.getId())) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); // check rollout is in running state mvc.perform(get("/rest/v1/rollouts/{rolloutId}", rollout.getId()).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("id", equalTo(rollout.getId().intValue()))) .andExpect(jsonPath("status", equalTo("running"))); @@ -1100,14 +1154,16 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { final Rollout rollout = createRollout("rollout1", 4, dsA.getId(), "controllerId==rollout*"); // starting rollout - mvc.perform(post("/rest/v1/rollouts/{rolloutId}/start", rollout.getId())).andDo(MockMvcResultPrinter.print()) + mvc.perform(post("/rest/v1/rollouts/{rolloutId}/start", rollout.getId())) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); // Run here, because scheduler is disabled during tests rolloutHandler.handleAll(); // starting rollout - already started should lead into bad request - mvc.perform(post("/rest/v1/rollouts/{rolloutId}/start", rollout.getId())).andDo(MockMvcResultPrinter.print()) + mvc.perform(post("/rest/v1/rollouts/{rolloutId}/start", rollout.getId())) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isBadRequest()) .andExpect(jsonPath("errorCode", equalTo("hawkbit.server.error.rollout.illegalstate"))); } @@ -1124,7 +1180,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { final Rollout rollout = createRollout("rollout1", 4, dsA.getId(), "controllerId==rollout*"); // resume not yet started rollout - mvc.perform(post("/rest/v1/rollouts/{rolloutId}/resume", rollout.getId())).andDo(MockMvcResultPrinter.print()) + mvc.perform(post("/rest/v1/rollouts/{rolloutId}/resume", rollout.getId())) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isBadRequest()) .andExpect(jsonPath("errorCode", equalTo("hawkbit.server.error.rollout.illegalstate"))); } @@ -1141,7 +1198,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { final Rollout rollout = createRollout("rollout1", 2, dsA.getId(), "controllerId==rollout*"); // starting rollout - mvc.perform(post("/rest/v1/rollouts/{rolloutId}/start", rollout.getId())).andDo(MockMvcResultPrinter.print()) + mvc.perform(post("/rest/v1/rollouts/{rolloutId}/start", rollout.getId())) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); // Run here, because scheduler is disabled during tests @@ -1150,9 +1208,12 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { // retrieve rollout groups from created rollout - 2 groups exists // (amountTargets / groupSize = 2) mvc.perform(get("/rest/v1/rollouts/{rolloutId}/deploygroups?sort=ID:ASC", rollout.getId()) - .accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .accept(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) - .andExpect(jsonPath("$.content", hasSize(2))).andExpect(jsonPath("$.total", equalTo(2))) + .andExpect(jsonPath("$.content", hasSize(2))) + .andExpect(jsonPath("$.total", equalTo(2))) .andExpect(jsonPath("$.content[0].status", equalTo("running"))) .andExpect(jsonPath("$.content[1].status", equalTo("scheduled"))); } @@ -1207,9 +1268,11 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { mvc.perform( get("/rest/v1/rollouts/{rolloutId}/deploygroups/{groupId}/targets", rollout.getId(), firstGroup.getId()) .accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) - .andExpect(jsonPath("$.content", hasSize(5))).andExpect(jsonPath("$.total", equalTo(5))); + .andExpect(jsonPath("$.content", hasSize(5))) + .andExpect(jsonPath("$.total", equalTo(5))); } @Test @@ -1233,9 +1296,11 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { mvc.perform( get("/rest/v1/rollouts/{rolloutId}/deploygroups/{groupId}/targets", rollout.getId(), firstGroup.getId()) .accept(MediaType.APPLICATION_JSON).param("q", "controllerId==" + targetInGroup)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) - .andExpect(jsonPath("$.content", hasSize(1))).andExpect(jsonPath("$.total", equalTo(1))); + .andExpect(jsonPath("$.content", hasSize(1))) + .andExpect(jsonPath("$.total", equalTo(1))); } @Test @@ -1261,9 +1326,11 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { mvc.perform( get("/rest/v1/rollouts/{rolloutId}/deploygroups/{groupId}/targets", rollout.getId(), firstGroup.getId()) .accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) - .andExpect(jsonPath("$.content", hasSize(5))).andExpect(jsonPath("$.total", equalTo(5))); + .andExpect(jsonPath("$.content", hasSize(5))) + .andExpect(jsonPath("$.total", equalTo(5))); } @Test @@ -1278,7 +1345,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { final Rollout rollout = createRollout("rollout1", 4, dsA.getId(), "controllerId==rollout*"); // starting rollout - mvc.perform(post("/rest/v1/rollouts/{rolloutId}/start", rollout.getId())).andDo(MockMvcResultPrinter.print()) + mvc.perform(post("/rest/v1/rollouts/{rolloutId}/start", rollout.getId())) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); // Run here, because scheduler is disabled during tests @@ -1298,7 +1366,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { // create rollout including the created targets with prefix 'rollout' final Rollout rollout = createRollout("rolloutDelete", 4, dsA.getId(), "controllerId==rolloutDelete*"); - mvc.perform(delete("/rest/v1/rollouts/{rolloutid}", rollout.getId())).andDo(MockMvcResultPrinter.print()) + mvc.perform(delete("/rest/v1/rollouts/{rolloutid}", rollout.getId())) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); assertStatusIs(rollout, RolloutStatus.DELETING); @@ -1309,8 +1378,10 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { void deleteRunningRollout() throws Exception { final Rollout rollout = testdataFactory.createSoftDeletedRollout("softDeletedRollout"); - mvc.perform(get("/rest/v1/rollouts/{rolloutid}", rollout.getId())).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isOk()).andExpect(jsonPath("$.deleted", equalTo(true))); + mvc.perform(get("/rest/v1/rollouts/{rolloutid}", rollout.getId())) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.deleted", equalTo(true))); assertStatusIs(rollout, RolloutStatus.DELETED); } @@ -1335,21 +1406,29 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { createRollout("other1", 5, dsA.getId(), "controllerId==other1*"); mvc.perform(get("/rest/v1/rollouts").param(MgmtRestConstants.REQUEST_PARAMETER_SEARCH, "name==*2") - .accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .accept(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) - .andExpect(jsonPath("$.content", hasSize(1))).andExpect(jsonPath("$.total", equalTo(1))) + .andExpect(jsonPath("$.content", hasSize(1))) + .andExpect(jsonPath("$.total", equalTo(1))) .andExpect(jsonPath("$.content[0].name", equalTo(rollout2.getName()))); mvc.perform(get("/rest/v1/rollouts").accept(MediaType.APPLICATION_JSON) .param(MgmtRestConstants.REQUEST_PARAMETER_SEARCH, "name==rollout*")) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) - .andExpect(jsonPath("$.content", hasSize(3))).andExpect(jsonPath("$.total", equalTo(3))); + .andExpect(jsonPath("$.content", hasSize(3))) + .andExpect(jsonPath("$.total", equalTo(3))); mvc.perform(get("/rest/v1/rollouts").accept(MediaType.APPLICATION_JSON) - .param(MgmtRestConstants.REQUEST_PARAMETER_SEARCH, "name==*1")).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) - .andExpect(jsonPath("$.content", hasSize(2))).andExpect(jsonPath("$.total", equalTo(2))); + .param(MgmtRestConstants.REQUEST_PARAMETER_SEARCH, "name==*1")) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(jsonPath("$.content", hasSize(2))) + .andExpect(jsonPath("$.total", equalTo(2))); } @@ -1367,24 +1446,30 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { // retrieve rollout groups from created rollout mvc.perform(get("/rest/v1/rollouts/{rolloutId}/deploygroups", rollout.getId()) .accept(MediaType.APPLICATION_JSON).param(MgmtRestConstants.REQUEST_PARAMETER_SEARCH, "name==group-1")) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) - .andExpect(jsonPath("$.content", hasSize(1))).andExpect(jsonPath("$.total", equalTo(1))) + .andExpect(jsonPath("$.content", hasSize(1))) + .andExpect(jsonPath("$.total", equalTo(1))) .andExpect(jsonPath("$.content[0].name", equalTo("group-1"))) .andExpect(jsonPath("$.content[0].totalTargetsPerStatus").doesNotExist()); mvc.perform(get("/rest/v1/rollouts/{rolloutId}/deploygroups", rollout.getId()) .accept(MediaType.APPLICATION_JSON).param(MgmtRestConstants.REQUEST_PARAMETER_SEARCH, "name==group*")) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) - .andExpect(jsonPath("$.content", hasSize(4))).andExpect(jsonPath("$.total", equalTo(4))); + .andExpect(jsonPath("$.content", hasSize(4))) + .andExpect(jsonPath("$.total", equalTo(4))); mvc.perform( get("/rest/v1/rollouts/{rolloutId}/deploygroups", rollout.getId()).accept(MediaType.APPLICATION_JSON) .param(MgmtRestConstants.REQUEST_PARAMETER_SEARCH, "name==group-1,name==group-2")) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) - .andExpect(jsonPath("$.content", hasSize(2))).andExpect(jsonPath("$.total", equalTo(2))) + .andExpect(jsonPath("$.content", hasSize(2))) + .andExpect(jsonPath("$.total", equalTo(2))) .andExpect(jsonPath("$.content[0].totalTargetsPerStatus").doesNotExist()) .andExpect(jsonPath("$.content[1].totalTargetsPerStatus").doesNotExist()); @@ -1412,9 +1497,12 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { // filter for the first group by RSQL mvc.perform(get("/rest/v1/rollouts/{rolloutId}/deploygroups", rollout.getId()) .accept(MediaType.APPLICATION_JSON).param(MgmtRestConstants.REQUEST_PARAMETER_SEARCH, "name==group-1") - .param("representation", "full")).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .param("representation", "full")) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) - .andExpect(jsonPath("$.content", hasSize(1))).andExpect(jsonPath("$.total", equalTo(1))) + .andExpect(jsonPath("$.content", hasSize(1))) + .andExpect(jsonPath("$.total", equalTo(1))) .andExpect(jsonPath("$.content[0].name", equalTo("group-1"))) .andExpect(jsonPath("content[0].totalTargetsPerStatus").exists()) .andExpect(jsonPath("content[0].totalTargetsPerStatus.running", equalTo(5))) @@ -1450,15 +1538,18 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { new RolloutGroupConditionBuilder().withDefaults().build(), null, null, weight, null, null, null); mvc.perform(post("/rest/v1/rollouts").content(valideWeightRequest).contentType(MediaType.APPLICATION_JSON) - .accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .accept(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isCreated()); enableMultiAssignments(); mvc.perform(post("/rest/v1/rollouts").content(invalideWeightRequest).contentType(MediaType.APPLICATION_JSON) - .accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .accept(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isBadRequest()) .andExpect(jsonPath("$.errorCode", equalTo("hawkbit.server.error.repo.constraintViolation"))); mvc.perform(post("/rest/v1/rollouts").content(valideWeightRequestMultiAssignment).contentType(MediaType.APPLICATION_JSON) - .accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .accept(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isCreated()); final List rollouts = rolloutManagement.findAll(PAGE, false).getContent(); @@ -1479,7 +1570,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { rolloutHandler.handleAll(); mvc.perform(post("/rest/v1/rollouts/{rolloutId}/triggerNextGroup", rollout.getId())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()); final List groupStatus = rolloutGroupManagement.findByRollout(PAGE, rollout.getId()) .getContent().stream().map(RolloutGroup::getStatus).collect(Collectors.toList()); @@ -1536,17 +1628,20 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { rolloutHandler.handleAll(); mvc.perform(get("/rest/v1/rollouts/" + rollout.getId()).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$.id", equalTo(rollout.getId().intValue()))) - .andExpect(jsonPath("$.name", equalTo("rollout1"))).andExpect(jsonPath("$.status", equalTo("running"))) + .andExpect(jsonPath("$.name", equalTo("rollout1"))) + .andExpect(jsonPath("$.status", equalTo("running"))) .andExpect(jsonPath("$.totalTargetsPerStatus.running", equalTo(5))) .andExpect(jsonPath("$.totalTargetsPerStatus.notstarted", equalTo(0))) .andExpect(jsonPath("$.totalTargetsPerStatus.scheduled", equalTo(15))) .andExpect(jsonPath("$.totalTargetsPerStatus.cancelled", equalTo(0))) .andExpect(jsonPath("$.totalTargetsPerStatus.finished", equalTo(0))) .andExpect(jsonPath("$.totalTargetsPerStatus.error", equalTo(0))) - .andExpect(jsonPath("$.deleted", equalTo(false))).andExpect(jsonPath("$.totalGroups", equalTo(4))); + .andExpect(jsonPath("$.deleted", equalTo(false))) + .andExpect(jsonPath("$.totalGroups", equalTo(4))); } @Step @@ -1554,17 +1649,20 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { rolloutManagement.start(rollout.getId()); mvc.perform(get("/rest/v1/rollouts/" + rollout.getId()).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$.id", equalTo(rollout.getId().intValue()))) - .andExpect(jsonPath("$.name", equalTo("rollout1"))).andExpect(jsonPath("$.status", equalTo("starting"))) + .andExpect(jsonPath("$.name", equalTo("rollout1"))) + .andExpect(jsonPath("$.status", equalTo("starting"))) .andExpect(jsonPath("$.totalTargetsPerStatus.running", equalTo(0))) .andExpect(jsonPath("$.totalTargetsPerStatus.notstarted", equalTo(20))) .andExpect(jsonPath("$.totalTargetsPerStatus.scheduled", equalTo(0))) .andExpect(jsonPath("$.totalTargetsPerStatus.cancelled", equalTo(0))) .andExpect(jsonPath("$.totalTargetsPerStatus.finished", equalTo(0))) .andExpect(jsonPath("$.totalTargetsPerStatus.error", equalTo(0))) - .andExpect(jsonPath("$.deleted", equalTo(false))).andExpect(jsonPath("$.totalGroups", equalTo(4))); + .andExpect(jsonPath("$.deleted", equalTo(false))) + .andExpect(jsonPath("$.totalGroups", equalTo(4))); } @Step @@ -1572,10 +1670,12 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { rolloutHandler.handleAll(); mvc.perform(get("/rest/v1/rollouts/" + rollout.getId()).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$.id", equalTo(rollout.getId().intValue()))) - .andExpect(jsonPath("$.name", equalTo("rollout1"))).andExpect(jsonPath("$.status", equalTo("ready"))) + .andExpect(jsonPath("$.name", equalTo("rollout1"))) + .andExpect(jsonPath("$.status", equalTo("ready"))) .andExpect(jsonPath("$.lastModifiedBy", equalTo("bumlux"))) .andExpect(jsonPath("$.lastModifiedAt", not(equalTo(0)))) .andExpect(jsonPath("$.totalTargetsPerStatus.running", equalTo(0))) @@ -1584,16 +1684,19 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { .andExpect(jsonPath("$.totalTargetsPerStatus.cancelled", equalTo(0))) .andExpect(jsonPath("$.totalTargetsPerStatus.finished", equalTo(0))) .andExpect(jsonPath("$.totalTargetsPerStatus.error", equalTo(0))) - .andExpect(jsonPath("$.deleted", equalTo(false))).andExpect(jsonPath("$.totalGroups", equalTo(4))); + .andExpect(jsonPath("$.deleted", equalTo(false))) + .andExpect(jsonPath("$.totalGroups", equalTo(4))); } @Step private void retrieveAndVerifyRolloutInCreating(final DistributionSet dsA, final Rollout rollout) throws Exception { mvc.perform(get("/rest/v1/rollouts/" + rollout.getId()).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$.id", equalTo(rollout.getId().intValue()))) - .andExpect(jsonPath("$.name", equalTo("rollout1"))).andExpect(jsonPath("$.status", equalTo("creating"))) + .andExpect(jsonPath("$.name", equalTo("rollout1"))) + .andExpect(jsonPath("$.status", equalTo("creating"))) .andExpect(jsonPath("$.targetFilterQuery", equalTo("controllerId==rollout*"))) .andExpect(jsonPath("$.distributionSetId", equalTo(dsA.getId().intValue()))) .andExpect(jsonPath("$.createdBy", equalTo("bumlux"))) @@ -1616,7 +1719,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { allOf(startsWith(HREF_ROLLOUT_PREFIX), endsWith("/triggerNextGroup")))) .andExpect(jsonPath("$._links.groups.href", allOf(startsWith(HREF_ROLLOUT_PREFIX), containsString("/deploygroups")))) - .andExpect(jsonPath("$.deleted", equalTo(false))).andExpect(jsonPath("$.totalGroups", equalTo(4))); + .andExpect(jsonPath("$.deleted", equalTo(false))) + .andExpect(jsonPath("$.totalGroups", equalTo(4))); } @Step @@ -1626,7 +1730,9 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { rolloutManagement.start(rollout.getId()); rolloutHandler.handleAll(); mvc.perform(get("/rest/v1/rollouts/{rolloutId}/deploygroups/{groupId}", rollout.getId(), firstGroup.getId()) - .accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .accept(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("status", equalTo("running"))) .andExpect(jsonPath("$.totalTargetsPerStatus.running", equalTo(5))) @@ -1639,7 +1745,9 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { : jsonPath("confirmationRequired").doesNotExist()); mvc.perform(get("/rest/v1/rollouts/{rolloutId}/deploygroups/{groupId}", rollout.getId(), secondGroup.getId()) - .accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .accept(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("status", equalTo("scheduled"))) .andExpect(jsonPath("$.totalTargetsPerStatus.running", equalTo(0))) @@ -1650,7 +1758,6 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { .andExpect(jsonPath("$.totalTargetsPerStatus.error", equalTo(0))) .andExpect(isConfirmationFlowEnabled() ? jsonPath("confirmationRequired", equalTo(confirmationRequired)) : jsonPath("confirmationRequired").doesNotExist()); - ; } @Step @@ -1658,7 +1765,9 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { throws Exception { rolloutHandler.handleAll(); mvc.perform(get("/rest/v1/rollouts/{rolloutId}/deploygroups/{groupId}", rollout.getId(), firstGroup.getId()) - .accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .accept(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("status", equalTo("ready"))) .andExpect(jsonPath("$.lastModifiedBy", equalTo("bumlux"))) @@ -1672,7 +1781,6 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { .andExpect(jsonPath("$.totalTargetsPerStatus.error", equalTo(0))) .andExpect(isConfirmationFlowEnabled() ? jsonPath("confirmationRequired").exists() : jsonPath("confirmationRequired").doesNotExist()); - ; } @Step @@ -1680,12 +1788,14 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { throws Exception { mvc.perform(get("/rest/v1/rollouts/{rolloutId}/deploygroups/{groupId}", rollout.getId(), firstGroup.getId()) .accept(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("id", equalTo(firstGroup.getId().intValue()))) .andExpect(isConfirmationFlowEnabled() ? jsonPath("confirmationRequired").exists() : jsonPath("confirmationRequired").doesNotExist()) - .andExpect(jsonPath("status", equalTo("creating"))).andExpect(jsonPath("name", endsWith("1"))) + .andExpect(jsonPath("status", equalTo("creating"))) + .andExpect(jsonPath("name", endsWith("1"))) .andExpect(jsonPath("description", endsWith("1"))) .andExpect(jsonPath("$.targetFilterQuery", equalTo(""))) .andExpect(jsonPath("$.targetPercentage", equalTo(25.0))) @@ -1745,8 +1855,11 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { null, isDynamic, dynamicGroupSuffix, dynamicGroupTargetsCount); mvc.perform(post("/rest/v1/rollouts").content(rollout).contentType(MediaType.APPLICATION_JSON) - .accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated()) - .andExpect(jsonPath("$.name", equalTo(name))).andExpect(jsonPath("$.status", equalTo("creating"))) + .accept(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isCreated()) + .andExpect(jsonPath("$.name", equalTo(name))) + .andExpect(jsonPath("$.status", equalTo("creating"))) .andExpect(jsonPath("$.type", equalTo(actionType))) .andExpect(jsonPath("$.targetFilterQuery", equalTo(targetFilterQuery))) .andExpect(jsonPath("$.description", equalTo("desc"))) @@ -1796,7 +1909,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { private void triggerNextGroupAndExpect(final Rollout rollout, final ResultMatcher expect) throws Exception { mvc.perform(post("/rest/v1/rollouts/{rolloutId}/triggerNextGroup", rollout.getId())) - .andDo(MockMvcResultPrinter.print()).andExpect(expect); + .andDo(MockMvcResultPrinter.print()) + .andExpect(expect); } private void setTargetsStatus(final List targets, final Status status) { @@ -1820,9 +1934,12 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { private void retrieveAndCompareRolloutsContent(final DistributionSet dsA, final String urlTemplate, final boolean isFullRepresentation, final boolean isStartTypeScheduled, final Long startAt, final Long forcetime) throws Exception { - mvc.perform(get(urlTemplate).accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) - .andExpect(jsonPath("$.content", hasSize(2))).andExpect(jsonPath("$.total", equalTo(2))) + mvc.perform(get(urlTemplate).accept(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(jsonPath("$.content", hasSize(2))) + .andExpect(jsonPath("$.total", equalTo(2))) .andExpect(jsonPath("content[0].name", equalTo("rollout1"))) .andExpect(jsonPath("content[0].status", equalTo("ready"))) .andExpect(jsonPath("content[0].targetFilterQuery", equalTo("id==target*"))) @@ -1910,5 +2027,4 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { : jsonPath("content[1]._links.distributionset.href").doesNotExist()) .andExpect(jsonPath("content[1]._links.self.href", startsWith(HREF_ROLLOUT_PREFIX))); } - -} +} \ No newline at end of file diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResourceTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResourceTest.java index 7d237b973..ec99ffe54 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResourceTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResourceTest.java @@ -15,6 +15,7 @@ import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.hasSize; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; @@ -89,7 +90,8 @@ import org.springframework.web.bind.annotation.RestController; */ @Feature("Component Tests - Management API") @Story("Software Module Resource") -@TestPropertySource(properties = { "hawkbit.server.security.dos.maxArtifactSize=100000", +@TestPropertySource(properties = { + "hawkbit.server.security.dos.maxArtifactSize=100000", "hawkbit.server.security.dos.maxArtifactStorage=500000" }) class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTest { @@ -167,7 +169,8 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes } mvc.perform(get(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/metadata", - module.getId())).andDo(MockMvcResultPrinter.print()) + module.getId())) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(content().contentType(MediaTypes.HAL_JSON)); } @@ -425,7 +428,8 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes // try to upload mvc.perform(multipart("/rest/v1/softwaremodules/{smId}/artifacts", sm.getId()).file(file) - .accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .accept(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isForbidden()) .andExpect(jsonPath("$.exceptionClass", equalTo(FileSizeQuotaExceededException.class.getName()))) .andExpect(jsonPath("$.errorCode", equalTo(SpServerError.SP_FILE_SIZE_QUOTA_EXCEEDED.getKey()))); @@ -475,15 +479,19 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes final MockMultipartFile file = new MockMultipartFile("file", "orig", null, random); mvc.perform(multipart("/rest/v1/softwaremodules/{smId}/artifacts", sm.getId()).file(file) - .accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated()) + .accept(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isCreated()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$.hashes.md5", equalTo(md5sum))) .andExpect(jsonPath("$.hashes.sha1", equalTo(sha1sum))) .andExpect(jsonPath("$.hashes.sha256", equalTo(sha256sum))) - .andExpect(jsonPath("$.providedFilename", equalTo("orig"))).andExpect(status().isCreated()); + .andExpect(jsonPath("$.providedFilename", equalTo("orig"))) + .andExpect(status().isCreated()); mvc.perform(multipart("/rest/v1/softwaremodules/{smId}/artifacts", sm.getId()).file(file)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isConflict()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isConflict()); } @Test @@ -531,7 +539,9 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes MvcResult mvcResult = mvc .perform(multipart("/rest/v1/softwaremodules/{smId}/artifacts", sm.getId()).file(file) .param("md5sum", md5sum).param("sha1sum", "afsdff").param("sha256sum", sha256sum)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()).andReturn(); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isBadRequest()) + .andReturn(); // check error result ExceptionInfo exceptionInfo = ResourceUtility.convertException(mvcResult.getResponse().getContentAsString()); @@ -542,7 +552,9 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes mvcResult = mvc .perform(multipart("/rest/v1/softwaremodules/{smId}/artifacts", sm.getId()).file(file) .param("md5sum", md5sum).param("sha1sum", sha1sum).param("sha256sum", "jdshfsd")) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()).andReturn(); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isBadRequest()) + .andReturn(); // check error result exceptionInfo = ResourceUtility.convertException(mvcResult.getResponse().getContentAsString()); @@ -553,7 +565,9 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes mvcResult = mvc .perform(multipart("/rest/v1/softwaremodules/{smId}/artifacts", sm.getId()).file(file) .param("md5sum", "sdfsdfs").param("sha1sum", sha1sum).param("sha256sum", sha256sum)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()).andReturn(); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isBadRequest()) + .andReturn(); // check error result exceptionInfo = ResourceUtility.convertException(mvcResult.getResponse().getContentAsString()); @@ -561,7 +575,8 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes .isEqualTo(SpServerError.SP_ARTIFACT_UPLOAD_FAILED_MD5_MATCH.getKey()); mvc.perform(multipart("/rest/v1/softwaremodules/{smId}/artifacts", sm.getId()).file(file) - .param("md5sum", md5sum).param("sha1sum", sha1sum)).andDo(MockMvcResultPrinter.print()) + .param("md5sum", md5sum).param("sha1sum", sha1sum)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isCreated()); assertArtifact(sm, random); @@ -584,13 +599,16 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes // upload mvc.perform(multipart("/rest/v1/softwaremodules/{smId}/artifacts", sm.getId()).file(file) - .accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isCreated()).andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .accept(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isCreated()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$.hashes.md5", equalTo(md5sum))) .andExpect(jsonPath("$.hashes.sha1", equalTo(sha1sum))) .andExpect(jsonPath("$.hashes.sha256", equalTo(sha256sum))) .andExpect(jsonPath("$.size", equalTo(random.length))) - .andExpect(jsonPath("$.providedFilename", equalTo("origFilename" + i))).andReturn(); + .andExpect(jsonPath("$.providedFilename", equalTo("origFilename" + i))) + .andReturn(); } // upload one more file to cause the quota to be exceeded @@ -599,7 +617,8 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes // upload mvc.perform(multipart("/rest/v1/softwaremodules/{smId}/artifacts", sm.getId()).file(file) - .accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .accept(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isForbidden()) .andExpect(jsonPath("$.exceptionClass", equalTo(AssignmentQuotaExceededException.class.getName()))) .andExpect(jsonPath("$.errorCode", equalTo(SpServerError.SP_QUOTA_EXCEEDED.getKey()))); @@ -627,13 +646,16 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes // upload final SoftwareModule sm = testdataFactory.createSoftwareModuleOs("sm" + i); mvc.perform(multipart("/rest/v1/softwaremodules/{smId}/artifacts", sm.getId()).file(file) - .accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isCreated()).andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .accept(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isCreated()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$.hashes.md5", equalTo(md5sum))) .andExpect(jsonPath("$.hashes.sha1", equalTo(sha1sum))) .andExpect(jsonPath("$.hashes.sha256", equalTo(sha256sum))) .andExpect(jsonPath("$.size", equalTo(random.length))) - .andExpect(jsonPath("$.providedFilename", equalTo("origFilename" + i))).andReturn(); + .andExpect(jsonPath("$.providedFilename", equalTo("origFilename" + i))) + .andReturn(); } // upload one more file to cause the quota to be exceeded @@ -643,7 +665,8 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes // upload final SoftwareModule sm = testdataFactory.createSoftwareModuleOs("sm" + numArtifacts); mvc.perform(multipart("/rest/v1/softwaremodules/{smId}/artifacts", sm.getId()).file(file) - .accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .accept(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isForbidden()) .andExpect(jsonPath("$.exceptionClass", equalTo(StorageQuotaExceededException.class.getName()))) .andExpect(jsonPath("$.errorCode", equalTo(SpServerError.SP_STORAGE_QUOTA_EXCEEDED.getKey()))); @@ -677,14 +700,16 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes final SoftwareModule sm = testdataFactory.createSoftwareModuleOs(); final int artifactSize = 5 * 1024; - final byte random[] = randomBytes(artifactSize); + final byte[] random = randomBytes(artifactSize); final Artifact artifact = artifactManagement .create(new ArtifactUpload(new ByteArrayInputStream(random), sm.getId(), "file1", false, artifactSize)); // perform test mvc.perform(get("/rest/v1/softwaremodules/{smId}/artifacts/{artId}", sm.getId(), artifact.getId()) - .accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .accept(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$.id", equalTo(artifact.getId().intValue()))) .andExpect(jsonPath("$.size", equalTo(random.length))) @@ -708,7 +733,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes final SoftwareModule sm = testdataFactory.createSoftwareModuleOs(); final int artifactSize = 5 * 1024; - final byte random[] = randomBytes(artifactSize); + final byte[] random = randomBytes(artifactSize); final Artifact artifact = artifactManagement .create(new ArtifactUpload(new ByteArrayInputStream(random), sm.getId(), "file1", false, artifactSize)); @@ -716,7 +741,9 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes // perform test mvc.perform(get("/rest/v1/softwaremodules/{smId}/artifacts/{artId}", sm.getId(), artifact.getId()) .param("useartifacturlhandler", String.valueOf(useArtifactUrlHandler)) - .accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .accept(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$.id", equalTo(artifact.getId().intValue()))) .andExpect(jsonPath("$.size", equalTo(random.length))) @@ -812,7 +839,9 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes mvc.perform(get("/rest/v1/softwaremodules/{smId}/artifacts", sm.getId()) .param("representation", MgmtRepresentationMode.FULL.toString()) .param("useartifacturlhandler", String.valueOf(useArtifactUrlHandler)) - .accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .accept(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$.[0].id", equalTo(artifact.getId().intValue()))) .andExpect(jsonPath("$.[0].size", equalTo(random.length))) @@ -853,39 +882,48 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes final SoftwareModule smSoftDeleted = testdataFactory.createSoftwareModuleOs("softDeleted"); final Artifact artifactSoftDeleted = testdataFactory.createArtifacts(smSoftDeleted.getId()).get(0); - testdataFactory.createDistributionSet(Arrays.asList(smSoftDeleted)); + testdataFactory.createDistributionSet(List.of(smSoftDeleted)); softwareModuleManagement.delete(smSoftDeleted.getId()); // no artifact available mvc.perform(get("/rest/v1/softwaremodules/{smId}/artifacts/1234567/download", sm.getId())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isNotFound()); mvc.perform(delete("/rest/v1/softwaremodules/{smId}/artifacts/1234567", sm.getId())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isNotFound()); // SM does not exist artifactManagement .create(new ArtifactUpload(new ByteArrayInputStream(random), sm.getId(), "file1", false, artifactSize)); - mvc.perform(get("/rest/v1/softwaremodules/1234567890/artifacts")).andDo(MockMvcResultPrinter.print()) + mvc.perform(get("/rest/v1/softwaremodules/1234567890/artifacts")) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNotFound()); mvc.perform(multipart("/rest/v1/softwaremodules/1234567890/artifacts").file(file)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isNotFound()); // bad request - no content mvc.perform(multipart("/rest/v1/softwaremodules/{smId}/artifacts", sm.getId())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isBadRequest()); // not allowed methods - mvc.perform(put("/rest/v1/softwaremodules/{smId}/artifacts", sm.getId())).andDo(MockMvcResultPrinter.print()) + mvc.perform(put("/rest/v1/softwaremodules/{smId}/artifacts", sm.getId())) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isMethodNotAllowed()); - mvc.perform(delete("/rest/v1/softwaremodules/{smId}/artifacts", sm.getId())).andDo(MockMvcResultPrinter.print()) + mvc.perform(delete("/rest/v1/softwaremodules/{smId}/artifacts", sm.getId())) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isMethodNotAllowed()); // SM soft deleted mvc.perform(get("/rest/v1/softwaremodules/{smId}/artifacts/{artifactId}/download", smSoftDeleted.getId(), - artifactSoftDeleted.getId())).andDo(MockMvcResultPrinter.print()).andExpect(status().isGone()); + artifactSoftDeleted.getId())) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isGone()); } @Test @@ -895,7 +933,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes final SoftwareModule sm = testdataFactory.createSoftwareModuleOs(); final int artifactSize = 5 * 1024; - final byte random[] = RandomStringUtils.random(artifactSize).getBytes(); + final byte[] random = RandomStringUtils.random(artifactSize).getBytes(); // Create 2 artifacts final Artifact artifact = artifactManagement.create( @@ -927,7 +965,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes void invalidRequestsOnSoftwareModulesResource() throws Exception { final SoftwareModule sm = testdataFactory.createSoftwareModuleOs(); - final List modules = Arrays.asList(sm); + final List modules = Collections.singletonList(sm); // SM does not exist mvc.perform(get("/rest/v1/softwaremodules/12345678")) @@ -945,23 +983,27 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes // bad request - bad content mvc.perform(post("/rest/v1/softwaremodules").content("sdfjsdlkjfskdjf".getBytes()) - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isBadRequest()); mvc.perform(post("/rest/v1/softwaremodules") .content("[{\"description\":\"Desc123\",\"key\":\"test123\", \"type\":\"os\"}]") - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isBadRequest()); final SoftwareModule toLongName = entityFactory.softwareModule().create().type(osType) .name(RandomStringUtils.randomAlphanumeric(80)).build(); - mvc.perform(post("/rest/v1/softwaremodules").content(JsonBuilder.softwareModules(Arrays.asList(toLongName))) - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + mvc.perform(post("/rest/v1/softwaremodules").content(JsonBuilder.softwareModules(Collections.singletonList(toLongName))) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isBadRequest()); // unsupported media type mvc.perform(post("/rest/v1/softwaremodules").content(JsonBuilder.softwareModules(modules)) - .contentType(MediaType.APPLICATION_OCTET_STREAM)).andDo(MockMvcResultPrinter.print()) + .contentType(MediaType.APPLICATION_OCTET_STREAM)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isUnsupportedMediaType()); final SoftwareModule swm = entityFactory.softwareModule().create().name("encryptedModule").type(osType) @@ -970,13 +1012,16 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes mvc.perform( post("/rest/v1/softwaremodules").content(JsonBuilder.softwareModules(Collections.singletonList(swm))) .contentType(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isBadRequest()); // not allowed methods - mvc.perform(put("/rest/v1/softwaremodules")).andDo(MockMvcResultPrinter.print()) + mvc.perform(put("/rest/v1/softwaremodules")) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isMethodNotAllowed()); - mvc.perform(delete("/rest/v1/softwaremodules")).andDo(MockMvcResultPrinter.print()) + mvc.perform(delete("/rest/v1/softwaremodules")) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isMethodNotAllowed()); } @@ -1082,11 +1127,14 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes contains(os1.getDescription()))) .andExpect(jsonPath("$.content.[?(@.id==" + os1.getId() + ")].vendor", contains(os1.getVendor()))) .andExpect(jsonPath("$.content.[?(@.id==" + os1.getId() + ")].type", contains("os"))) - .andExpect(jsonPath("$.content", hasSize(1))).andExpect(jsonPath("$.total", equalTo(1))); + .andExpect(jsonPath("$.content", hasSize(1))) + .andExpect(jsonPath("$.total", equalTo(1))); // by type, 2 software modules per type exists mvc.perform(get("/rest/v1/softwaremodules?q=type==" + Constants.SMT_DEFAULT_APP_KEY) - .accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .accept(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$.content.[?(@.id==" + app1.getId() + ")].name", contains(app1.getName()))) .andExpect(jsonPath("$.content.[?(@.id==" + app1.getId() + ")].version", contains(app1.getVersion()))) @@ -1102,13 +1150,15 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes .andExpect(jsonPath("$.content.[?(@.id==" + app2.getId() + ")].vendor", contains(app2.getVendor()))) .andExpect(jsonPath("$.content.[?(@.id==" + app2.getId() + ")].type", contains(Constants.SMT_DEFAULT_APP_KEY))) - .andExpect(jsonPath("$.content", hasSize(2))).andExpect(jsonPath("$.total", equalTo(2))); + .andExpect(jsonPath("$.content", hasSize(2))) + .andExpect(jsonPath("$.total", equalTo(2))); // by type and version=2.0.0 -> only one result mvc.perform(get( "/rest/v1/softwaremodules?q=type==" + Constants.SMT_DEFAULT_APP_KEY + ";version==" + app1.getVersion()) .accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$.content.[?(@.id==" + app1.getId() + ")].name", contains(app1.getName()))) .andExpect(jsonPath("$.content.[?(@.id==" + app1.getId() + ")].version", contains(app1.getVersion()))) @@ -1117,7 +1167,8 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes .andExpect(jsonPath("$.content.[?(@.id==" + app1.getId() + ")].vendor", contains(app1.getVendor()))) .andExpect(jsonPath("$.content.[?(@.id==" + app1.getId() + ")].type", contains(Constants.SMT_DEFAULT_APP_KEY))) - .andExpect(jsonPath("$.content", hasSize(1))).andExpect(jsonPath("$.total", equalTo(1))); + .andExpect(jsonPath("$.content", hasSize(1))) + .andExpect(jsonPath("$.total", equalTo(1))); } @Test @@ -1247,7 +1298,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes final SoftwareModule sm = testdataFactory.createSoftwareModuleOs(); final int artifactSize = 5 * 1024; - final byte random[] = RandomStringUtils.random(artifactSize).getBytes(); + final byte[] random = RandomStringUtils.random(artifactSize).getBytes(); artifactManagement.create( new ArtifactUpload(new ByteArrayInputStream(random), sm.getId(), "file1", false, artifactSize)); @@ -1270,7 +1321,7 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes final DistributionSet ds1 = testdataFactory.createDistributionSet("a"); final int artifactSize = 5 * 1024; - final byte random[] = RandomStringUtils.random(artifactSize).getBytes(); + final byte[] random = RandomStringUtils.random(artifactSize).getBytes(); final Long appTypeSmId = ds1.findFirstModuleByType(appType).get().getId(); @@ -1280,14 +1331,19 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes assertThat(softwareModuleManagement.count()).isEqualTo(3); assertThat(artifactManagement.count()).isEqualTo(1); - mvc.perform(get("/rest/v1/softwaremodules/{smId}", appTypeSmId)).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isOk()).andExpect(jsonPath("$.deleted", equalTo(false))); + mvc.perform(get("/rest/v1/softwaremodules/{smId}", appTypeSmId)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.deleted", equalTo(false))); - mvc.perform(delete("/rest/v1/softwaremodules/{smId}", appTypeSmId)).andDo(MockMvcResultPrinter.print()) + mvc.perform(delete("/rest/v1/softwaremodules/{smId}", appTypeSmId)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); - mvc.perform(get("/rest/v1/softwaremodules/{smId}", appTypeSmId)).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isOk()).andExpect(jsonPath("$.deleted", equalTo(true))); + mvc.perform(get("/rest/v1/softwaremodules/{smId}", appTypeSmId)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.deleted", equalTo(true))); assertThat(softwareModuleManagement.count()).isEqualTo(2); assertThat(artifactManagement.count()).isEqualTo(1); @@ -1310,7 +1366,8 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes mvc.perform(post("/rest/v1/softwaremodules/{swId}/metadata", sm.getId()).accept(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON).content(metaData1.toString())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isCreated()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("[0].key", equalTo(knownKey1))) .andExpect(jsonPath("[0].value", equalTo(knownValue1))) @@ -1334,7 +1391,8 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes mvc.perform(post("/rest/v1/softwaremodules/{swId}/metadata", sm.getId()).accept(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON).content(metaData2.toString())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isForbidden()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isForbidden()); // verify that the number of meta data entries has not changed // (we cannot use the PAGE constant here as it tries to sort by ID) @@ -1408,7 +1466,8 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes .andExpect(status().isNotFound()); mvc.perform(delete("/rest/v1/softwaremodules/1234/metadata/{key}", knownKey)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isNotFound()); assertThat(softwareModuleManagement.getMetaDataBySoftwareModuleId(sm.getId(), knownKey)).isPresent(); } @@ -1439,8 +1498,11 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes final String rsqlSearchValue1 = "value==knownValue1"; mvc.perform(get("/rest/v1/softwaremodules/{swId}/metadata?q=" + rsqlSearchValue1, sm.getId())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()).andExpect(jsonPath("size", equalTo(1))) - .andExpect(jsonPath("total", equalTo(1))).andExpect(jsonPath("content[0].key", equalTo("knownKey1"))) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("size", equalTo(1))) + .andExpect(jsonPath("total", equalTo(1))) + .andExpect(jsonPath("content[0].key", equalTo("knownKey1"))) .andExpect(jsonPath("content[0].value", equalTo("knownValue1"))); } @@ -1482,10 +1544,12 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes final MvcResult result = mvc .perform( get("/rest/v1/softwaremodules/{smId}/artifacts/{artId}/download", sm.getId(), artifact.getId())) - .andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_OCTET_STREAM)) - .andExpect(header().string("ETag", artifact.getSha1Hash())).andReturn(); + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_OCTET_STREAM)) + .andExpect(header().string("ETag", artifact.getSha1Hash())) + .andReturn(); - assertTrue(Arrays.equals(result.getResponse().getContentAsByteArray(), random), "Wrong response content"); + assertArrayEquals(result.getResponse().getContentAsByteArray(), random, "Wrong response content"); } private void createSoftwareModulesAlphabetical(final int amount) { @@ -1497,5 +1561,4 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes character++; } } - -} +} \ No newline at end of file diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeResourceTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeResourceTest.java index 970212364..49021019d 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeResourceTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeResourceTest.java @@ -24,6 +24,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.List; import com.jayway.jsonpath.JsonPath; @@ -56,7 +57,8 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt final SoftwareModuleType testType = createTestType(); mvc.perform(get("/rest/v1/softwaremoduletypes").accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$.content.[?(@.key=='" + osType.getKey() + "')].name", contains(osType.getName()))) .andExpect(jsonPath("$.content.[?(@.key=='" + osType.getKey() + "')].description", @@ -115,7 +117,8 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt // descending mvc.perform(get("/rest/v1/softwaremoduletypes").accept(MediaType.APPLICATION_JSON) .param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "MAXASSIGNMENTS:DESC")) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$.content.[1].id", equalTo(testType.getId().intValue()))) .andExpect(jsonPath("$.content.[1].name", equalTo("TestName123"))) @@ -132,7 +135,8 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt // ascending mvc.perform(get("/rest/v1/softwaremoduletypes").accept(MediaType.APPLICATION_JSON) .param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "MAXASSIGNMENTS:ASC")) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$.content.[2].id", equalTo(testType.getId().intValue()))) .andExpect(jsonPath("$.content.[2].name", equalTo("TestName123"))) @@ -157,14 +161,16 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt mvc.perform(post("/rest/v1/softwaremoduletypes").content(JsonBuilder.softwareModuleTypes(types)) .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isBadRequest()); types.clear(); types.add(entityFactory.softwareModuleType().create().key("test0").name("TestName0").maxAssignments(0).build()); mvc.perform(post("/rest/v1/softwaremoduletypes").content(JsonBuilder.softwareModuleTypes(types)) .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isBadRequest()); } @Test @@ -183,21 +189,26 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt final MvcResult mvcResult = mvc .perform(post("/rest/v1/softwaremoduletypes").content(JsonBuilder.softwareModuleTypes(types)) .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isCreated()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) - .andExpect(jsonPath("[0].name", equalTo("TestName1"))).andExpect(jsonPath("[0].key", equalTo("test1"))) + .andExpect(jsonPath("[0].name", equalTo("TestName1"))) + .andExpect(jsonPath("[0].key", equalTo("test1"))) .andExpect(jsonPath("[0].description", equalTo("Desc1"))) .andExpect(jsonPath("[0].createdBy", equalTo("uploadTester"))) .andExpect(jsonPath("[0].maxAssignments", equalTo(1))) - .andExpect(jsonPath("[1].name", equalTo("TestName2"))).andExpect(jsonPath("[1].key", equalTo("test2"))) + .andExpect(jsonPath("[1].name", equalTo("TestName2"))) + .andExpect(jsonPath("[1].key", equalTo("test2"))) .andExpect(jsonPath("[1].description", equalTo("Desc2"))) .andExpect(jsonPath("[1].createdBy", equalTo("uploadTester"))) .andExpect(jsonPath("[1].maxAssignments", equalTo(2))) - .andExpect(jsonPath("[2].name", equalTo("TestName3"))).andExpect(jsonPath("[2].key", equalTo("test3"))) + .andExpect(jsonPath("[2].name", equalTo("TestName3"))) + .andExpect(jsonPath("[2].key", equalTo("test3"))) .andExpect(jsonPath("[2].description", equalTo("Desc3"))) .andExpect(jsonPath("[2].createdBy", equalTo("uploadTester"))) .andExpect(jsonPath("[2].createdAt", not(equalTo(0)))) - .andExpect(jsonPath("[2].maxAssignments", equalTo(3))).andReturn(); + .andExpect(jsonPath("[2].maxAssignments", equalTo(3))) + .andReturn(); final SoftwareModuleType created1 = softwareModuleTypeManagement.getByKey("test1").get(); final SoftwareModuleType created2 = softwareModuleTypeManagement.getByKey("test2").get(); @@ -223,7 +234,8 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt final SoftwareModuleType testType = createTestType(); mvc.perform(get("/rest/v1/softwaremoduletypes/{smtId}", testType.getId()).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$.name", equalTo("TestName123"))) .andExpect(jsonPath("$.description", equalTo("Desc1234"))) @@ -244,7 +256,8 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt assertThat(softwareModuleTypeManagement.count()).isEqualTo(4); - mvc.perform(delete("/rest/v1/softwaremoduletypes/{smId}", testType.getId())).andDo(MockMvcResultPrinter.print()) + mvc.perform(delete("/rest/v1/softwaremoduletypes/{smId}", testType.getId())) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); assertThat(softwareModuleTypeManagement.count()).isEqualTo(3); @@ -253,7 +266,8 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt @Test @Description("Ensures that module type deletion request to API on an entity that does not exist results in NOT_FOUND.") public void deleteSoftwareModuleTypeThatDoesNotExistLeadsToNotFound() throws Exception { - mvc.perform(delete("/rest/v1/softwaremoduletypes/1234")).andDo(MockMvcResultPrinter.print()) + mvc.perform(delete("/rest/v1/softwaremoduletypes/1234")) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNotFound()); } @@ -267,14 +281,19 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt assertThat(softwareModuleTypeManagement.count()).isEqualTo(4); - mvc.perform(get("/rest/v1/softwaremoduletypes/{smtId}", testType.getId())).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isOk()).andExpect(jsonPath("$.deleted", equalTo(false))); + mvc.perform(get("/rest/v1/softwaremoduletypes/{smtId}", testType.getId())) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.deleted", equalTo(false))); mvc.perform(delete("/rest/v1/softwaremoduletypes/{smtId}", testType.getId())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()); - mvc.perform(get("/rest/v1/softwaremoduletypes/{smtId}", testType.getId())).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isOk()).andExpect(jsonPath("$.deleted", equalTo(true))); + mvc.perform(get("/rest/v1/softwaremoduletypes/{smtId}", testType.getId())) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.deleted", equalTo(true))); assertThat(softwareModuleTypeManagement.count()).isEqualTo(3); } @@ -288,11 +307,14 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt .put("colour", "updatedColour").put("name", "nameShouldNotBeChanged").toString(); mvc.perform(put("/rest/v1/softwaremoduletypes/{smId}", testType.getId()).content(body) - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath("$.id", equalTo(testType.getId().intValue()))) .andExpect(jsonPath("$.description", equalTo("foobardesc"))) .andExpect(jsonPath("$.colour", equalTo("updatedColour"))) - .andExpect(jsonPath("$.name", equalTo("TestName123"))).andReturn(); + .andExpect(jsonPath("$.name", equalTo("TestName123"))) + .andReturn(); } @@ -304,7 +326,9 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt final String body = new JSONObject().put("id", testType.getId()).put("deleted", true).toString(); mvc.perform(put("/rest/v1/softwaremoduletypes/{smtId}", testType.getId()).content(body) - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath("$.id", equalTo(testType.getId().intValue()))) .andExpect(jsonPath("$.lastModifiedAt", equalTo(testType.getLastModifiedAt()))) .andExpect(jsonPath("$.deleted", equalTo(false))); @@ -318,7 +342,8 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt @Description("Checks the correct behaviour of /rest/v1/softwaremoduletypes GET requests with paging.") public void getSoftwareModuleTypesWithoutAddtionalRequestParameters() throws Exception { final int types = 3; - mvc.perform(get(MgmtRestConstants.SOFTWAREMODULETYPE_V1_REQUEST_MAPPING)).andDo(MockMvcResultPrinter.print()) + mvc.perform(get(MgmtRestConstants.SOFTWAREMODULETYPE_V1_REQUEST_MAPPING)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(types))) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_SIZE, equalTo(types))) @@ -332,7 +357,8 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt final int limitSize = 1; mvc.perform(get(MgmtRestConstants.SOFTWAREMODULETYPE_V1_REQUEST_MAPPING) .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(limitSize))) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(types))) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_SIZE, equalTo(limitSize))) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(limitSize))); @@ -347,7 +373,8 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt mvc.perform(get(MgmtRestConstants.SOFTWAREMODULETYPE_V1_REQUEST_MAPPING) .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(offsetParam)) .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(types))) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(types))) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_SIZE, equalTo(expectedSize))) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(expectedSize))); @@ -358,46 +385,55 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt public void invalidRequestsOnSoftwaremoduleTypesResource() throws Exception { final SoftwareModuleType testType = createTestType(); - final List types = Arrays.asList(testType); + final List types = Collections.singletonList(testType); // SM does not exist - mvc.perform(get("/rest/v1/softwaremoduletypes/12345678")).andDo(MockMvcResultPrinter.print()) + mvc.perform(get("/rest/v1/softwaremoduletypes/12345678")) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNotFound()); - mvc.perform(delete("/rest/v1/softwaremoduletypes/12345678")).andDo(MockMvcResultPrinter.print()) + mvc.perform(delete("/rest/v1/softwaremoduletypes/12345678")) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNotFound()); // bad request - no content mvc.perform(post("/rest/v1/softwaremoduletypes").contentType(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isBadRequest()); // bad request - bad content mvc.perform(post("/rest/v1/softwaremoduletypes").content("sdfjsdlkjfskdjf".getBytes()) - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isBadRequest()); mvc.perform(post("/rest/v1/softwaremoduletypes").content( "[{\"description\":\"Desc123\",\"id\":9223372036854775807,\"key\":\"test123\",\"maxAssignments\":5}]") - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isBadRequest()); final SoftwareModuleType toLongName = entityFactory.softwareModuleType().create().key("test123") .name(RandomStringUtils.randomAlphanumeric(NamedEntity.NAME_MAX_SIZE + 1)).build(); mvc.perform( - post("/rest/v1/softwaremoduletypes").content(JsonBuilder.softwareModuleTypes(Arrays.asList(toLongName))) + post("/rest/v1/softwaremoduletypes").content(JsonBuilder.softwareModuleTypes(Collections.singletonList(toLongName))) .contentType(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isBadRequest()); // unsupported media type mvc.perform(post("/rest/v1/softwaremoduletypes").content(JsonBuilder.softwareModuleTypes(types)) - .contentType(MediaType.APPLICATION_OCTET_STREAM)).andDo(MockMvcResultPrinter.print()) + .contentType(MediaType.APPLICATION_OCTET_STREAM)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isUnsupportedMediaType()); // not allowed methods - mvc.perform(put("/rest/v1/softwaremoduletypes")).andDo(MockMvcResultPrinter.print()) + mvc.perform(put("/rest/v1/softwaremoduletypes")) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isMethodNotAllowed()); - mvc.perform(delete("/rest/v1/softwaremoduletypes")).andDo(MockMvcResultPrinter.print()) + mvc.perform(delete("/rest/v1/softwaremoduletypes")) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isMethodNotAllowed()); } @@ -412,9 +448,12 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt final String rsqlFindLikeDs1OrDs2 = "name==TestName123,name==TestName1234"; - mvc.perform(get("/rest/v1/softwaremoduletypes?q=" + rsqlFindLikeDs1OrDs2)).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isOk()).andExpect(jsonPath("size", equalTo(2))) - .andExpect(jsonPath("total", equalTo(2))).andExpect(jsonPath("content[0].name", equalTo("TestName123"))) + mvc.perform(get("/rest/v1/softwaremoduletypes?q=" + rsqlFindLikeDs1OrDs2)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("size", equalTo(2))) + .andExpect(jsonPath("total", equalTo(2))) + .andExpect(jsonPath("content[0].name", equalTo("TestName123"))) .andExpect(jsonPath("content[1].name", equalTo("TestName1234"))); } 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 a8008dbe9..d2d4a852d 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 @@ -108,7 +108,8 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte @Description("Handles the GET request of retrieving all target filter queries within SP based by parameter. Required Permission: READ_TARGET.") public void getTargetFilterQueriesWithParameters() throws Exception { mvc.perform(get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "?limit=10&sort=name:ASC&offset=0&q=name==*1")) - .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()); + .andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()); } @Test @@ -152,7 +153,9 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte public void updateTargetWhichDoesNotExistsLeadsToEntityNotFound() throws Exception { final String notExistingId = "4395"; mvc.perform(put(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + notExistingId).content("{}") - .contentType(MediaType.APPLICATION_JSON)).andDo(print()).andExpect(status().isNotFound()); + .contentType(MediaType.APPLICATION_JSON)) + .andDo(print()) + .andExpect(status().isNotFound()); } @Test @@ -167,7 +170,9 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte final TargetFilterQuery tfq = createSingleTargetFilterQuery(filterName, filterQuery); mvc.perform(put(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + tfq.getId()).content(body) - .contentType(MediaType.APPLICATION_JSON)).andDo(print()).andExpect(status().isOk()) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(print()) + .andExpect(status().isOk()) .andExpect(jsonPath(JSON_PATH_ID, equalTo(tfq.getId().intValue()))) .andExpect(jsonPath(JSON_PATH_QUERY, equalTo(filterQuery2))) .andExpect(jsonPath(JSON_PATH_NAME, equalTo(filterName))) @@ -191,12 +196,13 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte .create(entityFactory.targetFilterQuery().create().name(filterName).query(filterQuery)); mvc.perform(put(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + tfq.getId()).content(body) - .contentType(MediaType.APPLICATION_JSON)).andDo(print()).andExpect(status().isOk()) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(print()) + .andExpect(status().isOk()) .andExpect(jsonPath(JSON_PATH_ID, equalTo(tfq.getId().intValue()))) .andExpect(jsonPath(JSON_PATH_QUERY, equalTo(filterQuery))) .andExpect(jsonPath(JSON_PATH_NAME, equalTo(filterName2))) .andExpect(jsonPath(JSON_PATH_CONFIRMATION_REQUIRED).doesNotExist()); - ; final TargetFilterQuery tfqCheck = targetFilterQueryManagement.get(tfq.getId()).get(); assertThat(tfqCheck.getQuery()).isEqualTo(filterQuery); @@ -216,7 +222,9 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte createSingleTargetFilterQuery(idB, testQuery); createSingleTargetFilterQuery(idC, testQuery); - mvc.perform(get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING)).andExpect(status().isOk()).andDo(print()) + mvc.perform(get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING)) + .andExpect(status().isOk()) + .andDo(print()) .andExpect(jsonPath(JSON_PATH_PAGED_LIST_TOTAL, equalTo(knownTargetAmount))) .andExpect(jsonPath(JSON_PATH_PAGED_LIST_SIZE, equalTo(knownTargetAmount))) .andExpect(jsonPath(JSON_PATH_PAGED_LIST_CONTENT, hasSize(knownTargetAmount))) @@ -247,7 +255,8 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte mvc.perform(get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING) .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(limitSize))) - .andExpect(status().isOk()).andDo(print()) + .andExpect(status().isOk()) + .andDo(print()) .andExpect(jsonPath(JSON_PATH_PAGED_LIST_TOTAL, equalTo(knownTargetAmount))) .andExpect(jsonPath(JSON_PATH_PAGED_LIST_SIZE, equalTo(limitSize))) .andExpect(jsonPath(JSON_PATH_PAGED_LIST_CONTENT, hasSize(limitSize))) @@ -271,7 +280,8 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte mvc.perform( post(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + filterQuery.getId() + "/autoAssignDS") .content("{\"id\":" + set.getId() + "}").contentType(MediaType.APPLICATION_JSON)) - .andDo(print()).andExpect(status().isOk()); + .andDo(print()) + .andExpect(status().isOk()); final String result = mvc.perform( get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + filterQuery.getId())) @@ -281,7 +291,8 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte final String multipleResult = mvc.perform( get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "?representation=full")) - .andExpect(jsonPath("$.content", hasSize(1))).andExpect(jsonPath("$.total", equalTo(1))) + .andExpect(jsonPath("$.content", hasSize(1))) + .andExpect(jsonPath("$.total", equalTo(1))) .andExpect(jsonPath("$.content[0]._links.DS.href", startsWith(distributionsetHrefPrefix))) .andReturn().getResponse().getContentAsString(); @@ -317,7 +328,8 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte mvc.perform(get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING) .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(offsetParam)) .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(knownTargetAmount))) - .andExpect(status().isOk()).andDo(print()) + .andExpect(status().isOk()) + .andDo(print()) .andExpect(jsonPath(JSON_PATH_PAGED_LIST_TOTAL, equalTo(knownTargetAmount))) .andExpect(jsonPath(JSON_PATH_PAGED_LIST_SIZE, equalTo(expectedSize))) .andExpect(jsonPath(JSON_PATH_PAGED_LIST_CONTENT, hasSize(expectedSize))) @@ -342,8 +354,10 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte final String hrefPrefix = "http://localhost" + MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + tfq.getId(); // test - mvc.perform(get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + tfq.getId())).andDo(print()) - .andExpect(status().isOk()).andExpect(jsonPath(JSON_PATH_NAME, equalTo(knownName))) + mvc.perform(get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + tfq.getId())) + .andDo(print()) + .andExpect(status().isOk()) + .andExpect(jsonPath(JSON_PATH_NAME, equalTo(knownName))) .andExpect(jsonPath(JSON_PATH_QUERY, equalTo(knownQuery))) .andExpect(jsonPath(JSON_PATH_CONFIRMATION_REQUIRED).doesNotExist()) .andExpect(jsonPath("$._links.self.href", equalTo(hrefPrefix))) @@ -358,7 +372,8 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte final MvcResult mvcResult = mvc .perform(get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + targetIdNotExists)) - .andExpect(status().isNotFound()).andReturn(); + .andExpect(status().isNotFound()) + .andReturn(); // verify response json exception message final ExceptionInfo exceptionInfo = ResourceUtility @@ -374,7 +389,9 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte final MvcResult mvcResult = mvc .perform(post(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING).content(notJson) .contentType(MediaType.APPLICATION_JSON)) - .andDo(print()).andExpect(status().isBadRequest()).andReturn(); + .andDo(print()) + .andExpect(status().isBadRequest()) + .andReturn(); assertThat(targetFilterQueryManagement.count()).isEqualTo(0); @@ -392,7 +409,10 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte final String body = new JSONObject().put("query", invalidQuery).put("name", "invalidFilter").toString(); mvc.perform(post(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING).content(body) - .contentType(MediaType.APPLICATION_JSON)).andDo(print()).andExpect(status().isBadRequest()).andReturn(); + .contentType(MediaType.APPLICATION_JSON)) + .andDo(print()) + .andExpect(status().isBadRequest()) + .andReturn(); assertThat(targetFilterQueryManagement.count()).isEqualTo(0); } @@ -413,7 +433,8 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte mvc.perform( post(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + filterQuery.getId() + "/autoAssignDS") .content("{\"id\":" + set.getId() + "}").contentType(MediaType.APPLICATION_JSON)) - .andDo(print()).andExpect(status().isForbidden()) + .andDo(print()) + .andExpect(status().isForbidden()) .andExpect( jsonPath(JSON_PATH_EXCEPTION_CLASS, equalTo(AssignmentQuotaExceededException.class.getName()))) .andExpect(jsonPath(JSON_PATH_ERROR_CODE, equalTo(SpServerError.SP_QUOTA_EXCEEDED.getKey()))); @@ -436,7 +457,8 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte mvc.perform( post(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + filterQuery.getId() + "/autoAssignDS") .content("{\"id\":" + set.getId() + "}").contentType(MediaType.APPLICATION_JSON)) - .andDo(print()).andExpect(status().isOk()); + .andDo(print()) + .andExpect(status().isOk()); implicitLock(set); final TargetFilterQuery updatedFilterQuery = targetFilterQueryManagement.get(filterQuery.getId()).get(); @@ -447,7 +469,8 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte // update the query of the filter query to trigger a quota hit mvc.perform(put(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + filterQuery.getId()) .content("{\"query\":\"controllerId==target*\"}").contentType(MediaType.APPLICATION_JSON)) - .andDo(print()).andExpect(status().isForbidden()) + .andDo(print()) + .andExpect(status().isForbidden()) .andExpect( jsonPath(JSON_PATH_EXCEPTION_CLASS, equalTo(AssignmentQuotaExceededException.class.getName()))) .andExpect(jsonPath(JSON_PATH_ERROR_CODE, equalTo(SpServerError.SP_QUOTA_EXCEEDED.getKey()))); @@ -510,7 +533,7 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte mvc .perform(post(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/{targetFilterQueryId}/autoAssignDS", - filterQuery.getId()).contentType(MediaType.APPLICATION_JSON).content(autoAssignBody.toString())) + filterQuery.getId()).contentType(MediaType.APPLICATION_JSON).content(autoAssignBody)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); } @@ -547,7 +570,8 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte assertThat(updatedFilterQuery.getAutoAssignActionType()).isEqualTo(ActionType.FORCED); mvc.perform(get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + tfq.getId() + "/autoAssignDS")) - .andExpect(status().isOk()).andExpect(jsonPath(JSON_PATH_NAME, equalTo(dsName))); + .andExpect(status().isOk()) + .andExpect(jsonPath(JSON_PATH_NAME, equalTo(dsName))); mvc.perform(delete(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + tfq.getId() + "/autoAssignDS")) .andExpect(status().isNoContent()); @@ -573,15 +597,18 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte final String valideWeightRequest = new JSONObject().put("id", dsId).put("weight", 45).toString(); mvc.perform(post(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/{targetFilterQueryId}/autoAssignDS", - filterId).content(valideWeightRequest).contentType(MediaType.APPLICATION_JSON)).andDo(print()) + filterId).content(valideWeightRequest).contentType(MediaType.APPLICATION_JSON)) + .andDo(print()) .andExpect(status().isOk()); enableMultiAssignments(); mvc.perform(post(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/{targetFilterQueryId}/autoAssignDS", - filterId).content(invalideWeightRequest).contentType(MediaType.APPLICATION_JSON)).andDo(print()) + filterId).content(invalideWeightRequest).contentType(MediaType.APPLICATION_JSON)) + .andDo(print()) .andExpect(status().isBadRequest()) .andExpect(jsonPath("$.errorCode", equalTo("hawkbit.server.error.repo.constraintViolation"))); mvc.perform(post(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/{targetFilterQueryId}/autoAssignDS", - filterId).content(valideWeightRequest).contentType(MediaType.APPLICATION_JSON)).andDo(print()) + filterId).content(valideWeightRequest).contentType(MediaType.APPLICATION_JSON)) + .andDo(print()) .andExpect(status().isOk()); final List filters = targetFilterQueryManagement.findAll(PAGE).getContent(); @@ -649,7 +676,8 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte } mvc.perform(post(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + tfq.getId() + "/autoAssignDS") - .content(jsonObject.toString()).contentType(MediaType.APPLICATION_JSON)).andDo(print()) + .content(jsonObject.toString()).contentType(MediaType.APPLICATION_JSON)) + .andDo(print()) .andExpect(status().isOk()); implicitLock(set); @@ -660,8 +688,10 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte assertThat(updatedFilterQuery.getAutoAssignActionType()) .isEqualTo(MgmtRestModelMapper.convertActionType(expectedActionType)); - mvc.perform(get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + tfq.getId())).andDo(print()) - .andExpect(status().isOk()).andExpect(jsonPath(JSON_PATH_NAME, equalTo(tfq.getName()))) + mvc.perform(get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + tfq.getId())) + .andDo(print()) + .andExpect(status().isOk()) + .andExpect(jsonPath(JSON_PATH_NAME, equalTo(tfq.getName()))) .andExpect(jsonPath(JSON_PATH_QUERY, equalTo(tfq.getQuery()))) .andExpect(isConfirmationFlowEnabled() ? jsonPath(JSON_PATH_CONFIRMATION_REQUIRED, @@ -678,7 +708,9 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte throws Exception { mvc.perform(post(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + tfq.getId() + "/autoAssignDS") .content("{\"id\":" + set.getId() + ", \"type\":\"" + MgmtActionType.TIMEFORCED.getName() + "\"}") - .contentType(MediaType.APPLICATION_JSON)).andDo(print()).andExpect(status().isBadRequest()) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(print()) + .andExpect(status().isBadRequest()) .andExpect(jsonPath(JSON_PATH_EXCEPTION_CLASS, equalTo(InvalidAutoAssignActionTypeException.class.getName()))) .andExpect(jsonPath(JSON_PATH_ERROR_CODE, @@ -696,7 +728,8 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte throws Exception { mvc.perform(post(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + tfq.getId() + "/autoAssignDS") .content("{\"id\":" + set.getId() + ", \"type\":\"unknown\"}").contentType(MediaType.APPLICATION_JSON)) - .andDo(print()).andExpect(status().isBadRequest()) + .andDo(print()) + .andExpect(status().isBadRequest()) .andExpect(jsonPath(JSON_PATH_EXCEPTION_CLASS, equalTo(MessageNotReadableException.class.getName()))) .andExpect(jsonPath(JSON_PATH_ERROR_CODE, equalTo(SpServerError.SP_REST_BODY_NOT_READABLE.getKey()))); } @@ -709,7 +742,8 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte mvc.perform(post(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + tfq.getId() + "/autoAssignDS") .content("{\"id\":" + incompleteDistributionSet.getId() + "}").contentType(MediaType.APPLICATION_JSON)) - .andDo(print()).andExpect(status().isBadRequest()) + .andDo(print()) + .andExpect(status().isBadRequest()) .andExpect(jsonPath(JSON_PATH_EXCEPTION_CLASS, equalTo(IncompleteDistributionSetException.class.getName()))) .andExpect(jsonPath(JSON_PATH_ERROR_CODE, equalTo(SpServerError.SP_DS_INCOMPLETE.getKey()))); @@ -723,7 +757,8 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte mvc.perform(post(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + tfq.getId() + "/autoAssignDS") .content("{\"id\":" + softDeletedDs.getId() + "}").contentType(MediaType.APPLICATION_JSON)) - .andDo(print()).andExpect(status().isNotFound()) + .andDo(print()) + .andExpect(status().isNotFound()) .andExpect(jsonPath(JSON_PATH_EXCEPTION_CLASS, equalTo(DeletedException.class.getName()))) .andExpect(jsonPath(JSON_PATH_ERROR_CODE, equalTo(SpServerError.SP_DELETED.getKey()))); } 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 9cb2dc704..9df2ed5b9 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 @@ -161,14 +161,18 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { .address(knownNewAddress).targetType(targetType.getId())); mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId) - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath("$.controllerId", equalTo(knownControllerId))) .andExpect(jsonPath("$.address", equalTo(knownNewAddress))) .andExpect(jsonPath("$.name", equalTo(knownNameNotModify))) .andExpect(jsonPath("$.targetType").exists()); mvc.perform(put(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId).content(body) - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath("$.controllerId", equalTo(knownControllerId))) .andExpect(jsonPath("$.address", equalTo(knownNewAddress))) .andExpect(jsonPath("$.name", equalTo(knownNameNotModify))) @@ -197,7 +201,9 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { .address(knownNewAddress).targetType(targetType.getId())); mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId) - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath("$.controllerId", equalTo(knownControllerId))) .andExpect(jsonPath("$.address", equalTo(knownNewAddress))) .andExpect(jsonPath("$.name", equalTo(knownNameNotModify))) @@ -205,7 +211,9 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { //check if controller name is updated AND target type is missing (not assigned) mvc.perform(put(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId).content(body) - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath("$.controllerId", equalTo(knownControllerId))) .andExpect(jsonPath("$.address", equalTo(knownNewAddress))) .andExpect(jsonPath("$.name", equalTo(controllerNewName))) @@ -216,7 +224,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { @Description("Handles the GET request of retrieving all targets within SP..") public void getTargets() throws Exception { enableConfirmationFlow(); - mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING)).andExpect(status().isOk()) + mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING)) + .andExpect(status().isOk()) .andDo(MockMvcResultPrinter.print()); } @@ -224,7 +233,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { @Description("Handles the GET request of retrieving all targets within SP based by parameter.") public void getTargetsWithParameters() throws Exception { mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "?limit=10&sort=name:ASC&offset=0&q=name==a")) - .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()); + .andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()); } @Test @@ -291,7 +301,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actions.get(0).getId() + "/status") .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(limitSize)) .param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:DESC")) - .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) .andExpect(jsonPath(JSON_PATH_PAGED_LIST_TOTAL, equalTo(3))) .andExpect(jsonPath(JSON_PATH_PAGED_LIST_SIZE, equalTo(limitSize))) .andExpect(jsonPath(JSON_PATH_PAGED_LIST_CONTENT, hasSize(limitSize))) @@ -310,7 +321,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final String knownControllerId = "knownControllerId"; testdataFactory.createTarget(knownControllerId); mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}", knownControllerId)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath("securityToken").doesNotExist()); } @@ -323,7 +335,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final String knownControllerId = "knownControllerId"; final Target createTarget = testdataFactory.createTarget(knownControllerId); mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}", knownControllerId)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath("securityToken", equalTo(createTarget.getSecurityToken()))); } @@ -338,8 +351,10 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { createTarget(knownControllerId2); // test - mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING)).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isOk()).andExpect(jsonPath("total", equalTo(2))) + mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("total", equalTo(2))) .andExpect(jsonPath("size", equalTo(2))) .andExpect(jsonPath("$.content.[?(@.controllerId=='" + knownControllerId1 + "')].ipAddress", contains("127.0.0.1"))) @@ -366,20 +381,29 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final String rsqlPendingOrFinishedStatus = rsqlFinishedStatus + "," + rsqlPendingStatus; // pending status one result mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions?q=" + rsqlPendingStatus, - createTarget.getControllerId())).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(jsonPath("total", equalTo(1))).andExpect(jsonPath("size", equalTo(1))) + createTarget.getControllerId())) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("total", equalTo(1))) + .andExpect(jsonPath("size", equalTo(1))) .andExpect(jsonPath("content[0].status", equalTo("pending"))); // finished status none result mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions?q=" + rsqlFinishedStatus, - createTarget.getControllerId())).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(jsonPath("total", equalTo(0))).andExpect(jsonPath("size", equalTo(0))); + createTarget.getControllerId())) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("total", equalTo(0))) + .andExpect(jsonPath("size", equalTo(0))); // pending or finished status one result mvc.perform(get( MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions?q=" + rsqlPendingOrFinishedStatus, - createTarget.getControllerId())).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(jsonPath("total", equalTo(1))).andExpect(jsonPath("size", equalTo(1))) + createTarget.getControllerId())) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("total", equalTo(1))) + .andExpect(jsonPath("size", equalTo(1))) .andExpect(jsonPath("content[0].status", equalTo("pending"))); } @@ -394,7 +418,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { delete(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions/{actionId}", tA.getControllerId(), deploymentManagement.findActionsByTarget(tA.getControllerId(), PAGE) .getContent().get(0).getId())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isNoContent()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isNoContent()); final Action action = deploymentManagement.findAction( deploymentManagement.findActionsByTarget(tA.getControllerId(), PAGE).getContent().get(0).getId()).get(); @@ -426,7 +451,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { // test - cancel an cancel action returns forbidden mvc.perform(delete(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions/{actionId}", - tA.getControllerId(), cancelActions.get(0).getId())).andDo(MockMvcResultPrinter.print()) + tA.getControllerId(), cancelActions.get(0).getId())) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isMethodNotAllowed()); } @@ -448,7 +474,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { // test - force quit: Canceled actions should return 204 mvc.perform(delete(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions/{actionId}?force=true", - tA.getControllerId(), cancelActions.get(0).getId())).andDo(MockMvcResultPrinter.print()) + tA.getControllerId(), cancelActions.get(0).getId())) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNoContent()); } @@ -463,7 +490,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { delete(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions/{actionId}?force=true", tA.getControllerId(), deploymentManagement.findActionsByTarget(tA.getControllerId(), PAGE) .getContent().get(0).getId())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isMethodNotAllowed()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isMethodNotAllowed()); } @Test @@ -492,7 +520,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { void updateTargetWhichDoesNotExistsLeadsToNotFound() throws Exception { final String knownControllerId = "knownControllerIdUpdate"; mvc.perform(put(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId).content("{}") - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNotFound()); } @@ -509,7 +538,9 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { .description("old description")); mvc.perform(put(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId).content(body) - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath("$.controllerId", equalTo(knownControllerId))) .andExpect(jsonPath("$.description", equalTo(knownNewDescription))) .andExpect(jsonPath("$.name", equalTo(knownNameNotModify))); @@ -532,7 +563,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { .description("old description")); mvc.perform(put(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId).content(body) - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isBadRequest()); final Target findTargetByControllerID = targetManagement.getByControllerID(knownControllerId).get(); @@ -552,7 +584,9 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { .create(entityFactory.target().create().controllerId(knownControllerId).name(knownNameNotModify)); mvc.perform(put(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId).content(body) - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath("$.controllerId", equalTo(knownControllerId))) .andExpect(jsonPath("$.securityToken", equalTo(knownNewToken))) .andExpect(jsonPath("$.name", equalTo(knownNameNotModify))); @@ -575,7 +609,9 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { .address(knownNewAddress)); mvc.perform(put(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId).content(body) - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath("$.controllerId", equalTo(knownControllerId))) .andExpect(jsonPath("$.address", equalTo(knownNewAddress))) .andExpect(jsonPath("$.name", equalTo(knownNameNotModify))); @@ -594,7 +630,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final String idC = "c"; final String linksHrefPrefix = "http://localhost/rest/v1/targets/"; createTargetsAlphabetical(knownTargetAmount); - mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING)).andExpect(status().isOk()) + mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING)) + .andExpect(status().isOk()) .andDo(MockMvcResultPrinter.print()) .andExpect(jsonPath(JSON_PATH_PAGED_LIST_TOTAL, equalTo(knownTargetAmount))) .andExpect(jsonPath(JSON_PATH_PAGED_LIST_SIZE, equalTo(knownTargetAmount))) @@ -639,7 +676,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING) .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(limitSize))) - .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) .andExpect(jsonPath(JSON_PATH_PAGED_LIST_TOTAL, equalTo(knownTargetAmount))) .andExpect(jsonPath(JSON_PATH_PAGED_LIST_SIZE, equalTo(limitSize))) .andExpect(jsonPath(JSON_PATH_PAGED_LIST_CONTENT, hasSize(limitSize))) @@ -668,7 +706,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING) .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(offsetParam)) .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(knownTargetAmount))) - .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) .andExpect(jsonPath(JSON_PATH_PAGED_LIST_TOTAL, equalTo(knownTargetAmount))) .andExpect(jsonPath(JSON_PATH_PAGED_LIST_SIZE, equalTo(expectedSize))) .andExpect(jsonPath(JSON_PATH_PAGED_LIST_CONTENT, hasSize(expectedSize))) @@ -708,7 +747,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final String hrefPrefix = "http://localhost/rest/v1/targets/" + knownControllerId + "/"; // test mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath(JSON_PATH_NAME, equalTo(knownName))) .andExpect(jsonPath(JSON_PATH_CONTROLLERID, equalTo(knownControllerId))) .andExpect(jsonPath(JSON_PATH_DESCRIPTION, equalTo(TARGET_DESCRIPTION_TEST))) @@ -731,7 +771,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { // test final MvcResult mvcResult = mvc .perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + targetIdNotExists)) - .andExpect(status().isNotFound()).andReturn(); + .andExpect(status().isNotFound()) + .andReturn(); // verify response json exception message final ExceptionInfo exceptionInfo = ResourceUtility @@ -749,7 +790,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { // test mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId + "/assignedDS")) - .andExpect(status().isNoContent()).andExpect(content().string("")); + .andExpect(status().isNoContent()) + .andExpect(content().string("")); } @@ -769,7 +811,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final SoftwareModule jvm = ds.findFirstModuleByType(runtimeType).get(); final SoftwareModule bApp = ds.findFirstModuleByType(appType).get(); mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId + "/assignedDS")) - .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) .andExpect(jsonPath(JSON_PATH_ID, equalTo(ds.getId().intValue()))) .andExpect(jsonPath(JSON_PATH_NAME, equalTo(ds.getName()))) .andExpect(jsonPath(JSON_PATH_DESCRIPTION, equalTo(ds.getDescription()))) @@ -819,7 +862,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { createSingleTarget(knownControllerId, knownName); mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId + "/installedDS")) - .andExpect(status().isNoContent()).andExpect(content().string("")); + .andExpect(status().isNoContent()) + .andExpect(content().string("")); } @Test @@ -835,7 +879,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { Math.min(JpaTarget.CONTROLLER_ID_MAX_SIZE, NamedEntity.NAME_MAX_SIZE)); mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING).content(targetList) - .contentType(MediaType.APPLICATION_JSON)).andExpect(status().isCreated()) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isCreated()) .andExpect(jsonPath("[0].controllerId", equalTo(randomString))) .andExpect(jsonPath("[0].name", equalTo(expectedTargetName))); @@ -848,7 +893,9 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final MvcResult mvcResult = mvc .perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING).contentType(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()).andReturn(); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isBadRequest()) + .andReturn(); assertThat(targetManagement.count()).isZero(); @@ -867,7 +914,9 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final MvcResult mvcResult = mvc .perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING).content(notJson) .contentType(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()).andReturn(); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isBadRequest()) + .andReturn(); assertThat(targetManagement.count()).isZero(); @@ -884,7 +933,9 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final MvcResult mvcResult = mvc .perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING).content("[{\"name\":\"id1\"}]") .contentType(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()).andReturn(); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isBadRequest()) + .andReturn(); assertThat(targetManagement.count()).isZero(); @@ -905,7 +956,9 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { .perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING) .content(JsonBuilder.targets(Collections.singletonList(test1), true)) .contentType(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()).andReturn(); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isBadRequest()) + .andReturn(); assertThat(targetManagement.count()).isZero(); @@ -931,7 +984,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final MvcResult mvcResult = mvc .perform(post("/rest/v1/targets").content(JsonBuilder.targets(targets, true)) .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isCreated()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("[0].name", equalTo("testname1"))) .andExpect(jsonPath("[0].controllerId", equalTo("id1"))) @@ -950,7 +1004,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { .andExpect(jsonPath("[2].controllerId", equalTo("id3"))) .andExpect(jsonPath("[2].description", equalTo("testid3"))) .andExpect(jsonPath("[2].createdAt", not(equalTo(0)))) - .andExpect(jsonPath("[2].createdBy", equalTo("bumlux"))).andReturn(); + .andExpect(jsonPath("[2].createdBy", equalTo("bumlux"))) + .andReturn(); assertThat( JsonPath.compile("[0]._links.self.href").read(mvcResult.getResponse().getContentAsString()).toString()) @@ -979,7 +1034,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final String createTargetsJson = getCreateTargetsListJsonString(knownControllerId, knownName, knownDescription); mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING).content(createTargetsJson) - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().is2xxSuccessful()); final Slice findTargetsAll = targetManagement.findAll(PageRequest.of(0, 100)); @@ -1001,13 +1057,15 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { // create a taret first to provoke a already exists error mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING).content(createTargetsJson) - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().is2xxSuccessful()); // create another one to retrieve the entity already exists exception final MvcResult mvcResult = mvc .perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING).content(createTargetsJson) .contentType(MediaType.APPLICATION_JSON)) - .andExpect(status().is(HttpStatus.CONFLICT.value())).andReturn(); + .andExpect(status().is(HttpStatus.CONFLICT.value())) + .andReturn(); // verify only one entry assertThat(targetManagement.count()).isEqualTo(1); @@ -1027,8 +1085,11 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { testdataFactory.createTarget(knownTargetId); mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" - + MgmtRestConstants.TARGET_V1_ACTIONS)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(jsonPath("size", equalTo(0))).andExpect(jsonPath("content", hasSize(0))) + + MgmtRestConstants.TARGET_V1_ACTIONS)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("size", equalTo(0))) + .andExpect(jsonPath("content", hasSize(0))) .andExpect(jsonPath("total", equalTo(0))); } @@ -1040,9 +1101,11 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actions.get(1).getId())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath("id", equalTo(actions.get(1).getId().intValue()))) - .andExpect(jsonPath("type", equalTo("update"))).andExpect(jsonPath("status", equalTo("pending"))) + .andExpect(jsonPath("type", equalTo("update"))) + .andExpect(jsonPath("status", equalTo("pending"))) .andExpect(jsonPath("forceType", equalTo("forced"))) .andExpect(jsonPath("maintenanceWindow").doesNotExist()) .andExpect(jsonPath("_links.self.href", @@ -1065,9 +1128,11 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actions.get(1).getId())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath("id", equalTo(actions.get(1).getId().intValue()))) - .andExpect(jsonPath("type", equalTo("update"))).andExpect(jsonPath("status", equalTo("pending"))) + .andExpect(jsonPath("type", equalTo("update"))) + .andExpect(jsonPath("status", equalTo("pending"))) .andExpect(jsonPath("forceType", equalTo("forced"))) .andExpect(jsonPath("maintenanceWindow.schedule", equalTo(schedule))) .andExpect(jsonPath("maintenanceWindow.duration", equalTo(duration))) @@ -1090,9 +1155,11 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actions.get(0).getId())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath("id", equalTo(actions.get(0).getId().intValue()))) - .andExpect(jsonPath("type", equalTo("cancel"))).andExpect(jsonPath("status", equalTo("pending"))) + .andExpect(jsonPath("type", equalTo("cancel"))) + .andExpect(jsonPath("status", equalTo("pending"))) .andExpect(jsonPath("forceType", equalTo("forced"))) .andExpect(jsonPath("maintenanceWindow").doesNotExist()) .andExpect(jsonPath("_links.self.href", @@ -1115,9 +1182,11 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actions.get(0).getId())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath("id", equalTo(actions.get(0).getId().intValue()))) - .andExpect(jsonPath("forceType", equalTo("forced"))).andExpect(jsonPath("type", equalTo("cancel"))) + .andExpect(jsonPath("forceType", equalTo("forced"))) + .andExpect(jsonPath("type", equalTo("cancel"))) .andExpect(jsonPath("status", equalTo("pending"))) .andExpect(jsonPath("maintenanceWindow.schedule", equalTo(schedule))) .andExpect(jsonPath("maintenanceWindow.duration", equalTo(duration))) @@ -1156,7 +1225,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + MgmtRestConstants.TARGET_V1_ACTIONS).param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC")) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath("content.[1].id", equalTo(actions.get(1).getId().intValue()))) .andExpect(jsonPath("content.[1].type", equalTo("update"))) .andExpect(jsonPath("content.[1].status", equalTo("pending"))) @@ -1195,7 +1265,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { // sort is default descending order, latest status first mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + action.getId() + "/" - + MgmtRestConstants.TARGET_V1_ACTION_STATUS)).andDo(MockMvcResultPrinter.print()) + + MgmtRestConstants.TARGET_V1_ACTION_STATUS)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("content.[0].id", equalTo(actionStatus.get(0).getId().intValue()))) .andExpect(jsonPath("content.[0].type", equalTo("canceling"))) @@ -1224,7 +1295,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + action.getId() + "/" + MgmtRestConstants.TARGET_V1_ACTION_STATUS).param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "REPORTEDAT:DESC")) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath("content.[0].id", equalTo(actionStatus.get(1).getId().intValue()))) .andExpect(jsonPath("content.[0].type", equalTo("canceling"))) .andExpect(jsonPath("content.[0].messages", @@ -1242,7 +1314,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + action.getId() + "/" + MgmtRestConstants.TARGET_V1_ACTION_STATUS).param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "REPORTEDAT:ASC")) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath("content.[1].id", equalTo(actionStatus.get(1).getId().intValue()))) .andExpect(jsonPath("content.[1].type", equalTo("canceling"))) .andExpect(jsonPath("content.[1].messages", @@ -1271,7 +1344,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + action.getId() + "/" + MgmtRestConstants.TARGET_V1_ACTION_STATUS).param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(1))) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath("content.[0].id", equalTo(actionStatus.get(1).getId().intValue()))) .andExpect(jsonPath("content.[0].type", equalTo("canceling"))) .andExpect(jsonPath("content.[0].messages", @@ -1287,7 +1361,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { + MgmtRestConstants.TARGET_V1_ACTION_STATUS) .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(1)) .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(1))) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath("content.[0].id", equalTo(actionStatus.get(0).getId().intValue()))) .andExpect(jsonPath("content.[0].type", equalTo("running"))) .andExpect(jsonPath("content.[0].reportedAt", equalTo(actionStatus.get(0).getCreatedAt()))) @@ -1307,7 +1382,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { + MgmtRestConstants.TARGET_V1_ACTIONS) .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(1)) .param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC")) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath("content.[0].id", equalTo(actions.get(0).getId().intValue()))) .andExpect(jsonPath("content.[0].type", equalTo("cancel"))) .andExpect(jsonPath("content.[0].status", equalTo("pending"))) @@ -1324,7 +1400,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(1)) .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(1)) .param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC")) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath("content.[0].id", equalTo(actions.get(1).getId().intValue()))) .andExpect(jsonPath("content.[0].type", equalTo("update"))) .andExpect(jsonPath("content.[0].status", equalTo("pending"))) @@ -1348,9 +1425,12 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { mvc.perform(put(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + target.getControllerId() + "/" + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actionId).content(body) .contentType(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(jsonPath("id", equalTo(actionId.intValue()))).andExpect(jsonPath("type", equalTo("update"))) - .andExpect(jsonPath("status", equalTo("pending"))).andExpect(jsonPath("forceType", equalTo("forced"))) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("id", equalTo(actionId.intValue()))) + .andExpect(jsonPath("type", equalTo("update"))) + .andExpect(jsonPath("status", equalTo("pending"))) + .andExpect(jsonPath("forceType", equalTo("forced"))) .andExpect(jsonPath("_links.self.href", equalTo(generateActionSelfLink(target.getControllerId(), actionId)))) .andExpect(jsonPath("_links.distributionset.href", @@ -1370,8 +1450,10 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + target.getControllerId() + "/assignedDS") .content("{\"id\":" + set.getId() + "}").contentType(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(jsonPath("assigned", equalTo(1))).andExpect(jsonPath("alreadyAssigned", equalTo(0))) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("assigned", equalTo(1))) + .andExpect(jsonPath("alreadyAssigned", equalTo(0))) .andExpect(jsonPath("total", equalTo(1))); implicitLock(set); @@ -1381,8 +1463,10 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { // repeating DS assignment leads again to OK mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + target.getControllerId() + "/assignedDS") .content("{\"id\":" + set.getId() + "}").contentType(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(jsonPath("assigned", equalTo(0))).andExpect(jsonPath("alreadyAssigned", equalTo(1))) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("assigned", equalTo(0))) + .andExpect(jsonPath("alreadyAssigned", equalTo(1))) .andExpect(jsonPath("total", equalTo(1))); // ...but does not change the target @@ -1409,8 +1493,10 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + target.getControllerId() + "/assignedDS") .content(jsonPayload.toString()).contentType(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(jsonPath("assigned", equalTo(1))).andExpect(jsonPath("alreadyAssigned", equalTo(0))) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("assigned", equalTo(1))) + .andExpect(jsonPath("alreadyAssigned", equalTo(0))) .andExpect(jsonPath("total", equalTo(1))); implicitLock(set); @@ -1437,8 +1523,11 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + target.getControllerId() + "/assignedDS") .content("{\"id\":" + set.getId() + ",\"type\": \"downloadonly\"}") - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(jsonPath("assigned", equalTo(1))).andExpect(jsonPath("alreadyAssigned", equalTo(0))) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("assigned", equalTo(1))) + .andExpect(jsonPath("alreadyAssigned", equalTo(0))) .andExpect(jsonPath("total", equalTo(1))); implicitLock(set); @@ -1458,8 +1547,10 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + target.getControllerId() + "/assignedDS?offline=true").content("{\"id\":" + set.getId() + "}") .contentType(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(jsonPath("assigned", equalTo(1))).andExpect(jsonPath("alreadyAssigned", equalTo(0))) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("assigned", equalTo(1))) + .andExpect(jsonPath("alreadyAssigned", equalTo(0))) .andExpect(jsonPath("total", equalTo(1))); implicitLock(set); @@ -1472,8 +1563,10 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + target.getControllerId() + "/assignedDS?offline=true").content("{\"id\":" + set.getId() + "}") .contentType(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(jsonPath("assigned", equalTo(0))).andExpect(jsonPath("alreadyAssigned", equalTo(1))) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("assigned", equalTo(0))) + .andExpect(jsonPath("alreadyAssigned", equalTo(1))) .andExpect(jsonPath("total", equalTo(1))); // ...but does not change the target @@ -1490,7 +1583,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { .put("forcetime", forceTime).toString(); mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/fsdfsd/assignedDS").content(body) - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); implicitLock(set); @@ -1513,7 +1607,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { .put("maintenanceWindow", new JSONObject().put("schedule", getTestSchedule(0))).toString(); mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + target.getControllerId() + "/assignedDS") - .content(body).contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .content(body).contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isBadRequest()); } @@ -1528,7 +1623,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { .put("maintenanceWindow", new JSONObject().put("duration", getTestDuration(10))).toString(); mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + target.getControllerId() + "/assignedDS") - .content(body).contentType(MediaTypes.HAL_JSON_VALUE)).andDo(MockMvcResultPrinter.print()) + .content(body).contentType(MediaTypes.HAL_JSON_VALUE)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isBadRequest()); } @@ -1545,7 +1641,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { .toString(); mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + target.getControllerId() + "/assignedDS") - .content(body).contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .content(body).contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); } @@ -1563,11 +1660,14 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { .toString(); mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + target.getControllerId() + "/assignedDS") - .content(body).contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .content(body).contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + target.getControllerId() + "/" - + MgmtRestConstants.TARGET_V1_ACTIONS)).andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) + + MgmtRestConstants.TARGET_V1_ACTIONS)) + .andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) .andExpect(jsonPath("content.[0].maintenanceWindow.nextStartAt", not(nextExecutionStart))); } @@ -1584,7 +1684,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { .toString(); mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + target.getControllerId() + "/assignedDS") - .content(body).contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .content(body).contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isBadRequest()); } @@ -1595,25 +1696,30 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/fsdfsd/assignedDS") .content("{\"id\":" + set.getId() + "}").contentType(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isNotFound()); testdataFactory.createTarget("fsdfsd"); mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/fsdfsd/assignedDS") .content("{\"id\":" + set.getId() + "}").contentType(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()); mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/fsdfsd/assignedDS") .content("{\"id\":12345678}").contentType(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isNotFound()); mvc.perform(delete(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/fsdfsd/assignedDS") - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isMethodNotAllowed()); mvc.perform(put(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/fsdfsd/assignedDS") .content("{\"id\":" + set.getId() + "}").contentType(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isMethodNotAllowed()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isMethodNotAllowed()); } @@ -1623,29 +1729,34 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { // target does not exist mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" - + MgmtRestConstants.TARGET_V1_ACTIONS)).andDo(MockMvcResultPrinter.print()) + + MgmtRestConstants.TARGET_V1_ACTIONS)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNotFound()); final List actions = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId); final Long actionId = actions.get(0).getId(); // should work now mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" - + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actionId)).andDo(MockMvcResultPrinter.print()) + + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actionId)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); // action does not exist mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" - + MgmtRestConstants.TARGET_V1_ACTIONS + "/12321")).andDo(MockMvcResultPrinter.print()) + + MgmtRestConstants.TARGET_V1_ACTIONS + "/12321")) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNotFound()); // not allowed methods mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" - + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actionId)).andDo(MockMvcResultPrinter.print()) + + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actionId)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isMethodNotAllowed()); // Invalid content mvc.perform(put(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" - + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actionId)).andDo(MockMvcResultPrinter.print()) + + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actionId)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isUnsupportedMediaType()); } @@ -1655,30 +1766,36 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { // target does not exist mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" - + MgmtRestConstants.TARGET_V1_ACTIONS + "/1/status")).andDo(MockMvcResultPrinter.print()) + + MgmtRestConstants.TARGET_V1_ACTIONS + "/1/status")) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNotFound()); final List actions = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId); final Long actionId = actions.get(0).getId(); // should work now mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" - + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actionId + "/status")).andDo(MockMvcResultPrinter.print()) + + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actionId + "/status")) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); // action does not exist mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" - + MgmtRestConstants.TARGET_V1_ACTIONS + "/12321/status")).andDo(MockMvcResultPrinter.print()) + + MgmtRestConstants.TARGET_V1_ACTIONS + "/12321/status")) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNotFound()); // not allowed methods mvc.perform(delete(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" - + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actionId + "/status")).andDo(MockMvcResultPrinter.print()) + + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actionId + "/status")) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isMethodNotAllowed()); mvc.perform(put(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" - + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actionId + "/status")).andDo(MockMvcResultPrinter.print()) + + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actionId + "/status")) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isMethodNotAllowed()); mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" - + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actionId + "/status")).andDo(MockMvcResultPrinter.print()) + + MgmtRestConstants.TARGET_V1_ACTIONS + "/" + actionId + "/status")) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isMethodNotAllowed()); } @@ -1694,8 +1811,10 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { // test query target over rest resource mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/attributes")) - .andDo(MockMvcResultPrinter.print()).andExpect(status().is2xxSuccessful()) - .andExpect(jsonPath("$.a", equalTo("1"))).andExpect(jsonPath("$.b", equalTo("2"))); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().is2xxSuccessful()) + .andExpect(jsonPath("$.a", equalTo("1"))) + .andExpect(jsonPath("$.b", equalTo("2"))); } @Test @@ -1706,7 +1825,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { // test query target over rest resource mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/attributes")) - .andDo(MockMvcResultPrinter.print()).andExpect(status().is(HttpStatus.NO_CONTENT.value())); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().is(HttpStatus.NO_CONTENT.value())); } @Test @@ -1736,8 +1856,11 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final String rsqlFindAOrB = "controllerId==a,controllerId==b"; mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "?q=" + rsqlFindAOrB)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()).andExpect(jsonPath("size", equalTo(2))) - .andExpect(jsonPath("total", equalTo(2))).andExpect(jsonPath("content[0].controllerId", equalTo("a"))) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("size", equalTo(2))) + .andExpect(jsonPath("total", equalTo(2))) + .andExpect(jsonPath("content[0].controllerId", equalTo("a"))) .andExpect(jsonPath("content[1].controllerId", equalTo("b"))); } @@ -1787,7 +1910,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { mvc.perform(post("/rest/v1/targets/{targetId}/metadata", knownControllerId).accept(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON).content(metaData1.toString())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isCreated()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("[0].key", equalTo(knownKey1))) .andExpect(jsonPath("[0].value", equalTo(knownValue1))) @@ -1810,7 +1934,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { mvc.perform(post("/rest/v1/targets/{targetId}/metadata", knownControllerId).accept(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON).content(metaData2.toString())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isForbidden()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isForbidden()); // verify that the number of meta data entries has not changed // (we cannot use the PAGE constant here as it tries to sort by ID) @@ -1835,9 +1960,12 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { mvc.perform(put("/rest/v1/targets/{targetId}/metadata/{key}", knownControllerId, knownKey) .accept(MediaType.APPLICATION_JSON).contentType(MediaType.APPLICATION_JSON) - .content(jsonObject.toString())).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .content(jsonObject.toString())) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) - .andExpect(jsonPath("key", equalTo(knownKey))).andExpect(jsonPath("value", equalTo(updateValue))); + .andExpect(jsonPath("key", equalTo(knownKey))) + .andExpect(jsonPath("value", equalTo(updateValue))); final TargetMetadata updatedTargetMetadata = targetManagement .getMetaDataByControllerId(knownControllerId, knownKey).get(); @@ -1857,7 +1985,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { setupTargetWithMetadata(knownControllerId, knownKey, knownValue); mvc.perform(delete("/rest/v1/targets/{targetId}/metadata/{key}", knownControllerId, knownKey)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()); assertThat(targetManagement.getMetaDataByControllerId(knownControllerId, knownKey)).isNotPresent(); } @@ -1874,9 +2003,11 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { setupTargetWithMetadata(knownControllerId, knownKey, knownValue); mvc.perform(delete("/rest/v1/targets/{targetId}/metadata/XXX", knownControllerId)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isNotFound()); - mvc.perform(delete("/rest/v1/targets/1234/metadata/{key}", knownKey)).andDo(MockMvcResultPrinter.print()) + mvc.perform(delete("/rest/v1/targets/1234/metadata/{key}", knownKey)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNotFound()); assertThat(targetManagement.getMetaDataByControllerId(knownControllerId, knownKey)).isPresent(); @@ -1894,8 +2025,10 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { setupTargetWithMetadata(knownControllerId, knownKey, knownValue); mvc.perform(get("/rest/v1/targets/{targetId}/metadata/{key}", knownControllerId, knownKey)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(jsonPath("key", equalTo(knownKey))).andExpect(jsonPath("value", equalTo(knownValue))); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("key", equalTo(knownKey))) + .andExpect(jsonPath("value", equalTo(knownValue))); } @Test @@ -1912,8 +2045,11 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { setupTargetWithMetadata(knownControllerId, knownKeyPrefix, knownValuePrefix, totalMetadata); mvc.perform(get("/rest/v1/targets/{targetId}/metadata?offset=" + offsetParam + "&limit=" + limitParam, - knownControllerId)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(jsonPath("size", equalTo(limitParam))).andExpect(jsonPath("total", equalTo(totalMetadata))) + knownControllerId)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("size", equalTo(limitParam))) + .andExpect(jsonPath("total", equalTo(totalMetadata))) .andExpect(jsonPath("content[0].key", equalTo("knownKey0"))) .andExpect(jsonPath("content[0].value", equalTo("knownValue0"))); @@ -1933,8 +2069,11 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final String rsqlSearchValue1 = "value==knownValue1"; mvc.perform(get("/rest/v1/targets/{targetId}/metadata?q=" + rsqlSearchValue1, knownControllerId)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()).andExpect(jsonPath("size", equalTo(1))) - .andExpect(jsonPath("total", equalTo(1))).andExpect(jsonPath("content[0].key", equalTo("knownKey1"))) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("size", equalTo(1))) + .andExpect(jsonPath("total", equalTo(1))) + .andExpect(jsonPath("content[0].key", equalTo("knownKey1"))) .andExpect(jsonPath("content[0].value", equalTo("knownValue1"))); } @@ -1949,7 +2088,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { dsIds.forEach(id -> body.put(getAssignmentObject(id, MgmtActionType.FORCED, 67))); mvc.perform(post("/rest/v1/targets/{targetId}/assignedDS", targetId).content(body.toString()) - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isBadRequest()); } @@ -1961,7 +2101,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final JSONArray body = new JSONArray().put(getAssignmentObject(dsId, MgmtActionType.FORCED)); mvc.perform(post("/rest/v1/targets/{targetId}/assignedDS", targetId).content(body.toString()) - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); } @@ -1975,7 +2116,9 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final JSONArray body = new JSONArray().put(assignment).put(assignment); mvc.perform(post("/rest/v1/targets/{targetId}/assignedDS", targetId).content(body.toString()) - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath("total", equalTo(1))); } @@ -1991,7 +2134,9 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { enableMultiAssignments(); mvc.perform(post("/rest/v1/targets/{targetId}/assignedDS", targetId).content(body.toString()) - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath("total", equalTo(2))); } @@ -2007,11 +2152,13 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { enableMultiAssignments(); mvc.perform(post("/rest/v1/targets/{targetId}/assignedDS", targetId).content(bodyInvalid.toString()) - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isBadRequest()) .andExpect(jsonPath("$.errorCode", equalTo("hawkbit.server.error.repo.constraintViolation"))); mvc.perform(post("/rest/v1/targets/{targetId}/assignedDS", targetId).content(bodyValid.toString()) - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); final List actions = deploymentManagement.findActionsAll(PAGE).get().collect(Collectors.toList()); @@ -2028,7 +2175,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final JSONObject bodyValid = getAssignmentObject(dsId, MgmtActionType.FORCED, 98); mvc.perform(post("/rest/v1/targets/{targetId}/assignedDS", targetId).content(bodyValid.toString()) - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); } @@ -2043,7 +2191,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { enableMultiAssignments(); mvc.perform(post("/rest/v1/targets/{targetId}/assignedDS", targetId).content(bodyValid.toString()) - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); final List actions = deploymentManagement.findActionsAll(PAGE).get().collect(Collectors.toList()); @@ -2065,7 +2214,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { mvc.perform(get("/rest/v1/targets/{targetId}/actions", targetId) .param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "WEIGHT:ASC")) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath("content.[0].weight", equalTo(customWeightLow))) .andExpect(jsonPath("content.[1].weight", equalTo(customWeightHigh))) .andExpect(jsonPath("content.[2].weight", equalTo(1000))); @@ -2087,7 +2237,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { // get all actions for the first target final Target target = targets.get(0); - mvc.perform(get("/rest/v1/targets/{targetId}/actions", target.getControllerId())).andExpect(status().isOk()) + mvc.perform(get("/rest/v1/targets/{targetId}/actions", target.getControllerId())) + .andExpect(status().isOk()) .andDo(MockMvcResultPrinter.print()) .andExpect(jsonPath("content.[0].rollout", equalTo(rollout.getId().intValue()))) .andExpect(jsonPath("content.[0].rolloutName", equalTo(rollout.getName()))); @@ -2098,9 +2249,12 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { PageRequest.of(0, 100)); assertThat(action.getContent()).hasSize(1); mvc.perform(get("/rest/v1/targets/{targetId}/actions/{actionId}", target.getControllerId(), - action.getContent().get(0).getId())).andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) + action.getContent().get(0).getId())) + .andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) .andExpect(jsonPath("$.rollout", equalTo(rollout.getId().intValue()))) - .andExpect(jsonPath("$.rolloutName", equalTo(rollout.getName()))).andExpect(jsonPath( + .andExpect(jsonPath("$.rolloutName", equalTo(rollout.getName()))) + .andExpect(jsonPath( "$._links.rollout.href", containsString("/rest/v1/rollouts/" + rollout.getId().intValue()))); } @@ -2125,7 +2279,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final MvcResult mvcPostResult = mvc .perform(post("/rest/v1/targets").content(JsonBuilder.targets(targets, true)) .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isCreated()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("[0].name", equalTo("targetWithoutType"))) .andExpect(jsonPath("[0].controllerId", equalTo("id1"))) @@ -2147,15 +2302,18 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { .andExpect(jsonPath("[2].description", equalTo("testid3"))) .andExpect(jsonPath("[2].createdAt", not(equalTo(0)))) .andExpect(jsonPath("[2].createdBy", equalTo("bumlux"))) - .andExpect(jsonPath("[2].targetType", equalTo(type2.getId().intValue()))).andReturn(); + .andExpect(jsonPath("[2].targetType", equalTo(type2.getId().intValue()))) + .andReturn(); mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + test2.getControllerId())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath(JSON_PATH_NAME, equalTo("targetOfType1"))) .andExpect(jsonPath(JSON_PATH_CONTROLLERID, equalTo("id2"))) .andExpect(jsonPath(JSON_PATH_TYPE, equalTo(type1.getId().intValue()))) .andExpect(jsonPath(JSON_PATH_DESCRIPTION, equalTo("testid2"))) - .andExpect(jsonPath("$._links.targetType.href", equalTo(hrefType1))).andReturn(); + .andExpect(jsonPath("$._links.targetType.href", equalTo(hrefType1))) + .andReturn(); final Target target1 = assertTarget("id1", "targetWithoutType", "testid1"); assertThat(target1.getTargetType()).isNull(); @@ -2183,7 +2341,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { // test query target over rest resource mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING).content(targetList) - .contentType(MediaType.APPLICATION_JSON)).andExpect(status().isCreated()) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isCreated()) .andExpect(jsonPath("[0].controllerId", equalTo("targetcontroller"))) .andExpect(jsonPath("[0].targetType", equalTo(targetTypes.get(0).getId().intValue()))); @@ -2208,7 +2367,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final String body = new JSONObject().put("targetType", targetTypes.get(1).getId().intValue()).toString(); mvc.perform(put(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + controllerId).content(body) - .contentType(MediaType.APPLICATION_JSON)).andExpect(status().isOk()) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) .andExpect(jsonPath("controllerId", equalTo(controllerId))) .andExpect(jsonPath("targetType", equalTo(targetTypes.get(1).getId().intValue()))); } @@ -2230,7 +2390,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { // post target over rest resource mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING).content(targetList) - .contentType(MediaType.APPLICATION_JSON)).andExpect(status().isNotFound()) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isNotFound()) .andExpect(jsonPath("message", Matchers.containsString(errorMsg))); } @@ -2249,7 +2410,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { // assign target type over rest resource mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + targetControllerId + "/targettype") .content("{\"id\":" + targetType.getId() + "}").contentType(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()); assertThat(targetManagement.getByControllerID(targetControllerId).get().getTargetType().getId()) .isEqualTo(targetType.getId()); @@ -2269,7 +2431,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { // assign invalid target type over rest resource mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + targetControllerId + "/targettype") .content("{\"id\":" + invalidTargetTypeId + "}").contentType(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isNotFound()); // verify response json exception message if body does not include id // field @@ -2277,7 +2440,9 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { .perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + targetControllerId + "/targettype") .content("{\"unknownfield\":" + invalidTargetTypeId + "}") .contentType(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()).andReturn(); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isBadRequest()) + .andReturn(); final ExceptionInfo exceptionInfo = ResourceUtility .convertException(mvcResult.getResponse().getContentAsString()); assertThat(exceptionInfo.getExceptionClass()).isEqualTo(ConstraintViolationException.class.getName()); @@ -2301,7 +2466,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { // unassign target type over rest resource mvc.perform(delete(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + targetControllerId + "/targettype") - .contentType(MediaType.APPLICATION_JSON)).andExpect(status().isOk()); + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()); assertThat(targetManagement.getByControllerID(targetControllerId).get().getTargetType()).isNull(); } @@ -2314,34 +2480,43 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { // GET is not allowed mvc.perform(get( - MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + MgmtRestConstants.TARGET_TARGET_TYPE_V1_REQUEST_MAPPING, - knownTargetId)).andDo(MockMvcResultPrinter.print()).andExpect(status().isMethodNotAllowed()); + MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + MgmtRestConstants.TARGET_TARGET_TYPE_V1_REQUEST_MAPPING, + knownTargetId)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isMethodNotAllowed()); // PUT is not allowed mvc.perform(put( - MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + MgmtRestConstants.TARGET_TARGET_TYPE_V1_REQUEST_MAPPING, - knownTargetId)).andDo(MockMvcResultPrinter.print()).andExpect(status().isMethodNotAllowed()); + MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + MgmtRestConstants.TARGET_TARGET_TYPE_V1_REQUEST_MAPPING, + knownTargetId)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isMethodNotAllowed()); // POST does not exist with path parameter targettype mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + MgmtRestConstants.TARGET_TARGET_TYPE_V1_REQUEST_MAPPING + "/123", knownTargetId)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isNotFound()); // DELETE does not exist with path parameter targettype mvc.perform(delete(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + MgmtRestConstants.TARGET_TARGET_TYPE_V1_REQUEST_MAPPING + "/123", knownTargetId)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isNotFound()); // Invalid content mvc.perform(post( - MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + MgmtRestConstants.TARGET_TARGET_TYPE_V1_REQUEST_MAPPING, - knownTargetId)).andDo(MockMvcResultPrinter.print()).andExpect(status().isUnsupportedMediaType()); + MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + MgmtRestConstants.TARGET_TARGET_TYPE_V1_REQUEST_MAPPING, + knownTargetId)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isUnsupportedMediaType()); // Bad request if id field is missing mvc.perform(post( MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + MgmtRestConstants.TARGET_TARGET_TYPE_V1_REQUEST_MAPPING, knownTargetId).content("{\"unknownfield\":123}").contentType(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isBadRequest()); } @ParameterizedTest @@ -2353,7 +2528,9 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { // GET with all possible responses mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/" + TARGET_V1_AUTO_CONFIRM, - knownTargetId)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + knownTargetId)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath("active", equalTo(Boolean.TRUE))) .andExpect(initiator == null ? jsonPath("initiator").doesNotExist() : jsonPath("initiator", equalTo(initiator))) @@ -2368,21 +2545,26 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { testdataFactory.createTarget(knownTargetId); // GET if active - mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING)).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isOk()).andExpect(jsonPath("content.[0].autoConfirmActive").doesNotExist()); + mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("content.[0].autoConfirmActive").doesNotExist()); enableConfirmationFlow(); // GET if not active - mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING)).andDo(MockMvcResultPrinter.print()) + mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) .andExpect(jsonPath("content.[0].autoConfirmActive", equalTo(Boolean.FALSE))); confirmationManagement.activateAutoConfirmation(knownTargetId, "test", "remark"); // GET if active - mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING)).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isOk()).andExpect(jsonPath("content.[0].autoConfirmActive", equalTo(Boolean.TRUE))); + mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("content.[0].autoConfirmActive", equalTo(Boolean.TRUE))); } @Test @@ -2391,15 +2573,21 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { // GET for not existing target mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/" + TARGET_V1_AUTO_CONFIRM, - knownTargetId)).andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound()); + knownTargetId)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isNotFound()); testdataFactory.createTarget(knownTargetId); // GET for auto-confirm not active mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/" + TARGET_V1_AUTO_CONFIRM, - knownTargetId)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(jsonPath("active", equalTo(Boolean.FALSE))).andExpect(jsonPath("initiator").doesNotExist()) - .andExpect(jsonPath("remark").doesNotExist()).andExpect(jsonPath("_links.activate").exists()); + knownTargetId)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("active", equalTo(Boolean.FALSE))) + .andExpect(jsonPath("initiator").doesNotExist()) + .andExpect(jsonPath("remark").doesNotExist()) + .andExpect(jsonPath("_links.activate").exists()); } @Test @@ -2409,7 +2597,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { // GET with confirmation flow not active should not expose mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}", knownTargetId)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath("autoConfirmActive").doesNotExist()) .andExpect(jsonPath("_links.autoConfirm").doesNotExist()); @@ -2417,8 +2606,10 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { // GET with confirmation flow active should expose mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}", knownTargetId)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(jsonPath("autoConfirmActive").exists()).andExpect(jsonPath("_links.autoConfirm").exists()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("autoConfirmActive").exists()) + .andExpect(jsonPath("_links.autoConfirm").exists()); } @Test @@ -2432,28 +2623,36 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { // no status update yet -> no status code mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions/{actionId}", - target.getControllerId(), action.getId())).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isOk()).andExpect(jsonPath("lastStatusCode").doesNotExist()); + target.getControllerId(), action.getId())) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("lastStatusCode").doesNotExist()); // update action status with status code updateActionStatus(action, Status.RUNNING, 100); mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions/{actionId}", - target.getControllerId(), action.getId())).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isOk()).andExpect(jsonPath("lastStatusCode", equalTo(100))) + target.getControllerId(), action.getId())) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("lastStatusCode", equalTo(100))) .andExpect(jsonPath("detailStatus", equalTo("running"))); // update action status without a status code updateActionStatus(action, Status.RUNNING, null); mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions/{actionId}", - target.getControllerId(), action.getId())).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isOk()).andExpect(jsonPath("lastStatusCode").doesNotExist()) + target.getControllerId(), action.getId())) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("lastStatusCode").doesNotExist()) .andExpect(jsonPath("detailStatus", equalTo("running"))); // update action status with status code updateActionStatus(action, Status.ERROR, 432); mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions/{actionId}", - target.getControllerId(), action.getId())).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isOk()).andExpect(jsonPath("lastStatusCode", equalTo(432))) + target.getControllerId(), action.getId())) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("lastStatusCode", equalTo(432))) .andExpect(jsonPath("detailStatus", equalTo("error"))); } @@ -2496,7 +2695,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final ResultActions resultActions = mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + MgmtRestConstants.TARGET_V1_ACTIONS).param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC")) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath("content.[1].id", equalTo(actions.get(1).getId().intValue()))) .andExpect(jsonPath("content.[1].type", equalTo("update"))) .andExpect(jsonPath("content.[1].status", equalTo("pending"))) @@ -2586,7 +2786,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final String body = new JSONObject().put("requestAttributes", true).toString(); mvc.perform(put(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId).content(body) - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); assertThat(targetManagement.isControllerAttributesRequested(knownTargetId)).isTrue(); @@ -2597,7 +2798,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final String body = new JSONObject().put("description", "verify attribute can be missing").toString(); mvc.perform(put(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId).content(body) - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); } @@ -2606,7 +2808,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final String body = new JSONObject().put("requestAttributes", false).toString(); mvc.perform(put(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId).content(body) - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isBadRequest()); assertThat(targetManagement.isControllerAttributesRequested(knownTargetId)).isTrue(); @@ -2650,7 +2853,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { final DistributionSet dsA = testdataFactory.createDistributionSet(""); final Target tA = testdataFactory.createTarget("target-id-A"); // assign a distribution set so we get an active update action - assignDistributionSet(dsA, Arrays.asList(tA)); + assignDistributionSet(dsA, Collections.singletonList(tA)); // verify active action final Slice actionsByTarget = deploymentManagement.findActionsByTarget(tA.getControllerId(), PAGE); assertThat(actionsByTarget.getContent()).hasSize(1); 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 814a2b3a4..4ad392a8b 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 @@ -75,9 +75,11 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT final TargetTag unassigned = tags.get(1); mvc.perform(get(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) - .andExpect(applyTagMatcherOnPagedResult(assigned)).andExpect(applyTagMatcherOnPagedResult(unassigned)) + .andExpect(applyTagMatcherOnPagedResult(assigned)) + .andExpect(applyTagMatcherOnPagedResult(unassigned)) .andExpect(applySelfLinkMatcherOnPagedResult(assigned, TARGETTAGS_ROOT + assigned.getId())) .andExpect(applySelfLinkMatcherOnPagedResult(unassigned, TARGETTAGS_ROOT + unassigned.getId())) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(2))) @@ -93,7 +95,8 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT final TargetTag assigned = tags.get(0); final TargetTag unassigned = tags.get(1); mvc.perform(get(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "?limit=10&sort=name:ASC&offset=0&q=name==targetTag")) - .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()); + .andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()); } @Test @@ -116,7 +119,8 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT mvc.perform(get(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "?" + MgmtRestConstants.REQUEST_PARAMETER_SEARCH + "=colour==" + tag2.getColour()) .accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(applyTagMatcherOnPagedResult(tag2)) .andExpect(applySelfLinkMatcherOnPagedResult(tag2, TARGETTAGS_ROOT + tag2.getId())) @@ -133,7 +137,9 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT final TargetTag assigned = tags.get(0); mvc.perform(get(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + assigned.getId()) - .accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .accept(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(applyTagMatcherOnSingleResult(assigned)) .andExpect(applySelfLinkMatcherOnSingleResult(TARGETTAGS_ROOT + assigned.getId())) @@ -155,7 +161,8 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT .perform(post(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING) .content(JsonBuilder.tags(Arrays.asList(tagOne, tagTwo))) .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isCreated()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)); final Tag createdOne = targetTagManagement.findByRsql(PAGE, "name==thetest1").getContent().get(0); @@ -167,7 +174,8 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT assertThat(createdTwo.getDescription()).isEqualTo(tagTwo.getDescription()); assertThat(createdTwo.getColour()).isEqualTo(tagTwo.getColour()); - result.andExpect(applyTagMatcherOnArrayResult(createdOne)).andExpect(applyTagMatcherOnArrayResult(createdTwo)); + result.andExpect(applyTagMatcherOnArrayResult(createdOne)) + .andExpect(applyTagMatcherOnArrayResult(createdTwo)); } @Test @@ -185,7 +193,8 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT .perform(put(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + original.getId()) .content(JsonBuilder.tag(update)).contentType(MediaType.APPLICATION_JSON) .accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)); final Tag updated = targetTagManagement.findByRsql(PAGE, "name==updatedName").getContent().get(0); @@ -193,7 +202,8 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT assertThat(updated.getDescription()).isEqualTo(update.getDescription()); assertThat(updated.getColour()).isEqualTo(update.getColour()); - result.andExpect(applyTagMatcherOnArrayResult(updated)).andExpect(applyTagMatcherOnArrayResult(updated)); + result.andExpect(applyTagMatcherOnArrayResult(updated)) + .andExpect(applyTagMatcherOnArrayResult(updated)); } @Test @@ -205,7 +215,8 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT final TargetTag original = tags.get(0); mvc.perform(delete(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + original.getId())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()); assertThat(targetTagManagement.get(original.getId())).isNotPresent(); } @@ -221,7 +232,8 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT targetManagement.assignTag(targets.stream().map(Target::getControllerId).collect(Collectors.toList()), tag.getId()); mvc.perform(get(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned")) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(targetsAssigned))) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_SIZE, equalTo(targetsAssigned))) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(targetsAssigned))); @@ -240,7 +252,8 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT mvc.perform(get(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned") .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(limitSize))) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(targetsAssigned))) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_SIZE, equalTo(limitSize))) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(limitSize))); @@ -262,7 +275,8 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT mvc.perform(get(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned") .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(offsetParam)) .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(targetsAssigned))) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(targetsAssigned))) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_SIZE, equalTo(expectedSize))) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(expectedSize))); @@ -279,7 +293,9 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT final Target assigned = testdataFactory.createTargets(1).get(0); mvc.perform(post(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned/" + - assigned.getControllerId())).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()); + assigned.getControllerId())) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()); final List updated = targetManagement.findByTag(PAGE, tag.getId()).getContent(); assertThat(updated.stream().map(Target::getControllerId).collect(Collectors.toList())) @@ -297,12 +313,12 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT final List targets = testdataFactory.createTargets(2); final Target assigned0 = targets.get(0); final Target assigned1 = targets.get(1); - ; mvc.perform(put(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned") .content(JsonBuilder.toArray(Arrays.asList(assigned0.getControllerId(), assigned1.getControllerId()))) .contentType(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()); final List updated = targetManagement.findByTag(PAGE, tag.getId()).getContent(); assertThat(updated.stream().map(Target::getControllerId).collect(Collectors.toList())) @@ -439,7 +455,8 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT mvc.perform(delete(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned/" + unassigned.getControllerId())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()); final List updated = targetManagement.findByTag(PAGE, tag.getId()).getContent(); assertThat(updated.stream().map(Target::getControllerId).collect(Collectors.toList())) @@ -464,7 +481,8 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT mvc.perform(delete(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + tag.getId() + "/assigned") .content(JsonBuilder.toArray(Arrays.asList(unassigned0.getControllerId(), unassigned1.getControllerId()))) .contentType(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()); final List updated = targetManagement.findByTag(PAGE, tag.getId()).getContent(); assertThat(updated.stream().map(Target::getControllerId).collect(Collectors.toList())) @@ -635,7 +653,8 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT .content(controllerIdsOld( targets.stream().map(Target::getControllerId).collect(Collectors.toList()))) .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)); final List updated = targetManagement.findByTag(PAGE, tag.getId()).getContent(); @@ -663,7 +682,8 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT .content(controllerIdsOld( targets.stream().map(Target::getControllerId).collect(Collectors.toList()))) .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)); } } diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTypeResourceTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTypeResourceTest.java index c53ef978e..3b5999b68 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTypeResourceTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTypeResourceTest.java @@ -74,7 +74,8 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest { @Description("GET targettypes returns Forbidden when permission is missing") void getTargetTypesWithoutPermission() throws Exception { mvc.perform(get(TARGETTYPES_ENDPOINT).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isForbidden()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isForbidden()); } @Test @@ -86,9 +87,11 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest { Long typeId = testType.getId(); mvc.perform(get(TARGETTYPE_SINGLE_ENDPOINT, typeId).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) - .andExpect(jsonPath("$.id", is(typeId), Long.class)).andExpect(jsonPath("$.name", equalTo(typeName))) + .andExpect(jsonPath("$.id", is(typeId), Long.class)) + .andExpect(jsonPath("$.name", equalTo(typeName))) .andExpect(jsonPath("$.colour", is("#000000"))) .andExpect(jsonPath("$.description", equalTo(typeName + SPACE_AND_DESCRIPTION))) .andExpect(jsonPath("$.createdBy", equalTo(TEST_USER))) @@ -115,7 +118,8 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest { for (int index = 0; index < count; index++) { Long typeId = testTypes.get(index).getId(); - resultActions.andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + resultActions.andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$.content.[?(@.id=='" + typeId + "')].id", contains(typeId.intValue()))) .andExpect(jsonPath("$.content.[?(@.id=='" + typeId + "')].name", contains(typeName + index))) .andExpect(jsonPath("$.content.[?(@.id=='" + typeId + "')].colour", contains("#000000"))) @@ -134,7 +138,8 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest { .andExpect( jsonPath("$.content.[?(@.id=='" + typeId + "')]._links.compatibledistributionsettypes.href") .doesNotExist()) - .andExpect(jsonPath("$.total", equalTo(count))).andExpect(jsonPath("$.size", equalTo(count))); + .andExpect(jsonPath("$.total", equalTo(count))) + .andExpect(jsonPath("$.size", equalTo(count))); } } @@ -145,7 +150,9 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest { // 0 types overall (no default types are created) final int types = 0; - mvc.perform(get(TARGETTYPES_ENDPOINT)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + mvc.perform(get(TARGETTYPES_ENDPOINT)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(types))) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_SIZE, equalTo(types))) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(types))); @@ -167,8 +174,10 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest { // descending mvc.perform(get(TARGETTYPES_ENDPOINT).accept(MediaType.APPLICATION_JSON) - .param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "name:DESC")).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "name:DESC")) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$.content.[0].id", equalTo(testTypeC.getId().intValue()))) .andExpect(jsonPath("$.content.[0].name", equalTo(typeNameC))) .andExpect(jsonPath("$.content.[0].colour", equalTo("#000000"))) @@ -182,14 +191,17 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest { .andExpect(jsonPath("$.content.[0]._links.self.href", equalTo("http://localhost/rest/v1/targettypes/" + testTypeC.getId()))) .andExpect(jsonPath("$.content.[0]._links.compatibledistributionsettypes.href").doesNotExist()) - .andExpect(jsonPath("$.total", equalTo(3))).andExpect(jsonPath("$.size", equalTo(3))) + .andExpect(jsonPath("$.total", equalTo(3))) + .andExpect(jsonPath("$.size", equalTo(3))) .andExpect(jsonPath("$.content.[1].name", equalTo(typeNameB))) .andExpect(jsonPath("$.content.[2].name", equalTo(typeNameA))); // ascending mvc.perform(get(TARGETTYPES_ENDPOINT).accept(MediaType.APPLICATION_JSON) - .param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "name:ASC")).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + .param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "name:ASC")) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$.content.[0].id", equalTo(testTypeA.getId().intValue()))) .andExpect(jsonPath("$.content.[0].name", equalTo(typeNameA))) .andExpect(jsonPath("$.content.[0].description", equalTo("Updated description"))) @@ -203,7 +215,8 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest { .andExpect(jsonPath("$.content.[0]._links.self.href", equalTo("http://localhost/rest/v1/targettypes/" + testTypeA.getId()))) .andExpect(jsonPath("$.content.[0]._links.compatibledistributionsettypes.href").doesNotExist()) - .andExpect(jsonPath("$.total", equalTo(3))).andExpect(jsonPath("$.size", equalTo(3))) + .andExpect(jsonPath("$.total", equalTo(3))) + .andExpect(jsonPath("$.size", equalTo(3))) .andExpect(jsonPath("$.content.[1].name", equalTo(typeNameB))) .andExpect(jsonPath("$.content.[2].name", equalTo(typeNameC))); @@ -219,7 +232,9 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest { createTestTargetTypesInDB(typePrefix, count); mvc.perform(get(TARGETTYPES_ENDPOINT).param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, - String.valueOf(limit))).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + String.valueOf(limit))) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(count))) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_SIZE, equalTo(limit))) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(limit))); @@ -238,7 +253,8 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest { mvc.perform(get(TARGETTYPES_ENDPOINT) .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(offset)) .param(MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(count))) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(count))) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_SIZE, equalTo(expectedSize))) .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(expectedSize))); @@ -255,11 +271,13 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest { mvc.perform( put(TARGETTYPE_SINGLE_ENDPOINT, testType.getId()).content(body).contentType(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath("$.id", equalTo(testType.getId().intValue()))) .andExpect(jsonPath("$.description", equalTo("updated description"))) .andExpect(jsonPath("$.name", equalTo("TestTypePUTupdated"))) - .andExpect(jsonPath("$.colour", equalTo("#ffffff"))).andReturn(); + .andExpect(jsonPath("$.colour", equalTo("#ffffff"))) + .andReturn(); } @Test @@ -273,7 +291,8 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest { .description("Updated Description").colour("#ffffff")); mvc.perform(get(TARGETTYPE_SINGLE_ENDPOINT, testType.getId()).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$.name", equalTo(typeNameUpdated))) .andExpect(jsonPath("$.description", equalTo("Updated Description"))) @@ -306,7 +325,8 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest { mvc.perform(post(TARGETTYPE_DSTYPES_ENDPOINT, testType.getId()) .content("[{\"id\":" + standardDsType.getId() + "}]").contentType(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()); testType = targetTypeManagement.get(testType.getId()).get(); assertThat(testType.getLastModifiedBy()).isEqualTo(TEST_USER); @@ -322,7 +342,8 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest { final TargetType testType = createTestTargetTypeInDB(typeName, Collections.singletonList(standardDsType)); mvc.perform(get(TARGETTYPE_DSTYPES_ENDPOINT, testType.getId()).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$[0].name", equalTo(standardDsType.getName()))) .andExpect(jsonPath("$[0].description", equalTo(standardDsType.getDescription()))) @@ -339,7 +360,8 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest { final TargetType testType = createTestTargetTypeInDB(typeName); mvc.perform(get(TARGETTYPE_DSTYPE_SINGLE_ENDPOINT, testType.getId(), standardDsType.getId()) - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isMethodNotAllowed()); } @@ -352,7 +374,8 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest { TargetType testType = createTestTargetTypeInDB(typeName, Collections.singletonList(standardDsType)); mvc.perform(delete(TARGETTYPE_DSTYPE_SINGLE_ENDPOINT, testType.getId(), standardDsType.getId()) - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); testType = targetTypeManagement.get(testType.getId()).get(); @@ -370,7 +393,8 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest { assertThat(distributionSetTypeManagement.getByKey(standardDsType.getKey())).isNotEmpty(); mvc.perform(delete(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/" + standardDsType.getId())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()); testType = targetTypeManagement.get(testType.getId()).get(); assertThat(testType.getLastModifiedBy()).isEqualTo(TEST_USER); @@ -388,7 +412,8 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest { assertThat(targetTypeManagement.count()).isEqualTo(1); - mvc.perform(delete(TARGETTYPE_SINGLE_ENDPOINT, testType.getId())).andDo(MockMvcResultPrinter.print()) + mvc.perform(delete(TARGETTYPE_SINGLE_ENDPOINT, testType.getId())) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); assertThat(targetTypeManagement.count()).isZero(); @@ -407,7 +432,8 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest { assertThat(targetTypeManagement.count()).isEqualTo(1); assertThat(targetManagement.count()).isEqualTo(1); - mvc.perform(delete(TARGETTYPE_SINGLE_ENDPOINT, testType.getId())).andDo(MockMvcResultPrinter.print()) + mvc.perform(delete(TARGETTYPE_SINGLE_ENDPOINT, testType.getId())) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isConflict()); assertThat(targetManagement.count()).isEqualTo(1); @@ -418,7 +444,8 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest { @WithUser(principal = TEST_USER, allSpPermissions = true) @Description("Ensures that target type deletion request to API on an entity that does not exist results in NOT_FOUND.") void deleteTargetTypeThatDoesNotExistLeadsToNotFound() throws Exception { - mvc.perform(delete(TARGETTYPE_SINGLE_ENDPOINT, 1234)).andDo(MockMvcResultPrinter.print()) + mvc.perform(delete(TARGETTYPE_SINGLE_ENDPOINT, 1234)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNotFound()); } @@ -433,7 +460,8 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest { mvc.perform( put(TARGETTYPE_SINGLE_ENDPOINT, testType.getId()).content(body).contentType(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) .andExpect(jsonPath("$.id", equalTo(testType.getId().intValue()))) .andExpect(jsonPath("$.deleted", equalTo(false))); // don't delete with update } @@ -445,11 +473,14 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest { final TargetType testType = createTestTargetTypeInDB(typeName, Collections.singletonList(standardDsType)); // target type does not exist - mvc.perform(get(TARGETTYPE_SINGLE_ENDPOINT, 12345678)).andDo(MockMvcResultPrinter.print()) + mvc.perform(get(TARGETTYPE_SINGLE_ENDPOINT, 12345678)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNotFound()); - mvc.perform(get(TARGETTYPE_DSTYPES_ENDPOINT, 123456789)).andDo(MockMvcResultPrinter.print()) + mvc.perform(get(TARGETTYPE_DSTYPES_ENDPOINT, 123456789)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNotFound()); - mvc.perform(delete(TARGETTYPE_SINGLE_ENDPOINT, 123456789)).andDo(MockMvcResultPrinter.print()) + mvc.perform(delete(TARGETTYPE_SINGLE_ENDPOINT, 123456789)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNotFound()); // target types at creation time invalid @@ -457,66 +488,82 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest { Collections.singletonList(standardDsType)); mvc.perform(post(TARGETTYPES_ENDPOINT).content(JsonBuilder.targetTypes(Collections.singletonList(testNewType))) - .contentType(MediaType.APPLICATION_OCTET_STREAM)).andDo(MockMvcResultPrinter.print()) + .contentType(MediaType.APPLICATION_OCTET_STREAM)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isUnsupportedMediaType()); // bad request - no content mvc.perform(post(TARGETTYPES_ENDPOINT).contentType(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isBadRequest()); // bad request - bad content mvc.perform(post(TARGETTYPES_ENDPOINT).content("sdfjsdlkjfskdjf".getBytes()) - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isBadRequest()); // Missing mandatory field name mvc.perform(post(TARGETTYPES_ENDPOINT).content("[{\"description\":\"Desc123\"}]") - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isBadRequest()); final TargetType tooLongName = entityFactory.targetType().create() .name(RandomStringUtils.randomAlphanumeric(NamedEntity.NAME_MAX_SIZE + 1)).build(); mvc.perform(post(TARGETTYPES_ENDPOINT).content(JsonBuilder.targetTypes(Collections.singletonList(tooLongName))) - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isBadRequest()); // ds types - mvc.perform(get(TARGETTYPE_DSTYPES_ENDPOINT, testType.getId())).andDo(MockMvcResultPrinter.print()) + mvc.perform(get(TARGETTYPE_DSTYPES_ENDPOINT, testType.getId())) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); mvc.perform(delete(TARGETTYPE_DSTYPE_SINGLE_ENDPOINT, testType.getId(), 565765)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isNotFound()); mvc.perform(post(TARGETTYPE_DSTYPES_ENDPOINT, testType.getId()).content("{\"id\":1}") - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isBadRequest()); mvc.perform(post(TARGETTYPE_DSTYPES_ENDPOINT, testType.getId()).content("[{\"id\":44456}]") - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNotFound()); // not allowed methods - mvc.perform(put(TARGETTYPES_ENDPOINT)).andDo(MockMvcResultPrinter.print()) + mvc.perform(put(TARGETTYPES_ENDPOINT)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isMethodNotAllowed()); - mvc.perform(delete(TARGETTYPES_ENDPOINT)).andDo(MockMvcResultPrinter.print()) + mvc.perform(delete(TARGETTYPES_ENDPOINT)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isMethodNotAllowed()); - mvc.perform(put(TARGETTYPE_DSTYPES_ENDPOINT, testType.getId())).andDo(MockMvcResultPrinter.print()) + mvc.perform(put(TARGETTYPE_DSTYPES_ENDPOINT, testType.getId())) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isMethodNotAllowed()); - mvc.perform(delete(TARGETTYPE_DSTYPES_ENDPOINT, testType.getId(), 565765)).andDo(MockMvcResultPrinter.print()) + mvc.perform(delete(TARGETTYPE_DSTYPES_ENDPOINT, testType.getId(), 565765)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isMethodNotAllowed()); mvc.perform(put(TARGETTYPE_DSTYPE_SINGLE_ENDPOINT, testType.getId(), 565765)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isMethodNotAllowed()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isMethodNotAllowed()); mvc.perform(post(TARGETTYPE_DSTYPE_SINGLE_ENDPOINT, testType.getId(), 565765) - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isMethodNotAllowed()); mvc.perform(get(TARGETTYPE_DSTYPE_SINGLE_ENDPOINT, testType.getId(), 565765)) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isMethodNotAllowed()); + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isMethodNotAllowed()); } @Test @@ -527,9 +574,12 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest { final String rsqlFindLikeDs1OrDs2 = "name==TestName123,name==TestName1234"; - mvc.perform(get(TARGETTYPES_ENDPOINT + "?q=" + rsqlFindLikeDs1OrDs2)).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isOk()).andExpect(jsonPath("size", equalTo(2))) - .andExpect(jsonPath("total", equalTo(2))).andExpect(jsonPath("content[0].name", equalTo("TestName123"))) + mvc.perform(get(TARGETTYPES_ENDPOINT + "?q=" + rsqlFindLikeDs1OrDs2)) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("size", equalTo(2))) + .andExpect(jsonPath("total", equalTo(2))) + .andExpect(jsonPath("content[0].name", equalTo("TestName123"))) .andExpect(jsonPath("content[1].name", equalTo("TestName1234"))); } @@ -551,12 +601,14 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest { // verify quota enforcement for distribution set types mvc.perform(post(TARGETTYPE_DSTYPES_ENDPOINT, testType.getId()) .content(JsonBuilder.ids(dsTypeIds.subList(0, dsTypeIds.size() - 1))) - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); mvc.perform(post(TARGETTYPE_DSTYPES_ENDPOINT, testType.getId()) .content("[{\"id\":" + dsTypeIds.get(dsTypeIds.size() - 1) + "}]") - .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isForbidden()) .andExpect(jsonPath("$.exceptionClass", equalTo(AssignmentQuotaExceededException.class.getName()))) .andExpect(jsonPath("$.errorCode", equalTo(SpServerError.SP_QUOTA_EXCEEDED.getKey()))); @@ -611,7 +663,8 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest { .andDo(MockMvcResultPrinter.print()); for (int index = 0; index < size; index++) { - resultActions.andExpect(status().isCreated()).andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) + resultActions.andExpect(status().isCreated()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$[" + index + "].id").exists()) .andExpect(jsonPath("$[" + index + "].name", startsWith("TestTypePOST"))) .andExpect(jsonPath("$[" + index + "].colour", hasToString("#aaaaaa"))) diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTenantManagementResourceTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTenantManagementResourceTest.java index b71bd87f2..af8bdee0b 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTenantManagementResourceTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTenantManagementResourceTest.java @@ -142,11 +142,13 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg final String bodyDeactivate = new JSONObject().put("value", false).toString(); mvc.perform(put(MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}", KEY_MULTI_ASSIGNMENTS) - .content(bodyActivate).contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .content(bodyActivate).contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); mvc.perform(put(MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}", KEY_MULTI_ASSIGNMENTS) - .content(bodyDeactivate).contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .content(bodyDeactivate).contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isForbidden()); } @@ -212,7 +214,8 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg String body = configuration.toString(); mvc.perform(put(MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs") - .content(body).contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .content(body).contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); //assert all changes were applied after Rest Success @@ -236,17 +239,20 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg // enable Multi-Assignments mvc.perform(put(MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}", KEY_MULTI_ASSIGNMENTS) - .content(bodyActivate).contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .content(bodyActivate).contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()); // try to enable Auto-Close mvc.perform(put(MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}", KEY_AUTO_CLOSE) - .content(bodyActivate).contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .content(bodyActivate).contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isForbidden()); // try to disable Auto-Close mvc.perform(put(MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}", KEY_AUTO_CLOSE) - .content(bodyDeactivate).contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .content(bodyDeactivate).contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(status().isForbidden()); } @@ -337,7 +343,8 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg String body = configuration.toString(); mvc.perform(put(MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs") - .content(body).contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .content(body).contentType(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()) .andExpect(resultMatchers); //Check if TenantMetadata and TenantConfiguration is not changed as Batch config failed assertEquals(oldDefaultDsType, getActualDefaultDsType(), diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/util/ResourceUtility.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/util/ResourceUtility.java index a7a2cc89d..074c24fa0 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/util/ResourceUtility.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/util/ResourceUtility.java @@ -11,8 +11,6 @@ package org.eclipse.hawkbit.mgmt.rest.resource.util; import java.io.IOException; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import org.eclipse.hawkbit.mgmt.json.model.PagedList; import org.eclipse.hawkbit.mgmt.json.model.artifact.MgmtArtifact; @@ -23,21 +21,17 @@ import org.eclipse.hawkbit.rest.json.model.ExceptionInfo; */ public final class ResourceUtility { - private static final ObjectMapper mapper = new ObjectMapper(); + private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); - public static ExceptionInfo convertException(final String jsonExceptionResponse) - throws JsonParseException, JsonMappingException, IOException { - return mapper.readValue(jsonExceptionResponse, ExceptionInfo.class); + public static ExceptionInfo convertException(final String jsonExceptionResponse) throws IOException { + return OBJECT_MAPPER.readValue(jsonExceptionResponse, ExceptionInfo.class); } - public static MgmtArtifact convertArtifactResponse(final String jsonResponse) - throws JsonParseException, JsonMappingException, IOException { - return mapper.readValue(jsonResponse, MgmtArtifact.class); - + public static MgmtArtifact convertArtifactResponse(final String jsonResponse) throws IOException { + return OBJECT_MAPPER.readValue(jsonResponse, MgmtArtifact.class); } - public static PagedList mapResponse(final Class clazz, final String responseBody) - throws JsonParseException, JsonMappingException, IOException { - return mapper.readValue(responseBody, PagedList.class); + public static PagedList mapResponse(final Class clazz, final String responseBody) throws IOException { + return OBJECT_MAPPER.readValue(responseBody, PagedList.class); } -} +} \ No newline at end of file diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/util/SortUtilityTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/util/SortUtilityTest.java index f67244e1e..15d8c986c 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/util/SortUtilityTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/util/SortUtilityTest.java @@ -77,4 +77,4 @@ public class SortUtilityTest { assertThrows(SortParameterUnsupportedFieldException.class, () -> SortUtility.parse(TargetFields.class, WRONG_FIELD_PARAM)); } -} +} \ No newline at end of file diff --git a/hawkbit-mgmt/hawkbit-mgmt-server/src/main/java/org/eclipse/hawkbit/app/mgmt/ErrorController.java b/hawkbit-mgmt/hawkbit-mgmt-server/src/main/java/org/eclipse/hawkbit/app/mgmt/ErrorController.java index 8f6250ccf..b48665066 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-server/src/main/java/org/eclipse/hawkbit/app/mgmt/ErrorController.java +++ b/hawkbit-mgmt/hawkbit-mgmt-server/src/main/java/org/eclipse/hawkbit/app/mgmt/ErrorController.java @@ -65,4 +65,4 @@ public class ErrorController extends BasicErrorController { } return body; } -} +} \ No newline at end of file diff --git a/hawkbit-mgmt/hawkbit-mgmt-server/src/main/java/org/eclipse/hawkbit/app/mgmt/MgmtServerStart.java b/hawkbit-mgmt/hawkbit-mgmt-server/src/main/java/org/eclipse/hawkbit/app/mgmt/MgmtServerStart.java index 58a328efb..749a9f33c 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-server/src/main/java/org/eclipse/hawkbit/app/mgmt/MgmtServerStart.java +++ b/hawkbit-mgmt/hawkbit-mgmt-server/src/main/java/org/eclipse/hawkbit/app/mgmt/MgmtServerStart.java @@ -48,7 +48,5 @@ public class MgmtServerStart { @Configuration @EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true, proxyTargetClass = true) - public static class MethodSecurityConfig { - - } -} + public static class MethodSecurityConfig {} +} \ No newline at end of file diff --git a/hawkbit-mgmt/hawkbit-mgmt-starter/src/main/java/org/eclipse/hawkbit/autoconfigure/mgmt/MgmtApiAutoConfiguration.java b/hawkbit-mgmt/hawkbit-mgmt-starter/src/main/java/org/eclipse/hawkbit/autoconfigure/mgmt/MgmtApiAutoConfiguration.java index 23250e561..bd14f4192 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-starter/src/main/java/org/eclipse/hawkbit/autoconfigure/mgmt/MgmtApiAutoConfiguration.java +++ b/hawkbit-mgmt/hawkbit-mgmt-starter/src/main/java/org/eclipse/hawkbit/autoconfigure/mgmt/MgmtApiAutoConfiguration.java @@ -20,6 +20,4 @@ import org.springframework.context.annotation.Import; @Configuration @ConditionalOnClass(MgmtApiConfiguration.class) @Import(MgmtApiConfiguration.class) -public class MgmtApiAutoConfiguration { - -} +public class MgmtApiAutoConfiguration {} \ No newline at end of file diff --git a/hawkbit-mgmt/hawkbit-mgmt-starter/src/main/java/org/eclipse/hawkbit/autoconfigure/mgmt/MgmtSecurityConfiguration.java b/hawkbit-mgmt/hawkbit-mgmt-starter/src/main/java/org/eclipse/hawkbit/autoconfigure/mgmt/MgmtSecurityConfiguration.java index 6b4787f2c..8a5b2dc1f 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-starter/src/main/java/org/eclipse/hawkbit/autoconfigure/mgmt/MgmtSecurityConfiguration.java +++ b/hawkbit-mgmt/hawkbit-mgmt-starter/src/main/java/org/eclipse/hawkbit/autoconfigure/mgmt/MgmtSecurityConfiguration.java @@ -11,10 +11,10 @@ package org.eclipse.hawkbit.autoconfigure.mgmt; import java.util.List; -import org.eclipse.hawkbit.rest.SecurityManagedConfiguration; import org.eclipse.hawkbit.im.authentication.SpPermission; import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; import org.eclipse.hawkbit.repository.SystemManagement; +import org.eclipse.hawkbit.rest.SecurityManagedConfiguration; import org.eclipse.hawkbit.rest.security.DosFilter; import org.eclipse.hawkbit.security.HawkbitSecurityProperties; import org.eclipse.hawkbit.security.MdcHandler; diff --git a/hawkbit-simple-ui/src/main/java/org/eclipse/hawkbit/ui/simple/view/DistributionSetView.java b/hawkbit-simple-ui/src/main/java/org/eclipse/hawkbit/ui/simple/view/DistributionSetView.java index df376d869..cdede99d5 100644 --- a/hawkbit-simple-ui/src/main/java/org/eclipse/hawkbit/ui/simple/view/DistributionSetView.java +++ b/hawkbit-simple-ui/src/main/java/org/eclipse/hawkbit/ui/simple/view/DistributionSetView.java @@ -45,7 +45,7 @@ import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtDistributionSet; import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtDistributionSetRequestBodyPost; import org.eclipse.hawkbit.mgmt.json.model.distributionsettype.MgmtDistributionSetType; import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModule; -import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleAssigment; +import org.eclipse.hawkbit.mgmt.json.model.softwaremodule.MgmtSoftwareModuleAssignment; import org.eclipse.hawkbit.mgmt.json.model.tag.MgmtTag; import org.eclipse.hawkbit.ui.simple.HawkbitMgmtClient; import org.eclipse.hawkbit.ui.simple.MainLayout; @@ -317,7 +317,7 @@ public class DistributionSetView extends TableView { finishBtn.addClickListener(e -> { hawkbitClient.getDistributionSetRestApi().assignSoftwareModules( distributionSetId, softwareModules.stream().map(softwareModule -> { - final MgmtSoftwareModuleAssigment assignment = new MgmtSoftwareModuleAssigment(); + final MgmtSoftwareModuleAssignment assignment = new MgmtSoftwareModuleAssignment(); assignment.setId(softwareModule.getModuleId()); return assignment; }).toList());