Merge pull request #1018 from bosch-io/fix_migration_to_new_spring_boot_version

Update Spring Boot to 2.3.7.RELEASE
This commit is contained in:
Dominic Schabel
2021-02-11 16:42:14 +01:00
committed by GitHub
104 changed files with 831 additions and 415 deletions

View File

@@ -25,6 +25,10 @@
<artifactId>hawkbit-security-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>

View File

@@ -28,7 +28,6 @@ import org.eclipse.hawkbit.repository.model.ArtifactUpload;
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.
*
*

View File

@@ -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 <T> the parameter of the class
*/
@FunctionalInterface
public interface Identifiable<T extends Serializable> {
T getId();
}

View File

@@ -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;

View File

@@ -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.

View File

@@ -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.
*

View File

@@ -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;
/**
*

View File

@@ -47,7 +47,7 @@ public class MaintenanceScheduleHelperTest {
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

View File

@@ -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<Long> {

View File

@@ -914,7 +914,7 @@ public class JpaControllerManagement extends JpaActionManagement implements Cont
? 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<String> messages = actionStatusRepository.findMessagesByActionIdAndMessageNotLike(pageable, actionId,
RepositoryConstants.SERVER_MESSAGE_PREFIX + "%");

View File

@@ -333,7 +333,7 @@ public class JpaRolloutManagement extends AbstractRolloutManagement {
LOGGER.debug("handleCreateRollout called for rollout {}", rollout.getId());
final List<RolloutGroup> 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;

View File

@@ -145,9 +145,8 @@ import org.springframework.validation.beanvalidation.MethodValidationPostProcess
public class RepositoryApplicationConfiguration extends JpaBaseConfiguration {
protected RepositoryApplicationConfiguration(final DataSource dataSource, final JpaProperties properties,
final ObjectProvider<JtaTransactionManager> jtaTransactionManagerProvider,
final ObjectProvider<TransactionManagerCustomizers> transactionManagerCustomizers) {
super(dataSource, properties, jtaTransactionManagerProvider, transactionManagerCustomizers);
final ObjectProvider<JtaTransactionManager> jtaTransactionManagerProvider) {
super(dataSource, properties, jtaTransactionManagerProvider);
}
@Bean
@@ -410,12 +409,12 @@ public class RepositoryApplicationConfiguration extends JpaBaseConfiguration {
/**
* {@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> transactionManagerCustomizers) {
return new MultiTenantJpaTransactionManager();
}

View File

@@ -39,7 +39,6 @@ import org.eclipse.hawkbit.repository.model.Target;
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 final class TargetSpecifications {
* @return the {@link Target} {@link Specification}
*/
public static Specification<JpaTarget> likeIdOrNameOrDescriptionOrAttributeValue(final String searchText) {
return Specifications.where(likeIdOrNameOrDescription(searchText)).or(likeAttributeValue(searchText));
return Specification.where(likeIdOrNameOrDescription(searchText)).or(likeAttributeValue(searchText));
}
/**

View File

@@ -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

View File

@@ -43,10 +43,10 @@ import org.eclipse.hawkbit.repository.event.remote.entity.RolloutUpdatedEvent;
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 class RolloutManagementTest extends AbstractJpaIntegrationTest {
// 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<RolloutGroup> 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 class RolloutManagementTest extends AbstractJpaIntegrationTest {
// verify that now the first and the second group are in running state
final List<RolloutGroup> 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 class RolloutManagementTest extends AbstractJpaIntegrationTest {
// verify that the other groups are still in schedule state
final List<RolloutGroup> 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 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
private void checkSecondGroupStatusIsRunning(final Rollout createdRollout) {
rolloutManagement.handleRollouts();
final List<RolloutGroup> 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 class RolloutManagementTest extends AbstractJpaIntegrationTest {
// the first rollout group should be in error state
final List<RolloutGroup> 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<RolloutGroup> 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 class RolloutManagementTest extends AbstractJpaIntegrationTest {
// all other groups should still be in scheduled state
final List<RolloutGroup> 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 class RolloutManagementTest extends AbstractJpaIntegrationTest {
// next group should be running again after resuming the rollout
final List<RolloutGroup> 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 class RolloutManagementTest extends AbstractJpaIntegrationTest {
// 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 class RolloutManagementTest extends AbstractJpaIntegrationTest {
rolloutManagement.handleRollouts();
final Page<Rollout> 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<Rollout> rolloutList = rolloutPage.getContent();
// validate rolloutA -> 6 running and 6 ready
@@ -1084,7 +1084,7 @@ public class RolloutManagementTest extends AbstractJpaIntegrationTest {
}
final Slice<Rollout> 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<Rollout> rolloutList = rollout.getContent();
assertThat(rolloutList.size()).isEqualTo(5);
int i = 1;

View File

@@ -93,7 +93,7 @@ public class SpecificationsBuilderTest {
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);

View File

@@ -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<BaseEntity> hasId(final Long id) {
return new HasIdMatcher(Matchers.equalTo(id));
}

View File

@@ -113,7 +113,7 @@ import com.google.common.io.Files;
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");

View File

@@ -23,7 +23,7 @@ import org.springframework.data.domain.Sort.Direction;
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;