diff --git a/README.md b/README.md index c4a23dd2c3..db7c977d8e 100644 --- a/README.md +++ b/README.md @@ -52,14 +52,14 @@ There are clients outside of the Eclipse IoT eco system as well, e.g.: ## SQL database -| Database | H2 | MySQL/MariaDB | MS SQL Server | PostgreSQL | IBM DB2 | -| --------------------------------- | :------------------------------------------------: | :-----------------------------------------------------------------------: | :-------------------------------------------------------: | :----------------------------------------------------------------: | :----------------: | -| DDLs maintained by project | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| Test dependencies defined | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | -| Versions tested | 1.4 | MySQL 5.6/5.7, AWS Aurora | MS SQL Server 2017/2019 | PostgreSQL 12/13 | DB2 Server v11.1 | -| Docker image with driver provided | :white_check_mark: | :white_check_mark: (Tag: "-mysql") | :white_check_mark: | :white_check_mark: | | -| JDBC driver | [H2 1.4](https://github.com/h2database/h2database) | [MariaDB Connector/J 2.0](https://github.com/MariaDB/mariadb-connector-j) | [MSSQL-JDBC 6.4](https://github.com/Microsoft/mssql-jdbc) | [PostgreSQL JDBC Driver 42.2.10](https://github.com/pgjdbc/pgjdbc) | | -| Status | Test, Dev | Production grade | Production grade | Test, Dev | Test, Dev | +| Database | H2 | MySQL/MariaDB | MS SQL Server | PostgreSQL | IBM DB2 | +| --------------------------------- | :----------------------------------------------------: | :-------------------------------------------------------------------------: | :--------------------------------------------------------------: | :----------------------------------------------------------------: | :----------------: | +| DDLs maintained by project | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| Test dependencies defined | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | +| Versions tested | 1.4 | MySQL 5.6/5.7, AWS Aurora | MS SQL Server 2017/2019 | PostgreSQL 12/13 | DB2 Server v11.1 | +| Docker image with driver provided | :white_check_mark: | :white_check_mark: (Tag: "-mysql") | :white_check_mark: | :white_check_mark: | | +| JDBC driver | [H2 1.4.200](https://github.com/h2database/h2database) | [MariaDB Connector/J 2.6.2](https://github.com/MariaDB/mariadb-connector-j) | [MSSQL-JDBC 7.4.1.jre8](https://github.com/Microsoft/mssql-jdbc) | [PostgreSQL JDBC Driver 42.2.14](https://github.com/pgjdbc/pgjdbc) | | +| Status | Test, Dev | Production grade | Production grade | Test, Dev | Test, Dev | ## (Optional) RabbitMQ: 3.6,3.7,3.8 diff --git a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/SecurityManagedConfiguration.java b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/SecurityManagedConfiguration.java index 9b1be1ed4e..c8b6f8794b 100644 --- a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/SecurityManagedConfiguration.java +++ b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/SecurityManagedConfiguration.java @@ -12,6 +12,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import java.util.List; import javax.servlet.Filter; import javax.servlet.FilterChain; @@ -19,6 +20,7 @@ import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; import org.eclipse.hawkbit.cache.DownloadIdCache; import org.eclipse.hawkbit.ddi.rest.api.DdiRestConstants; @@ -56,6 +58,7 @@ import org.springframework.context.annotation.AdviceMode; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; import org.springframework.context.annotation.PropertySource; import org.springframework.core.Ordered; import org.springframework.core.annotation.Order; @@ -91,9 +94,13 @@ import org.springframework.security.web.authentication.preauth.RequestHeaderAuthenticationFilter; import org.springframework.security.web.authentication.www.BasicAuthenticationEntryPoint; import org.springframework.security.web.authentication.www.BasicAuthenticationFilter; +import org.springframework.security.web.firewall.FirewalledRequest; +import org.springframework.security.web.firewall.HttpFirewall; +import org.springframework.security.web.firewall.StrictHttpFirewall; import org.springframework.security.web.session.HttpSessionEventPublisher; import org.springframework.security.web.session.SessionManagementFilter; import org.springframework.util.Assert; +import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; import org.springframework.web.cors.CorsConfiguration; import org.springframework.web.cors.CorsConfigurationSource; @@ -183,7 +190,7 @@ static class ControllerSecurityConfigurationAdapter extends WebSecurityConfigure /** * Filter to protect the hawkBit server DDI interface against to many * requests. - * + * * @param securityProperties * for filter configuration * @@ -299,7 +306,7 @@ static class ControllerDownloadSecurityConfigurationAdapter extends WebSecurityC /** * Filter to protect the hawkBit server DDI download interface against * to many requests. - * + * * @param securityProperties * for filter configuration * @@ -389,7 +396,7 @@ protected void configure(final AuthenticationManagerBuilder auth) throws Excepti /** * Filter to protect the hawkBit server system management interface against * to many requests. - * + * * @param securityProperties * for filter configuration * @@ -490,7 +497,7 @@ public static class RestSecurityConfigurationAdapter extends WebSecurityConfigur /** * Filter to protect the hawkBit server Management interface against to * many requests. - * + * * @param securityProperties * for filter configuration * @@ -523,9 +530,8 @@ protected void configure(final HttpSecurity http) throws Exception { httpSec = httpSec.requiresChannel().anyRequest().requiresSecure().and(); } - httpSec.authorizeRequests().anyRequest().authenticated() - .antMatchers(MgmtRestConstants.BASE_SYSTEM_MAPPING + "/admin/**") - .hasAnyAuthority(SpPermission.SYSTEM_ADMIN); + httpSec.authorizeRequests().antMatchers(MgmtRestConstants.BASE_SYSTEM_MAPPING + "/admin/**") + .hasAnyAuthority(SpPermission.SYSTEM_ADMIN).anyRequest().authenticated(); if (oidcBearerTokenAuthenticationFilter != null) { @@ -619,7 +625,7 @@ public static class UISecurityConfigurationAdapter extends WebSecurityConfigurer /** * Filter to protect the hawkBit management UI against to many requests. - * + * * @param securityProperties * for filter configuration * @@ -647,8 +653,10 @@ public AuthenticationManager authenticationManagerBean() throws Exception { } /** + * Overwriting VaadinAuthenticationSuccessHandler of default VaadinSharedSecurityConfiguration * @return the vaadin success authentication handler */ + @Primary @Bean(name = VaadinSharedSecurityConfiguration.VAADIN_AUTHENTICATION_SUCCESS_HANDLER_BEAN) public VaadinAuthenticationSuccessHandler redirectSaveHandler(final HttpService httpService, final VaadinRedirectStrategy redirectStrategy) { @@ -719,6 +727,49 @@ protected void configure(final HttpSecurity http) throws Exception { .logoutSuccessHandler(logoutSuccessHandler); } + /** + * HttpFirewall which enables to define a list of allowed host names. + * + * @return the http firewall. + */ + @Bean + public HttpFirewall httpFirewall() { + final List allowedHostNames = hawkbitSecurityProperties.getAllowedHostNames(); + final IgnorePathsStrictHttpFirewall firewall = new IgnorePathsStrictHttpFirewall( + hawkbitSecurityProperties.getHttpFirewallIgnoredPaths()); + + if (!CollectionUtils.isEmpty(allowedHostNames)) { + firewall.setAllowedHostnames(hostName -> { + LOG.debug("Firewall check host: {}, allowed: {}", hostName, allowedHostNames.contains(hostName)); + return allowedHostNames.contains(hostName); + }); + } + return firewall; + } + + private static class IgnorePathsStrictHttpFirewall extends StrictHttpFirewall { + + private final Collection pathsToIgnore; + + public IgnorePathsStrictHttpFirewall(final Collection pathsToIgnore) { + super(); + this.pathsToIgnore = pathsToIgnore; + } + + @Override + public FirewalledRequest getFirewalledRequest(final HttpServletRequest request) { + if (pathsToIgnore != null && pathsToIgnore.contains(request.getRequestURI())) { + return new FirewalledRequest(request) { + @Override + public void reset() { + //nothing to do + } + }; + } + return super.getFirewalledRequest(request); + } + } + @Override public void configure(final WebSecurity webSecurity) throws Exception { // No security for static content diff --git a/hawkbit-core/src/test/java/org/eclipse/hawkbit/api/PropertyBasedArtifactUrlHandlerTest.java b/hawkbit-core/src/test/java/org/eclipse/hawkbit/api/PropertyBasedArtifactUrlHandlerTest.java index 463701dd14..355639d73e 100644 --- a/hawkbit-core/src/test/java/org/eclipse/hawkbit/api/PropertyBasedArtifactUrlHandlerTest.java +++ b/hawkbit-core/src/test/java/org/eclipse/hawkbit/api/PropertyBasedArtifactUrlHandlerTest.java @@ -20,7 +20,7 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import io.qameta.allure.Description; import io.qameta.allure.Feature; diff --git a/hawkbit-core/src/test/java/org/eclipse/hawkbit/cache/DefaultDownloadIdCacheTest.java b/hawkbit-core/src/test/java/org/eclipse/hawkbit/cache/DefaultDownloadIdCacheTest.java index cfb94b4a7c..69c3a7a463 100644 --- a/hawkbit-core/src/test/java/org/eclipse/hawkbit/cache/DefaultDownloadIdCacheTest.java +++ b/hawkbit-core/src/test/java/org/eclipse/hawkbit/cache/DefaultDownloadIdCacheTest.java @@ -18,7 +18,7 @@ import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.springframework.cache.Cache; import org.springframework.cache.CacheManager; import org.springframework.cache.support.SimpleValueWrapper; diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/pom.xml b/hawkbit-dmf/hawkbit-dmf-amqp/pom.xml index fd11410ebb..e92eeb85f0 100644 --- a/hawkbit-dmf/hawkbit-dmf-amqp/pom.xml +++ b/hawkbit-dmf/hawkbit-dmf-amqp/pom.xml @@ -21,7 +21,6 @@ hawkBit :: DMF :: AMQP 0.9 Implementation - org.eclipse.hawkbit hawkbit-repository-api diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/BaseAmqpServiceTest.java b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/BaseAmqpServiceTest.java index d05fb42a1c..8c16f41ef8 100644 --- a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/BaseAmqpServiceTest.java +++ b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/BaseAmqpServiceTest.java @@ -21,7 +21,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.springframework.amqp.core.Message; import org.springframework.amqp.core.MessageProperties; import org.springframework.amqp.rabbit.core.RabbitTemplate; diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/matcher/SoftwareModuleJsonMatcher.java b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/matcher/SoftwareModuleJsonMatcher.java index f7cff9ed69..00d2f6031a 100644 --- a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/matcher/SoftwareModuleJsonMatcher.java +++ b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/matcher/SoftwareModuleJsonMatcher.java @@ -16,7 +16,6 @@ import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.hamcrest.BaseMatcher; import org.hamcrest.Description; -import org.hamcrest.Factory; /** * Set matcher for {@link SoftwareModule} and a list of @@ -44,7 +43,6 @@ public final class SoftwareModuleJsonMatcher { * @param expectedModules * the json sofware modules. */ - @Factory public static SoftwareModulesMatcher containsExactly(final List expectedModules) { return new SoftwareModulesMatcher(expectedModules); } diff --git a/hawkbit-http-security/src/test/java/org/eclipse/hawkbit/security/PreAuthTokenSourceTrustAuthenticationProviderTest.java b/hawkbit-http-security/src/test/java/org/eclipse/hawkbit/security/PreAuthTokenSourceTrustAuthenticationProviderTest.java index 8a423a9208..88d9591a64 100644 --- a/hawkbit-http-security/src/test/java/org/eclipse/hawkbit/security/PreAuthTokenSourceTrustAuthenticationProviderTest.java +++ b/hawkbit-http-security/src/test/java/org/eclipse/hawkbit/security/PreAuthTokenSourceTrustAuthenticationProviderTest.java @@ -17,7 +17,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.springframework.security.authentication.BadCredentialsException; import org.springframework.security.authentication.InsufficientAuthenticationException; import org.springframework.security.core.Authentication; diff --git a/hawkbit-repository/hawkbit-repository-api/pom.xml b/hawkbit-repository/hawkbit-repository-api/pom.xml index 620aa7f56e..7fa3049b55 100644 --- a/hawkbit-repository/hawkbit-repository-api/pom.xml +++ b/hawkbit-repository/hawkbit-repository-api/pom.xml @@ -25,6 +25,10 @@ hawkbit-security-core ${project.version} + + com.fasterxml.jackson.core + jackson-annotations + javax.validation validation-api diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/ArtifactManagement.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/ArtifactManagement.java index 45b05718f4..bb0b5f360f 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/ArtifactManagement.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/ArtifactManagement.java @@ -28,7 +28,6 @@ import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; -import org.springframework.hateoas.Identifiable; import org.springframework.security.access.prepost.PreAuthorize; /** @@ -70,7 +69,7 @@ public interface ArtifactManagement { /** * Garbage collects artifact binaries if only referenced by given - * {@link SoftwareModule#getId()} or {@link SoftwareModules} that are marged + * {@link SoftwareModule#getId()} or {@link SoftwareModule}'s that are marked * as deleted. * * diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/Identifiable.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/Identifiable.java new file mode 100644 index 0000000000..a2e71a32bb --- /dev/null +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/Identifiable.java @@ -0,0 +1,20 @@ +/** + * Copyright (c) 2020 Bosch.IO GmbH and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.eclipse.hawkbit.repository; + +import java.io.Serializable; + +/** + * @param the parameter of the class + */ +@FunctionalInterface +public interface Identifiable { + + T getId(); +} diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/event/remote/MultiActionEvent.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/event/remote/MultiActionEvent.java index 873efe7e4b..cab41be448 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/event/remote/MultiActionEvent.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/event/remote/MultiActionEvent.java @@ -8,9 +8,9 @@ */ package org.eclipse.hawkbit.repository.event.remote; +import org.eclipse.hawkbit.repository.Identifiable; import org.eclipse.hawkbit.repository.model.Action; import org.eclipse.hawkbit.repository.model.Target; -import org.springframework.hateoas.Identifiable; import java.util.ArrayList; import java.util.Iterator; diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/model/AssignedSoftwareModule.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/model/AssignedSoftwareModule.java index 94e5a72af3..8253502ee1 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/model/AssignedSoftwareModule.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/model/AssignedSoftwareModule.java @@ -8,9 +8,10 @@ */ package org.eclipse.hawkbit.repository.model; +import org.eclipse.hawkbit.repository.Identifiable; + import java.io.Serializable; -import org.springframework.hateoas.Identifiable; /** * Use to display software modules for the selected distribution. diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/model/BaseEntity.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/model/BaseEntity.java index 7c56647f60..c3c031d7da 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/model/BaseEntity.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/model/BaseEntity.java @@ -8,11 +8,11 @@ */ package org.eclipse.hawkbit.repository.model; +import org.eclipse.hawkbit.repository.Identifiable; + import java.io.Serializable; import java.util.concurrent.TimeUnit; -import org.springframework.hateoas.Identifiable; - /** * Core information of all entities. * diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/model/TargetWithActionStatus.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/model/TargetWithActionStatus.java index 41f7ccbc23..efe59fea1f 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/model/TargetWithActionStatus.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/model/TargetWithActionStatus.java @@ -8,8 +8,8 @@ */ package org.eclipse.hawkbit.repository.model; +import org.eclipse.hawkbit.repository.Identifiable; import org.eclipse.hawkbit.repository.model.Action.Status; -import org.springframework.hateoas.Identifiable; /** * diff --git a/hawkbit-repository/hawkbit-repository-api/src/test/java/org/eclipse/hawkbit/repository/MaintenanceScheduleHelperTest.java b/hawkbit-repository/hawkbit-repository-api/src/test/java/org/eclipse/hawkbit/repository/MaintenanceScheduleHelperTest.java index e92d0f97b5..d66eabda8f 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/test/java/org/eclipse/hawkbit/repository/MaintenanceScheduleHelperTest.java +++ b/hawkbit-repository/hawkbit-repository-api/src/test/java/org/eclipse/hawkbit/repository/MaintenanceScheduleHelperTest.java @@ -47,7 +47,7 @@ public void validateDurationInvalid() { final String duration = "10"; assertThatThrownBy(() -> MaintenanceScheduleHelper.validateDuration(duration)) .isInstanceOf(InvalidMaintenanceScheduleException.class).hasMessage("Provided duration is not valid") - .extracting("durationErrorIndex").containsExactly(2); + .extracting("durationErrorIndex").isEqualTo(2); } @Test diff --git a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractBaseEntityBuilder.java b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractBaseEntityBuilder.java index 53bf9ed2e7..5fd17ab38b 100644 --- a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractBaseEntityBuilder.java +++ b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractBaseEntityBuilder.java @@ -8,7 +8,7 @@ */ package org.eclipse.hawkbit.repository.builder; -import org.springframework.hateoas.Identifiable; +import org.eclipse.hawkbit.repository.Identifiable; public abstract class AbstractBaseEntityBuilder implements Identifiable { diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaControllerManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaControllerManagement.java index de18b4e6e3..ac61e96d1c 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaControllerManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaControllerManagement.java @@ -914,7 +914,7 @@ public List getActionHistoryMessages(final long actionId, final int mess ? RepositoryConstants.MAX_ACTION_HISTORY_MSG_COUNT : messageCount; - final PageRequest pageable = PageRequest.of(0, limit, new Sort(Direction.DESC, "occurredAt")); + final PageRequest pageable = PageRequest.of(0, limit, Sort.by(Direction.DESC, "occurredAt")); final Page messages = actionStatusRepository.findMessagesByActionIdAndMessageNotLike(pageable, actionId, RepositoryConstants.SERVER_MESSAGE_PREFIX + "%"); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaRolloutManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaRolloutManagement.java index 78ee099ee0..2f319648e3 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaRolloutManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/JpaRolloutManagement.java @@ -333,7 +333,7 @@ private void handleCreateRollout(final JpaRollout rollout) { LOGGER.debug("handleCreateRollout called for rollout {}", rollout.getId()); final List rolloutGroups = rolloutGroupManagement.findByRollout( - PageRequest.of(0, quotaManagement.getMaxRolloutGroupsPerRollout(), new Sort(Direction.ASC, "id")), + PageRequest.of(0, quotaManagement.getMaxRolloutGroupsPerRollout(), Sort.by(Direction.ASC, "id")), rollout.getId()).getContent(); int readyGroups = 0; diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/RepositoryApplicationConfiguration.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/RepositoryApplicationConfiguration.java index 34b3f450a6..8d80cf45f4 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/RepositoryApplicationConfiguration.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/RepositoryApplicationConfiguration.java @@ -145,9 +145,8 @@ public class RepositoryApplicationConfiguration extends JpaBaseConfiguration { protected RepositoryApplicationConfiguration(final DataSource dataSource, final JpaProperties properties, - final ObjectProvider jtaTransactionManagerProvider, - final ObjectProvider transactionManagerCustomizers) { - super(dataSource, properties, jtaTransactionManagerProvider, transactionManagerCustomizers); + final ObjectProvider jtaTransactionManagerProvider) { + super(dataSource, properties, jtaTransactionManagerProvider); } @Bean @@ -410,12 +409,12 @@ protected Map getVendorProperties() { /** * {@link MultiTenantJpaTransactionManager} bean. * - * @see org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration#transactionManager() + * @see org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration#transactionManager(ObjectProvider) * @return a new {@link PlatformTransactionManager} */ @Override @Bean - public PlatformTransactionManager transactionManager() { + public PlatformTransactionManager transactionManager(ObjectProvider transactionManagerCustomizers) { return new MultiTenantJpaTransactionManager(); } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/specifications/TargetSpecifications.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/specifications/TargetSpecifications.java index 5e92e5d415..f7f94682f5 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/specifications/TargetSpecifications.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/specifications/TargetSpecifications.java @@ -39,7 +39,6 @@ import org.eclipse.hawkbit.repository.model.TargetTag; import org.eclipse.hawkbit.repository.model.TargetUpdateStatus; import org.springframework.data.jpa.domain.Specification; -import org.springframework.data.jpa.domain.Specifications; /** * Specifications class for {@link Target}s. The class provides Spring Data JPQL @@ -178,7 +177,7 @@ public static Specification likeAttributeValue(final String searchTex * @return the {@link Target} {@link Specification} */ public static Specification likeIdOrNameOrDescriptionOrAttributeValue(final String searchText) { - return Specifications.where(likeIdOrNameOrDescription(searchText)).or(likeAttributeValue(searchText)); + return Specification.where(likeIdOrNameOrDescription(searchText)).or(likeAttributeValue(searchText)); } /** diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/resources/hawkbit-jpa-defaults.properties b/hawkbit-repository/hawkbit-repository-jpa/src/main/resources/hawkbit-jpa-defaults.properties index 3adf8567fd..aebd7ee5d9 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/resources/hawkbit-jpa-defaults.properties +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/resources/hawkbit-jpa-defaults.properties @@ -12,6 +12,7 @@ spring.main.allow-bean-definition-overriding=true ### JPA / Datasource - START spring.jpa.database=H2 spring.jpa.show-sql=false +spring.datasource.url=jdbc:h2:mem:testdb;MODE=MySQL; # Logging spring.datasource.eclipselink.logging.logger=JavaLogger spring.jpa.properties.eclipselink.logging.level=off diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/RolloutManagementTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/RolloutManagementTest.java index 59183de64d..aefcbbe3ae 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/RolloutManagementTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/RolloutManagementTest.java @@ -43,10 +43,10 @@ import org.eclipse.hawkbit.repository.event.remote.entity.SoftwareModuleCreatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.TargetCreatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.TargetUpdatedEvent; +import org.eclipse.hawkbit.repository.exception.AssignmentQuotaExceededException; import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException; import org.eclipse.hawkbit.repository.exception.EntityReadOnlyException; import org.eclipse.hawkbit.repository.exception.MultiAssignmentIsNotEnabledException; -import org.eclipse.hawkbit.repository.exception.AssignmentQuotaExceededException; import org.eclipse.hawkbit.repository.exception.RolloutIllegalStateException; import org.eclipse.hawkbit.repository.jpa.model.JpaAction; import org.eclipse.hawkbit.repository.jpa.model.JpaRollout; @@ -239,13 +239,13 @@ public void startRolloutSetFirstGroupAndActionsInRunningStateAndOthersInSchedule // verify first group is running final RolloutGroup firstGroup = rolloutGroupManagement - .findByRollout(new OffsetBasedPageRequest(0, 1, new Sort(Direction.ASC, "id")), createdRollout.getId()) + .findByRollout(new OffsetBasedPageRequest(0, 1, Sort.by(Direction.ASC, "id")), createdRollout.getId()) .getContent().get(0); assertThat(firstGroup.getStatus()).isEqualTo(RolloutGroupStatus.RUNNING); // verify other groups are scheduled final List scheduledGroups = rolloutGroupManagement.findByRollout( - new OffsetBasedPageRequest(1, 100, new Sort(Direction.ASC, "id")), createdRollout.getId()).getContent(); + new OffsetBasedPageRequest(1, 100, Sort.by(Direction.ASC, "id")), createdRollout.getId()).getContent(); scheduledGroups.forEach(group -> assertThat(group.getStatus()).isEqualTo(RolloutGroupStatus.SCHEDULED) .as("group which should be in scheduled state is in " + group.getStatus() + " state")); // verify that the first group actions has been started and are in state @@ -283,7 +283,7 @@ public void checkRunningRolloutsDoesNotStartNextGroupIfFinishConditionIsNotHit() // verify that now the first and the second group are in running state final List runningRolloutGroups = rolloutGroupManagement - .findByRollout(new OffsetBasedPageRequest(0, 2, new Sort(Direction.ASC, "id")), createdRollout.getId()) + .findByRollout(new OffsetBasedPageRequest(0, 2, Sort.by(Direction.ASC, "id")), createdRollout.getId()) .getContent(); runningRolloutGroups.forEach(group -> assertThat(group.getStatus()).isEqualTo(RolloutGroupStatus.RUNNING) .as("group should be in running state because it should be started but it is in " + group.getStatus() @@ -291,7 +291,7 @@ public void checkRunningRolloutsDoesNotStartNextGroupIfFinishConditionIsNotHit() // verify that the other groups are still in schedule state final List scheduledRolloutGroups = rolloutGroupManagement - .findByRollout(new OffsetBasedPageRequest(2, 10, new Sort(Direction.ASC, "id")), createdRollout.getId()) + .findByRollout(new OffsetBasedPageRequest(2, 10, Sort.by(Direction.ASC, "id")), createdRollout.getId()) .getContent(); scheduledRolloutGroups.forEach(group -> assertThat(group.getStatus()).isEqualTo(RolloutGroupStatus.SCHEDULED) .as("group should be in scheduled state because it should not be started but it is in " @@ -354,7 +354,7 @@ private void finishActionAndDeleteTargetsOfFirstRunningGroup(final Rollout creat private void checkSecondGroupStatusIsRunning(final Rollout createdRollout) { rolloutManagement.handleRollouts(); final List runningRolloutGroups = rolloutGroupManagement - .findByRollout(new OffsetBasedPageRequest(0, 10, new Sort(Direction.ASC, "id")), createdRollout.getId()) + .findByRollout(new OffsetBasedPageRequest(0, 10, Sort.by(Direction.ASC, "id")), createdRollout.getId()) .getContent(); assertThat(runningRolloutGroups.get(0).getStatus()).isEqualTo(RolloutGroupStatus.FINISHED); assertThat(runningRolloutGroups.get(1).getStatus()).isEqualTo(RolloutGroupStatus.RUNNING); @@ -431,14 +431,14 @@ public void checkErrorHitOfGroupCallsErrorActionToPauseTheRollout() { // the first rollout group should be in error state final List errorGroup = rolloutGroupManagement - .findByRollout(new OffsetBasedPageRequest(0, 1, new Sort(Direction.ASC, "id")), createdRollout.getId()) + .findByRollout(new OffsetBasedPageRequest(0, 1, Sort.by(Direction.ASC, "id")), createdRollout.getId()) .getContent(); assertThat(errorGroup).hasSize(1); assertThat(errorGroup.get(0).getStatus()).isEqualTo(RolloutGroupStatus.ERROR); // all other groups should still be in scheduled state final List scheduleGroups = rolloutGroupManagement.findByRollout( - new OffsetBasedPageRequest(1, 100, new Sort(Direction.ASC, "id")), createdRollout.getId()).getContent(); + new OffsetBasedPageRequest(1, 100, Sort.by(Direction.ASC, "id")), createdRollout.getId()).getContent(); scheduleGroups.forEach(group -> assertThat(group.getStatus()).isEqualTo(RolloutGroupStatus.SCHEDULED)); } @@ -472,7 +472,7 @@ public void errorActionPausesRolloutAndRolloutGetsResumedStartsNextScheduledGrou // all other groups should still be in scheduled state final List scheduleGroups = rolloutGroupManagement.findByRollout( - new OffsetBasedPageRequest(1, 100, new Sort(Direction.ASC, "id")), createdRollout.getId()).getContent(); + new OffsetBasedPageRequest(1, 100, Sort.by(Direction.ASC, "id")), createdRollout.getId()).getContent(); scheduleGroups.forEach(group -> assertThat(group.getStatus()).isEqualTo(RolloutGroupStatus.SCHEDULED)); // resume the rollout again after it gets paused by error action @@ -486,7 +486,7 @@ public void errorActionPausesRolloutAndRolloutGetsResumedStartsNextScheduledGrou // next group should be running again after resuming the rollout final List resumedGroups = rolloutGroupManagement - .findByRollout(new OffsetBasedPageRequest(1, 1, new Sort(Direction.ASC, "id")), createdRollout.getId()) + .findByRollout(new OffsetBasedPageRequest(1, 1, Sort.by(Direction.ASC, "id")), createdRollout.getId()) .getContent(); assertThat(resumedGroups).hasSize(1); assertThat(resumedGroups.get(0).getStatus()).isEqualTo(RolloutGroupStatus.RUNNING); @@ -522,7 +522,7 @@ public void rolloutStartsGroupAfterGroupAndGetsFinished() { // verify all groups are in finished state rolloutGroupManagement - .findByRollout(new OffsetBasedPageRequest(0, 100, new Sort(Direction.ASC, "id")), + .findByRollout(new OffsetBasedPageRequest(0, 100, Sort.by(Direction.ASC, "id")), createdRollout.getId()) .forEach(group -> assertThat(group.getStatus()).isEqualTo(RolloutGroupStatus.FINISHED)); @@ -998,7 +998,7 @@ public void findAllRolloutsWithDetailedStatus() { rolloutManagement.handleRollouts(); final Page rolloutPage = rolloutManagement - .findAllWithDetailedStatus(new OffsetBasedPageRequest(0, 100, new Sort(Direction.ASC, "name")), false); + .findAllWithDetailedStatus(new OffsetBasedPageRequest(0, 100, Sort.by(Direction.ASC, "name")), false); final List rolloutList = rolloutPage.getContent(); // validate rolloutA -> 6 running and 6 ready @@ -1084,7 +1084,7 @@ public void findRolloutByFilters() { } final Slice rollout = rolloutManagement.findByFiltersWithDetailedStatus( - new OffsetBasedPageRequest(0, 100, new Sort(Direction.ASC, "name")), "Rollout%", false); + new OffsetBasedPageRequest(0, 100, Sort.by(Direction.ASC, "name")), "Rollout%", false); final List rolloutList = rollout.getContent(); assertThat(rolloutList.size()).isEqualTo(5); int i = 1; diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/specifications/SpecificationsBuilderTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/specifications/SpecificationsBuilderTest.java index fa8b294eef..a153db4715 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/specifications/SpecificationsBuilderTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/specifications/SpecificationsBuilderTest.java @@ -93,7 +93,7 @@ public void combineWithAndList() { when(criteriaBuilder.equal(any(Path.class), eq("testValue1"))).thenReturn(equalPredicate1); when(criteriaBuilder.equal(any(Path.class), eq("testValue2"))).thenReturn(equalPredicate2); - when(criteriaBuilder.and(eq(equalPredicate1), eq(equalPredicate2))).thenReturn(combinedPredicate); + when(criteriaBuilder.and(eq(equalPredicate2), eq(equalPredicate1))).thenReturn(combinedPredicate); when(root.get("field1")).thenReturn(field1); when(root.get("field2")).thenReturn(field2); diff --git a/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/matcher/BaseEntityMatcher.java b/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/matcher/BaseEntityMatcher.java index c83ae8ad1a..65b6486a98 100644 --- a/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/matcher/BaseEntityMatcher.java +++ b/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/matcher/BaseEntityMatcher.java @@ -9,7 +9,6 @@ package org.eclipse.hawkbit.repository.test.matcher; import org.eclipse.hawkbit.repository.model.BaseEntity; -import org.hamcrest.Factory; import org.hamcrest.FeatureMatcher; import org.hamcrest.Matcher; import org.hamcrest.Matchers; @@ -22,7 +21,6 @@ public final class BaseEntityMatcher { private BaseEntityMatcher() { } - @Factory public static Matcher hasId(final Long id) { return new HasIdMatcher(Matchers.equalTo(id)); } diff --git a/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/AbstractIntegrationTest.java b/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/AbstractIntegrationTest.java index 71e872d796..086ae23f83 100644 --- a/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/AbstractIntegrationTest.java +++ b/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/AbstractIntegrationTest.java @@ -113,7 +113,7 @@ public abstract class AbstractIntegrationTest { private static final Logger LOG = LoggerFactory.getLogger(AbstractIntegrationTest.class); - protected static final Pageable PAGE = PageRequest.of(0, 400, new Sort(Direction.ASC, "id")); + protected static final Pageable PAGE = PageRequest.of(0, 400, Sort.by(Direction.ASC, "id")); protected static final URI LOCALHOST = URI.create("http://127.0.0.1"); diff --git a/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/JpaTestRepositoryManagement.java b/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/JpaTestRepositoryManagement.java index fa69a2dfbb..894e1d3027 100644 --- a/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/JpaTestRepositoryManagement.java +++ b/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/JpaTestRepositoryManagement.java @@ -23,7 +23,7 @@ public class JpaTestRepositoryManagement { private static final Logger LOGGER = LoggerFactory.getLogger(JpaTestRepositoryManagement.class); - private static final Pageable PAGE = PageRequest.of(0, 400, new Sort(Direction.ASC, "id")); + private static final Pageable PAGE = PageRequest.of(0, 400, Sort.by(Direction.ASC, "id")); private final TenantAwareCacheManager cacheManager; diff --git a/hawkbit-rest/hawkbit-ddi-api/src/main/java/org/eclipse/hawkbit/ddi/json/model/DdiArtifact.java b/hawkbit-rest/hawkbit-ddi-api/src/main/java/org/eclipse/hawkbit/ddi/json/model/DdiArtifact.java index 1f6facea6d..06e75eb3fd 100644 --- a/hawkbit-rest/hawkbit-ddi-api/src/main/java/org/eclipse/hawkbit/ddi/json/model/DdiArtifact.java +++ b/hawkbit-rest/hawkbit-ddi-api/src/main/java/org/eclipse/hawkbit/ddi/json/model/DdiArtifact.java @@ -10,7 +10,7 @@ import javax.validation.constraints.NotNull; -import org.springframework.hateoas.ResourceSupport; +import org.springframework.hateoas.RepresentationModel; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; @@ -20,7 +20,7 @@ * . */ @JsonIgnoreProperties(ignoreUnknown = true) -public class DdiArtifact extends ResourceSupport { +public class DdiArtifact extends RepresentationModel { @NotNull @JsonProperty diff --git a/hawkbit-rest/hawkbit-ddi-api/src/main/java/org/eclipse/hawkbit/ddi/json/model/DdiControllerBase.java b/hawkbit-rest/hawkbit-ddi-api/src/main/java/org/eclipse/hawkbit/ddi/json/model/DdiControllerBase.java index b20768faac..b1c86547bf 100644 --- a/hawkbit-rest/hawkbit-ddi-api/src/main/java/org/eclipse/hawkbit/ddi/json/model/DdiControllerBase.java +++ b/hawkbit-rest/hawkbit-ddi-api/src/main/java/org/eclipse/hawkbit/ddi/json/model/DdiControllerBase.java @@ -8,7 +8,7 @@ */ package org.eclipse.hawkbit.ddi.json.model; -import org.springframework.hateoas.ResourceSupport; +import org.springframework.hateoas.RepresentationModel; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; @@ -20,7 +20,7 @@ */ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class DdiControllerBase extends ResourceSupport { +public class DdiControllerBase extends RepresentationModel { @JsonProperty private DdiConfig config; diff --git a/hawkbit-rest/hawkbit-ddi-api/src/main/java/org/eclipse/hawkbit/ddi/json/model/DdiDeploymentBase.java b/hawkbit-rest/hawkbit-ddi-api/src/main/java/org/eclipse/hawkbit/ddi/json/model/DdiDeploymentBase.java index 331d636889..67f20af25b 100644 --- a/hawkbit-rest/hawkbit-ddi-api/src/main/java/org/eclipse/hawkbit/ddi/json/model/DdiDeploymentBase.java +++ b/hawkbit-rest/hawkbit-ddi-api/src/main/java/org/eclipse/hawkbit/ddi/json/model/DdiDeploymentBase.java @@ -10,7 +10,7 @@ import javax.validation.constraints.NotNull; -import org.springframework.hateoas.ResourceSupport; +import org.springframework.hateoas.RepresentationModel; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; @@ -22,7 +22,7 @@ */ @JsonIgnoreProperties(ignoreUnknown = true) @JsonPropertyOrder({ "id", "deployment", "actionHistory" }) -public class DdiDeploymentBase extends ResourceSupport { +public class DdiDeploymentBase extends RepresentationModel { @JsonProperty("id") @NotNull diff --git a/hawkbit-rest/hawkbit-ddi-api/src/main/java/org/eclipse/hawkbit/ddi/rest/api/DdiRestConstants.java b/hawkbit-rest/hawkbit-ddi-api/src/main/java/org/eclipse/hawkbit/ddi/rest/api/DdiRestConstants.java index cf04baa45d..90e0b26df5 100644 --- a/hawkbit-rest/hawkbit-ddi-api/src/main/java/org/eclipse/hawkbit/ddi/rest/api/DdiRestConstants.java +++ b/hawkbit-rest/hawkbit-ddi-api/src/main/java/org/eclipse/hawkbit/ddi/rest/api/DdiRestConstants.java @@ -60,7 +60,10 @@ public final class DdiRestConstants { * Media type for CBOR content with strings encoded as UTF-8. Technically * redundant since CBOR always uses UTF-8, but Spring will append it * regardless. + * @deprecated Since the Spring Framework (v5.2.4.RELEASE) dropped the charset attribute + * from content type headers, please use {@link DdiRestConstants#MEDIA_TYPE_CBOR} instead. */ + @Deprecated public static final String MEDIA_TYPE_CBOR_UTF8 = "application/cbor;charset=UTF-8"; private DdiRestConstants() { diff --git a/hawkbit-rest/hawkbit-ddi-resource/pom.xml b/hawkbit-rest/hawkbit-ddi-resource/pom.xml index ce6b4f3231..3feded927b 100644 --- a/hawkbit-rest/hawkbit-ddi-resource/pom.xml +++ b/hawkbit-rest/hawkbit-ddi-resource/pom.xml @@ -19,7 +19,7 @@ hawkbit-ddi-resource hawkBit :: REST :: DDI Resources - + org.eclipse.hawkbit @@ -39,7 +39,7 @@ org.springframework.plugin spring-plugin-core - + com.google.guava guava @@ -49,10 +49,10 @@ javax.servlet-api provided - - - - + + + + org.eclipse.hawkbit hawkbit-repository-test ${project.version} @@ -107,10 +107,10 @@ allure-junit4 test - + org.springframework spring-context-support test - + diff --git a/hawkbit-rest/hawkbit-ddi-resource/src/main/java/org/eclipse/hawkbit/ddi/rest/resource/DataConversionHelper.java b/hawkbit-rest/hawkbit-ddi-resource/src/main/java/org/eclipse/hawkbit/ddi/rest/resource/DataConversionHelper.java index 1e915424d2..abcb81613f 100644 --- a/hawkbit-rest/hawkbit-ddi-resource/src/main/java/org/eclipse/hawkbit/ddi/rest/resource/DataConversionHelper.java +++ b/hawkbit-rest/hawkbit-ddi-resource/src/main/java/org/eclipse/hawkbit/ddi/rest/resource/DataConversionHelper.java @@ -34,7 +34,7 @@ import org.eclipse.hawkbit.rest.data.ResponseList; import org.eclipse.hawkbit.tenancy.TenantAware; import org.springframework.hateoas.Link; -import org.springframework.hateoas.mvc.ControllerLinkBuilder; +import org.springframework.hateoas.server.mvc.WebMvcLinkBuilder; import org.springframework.http.HttpRequest; import org.springframework.util.CollectionUtils; @@ -115,8 +115,8 @@ static DdiControllerBase fromTarget(final Target target, final Action action, if (action != null) { if (action.isCancelingOrCanceled()) { - result.add(ControllerLinkBuilder - .linkTo(ControllerLinkBuilder.methodOn(DdiRootController.class, tenantAware.getCurrentTenant()) + result.add(WebMvcLinkBuilder + .linkTo(WebMvcLinkBuilder.methodOn(DdiRootController.class, tenantAware.getCurrentTenant()) .getControllerCancelAction(tenantAware.getCurrentTenant(), target.getControllerId(), action.getId())) .withRel(DdiRestConstants.CANCEL_ACTION)); @@ -126,8 +126,8 @@ static DdiControllerBase fromTarget(final Target target, final Action action, // have changed from 'soft' to 'forced' type and we need to // change the payload of the // response because of eTags. - result.add(ControllerLinkBuilder - .linkTo(ControllerLinkBuilder.methodOn(DdiRootController.class, tenantAware.getCurrentTenant()) + result.add(WebMvcLinkBuilder + .linkTo(WebMvcLinkBuilder.methodOn(DdiRootController.class, tenantAware.getCurrentTenant()) .getControllerBasedeploymentAction(tenantAware.getCurrentTenant(), target.getControllerId(), action.getId(), calculateEtag(action), null)) .withRel(DdiRestConstants.DEPLOYMENT_BASE_ACTION)); @@ -135,8 +135,8 @@ static DdiControllerBase fromTarget(final Target target, final Action action, } if (target.isRequestControllerAttributes()) { - result.add(ControllerLinkBuilder - .linkTo(ControllerLinkBuilder.methodOn(DdiRootController.class, tenantAware.getCurrentTenant()) + result.add(WebMvcLinkBuilder + .linkTo(WebMvcLinkBuilder.methodOn(DdiRootController.class, tenantAware.getCurrentTenant()) .putConfigData(null, tenantAware.getCurrentTenant(), target.getControllerId())) .withRel(DdiRestConstants.CONFIG_DATA_ACTION)); } diff --git a/hawkbit-rest/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiCancelActionTest.java b/hawkbit-rest/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiCancelActionTest.java index a5607db70d..da488e7f6c 100644 --- a/hawkbit-rest/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiCancelActionTest.java +++ b/hawkbit-rest/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiCancelActionTest.java @@ -60,7 +60,7 @@ public void cancelActionCbor() throws Exception { final byte[] result = mvc.perform(get("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/cancelAction/" + cancelAction.getId(), tenantAware.getCurrentTenant()).accept(DdiRestConstants.MEDIA_TYPE_CBOR)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(DdiRestConstants.MEDIA_TYPE_CBOR_UTF8)) + .andExpect(content().contentType(DdiRestConstants.MEDIA_TYPE_CBOR)) .andReturn().getResponse().getContentAsByteArray(); assertThat(JsonPathUtils.evaluate(cborToJson(result), "$.id")).isEqualTo(String.valueOf(cancelAction.getId())); assertThat(JsonPathUtils.evaluate(cborToJson(result), "$.cancelAction.stopId")).isEqualTo(String.valueOf(actionId)); @@ -99,7 +99,7 @@ public void rootRsCancelActionButContinueAnyway() throws Exception { get("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/deploymentBase/" + actionId, tenantAware.getCurrentTenant()).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$.id", equalTo(String.valueOf(actionId)))) .andExpect(jsonPath("$.deployment.download", equalTo("forced"))) .andExpect(jsonPath("$.deployment.update", equalTo("forced"))) @@ -139,9 +139,9 @@ public void rootRsCancelAction() throws Exception { long current = System.currentTimeMillis(); mvc.perform(get("/{tenant}/controller/v1/{controller}", tenantAware.getCurrentTenant(), - TestdataFactory.DEFAULT_CONTROLLER_ID).accept(MediaTypes.HAL_JSON_UTF8)) + TestdataFactory.DEFAULT_CONTROLLER_ID).accept(MediaTypes.HAL_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON_UTF8)) + .andExpect(content().contentType(MediaTypes.HAL_JSON)) .andExpect(jsonPath("$.config.polling.sleep", equalTo("00:01:00"))) .andExpect(jsonPath("$._links.deploymentBase.href", startsWith("http://localhost/" + tenantAware.getCurrentTenant() + "/controller/v1/" @@ -174,7 +174,7 @@ public void rootRsCancelAction() throws Exception { current = System.currentTimeMillis(); mvc.perform(get("/{tenant}/controller/v1/{controller}", tenantAware.getCurrentTenant(), TestdataFactory.DEFAULT_CONTROLLER_ID)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON_UTF8)) + .andExpect(content().contentType(MediaTypes.HAL_JSON)) .andExpect(jsonPath("$.config.polling.sleep", equalTo("00:01:00"))) .andExpect(jsonPath("$._links.cancelAction.href", equalTo("http://localhost/" + tenantAware.getCurrentTenant() + "/controller/v1/" @@ -193,7 +193,7 @@ public void rootRsCancelAction() throws Exception { mvc.perform(get("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/cancelAction/" + cancelAction.getId(), tenantAware.getCurrentTenant()).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$.id", equalTo(String.valueOf(cancelAction.getId())))) .andExpect(jsonPath("$.cancelAction.stopId", equalTo(String.valueOf(actionId)))); assertThat(targetManagement.getByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).get().getLastTargetQuery()) @@ -359,14 +359,14 @@ public void multipleCancelActionFeedback() throws Exception { mvc.perform(get("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/cancelAction/" + cancelAction.getId(), tenantAware.getCurrentTenant()).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$.id", equalTo(String.valueOf(cancelAction.getId())))) .andExpect(jsonPath("$.cancelAction.stopId", equalTo(String.valueOf(actionId)))); assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(6); mvc.perform(get("/{tenant}/controller/v1/{controllerId}", tenantAware.getCurrentTenant(), TestdataFactory.DEFAULT_CONTROLLER_ID)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON_UTF8)) + .andExpect(content().contentType(MediaTypes.HAL_JSON)) .andExpect(jsonPath("$.config.polling.sleep", equalTo("00:01:00"))) .andExpect(jsonPath("$._links.cancelAction.href", equalTo("http://localhost/" + tenantAware.getCurrentTenant() + "/controller/v1/" @@ -386,14 +386,14 @@ public void multipleCancelActionFeedback() throws Exception { mvc.perform(get("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/cancelAction/" + cancelAction2.getId(), tenantAware.getCurrentTenant()).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$.id", equalTo(String.valueOf(cancelAction2.getId())))) .andExpect(jsonPath("$.cancelAction.stopId", equalTo(String.valueOf(actionId2)))); assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(8); mvc.perform(get("/{tenant}/controller/v1/{controller}", tenantAware.getCurrentTenant(), TestdataFactory.DEFAULT_CONTROLLER_ID)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON_UTF8)) + .andExpect(content().contentType(MediaTypes.HAL_JSON)) .andExpect(jsonPath("$.config.polling.sleep", equalTo("00:01:00"))) .andExpect(jsonPath("$._links.cancelAction.href", equalTo("http://localhost/" + tenantAware.getCurrentTenant() + "/controller/v1/" @@ -429,7 +429,7 @@ public void multipleCancelActionFeedback() throws Exception { mvc.perform(get("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/cancelAction/" + cancelAction3.getId(), tenantAware.getCurrentTenant()).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$.id", equalTo(String.valueOf(cancelAction3.getId())))) .andExpect(jsonPath("$.cancelAction.stopId", equalTo(String.valueOf(actionId3)))); assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(12); @@ -438,7 +438,7 @@ public void multipleCancelActionFeedback() throws Exception { mvc.perform(post("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/cancelAction/" + cancelAction3.getId() + "/feedback", tenantAware.getCurrentTenant()) .content(JsonBuilder.cancelActionFeedback(cancelAction3.getId().toString(), "closed")) - .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON_UTF8)) + .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()); assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(13); diff --git a/hawkbit-rest/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiConfigDataTest.java b/hawkbit-rest/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiConfigDataTest.java index 15c2157e55..0d9a41b647 100644 --- a/hawkbit-rest/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiConfigDataTest.java +++ b/hawkbit-rest/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiConfigDataTest.java @@ -79,9 +79,9 @@ public void requestConfigDataIfEmpty() throws Exception { final long current = System.currentTimeMillis(); mvc.perform( - get("/{tenant}/controller/v1/4712", tenantAware.getCurrentTenant()).accept(MediaTypes.HAL_JSON_UTF8)) + get("/{tenant}/controller/v1/4712", tenantAware.getCurrentTenant()).accept(MediaTypes.HAL_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON_UTF8)) + .andExpect(content().contentType(MediaTypes.HAL_JSON)) .andExpect(jsonPath("$.config.polling.sleep", equalTo("00:01:00"))) .andExpect(jsonPath("$._links.configData.href", equalTo( "http://localhost/" + tenantAware.getCurrentTenant() + "/controller/v1/4712/configData"))); @@ -103,9 +103,9 @@ public void requestConfigDataIfEmpty() throws Exception { assertThat(updateControllerAttributes.isRequestControllerAttributes()).isFalse(); mvc.perform( - get("/{tenant}/controller/v1/4712", tenantAware.getCurrentTenant()).accept(MediaTypes.HAL_JSON_UTF8)) + get("/{tenant}/controller/v1/4712", tenantAware.getCurrentTenant()).accept(MediaTypes.HAL_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON_UTF8)) + .andExpect(content().contentType(MediaTypes.HAL_JSON)) .andExpect(jsonPath("$.config.polling.sleep", equalTo("00:01:00"))) .andExpect(jsonPath("$._links.configData.href").doesNotExist()); } diff --git a/hawkbit-rest/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiDeploymentBaseTest.java b/hawkbit-rest/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiDeploymentBaseTest.java index a54e912bf0..576caf30b3 100644 --- a/hawkbit-rest/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiDeploymentBaseTest.java +++ b/hawkbit-rest/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiDeploymentBaseTest.java @@ -187,7 +187,7 @@ public void deploymentForceAction() throws Exception { final DistributionSet findDistributionSetByAction = distributionSetManagement.getByAction(action.getId()).get(); - getAndVerifyDeploymentBasePayload(DEFAULT_CONTROLLER_ID, MediaType.APPLICATION_JSON_UTF8, ds, artifact, + getAndVerifyDeploymentBasePayload(DEFAULT_CONTROLLER_ID, MediaType.APPLICATION_JSON, ds, artifact, artifactSignature, action.getId(), findDistributionSetByAction.findFirstModuleByType(osType).get().getId(), "forced", "forced"); @@ -287,7 +287,7 @@ public void deploymentAttemptAction() throws Exception { final DistributionSet findDistributionSetByAction = distributionSetManagement.getByAction(action.getId()).get(); - getAndVerifyDeploymentBasePayload(DEFAULT_CONTROLLER_ID, MediaType.APPLICATION_JSON_UTF8, ds, + getAndVerifyDeploymentBasePayload(DEFAULT_CONTROLLER_ID, MediaType.APPLICATION_JSON, ds, visibleMetadataOsKey, visibleMetadataOsValue, artifact, artifactSignature, action.getId(), "attempt", "attempt", getOsModule(findDistributionSetByAction)); @@ -347,11 +347,11 @@ public void deploymentAutoForceAction() throws Exception { final DistributionSet findDistributionSetByAction = distributionSetManagement.getByAction(action.getId()).get(); - getAndVerifyDeploymentBasePayload(DEFAULT_CONTROLLER_ID, MediaType.APPLICATION_JSON_UTF8, ds, artifact, + getAndVerifyDeploymentBasePayload(DEFAULT_CONTROLLER_ID, MediaType.APPLICATION_JSON, ds, artifact, artifactSignature, action.getId(), findDistributionSetByAction.findFirstModuleByType(osType).get().getId(), "forced", "forced"); - getAndVerifyDeploymentBasePayload(DEFAULT_CONTROLLER_ID, MediaTypes.HAL_JSON_UTF8, ds, artifact, + getAndVerifyDeploymentBasePayload(DEFAULT_CONTROLLER_ID, MediaTypes.HAL_JSON, ds, artifact, artifactSignature, action.getId(), findDistributionSetByAction.findFirstModuleByType(osType).get().getId(), "forced", "forced"); @@ -415,7 +415,7 @@ public void deploymentDownloadOnlyAction() throws Exception { final DistributionSet findDistributionSetByAction = distributionSetManagement.getByAction(action.getId()).get(); - getAndVerifyDeploymentBasePayload(DEFAULT_CONTROLLER_ID, MediaType.APPLICATION_JSON_UTF8, ds, "metaDataVisible", + getAndVerifyDeploymentBasePayload(DEFAULT_CONTROLLER_ID, MediaType.APPLICATION_JSON, ds, "metaDataVisible", "withValue", artifact, artifactSignature, action.getId(), "forced", "skip", getOsModule(findDistributionSetByAction)); diff --git a/hawkbit-rest/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiRootControllerTest.java b/hawkbit-rest/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiRootControllerTest.java index 68849dc2ef..c5a0a38d57 100644 --- a/hawkbit-rest/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiRootControllerTest.java +++ b/hawkbit-rest/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiRootControllerTest.java @@ -88,7 +88,7 @@ public class DdiRootControllerTest extends AbstractDDiApiIntegrationTest { public void rootPollResourceCbor() throws Exception { mvc.perform(get("/{tenant}/controller/v1/4711", tenantAware.getCurrentTenant()) .accept(DdiRestConstants.MEDIA_TYPE_CBOR)).andDo(MockMvcResultPrinter.print()) - .andExpect(content().contentType(DdiRestConstants.MEDIA_TYPE_CBOR_UTF8)).andExpect(status().isOk()); + .andExpect(content().contentType(DdiRestConstants.MEDIA_TYPE_CBOR)).andExpect(status().isOk()); } @Test @@ -96,7 +96,7 @@ public void rootPollResourceCbor() throws Exception { public void apiReturnsJSONByDefault() throws Exception { final MvcResult result = mvc.perform(get("/{tenant}/controller/v1/4711", tenantAware.getCurrentTenant())) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON_UTF8)).andReturn(); + .andExpect(content().contentType(MediaTypes.HAL_JSON)).andReturn(); // verify that we did not specify a content-type in the request, in case // there are any default values @@ -176,7 +176,7 @@ public void rootRsPlugAndPlay() throws Exception { final long current = System.currentTimeMillis(); mvc.perform(get("/default-tenant/controller/v1/4711")).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isOk()).andExpect(content().contentType(MediaTypes.HAL_JSON_UTF8)) + .andExpect(status().isOk()).andExpect(content().contentType(MediaTypes.HAL_JSON)) .andExpect(jsonPath("$.config.polling.sleep", equalTo("00:01:00"))); assertThat(targetManagement.getByControllerID("4711").get().getLastTargetQuery()) .isGreaterThanOrEqualTo(current); @@ -210,7 +210,7 @@ public void pollWithModifiedGloablPollingTime() throws Exception { securityRule.runAs(WithSpringAuthorityRule.withUser("controller", CONTROLLER_ROLE_ANONYMOUS), () -> { mvc.perform(get("/{tenant}/controller/v1/4711", tenantAware.getCurrentTenant())) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON_UTF8)) + .andExpect(content().contentType(MediaTypes.HAL_JSON)) .andExpect(jsonPath("$.config.polling.sleep", equalTo("00:02:00"))); return null; }); @@ -229,7 +229,7 @@ public void pollWithModifiedGloablPollingTime() throws Exception { public void rootRsNotModified() throws Exception { final String etag = mvc.perform(get("/{tenant}/controller/v1/4711", tenantAware.getCurrentTenant())) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON_UTF8)) + .andExpect(content().contentType(MediaTypes.HAL_JSON)) .andExpect(jsonPath("$.config.polling.sleep", equalTo("00:01:00"))).andReturn().getResponse() .getHeader("ETag"); @@ -247,7 +247,7 @@ public void rootRsNotModified() throws Exception { .perform(get("/{tenant}/controller/v1/4711", tenantAware.getCurrentTenant()) .header("If-None-Match", etag).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$.config.polling.sleep", equalTo("00:01:00"))) .andExpect(jsonPath("$._links.deploymentBase.href", startsWith("http://localhost/" + tenantAware.getCurrentTenant() @@ -278,7 +278,7 @@ public void rootRsNotModified() throws Exception { mvc.perform(get("/{tenant}/controller/v1/4711", tenantAware.getCurrentTenant()) .header("If-None-Match", etagWithFirstUpdate).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$.config.polling.sleep", equalTo("00:01:00"))) .andExpect(jsonPath("$._links.deploymentBase.href", startsWith("http://localhost/" + tenantAware.getCurrentTenant() @@ -300,7 +300,7 @@ public void rootRsPrecommissioned() throws Exception { final long current = System.currentTimeMillis(); mvc.perform(get("/{tenant}/controller/v1/4711", tenantAware.getCurrentTenant())) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON_UTF8)) + .andExpect(content().contentType(MediaTypes.HAL_JSON)) .andExpect(jsonPath("$.config.polling.sleep", equalTo("00:01:00"))); assertThat(targetManagement.getByControllerID("4711").get().getLastTargetQuery()) diff --git a/hawkbit-rest/hawkbit-mgmt-api/pom.xml b/hawkbit-rest/hawkbit-mgmt-api/pom.xml index 59defdc9d8..99df616273 100644 --- a/hawkbit-rest/hawkbit-mgmt-api/pom.xml +++ b/hawkbit-rest/hawkbit-mgmt-api/pom.xml @@ -24,6 +24,11 @@ org.springframework.hateoas spring-hateoas + + org.springframework + spring-webmvc + test + org.springframework.boot spring-boot-starter-json diff --git a/hawkbit-rest/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/MgmtBaseEntity.java b/hawkbit-rest/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/MgmtBaseEntity.java index 7287340508..1013eb305e 100644 --- a/hawkbit-rest/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/MgmtBaseEntity.java +++ b/hawkbit-rest/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/MgmtBaseEntity.java @@ -8,7 +8,8 @@ */ package org.eclipse.hawkbit.mgmt.json.model; -import org.springframework.hateoas.ResourceSupport; +import org.springframework.hateoas.Link; +import org.springframework.hateoas.RepresentationModel; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; @@ -17,7 +18,7 @@ * A json annotated rest model for BaseEntity to RESTful API representation. * */ -public abstract class MgmtBaseEntity extends ResourceSupport { +public abstract class MgmtBaseEntity extends RepresentationModel { @JsonProperty private String createdBy; @@ -31,6 +32,16 @@ public abstract class MgmtBaseEntity extends ResourceSupport { @JsonProperty private Long lastModifiedAt; + /** + * Added for backwards compatibility + * + * @return the unique identifier of the {@link MgmtBaseEntity}. + */ + @JsonIgnore + public Link getId() { + return this.getRequiredLink("self"); + } + /** * @return the createdBy */ diff --git a/hawkbit-rest/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/PagedList.java b/hawkbit-rest/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/PagedList.java index 534cfa98d6..a1009e9bff 100644 --- a/hawkbit-rest/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/PagedList.java +++ b/hawkbit-rest/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/PagedList.java @@ -13,7 +13,7 @@ import javax.validation.constraints.NotNull; -import org.springframework.hateoas.ResourceSupport; +import org.springframework.hateoas.RepresentationModel; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; @@ -32,7 +32,7 @@ */ @JsonIgnoreProperties(ignoreUnknown = true) @JsonInclude(Include.NON_NULL) -public class PagedList extends ResourceSupport { +public class PagedList extends RepresentationModel> { @JsonProperty private final List content; diff --git a/hawkbit-rest/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtActionId.java b/hawkbit-rest/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtActionId.java index b0cf945bd2..91f259e217 100644 --- a/hawkbit-rest/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtActionId.java +++ b/hawkbit-rest/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtActionId.java @@ -8,24 +8,24 @@ */ package org.eclipse.hawkbit.mgmt.json.model.distributionset; -import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo; -import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn; +import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo; +import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn; + +import java.util.Objects; import org.eclipse.hawkbit.mgmt.rest.api.MgmtTargetRestApi; -import org.springframework.hateoas.ResourceSupport; +import org.springframework.hateoas.RepresentationModel; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.Objects; - /** * Representation of an Action Id as a Json Object with link to the Action resource */ @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class MgmtActionId extends ResourceSupport { +public class MgmtActionId extends RepresentationModel { private long actionId; diff --git a/hawkbit-rest/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtTargetAssignmentResponseBody.java b/hawkbit-rest/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtTargetAssignmentResponseBody.java index 04c28dc2f9..c0ede38645 100644 --- a/hawkbit-rest/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtTargetAssignmentResponseBody.java +++ b/hawkbit-rest/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtTargetAssignmentResponseBody.java @@ -11,11 +11,12 @@ import java.util.List; import java.util.Objects; +import org.springframework.hateoas.RepresentationModel; + import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonProperty; -import org.springframework.hateoas.ResourceSupport; /** * Response Body of Target for assignment operations. @@ -25,7 +26,7 @@ */ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class MgmtTargetAssignmentResponseBody extends ResourceSupport { +public class MgmtTargetAssignmentResponseBody extends RepresentationModel { private int alreadyAssigned; private List assignedActions; diff --git a/hawkbit-rest/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/system/MgmtSystemTenantConfigurationValue.java b/hawkbit-rest/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/system/MgmtSystemTenantConfigurationValue.java index 776b69c09c..7c2e33a0f0 100644 --- a/hawkbit-rest/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/system/MgmtSystemTenantConfigurationValue.java +++ b/hawkbit-rest/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/system/MgmtSystemTenantConfigurationValue.java @@ -9,7 +9,7 @@ package org.eclipse.hawkbit.mgmt.json.model.system; -import org.springframework.hateoas.ResourceSupport; +import org.springframework.hateoas.RepresentationModel; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; @@ -22,7 +22,7 @@ */ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -public class MgmtSystemTenantConfigurationValue extends ResourceSupport { +public class MgmtSystemTenantConfigurationValue extends RepresentationModel { @JsonInclude(Include.ALWAYS) private Object value; diff --git a/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetMapper.java b/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetMapper.java index 18127da8a9..2a7bb46fbd 100644 --- a/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetMapper.java +++ b/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetMapper.java @@ -8,8 +8,8 @@ */ package org.eclipse.hawkbit.mgmt.rest.resource; -import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo; -import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn; +import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo; +import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn; import java.util.ArrayList; import java.util.Collection; diff --git a/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeMapper.java b/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeMapper.java index f6ca54b10b..dfd3b28961 100644 --- a/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeMapper.java +++ b/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeMapper.java @@ -8,8 +8,8 @@ */ package org.eclipse.hawkbit.mgmt.rest.resource; -import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo; -import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn; +import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo; +import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn; import java.util.Collection; import java.util.Collections; diff --git a/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutMapper.java b/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutMapper.java index cd4c6cb280..04e99b6bff 100644 --- a/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutMapper.java +++ b/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutMapper.java @@ -8,8 +8,8 @@ */ package org.eclipse.hawkbit.mgmt.rest.resource; -import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo; -import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn; +import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo; +import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn; import java.util.Collections; import java.util.List; diff --git a/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleMapper.java b/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleMapper.java index d7f006499e..027bc9a3a6 100644 --- a/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleMapper.java +++ b/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleMapper.java @@ -8,8 +8,8 @@ */ package org.eclipse.hawkbit.mgmt.rest.resource; -import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo; -import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn; +import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo; +import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn; import java.util.Collection; import java.util.Collections; diff --git a/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeMapper.java b/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeMapper.java index 0b1456fc47..47900b4d25 100644 --- a/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeMapper.java +++ b/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeMapper.java @@ -8,8 +8,8 @@ */ package org.eclipse.hawkbit.mgmt.rest.resource; -import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo; -import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn; +import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo; +import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn; import java.util.Collection; import java.util.Collections; diff --git a/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTagMapper.java b/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTagMapper.java index 37bfa644f1..a6348973bc 100644 --- a/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTagMapper.java +++ b/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTagMapper.java @@ -8,8 +8,8 @@ */ package org.eclipse.hawkbit.mgmt.rest.resource; -import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo; -import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn; +import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo; +import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn; import java.util.ArrayList; import java.util.Collection; diff --git a/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetFilterQueryMapper.java b/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetFilterQueryMapper.java index 935e727d6a..446458cd5c 100644 --- a/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetFilterQueryMapper.java +++ b/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetFilterQueryMapper.java @@ -8,8 +8,8 @@ */ package org.eclipse.hawkbit.mgmt.rest.resource; -import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo; -import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn; +import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo; +import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn; import java.util.Collections; import java.util.List; diff --git a/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetMapper.java b/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetMapper.java index 8c046c68dd..1409816c11 100644 --- a/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetMapper.java +++ b/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetMapper.java @@ -8,8 +8,8 @@ */ package org.eclipse.hawkbit.mgmt.rest.resource; -import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo; -import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn; +import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo; +import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn; import java.net.URI; import java.time.ZoneId; diff --git a/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTenantManagementMapper.java b/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTenantManagementMapper.java index 034a68758b..f93cf0b8d3 100644 --- a/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTenantManagementMapper.java +++ b/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTenantManagementMapper.java @@ -8,8 +8,8 @@ */ package org.eclipse.hawkbit.mgmt.rest.resource; -import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo; -import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn; +import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo; +import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn; import java.util.Map; import java.util.stream.Collectors; diff --git a/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/PagingUtility.java b/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/PagingUtility.java index 4b357358fd..b9fd6df598 100644 --- a/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/PagingUtility.java +++ b/hawkbit-rest/hawkbit-mgmt-resource/src/main/java/org/eclipse/hawkbit/mgmt/rest/resource/PagingUtility.java @@ -56,106 +56,106 @@ static int sanitizePageLimitParam(final int pageLimit) { static Sort sanitizeTargetSortParam(final String sortParam) { if (sortParam == null) { // default - return new Sort(Direction.ASC, TargetFields.CONTROLLERID.getFieldName()); + return Sort.by(Direction.ASC, TargetFields.CONTROLLERID.getFieldName()); } - return new Sort(SortUtility.parse(TargetFields.class, sortParam)); + return Sort.by(SortUtility.parse(TargetFields.class, sortParam)); } static Sort sanitizeTagSortParam(final String sortParam) { if (sortParam == null) { // default - return new Sort(Direction.ASC, TagFields.ID.getFieldName()); + return Sort.by(Direction.ASC, TagFields.ID.getFieldName()); } - return new Sort(SortUtility.parse(TagFields.class, sortParam)); + return Sort.by(SortUtility.parse(TagFields.class, sortParam)); } static Sort sanitizeTargetFilterQuerySortParam(final String sortParam) { if (sortParam == null) { // default - return new Sort(Direction.ASC, TargetFilterQueryFields.ID.getFieldName()); + return Sort.by(Direction.ASC, TargetFilterQueryFields.ID.getFieldName()); } - return new Sort(SortUtility.parse(TargetFilterQueryFields.class, sortParam)); + return Sort.by(SortUtility.parse(TargetFilterQueryFields.class, sortParam)); } static Sort sanitizeSoftwareModuleSortParam(final String sortParam) { if (sortParam == null) { // default - return new Sort(Direction.ASC, SoftwareModuleFields.ID.getFieldName()); + return Sort.by(Direction.ASC, SoftwareModuleFields.ID.getFieldName()); } - return new Sort(SortUtility.parse(SoftwareModuleFields.class, sortParam)); + return Sort.by(SortUtility.parse(SoftwareModuleFields.class, sortParam)); } static Sort sanitizeSoftwareModuleTypeSortParam(final String sortParam) { if (sortParam == null) { // default - return new Sort(Direction.ASC, SoftwareModuleTypeFields.ID.getFieldName()); + return Sort.by(Direction.ASC, SoftwareModuleTypeFields.ID.getFieldName()); } - return new Sort(SortUtility.parse(SoftwareModuleTypeFields.class, sortParam)); + return Sort.by(SortUtility.parse(SoftwareModuleTypeFields.class, sortParam)); } static Sort sanitizeDistributionSetSortParam(final String sortParam) { if (sortParam == null) { // default - return new Sort(Direction.ASC, DistributionSetFields.ID.getFieldName()); + return Sort.by(Direction.ASC, DistributionSetFields.ID.getFieldName()); } - return new Sort(SortUtility.parse(DistributionSetFields.class, sortParam)); + return Sort.by(SortUtility.parse(DistributionSetFields.class, sortParam)); } static Sort sanitizeDistributionSetTypeSortParam(final String sortParam) { if (sortParam == null) { // default - return new Sort(Direction.ASC, DistributionSetTypeFields.ID.getFieldName()); + return Sort.by(Direction.ASC, DistributionSetTypeFields.ID.getFieldName()); } - return new Sort(SortUtility.parse(DistributionSetTypeFields.class, sortParam)); + return Sort.by(SortUtility.parse(DistributionSetTypeFields.class, sortParam)); } static Sort sanitizeActionSortParam(final String sortParam) { if (sortParam == null) { // default sort is DESC in case of action to match behavior // of management UI (last entry on top) - return new Sort(Direction.DESC, ActionFields.ID.getFieldName()); + return Sort.by(Direction.DESC, ActionFields.ID.getFieldName()); } - return new Sort(SortUtility.parse(ActionFields.class, sortParam)); + return Sort.by(SortUtility.parse(ActionFields.class, sortParam)); } static Sort sanitizeActionStatusSortParam(final String sortParam) { if (sortParam == null) { // default sort is DESC in case of action status to match behavior // of management UI (last entry on top) - return new Sort(Direction.DESC, ActionStatusFields.ID.getFieldName()); + return Sort.by(Direction.DESC, ActionStatusFields.ID.getFieldName()); } - return new Sort(SortUtility.parse(ActionStatusFields.class, sortParam)); + return Sort.by(SortUtility.parse(ActionStatusFields.class, sortParam)); } static Sort sanitizeDistributionSetMetadataSortParam(final String sortParam) { if (sortParam == null) { // default - return new Sort(Direction.ASC, DistributionSetMetadataFields.KEY.getFieldName()); + return Sort.by(Direction.ASC, DistributionSetMetadataFields.KEY.getFieldName()); } - return new Sort(SortUtility.parse(DistributionSetMetadataFields.class, sortParam)); + return Sort.by(SortUtility.parse(DistributionSetMetadataFields.class, sortParam)); } static Sort sanitizeSoftwareModuleMetadataSortParam(final String sortParam) { if (sortParam == null) { // default - return new Sort(Direction.ASC, SoftwareModuleMetadataFields.KEY.getFieldName()); + return Sort.by(Direction.ASC, SoftwareModuleMetadataFields.KEY.getFieldName()); } - return new Sort(SortUtility.parse(SoftwareModuleMetadataFields.class, sortParam)); + return Sort.by(SortUtility.parse(SoftwareModuleMetadataFields.class, sortParam)); } static Sort sanitizeRolloutSortParam(final String sortParam) { if (sortParam == null) { // default - return new Sort(Direction.ASC, RolloutFields.ID.getFieldName()); + return Sort.by(Direction.ASC, RolloutFields.ID.getFieldName()); } - return new Sort(SortUtility.parse(RolloutFields.class, sortParam)); + return Sort.by(SortUtility.parse(RolloutFields.class, sortParam)); } static Sort sanitizeRolloutGroupSortParam(final String sortParam) { if (sortParam == null) { // default - return new Sort(Direction.ASC, RolloutGroupFields.ID.getFieldName()); + return Sort.by(Direction.ASC, RolloutGroupFields.ID.getFieldName()); } - return new Sort(SortUtility.parse(RolloutGroupFields.class, sortParam)); + return Sort.by(SortUtility.parse(RolloutGroupFields.class, sortParam)); } } diff --git a/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtContentTypeTest.java b/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtContentTypeTest.java new file mode 100644 index 0000000000..966cf11ce6 --- /dev/null +++ b/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtContentTypeTest.java @@ -0,0 +1,189 @@ +/** + * Copyright (c) 2020 Bosch.IO GmbH and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.eclipse.hawkbit.mgmt.rest.resource; + +import io.qameta.allure.Description; +import io.qameta.allure.Feature; +import io.qameta.allure.Story; +import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; +import org.eclipse.hawkbit.repository.model.DistributionSet; +import org.eclipse.hawkbit.rest.util.JsonBuilder; +import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter; +import org.junit.Before; +import org.junit.Test; +import org.springframework.boot.autoconfigure.web.servlet.HttpEncodingAutoConfiguration; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.web.servlet.server.Encoding; +import org.springframework.context.annotation.Import; +import org.springframework.hateoas.MediaTypes; +import org.springframework.http.MediaType; +import org.springframework.test.web.servlet.MvcResult; + +import java.util.Arrays; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.junit.Assert.assertEquals; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; + +/** + * With Spring Boot 2.2.x the default charset encoding became deprecated. In + * hawkBit we want to keep the old behavior for now and still return the charset + * in the response, which is achieved through enabling {@link Encoding} via + * properties. + */ +@SpringBootTest(properties = { "server.servlet.encoding.charset=UTF-8", "server.servlet.encoding.force=true" }) +@Import(HttpEncodingAutoConfiguration.class) +@Feature("Component Tests - Management API") +@Story("Response Content-Type") +public class MgmtContentTypeTest extends AbstractManagementApiIntegrationTest { + + private DistributionSet ds; + private final String dsName = "DS-ö"; + + @Before + public void setupBeforeTest() { + ds = testdataFactory.generateDistributionSet(dsName); + } + + @Test + @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(); + + assertEquals(MediaTypes.HAL_JSON_VALUE + ";charset=UTF-8", getResponseHeaderContentType(result)); + } + + @Test + @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))) + .contentType(MediaType.APPLICATION_JSON_UTF8).accept(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated()) + .andExpect(jsonPath("[0]name", equalTo(dsName))).andReturn(); + + assertEquals(MediaType.APPLICATION_JSON_UTF8_VALUE, getResponseHeaderContentType(result)); + } + + @Test + @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))) + .contentType(MediaType.APPLICATION_JSON_UTF8).accept(MediaType.APPLICATION_JSON_UTF8)) + .andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated()) + .andExpect(jsonPath("[0]name", equalTo(dsName))).andReturn(); + + assertEquals(MediaType.APPLICATION_JSON_UTF8_VALUE, getResponseHeaderContentType(result)); + } + + @Test + @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))) + .contentType(MediaType.APPLICATION_JSON_UTF8).accept(MediaTypes.HAL_JSON)) + .andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated()) + .andExpect(jsonPath("[0]name", equalTo(dsName))).andReturn(); + + assertEquals(MediaTypes.HAL_JSON_VALUE + ";charset=UTF-8", getResponseHeaderContentType(result)); + } + + @Test + @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()) + .andExpect(status().isCreated()) + .andExpect(jsonPath("[0]name", equalTo(dsName))).andReturn(); + + assertEquals(MediaTypes.HAL_JSON_VALUE + ";charset=UTF-8", getResponseHeaderContentType(result)); + } + + @Test + @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))) + .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated()) + .andExpect(jsonPath("[0]name", equalTo(dsName))).andReturn(); + + assertEquals(MediaType.APPLICATION_JSON_UTF8_VALUE, getResponseHeaderContentType(result)); + } + + @Test + @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()) + .andExpect(status().isCreated()) + .andExpect(jsonPath("[0]name", equalTo(dsName))).andReturn(); + + assertEquals(MediaType.APPLICATION_JSON_UTF8_VALUE, getResponseHeaderContentType(result)); + } + + @Test + @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()) + .andExpect(status().isCreated()) + .andExpect(jsonPath("[0]name", equalTo(dsName))).andReturn(); + + assertEquals(MediaTypes.HAL_JSON_VALUE + ";charset=UTF-8", getResponseHeaderContentType(result)); + } + + @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()) + .andExpect(status().isOk()) + .andReturn(); + + assertEquals(MediaTypes.HAL_JSON_VALUE + ";charset=UTF-8", getResponseHeaderContentType(result)); + } + + @Test + @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()) + .andReturn(); + + assertEquals(MediaType.APPLICATION_JSON_UTF8_VALUE, getResponseHeaderContentType(result)); + } + + @Test + @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()) + .andReturn(); + + assertEquals(MediaType.APPLICATION_JSON_UTF8_VALUE, getResponseHeaderContentType(result)); + } + + @Test + @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()) + .andReturn(); + + assertEquals(MediaTypes.HAL_JSON_VALUE + ";charset=UTF-8", getResponseHeaderContentType(result)); + } + + private String getResponseHeaderContentType(MvcResult result) { + return result.getResponse().getHeader("Content-Type"); + } +} diff --git a/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResourceTest.java b/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResourceTest.java index 798502a2c6..edf2a40c5e 100644 --- a/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResourceTest.java +++ b/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResourceTest.java @@ -694,7 +694,7 @@ public void getDistributionSets() throws Exception { // perform request mvc.perform(get("/rest/v1/distributionsets").accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$.content.[0]._links.self.href", equalTo("http://localhost/rest/v1/distributionsets/" + set.getId()))) .andExpect(jsonPath("$.content.[0].id", equalTo(set.getId().intValue()))) @@ -725,7 +725,7 @@ public void getDistributionSet() throws Exception { // perform request mvc.perform(get("/rest/v1/distributionsets/{dsId}", set.getId()).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$._links.self.href", equalTo("http://localhost/rest/v1/distributionsets/" + set.getId()))) .andExpect(jsonPath("$.id", equalTo(set.getId().intValue()))) @@ -818,7 +818,7 @@ private MvcResult executeMgmtTargetPost(final DistributionSet one, final Distrib .content(JsonBuilder.distributionSets(Arrays.asList(one, two, three))) .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("[0]name", equalTo(one.getName()))) .andExpect(jsonPath("[0]description", equalTo(one.getDescription()))) .andExpect(jsonPath("[0]type", equalTo(standardDsType.getKey()))) @@ -1034,7 +1034,7 @@ public void createMetadata() throws Exception { 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()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("[0]key", equalTo(knownKey1))).andExpect(jsonPath("[0]value", equalTo(knownValue1))) .andExpect(jsonPath("[1]key", equalTo(knownKey2))) .andExpect(jsonPath("[1]value", equalTo(knownValue2))); @@ -1083,7 +1083,7 @@ public void updateMetadata() throws Exception { 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()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("key", equalTo(knownKey))).andExpect(jsonPath("value", equalTo(updateValue))); final DistributionSetMetadata assertDS = distributionSetManagement diff --git a/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTagResourceTest.java b/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTagResourceTest.java index 11aeadeb87..8a1b35413c 100644 --- a/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTagResourceTest.java +++ b/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTagResourceTest.java @@ -63,7 +63,7 @@ public void getDistributionSetTags() throws Exception { mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(applyBaseEntityMatcherOnPagedResult(assigned)) .andExpect(applyBaseEntityMatcherOnPagedResult(unassigned)) .andExpect(applySelfLinkMatcherOnPagedResult(assigned, DISTRIBUTIONSETTAGS_ROOT + assigned.getId())) @@ -82,7 +82,7 @@ public void getDistributionSetTag() throws Exception { mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/" + assigned.getId()) .accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(applyTagMatcherOnSingleResult(assigned)) .andExpect(applySelfLinkMatcherOnSingleResult(DISTRIBUTIONSETTAGS_ROOT + assigned.getId())) .andExpect(jsonPath("_links.assignedDistributionSets.href", @@ -103,7 +103,7 @@ public void createDistributionSetTags() throws JSONException, Exception { .content(JsonBuilder.tags(Arrays.asList(tagOne, tagTwo))) .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)); + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)); final Tag createdOne = distributionSetTagManagement.findByRsql(PAGE, "name==thetest1").getContent().get(0); assertThat(createdOne.getName()).isEqualTo(tagOne.getName()); @@ -133,7 +133,7 @@ public void updateDistributionSetTag() throws Exception { .content(JsonBuilder.tag(update)).contentType(MediaType.APPLICATION_JSON) .accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)); + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)); final Tag updated = distributionSetTagManagement.findByRsql(PAGE, "name==updatedName").getContent().get(0); assertThat(updated.getName()).isEqualTo(update.getName()); @@ -260,7 +260,7 @@ private ResultActions toggle(final DistributionSetTag tag, final List updated = distributionSetManagement.findByTag(PAGE, tag.getId()).getContent(); diff --git a/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeResourceTest.java b/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeResourceTest.java index b813817aec..ebba9ef40e 100644 --- a/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeResourceTest.java +++ b/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeResourceTest.java @@ -72,7 +72,7 @@ public void getDistributionSetTypes() throws Exception { // generated in this test) mvc.perform(get("/rest/v1/distributionsettypes").accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$.content.[?(@.key=='" + standardDsType.getKey() + "')].name", contains(standardDsType.getName()))) .andExpect(jsonPath("$.content.[?(@.key=='" + standardDsType.getKey() + "')].description", @@ -106,7 +106,7 @@ public void getDistributionSetTypesSortedByKey() throws Exception { // 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_UTF8_VALUE)) + .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"))) @@ -120,7 +120,7 @@ public void getDistributionSetTypesSortedByKey() throws Exception { // 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_UTF8_VALUE)) + .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"))) @@ -174,7 +174,7 @@ private MvcResult runPostDistributionSetType(final List typ .perform(post("/rest/v1/distributionsettypes/").content(JsonBuilder.distributionSetTypes(types)) .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("[0].name", equalTo("TestName1"))) .andExpect(jsonPath("[0].key", equalTo("testKey1"))) .andExpect(jsonPath("[0].description", equalTo("Desc1"))) @@ -306,7 +306,7 @@ public void getMandatoryModulesOfDistributionSetType() throws Exception { mvc.perform(get("/rest/v1/distributionsettypes/{dstID}/mandatorymoduletypes", testType.getId()) .accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .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"))); @@ -320,7 +320,7 @@ public void getOptionalModulesOfDistributionSetType() throws Exception { mvc.perform(get("/rest/v1/distributionsettypes/{dstID}/optionalmoduletypes", testType.getId()) .accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("[0].name", equalTo(appType.getName()))) .andExpect(jsonPath("[0].description", equalTo(appType.getDescription()))) .andExpect(jsonPath("[0].maxAssignments", equalTo(Integer.MAX_VALUE))) @@ -417,7 +417,7 @@ public void getDistributionSetType() throws Exception { mvc.perform(get("/rest/v1/distributionsettypes/{dstId}", testType.getId()).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$.name", equalTo("TestName123"))) .andExpect(jsonPath("$.description", equalTo("Desc1234"))) .andExpect(jsonPath("$.createdBy", equalTo("uploadTester"))) diff --git a/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutResourceTest.java b/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutResourceTest.java index 17f2812a4e..0b7b340c38 100644 --- a/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutResourceTest.java +++ b/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutResourceTest.java @@ -251,7 +251,7 @@ public void createRolloutWithTooHighPercentage() throws Exception { @Description("Testing the empty list is returned if no rollout exists") public 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_UTF8_VALUE)) + .andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$.content", hasSize(0))).andExpect(jsonPath("$.total", equalTo(0))); } @@ -280,7 +280,7 @@ private void retrieveAndVerifyRolloutInRunning(final Rollout rollout) throws Exc mvc.perform(get("/rest/v1/rollouts/" + rollout.getId()).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .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("$.totalTargetsPerStatus.running", equalTo(5))) @@ -298,7 +298,7 @@ private void retrieveAndVerifyRolloutInStarting(final Rollout rollout) throws Ex mvc.perform(get("/rest/v1/rollouts/" + rollout.getId()).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .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("$.totalTargetsPerStatus.running", equalTo(0))) @@ -316,7 +316,7 @@ private void retrieveAndVerifyRolloutInReady(final Rollout rollout) throws Excep mvc.perform(get("/rest/v1/rollouts/" + rollout.getId()).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .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("$.lastModifiedBy", equalTo("bumlux"))) @@ -334,7 +334,7 @@ private void retrieveAndVerifyRolloutInReady(final Rollout rollout) throws Excep 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()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .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("$.targetFilterQuery", equalTo("controllerId==rollout*"))) @@ -375,7 +375,7 @@ public void rolloutPagedListContainsAllRollouts() throws Exception { rolloutManagement.handleRollouts(); mvc.perform(get("/rest/v1/rollouts").accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .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"))) @@ -417,7 +417,7 @@ public void rolloutPagedListIsLimitedToQueryParam() throws Exception { mvc.perform(get("/rest/v1/rollouts?limit=1").accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$.content", hasSize(1))).andExpect(jsonPath("$.total", equalTo(2))); } @@ -436,7 +436,7 @@ public void retrieveRolloutGroupsForSpecificRollout() throws Exception { mvc.perform( get("/rest/v1/rollouts/{rolloutId}/deploygroups", rollout.getId()).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$.content", hasSize(4))).andExpect(jsonPath("$.total", equalTo(4))) .andExpect(jsonPath("$.content[0].status", equalTo("ready"))) .andExpect(jsonPath("$.content[1].status", equalTo("ready"))) @@ -462,7 +462,7 @@ public void startingRolloutSwitchesIntoRunningState() throws Exception { // 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()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("id", equalTo(rollout.getId().intValue()))) .andExpect(jsonPath("status", equalTo("starting"))); @@ -472,7 +472,7 @@ public void startingRolloutSwitchesIntoRunningState() throws Exception { // 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()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("id", equalTo(rollout.getId().intValue()))) .andExpect(jsonPath("status", equalTo("running"))); } @@ -502,7 +502,7 @@ public void pausingRolloutSwitchesIntoPausedState() throws Exception { // 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()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("id", equalTo(rollout.getId().intValue()))) .andExpect(jsonPath("status", equalTo("paused"))); } @@ -536,7 +536,7 @@ public void resumingRolloutSwitchesIntoRunningState() throws Exception { // 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()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("id", equalTo(rollout.getId().intValue()))) .andExpect(jsonPath("status", equalTo("running"))); } @@ -604,7 +604,7 @@ public void startingRolloutFirstRolloutGroupIsInRunningState() throws Exception // (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()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$.content", hasSize(2))).andExpect(jsonPath("$.total", equalTo(2))) .andExpect(jsonPath("$.content[0].status", equalTo("running"))) .andExpect(jsonPath("$.content[1].status", equalTo("scheduled"))); @@ -642,7 +642,7 @@ private void retrieveAndVerifyRolloutGroupInRunningAndScheduled(final Rollout ro rolloutManagement.handleRollouts(); mvc.perform(get("/rest/v1/rollouts/{rolloutId}/deploygroups/{groupId}", rollout.getId(), firstGroup.getId()) .accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("status", equalTo("running"))) .andExpect(jsonPath("$.totalTargetsPerStatus.running", equalTo(5))) .andExpect(jsonPath("$.totalTargetsPerStatus.notstarted", equalTo(0))) @@ -653,7 +653,7 @@ private void retrieveAndVerifyRolloutGroupInRunningAndScheduled(final Rollout ro mvc.perform(get("/rest/v1/rollouts/{rolloutId}/deploygroups/{groupId}", rollout.getId(), secondGroup.getId()) .accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("status", equalTo("scheduled"))) .andExpect(jsonPath("$.totalTargetsPerStatus.running", equalTo(0))) .andExpect(jsonPath("$.totalTargetsPerStatus.notstarted", equalTo(0))) @@ -669,7 +669,7 @@ private void retrieveAndVerifyRolloutGroupInReady(final Rollout rollout, final R rolloutManagement.handleRollouts(); mvc.perform(get("/rest/v1/rollouts/{rolloutId}/deploygroups/{groupId}", rollout.getId(), firstGroup.getId()) .accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("status", equalTo("ready"))) .andExpect(jsonPath("$.lastModifiedBy", equalTo("bumlux"))) .andExpect(jsonPath("$.lastModifiedAt", not(equalTo(0)))) @@ -688,7 +688,7 @@ private void retrieveAndVerifyRolloutGroupInCreating(final Rollout rollout, fina 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()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("id", equalTo(firstGroup.getId().intValue()))) .andExpect(jsonPath("status", equalTo("creating"))).andExpect(jsonPath("name", endsWith("1"))) .andExpect(jsonPath("description", endsWith("1"))) @@ -728,7 +728,7 @@ public void retrieveTargetsFromRolloutGroup() throws Exception { get("/rest/v1/rollouts/{rolloutId}/deploygroups/{groupId}/targets", rollout.getId(), firstGroup.getId()) .accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$.content", hasSize(5))).andExpect(jsonPath("$.total", equalTo(5))); } @@ -754,7 +754,7 @@ public void retrieveTargetsFromRolloutGroupWithQuery() throws Exception { 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()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$.content", hasSize(1))).andExpect(jsonPath("$.total", equalTo(1))); } @@ -782,7 +782,7 @@ public void retrieveTargetsFromRolloutGroupAfterRolloutIsStarted() throws Except get("/rest/v1/rollouts/{rolloutId}/deploygroups/{groupId}/targets", rollout.getId(), firstGroup.getId()) .accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$.content", hasSize(5))).andExpect(jsonPath("$.total", equalTo(5))); } @@ -856,19 +856,19 @@ public void getRolloutWithRSQLParam() throws Exception { mvc.perform(get("/rest/v1/rollouts").param(MgmtRestConstants.REQUEST_PARAMETER_SEARCH, "name==*2") .accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .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()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .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_UTF8_VALUE)) + .andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$.content", hasSize(2))).andExpect(jsonPath("$.total", equalTo(2))); } @@ -888,21 +888,21 @@ public void retrieveRolloutGroupsForSpecificRolloutWithRSQLParam() throws Except 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()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$.content", hasSize(1))).andExpect(jsonPath("$.total", equalTo(1))) .andExpect(jsonPath("$.content[0].name", equalTo("group-1"))); 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()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .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()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$.content", hasSize(2))).andExpect(jsonPath("$.total", equalTo(2))); } diff --git a/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResourceTest.java b/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResourceTest.java index 1bdac9f3b1..9929b9606e 100644 --- a/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResourceTest.java +++ b/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResourceTest.java @@ -16,8 +16,8 @@ import static org.hamcrest.Matchers.hasSize; import static org.junit.Assert.assertTrue; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.fileUpload; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.multipart; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; @@ -170,10 +170,10 @@ public void uploadArtifact() throws Exception { // upload final MvcResult mvcResult = mvc - .perform(fileUpload("/rest/v1/softwaremodules/{smId}/artifacts", sm.getId()).file(file) + .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_UTF8_VALUE)) + .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))) @@ -207,7 +207,7 @@ public void uploadArtifactFailsIfTooLarge() throws Exception { final MockMultipartFile file = new MockMultipartFile("file", "origFilename", null, randomBytes); // try to upload - mvc.perform(fileUpload("/rest/v1/softwaremodules/{smId}/artifacts", sm.getId()).file(file) + mvc.perform(multipart("/rest/v1/softwaremodules/{smId}/artifacts", sm.getId()).file(file) .accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) .andExpect(status().isForbidden()) .andExpect(jsonPath("$.exceptionClass", equalTo(FileSizeQuotaExceededException.class.getName()))) @@ -223,7 +223,7 @@ public void uploadArtifactFailsIfFilenameInvalide() throws Exception { final byte[] randomBytes = randomBytes(5 * 1024); final MockMultipartFile file = new MockMultipartFile("file", illegalFilename, null, randomBytes); - mvc.perform(fileUpload("/rest/v1/softwaremodules/{smId}/artifacts", sm.getId()).file(file) + mvc.perform(multipart("/rest/v1/softwaremodules/{smId}/artifacts", sm.getId()).file(file) .accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) .andExpect(status().isBadRequest()) .andExpect(jsonPath("$.message", containsString("Invalid characters in string"))); @@ -267,7 +267,7 @@ public void emptyUploadArtifact() throws Exception { final MockMultipartFile file = new MockMultipartFile("file", "orig", null, new byte[0]); - mvc.perform(fileUpload("/rest/v1/softwaremodules/{smId}/artifacts", sm.getId()).file(file) + mvc.perform(multipart("/rest/v1/softwaremodules/{smId}/artifacts", sm.getId()).file(file) .accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) .andExpect(status().isBadRequest()); } @@ -283,15 +283,15 @@ public void duplicateUploadArtifact() throws Exception { final String sha256sum = HashGeneratorUtils.generateSHA256(random); final MockMultipartFile file = new MockMultipartFile("file", "orig", null, random); - mvc.perform(fileUpload("/rest/v1/softwaremodules/{smId}/artifacts", sm.getId()).file(file) + 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_UTF8_VALUE)) + .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()); - mvc.perform(fileUpload("/rest/v1/softwaremodules/{smId}/artifacts", sm.getId()).file(file)) + mvc.perform(multipart("/rest/v1/softwaremodules/{smId}/artifacts", sm.getId()).file(file)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isConflict()); } @@ -306,9 +306,9 @@ public void uploadArtifactWithCustomName() throws Exception { final MockMultipartFile file = new MockMultipartFile("file", "origFilename", null, random); // upload - mvc.perform(fileUpload("/rest/v1/softwaremodules/{smId}/artifacts", sm.getId()).file(file).param("filename", + mvc.perform(multipart("/rest/v1/softwaremodules/{smId}/artifacts", sm.getId()).file(file).param("filename", "customFilename")).andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated()) - .andExpect(content().contentType(MediaTypes.HAL_JSON_UTF8)) + .andExpect(content().contentType(MediaTypes.HAL_JSON)) .andExpect(jsonPath("$.providedFilename", equalTo("customFilename"))).andExpect(status().isCreated()); // check result in db... @@ -335,7 +335,7 @@ public void uploadArtifactWithHashCheck() throws Exception { // upload // wrong sha1 MvcResult mvcResult = mvc - .perform(fileUpload("/rest/v1/softwaremodules/{smId}/artifacts", sm.getId()).file(file) + .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(); @@ -346,7 +346,7 @@ public void uploadArtifactWithHashCheck() throws Exception { // wrong sha256 mvcResult = mvc - .perform(fileUpload("/rest/v1/softwaremodules/{smId}/artifacts", sm.getId()).file(file) + .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(); @@ -357,7 +357,7 @@ public void uploadArtifactWithHashCheck() throws Exception { // wrong md5 mvcResult = mvc - .perform(fileUpload("/rest/v1/softwaremodules/{smId}/artifacts", sm.getId()).file(file) + .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(); @@ -366,7 +366,7 @@ public void uploadArtifactWithHashCheck() throws Exception { assertThat(exceptionInfo.getErrorCode()).as("Exception contains wrong error code") .isEqualTo(SpServerError.SP_ARTIFACT_UPLOAD_FAILED_MD5_MATCH.getKey()); - mvc.perform(fileUpload("/rest/v1/softwaremodules/{smId}/artifacts", sm.getId()).file(file) + mvc.perform(multipart("/rest/v1/softwaremodules/{smId}/artifacts", sm.getId()).file(file) .param("md5sum", md5sum).param("sha1sum", sha1sum)).andDo(MockMvcResultPrinter.print()) .andExpect(status().isCreated()); @@ -389,10 +389,10 @@ public void uploadArtifactsUntilQuotaExceeded() throws Exception { final MockMultipartFile file = new MockMultipartFile("file", "origFilename" + i, null, random); // upload - mvc.perform(fileUpload("/rest/v1/softwaremodules/{smId}/artifacts", sm.getId()).file(file) + 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_UTF8_VALUE)) + .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))) @@ -405,7 +405,7 @@ public void uploadArtifactsUntilQuotaExceeded() throws Exception { final MockMultipartFile file = new MockMultipartFile("file", "origFilename_final", null, random); // upload - mvc.perform(fileUpload("/rest/v1/softwaremodules/{smId}/artifacts", sm.getId()).file(file) + mvc.perform(multipart("/rest/v1/softwaremodules/{smId}/artifacts", sm.getId()).file(file) .accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) .andExpect(status().isForbidden()) .andExpect(jsonPath("$.exceptionClass", equalTo(AssignmentQuotaExceededException.class.getName()))) @@ -433,10 +433,10 @@ public void uploadArtifactsUntilStorageQuotaExceeded() throws Exception { // upload final SoftwareModule sm = testdataFactory.createSoftwareModuleOs("sm" + i); - mvc.perform(fileUpload("/rest/v1/softwaremodules/{smId}/artifacts", sm.getId()).file(file) + 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_UTF8_VALUE)) + .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))) @@ -450,7 +450,7 @@ public void uploadArtifactsUntilStorageQuotaExceeded() throws Exception { // upload final SoftwareModule sm = testdataFactory.createSoftwareModuleOs("sm" + numArtifacts); - mvc.perform(fileUpload("/rest/v1/softwaremodules/{smId}/artifacts", sm.getId()).file(file) + mvc.perform(multipart("/rest/v1/softwaremodules/{smId}/artifacts", sm.getId()).file(file) .accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) .andExpect(status().isForbidden()) .andExpect(jsonPath("$.exceptionClass", equalTo(StorageQuotaExceededException.class.getName()))) @@ -504,7 +504,7 @@ public void getArtifact() throws Exception { // 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()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$.id", equalTo(artifact.getId().intValue()))) .andExpect(jsonPath("$.size", equalTo(random.length))) .andExpect(jsonPath("$.hashes.md5", equalTo(artifact.getMd5Hash()))) @@ -533,7 +533,7 @@ public void getArtifacts() throws Exception { mvc.perform(get("/rest/v1/softwaremodules/{smId}/artifacts", sm.getId()).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$.[0].id", equalTo(artifact.getId().intValue()))) .andExpect(jsonPath("$.[0].size", equalTo(random.length))) .andExpect(jsonPath("$.[0].hashes.md5", equalTo(artifact.getMd5Hash()))) @@ -575,11 +575,11 @@ public void invalidRequestsOnArtifactResource() throws Exception { mvc.perform(get("/rest/v1/softwaremodules/1234567890/artifacts")).andDo(MockMvcResultPrinter.print()) .andExpect(status().isNotFound()); - mvc.perform(fileUpload("/rest/v1/softwaremodules/1234567890/artifacts").file(file)) + mvc.perform(multipart("/rest/v1/softwaremodules/1234567890/artifacts").file(file)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound()); // bad request - no content - mvc.perform(fileUpload("/rest/v1/softwaremodules/{smId}/artifacts", sm.getId())) + mvc.perform(multipart("/rest/v1/softwaremodules/{smId}/artifacts", sm.getId())) .andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()); // not allowed methods @@ -689,7 +689,7 @@ public void getSoftwareModules() throws Exception { mvc.perform(get("/rest/v1/softwaremodules").accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$.content.[?(@.id==" + os.getId() + ")].name", contains(os.getName()))) .andExpect(jsonPath("$.content.[?(@.id==" + os.getId() + ")].version", contains(os.getVersion()))) .andExpect( @@ -727,7 +727,7 @@ public void getSoftwareModulesWithFilterParameters() throws Exception { // only by name, only one exists per name mvc.perform(get("/rest/v1/softwaremodules?q=name==" + os1.getName()).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$.content.[?(@.id==" + os1.getId() + ")].name", contains(os1.getName()))) .andExpect(jsonPath("$.content.[?(@.id==" + os1.getId() + ")].version", contains(os1.getVersion()))) .andExpect(jsonPath("$.content.[?(@.id==" + os1.getId() + ")].description", @@ -739,7 +739,7 @@ public void getSoftwareModulesWithFilterParameters() throws Exception { // 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()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .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()))) .andExpect(jsonPath("$.content.[?(@.id==" + app1.getId() + ")].description", @@ -761,7 +761,7 @@ public void getSoftwareModulesWithFilterParameters() throws Exception { "/rest/v1/softwaremodules?q=type==" + Constants.SMT_DEFAULT_APP_KEY + ";version==" + app1.getVersion()) .accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .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()))) .andExpect(jsonPath("$.content.[?(@.id==" + app1.getId() + ")].description", @@ -796,7 +796,7 @@ public void getSoftwareModule() throws Exception { mvc.perform(get("/rest/v1/softwaremodules/{smId}", os.getId()).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$.name", equalTo(os.getName()))) .andExpect(jsonPath("$.version", equalTo(os.getVersion()))) .andExpect(jsonPath("$.description", equalTo(os.getDescription()))) @@ -830,10 +830,10 @@ public void createSoftwareModules() throws Exception { final long current = System.currentTimeMillis(); final MvcResult mvcResult = mvc - .perform(post("/rest/v1/softwaremodules/").accept(MediaType.APPLICATION_JSON_UTF8_VALUE) + .perform(post("/rest/v1/softwaremodules/").accept(MediaType.APPLICATION_JSON_VALUE) .content(JsonBuilder.softwareModules(modules)).contentType(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("[0].name", equalTo("name1"))) .andExpect(jsonPath("[0].version", equalTo("version1"))) .andExpect(jsonPath("[0].description", equalTo("description1"))) @@ -976,7 +976,7 @@ public void createMetadata() throws Exception { 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()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("[0]key", equalTo(knownKey1))).andExpect(jsonPath("[0]value", equalTo(knownValue1))) .andExpect(jsonPath("[0]targetVisible", equalTo(false))) .andExpect(jsonPath("[1]key", equalTo(knownKey2))).andExpect(jsonPath("[1]value", equalTo(knownValue2))) @@ -1028,7 +1028,7 @@ public void updateMetadata() throws Exception { mvc.perform(put("/rest/v1/softwaremodules/{swId}/metadata/{key}", sm.getId(), knownKey) .accept(MediaType.APPLICATION_JSON).contentType(MediaType.APPLICATION_JSON) .content(jsonObject.toString())).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("key", equalTo(knownKey))).andExpect(jsonPath("value", equalTo(updateValue))); final SoftwareModuleMetadata assertDS = softwareModuleManagement diff --git a/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeResourceTest.java b/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeResourceTest.java index 64ba7b9189..69ae315dfd 100644 --- a/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeResourceTest.java +++ b/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeResourceTest.java @@ -59,7 +59,7 @@ public void getSoftwareModuleTypes() throws Exception { mvc.perform(get("/rest/v1/softwaremoduletypes").accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$.content.[?(@.key=='" + osType.getKey() + "')].name", contains(osType.getName()))) .andExpect(jsonPath("$.content.[?(@.key=='" + osType.getKey() + "')].description", contains(osType.getDescription()))) @@ -109,7 +109,7 @@ public void getSoftwareModuleTypesSortedByMaxAssignments() throws Exception { mvc.perform(get("/rest/v1/softwaremoduletypes").accept(MediaType.APPLICATION_JSON) .param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "MAXASSIGNMENTS:DESC")) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$.content.[1].id", equalTo(testType.getId().intValue()))) .andExpect(jsonPath("$.content.[1].name", equalTo("TestName123"))) .andExpect(jsonPath("$.content.[1].description", equalTo("Desc1234"))) @@ -125,7 +125,7 @@ public void getSoftwareModuleTypesSortedByMaxAssignments() throws Exception { mvc.perform(get("/rest/v1/softwaremoduletypes").accept(MediaType.APPLICATION_JSON) .param(MgmtRestConstants.REQUEST_PARAMETER_SORTING, "MAXASSIGNMENTS:ASC")) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$.content.[2].id", equalTo(testType.getId().intValue()))) .andExpect(jsonPath("$.content.[2].name", equalTo("TestName123"))) .andExpect(jsonPath("$.content.[2].description", equalTo("Desc1234"))) @@ -176,7 +176,7 @@ public void createSoftwareModuleTypes() throws Exception { .perform(post("/rest/v1/softwaremoduletypes/").content(JsonBuilder.softwareModuleTypes(types)) .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("[0].name", equalTo("TestName1"))).andExpect(jsonPath("[0].key", equalTo("test1"))) .andExpect(jsonPath("[0].description", equalTo("Desc1"))) .andExpect(jsonPath("[0].createdBy", equalTo("uploadTester"))) @@ -216,7 +216,7 @@ public void getSoftwareModuleType() throws Exception { mvc.perform(get("/rest/v1/softwaremoduletypes/{smtId}", testType.getId()).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("$.name", equalTo("TestName123"))) .andExpect(jsonPath("$.description", equalTo("Desc1234"))) .andExpect(jsonPath("$.maxAssignments", equalTo(5))) diff --git a/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResourceTest.java b/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResourceTest.java index cd396f04f2..8682046d52 100644 --- a/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResourceTest.java +++ b/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResourceTest.java @@ -782,7 +782,7 @@ public void createTargetsListReturnsSuccessful() throws Exception { .perform(post("/rest/v1/targets/").content(JsonBuilder.targets(targets, true)) .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("[0].name", equalTo("testname1"))) .andExpect(jsonPath("[0].controllerId", equalTo("id1"))) .andExpect(jsonPath("[0].description", equalTo("testid1"))) @@ -1727,7 +1727,7 @@ public void createMetadata() throws Exception { 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()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("[0]key", equalTo(knownKey1))).andExpect(jsonPath("[0]value", equalTo(knownValue1))) .andExpect(jsonPath("[1]key", equalTo(knownKey2))) .andExpect(jsonPath("[1]value", equalTo(knownValue2))); @@ -1774,7 +1774,7 @@ public void updateMetadata() throws Exception { 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()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(jsonPath("key", equalTo(knownKey))).andExpect(jsonPath("value", equalTo(updateValue))); final TargetMetadata updatedTargetMetadata = targetManagement diff --git a/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTagResourceTest.java b/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTagResourceTest.java index c155cc1bb8..2c8dc1c9b0 100644 --- a/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTagResourceTest.java +++ b/hawkbit-rest/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTagResourceTest.java @@ -65,7 +65,7 @@ public void getTargetTags() throws Exception { mvc.perform(get(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(applyTagMatcherOnPagedResult(assigned)).andExpect(applyTagMatcherOnPagedResult(unassigned)) .andExpect(applySelfLinkMatcherOnPagedResult(assigned, TARGETTAGS_ROOT + assigned.getId())) .andExpect(applySelfLinkMatcherOnPagedResult(unassigned, TARGETTAGS_ROOT + unassigned.getId())) @@ -84,7 +84,7 @@ public void getTargetTag() throws Exception { mvc.perform(get(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/" + assigned.getId()) .accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)) .andExpect(applyTagMatcherOnSingleResult(assigned)) .andExpect(applySelfLinkMatcherOnSingleResult(TARGETTAGS_ROOT + assigned.getId())) .andExpect(jsonPath("_links.assignedTargets.href", @@ -106,7 +106,7 @@ public void createTargetTags() throws Exception { .content(JsonBuilder.tags(Arrays.asList(tagOne, tagTwo))) .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)); + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)); final Tag createdOne = targetTagManagement.findByRsql(PAGE, "name==thetest1").getContent().get(0); assertThat(createdOne.getName()).isEqualTo(tagOne.getName()); @@ -136,7 +136,7 @@ public void updateTargetTag() throws Exception { .content(JsonBuilder.tag(update)).contentType(MediaType.APPLICATION_JSON) .accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)); + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)); final Tag updated = targetTagManagement.findByRsql(PAGE, "name==updatedName").getContent().get(0); assertThat(updated.getName()).isEqualTo(update.getName()); @@ -258,7 +258,7 @@ private ResultActions toggle(final TargetTag tag, final List targets) th targets.stream().map(Target::getControllerId).collect(Collectors.toList()))) .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)); + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)); } @Test @@ -276,7 +276,7 @@ public void assignTargets() throws Exception { targets.stream().map(Target::getControllerId).collect(Collectors.toList()))) .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)); + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)); final List updated = targetManagement.findByTag(PAGE, tag.getId()).getContent(); diff --git a/hawkbit-rest/hawkbit-mgmt-resource/src/test/resources/mgmt-test.properties b/hawkbit-rest/hawkbit-mgmt-resource/src/test/resources/mgmt-test.properties index 96959921db..c69732803a 100644 --- a/hawkbit-rest/hawkbit-mgmt-resource/src/test/resources/mgmt-test.properties +++ b/hawkbit-rest/hawkbit-mgmt-resource/src/test/resources/mgmt-test.properties @@ -10,3 +10,4 @@ # Logging START - activate to see request/response details #logging.level.org.eclipse.hawkbit.rest.util.MockMvcResultPrinter=DEBUG # Logging END + 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 def9fe8e82..a95c209bb8 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 @@ -13,7 +13,7 @@ import java.util.List; import java.util.ListIterator; -import org.springframework.hateoas.ResourceSupport; +import org.springframework.hateoas.RepresentationModel; /** * List that extends ResourceSupport to ensure that links in content are in HAL @@ -22,7 +22,7 @@ * @param * of the response content */ -public class ResponseList extends ResourceSupport implements List { +public class ResponseList extends RepresentationModel> implements List { private final List content; 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 3801a02735..d95273c5d3 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 @@ -23,6 +23,7 @@ import org.springframework.test.web.servlet.setup.DefaultMockMvcBuilder; import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.web.context.WebApplicationContext; +import org.springframework.web.filter.CharacterEncodingFilter; /** * Abstract Test for Rest tests. @@ -38,6 +39,9 @@ public abstract class AbstractRestIntegrationTest extends AbstractIntegrationTes @Autowired private FilterHttpResponse filterHttpResponse; + @Autowired + private CharacterEncodingFilter characterEncodingFilter; + @Autowired protected WebApplicationContext webApplicationContext; @@ -51,6 +55,8 @@ public void before() throws Exception { protected DefaultMockMvcBuilder createMvcWebAppContext(final WebApplicationContext context) { final DefaultMockMvcBuilder createMvcWebAppContext = MockMvcBuilders.webAppContextSetup(context); + // CharacterEncodingFilter is needed for the encoding properties to be imported properly + createMvcWebAppContext.addFilter(characterEncodingFilter); createMvcWebAppContext.addFilter( new ExcludePathAwareShallowETagFilter("/rest/v1/softwaremodules/{smId}/artifacts/{artId}/download", "/{tenant}/controller/v1/{controllerId}/softwaremodules/{softwareModuleId}/artifacts/**", 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 eaf38be6d0..ee9a23c076 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 @@ -26,7 +26,7 @@ import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import io.qameta.allure.Feature; import io.qameta.allure.Story; diff --git a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/ddi/documentation/RootControllerDocumentationTest.java b/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/ddi/documentation/RootControllerDocumentationTest.java index 0020369961..52805e95e4 100644 --- a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/ddi/documentation/RootControllerDocumentationTest.java +++ b/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/ddi/documentation/RootControllerDocumentationTest.java @@ -77,7 +77,7 @@ public void getControllerBaseWithOpenDeplyoment() throws Exception { mockMvc.perform(get(DdiRestConstants.BASE_V1_REQUEST_MAPPING + "/{controllerId}", tenantAware.getCurrentTenant(), target.getControllerId()).accept(MediaTypes.HAL_JSON_VALUE)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON_UTF8)) + .andExpect(content().contentType(MediaTypes.HAL_JSON)) .andDo(this.document.document( pathParameters(parameterWithName("tenant").description(ApiModelPropertiesGeneric.TENANT), parameterWithName("controllerId").description(DdiApiModelProperties.CONTROLLER_ID)), @@ -106,7 +106,7 @@ public void getControllerBaseWithOpenDeploymentCancellation() throws Exception { mockMvc.perform(get(DdiRestConstants.BASE_V1_REQUEST_MAPPING + "/{controllerId}", tenantAware.getCurrentTenant(), target.getControllerId()).accept(MediaTypes.HAL_JSON_VALUE)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON_UTF8)) + .andExpect(content().contentType(MediaTypes.HAL_JSON)) .andDo(this.document.document( pathParameters(parameterWithName("tenant").description(ApiModelPropertiesGeneric.TENANT), parameterWithName("controllerId").description(DdiApiModelProperties.CONTROLLER_ID)), @@ -144,7 +144,7 @@ public void getControllerCancelAction() throws Exception { + "/{actionId}", tenantAware.getCurrentTenant(), target.getControllerId(), cancelAction.getId()) .accept(MediaTypes.HAL_JSON_VALUE)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON_UTF8)) + .andExpect(content().contentType(MediaTypes.HAL_JSON)) .andDo(this.document.document( pathParameters(parameterWithName("tenant").description(ApiModelPropertiesGeneric.TENANT), parameterWithName("controllerId").description(DdiApiModelProperties.CONTROLLER_ID), @@ -264,7 +264,7 @@ public void getControllerBasedeploymentAction() throws Exception { + "/{actionId}?actionHistory=10", tenantAware.getCurrentTenant(), target.getControllerId(), actionId).accept(MediaTypes.HAL_JSON_VALUE)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON_UTF8)) + .andExpect(content().contentType(MediaTypes.HAL_JSON)) .andDo(this.document.document( pathParameters(parameterWithName("tenant").description(ApiModelPropertiesGeneric.TENANT), parameterWithName("controllerId").description(DdiApiModelProperties.CONTROLLER_ID), @@ -337,7 +337,7 @@ public void getControllerBasedeploymentActionWithMaintenanceWindow() throws Exce + "/{actionId}?actionHistory=10", tenantAware.getCurrentTenant(), target.getControllerId(), actionId).accept(MediaTypes.HAL_JSON_VALUE)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON_UTF8)) + .andExpect(content().contentType(MediaTypes.HAL_JSON)) .andDo(this.document.document( pathParameters(parameterWithName("tenant").description(ApiModelPropertiesGeneric.TENANT), parameterWithName("controllerId").description(DdiApiModelProperties.CONTROLLER_ID), @@ -422,7 +422,7 @@ public void getSoftwareModulesArtifacts() throws Exception { tenantAware.getCurrentTenant(), target.getControllerId(), module.getId()) .accept(MediaTypes.HAL_JSON_VALUE)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON_UTF8)) + .andExpect(content().contentType(MediaTypes.HAL_JSON)) .andDo(this.document.document( pathParameters(parameterWithName("tenant").description(ApiModelPropertiesGeneric.TENANT), parameterWithName("controllerId").description(DdiApiModelProperties.CONTROLLER_ID), diff --git a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/DistributionSetTagResourceDocumentationTest.java b/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/DistributionSetTagResourceDocumentationTest.java index 459224053e..27b48dcb0c 100644 --- a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/DistributionSetTagResourceDocumentationTest.java +++ b/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/DistributionSetTagResourceDocumentationTest.java @@ -107,7 +107,7 @@ public void createDistributionSetTags() throws Exception { final String json = mapper.writeValueAsString(Arrays.asList(bodyPut)); this.mockMvc .perform(post(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING).content(json) - .contentType(MediaType.APPLICATION_JSON_UTF8)) + .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isCreated()).andDo(MockMvcResultPrinter.print()) .andDo(this.document.document(getRequestFieldsTag(true), getResponseFieldsTag(true))); } @@ -123,7 +123,7 @@ public void updateDistributionSetTag() throws Exception { this.mockMvc .perform( put(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/{distributionsetTagId}", tagId) - .content(json).contentType(MediaType.APPLICATION_JSON_UTF8)) + .content(json).contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) .andDo(this.document.document( pathParameters(parameterWithName("distributionsetTagId") @@ -146,7 +146,7 @@ public void deleteDistributionSetTag() throws Exception { final Long tagId = createDistributionSetTagId(); this.mockMvc .perform(delete(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/{distributionsetTagId}", - tagId).contentType(MediaType.APPLICATION_JSON_UTF8)) + tagId).contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) .andDo(this.document.document(pathParameters( parameterWithName("distributionsetTagId").description(ApiModelPropertiesGeneric.ITEM_ID)))); @@ -162,7 +162,7 @@ public void getAssignedDistributionSets() throws Exception { this.mockMvc .perform(get(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + MgmtRestConstants.DISTRIBUTIONSET_TAG_DISTRIBUTIONSETS_REQUEST_MAPPING, tag.getId()) - .contentType(MediaType.APPLICATION_JSON_UTF8)) + .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) .andDo(this.document.document( pathParameters(parameterWithName("distributionsetTagId") @@ -187,7 +187,7 @@ public void toggleTagAssignment() throws Exception { this.mockMvc .perform(post(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + MgmtRestConstants.DISTRIBUTIONSET_TAG_DISTRIBUTIONSETS_REQUEST_MAPPING - + "/toggleTagAssignment", tagId).content(json).contentType(MediaType.APPLICATION_JSON_UTF8)) + + "/toggleTagAssignment", tagId).content(json).contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) .andDo(this.document.document( pathParameters(parameterWithName("distributionsetTagId") @@ -210,7 +210,7 @@ public void assignDistributionSets() throws Exception { this.mockMvc .perform(post(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + MgmtRestConstants.DISTRIBUTIONSET_TAG_DISTRIBUTIONSETS_REQUEST_MAPPING, tagId).content(json) - .contentType(MediaType.APPLICATION_JSON_UTF8)) + .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) .andDo(this.document.document( pathParameters(parameterWithName("distributionsetTagId") @@ -227,7 +227,7 @@ public void unassignDistributionSet() throws Exception { .perform(delete(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + MgmtRestConstants.DISTRIBUTIONSET_TAG_DISTRIBUTIONSETS_REQUEST_MAPPING + "/{distributionsetId}", tagId, distributionSet.getId()) - .contentType(MediaType.APPLICATION_JSON_UTF8)) + .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) .andDo(this.document.document(pathParameters( parameterWithName("distributionsetTagId").description(ApiModelPropertiesGeneric.ITEM_ID), diff --git a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/DistributionSetTypesDocumentationTest.java b/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/DistributionSetTypesDocumentationTest.java index b92635d44b..6d16c4149f 100644 --- a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/DistributionSetTypesDocumentationTest.java +++ b/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/DistributionSetTypesDocumentationTest.java @@ -71,7 +71,7 @@ public void getDistributionSetTypes() throws Exception { mockMvc.perform( get(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$.total", equalTo(4))) .andDo(this.document.document(responseFields( fieldWithPath("size").type(JsonFieldType.NUMBER).description(ApiModelPropertiesGeneric.SIZE), @@ -99,7 +99,7 @@ public void getDistributionSetTypesWithParameters() throws Exception { mockMvc.perform(get(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING).accept(MediaType.APPLICATION_JSON) .param("offset", "1").param("limit", "2").param("sort", "name:DESC").param("q", "name==a*")) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andDo(this.document.document(getFilterRequestParamter())); } @@ -117,7 +117,7 @@ public void postDistributionSetTypes() throws Exception { mockMvc.perform(post(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING) .content(JsonBuilder.distributionSetTypesCreateValidFieldsOnly(types)) - .contentType(MediaType.APPLICATION_JSON_UTF8).accept(MediaType.APPLICATION_JSON)) + .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated()).andDo( this.document.document( requestFields( @@ -213,7 +213,7 @@ public void putDistributionSetType() throws Exception { this.mockMvc .perform(put(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/{distributionSetTypeId}", - testType.getId()).content(body).contentType(MediaType.APPLICATION_JSON_UTF8)) + testType.getId()).content(body).contentType(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andDo(this.document.document( pathParameters(parameterWithName("distributionSetTypeId") @@ -249,7 +249,7 @@ public void getMandatoryModules() throws Exception { mockMvc.perform(get(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/{distributionSetTypeId}/mandatorymoduletypes", testType.getId()).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andDo(this.document.document( pathParameters(parameterWithName("distributionSetTypeId") @@ -281,7 +281,7 @@ public void postMandatoryModule() throws Exception { mockMvc.perform(post(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/{distributionSetTypeId}/mandatorymoduletypes", testType.getId()) - .content("{\"id\":" + osType.getId() + "}").contentType(MediaType.APPLICATION_JSON_UTF8)) + .content("{\"id\":" + osType.getId() + "}").contentType(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andDo(this.document.document( pathParameters(parameterWithName("distributionSetTypeId") @@ -299,7 +299,7 @@ public void deleteMandatoryModule() throws Exception { mockMvc.perform(delete( MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/{distributionSetTypeId}/mandatorymoduletypes/{softwareModuleTypeId}", - testType.getId(), osType.getId()).contentType(MediaType.APPLICATION_JSON_UTF8)) + testType.getId(), osType.getId()).contentType(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andDo(this.document.document(pathParameters( parameterWithName("distributionSetTypeId").description(ApiModelPropertiesGeneric.ITEM_ID), @@ -317,7 +317,7 @@ public void getMandatoryModule() throws Exception { mockMvc.perform(get( MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/{distributionSetTypeId}/mandatorymoduletypes/{softwareModuleTypeId}", - testType.getId(), osType.getId()).contentType(MediaType.APPLICATION_JSON_UTF8)) + testType.getId(), osType.getId()).contentType(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andDo(this.document.document(pathParameters( parameterWithName("distributionSetTypeId").description(ApiModelPropertiesGeneric.ITEM_ID), @@ -346,7 +346,7 @@ public void getOptionalModules() throws Exception { mockMvc.perform(get(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/{distributionSetTypeId}/optionalmoduletypes", testType.getId()).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andDo(this.document.document( pathParameters(parameterWithName("distributionSetTypeId") .description(ApiModelPropertiesGeneric.ITEM_ID)), @@ -375,7 +375,7 @@ public void postOptionalModule() throws Exception { entityFactory.distributionSetType().create().key("test1").name("TestName1").description("Desc1")); mockMvc.perform(post(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/{distributionSetTypeId}/optionalmoduletypes", testType.getId()) - .content("{\"id\":" + appType.getId() + "}").contentType(MediaType.APPLICATION_JSON_UTF8)) + .content("{\"id\":" + appType.getId() + "}").contentType(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andDo(this.document.document( pathParameters(parameterWithName("distributionSetTypeId") @@ -394,7 +394,7 @@ public void deleteOptionalModule() throws Exception { mockMvc.perform(delete( MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/{distributionSetTypeId}/optionalmoduletypes/{softwareModuleTypeId}", - testType.getId(), appType.getId()).contentType(MediaType.APPLICATION_JSON_UTF8)) + testType.getId(), appType.getId()).contentType(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andDo(this.document.document(pathParameters( parameterWithName("distributionSetTypeId").description(ApiModelPropertiesGeneric.ITEM_ID), @@ -411,7 +411,7 @@ public void getOptionalModule() throws Exception { mockMvc.perform(get( MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "/{distributionSetTypeId}/optionalmoduletypes/{softwareModuleTypeId}", - testType.getId(), appType.getId()).contentType(MediaType.APPLICATION_JSON_UTF8)) + testType.getId(), appType.getId()).contentType(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andDo(this.document.document(pathParameters( parameterWithName("distributionSetTypeId").description(ApiModelPropertiesGeneric.ITEM_ID), diff --git a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/DistributionSetsDocumentationTest.java b/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/DistributionSetsDocumentationTest.java index 97f50126af..bb8b6ed0cb 100644 --- a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/DistributionSetsDocumentationTest.java +++ b/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/DistributionSetsDocumentationTest.java @@ -74,7 +74,7 @@ public void getDistributionSet() throws Exception { mockMvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}", set.getId()) .accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andDo(this.document.document( pathParameters( parameterWithName("distributionSetId").description(ApiModelPropertiesGeneric.ITEM_ID)), @@ -88,7 +88,7 @@ public void getDistributionSets() throws Exception { mockMvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andDo(this.document.document(responseFields( fieldWithPath("total").description(ApiModelPropertiesGeneric.TOTAL_ELEMENTS), fieldWithPath("size").type(JsonFieldType.NUMBER).description(ApiModelPropertiesGeneric.SIZE), @@ -125,7 +125,7 @@ public void getDistributionSetsWithParameters() throws Exception { get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING).param("offset", "1").param("limit", "2") .param("sort", "version:DESC").param("q", "name==testDS*").accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andDo(this.document.document(getFilterRequestParamter())); } @@ -164,7 +164,7 @@ public void createDistributionSets() throws Exception { this.mockMvc .perform(post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/") .content(JsonBuilder.distributionSetsCreateValidFieldsOnly(sets)) - .contentType(MediaType.APPLICATION_JSON_UTF8)) + .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isCreated()).andDo(MockMvcResultPrinter.print()) .andDo(this.document.document( requestFields(requestFieldWithPath("[]name").description(ApiModelPropertiesGeneric.NAME), @@ -188,9 +188,9 @@ public void updateDistributionSet() throws Exception { mockMvc.perform(put(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}", set.getId()) .content(JsonBuilder.distributionSetUpdateValidFieldsOnly(update)) - .contentType(MediaType.APPLICATION_JSON_UTF8).accept(MediaType.APPLICATION_JSON)) + .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andDo(this.document.document( pathParameters( parameterWithName("distributionSetId").description(ApiModelPropertiesGeneric.ITEM_ID)), @@ -217,7 +217,7 @@ public void getAssignedTargets() throws Exception { get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/assignedTargets", set.getId()).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andDo(this.document.document( pathParameters( parameterWithName("distributionSetId").description(ApiModelPropertiesGeneric.ITEM_ID)), @@ -242,7 +242,7 @@ public void getAutoAssignTargetFilterQueries() throws Exception { mockMvc.perform(get( MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/autoAssignTargetFilters", set.getId()).accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) + .andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andDo(this.document.document( pathParameters( parameterWithName("distributionSetId").description(ApiModelPropertiesGeneric.ITEM_ID)), @@ -267,7 +267,7 @@ public void getAutoAssignTargetFilterQueriesWithParameters() throws Exception { .param("offset", "1").param("limit", "2").param("sort", "name:DESC").param("q", "name==*1") .accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andDo(this.document.document(requestParameters( parameterWithName("limit").attributes(key("type").value("query")) .description(ApiModelPropertiesGeneric.LIMIT), @@ -291,7 +291,7 @@ public void getAssignedTargetsWithParameters() throws Exception { .param("offset", "1").param("limit", "2").param("sort", "name:DESC") .param("q", "controllerId==target*").accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andDo(this.document.document(requestParameters( parameterWithName("limit").attributes(key("type").value("query")) .description(ApiModelPropertiesGeneric.LIMIT), @@ -317,7 +317,7 @@ public void getInstalledTargetsWithParameters() throws Exception { .param("offset", "1").param("limit", "2").param("sort", "name:DESC") .param("q", "controllerId==target*").accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andDo(this.document.document(requestParameters( parameterWithName("limit").attributes(key("type").value("query")) .description(ApiModelPropertiesGeneric.LIMIT), @@ -342,7 +342,7 @@ public void getInstalledTargets() throws Exception { get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/installedTargets", set.getId()).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andDo(this.document.document( pathParameters( parameterWithName("distributionSetId").description(ApiModelPropertiesGeneric.ITEM_ID)), @@ -376,7 +376,7 @@ public void createAssignedTarget() throws Exception { this.mockMvc .perform(post( MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/assignedTargets", - set.getId()).content(list.toString()).contentType(MediaType.APPLICATION_JSON_UTF8)) + set.getId()).content(list.toString()).contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) .andDo(this.document.document( pathParameters( @@ -432,7 +432,7 @@ public void assignSoftwareModules() throws Exception { // post assignment mockMvc.perform(post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/assignedSM", - disSet.getId()).contentType(MediaType.APPLICATION_JSON_UTF8).content(list.toString())) + disSet.getId()).contentType(MediaType.APPLICATION_JSON).content(list.toString())) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andDo(this.document.document( pathParameters( @@ -450,7 +450,7 @@ public void deleteAssignSoftwareModules() throws Exception { MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/assignedSM/{softwareModuleId}", set.getId(), set.findFirstModuleByType(osType).get().getId()) - .contentType(MediaType.APPLICATION_JSON_UTF8)) + .contentType(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andDo(this.document.document(pathParameters( parameterWithName("distributionSetId").description(ApiModelPropertiesGeneric.ITEM_ID), @@ -467,7 +467,7 @@ public void getAssignedSoftwareModules() throws Exception { // post assignment mockMvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/assignedSM", set.getId()).accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) + .andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andDo(this.document.document( pathParameters( parameterWithName("distributionSetId").description(ApiModelPropertiesGeneric.ITEM_ID)), @@ -501,7 +501,7 @@ public void getAssignedSoftwareModulesWithParameters() throws Exception { mockMvc.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()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andDo(this.document.document(requestParameters( parameterWithName("limit").attributes(key("type").value("query")) .description(ApiModelPropertiesGeneric.LIMIT), @@ -525,7 +525,7 @@ public void getMetadata() throws Exception { mockMvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/metadata", testDS.getId())).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON_UTF8)) + .andExpect(content().contentType(MediaTypes.HAL_JSON)) .andDo(this.document.document( pathParameters( parameterWithName("distributionSetId").description(ApiModelPropertiesGeneric.ITEM_ID)), @@ -554,7 +554,7 @@ public void getMetadataWithParameters() throws Exception { mockMvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{dsId}/metadata", testDS.getId()) .param("offset", "1").param("limit", "2").param("sort", "key:DESC").param("q", "key==known*")) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON_UTF8)) + .andExpect(content().contentType(MediaTypes.HAL_JSON)) .andDo(this.document.document( requestParameters( parameterWithName("limit").attributes(key("type").value("query")) @@ -610,7 +610,7 @@ public void updateMetadata() throws Exception { mockMvc.perform(put( MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/metadata/{metadatakey}", - testDS.getId(), knownKey).contentType(MediaType.APPLICATION_JSON_UTF8).content(jsonObject.toString())) + testDS.getId(), knownKey).contentType(MediaType.APPLICATION_JSON).content(jsonObject.toString())) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andDo(this.document.document( pathParameters( @@ -662,9 +662,9 @@ public void createMetadata() throws Exception { jsonArray.put(new JSONObject().put("key", knownKey2).put("value", knownValue2)); mockMvc.perform(post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/metadata", - testDS.getId()).contentType(MediaType.APPLICATION_JSON_UTF8).content(jsonArray.toString())) + testDS.getId()).contentType(MediaType.APPLICATION_JSON).content(jsonArray.toString())) .andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated()) - .andExpect(content().contentType(MediaTypes.HAL_JSON_UTF8)) + .andExpect(content().contentType(MediaTypes.HAL_JSON)) .andDo(this.document.document( pathParameters( parameterWithName("distributionSetId").description(ApiModelPropertiesGeneric.ITEM_ID)), diff --git a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/RolloutResourceDocumentationTest.java b/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/RolloutResourceDocumentationTest.java index ab4167224c..fb393cd515 100644 --- a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/RolloutResourceDocumentationTest.java +++ b/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/RolloutResourceDocumentationTest.java @@ -86,7 +86,7 @@ public void getRollouts() throws Exception { mockMvc.perform(get(MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING).accept(MediaTypes.HAL_JSON_VALUE)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON_UTF8)) + .andExpect(content().contentType(MediaTypes.HAL_JSON)) .andDo(this.document.document(getRolloutResponseFields(true, false, fieldWithPath("total").description(ApiModelPropertiesGeneric.TOTAL_ELEMENTS), fieldWithPath("size").type(JsonFieldType.NUMBER).description(ApiModelPropertiesGeneric.SIZE), @@ -102,7 +102,7 @@ public void getRolloutsWithParameters() throws Exception { mockMvc.perform(get(MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING).param("offset", "0").param("limit", "2") .param("sort", "id:DESC").param("q", "name==exampleRollout*").accept(MediaTypes.HAL_JSON_VALUE)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON_UTF8)) + .andExpect(content().contentType(MediaTypes.HAL_JSON)) .andDo(this.document.document(getFilterRequestParamter())); } @@ -167,7 +167,7 @@ public void getRollout() throws Exception { mockMvc.perform(get(MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}", rollout.getId()) .accept(MediaTypes.HAL_JSON_VALUE)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON_UTF8)) + .andExpect(content().contentType(MediaTypes.HAL_JSON)) .andDo(this.document.document(getRolloutResponseFields(false, true), pathParameters(parameterWithName("rolloutId").description(ApiModelPropertiesGeneric.ITEM_ID)))); } @@ -195,9 +195,9 @@ public void createRollout() throws Exception { post(MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING) .content(JsonBuilder.rollout(name, description, groupSize, dsId, targetFilter, rolloutGroupConditions, type)) - .contentType(MediaTypes.HAL_JSON_UTF8).accept(MediaTypes.HAL_JSON_VALUE)) + .contentType(MediaTypes.HAL_JSON).accept(MediaTypes.HAL_JSON_VALUE)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated()) - .andExpect(content().contentType(MediaTypes.HAL_JSON_UTF8)) + .andExpect(content().contentType(MediaTypes.HAL_JSON)) .andDo(this.document.document(requestFields( requestFieldWithPath("name").description(ApiModelPropertiesGeneric.NAME), requestFieldWithPathMandatoryInMultiAssignMode("weight").type(JsonFieldType.NUMBER) @@ -285,7 +285,7 @@ public void createRolloutWithGroupsDefinition() throws Exception { rolloutGroupConditions, rolloutGroups)) .contentType(MediaType.APPLICATION_JSON).accept(MediaTypes.HAL_JSON_VALUE)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated()) - .andExpect(content().contentType(MediaTypes.HAL_JSON_UTF8)) + .andExpect(content().contentType(MediaTypes.HAL_JSON)) .andDo(this.document.document( requestFields(requestFieldWithPath("name").description(ApiModelPropertiesGeneric.NAME), requestFieldWithPathMandatoryInMultiAssignMode("weight") @@ -448,7 +448,7 @@ public void getRolloutDeployGroups() throws Exception { mockMvc.perform(get(MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/deploygroups", rollout.getId()) .accept(MediaTypes.HAL_JSON_VALUE)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON_UTF8)) + .andExpect(content().contentType(MediaTypes.HAL_JSON)) .andDo(this.document.document( getRolloutDeployGroupResponseFields(true, false, fieldWithPath("total").description(ApiModelPropertiesGeneric.TOTAL_ELEMENTS), @@ -469,7 +469,7 @@ public void getRolloutDeployGroup() throws Exception { mockMvc.perform(get(MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/deploygroups/{deployGroupId}", rollout.getId(), firstRolloutGroup.getId()).accept(MediaTypes.HAL_JSON_VALUE)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON_UTF8)) + .andExpect(content().contentType(MediaTypes.HAL_JSON)) .andDo(this.document.document(getRolloutDeployGroupResponseFields(false, true), pathParameters(parameterWithName("rolloutId").description(ApiModelPropertiesGeneric.ITEM_ID), parameterWithName("deployGroupId").description(ApiModelPropertiesGeneric.ITEM_ID)))); @@ -557,7 +557,7 @@ public void getRolloutDeployGroupWithParameters() throws Exception { .param("sort", "id:DESC").param("q", "id==" + firstRolloutGroup.getId()) .accept(MediaTypes.HAL_JSON_VALUE)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON_UTF8)) + .andExpect(content().contentType(MediaTypes.HAL_JSON)) .andDo(this.document.document( pathParameters(parameterWithName("rolloutId").description(ApiModelPropertiesGeneric.ITEM_ID), parameterWithName("deployGroupId").description(ApiModelPropertiesGeneric.ITEM_ID)), @@ -576,7 +576,7 @@ public void getRolloutDeployGroupTargets() throws Exception { get(MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/deploygroups/{deployGroupId}/targets", rollout.getId(), firstRolloutGroup.getId()).accept(MediaTypes.HAL_JSON_VALUE)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON_UTF8)) + .andExpect(content().contentType(MediaTypes.HAL_JSON)) .andDo(this.document.document( pathParameters(parameterWithName("rolloutId").description(ApiModelPropertiesGeneric.ITEM_ID), parameterWithName("deployGroupId").description(ApiModelPropertiesGeneric.ITEM_ID)), @@ -626,7 +626,7 @@ public void getRolloutDeployGroupTargetsWithParameters() throws Exception { .param("sort", "name:ASC").param("q", "controllerId==exampleTarget0") .accept(MediaTypes.HAL_JSON_VALUE)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON_UTF8)) + .andExpect(content().contentType(MediaTypes.HAL_JSON)) .andDo(this.document.document( pathParameters(parameterWithName("rolloutId").description(ApiModelPropertiesGeneric.ITEM_ID), parameterWithName("deployGroupId").description(ApiModelPropertiesGeneric.ITEM_ID)), diff --git a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/SoftwaremoduleTypesDocumentationTest.java b/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/SoftwaremoduleTypesDocumentationTest.java index 55cc7c47e4..b41b9c6e17 100644 --- a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/SoftwaremoduleTypesDocumentationTest.java +++ b/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/SoftwaremoduleTypesDocumentationTest.java @@ -110,7 +110,7 @@ public void postSoftwareModuleTypes() throws Exception { this.mockMvc .perform(post(MgmtRestConstants.SOFTWAREMODULETYPE_V1_REQUEST_MAPPING) .content(JsonBuilder.softwareModuleTypesCreatableFieldsOnly(types)) - .contentType(MediaType.APPLICATION_JSON_UTF8).accept(MediaType.APPLICATION_JSON)) + .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andDo(this.document.document( requestFields( @@ -194,7 +194,7 @@ public void putSoftwareModuleType() throws Exception { this.mockMvc .perform(put(MgmtRestConstants.SOFTWAREMODULETYPE_V1_REQUEST_MAPPING + "/{softwareModuleTypeID}", - testType.getId()).content(body.toString()).contentType(MediaType.APPLICATION_JSON_UTF8)) + testType.getId()).content(body.toString()).contentType(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andDo(this.document.document( pathParameters(parameterWithName("softwareModuleTypeID") diff --git a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/SoftwaremodulesDocumentationTest.java b/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/SoftwaremodulesDocumentationTest.java index 778a1ce7e0..099ac87f1f 100644 --- a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/SoftwaremodulesDocumentationTest.java +++ b/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/SoftwaremodulesDocumentationTest.java @@ -78,7 +78,7 @@ public void getSoftwareModules() throws Exception { .update(entityFactory.softwareModule().update(sm2.getId()).description("a description")); mockMvc.perform(get(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING)).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isOk()).andExpect(content().contentType(MediaTypes.HAL_JSON_UTF8)) + .andExpect(status().isOk()).andExpect(content().contentType(MediaTypes.HAL_JSON)) .andDo(this.document.document(responseFields( fieldWithPath("total").description(ApiModelPropertiesGeneric.TOTAL_ELEMENTS), fieldWithPath("size").type(JsonFieldType.NUMBER).description(ApiModelPropertiesGeneric.SIZE), @@ -114,7 +114,7 @@ public void getSoftwareModulesWithParameters() throws Exception { .param("limit", "2").param("sort", "version:DESC").param("q", "name==SM*")) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON_UTF8)) + .andExpect(content().contentType(MediaTypes.HAL_JSON)) .andDo(this.document.document(getFilterRequestParamter())); } @@ -130,9 +130,9 @@ public void postSoftwareModules() throws Exception { final List modules = Arrays.asList(os, ah); mockMvc.perform(post(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING) - .content(JsonBuilder.softwareModulesCreatableFieldsOnly(modules)).contentType(MediaTypes.HAL_JSON_UTF8)) + .content(JsonBuilder.softwareModulesCreatableFieldsOnly(modules)).contentType(MediaTypes.HAL_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated()) - .andExpect(content().contentType(MediaTypes.HAL_JSON_UTF8)) + .andExpect(content().contentType(MediaTypes.HAL_JSON)) .andDo(this.document.document( requestFields(requestFieldWithPath("[]name").description(ApiModelPropertiesGeneric.NAME), optionalRequestFieldWithPath("[]description") @@ -179,7 +179,7 @@ public void getSoftwareModule() throws Exception { mockMvc.perform(get(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}", sm.getId())) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON_UTF8)) + .andExpect(content().contentType(MediaTypes.HAL_JSON)) .andDo(this.document.document( pathParameters( parameterWithName("softwareModuleId").description(ApiModelPropertiesGeneric.ITEM_ID)), @@ -211,9 +211,9 @@ public void putSoftwareModule() throws Exception { .vendor("another Vendor").description("a new description").type(Constants.SMT_DEFAULT_OS_KEY).build(); mockMvc.perform(put(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}", sm.getId()) - .content(JsonBuilder.softwareModuleUpdatableFieldsOnly(update)).contentType(MediaTypes.HAL_JSON_UTF8)) + .content(JsonBuilder.softwareModuleUpdatableFieldsOnly(update)).contentType(MediaTypes.HAL_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON_UTF8)) + .andExpect(content().contentType(MediaTypes.HAL_JSON)) .andDo(this.document.document( pathParameters( parameterWithName("softwareModuleId").description(ApiModelPropertiesGeneric.ITEM_ID)), @@ -251,7 +251,7 @@ public void getArtifacts() throws Exception { mockMvc.perform( get(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/artifacts", sm.getId())) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON_UTF8)) + .andExpect(content().contentType(MediaTypes.HAL_JSON)) .andDo(this.document.document( pathParameters( parameterWithName("softwareModuleId").description(ApiModelPropertiesGeneric.ITEM_ID)), @@ -282,11 +282,9 @@ public void postArtifact() throws Exception { final byte random[] = RandomStringUtils.random(5).getBytes(); final MockMultipartFile file = new MockMultipartFile("file", "origFilename", null, random); - mockMvc.perform( - fileUpload(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/artifacts", - sm.getId()).file(file)) + mockMvc.perform(fileUpload(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/artifacts", sm.getId()).file(file)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated()) - .andExpect(content().contentType(MediaTypes.HAL_JSON_UTF8)) + .andExpect(content().contentType(MediaTypes.HAL_JSON)) .andDo(this.document.document( pathParameters( parameterWithName("softwareModuleId").description(ApiModelPropertiesGeneric.ITEM_ID)), @@ -318,12 +316,11 @@ public void postArtifactWithParameters() throws Exception { final byte random[] = RandomStringUtils.random(5).getBytes(); final MockMultipartFile file = new MockMultipartFile("file", "origFilename", null, random); - mockMvc.perform( - fileUpload(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/artifacts", + mockMvc.perform(fileUpload(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/artifacts", sm.getId()).file(file).param("filename", "filename").param("file", "s") .param("md5sum", "md5sum").param("sha1sum", "sha1sum")) .andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andDo(this.document.document(requestParameters( parameterWithName("filename").description(MgmtApiModelProperties.ARTIFACT_PROVIDED_FILENAME), parameterWithName("file").description(MgmtApiModelProperties.ARTIFACT_PROVIDED_FILE), @@ -365,7 +362,7 @@ public void getArtifact() throws Exception { get(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/artifacts/{artifactId}", sm.getId(), artifact.getId())) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON_UTF8)) + .andExpect(content().contentType(MediaTypes.HAL_JSON)) .andDo(this.document.document( pathParameters( parameterWithName("softwareModuleId").description(ApiModelPropertiesGeneric.ITEM_ID), @@ -424,7 +421,7 @@ public void getMetadata() throws Exception { mockMvc.perform(get(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/metadata", module.getId())).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON_UTF8)) + .andExpect(content().contentType(MediaTypes.HAL_JSON)) .andDo(this.document.document( pathParameters( parameterWithName("softwareModuleId").description(ApiModelPropertiesGeneric.ITEM_ID)), @@ -456,7 +453,7 @@ public void getMetadataWithParameters() throws Exception { module.getId()).param("offset", "1").param("limit", "2").param("sort", "key:DESC").param("q", "key==known*")) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON_UTF8)) + .andExpect(content().contentType(MediaTypes.HAL_JSON)) .andDo(this.document.document( pathParameters( parameterWithName("softwareModuleId").description(ApiModelPropertiesGeneric.ITEM_ID)), @@ -485,9 +482,9 @@ public void postMetadata() throws Exception { jsonArray.put(new JSONObject().put("key", knownKey2).put("value", knownValue2).put("targetVisible", true)); mockMvc.perform(post(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/metadata", - module.getId()).contentType(MediaTypes.HAL_JSON_UTF8).content(jsonArray.toString())) + module.getId()).contentType(MediaTypes.HAL_JSON).content(jsonArray.toString())) .andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated()) - .andExpect(content().contentType(MediaTypes.HAL_JSON_UTF8)) + .andExpect(content().contentType(MediaTypes.HAL_JSON)) .andDo(this.document.document( pathParameters( parameterWithName("softwareModuleId").description(ApiModelPropertiesGeneric.ITEM_ID)), @@ -569,7 +566,7 @@ public void putMetadata() throws Exception { mockMvc.perform( put(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING + "/{softwareModuleId}/metadata/{metadataKey}", - module.getId(), knownKey).contentType(MediaTypes.HAL_JSON_UTF8).content(jsonObject.toString())) + module.getId(), knownKey).contentType(MediaTypes.HAL_JSON).content(jsonObject.toString())) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andDo(this.document.document( pathParameters(parameterWithName("softwareModuleId") diff --git a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/TargetResourceDocumentationTest.java b/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/TargetResourceDocumentationTest.java index 937e916dee..e93fdb0083 100644 --- a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/TargetResourceDocumentationTest.java +++ b/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/TargetResourceDocumentationTest.java @@ -124,7 +124,7 @@ public void postTargets() throws Exception { final String target = createTargetJsonForPostRequest("123456", "controllerId", "test"); mockMvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING) - .contentType(MediaType.APPLICATION_JSON_UTF8).content(target)).andExpect(status().isCreated()) + .contentType(MediaType.APPLICATION_JSON).content(target)).andExpect(status().isCreated()) .andDo(MockMvcResultPrinter.print()) .andDo(this.document.document(requestFields( requestFieldWithPath("[]controllerId").description(ApiModelPropertiesGeneric.ITEM_ID), @@ -183,7 +183,7 @@ public void putTarget() throws Exception { final String targetAsJson = createJsonTarget(targetId, "newTargetName", "I've been updated"); mockMvc.perform(put(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}", target.getControllerId()) - .contentType(MediaType.APPLICATION_JSON_UTF8).content(targetAsJson)).andExpect(status().isOk()) + .contentType(MediaType.APPLICATION_JSON).content(targetAsJson)).andExpect(status().isOk()) .andDo(MockMvcResultPrinter.print()) .andDo(this.document.document( pathParameters(parameterWithName("targetId").description(ApiModelPropertiesGeneric.ITEM_ID)), @@ -418,7 +418,7 @@ public void switchActionToForced() throws Exception { mockMvc.perform( put(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/" + MgmtRestConstants.TARGET_V1_ACTIONS + "/{actionId}", targetId, actionId).content(this.objectMapper.writeValueAsString(body)) - .contentType(MediaType.APPLICATION_JSON_UTF8)) + .contentType(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andDo(this.document.document( pathParameters(parameterWithName("targetId").description(ApiModelPropertiesGeneric.ITEM_ID), @@ -518,7 +518,7 @@ public void postAssignDistributionSetToTarget() throws Exception { mockMvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/" + MgmtRestConstants.TARGET_V1_ASSIGNED_DISTRIBUTION_SET, targetId).content(body) - .contentType(MediaType.APPLICATION_JSON_UTF8)) + .contentType(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andDo(this.document.document( pathParameters(parameterWithName("targetId").description(ApiModelPropertiesGeneric.ITEM_ID)), @@ -562,7 +562,7 @@ public void postAssignDistributionSetsToTarget() throws Exception { enableMultiAssignments(); mockMvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/" + MgmtRestConstants.TARGET_V1_ASSIGNED_DISTRIBUTION_SET, targetId).content(body.toString()) - .contentType(MediaType.APPLICATION_JSON_UTF8)) + .contentType(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andDo(this.document.document( pathParameters(parameterWithName("targetId").description(ApiModelPropertiesGeneric.ITEM_ID)), @@ -653,7 +653,7 @@ public void getMetadata() throws Exception { mockMvc.perform( get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/metadata", testTarget.getControllerId())) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON_UTF8)) + .andExpect(content().contentType(MediaTypes.HAL_JSON)) .andDo(this.document.document( pathParameters(parameterWithName("targetId").description(ApiModelPropertiesGeneric.ITEM_ID)), responseFields(fieldWithPath("total").description(ApiModelPropertiesGeneric.TOTAL_ELEMENTS), @@ -682,7 +682,7 @@ public void getMetadataWithParameters() throws Exception { get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/metadata", testTarget.getControllerId()) .param("offset", "1").param("limit", "2").param("sort", "key:DESC").param("q", "key==known*")) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(content().contentType(MediaTypes.HAL_JSON_UTF8)) + .andExpect(content().contentType(MediaTypes.HAL_JSON)) .andDo(this.document.document( requestParameters( parameterWithName("limit").attributes(key("type").value("query")) @@ -736,7 +736,7 @@ public void updateMetadata() throws Exception { mockMvc.perform(put(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/metadata/{metadatakey}", testTarget.getControllerId(), knownKey) - .contentType(MediaType.APPLICATION_JSON_UTF8).content(jsonObject.toString())) + .contentType(MediaType.APPLICATION_JSON).content(jsonObject.toString())) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andDo(this.document.document( pathParameters(parameterWithName("targetId").description(ApiModelPropertiesGeneric.ITEM_ID), @@ -786,9 +786,9 @@ public void createMetadata() throws Exception { mockMvc.perform( post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/metadata", testTarget.getControllerId()) - .contentType(MediaType.APPLICATION_JSON_UTF8).content(jsonArray.toString())) + .contentType(MediaType.APPLICATION_JSON).content(jsonArray.toString())) .andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated()) - .andExpect(content().contentType(MediaTypes.HAL_JSON_UTF8)) + .andExpect(content().contentType(MediaTypes.HAL_JSON)) .andDo(this.document.document( pathParameters(parameterWithName("targetId").description(ApiModelPropertiesGeneric.ITEM_ID)), requestFields(requestFieldWithPath("[]key").description(MgmtApiModelProperties.META_DATA_KEY), diff --git a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/TargetTagResourceDocumentationTest.java b/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/TargetTagResourceDocumentationTest.java index c0a0f5cea0..ea444e8233 100644 --- a/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/TargetTagResourceDocumentationTest.java +++ b/hawkbit-rest/hawkbit-rest-docs/src/test/java/org/eclipse/hawkbit/rest/mgmt/documentation/TargetTagResourceDocumentationTest.java @@ -110,7 +110,7 @@ public void createTargetTags() throws Exception { final String json = mapper.writeValueAsString(Arrays.asList(bodyPut)); this.mockMvc .perform(post(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING).content(json) - .contentType(MediaType.APPLICATION_JSON_UTF8)) + .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isCreated()).andDo(MockMvcResultPrinter.print()) .andDo(this.document.document(getRequestFieldsTargetTag(true), getResponseFieldTargetTag(true))); } @@ -128,7 +128,7 @@ public void updateTagretTag() throws Exception { this.mockMvc .perform(put(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/{targetTagId}", tagId).content(json) - .contentType(MediaType.APPLICATION_JSON_UTF8)) + .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) .andDo(this.document.document( pathParameters(parameterWithName("targetTagId").description(ApiModelPropertiesGeneric.ITEM_ID)), @@ -142,7 +142,7 @@ public void deleteTargetTag() throws Exception { final Long tagId = createTargetTagId(); this.mockMvc .perform(delete(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/{targetTagId}", tagId) - .contentType(MediaType.APPLICATION_JSON_UTF8)) + .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) .andDo(this.document.document(pathParameters( parameterWithName("targetTagId").description(ApiModelPropertiesGeneric.ITEM_ID)))); @@ -159,7 +159,7 @@ public void getAssignedTargets() throws Exception { this.mockMvc .perform(get(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + MgmtRestConstants.TARGET_TAG_TARGETS_REQUEST_MAPPING, tag.getId()) - .contentType(MediaType.APPLICATION_JSON_UTF8)) + .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) .andDo(this.document.document( pathParameters(parameterWithName("targetTagId").description(ApiModelPropertiesGeneric.ITEM_ID)), @@ -185,7 +185,7 @@ public void toggleTagAssignment() throws Exception { this.mockMvc .perform(post(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + MgmtRestConstants.TARGET_TAG_TARGETS_REQUEST_MAPPING + "/toggleTagAssignment", tagId) - .content(json).contentType(MediaType.APPLICATION_JSON_UTF8)) + .content(json).contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) .andDo(this.document.document( pathParameters(parameterWithName("targetTagId").description(ApiModelPropertiesGeneric.ITEM_ID)), @@ -208,7 +208,7 @@ public void assignTargets() throws Exception { this.mockMvc .perform(post(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + MgmtRestConstants.TARGET_TAG_TARGETS_REQUEST_MAPPING, tagId).content(json) - .contentType(MediaType.APPLICATION_JSON_UTF8)) + .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) .andDo(this.document.document( pathParameters(parameterWithName("targetTagId").description(ApiModelPropertiesGeneric.ITEM_ID)), @@ -225,7 +225,7 @@ public void unassignTarget() throws Exception { .perform(delete( MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + MgmtRestConstants.TARGET_TAG_TARGETS_REQUEST_MAPPING + "/{controllerId}", - tagId, target.getControllerId()).contentType(MediaType.APPLICATION_JSON_UTF8)) + tagId, target.getControllerId()).contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()).andDo(MockMvcResultPrinter.print()) .andDo(this.document.document( pathParameters(parameterWithName("targetTagId").description(ApiModelPropertiesGeneric.ITEM_ID), diff --git a/hawkbit-runtime/hawkbit-update-server/src/main/resources/application.properties b/hawkbit-runtime/hawkbit-update-server/src/main/resources/application.properties index 468eb4793b..1d63f77424 100644 --- a/hawkbit-runtime/hawkbit-update-server/src/main/resources/application.properties +++ b/hawkbit-runtime/hawkbit-update-server/src/main/resources/application.properties @@ -12,6 +12,11 @@ spring.security.user.name=admin spring.security.user.password={noop}admin spring.main.allow-bean-definition-overriding=true +# Http Encoding +server.servlet.encoding.charset=UTF-8 +server.servlet.encoding.enabled=true +server.servlet.encoding.force=true + # DDI authentication configuration hawkbit.server.ddi.security.authentication.anonymous.enabled=false hawkbit.server.ddi.security.authentication.targettoken.enabled=true diff --git a/hawkbit-runtime/hawkbit-update-server/src/test/java/org/eclipse/hawkbit/app/AbstractSecurityTest.java b/hawkbit-runtime/hawkbit-update-server/src/test/java/org/eclipse/hawkbit/app/AbstractSecurityTest.java new file mode 100644 index 0000000000..9b4114eb28 --- /dev/null +++ b/hawkbit-runtime/hawkbit-update-server/src/test/java/org/eclipse/hawkbit/app/AbstractSecurityTest.java @@ -0,0 +1,46 @@ +/** + * Copyright (c) 2020 Bosch.IO GmbH and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.eclipse.hawkbit.app; + +import org.eclipse.hawkbit.repository.test.util.MsSqlTestDatabase; +import org.eclipse.hawkbit.repository.test.util.MySqlTestDatabase; +import org.junit.Before; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.context.TestExecutionListeners; +import org.springframework.test.context.TestExecutionListeners.MergeMode; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.setup.DefaultMockMvcBuilder; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.web.context.WebApplicationContext; + +@RunWith(SpringRunner.class) +@SpringBootTest(properties = { "hawkbit.dmf.rabbitmq.enabled=false" }) +@TestExecutionListeners(listeners = { MySqlTestDatabase.class, + MsSqlTestDatabase.class }, mergeMode = MergeMode.MERGE_WITH_DEFAULTS) +@DirtiesContext +public abstract class AbstractSecurityTest { + + @Autowired + private WebApplicationContext context; + + protected MockMvc mvc; + + @Before + public void setup() { + final DefaultMockMvcBuilder builder = MockMvcBuilders.webAppContextSetup(context) + .apply(SecurityMockMvcConfigurers.springSecurity()).dispatchOptions(true); + mvc = builder.build(); + } + +} \ No newline at end of file diff --git a/hawkbit-runtime/hawkbit-update-server/src/test/java/org/eclipse/hawkbit/app/AllowedHostNamesTest.java b/hawkbit-runtime/hawkbit-update-server/src/test/java/org/eclipse/hawkbit/app/AllowedHostNamesTest.java new file mode 100644 index 0000000000..057ef17606 --- /dev/null +++ b/hawkbit-runtime/hawkbit-update-server/src/test/java/org/eclipse/hawkbit/app/AllowedHostNamesTest.java @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2019 Bosch Software Innovations GmbH and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.eclipse.hawkbit.app; + +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +import io.qameta.allure.Description; +import org.junit.Test; +import org.springframework.http.HttpHeaders; +import org.springframework.security.web.firewall.RequestRejectedException; + +import io.qameta.allure.Feature; +import io.qameta.allure.Story; +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = { "hawkbit.server.security.allowedHostNames=localhost", + "hawkbit.server.security.httpFirewallIgnoredPaths=/index.html" }) +@Feature("Integration Test - Security") +@Story("Allowed Host Names") +public class AllowedHostNamesTest extends AbstractSecurityTest { + + @Test + @Description("Tests whether a RequestRejectedException is thrown when not allowed host is used") + public void allowedHostNameWithNotAllowedHost() { + assertThatExceptionOfType(RequestRejectedException.class).isThrownBy( + () -> mvc.perform(get("/").header(HttpHeaders.HOST, "www.google.com"))); + } + + @Test + @Description("Tests whether request is redirected when allowed host is used") + public void allowedHostNameWithAllowedHost() throws Exception { + mvc.perform(get("/").header(HttpHeaders.HOST, "localhost")).andExpect(status().is3xxRedirection()); + } + + @Test + @Description("Tests whether request without allowed host name and with ignored path end up with a client error") + public void notAllowedHostnameWithIgnoredPath() throws Exception { + mvc.perform(get("/index.html").header(HttpHeaders.HOST, "www.google.com")) + .andExpect(status().is4xxClientError()); + } +} \ No newline at end of file diff --git a/hawkbit-runtime/hawkbit-update-server/src/test/java/org/eclipse/hawkbit/app/CorsTest.java b/hawkbit-runtime/hawkbit-update-server/src/test/java/org/eclipse/hawkbit/app/CorsTest.java index d7e7e27a7e..7785ca91d8 100644 --- a/hawkbit-runtime/hawkbit-update-server/src/test/java/org/eclipse/hawkbit/app/CorsTest.java +++ b/hawkbit-runtime/hawkbit-update-server/src/test/java/org/eclipse/hawkbit/app/CorsTest.java @@ -23,8 +23,10 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.security.test.context.support.WithUserDetails; import org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers; +import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.TestExecutionListeners.MergeMode; +import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.ResultActions; @@ -36,15 +38,13 @@ import io.qameta.allure.Feature; import io.qameta.allure.Story; -@RunWith(SpringRunner.class) -@SpringBootTest(properties = { "hawkbit.dmf.rabbitmq.enabled=false", "hawkbit.server.security.cors.enabled=true", - "hawkbit.server.security.cors.allowedOrigins=" + CorsTest.ALLOWED_ORIGIN_FIRST + "," - + CorsTest.ALLOWED_ORIGIN_SECOND }) -@TestExecutionListeners(listeners = { MySqlTestDatabase.class, MsSqlTestDatabase.class, - PostgreSqlTestDatabase.class }, mergeMode = MergeMode.MERGE_WITH_DEFAULTS) +@SpringBootTest(properties = {"hawkbit.dmf.rabbitmq.enabled=false", "hawkbit.server.security.cors.enabled=true", + "hawkbit.server.security.cors.allowedOrigins=" + CorsTest.ALLOWED_ORIGIN_FIRST + "," + CorsTest.ALLOWED_ORIGIN_SECOND}) +@TestExecutionListeners(listeners = { MySqlTestDatabase.class, MsSqlTestDatabase.class }, + mergeMode = MergeMode.MERGE_WITH_DEFAULTS) @Feature("Integration Test - Security") @Story("CORS") -public class CorsTest { +public class CorsTest extends AbstractSecurityTest { final static String ALLOWED_ORIGIN_FIRST = "http://test.first.origin"; final static String ALLOWED_ORIGIN_SECOND = "http://test.second.origin"; @@ -52,18 +52,6 @@ public class CorsTest { private final static String INVALID_ORIGIN = "http://test.invalid.origin"; private final static String INVALID_CORS_REQUEST = "Invalid CORS request"; - @Autowired - private WebApplicationContext context; - - private MockMvc mvc; - - @Before - public void setup() { - final DefaultMockMvcBuilder builder = MockMvcBuilders.webAppContextSetup(context) - .apply(SecurityMockMvcConfigurers.springSecurity()).dispatchOptions(true); - mvc = builder.build(); - } - @WithUserDetails("admin") @Test @Description("Ensures that Cors is working.") diff --git a/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/security/HawkbitSecurityProperties.java b/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/security/HawkbitSecurityProperties.java index 5e0bed358f..420f1e8285 100644 --- a/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/security/HawkbitSecurityProperties.java +++ b/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/security/HawkbitSecurityProperties.java @@ -35,6 +35,17 @@ public class HawkbitSecurityProperties { */ private boolean requireSsl; + /** + * With this property a list of allowed hostnames can be configured. All + * requests with different Host headers will be rejected. + */ + private List allowedHostNames; + + /** + * Add paths that will be ignored by {@link StrictHttpFirewall}. + */ + private List httpFirewallIgnoredPaths; + /** * Basic authentication realm, see * https://tools.ietf.org/html/rfc2617#page-3 . @@ -49,6 +60,22 @@ public void setRequireSsl(final boolean requireSsl) { this.requireSsl = requireSsl; } + public List getAllowedHostNames() { + return allowedHostNames; + } + + public void setAllowedHostNames(final List allowedHostNames) { + this.allowedHostNames = allowedHostNames; + } + + public List getHttpFirewallIgnoredPaths() { + return httpFirewallIgnoredPaths; + } + + public void setHttpFirewallIgnoredPaths(final List httpFirewallIgnoredPaths) { + this.httpFirewallIgnoredPaths = httpFirewallIgnoredPaths; + } + public String getBasicRealm() { return basicRealm; } diff --git a/hawkbit-security-core/src/test/java/org/eclipse/hawkbit/util/IpUtilTest.java b/hawkbit-security-core/src/test/java/org/eclipse/hawkbit/util/IpUtilTest.java index fcf409fdf2..7934fcd21f 100644 --- a/hawkbit-security-core/src/test/java/org/eclipse/hawkbit/util/IpUtilTest.java +++ b/hawkbit-security-core/src/test/java/org/eclipse/hawkbit/util/IpUtilTest.java @@ -27,7 +27,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import io.qameta.allure.Description; import io.qameta.allure.Feature; diff --git a/hawkbit-security-integration/src/test/java/org/eclipse/hawkbit/security/ControllerPreAuthenticatedAnonymousDownloadTest.java b/hawkbit-security-integration/src/test/java/org/eclipse/hawkbit/security/ControllerPreAuthenticatedAnonymousDownloadTest.java index 90e692e252..13e4a933f2 100644 --- a/hawkbit-security-integration/src/test/java/org/eclipse/hawkbit/security/ControllerPreAuthenticatedAnonymousDownloadTest.java +++ b/hawkbit-security-integration/src/test/java/org/eclipse/hawkbit/security/ControllerPreAuthenticatedAnonymousDownloadTest.java @@ -17,7 +17,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.springframework.security.core.authority.SimpleGrantedAuthority; import io.qameta.allure.Feature; diff --git a/hawkbit-security-integration/src/test/java/org/eclipse/hawkbit/security/ControllerPreAuthenticatedSecurityHeaderFilterTest.java b/hawkbit-security-integration/src/test/java/org/eclipse/hawkbit/security/ControllerPreAuthenticatedSecurityHeaderFilterTest.java index 2f2aa5c1dd..405f7be734 100644 --- a/hawkbit-security-integration/src/test/java/org/eclipse/hawkbit/security/ControllerPreAuthenticatedSecurityHeaderFilterTest.java +++ b/hawkbit-security-integration/src/test/java/org/eclipse/hawkbit/security/ControllerPreAuthenticatedSecurityHeaderFilterTest.java @@ -23,7 +23,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import io.qameta.allure.Description; import io.qameta.allure.Feature; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/data/mappers/IdentifiableEntityToProxyIdentifiableEntityMapper.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/data/mappers/IdentifiableEntityToProxyIdentifiableEntityMapper.java index 3b106ec98c..f1a65180d3 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/data/mappers/IdentifiableEntityToProxyIdentifiableEntityMapper.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/data/mappers/IdentifiableEntityToProxyIdentifiableEntityMapper.java @@ -8,8 +8,8 @@ */ package org.eclipse.hawkbit.ui.common.data.mappers; +import org.eclipse.hawkbit.repository.Identifiable; import org.eclipse.hawkbit.ui.common.data.proxies.ProxyIdentifiableEntity; -import org.springframework.hateoas.Identifiable; /** * Interface for mapping identifiable entities, fetched from backend, to the diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/data/providers/AbstractMetaDataDataProvider.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/data/providers/AbstractMetaDataDataProvider.java index 5448c5218f..52741b86d2 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/data/providers/AbstractMetaDataDataProvider.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/data/providers/AbstractMetaDataDataProvider.java @@ -31,7 +31,7 @@ public abstract class AbstractMetaDataDataProvider private static final long serialVersionUID = 1L; protected AbstractMetaDataDataProvider() { - this(new Sort(Direction.DESC, "key")); + this(Sort.by(Direction.DESC, "key")); } protected AbstractMetaDataDataProvider(final Sort defaultSortOrder) { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/data/providers/AbstractProxyDataProvider.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/data/providers/AbstractProxyDataProvider.java index 469739927b..84f023ca77 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/data/providers/AbstractProxyDataProvider.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/data/providers/AbstractProxyDataProvider.java @@ -10,12 +10,12 @@ import java.util.stream.Stream; +import org.eclipse.hawkbit.repository.Identifiable; import org.eclipse.hawkbit.ui.common.data.mappers.IdentifiableEntityToProxyIdentifiableEntityMapper; import org.eclipse.hawkbit.ui.common.data.proxies.ProxyIdentifiableEntity; import org.springframework.data.domain.Slice; import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort.Direction; -import org.springframework.hateoas.Identifiable; /** * Base class for loading a batch of {@link Identifiable} entities from backend @@ -41,7 +41,7 @@ public abstract class AbstractProxyDataProvider mapper) { - this(mapper, new Sort(Direction.ASC, "id")); + this(mapper, Sort.by(Direction.ASC, "id")); } /** diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/data/providers/ActionDataProvider.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/data/providers/ActionDataProvider.java index d2fcfe584d..5ad3dc6b4e 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/data/providers/ActionDataProvider.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/data/providers/ActionDataProvider.java @@ -42,7 +42,7 @@ public class ActionDataProvider extends AbstractProxyDataProvider mapper) { - super(mapper, new Sort(Direction.ASC, "name")); + super(mapper, Sort.by(Direction.ASC, "name")); this.distributionSetTagManagement = distributionSetTagManagement; } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/data/providers/DistributionSetTypeDataProvider.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/data/providers/DistributionSetTypeDataProvider.java index 8466703451..81e2f12cc3 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/data/providers/DistributionSetTypeDataProvider.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/data/providers/DistributionSetTypeDataProvider.java @@ -41,7 +41,7 @@ public class DistributionSetTypeDataProvider */ public DistributionSetTypeDataProvider(final DistributionSetTypeManagement distributionSetTypeManagement, final IdentifiableEntityToProxyIdentifiableEntityMapper mapper) { - super(mapper, new Sort(Direction.ASC, "name")); + super(mapper, Sort.by(Direction.ASC, "name")); this.distributionSetTypeManagement = distributionSetTypeManagement; } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/data/providers/RolloutDataProvider.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/data/providers/RolloutDataProvider.java index a079f92c8f..db12f1be1b 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/data/providers/RolloutDataProvider.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/data/providers/RolloutDataProvider.java @@ -39,7 +39,7 @@ public class RolloutDataProvider extends AbstractProxyDataProvider */ public SoftwareModuleTypeDataProvider(final SoftwareModuleTypeManagement softwareModuleTypeManagement, final IdentifiableEntityToProxyIdentifiableEntityMapper mapper) { - super(mapper, new Sort(Direction.ASC, "name")); + super(mapper, Sort.by(Direction.ASC, "name")); this.softwareModuleTypeManagement = softwareModuleTypeManagement; } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/data/providers/TargetFilterQueryDataProvider.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/data/providers/TargetFilterQueryDataProvider.java index ffbbd0381f..8f8a0963f5 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/data/providers/TargetFilterQueryDataProvider.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/data/providers/TargetFilterQueryDataProvider.java @@ -39,7 +39,7 @@ public class TargetFilterQueryDataProvider */ public TargetFilterQueryDataProvider(final TargetFilterQueryManagement targetFilterQueryManagement, final TargetFilterQueryToProxyTargetFilterMapper entityMapper) { - super(entityMapper, new Sort(Direction.ASC, "name")); + super(entityMapper, Sort.by(Direction.ASC, "name")); this.targetFilterQueryManagement = targetFilterQueryManagement; } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/data/providers/TargetFilterQueryDetailsDataProvider.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/data/providers/TargetFilterQueryDetailsDataProvider.java index 7d175f01d3..fe4aa56a53 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/data/providers/TargetFilterQueryDetailsDataProvider.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/data/providers/TargetFilterQueryDetailsDataProvider.java @@ -38,7 +38,7 @@ public class TargetFilterQueryDetailsDataProvider */ public TargetFilterQueryDetailsDataProvider(final TargetFilterQueryManagement targetFilterQueryManagement, final TargetFilterQueryToProxyTargetFilterMapper entityMapper) { - super(entityMapper, new Sort(Direction.ASC, "name")); + super(entityMapper, Sort.by(Direction.ASC, "name")); this.targetFilterQueryManagement = targetFilterQueryManagement; } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/data/providers/TargetFilterStateDataProvider.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/data/providers/TargetFilterStateDataProvider.java index f52b8a4cd7..93c57524b2 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/data/providers/TargetFilterStateDataProvider.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/data/providers/TargetFilterStateDataProvider.java @@ -40,7 +40,7 @@ public class TargetFilterStateDataProvider extends AbstractProxyDataProvider mapper) { - super(mapper, new Sort(Direction.ASC, "name")); + super(mapper, Sort.by(Direction.ASC, "name")); this.tagManagementService = tagManagementService; } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/data/proxies/ProxyIdentifiableEntity.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/data/proxies/ProxyIdentifiableEntity.java index dc1fe368b5..b29b7ab041 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/data/proxies/ProxyIdentifiableEntity.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/data/proxies/ProxyIdentifiableEntity.java @@ -8,10 +8,9 @@ */ package org.eclipse.hawkbit.ui.common.data.proxies; +import org.eclipse.hawkbit.repository.Identifiable; import java.io.Serializable; -import org.springframework.hateoas.Identifiable; - /** * Proxy entity representing the {@link Identifiable} entity, fetched from * backend. diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/AbstractTagToken.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/AbstractTagToken.java index 4c5c101aa5..989bd0e5c3 100644 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/AbstractTagToken.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/AbstractTagToken.java @@ -14,6 +14,7 @@ import java.util.Optional; import java.util.stream.Collectors; +import org.eclipse.hawkbit.repository.Identifiable; import org.eclipse.hawkbit.ui.SpPermissionChecker; import org.eclipse.hawkbit.ui.common.CommonUiDependencies; import org.eclipse.hawkbit.ui.common.data.proxies.ProxyNamedEntity; @@ -22,7 +23,6 @@ import org.eclipse.hawkbit.ui.common.tagdetails.TagPanelLayout.TagAssignmentListener; import org.eclipse.hawkbit.ui.utils.UINotification; import org.eclipse.hawkbit.ui.utils.VaadinMessageSource; -import org.springframework.hateoas.Identifiable; import org.springframework.util.CollectionUtils; import org.vaadin.spring.events.EventBus.UIEventBus; diff --git a/hawkbit-ui/src/test/java/org/eclipse/hawkbit/ui/artifacts/state/ArtifactUploadStateTest.java b/hawkbit-ui/src/test/java/org/eclipse/hawkbit/ui/artifacts/state/ArtifactUploadStateTest.java index 211b6ee16d..386a5cf82a 100644 --- a/hawkbit-ui/src/test/java/org/eclipse/hawkbit/ui/artifacts/state/ArtifactUploadStateTest.java +++ b/hawkbit-ui/src/test/java/org/eclipse/hawkbit/ui/artifacts/state/ArtifactUploadStateTest.java @@ -18,7 +18,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import io.qameta.allure.Feature; import io.qameta.allure.Story; diff --git a/pom.xml b/pom.xml index 1cca108515..10af24e2e2 100644 --- a/pom.xml +++ b/pom.xml @@ -16,7 +16,7 @@ org.springframework.boot spring-boot-starter-parent - 2.1.4.RELEASE + 2.3.7.RELEASE org.eclipse.hawkbit @@ -127,13 +127,14 @@ - + 1.8 - 2.1.4.RELEASE - Greenwich.RELEASE + 2.3.7.RELEASE + Hoxton.SR7 + 2.0.0.RELEASE true @@ -141,13 +142,11 @@ upgrade) - START --> - 2.1.0.RELEASE - - - 3.7 - 1.3.4 - - 4.5.6 + 3.5.0.RELEASE + + 6.0.20.Final + + 5.2.4 @@ -162,6 +161,7 @@ 3.3.3 1.11.1 + 3.9.0 9.1.3 @@ -463,6 +463,7 @@ org.apache.maven.plugins maven-site-plugin + ${maven.site.plugin.version} true true @@ -733,6 +734,11 @@ org.eclipse.persistence.jpa ${eclipselink.version} + + org.springframework.plugin + spring-plugin-core + ${spring.plugin.core.version} + @@ -766,6 +772,20 @@ org.springframework.boot spring-boot-starter-logging + + + org.junit.jupiter + junit-jupiter + + + + org.junit.vintage + junit-vintage-engine + + + org.mockito + mockito-junit-jupiter +