From 4b460d8e6841310a139b2fc63fce76896eaa21ff Mon Sep 17 00:00:00 2001
From: Avgustin Marinov
Date: Tue, 5 Nov 2024 11:32:28 +0200
Subject: [PATCH] Code format hawkbit-rest-core (#1944)
Signed-off-by: Marinov Avgustin
---
hawkbit-rest/hawkbit-rest-core/pom.xml | 168 +++++++++---------
.../hawkbit/rest/OpenApiConfiguration.java | 145 +++++++--------
.../hawkbit/rest/RestConfiguration.java | 3 -
.../hawkbit/rest/data/ResponseList.java | 25 ++-
.../hawkbit/rest/data/SortDirection.java | 8 +-
.../MessageNotReadableException.java | 4 +-
.../MultiPartFileUploadException.java | 4 +-
.../exception/ResponseExceptionHandler.java | 47 ++---
.../SortParameterSyntaxErrorException.java | 8 +-
...arameterUnsupportedDirectionException.java | 17 +-
...ortParameterUnsupportedFieldException.java | 17 +-
.../util/FileStreamingFailedException.java | 18 +-
.../util/FileStreamingProgressListener.java | 12 +-
.../hawkbit/rest/util/FileStreamingUtil.java | 78 ++++----
.../eclipse/hawkbit/rest/util/HttpUtil.java | 7 +-
.../util/RequestResponseContextHolder.java | 4 +-
.../hawkbit/rest/util/SortUtility.java | 47 ++---
.../rest/AbstractRestIntegrationTest.java | 8 +-
...ExcludePathAwareShallowETagFilterTest.java | 5 +-
.../rest/json/model/ExceptionInfoTest.java | 3 +-
.../rest/util/FileStreamingUtilTest.java | 6 +-
.../hawkbit/rest/util/JsonBuilder.java | 69 ++++---
.../hawkbit/rest/util/SortUtilityTest.java | 8 +-
.../hawkbit/rest/util/SuccessCondition.java | 2 -
24 files changed, 315 insertions(+), 398 deletions(-)
diff --git a/hawkbit-rest/hawkbit-rest-core/pom.xml b/hawkbit-rest/hawkbit-rest-core/pom.xml
index ebe271090..e7e888c44 100644
--- a/hawkbit-rest/hawkbit-rest-core/pom.xml
+++ b/hawkbit-rest/hawkbit-rest-core/pom.xml
@@ -9,92 +9,92 @@
SPDX-License-Identifier: EPL-2.0
-->
-
- 4.0.0
-
- org.eclipse.hawkbit
- hawkbit-rest-parent
- ${revision}
-
- hawkbit-rest-core
- hawkBit :: REST :: Core
+
+ 4.0.0
+
+ org.eclipse.hawkbit
+ hawkbit-rest-parent
+ ${revision}
+
+ hawkbit-rest-core
+ hawkBit :: REST :: Core
-
-
- org.eclipse.hawkbit
- hawkbit-core
- ${project.version}
-
-
- org.apache.commons
- commons-lang3
-
-
- org.springframework.boot
- spring-boot-starter-web
-
-
- org.springframework.hateoas
- spring-hateoas
-
-
- org.springframework.data
- spring-data-commons
-
-
- org.springframework.boot
- spring-boot-starter-json
-
-
- org.springdoc
- springdoc-openapi-starter-webmvc-ui
-
-
- jakarta.servlet
- jakarta.servlet-api
- provided
-
+
+
+ org.eclipse.hawkbit
+ hawkbit-core
+ ${project.version}
+
+
+ org.apache.commons
+ commons-lang3
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+ org.springframework.hateoas
+ spring-hateoas
+
+
+ org.springframework.data
+ spring-data-commons
+
+
+ org.springframework.boot
+ spring-boot-starter-json
+
+
+ org.springdoc
+ springdoc-openapi-starter-webmvc-ui
+
+
+ jakarta.servlet
+ jakarta.servlet-api
+ provided
+
-
-
- org.eclipse.hawkbit
- hawkbit-repository-test
- ${project.version}
- test
-
-
- org.eclipse.hawkbit
- hawkbit-repository-jpa
- ${project.version}
- test
-
-
- io.qameta.allure
- allure-junit5
- test
-
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
+
+
+ org.eclipse.hawkbit
+ hawkbit-repository-test
+ ${project.version}
+ test
+
+
+ org.eclipse.hawkbit
+ hawkbit-repository-jpa
+ ${project.version}
+ test
+
+
+ io.qameta.allure
+ allure-junit5
+ test
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
-
-
-
- org.apache.maven.plugins
- maven-jar-plugin
-
-
-
- test-jar
-
-
-
-
-
-
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+
+
+
+ test-jar
+
+
+
+
+
+
\ No newline at end of file
diff --git a/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/OpenApiConfiguration.java b/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/OpenApiConfiguration.java
index a7b2c4337..6c3a40c0d 100644
--- a/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/OpenApiConfiguration.java
+++ b/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/OpenApiConfiguration.java
@@ -20,83 +20,84 @@ import org.springframework.context.annotation.Configuration;
@Configuration
@ConditionalOnProperty(
- value="hawkbit.server.swagger.enabled",
- havingValue = "true",
- matchIfMissing = true)
+ value = "hawkbit.server.swagger.enabled",
+ havingValue = "true",
+ matchIfMissing = true)
public class OpenApiConfiguration {
- private static final String API_TITLE = "hawkBit REST APIs";
- private static final String API_VERSION = "v1";
- private static final String DESCRIPTION = """
- Eclipse hawkBit™ is a domain-independent back-end framework for rolling out software updates to constrained edge devices as well as more powerful controllers and gateways connected to IP based networking infrastructure.
- """;
+ private static final String API_TITLE = "hawkBit REST APIs";
+ private static final String API_VERSION = "v1";
+ private static final String DESCRIPTION = """
+ Eclipse hawkBit™ is a domain-independent back-end framework for rolling out software updates to constrained edge devices as well as more powerful controllers and gateways connected to IP based networking infrastructure.
+ """;
- private static final String BASIC_AUTH_SEC_SCHEME_NAME = "Basic Authentication";
- private static final String BEARER_AUTH_SEC_SCHEME_NAME = "Bearer Authentication";
- private static final String DDI_TOKEN_SEC_SCHEME_NAME = "DDI Target/GatewayToken Authentication";
+ private static final String BASIC_AUTH_SEC_SCHEME_NAME = "Basic Authentication";
+ private static final String BEARER_AUTH_SEC_SCHEME_NAME = "Bearer Authentication";
+ private static final String DDI_TOKEN_SEC_SCHEME_NAME = "DDI Target/GatewayToken Authentication";
- @Bean
- public OpenAPI openApi() {
- return new OpenAPI().info(new Info().title(API_TITLE).version(API_VERSION).description(DESCRIPTION));
- }
+ @Bean
+ public OpenAPI openApi() {
+ return new OpenAPI().info(new Info().title(API_TITLE).version(API_VERSION).description(DESCRIPTION));
+ }
- @Bean
- @ConditionalOnProperty(
- value="hawkbit.server.swagger.mgmt.api.group.enabled",
- havingValue = "true",
- matchIfMissing = true)
- public GroupedOpenApi mgmtApi() {
- return GroupedOpenApi
- .builder()
- .group("Management API")
- .pathsToMatch("/rest/v1/**")
- .addOpenApiCustomizer(openApi -> {
- openApi
- .addSecurityItem(new SecurityRequirement()
- .addList(BASIC_AUTH_SEC_SCHEME_NAME)
- .addList(BEARER_AUTH_SEC_SCHEME_NAME))
- .components(
+ @Bean
+ @ConditionalOnProperty(
+ value = "hawkbit.server.swagger.mgmt.api.group.enabled",
+ havingValue = "true",
+ matchIfMissing = true)
+ public GroupedOpenApi mgmtApi() {
+ return GroupedOpenApi
+ .builder()
+ .group("Management API")
+ .pathsToMatch("/rest/v1/**")
+ .addOpenApiCustomizer(openApi -> {
openApi
- .getComponents()
- .addSecuritySchemes(BASIC_AUTH_SEC_SCHEME_NAME,
- new SecurityScheme()
- .name(BASIC_AUTH_SEC_SCHEME_NAME)
- .type(SecurityScheme.Type.HTTP)
- .in(SecurityScheme.In.HEADER)
- .scheme("basic"))
- .addSecuritySchemes(BEARER_AUTH_SEC_SCHEME_NAME,
- new SecurityScheme()
- .name(BEARER_AUTH_SEC_SCHEME_NAME)
- .type(SecurityScheme.Type.HTTP)
- .in(SecurityScheme.In.HEADER)
- .bearerFormat("JWT")
- .scheme("bearer")));
- })
- .build();
- }
- @Bean
- @ConditionalOnProperty(
- value="hawkbit.server.swagger.ddi.api.group.enabled",
- havingValue = "true",
- matchIfMissing = true)
- public GroupedOpenApi ddiApi() {
- return GroupedOpenApi
- .builder()
- .group("Direct Device Integration API")
- .pathsToMatch("/{tenant}/controller/**")
- .addOpenApiCustomizer(openApi -> {
- openApi
- .addSecurityItem(new SecurityRequirement().addList(DDI_TOKEN_SEC_SCHEME_NAME))
- .components(
+ .addSecurityItem(new SecurityRequirement()
+ .addList(BASIC_AUTH_SEC_SCHEME_NAME)
+ .addList(BEARER_AUTH_SEC_SCHEME_NAME))
+ .components(
+ openApi
+ .getComponents()
+ .addSecuritySchemes(BASIC_AUTH_SEC_SCHEME_NAME,
+ new SecurityScheme()
+ .name(BASIC_AUTH_SEC_SCHEME_NAME)
+ .type(SecurityScheme.Type.HTTP)
+ .in(SecurityScheme.In.HEADER)
+ .scheme("basic"))
+ .addSecuritySchemes(BEARER_AUTH_SEC_SCHEME_NAME,
+ new SecurityScheme()
+ .name(BEARER_AUTH_SEC_SCHEME_NAME)
+ .type(SecurityScheme.Type.HTTP)
+ .in(SecurityScheme.In.HEADER)
+ .bearerFormat("JWT")
+ .scheme("bearer")));
+ })
+ .build();
+ }
+
+ @Bean
+ @ConditionalOnProperty(
+ value = "hawkbit.server.swagger.ddi.api.group.enabled",
+ havingValue = "true",
+ matchIfMissing = true)
+ public GroupedOpenApi ddiApi() {
+ return GroupedOpenApi
+ .builder()
+ .group("Direct Device Integration API")
+ .pathsToMatch("/{tenant}/controller/**")
+ .addOpenApiCustomizer(openApi -> {
openApi
- .getComponents()
- .addSecuritySchemes(DDI_TOKEN_SEC_SCHEME_NAME,
- new SecurityScheme()
- .name("Authorization")
- .type(SecurityScheme.Type.APIKEY)
- .in(SecurityScheme.In.HEADER)
- .description("Format: (Target|Gateway)Token <token>")));
- })
- .build();
- }
+ .addSecurityItem(new SecurityRequirement().addList(DDI_TOKEN_SEC_SCHEME_NAME))
+ .components(
+ openApi
+ .getComponents()
+ .addSecuritySchemes(DDI_TOKEN_SEC_SCHEME_NAME,
+ new SecurityScheme()
+ .name("Authorization")
+ .type(SecurityScheme.Type.APIKEY)
+ .in(SecurityScheme.In.HEADER)
+ .description("Format: (Target|Gateway)Token <token>")));
+ })
+ .build();
+ }
}
diff --git a/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/RestConfiguration.java b/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/RestConfiguration.java
index 4bb1ff6c0..e1991554c 100644
--- a/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/RestConfiguration.java
+++ b/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/RestConfiguration.java
@@ -9,8 +9,6 @@
*/
package org.eclipse.hawkbit.rest;
-import jakarta.servlet.http.HttpServletResponse;
-
import org.eclipse.hawkbit.rest.exception.ResponseExceptionHandler;
import org.eclipse.hawkbit.rest.filter.ExcludePathAwareShallowETagFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
@@ -20,7 +18,6 @@ import org.springframework.hateoas.config.EnableHypermediaSupport;
import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ControllerAdvice;
-import org.springframework.web.context.WebApplicationContext;
/**
* Configuration for Rest api.
diff --git a/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/data/ResponseList.java b/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/data/ResponseList.java
index b7bd91fad..cfbd977cf 100644
--- a/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/data/ResponseList.java
+++ b/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/data/ResponseList.java
@@ -18,7 +18,7 @@ import org.springframework.hateoas.RepresentationModel;
/**
* List that extends RepresentationModel to ensure that links in content are in HAL format.
- *
+ *
* @param of the response content
*/
public class ResponseList extends RepresentationModel> implements List {
@@ -26,8 +26,7 @@ public class ResponseList extends RepresentationModel> implem
private final List content;
/**
- * @param content
- * to delegate
+ * @param content to delegate
*/
public ResponseList(final List content) {
this.content = content;
@@ -103,16 +102,6 @@ public class ResponseList extends RepresentationModel> implem
content.clear();
}
- @Override
- public boolean equals(final Object o) {
- return content.equals(o);
- }
-
- @Override
- public int hashCode() {
- return content.hashCode();
- }
-
@Override
public T get(final int index) {
return content.get(index);
@@ -163,4 +152,14 @@ public class ResponseList extends RepresentationModel> implem
return "ResponseList [content=" + content + "]";
}
+ @Override
+ public boolean equals(final Object o) {
+ return content.equals(o);
+ }
+
+ @Override
+ public int hashCode() {
+ return content.hashCode();
+ }
+
}
diff --git a/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/data/SortDirection.java b/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/data/SortDirection.java
index 370d562a5..cdb412f79 100644
--- a/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/data/SortDirection.java
+++ b/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/data/SortDirection.java
@@ -26,12 +26,10 @@ public enum SortDirection {
/**
* Returns the sort direction for the given name.
- *
- * @param name
- * the name of the enum
+ *
+ * @param name the name of the enum
* @return the corresponding enum
- * @throws SortParameterUnsupportedDirectionException
- * if there is no matching enum for the specified name
+ * @throws SortParameterUnsupportedDirectionException if there is no matching enum for the specified name
*/
public static SortDirection getByName(final String name) {
try {
diff --git a/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/exception/MessageNotReadableException.java b/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/exception/MessageNotReadableException.java
index 9080a40d9..a2f0ef00c 100644
--- a/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/exception/MessageNotReadableException.java
+++ b/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/exception/MessageNotReadableException.java
@@ -9,11 +9,11 @@
*/
package org.eclipse.hawkbit.rest.exception;
+import java.io.Serial;
+
import org.eclipse.hawkbit.exception.AbstractServerRtException;
import org.eclipse.hawkbit.exception.SpServerError;
-import java.io.Serial;
-
/**
* Exception which is thrown in case an request body is not well formatted and
* cannot be parsed.
diff --git a/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/exception/MultiPartFileUploadException.java b/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/exception/MultiPartFileUploadException.java
index fe9f68b6e..00f498e4c 100644
--- a/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/exception/MultiPartFileUploadException.java
+++ b/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/exception/MultiPartFileUploadException.java
@@ -14,15 +14,13 @@ import org.eclipse.hawkbit.exception.SpServerError;
/**
* Thrown if a multi part exception occurred.
- *
*/
public final class MultiPartFileUploadException extends AbstractServerRtException {
private static final long serialVersionUID = 1L;
/**
- * @param cause
- * for the exception
+ * @param cause for the exception
*/
public MultiPartFileUploadException(final Throwable cause) {
super(cause.getMessage(), SpServerError.SP_ARTIFACT_UPLOAD_FAILED, cause);
diff --git a/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/exception/ResponseExceptionHandler.java b/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/exception/ResponseExceptionHandler.java
index bf7a0a5c2..a4eb75f5e 100644
--- a/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/exception/ResponseExceptionHandler.java
+++ b/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/exception/ResponseExceptionHandler.java
@@ -99,19 +99,12 @@ public class ResponseExceptionHandler {
ERROR_TO_HTTP_STATUS.put(SpServerError.SP_STOP_ROLLOUT_FAILED, HttpStatus.LOCKED);
}
- private static HttpStatus getStatusOrDefault(final SpServerError error) {
- return ERROR_TO_HTTP_STATUS.getOrDefault(error, DEFAULT_RESPONSE_STATUS);
- }
-
/**
* method for handling exception of type AbstractServerRtException. Called
* by the Spring-Framework for exception handling.
*
- * @param request
- * the Http request
- * @param ex
- * the exception which occurred
- *
+ * @param request the Http request
+ * @param ex the exception which occurred
* @return the entity to be responded containing the exception information
* as entity.
*/
@@ -137,10 +130,8 @@ public class ResponseExceptionHandler {
* ResponseStatus 500 is returned. Called by the Spring-Framework for
* exception handling.
*
- * @param request
- * the Http request
- * @param ex
- * the exception which occurred
+ * @param request the Http request
+ * @param ex the exception which occurred
* @return the entity to be responded containing the response status 500
*/
@ExceptionHandler(FileStreamingFailedException.class)
@@ -158,10 +149,8 @@ public class ResponseExceptionHandler {
* cannot be deserialized. Called by the Spring-Framework for exception
* handling.
*
- * @param request
- * the Http request
- * @param ex
- * the exception which occurred
+ * @param request the Http request
+ * @param ex the exception which occurred
* @return the entity to be responded containing the exception information
* as entity.
*/
@@ -181,10 +170,8 @@ public class ResponseExceptionHandler {
* is thrown in case the request is rejected due to a constraint violation.
* Called by the Spring-Framework for exception handling.
*
- * @param request
- * the Http request
- * @param ex
- * the exception which occurred
+ * @param request the Http request
+ * @param ex the exception which occurred
* @return the entity to be responded containing the exception information
* as entity.
*/
@@ -195,7 +182,7 @@ public class ResponseExceptionHandler {
final ExceptionInfo response = new ExceptionInfo();
response.setMessage(ex.getConstraintViolations().stream().map(
- violation -> violation.getPropertyPath() + MESSAGE_FORMATTER_SEPARATOR + violation.getMessage() + ".")
+ violation -> violation.getPropertyPath() + MESSAGE_FORMATTER_SEPARATOR + violation.getMessage() + ".")
.collect(Collectors.joining(MESSAGE_FORMATTER_SEPARATOR)));
response.setExceptionClass(ex.getClass().getName());
response.setErrorCode(SpServerError.SP_REPO_CONSTRAINT_VIOLATION.getKey());
@@ -208,10 +195,8 @@ public class ResponseExceptionHandler {
* in case the request is rejected due to invalid requests. Called by the
* Spring-Framework for exception handling.
*
- * @param request
- * the Http request
- * @param ex
- * the exception which occurred
+ * @param request the Http request
+ * @param ex the exception which occurred
* @return the entity to be responded containing the exception information
* as entity.
*/
@@ -233,10 +218,8 @@ public class ResponseExceptionHandler {
* thrown in case the request body is not well formed and cannot be
* deserialized. Called by the Spring-Framework for exception handling.
*
- * @param request
- * the Http request
- * @param ex
- * the exception which occurred
+ * @param request the Http request
+ * @param ex the exception which occurred
* @return the entity to be responded containing the exception information
* as entity.
*/
@@ -258,6 +241,10 @@ public class ResponseExceptionHandler {
return new ResponseEntity<>(response, HttpStatus.BAD_REQUEST);
}
+ private static HttpStatus getStatusOrDefault(final SpServerError error) {
+ return ERROR_TO_HTTP_STATUS.getOrDefault(error, DEFAULT_RESPONSE_STATUS);
+ }
+
private void logRequest(final HttpServletRequest request, final Exception ex) {
log.debug("Handling exception {} of request {}", ex.getClass().getName(), request.getRequestURL());
}
diff --git a/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/exception/SortParameterSyntaxErrorException.java b/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/exception/SortParameterSyntaxErrorException.java
index 6a3b1afed..d63c17a1a 100644
--- a/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/exception/SortParameterSyntaxErrorException.java
+++ b/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/exception/SortParameterSyntaxErrorException.java
@@ -14,16 +14,12 @@ import org.eclipse.hawkbit.exception.SpServerError;
/**
* Exception used by the REST API in case of invalid sort parameter syntax.
- *
- *
- *
- *
*/
public class SortParameterSyntaxErrorException extends AbstractServerRtException {
/**
- *
- */
+ *
+ */
private static final long serialVersionUID = 1L;
/**
diff --git a/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/exception/SortParameterUnsupportedDirectionException.java b/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/exception/SortParameterUnsupportedDirectionException.java
index 6c2ef2ea2..183264602 100644
--- a/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/exception/SortParameterUnsupportedDirectionException.java
+++ b/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/exception/SortParameterUnsupportedDirectionException.java
@@ -15,16 +15,12 @@ import org.eclipse.hawkbit.exception.SpServerError;
/**
* Exception used by the REST API in case of invalid sort parameter direction
* name.
- *
- *
- *
- *
*/
public class SortParameterUnsupportedDirectionException extends AbstractServerRtException {
/**
- *
- */
+ *
+ */
private static final long serialVersionUID = 1L;
/**
@@ -37,11 +33,10 @@ public class SortParameterUnsupportedDirectionException extends AbstractServerRt
/**
* Creates a new SortParameterSyntaxErrorException with
* {@link SpServerError#SP_REST_SORT_PARAM_INVALID_DIRECTION} error.
- *
- * @param cause
- * the cause (which is saved for later retrieval by the
- * getCause() method). (A null value is permitted, and indicates
- * that the cause is nonexistent or unknown.)
+ *
+ * @param cause the cause (which is saved for later retrieval by the
+ * getCause() method). (A null value is permitted, and indicates
+ * that the cause is nonexistent or unknown.)
*/
public SortParameterUnsupportedDirectionException(final Throwable cause) {
super(SpServerError.SP_REST_SORT_PARAM_INVALID_DIRECTION, cause);
diff --git a/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/exception/SortParameterUnsupportedFieldException.java b/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/exception/SortParameterUnsupportedFieldException.java
index deedb8185..4d7f595eb 100644
--- a/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/exception/SortParameterUnsupportedFieldException.java
+++ b/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/exception/SortParameterUnsupportedFieldException.java
@@ -15,16 +15,12 @@ import org.eclipse.hawkbit.exception.SpServerError;
/**
* Exception used by the REST API in case of invalid field name in the sort
* parameter.
- *
- *
- *
- *
*/
public class SortParameterUnsupportedFieldException extends AbstractServerRtException {
/**
- *
- */
+ *
+ */
private static final long serialVersionUID = 1L;
/**
@@ -38,11 +34,10 @@ public class SortParameterUnsupportedFieldException extends AbstractServerRtExce
/**
* Creates a new SortParameterSyntaxErrorException with
* {@link SpServerError#SP_REST_SORT_PARAM_INVALID_FIELD} error.
- *
- * @param cause
- * the cause (which is saved for later retrieval by the
- * getCause() method). (A null value is permitted, and indicates
- * that the cause is nonexistent or unknown.)
+ *
+ * @param cause the cause (which is saved for later retrieval by the
+ * getCause() method). (A null value is permitted, and indicates
+ * that the cause is nonexistent or unknown.)
*/
public SortParameterUnsupportedFieldException(final Throwable cause) {
super(SpServerError.SP_REST_SORT_PARAM_INVALID_FIELD, cause);
diff --git a/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/util/FileStreamingFailedException.java b/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/util/FileStreamingFailedException.java
index f36eb84d3..3b35da110 100644
--- a/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/util/FileStreamingFailedException.java
+++ b/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/util/FileStreamingFailedException.java
@@ -29,9 +29,8 @@ public final class FileStreamingFailedException extends AbstractServerRtExceptio
/**
* Constructor with Throwable.
- *
- * @param cause
- * for the exception
+ *
+ * @param cause for the exception
*/
public FileStreamingFailedException(final Throwable cause) {
super(SpServerError.SP_ARTIFACT_LOAD_FAILED, cause);
@@ -39,9 +38,8 @@ public final class FileStreamingFailedException extends AbstractServerRtExceptio
/**
* Constructor with error string.
- *
- * @param message
- * of the error
+ *
+ * @param message of the error
*/
public FileStreamingFailedException(final String message) {
super(message, SpServerError.SP_ARTIFACT_LOAD_FAILED);
@@ -49,11 +47,9 @@ public final class FileStreamingFailedException extends AbstractServerRtExceptio
/**
* Constructor with error string and cause.
- *
- * @param message
- * of the error
- * @param cause
- * for the exception
+ *
+ * @param message of the error
+ * @param cause for the exception
*/
public FileStreamingFailedException(final String message, final Throwable cause) {
super(message, SpServerError.SP_ARTIFACT_LOAD_FAILED, cause);
diff --git a/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/util/FileStreamingProgressListener.java b/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/util/FileStreamingProgressListener.java
index 1b5f14ebc..331c20e24 100644
--- a/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/util/FileStreamingProgressListener.java
+++ b/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/util/FileStreamingProgressListener.java
@@ -11,20 +11,16 @@ package org.eclipse.hawkbit.rest.util;
/**
* Listener for progress on artifact file streaming.
- *
*/
@FunctionalInterface
public interface FileStreamingProgressListener {
/**
* Called multiple times during streaming.
- *
- * @param requestedBytes
- * requested bytes of the request
- * @param shippedBytesSinceLast
- * since the last report
- * @param shippedBytesOverall
- * during the request
+ *
+ * @param requestedBytes requested bytes of the request
+ * @param shippedBytesSinceLast since the last report
+ * @param shippedBytesOverall during the request
*/
void progress(long requestedBytes, long shippedBytesSinceLast, long shippedBytesOverall);
}
diff --git a/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/util/FileStreamingUtil.java b/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/util/FileStreamingUtil.java
index b0f56787c..9642a2145 100644
--- a/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/util/FileStreamingUtil.java
+++ b/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/util/FileStreamingUtil.java
@@ -12,7 +12,6 @@ package org.eclipse.hawkbit.rest.util;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.math.RoundingMode;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashMap;
@@ -46,19 +45,15 @@ public final class FileStreamingUtil {
*/
public static final String ARTIFACT_MD5_DWNL_SUFFIX = ".MD5SUM";
private static final int BUFFER_SIZE = 0x2000; // 8k
-
+
/**
* Write a md5 file response.
*
- * @param response
- * the response
- * @param md5Hash
- * of the artifact
- * @param filename
- * as provided by the client
+ * @param response the response
+ * @param md5Hash of the artifact
+ * @param filename as provided by the client
* @return the response
- * @throws IOException
- * cannot write output stream
+ * @throws IOException cannot write output stream
*/
public static ResponseEntity writeMD5FileResponse(final HttpServletResponse response, final String md5Hash,
final String filename) throws IOException {
@@ -94,26 +89,16 @@ public final class FileStreamingUtil {
* The request supports RFC7233 range requests.
*
*
- * @param artifact
- * the artifact
- * @param filename
- * to be written to the client response
- * @param lastModified
- * unix timestamp of the artifact
- * @param response
- * to be sent back to the requesting client
- * @param request
- * from the client
- * @param progressListener
- * to write progress updates to
- *
+ * @param artifact the artifact
+ * @param filename to be written to the client response
+ * @param lastModified unix timestamp of the artifact
+ * @param response to be sent back to the requesting client
+ * @param request from the client
+ * @param progressListener to write progress updates to
* @return http response
- *
+ * @throws FileStreamingFailedException if streaming fails
* @see https://tools.ietf.org
- * /html/rfc7233
- *
- * @throws FileStreamingFailedException
- * if streaming fails
+ * /html/rfc7233
*/
public static ResponseEntity writeFileResponse(final DbArtifact artifact, final String filename,
final long lastModified, final HttpServletResponse response, final HttpServletRequest request,
@@ -187,7 +172,7 @@ public final class FileStreamingUtil {
return result;
}
- private static void resetResponseExceptHeaders(final HttpServletResponse response){
+ private static void resetResponseExceptHeaders(final HttpServletResponse response) {
// do backup the current headers (like CORS related)
final Map storedHeaders = new HashMap<>();
for (final String header : response.getHeaderNames()) {
@@ -359,7 +344,7 @@ public final class FileStreamingUtil {
}
if (progressListener != null) {
- final int newPercent = (int)Math.floor(total * 100.0 / length);
+ final int newPercent = (int) Math.floor(total * 100.0 / length);
// every 10 percent an event
if (newPercent == 100 || newPercent > progressPercent + 10) {
@@ -383,6 +368,7 @@ public final class FileStreamingUtil {
}
private static final class ByteRange {
+
private static final String MULTIPART_BOUNDARY = "THIS_STRING_SEPARATES_MULTIPART";
private final long start;
@@ -397,22 +383,6 @@ public final class FileStreamingUtil {
this.total = total;
}
- private long getStart() {
- return start;
- }
-
- private long getEnd() {
- return end;
- }
-
- private long getLength() {
- return length;
- }
-
- private long getTotal() {
- return total;
- }
-
@Override
// Generated code
@SuppressWarnings("squid:S864")
@@ -455,6 +425,22 @@ public final class FileStreamingUtil {
return true;
}
+ private long getStart() {
+ return start;
+ }
+
+ private long getEnd() {
+ return end;
+ }
+
+ private long getLength() {
+ return length;
+ }
+
+ private long getTotal() {
+ return total;
+ }
+
}
}
diff --git a/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/util/HttpUtil.java b/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/util/HttpUtil.java
index 4d4034a2b..e62118f3f 100644
--- a/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/util/HttpUtil.java
+++ b/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/util/HttpUtil.java
@@ -23,11 +23,8 @@ public final class HttpUtil {
/**
* Checks given CSV string for defined match value or wildcard.
*
- * @param matchHeader
- * to search through
- * @param toMatch
- * to search for
- *
+ * @param matchHeader to search through
+ * @param toMatch to search for
* @return true if string matches.
*/
public static boolean matchesHttpHeader(final String matchHeader, final String toMatch) {
diff --git a/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/util/RequestResponseContextHolder.java b/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/util/RequestResponseContextHolder.java
index 4a9a656bd..2dc3078ce 100644
--- a/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/util/RequestResponseContextHolder.java
+++ b/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/util/RequestResponseContextHolder.java
@@ -9,6 +9,8 @@
*/
package org.eclipse.hawkbit.rest.util;
+import java.util.Objects;
+
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
@@ -16,8 +18,6 @@ import lombok.NoArgsConstructor;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
-import java.util.Objects;
-
/**
* Gives access to the request and response for the rest resources.
*/
diff --git a/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/util/SortUtility.java b/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/util/SortUtility.java
index 06be0abfd..41a026c8b 100644
--- a/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/util/SortUtility.java
+++ b/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/util/SortUtility.java
@@ -23,9 +23,6 @@ import org.springframework.data.domain.Sort.Order;
/**
* A utility class for parsing query parameters which define the sorting of
* elements.
- *
- *
- *
*/
public final class SortUtility {
@@ -47,25 +44,19 @@ public final class SortUtility {
* of sorting: http://localhost/entity?s=field1:ASC, field2:DESC The fields
* will be split into the keys of the returned map. The direction of the
* sorting will be mapped into the {@link Direction} enum.
- *
- * @param enumType
- * the class of the enum which the fields in the sort string
- * should be related to.
- * @param
- * the type of the enumeration which must be derived from
- * {@link RsqlQueryField}
- * @param sortString
- * the string representation of the query parameters. Might be
- * {@code null} or an empty string.
+ *
+ * @param enumType the class of the enum which the fields in the sort string
+ * should be related to.
+ * @param the type of the enumeration which must be derived from
+ * {@link RsqlQueryField}
+ * @param sortString the string representation of the query parameters. Might be
+ * {@code null} or an empty string.
* @return a list which holds the {@link RsqlQueryField} and the specific
* {@link Direction} for them as a tuple. Never {@code null}. In
* case of no sorting parameters an empty map will be returned.
- * @throws SortParameterSyntaxErrorException
- * if the sorting query parameter is not well-formed
- * @throws SortParameterUnsupportedFieldException
- * if a field name cannot be mapped to the enum type
- * @throws SortParameterUnsupportedDirectionException
- * if the given direction is not "ASC" or "DESC"
+ * @throws SortParameterSyntaxErrorException if the sorting query parameter is not well-formed
+ * @throws SortParameterUnsupportedFieldException if a field name cannot be mapped to the enum type
+ * @throws SortParameterUnsupportedDirectionException if the given direction is not "ASC" or "DESC"
*/
public static & RsqlQueryField> List parse(final Class enumType,
final String sortString) throws SortParameterSyntaxErrorException {
@@ -95,18 +86,14 @@ public final class SortUtility {
/**
* Returns the attribute identifier for the given name.
- *
- * @param enumType
- * the class of the enum which the fields in the sort string
- * should be related to.
- * @param name
- * the name of the enum
- * @param
- * the type of the enumeration which must be derived from
- * {@link RsqlQueryField}
+ *
+ * @param enumType the class of the enum which the fields in the sort string
+ * should be related to.
+ * @param name the name of the enum
+ * @param the type of the enumeration which must be derived from
+ * {@link RsqlQueryField}
* @return the corresponding enum
- * @throws SortParameterUnsupportedFieldException
- * if there is no matching enum for the specified name
+ * @throws SortParameterUnsupportedFieldException if there is no matching enum for the specified name
*/
private static & RsqlQueryField> T getAttributeIdentifierByName(final Class enumType,
final String name) {
diff --git a/hawkbit-rest/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/AbstractRestIntegrationTest.java b/hawkbit-rest/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/AbstractRestIntegrationTest.java
index 92cedf2da..da4b977d9 100644
--- a/hawkbit-rest/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/AbstractRestIntegrationTest.java
+++ b/hawkbit-rest/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/AbstractRestIntegrationTest.java
@@ -32,19 +32,17 @@ import org.springframework.web.filter.CharacterEncodingFilter;
*/
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.MOCK)
@ContextConfiguration(classes = {
- RestConfiguration.class, RepositoryApplicationConfiguration.class, TestConfiguration.class})
+ RestConfiguration.class, RepositoryApplicationConfiguration.class, TestConfiguration.class })
@Import(TestChannelBinderConfiguration.class)
@WebAppConfiguration
@AutoConfigureMockMvc
public abstract class AbstractRestIntegrationTest extends AbstractIntegrationTest {
protected MockMvc mvc;
-
- @Autowired
- private CharacterEncodingFilter characterEncodingFilter;
-
@Autowired
protected WebApplicationContext webApplicationContext;
+ @Autowired
+ private CharacterEncodingFilter characterEncodingFilter;
@BeforeEach
public void before() throws Exception {
diff --git a/hawkbit-rest/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/filter/ExcludePathAwareShallowETagFilterTest.java b/hawkbit-rest/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/filter/ExcludePathAwareShallowETagFilterTest.java
index c512b9edb..4771022ea 100644
--- a/hawkbit-rest/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/filter/ExcludePathAwareShallowETagFilterTest.java
+++ b/hawkbit-rest/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/filter/ExcludePathAwareShallowETagFilterTest.java
@@ -22,6 +22,8 @@ import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
+import io.qameta.allure.Feature;
+import io.qameta.allure.Story;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
@@ -29,9 +31,6 @@ import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.jupiter.MockitoExtension;
-import io.qameta.allure.Feature;
-import io.qameta.allure.Story;
-
@Feature("Unit Tests - Security")
@Story("Exclude path aware shallow ETag filter")
@ExtendWith(MockitoExtension.class)
diff --git a/hawkbit-rest/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/json/model/ExceptionInfoTest.java b/hawkbit-rest/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/json/model/ExceptionInfoTest.java
index 3397210d5..8b1bc0db3 100644
--- a/hawkbit-rest/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/json/model/ExceptionInfoTest.java
+++ b/hawkbit-rest/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/json/model/ExceptionInfoTest.java
@@ -14,11 +14,10 @@ import static org.assertj.core.api.Assertions.assertThat;
import java.util.HashMap;
import java.util.Map;
-import org.junit.jupiter.api.Test;
-
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
import io.qameta.allure.Story;
+import org.junit.jupiter.api.Test;
@Feature("Unit Tests - Management API")
@Story("Error Handling")
diff --git a/hawkbit-rest/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/util/FileStreamingUtilTest.java b/hawkbit-rest/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/util/FileStreamingUtilTest.java
index a55ea9293..ee39cf2d3 100644
--- a/hawkbit-rest/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/util/FileStreamingUtilTest.java
+++ b/hawkbit-rest/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/util/FileStreamingUtilTest.java
@@ -25,6 +25,8 @@ import jakarta.servlet.ServletOutputStream;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
+import io.qameta.allure.Feature;
+import io.qameta.allure.Story;
import org.eclipse.hawkbit.artifact.repository.model.DbArtifact;
import org.eclipse.hawkbit.artifact.repository.model.DbArtifactHash;
import org.junit.jupiter.api.Test;
@@ -34,12 +36,10 @@ import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
-import io.qameta.allure.Feature;
-import io.qameta.allure.Story;
-
@Feature("Component Tests - Management API")
@Story("File streaming")
class FileStreamingUtilTest {
+
private final static String CONTENT = "This is some very long string which is intended to test";
private final static byte[] CONTENT_BYTES = CONTENT.getBytes(StandardCharsets.UTF_8);
diff --git a/hawkbit-rest/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/util/JsonBuilder.java b/hawkbit-rest/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/util/JsonBuilder.java
index ddb2a32d5..c304c5744 100644
--- a/hawkbit-rest/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/util/JsonBuilder.java
+++ b/hawkbit-rest/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/util/JsonBuilder.java
@@ -9,6 +9,8 @@
*/
package org.eclipse.hawkbit.rest.util;
+import static org.junit.jupiter.api.Assertions.fail;
+
import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -30,8 +32,6 @@ import org.json.JSONException;
import org.json.JSONObject;
import org.springframework.util.CollectionUtils;
-import static org.junit.jupiter.api.Assertions.fail;
-
/**
* Builder class for building certain json strings.
*/
@@ -73,12 +73,6 @@ public abstract class JsonBuilder {
}
- private static void createTagLine(final StringBuilder builder, final Tag tag) throws JSONException {
- builder.append(new JSONObject().put("name", tag.getName()).put("description", tag.getDescription())
- .put("colour", tag.getColour()).put("createdAt", "0").put("updatedAt", "0")
- .put("createdBy", "fghdfkjghdfkjh").put("updatedBy", "fghdfkjghdfkjh").toString());
- }
-
public static String tag(final Tag tag) throws JSONException {
final StringBuilder builder = new StringBuilder();
@@ -185,16 +179,13 @@ public abstract class JsonBuilder {
return builder.toString();
}
-
+
/**
* Build an invalid request body with missing result for feedback message.
- *
- * @param id
- * id of the action
- * @param execution
- * the execution
- * @param message
- * the message
+ *
+ * @param id id of the action
+ * @param execution the execution
+ * @param message the message
* @return a invalid request body
* @throws JSONException
*/
@@ -209,13 +200,10 @@ public abstract class JsonBuilder {
/**
* Build an invalid request body with missing finished result for feedback
* message.
- *
- * @param id
- * id of the action
- * @param execution
- * the execution
- * @param message
- * the message
+ *
+ * @param id id of the action
+ * @param execution the execution
+ * @param message the message
* @return a invalid request body
* @throws JSONException
*/
@@ -486,7 +474,7 @@ public abstract class JsonBuilder {
final long distributionSetId, final String targetFilterQuery, final RolloutGroupConditions conditions,
final String type) {
return rollout(name, description, groupSize, distributionSetId, targetFilterQuery, conditions, null, type,
- null, null, null, null);
+ null, null, null, null);
}
public static String rolloutWithGroups(final String name, final String description, final Integer groupSize,
@@ -511,13 +499,13 @@ public abstract class JsonBuilder {
final List groupJsonList, final String type, final Integer weight, final Long startAt, final Long forceTime,
final Boolean confirmationRequired) {
return rollout(name, description, groupSize, distributionSetId, targetFilterQuery, conditions, groupJsonList, type,
- weight, startAt, forceTime, confirmationRequired, false, null, 0);
+ weight, startAt, forceTime, confirmationRequired, false, null, 0);
}
public static String rollout(final String name, final String description, final Integer groupSize,
- final long distributionSetId, final String targetFilterQuery, final RolloutGroupConditions conditions,
- final List groupJsonList, final String type, final Integer weight, final Long startAt, final Long forceTime,
- final Boolean confirmationRequired, final boolean isDynamic, final String dynamicGroupSuffix, final int dynamicGroupTargetsCount) {
+ final long distributionSetId, final String targetFilterQuery, final RolloutGroupConditions conditions,
+ final List groupJsonList, final String type, final Integer weight, final Long startAt, final Long forceTime,
+ final Boolean confirmationRequired, final boolean isDynamic, final String dynamicGroupSuffix, final int dynamicGroupTargetsCount) {
final JSONObject json = new JSONObject();
try {
@@ -576,7 +564,8 @@ public abstract class JsonBuilder {
final JSONObject dynamicGroupTemplate = new JSONObject();
json.put("dynamicGroupTemplate", dynamicGroupTemplate);
- dynamicGroupTemplate.put("nameSuffix", (dynamicGroupSuffix == null || dynamicGroupSuffix.isEmpty()) ? "-dynamic" : dynamicGroupSuffix);
+ dynamicGroupTemplate.put("nameSuffix",
+ (dynamicGroupSuffix == null || dynamicGroupSuffix.isEmpty()) ? "-dynamic" : dynamicGroupSuffix);
dynamicGroupTemplate.put("targetCount", dynamicGroupTargetsCount < 0 ? 1 : dynamicGroupTargetsCount);
}
@@ -602,14 +591,6 @@ public abstract class JsonBuilder {
}
- private static RolloutGroupConditions getConditions(final RolloutGroup rolloutGroup) {
- return new RolloutGroupConditionBuilder()
- .errorCondition(rolloutGroup.getErrorCondition(), rolloutGroup.getErrorConditionExp())
- .errorAction(rolloutGroup.getErrorAction(), rolloutGroup.getErrorActionExp())
- .successAction(rolloutGroup.getSuccessAction(), rolloutGroup.getSuccessActionExp())
- .successCondition(rolloutGroup.getSuccessCondition(), rolloutGroup.getSuccessConditionExp()).build();
- }
-
public static String rolloutGroup(final String name, final String description, final String targetFilterQuery,
final Float targetPercentage, final Boolean confirmationRequired,
final RolloutGroupConditions rolloutGroupConditions) {
@@ -705,4 +686,18 @@ public abstract class JsonBuilder {
}
return json;
}
+
+ private static void createTagLine(final StringBuilder builder, final Tag tag) throws JSONException {
+ builder.append(new JSONObject().put("name", tag.getName()).put("description", tag.getDescription())
+ .put("colour", tag.getColour()).put("createdAt", "0").put("updatedAt", "0")
+ .put("createdBy", "fghdfkjghdfkjh").put("updatedBy", "fghdfkjghdfkjh").toString());
+ }
+
+ private static RolloutGroupConditions getConditions(final RolloutGroup rolloutGroup) {
+ return new RolloutGroupConditionBuilder()
+ .errorCondition(rolloutGroup.getErrorCondition(), rolloutGroup.getErrorConditionExp())
+ .errorAction(rolloutGroup.getErrorAction(), rolloutGroup.getErrorActionExp())
+ .successAction(rolloutGroup.getSuccessAction(), rolloutGroup.getSuccessActionExp())
+ .successCondition(rolloutGroup.getSuccessCondition(), rolloutGroup.getSuccessConditionExp()).build();
+ }
}
diff --git a/hawkbit-rest/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/util/SortUtilityTest.java b/hawkbit-rest/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/util/SortUtilityTest.java
index 0955f865c..a5b131f41 100644
--- a/hawkbit-rest/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/util/SortUtilityTest.java
+++ b/hawkbit-rest/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/util/SortUtilityTest.java
@@ -14,6 +14,9 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
import java.util.List;
+import io.qameta.allure.Description;
+import io.qameta.allure.Feature;
+import io.qameta.allure.Story;
import org.eclipse.hawkbit.repository.TargetFields;
import org.eclipse.hawkbit.rest.exception.SortParameterSyntaxErrorException;
import org.eclipse.hawkbit.rest.exception.SortParameterUnsupportedDirectionException;
@@ -21,16 +24,13 @@ import org.eclipse.hawkbit.rest.exception.SortParameterUnsupportedFieldException
import org.junit.jupiter.api.Test;
import org.springframework.data.domain.Sort.Order;
-import io.qameta.allure.Description;
-import io.qameta.allure.Feature;
-import io.qameta.allure.Story;
-
/**
*
*/
@Feature("Component Tests - Management API")
@Story("Sorting parameter")
public class SortUtilityTest {
+
private static final String SORT_PARAM_1 = "NAME:ASC";
private static final String SORT_PARAM_2 = "NAME:ASC, DESCRIPTION:DESC";
private static final String SYNTAX_FAILURE_SORT_PARAM = "NAME:ASC DESCRIPTION:DESC";
diff --git a/hawkbit-rest/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/util/SuccessCondition.java b/hawkbit-rest/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/util/SuccessCondition.java
index 744fde4c4..3e240017e 100644
--- a/hawkbit-rest/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/util/SuccessCondition.java
+++ b/hawkbit-rest/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/util/SuccessCondition.java
@@ -10,13 +10,11 @@
package org.eclipse.hawkbit.rest.util;
/**
- *
* @param
*/
public interface SuccessCondition {
/**
- *
* @param result
* @return
*/