Reduce dependency on Guava (#1589)

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2024-02-02 22:21:46 +02:00
committed by GitHub
parent 0ee916e8cb
commit bce69676d2
63 changed files with 222 additions and 332 deletions

View File

@@ -24,7 +24,7 @@ Please read this if you intend to contribute to the project.
### Utility library usage ### Utility library usage
hawkBit has currently both [guava](https://github.com/google/guava) and [Apache commons lang](https://commons.apache.org/proper/commons-lang/) on the classpath in several of its modules. However, we see introducing too many utility libraries problematic as we force these as transitive dependencies on hawkBit users. We in fact are looking into reducing them in future not adding new ones. hawkBit has currently [Apache commons lang](https://commons.apache.org/proper/commons-lang/) on the classpath in several of its modules. However, we see introducing too many utility libraries problematic as we force these as transitive dependencies on hawkBit users. We in fact are looking into reducing them in future not adding new ones.
So we kindly ask contributors: So we kindly ask contributors:
@@ -33,14 +33,8 @@ So we kindly ask contributors:
* use utility functions in general based in the following priority: * use utility functions in general based in the following priority:
* use utility functions from JDK if feasible * use utility functions from JDK if feasible
* use Spring utility classes if feasible * use Spring utility classes if feasible
* use [Guava](https://github.com/google/guava) if feasible
* use [Apache commons lang](https://commons.apache.org/proper/commons-lang/) if feasible * use [Apache commons lang](https://commons.apache.org/proper/commons-lang/) if feasible
Examples:
* Prefer `Arrays.asList(...)` from JDK over Guava's `Lists.newArrayList(...)`
* Prefer `StringUtils` from Spring over Guava's `Strings` and Apache's `StringUtils`
### Test documentation ### Test documentation
Please document the test cases that you contribute by means of [Allure](https://docs.qameta.io/allure/) annotations and proper test method naming. Please document the test cases that you contribute by means of [Allure](https://docs.qameta.io/allure/) annotations and proper test method naming.

View File

@@ -25,10 +25,6 @@
<artifactId>hawkbit-core</artifactId> <artifactId>hawkbit-core</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId> <artifactId>spring-core</artifactId>

View File

@@ -11,6 +11,7 @@ package org.eclipse.hawkbit.artifact.repository;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.List; import java.util.List;
@@ -21,7 +22,6 @@ import org.eclipse.hawkbit.artifact.repository.model.DbArtifactHash;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import com.google.common.base.Splitter; import com.google.common.base.Splitter;
import com.google.common.io.Files;
/** /**
* Implementation of the {@link ArtifactRepository} to store artifacts on the * Implementation of the {@link ArtifactRepository} to store artifacts on the
@@ -79,7 +79,7 @@ public class ArtifactFilesystemRepository extends AbstractArtifactRepository {
if (fileSHA1Naming.exists()) { if (fileSHA1Naming.exists()) {
FileUtils.deleteQuietly(file); FileUtils.deleteQuietly(file);
} else { } else {
Files.move(file, fileSHA1Naming); Files.move(file.toPath(), fileSHA1Naming.toPath());
} }
return new ArtifactFilesystem(fileSHA1Naming, artifact.getArtifactId(), artifact.getHashes(), return new ArtifactFilesystem(fileSHA1Naming, artifact.getArtifactId(), artifact.getHashes(),

View File

@@ -72,10 +72,6 @@
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId> <artifactId>spring-context-support</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency> <dependency>
<groupId>io.protostuff</groupId> <groupId>io.protostuff</groupId>
<artifactId>protostuff-core</artifactId> <artifactId>protostuff-core</artifactId>

View File

@@ -34,8 +34,9 @@
<artifactId>jakarta.validation-api</artifactId> <artifactId>jakarta.validation-api</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.google.guava</groupId> <groupId>commons-io</groupId>
<artifactId>guava</artifactId> <artifactId>commons-io</artifactId>
<version>${commons-io.version}</version>
</dependency> </dependency>
<!-- Test --> <!-- Test -->

View File

@@ -19,16 +19,15 @@ import java.nio.file.Files;
import java.security.DigestInputStream; import java.security.DigestInputStream;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.util.HexFormat;
import org.apache.commons.io.IOUtils;
import org.eclipse.hawkbit.artifact.repository.model.AbstractDbArtifact; import org.eclipse.hawkbit.artifact.repository.model.AbstractDbArtifact;
import org.eclipse.hawkbit.artifact.repository.model.DbArtifactHash; import org.eclipse.hawkbit.artifact.repository.model.DbArtifactHash;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import com.google.common.io.BaseEncoding;
import com.google.common.io.ByteStreams;
/** /**
* Abstract utility class for ArtifactRepository implementations with common * Abstract utility class for ArtifactRepository implementations with common
* functionality, e.g. computation of hashes. * functionality, e.g. computation of hashes.
@@ -61,9 +60,11 @@ public abstract class AbstractArtifactRepository implements ArtifactRepository {
tempFile = storeTempFile(inputStream); tempFile = storeTempFile(inputStream);
final String sha1Hash16 = BaseEncoding.base16().lowerCase().encode(mdSHA1.digest()); final HexFormat hexFormat = HexFormat.of().withLowerCase();
final String md5Hash16 = BaseEncoding.base16().lowerCase().encode(mdMD5.digest());
final String sha256Hash16 = BaseEncoding.base16().lowerCase().encode(mdSHA256.digest()); final String sha1Hash16 = hexFormat.formatHex(mdSHA1.digest());
final String md5Hash16 = hexFormat.formatHex(mdMD5.digest());
final String sha256Hash16 = hexFormat.formatHex(mdSHA256.digest());
checkHashes(sha1Hash16, md5Hash16, sha256Hash16, providedHashes); checkHashes(sha1Hash16, md5Hash16, sha256Hash16, providedHashes);
@@ -110,7 +111,7 @@ public abstract class AbstractArtifactRepository implements ArtifactRepository {
protected String storeTempFile(final InputStream content) throws IOException { protected String storeTempFile(final InputStream content) throws IOException {
final File file = createTempFile(); final File file = createTempFile();
try (final OutputStream outputstream = new BufferedOutputStream(new FileOutputStream(file))) { try (final OutputStream outputstream = new BufferedOutputStream(new FileOutputStream(file))) {
ByteStreams.copy(content, outputstream); IOUtils.copy(content, outputstream);
outputstream.flush(); outputstream.flush();
} }
return file.getPath(); return file.getPath();

View File

@@ -62,10 +62,6 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-json</artifactId> <artifactId>spring-boot-starter-json</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId> <artifactId>slf4j-api</artifactId>

View File

@@ -9,7 +9,6 @@
*/ */
package org.eclipse.hawkbit.amqp; package org.eclipse.hawkbit.amqp;
import com.google.common.collect.Maps;
import org.eclipse.hawkbit.api.ArtifactUrlHandler; import org.eclipse.hawkbit.api.ArtifactUrlHandler;
import org.eclipse.hawkbit.api.HostnameResolver; import org.eclipse.hawkbit.api.HostnameResolver;
import org.eclipse.hawkbit.cache.DownloadIdCache; import org.eclipse.hawkbit.cache.DownloadIdCache;
@@ -54,6 +53,7 @@ import org.springframework.retry.support.RetryTemplate;
import org.springframework.util.ErrorHandler; import org.springframework.util.ErrorHandler;
import java.time.Duration; import java.time.Duration;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -366,10 +366,9 @@ public class AmqpConfiguration {
} }
private static Map<String, Object> getTTLMaxArgsAuthenticationQueue() { private static Map<String, Object> getTTLMaxArgsAuthenticationQueue() {
final Map<String, Object> args = Maps.newHashMapWithExpectedSize(2); final Map<String, Object> args = new HashMap<>(2);
args.put("x-message-ttl", Duration.ofSeconds(30).toMillis()); args.put("x-message-ttl", Duration.ofSeconds(30).toMillis());
args.put("x-max-length", 1_000); args.put("x-max-length", 1_000);
return args; return args;
} }
} }

View File

@@ -9,6 +9,7 @@
*/ */
package org.eclipse.hawkbit.amqp; package org.eclipse.hawkbit.amqp;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import jakarta.annotation.PostConstruct; import jakarta.annotation.PostConstruct;
@@ -33,8 +34,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.security.core.Authentication; import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationToken; import org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationToken;
import com.google.common.collect.Lists;
/** /**
* *
* A controller which handles the DMF AMQP authentication. * A controller which handles the DMF AMQP authentication.
@@ -93,7 +92,7 @@ public class AmqpControllerAuthentication {
} }
private void addFilter() { private void addFilter() {
filterChain = Lists.newArrayListWithExpectedSize(5); filterChain = new ArrayList<>(5);
final ControllerPreAuthenticatedGatewaySecurityTokenFilter gatewaySecurityTokenFilter = new ControllerPreAuthenticatedGatewaySecurityTokenFilter( final ControllerPreAuthenticatedGatewaySecurityTokenFilter gatewaySecurityTokenFilter = new ControllerPreAuthenticatedGatewaySecurityTokenFilter(
tenantConfigurationManagement, tenantAware, systemSecurityContext); tenantConfigurationManagement, tenantAware, systemSecurityContext);

View File

@@ -10,13 +10,12 @@
package org.eclipse.hawkbit.amqp; package org.eclipse.hawkbit.amqp;
import java.time.Duration; import java.time.Duration;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.springframework.amqp.core.Queue; import org.springframework.amqp.core.Queue;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import com.google.common.collect.Maps;
/** /**
* Bean which holds the necessary properties for configuring the AMQP deadletter * Bean which holds the necessary properties for configuring the AMQP deadletter
* queue. * queue.
@@ -39,7 +38,7 @@ public class AmqpDeadletterProperties {
* @return map which holds the properties * @return map which holds the properties
*/ */
public Map<String, Object> getDeadLetterExchangeArgs(final String exchange) { public Map<String, Object> getDeadLetterExchangeArgs(final String exchange) {
final Map<String, Object> args = Maps.newHashMapWithExpectedSize(1); final Map<String, Object> args = new HashMap<>(1);
args.put("x-dead-letter-exchange", exchange); args.put("x-dead-letter-exchange", exchange);
return args; return args;
} }
@@ -56,7 +55,7 @@ public class AmqpDeadletterProperties {
} }
private Map<String, Object> getTTLArgs() { private Map<String, Object> getTTLArgs() {
final Map<String, Object> args = Maps.newHashMapWithExpectedSize(1); final Map<String, Object> args = new HashMap<>(1);
args.put("x-message-ttl", getTtl()); args.put("x-message-ttl", getTtl());
return args; return args;
} }

View File

@@ -25,6 +25,7 @@ import java.util.function.Supplier;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.StreamSupport; import java.util.stream.StreamSupport;
import com.google.common.collect.Iterables;
import org.eclipse.hawkbit.api.ApiType; import org.eclipse.hawkbit.api.ApiType;
import org.eclipse.hawkbit.api.ArtifactUrl; import org.eclipse.hawkbit.api.ArtifactUrl;
import org.eclipse.hawkbit.api.ArtifactUrlHandler; import org.eclipse.hawkbit.api.ArtifactUrlHandler;
@@ -79,8 +80,6 @@ import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import com.google.common.collect.Iterables;
/** /**
* {@link AmqpMessageDispatcherService} create all outgoing AMQP messages and * {@link AmqpMessageDispatcherService} create all outgoing AMQP messages and
* delegate the messages to a {@link AmqpMessageSenderService}. * delegate the messages to a {@link AmqpMessageSenderService}.

View File

@@ -43,10 +43,6 @@
<artifactId>hawkbit-dmf-api</artifactId> <artifactId>hawkbit-dmf-api</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.amqp</groupId> <groupId>org.springframework.amqp</groupId>
<artifactId>spring-rabbit-junit</artifactId> <artifactId>spring-rabbit-junit</artifactId>

View File

@@ -88,10 +88,5 @@
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@@ -14,18 +14,16 @@ import static org.assertj.core.api.Assertions.assertThat;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.net.URISyntaxException;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.google.common.reflect.ClassPath;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import com.google.common.reflect.ClassPath;
import io.qameta.allure.Description; import io.qameta.allure.Description;
import io.qameta.allure.Feature; import io.qameta.allure.Feature;
import io.qameta.allure.Story; import io.qameta.allure.Story;
@@ -42,8 +40,7 @@ public class RepositoryManagementMethodPreAuthorizeAnnotatedTest {
@Test @Test
@Description("Verifies that repository methods are @PreAuthorize annotated") @Description("Verifies that repository methods are @PreAuthorize annotated")
public void repositoryManagementMethodsArePreAuthorizedAnnotated() public void repositoryManagementMethodsArePreAuthorizedAnnotated() throws IOException {
throws ClassNotFoundException, URISyntaxException, IOException {
final List<Class<?>> findInterfacesInPackage = findInterfacesInPackage(getClass().getPackage(), final List<Class<?>> findInterfacesInPackage = findInterfacesInPackage(getClass().getPackage(),
Pattern.compile(".*Management")); Pattern.compile(".*Management"));
@@ -81,8 +78,7 @@ public class RepositoryManagementMethodPreAuthorizeAnnotatedTest {
} }
} }
private List<Class<?>> findInterfacesInPackage(final Package p, final Pattern includeFilter) private List<Class<?>> findInterfacesInPackage(final Package p, final Pattern includeFilter) throws IOException {
throws URISyntaxException, IOException, ClassNotFoundException {
return ClassPath.from(Thread.currentThread().getContextClassLoader()).getTopLevelClasses(p.getName()).stream() return ClassPath.from(Thread.currentThread().getContextClassLoader()).getTopLevelClasses(p.getName()).stream()
.filter(clazzInfo -> includeFilter.matcher(clazzInfo.getSimpleName()).matches()) .filter(clazzInfo -> includeFilter.matcher(clazzInfo.getSimpleName()).matches())
.map(clazzInfo -> clazzInfo.load()).filter(clazz -> clazz.isInterface()).collect(Collectors.toList()); .map(clazzInfo -> clazzInfo.load()).filter(clazz -> clazz.isInterface()).collect(Collectors.toList());

View File

@@ -29,10 +29,6 @@
<groupId>org.apache.commons</groupId> <groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId> <artifactId>commons-lang3</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency> <dependency>
<groupId>com.github.ben-manes.caffeine</groupId> <groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId> <artifactId>caffeine</artifactId>

View File

@@ -69,10 +69,6 @@
<groupId>cz.jirutka.rsql</groupId> <groupId>cz.jirutka.rsql</groupId>
<artifactId>rsql-parser</artifactId> <artifactId>rsql-parser</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.jsoup</groupId> <groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId> <artifactId>jsoup</artifactId>

View File

@@ -9,6 +9,7 @@
*/ */
package org.eclipse.hawkbit.repository.jpa; package org.eclipse.hawkbit.repository.jpa;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
@@ -198,8 +199,6 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.transaction.jta.JtaTransactionManager; import org.springframework.transaction.jta.JtaTransactionManager;
import org.springframework.validation.beanvalidation.MethodValidationPostProcessor; import org.springframework.validation.beanvalidation.MethodValidationPostProcessor;
import com.google.common.collect.Maps;
/** /**
* General configuration for hawkBit's Repository. * General configuration for hawkBit's Repository.
* *
@@ -483,7 +482,7 @@ public class RepositoryApplicationConfiguration extends JpaBaseConfiguration {
@Override @Override
protected Map<String, Object> getVendorProperties() { protected Map<String, Object> getVendorProperties() {
final Map<String, Object> properties = Maps.newHashMapWithExpectedSize(7); final Map<String, Object> properties = new HashMap<>(7);
// Turn off dynamic weaving to disable LTW lookup in static weaving mode // Turn off dynamic weaving to disable LTW lookup in static weaving mode
properties.put(PersistenceUnitProperties.WEAVING, "false"); properties.put(PersistenceUnitProperties.WEAVING, "false");
// needed for reports // needed for reports

View File

@@ -9,6 +9,8 @@
*/ */
package org.eclipse.hawkbit.repository.jpa.aspects; package org.eclipse.hawkbit.repository.jpa.aspects;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -29,9 +31,6 @@ import org.springframework.dao.OptimisticLockingFailureException;
import org.springframework.security.access.AccessDeniedException; import org.springframework.security.access.AccessDeniedException;
import org.springframework.transaction.TransactionSystemException; import org.springframework.transaction.TransactionSystemException;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
/** /**
* {@link Aspect} catches persistence exceptions and wraps them to custom * {@link Aspect} catches persistence exceptions and wraps them to custom
* specific exceptions Additionally it checks and prevents access to certain * specific exceptions Additionally it checks and prevents access to certain
@@ -42,14 +41,14 @@ public class ExceptionMappingAspectHandler implements Ordered {
private static final Logger LOG = LoggerFactory.getLogger(ExceptionMappingAspectHandler.class); private static final Logger LOG = LoggerFactory.getLogger(ExceptionMappingAspectHandler.class);
private static final Map<String, String> EXCEPTION_MAPPING = Maps.newHashMapWithExpectedSize(4); private static final Map<String, String> EXCEPTION_MAPPING = new HashMap<>(4);
/** /**
* this is required to enable a certain order of exception and to select the * this is required to enable a certain order of exception and to select the
* most specific mappable exception according to the type hierarchy of the * most specific mappable exception according to the type hierarchy of the
* exception. * exception.
*/ */
private static final List<Class<?>> MAPPED_EXCEPTION_ORDER = Lists.newArrayListWithExpectedSize(4); private static final List<Class<?>> MAPPED_EXCEPTION_ORDER = new ArrayList<>(4);
static { static {

View File

@@ -21,6 +21,8 @@ import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalUnit; import java.time.temporal.TemporalUnit;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
@@ -31,6 +33,7 @@ import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.google.common.collect.Lists;
import jakarta.persistence.EntityManager; import jakarta.persistence.EntityManager;
import jakarta.persistence.Query; import jakarta.persistence.Query;
import jakarta.persistence.criteria.CriteriaBuilder; import jakarta.persistence.criteria.CriteriaBuilder;
@@ -111,10 +114,6 @@ import org.springframework.transaction.support.TransactionCallback;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
/** /**
* JPA based {@link ControllerManagement} implementation. * JPA based {@link ControllerManagement} implementation.
* *
@@ -450,7 +449,7 @@ public class JpaControllerManagement extends JpaActionManagement implements Cont
LOG.debug("{} events in flushUpdateQueue.", size); LOG.debug("{} events in flushUpdateQueue.", size);
final Set<TargetPoll> events = Sets.newHashSetWithExpectedSize(queue.size()); final Set<TargetPoll> events = new HashSet<>(queue.size());
final int drained = queue.drainTo(events); final int drained = queue.drainTo(events);
if (drained <= 0) { if (drained <= 0) {
@@ -494,7 +493,7 @@ public class JpaControllerManagement extends JpaActionManagement implements Cont
* itself. * itself.
*/ */
private void setLastTargetQuery(final String tenant, final long currentTimeMillis, final List<String> chunk) { private void setLastTargetQuery(final String tenant, final long currentTimeMillis, final List<String> chunk) {
final Map<String, String> paramMapping = Maps.newHashMapWithExpectedSize(chunk.size()); final Map<String, String> paramMapping = new HashMap<>(chunk.size());
for (int i = 0; i < chunk.size(); i++) { for (int i = 0; i < chunk.size(); i++) {
paramMapping.put("cid" + i, chunk.get(i)); paramMapping.put("cid" + i, chunk.get(i));

View File

@@ -28,6 +28,7 @@ import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.IntStream; import java.util.stream.IntStream;
import com.google.common.collect.Lists;
import jakarta.persistence.EntityManager; import jakarta.persistence.EntityManager;
import jakarta.persistence.Query; import jakarta.persistence.Query;
import jakarta.persistence.criteria.CriteriaBuilder; import jakarta.persistence.criteria.CriteriaBuilder;
@@ -111,8 +112,6 @@ import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import com.google.common.collect.Lists;
/** /**
* JPA implementation for {@link DeploymentManagement}. * JPA implementation for {@link DeploymentManagement}.
* *

View File

@@ -89,8 +89,6 @@ import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import com.google.common.collect.Lists;
/** /**
* JPA implementation of {@link DistributionSetManagement}. * JPA implementation of {@link DistributionSetManagement}.
* *
@@ -600,7 +598,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
private static List<Specification<JpaDistributionSet>> buildDistributionSetSpecifications( private static List<Specification<JpaDistributionSet>> buildDistributionSetSpecifications(
final DistributionSetFilter distributionSetFilter) { final DistributionSetFilter distributionSetFilter) {
final List<Specification<JpaDistributionSet>> specList = Lists.newArrayListWithExpectedSize(10); final List<Specification<JpaDistributionSet>> specList = new ArrayList<>(10);
Specification<JpaDistributionSet> spec; Specification<JpaDistributionSet> spec;

View File

@@ -93,8 +93,6 @@ import org.springframework.util.CollectionUtils;
import org.springframework.util.concurrent.ListenableFuture; import org.springframework.util.concurrent.ListenableFuture;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import com.google.common.collect.Lists;
/** /**
* JPA implementation of {@link RolloutManagement}. * JPA implementation of {@link RolloutManagement}.
*/ */
@@ -171,7 +169,7 @@ public class JpaRolloutManagement implements RolloutManagement {
@Override @Override
public Page<Rollout> findByRsql(final Pageable pageable, final String rsqlParam, final boolean deleted) { public Page<Rollout> findByRsql(final Pageable pageable, final String rsqlParam, final boolean deleted) {
final List<Specification<JpaRollout>> specList = Lists.newArrayListWithExpectedSize(2); final List<Specification<JpaRollout>> specList = new ArrayList<>(2);
specList.add( specList.add(
RSQLUtility.buildRsqlSpecification(rsqlParam, RolloutFields.class, virtualPropertyReplacer, database)); RSQLUtility.buildRsqlSpecification(rsqlParam, RolloutFields.class, virtualPropertyReplacer, database));
specList.add(RolloutSpecification.isDeletedWithDistributionSet(deleted, pageable.getSort())); specList.add(RolloutSpecification.isDeletedWithDistributionSet(deleted, pageable.getSort()));

View File

@@ -9,6 +9,7 @@
*/ */
package org.eclipse.hawkbit.repository.jpa.management; package org.eclipse.hawkbit.repository.jpa.management;
import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
@@ -63,8 +64,6 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import com.google.common.collect.Lists;
import cz.jirutka.rsql.parser.RSQLParserException; import cz.jirutka.rsql.parser.RSQLParserException;
/** /**
@@ -212,7 +211,7 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
final String rsqlFilter) { final String rsqlFilter) {
final DistributionSet distributionSet = distributionSetManagement.getOrElseThrowException(setId); final DistributionSet distributionSet = distributionSetManagement.getOrElseThrowException(setId);
final List<Specification<JpaTargetFilterQuery>> specList = Lists.newArrayListWithExpectedSize(2); final List<Specification<JpaTargetFilterQuery>> specList = new ArrayList<>(2);
specList.add(TargetFilterQuerySpecification.byAutoAssignDS(distributionSet)); specList.add(TargetFilterQuerySpecification.byAutoAssignDS(distributionSet));
if (!ObjectUtils.isEmpty(rsqlFilter)) { if (!ObjectUtils.isEmpty(rsqlFilter)) {
specList.add(RSQLUtility.buildRsqlSpecification(rsqlFilter, TargetFilterQueryFields.class, specList.add(RSQLUtility.buildRsqlSpecification(rsqlFilter, TargetFilterQueryFields.class,

View File

@@ -21,6 +21,7 @@ import java.util.Objects;
import java.util.Optional; import java.util.Optional;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.google.common.collect.Lists;
import jakarta.persistence.EntityManager; import jakarta.persistence.EntityManager;
import jakarta.persistence.criteria.CriteriaBuilder; import jakarta.persistence.criteria.CriteriaBuilder;
import jakarta.persistence.criteria.CriteriaQuery; import jakarta.persistence.criteria.CriteriaQuery;
@@ -94,8 +95,6 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import com.google.common.collect.Lists;
import static org.eclipse.hawkbit.repository.jpa.JpaManagementHelper.combineWithAnd; import static org.eclipse.hawkbit.repository.jpa.JpaManagementHelper.combineWithAnd;
/** /**

View File

@@ -17,6 +17,7 @@ import java.util.function.BooleanSupplier;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.google.common.collect.Lists;
import org.eclipse.hawkbit.repository.QuotaManagement; import org.eclipse.hawkbit.repository.QuotaManagement;
import org.eclipse.hawkbit.repository.RepositoryConstants; import org.eclipse.hawkbit.repository.RepositoryConstants;
import org.eclipse.hawkbit.repository.RepositoryProperties; import org.eclipse.hawkbit.repository.RepositoryProperties;
@@ -40,8 +41,6 @@ import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
import org.eclipse.hawkbit.repository.model.TargetWithActionType; import org.eclipse.hawkbit.repository.model.TargetWithActionType;
import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder; import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder;
import com.google.common.collect.Lists;
/** /**
* AbstractDsAssignmentStrategy for offline assignments, i.e. not managed by * AbstractDsAssignmentStrategy for offline assignments, i.e. not managed by
* hawkBit. * hawkBit.

View File

@@ -18,6 +18,7 @@ import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import com.google.common.collect.Lists;
import org.eclipse.hawkbit.repository.QuotaManagement; import org.eclipse.hawkbit.repository.QuotaManagement;
import org.eclipse.hawkbit.repository.RepositoryProperties; import org.eclipse.hawkbit.repository.RepositoryProperties;
import org.eclipse.hawkbit.repository.event.remote.MultiActionAssignEvent; import org.eclipse.hawkbit.repository.event.remote.MultiActionAssignEvent;
@@ -44,8 +45,6 @@ import org.eclipse.hawkbit.repository.model.TargetWithActionType;
import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder; import org.eclipse.hawkbit.repository.model.helper.EventPublisherHolder;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import com.google.common.collect.Lists;
/** /**
* AbstractDsAssignmentStrategy for online assignments, i.e. managed by hawkBit. * AbstractDsAssignmentStrategy for online assignments, i.e. managed by hawkBit.
* *

View File

@@ -14,6 +14,7 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import com.google.common.base.Splitter;
import jakarta.persistence.CollectionTable; import jakarta.persistence.CollectionTable;
import jakarta.persistence.Column; import jakarta.persistence.Column;
import jakarta.persistence.ConstraintMode; import jakarta.persistence.ConstraintMode;
@@ -37,8 +38,6 @@ import org.eclipse.persistence.annotations.ConversionValue;
import org.eclipse.persistence.annotations.Convert; import org.eclipse.persistence.annotations.Convert;
import org.eclipse.persistence.annotations.ObjectTypeConverter; import org.eclipse.persistence.annotations.ObjectTypeConverter;
import com.google.common.base.Splitter;
/** /**
* Entity to store the status for a specific action. * Entity to store the status for a specific action.
*/ */

View File

@@ -35,7 +35,6 @@ import jakarta.persistence.criteria.Predicate;
import jakarta.persistence.criteria.Root; import jakarta.persistence.criteria.Root;
import jakarta.persistence.criteria.Subquery; import jakarta.persistence.criteria.Subquery;
import com.google.common.collect.Lists;
import cz.jirutka.rsql.parser.ast.AndNode; import cz.jirutka.rsql.parser.ast.AndNode;
import cz.jirutka.rsql.parser.ast.ComparisonNode; import cz.jirutka.rsql.parser.ast.ComparisonNode;
import cz.jirutka.rsql.parser.ast.LogicalNode; import cz.jirutka.rsql.parser.ast.LogicalNode;
@@ -73,7 +72,7 @@ public class JpaQueryRsqlVisitor<A extends Enum<A> & FieldNameProvider, T> exten
public static final Character LIKE_WILDCARD = '*'; public static final Character LIKE_WILDCARD = '*';
private static final char ESCAPE_CHAR = '\\'; private static final char ESCAPE_CHAR = '\\';
private static final List<String> NO_JOINS_OPERATOR = Lists.newArrayList("!=", "=out="); private static final List<String> NO_JOINS_OPERATOR = List.of("!=", "=out=");
private static final String ESCAPE_CHAR_WITH_ASTERISK = ESCAPE_CHAR +"*"; private static final String ESCAPE_CHAR_WITH_ASTERISK = ESCAPE_CHAR +"*";
private final Map<Integer, Set<Join<Object, Object>>> joinsInLevel = new HashMap<>(3); private final Map<Integer, Set<Join<Object, Object>>> joinsInLevel = new HashMap<>(3);

View File

@@ -11,6 +11,7 @@ package org.eclipse.hawkbit.repository.event.remote;
import static org.junit.jupiter.api.Assertions.fail; import static org.junit.jupiter.api.Assertions.fail;
import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
import org.eclipse.hawkbit.event.BusProtoStuffMessageConverter; import org.eclipse.hawkbit.event.BusProtoStuffMessageConverter;
@@ -33,7 +34,6 @@ import org.springframework.util.MimeTypeUtils;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.Maps;
/** /**
* Test the remote entity events. * Test the remote entity events.
@@ -57,13 +57,13 @@ public abstract class AbstractRemoteEventTest extends AbstractJpaIntegrationTest
} }
private Message<?> createProtoStuffMessage(final TenantAwareEvent event) { private Message<?> createProtoStuffMessage(final TenantAwareEvent event) {
final Map<String, Object> headers = Maps.newLinkedHashMap(); final Map<String, Object> headers = new LinkedHashMap<>();
headers.put(MessageHeaders.CONTENT_TYPE, BusProtoStuffMessageConverter.APPLICATION_BINARY_PROTOSTUFF); headers.put(MessageHeaders.CONTENT_TYPE, BusProtoStuffMessageConverter.APPLICATION_BINARY_PROTOSTUFF);
return busProtoStuffMessageConverter.toMessage(event, new MutableMessageHeaders(headers)); return busProtoStuffMessageConverter.toMessage(event, new MutableMessageHeaders(headers));
} }
private Message<String> createJsonMessage(final Object event) { private Message<String> createJsonMessage(final Object event) {
final Map<String, MimeType> headers = Maps.newLinkedHashMap(); final Map<String, MimeType> headers = new LinkedHashMap<>();
headers.put(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.APPLICATION_JSON); headers.put(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.APPLICATION_JSON);
try { try {
final String json = new ObjectMapper().writeValueAsString(event); final String json = new ObjectMapper().writeValueAsString(event);
@@ -76,7 +76,7 @@ public abstract class AbstractRemoteEventTest extends AbstractJpaIntegrationTest
} }
protected Message<?> createMessageWithImmutableHeader(final TenantAwareEvent event) { protected Message<?> createMessageWithImmutableHeader(final TenantAwareEvent event) {
final Map<String, Object> headers = Maps.newLinkedHashMap(); final Map<String, Object> headers = new LinkedHashMap<>();
return busProtoStuffMessageConverter.toMessage(event, new MessageHeaders(headers)); return busProtoStuffMessageConverter.toMessage(event, new MessageHeaders(headers));
} }

View File

@@ -9,9 +9,13 @@
*/ */
package org.eclipse.hawkbit.repository.jpa; package org.eclipse.hawkbit.repository.jpa;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
import jakarta.persistence.EntityManager; import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceContext; import jakarta.persistence.PersistenceContext;
@@ -63,8 +67,6 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.TestPropertySource;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import com.google.common.collect.Lists;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ContextConfiguration(classes = { @ContextConfiguration(classes = {
@@ -143,7 +145,7 @@ public abstract class AbstractJpaIntegrationTest extends AbstractIntegrationTest
@Transactional(readOnly = true) @Transactional(readOnly = true)
protected List<Action> findActionsByRolloutAndStatus(final Rollout rollout, final Action.Status actionStatus) { protected List<Action> findActionsByRolloutAndStatus(final Rollout rollout, final Action.Status actionStatus) {
return Lists.newArrayList(actionRepository.findByRolloutIdAndStatus(PAGE, rollout.getId(), actionStatus)); return toList(actionRepository.findByRolloutIdAndStatus(PAGE, rollout.getId(), actionStatus));
} }
protected static void verifyThrownExceptionBy(final ThrowingCallable tc, final String objectType) { protected static void verifyThrownExceptionBy(final ThrowingCallable tc, final String objectType) {
@@ -205,4 +207,17 @@ public abstract class AbstractJpaIntegrationTest extends AbstractIntegrationTest
protected JpaRolloutGroup refresh(final RolloutGroup group) { protected JpaRolloutGroup refresh(final RolloutGroup group) {
return rolloutGroupRepository.findById(group.getId()).get(); return rolloutGroupRepository.findById(group.getId()).get();
} }
protected static <T> List<T> toList(final Iterable<? extends T> it) {
return StreamSupport.stream(it.spliterator(), false).map(e -> (T)e).toList();
}
protected static <T> T[] toArray(final Iterable<? extends T> it, final Class<T> type) {
final List<T> list = toList(it);
final T[] array = (T[])Array.newInstance(type, list.size());
for (int i = 0; i < array.length; i++) {
array[i] = list.get(i);
}
return array;
}
} }

View File

@@ -19,6 +19,8 @@ import java.io.InputStream;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.HexFormat;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
@@ -54,9 +56,6 @@ import org.eclipse.hawkbit.repository.test.util.SecurityContextSwitch;
import org.eclipse.hawkbit.repository.test.util.WithUser; import org.eclipse.hawkbit.repository.test.util.WithUser;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import com.google.common.collect.Lists;
import com.google.common.io.BaseEncoding;
import io.qameta.allure.Description; import io.qameta.allure.Description;
import io.qameta.allure.Feature; import io.qameta.allure.Feature;
import io.qameta.allure.Story; import io.qameta.allure.Story;
@@ -185,7 +184,7 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
// now create artifacts for this module until the quota is exceeded // now create artifacts for this module until the quota is exceeded
final long maxArtifacts = quotaManagement.getMaxArtifactsPerSoftwareModule(); final long maxArtifacts = quotaManagement.getMaxArtifactsPerSoftwareModule();
final List<Long> artifactIds = Lists.newArrayList(); final List<Long> artifactIds = new ArrayList<>();
final int artifactSize = 5 * 1024; final int artifactSize = 5 * 1024;
for (int i = 0; i < maxArtifacts; ++i) { for (int i = 0; i < maxArtifacts; ++i) {
artifactIds.add(createArtifactForSoftwareModule("file" + i, smId, artifactSize).getId()); artifactIds.add(createArtifactForSoftwareModule("file" + i, smId, artifactSize).getId());
@@ -213,7 +212,7 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
// create as many small artifacts as possible w/o violating the storage // create as many small artifacts as possible w/o violating the storage
// quota // quota
final long maxBytes = quotaManagement.getMaxArtifactStorage(); final long maxBytes = quotaManagement.getMaxArtifactStorage();
final List<Long> artifactIds = Lists.newArrayList(); final List<Long> artifactIds = new ArrayList<>();
// choose an artifact size which does not violate the max file size // choose an artifact size which does not violate the max file size
final int artifactSize = Math.toIntExact(quotaManagement.getMaxArtifactSize() / 10); final int artifactSize = Math.toIntExact(quotaManagement.getMaxArtifactSize() / 10);
@@ -591,7 +590,7 @@ public class ArtifactManagementTest extends AbstractJpaIntegrationTest {
private String toBase16Hash(final String algorithm, final byte[] input) throws NoSuchAlgorithmException { private String toBase16Hash(final String algorithm, final byte[] input) throws NoSuchAlgorithmException {
final MessageDigest messageDigest = MessageDigest.getInstance(algorithm); final MessageDigest messageDigest = MessageDigest.getInstance(algorithm);
messageDigest.update(input); messageDigest.update(input);
return BaseEncoding.base16().lowerCase().encode(messageDigest.digest()); return HexFormat.of().withLowerCase().formatHex(messageDigest.digest());
} }
private Artifact createArtifactForSoftwareModule(final String filename, final long moduleId, final int artifactSize) private Artifact createArtifactForSoftwareModule(final String filename, final long moduleId, final int artifactSize)

View File

@@ -86,9 +86,6 @@ import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.ConcurrencyFailureException; import org.springframework.dao.ConcurrencyFailureException;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import io.qameta.allure.Description; import io.qameta.allure.Description;
import io.qameta.allure.Feature; import io.qameta.allure.Feature;
import io.qameta.allure.Step; import io.qameta.allure.Step;
@@ -156,7 +153,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
verifyThrownExceptionBy(() -> controllerManagement.registerRetrieved(NOT_EXIST_IDL, "test message"), "Action"); verifyThrownExceptionBy(() -> controllerManagement.registerRetrieved(NOT_EXIST_IDL, "test message"), "Action");
verifyThrownExceptionBy( verifyThrownExceptionBy(
() -> controllerManagement.updateControllerAttributes(NOT_EXIST_ID, Maps.newHashMap(), null), "Target"); () -> controllerManagement.updateControllerAttributes(NOT_EXIST_ID, new HashMap<>(), null), "Target");
} }
@Test @Test
@@ -973,7 +970,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
@Step @Step
private void addAttributeAndVerify(final String controllerId) { private void addAttributeAndVerify(final String controllerId) {
final Map<String, String> testData = Maps.newHashMapWithExpectedSize(1); final Map<String, String> testData = new HashMap<>(1);
testData.put("test1", "testdata1"); testData.put("test1", "testdata1");
controllerManagement.updateControllerAttributes(controllerId, testData, null); controllerManagement.updateControllerAttributes(controllerId, testData, null);
@@ -983,7 +980,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
@Step @Step
private void addSecondAttributeAndVerify(final String controllerId) { private void addSecondAttributeAndVerify(final String controllerId) {
final Map<String, String> testData = Maps.newHashMapWithExpectedSize(2); final Map<String, String> testData = new HashMap<>(2);
testData.put("test2", "testdata20"); testData.put("test2", "testdata20");
controllerManagement.updateControllerAttributes(controllerId, testData, null); controllerManagement.updateControllerAttributes(controllerId, testData, null);
@@ -994,7 +991,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
@Step @Step
private void updateAttributeAndVerify(final String controllerId) { private void updateAttributeAndVerify(final String controllerId) {
final Map<String, String> testData = Maps.newHashMapWithExpectedSize(2); final Map<String, String> testData = new HashMap<>(2);
testData.put("test1", "testdata12"); testData.put("test1", "testdata12");
controllerManagement.updateControllerAttributes(controllerId, testData, null); controllerManagement.updateControllerAttributes(controllerId, testData, null);
@@ -1141,7 +1138,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
private void writeAttributes(final String controllerId, final int allowedAttributes, final String keyPrefix, private void writeAttributes(final String controllerId, final int allowedAttributes, final String keyPrefix,
final String valuePrefix) { final String valuePrefix) {
final Map<String, String> testData = Maps.newHashMapWithExpectedSize(allowedAttributes); final Map<String, String> testData = new HashMap<>(allowedAttributes);
for (int i = 0; i < allowedAttributes; i++) { for (int i = 0; i < allowedAttributes; i++) {
testData.put(keyPrefix + i, valuePrefix); testData.put(keyPrefix + i, valuePrefix);
} }
@@ -1212,13 +1209,13 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
controllerManagement.addUpdateActionStatus(entityFactory.actionStatus().create(actionId) controllerManagement.addUpdateActionStatus(entityFactory.actionStatus().create(actionId)
.status(Action.Status.RUNNING).occurredAt(System.currentTimeMillis()) .status(Action.Status.RUNNING).occurredAt(System.currentTimeMillis())
.messages(Lists.newArrayList("proceeding message 1"))); .messages(List.of("proceeding message 1")));
final long createTime = System.currentTimeMillis(); final long createTime = System.currentTimeMillis();
waitNextMillis(); waitNextMillis();
controllerManagement.addUpdateActionStatus(entityFactory.actionStatus().create(actionId) controllerManagement.addUpdateActionStatus(entityFactory.actionStatus().create(actionId)
.status(Action.Status.RUNNING).occurredAt(System.currentTimeMillis()) .status(Action.Status.RUNNING).occurredAt(System.currentTimeMillis())
.messages(Lists.newArrayList("proceeding message 2"))); .messages(List.of("proceeding message 2")));
final List<String> messages = controllerManagement.getActionHistoryMessages(actionId, 2); final List<String> messages = controllerManagement.getActionHistoryMessages(actionId, 2);
@@ -1279,7 +1276,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
assignDistributionSet(testdataFactory.createDistributionSet("ds1"), testdataFactory.createTargets(1))); assignDistributionSet(testdataFactory.createDistributionSet("ds1"), testdataFactory.createTargets(1)));
assertThat(actionId).isNotNull(); assertThat(actionId).isNotNull();
final List<String> messages = Lists.newArrayList(); final List<String> messages = new ArrayList<>();
IntStream.range(0, maxMessages).forEach(i -> messages.add(i, "msg")); IntStream.range(0, maxMessages).forEach(i -> messages.add(i, "msg"));
assertThat(controllerManagement.addInformationalActionStatus( assertThat(controllerManagement.addInformationalActionStatus(

View File

@@ -24,6 +24,7 @@ import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Objects; import java.util.Objects;
import java.util.Optional; import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
@@ -90,10 +91,6 @@ import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Slice; import org.springframework.data.domain.Slice;
import org.springframework.data.domain.Sort.Direction; import org.springframework.data.domain.Sort.Direction;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import io.qameta.allure.Description; import io.qameta.allure.Description;
import io.qameta.allure.Feature; import io.qameta.allure.Feature;
import io.qameta.allure.Story; import io.qameta.allure.Story;
@@ -259,7 +256,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Ensures that tag to distribution set assignment that does not exist will cause EntityNotFoundException.") @Description("Ensures that tag to distribution set assignment that does not exist will cause EntityNotFoundException.")
void assignDistributionSetToTagThatDoesNotExistThrowsException() { void assignDistributionSetToTagThatDoesNotExistThrowsException() {
final List<Long> assignDS = Lists.newArrayListWithExpectedSize(5); final List<Long> assignDS = new ArrayList<>(5);
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
assignDS.add(testdataFactory.createDistributionSet("DS" + i, "1.0", Collections.emptyList()).getId()); assignDS.add(testdataFactory.createDistributionSet("DS" + i, "1.0", Collections.emptyList()).getId());
} }
@@ -730,9 +727,10 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
final DistributionSet createdDs = testdataFactory.createDistributionSet(); final DistributionSet createdDs = testdataFactory.createDistributionSet();
final String[] knownTargetIdsArray = { "1", "2" }; final List<String> knownTargetIds = new ArrayList<>();
final List<String> knownTargetIds = Lists.newArrayList(knownTargetIdsArray); knownTargetIds.add( "1");
testdataFactory.createTargets(knownTargetIdsArray); knownTargetIds.add("2");
testdataFactory.createTargets(knownTargetIds.toArray(new String[0]));
// add not existing target to targets // add not existing target to targets
knownTargetIds.add(notExistingId); knownTargetIds.add(notExistingId);
@@ -1055,9 +1053,9 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
assertThat(allFoundTargets).as("founded targets are wrong").containsAll(savedDeployedTargets) assertThat(allFoundTargets).as("founded targets are wrong").containsAll(savedDeployedTargets)
.containsAll(savedNakedTargets); .containsAll(savedNakedTargets);
assertThat(savedDeployedTargets).as("saved target are wrong") assertThat(savedDeployedTargets).as("saved target are wrong")
.doesNotContain(Iterables.toArray(savedNakedTargets, Target.class)); .doesNotContain(toArray(savedNakedTargets, Target.class));
assertThat(savedNakedTargets).as("saved target are wrong") assertThat(savedNakedTargets).as("saved target are wrong")
.doesNotContain(Iterables.toArray(savedDeployedTargets, Target.class)); .doesNotContain(toArray(savedDeployedTargets, Target.class));
for (final Target myt : savedNakedTargets) { for (final Target myt : savedNakedTargets) {
final Target t = targetManagement.getByControllerID(myt.getControllerId()).get(); final Target t = targetManagement.getByControllerID(myt.getControllerId()).get();
@@ -1101,7 +1099,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
.isThrownBy(() -> assignDistributionSet(incomplete, targets)); .isThrownBy(() -> assignDistributionSet(incomplete, targets));
final DistributionSet nowComplete = distributionSetManagement.assignSoftwareModules(incomplete.getId(), final DistributionSet nowComplete = distributionSetManagement.assignSoftwareModules(incomplete.getId(),
Sets.newHashSet(os.getId())); Set.of(os.getId()));
assertThat(assignDistributionSet(nowComplete, targets).getAssigned()).as("assign ds doesn't work") assertThat(assignDistributionSet(nowComplete, targets).getAssigned()).as("assign ds doesn't work")
.isEqualTo(10); .isEqualTo(10);
@@ -1165,9 +1163,9 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
assertThat(deployedTargetsFromDB).as("content of deployed target is wrong") assertThat(deployedTargetsFromDB).as("content of deployed target is wrong")
.usingElementComparator(controllerIdComparator()).containsAll(savedDeployedTargets) .usingElementComparator(controllerIdComparator()).containsAll(savedDeployedTargets)
.doesNotContain(Iterables.toArray(undeployedTargetsFromDB, JpaTarget.class)); .doesNotContain(toArray(undeployedTargetsFromDB, JpaTarget.class));
assertThat(undeployedTargetsFromDB).as("content of undeployed target is wrong").containsAll(savedNakedTargets) assertThat(undeployedTargetsFromDB).as("content of undeployed target is wrong").containsAll(savedNakedTargets)
.doesNotContain(Iterables.toArray(deployedTargetsFromDB, JpaTarget.class)); .doesNotContain(toArray(deployedTargetsFromDB, JpaTarget.class));
} }
@Test @Test
@@ -1710,9 +1708,9 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
final Iterable<DistributionSet> dss, final String deployedTargetPrefix, final Iterable<DistributionSet> dss, final String deployedTargetPrefix,
final String undeployedTargetPrefix, final String distributionSetPrefix) { final String undeployedTargetPrefix, final String distributionSetPrefix) {
Iterables.addAll(deployedTargets, deployedTs); deployedTargets.addAll(toList(deployedTs));
Iterables.addAll(undeployedTargets, undeployedTs); undeployedTargets.addAll(toList(undeployedTs));
Iterables.addAll(distributionSets, dss); distributionSets.addAll(toList(dss));
deployedTargets.forEach(t -> deployedTargetIDs.add(t.getId())); deployedTargets.forEach(t -> deployedTargetIDs.add(t.getId()));

View File

@@ -18,10 +18,12 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import java.util.Optional; import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
@@ -70,9 +72,6 @@ import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction; import org.springframework.data.domain.Sort.Direction;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import io.qameta.allure.Description; import io.qameta.allure.Description;
import io.qameta.allure.Feature; import io.qameta.allure.Feature;
import io.qameta.allure.Step; import io.qameta.allure.Step;
@@ -324,7 +323,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
@Description("Verifies that multiple DS are of default type if not specified explicitly at creation time.") @Description("Verifies that multiple DS are of default type if not specified explicitly at creation time.")
void createMultipleDistributionSetsWithImplicitType() { void createMultipleDistributionSetsWithImplicitType() {
final List<DistributionSetCreate> creates = Lists.newArrayListWithExpectedSize(10); final List<DistributionSetCreate> creates = new ArrayList<>(10);
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
creates.add(entityFactory.distributionSet().create().name("newtypesoft" + i).version("1" + i)); creates.add(entityFactory.distributionSet().create().name("newtypesoft" + i).version("1" + i));
} }
@@ -406,7 +405,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
@Test @Test
@Description("Ensures that distribution sets can assigned and unassigned to a distribution set tag.") @Description("Ensures that distribution sets can assigned and unassigned to a distribution set tag.")
void assignAndUnassignDistributionSetToTag() { void assignAndUnassignDistributionSetToTag() {
final List<Long> assignDS = Lists.newArrayListWithExpectedSize(4); final List<Long> assignDS = new ArrayList<>(4);
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
assignDS.add(testdataFactory.createDistributionSet("DS" + i, "1.0", Collections.emptyList()).getId()); assignDS.add(testdataFactory.createDistributionSet("DS" + i, "1.0", Collections.emptyList()).getId());
} }
@@ -450,7 +449,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
final SoftwareModule os2 = testdataFactory.createSoftwareModuleOs(); final SoftwareModule os2 = testdataFactory.createSoftwareModuleOs();
// update is allowed as it is still not assigned to a target // update is allowed as it is still not assigned to a target
ds = distributionSetManagement.assignSoftwareModules(ds.getId(), Sets.newHashSet(ah2.getId())); ds = distributionSetManagement.assignSoftwareModules(ds.getId(), Set.of(ah2.getId()));
// assign target // assign target
assignDistributionSet(ds.getId(), target.getControllerId()); assignDistributionSet(ds.getId(), target.getControllerId());
@@ -458,7 +457,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
final Long dsId = ds.getId(); final Long dsId = ds.getId();
// not allowed as it is assigned now // not allowed as it is assigned now
assertThatThrownBy(() -> distributionSetManagement.assignSoftwareModules(dsId, Sets.newHashSet(os2.getId()))) assertThatThrownBy(() -> distributionSetManagement.assignSoftwareModules(dsId, Set.of(os2.getId())))
.isInstanceOf(EntityReadOnlyException.class); .isInstanceOf(EntityReadOnlyException.class);
// not allowed as it is assigned now // not allowed as it is assigned now
@@ -482,7 +481,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
// update data // update data
assertThatThrownBy( assertThatThrownBy(
() -> distributionSetManagement.assignSoftwareModules(set.getId(), Sets.newHashSet(module.getId()))) () -> distributionSetManagement.assignSoftwareModules(set.getId(), Set.of(module.getId())))
.isInstanceOf(UnsupportedSoftwareModuleForThisDistributionSetException.class); .isInstanceOf(UnsupportedSoftwareModuleForThisDistributionSetException.class);
} }
@@ -495,7 +494,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
// update data // update data
// legal update of module addition // legal update of module addition
distributionSetManagement.assignSoftwareModules(ds.getId(), Sets.newHashSet(os.getId())); distributionSetManagement.assignSoftwareModules(ds.getId(), Set.of(os.getId()));
ds = getOrThrow(distributionSetManagement.getWithDetails(ds.getId())); ds = getOrThrow(distributionSetManagement.getWithDetails(ds.getId()));
assertThat(getOrThrow(ds.findFirstModuleByType(osType))).isEqualTo(os); assertThat(getOrThrow(ds.findFirstModuleByType(osType))).isEqualTo(os);
@@ -531,7 +530,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
// create some software modules // create some software modules
final int maxModules = quotaManagement.getMaxSoftwareModulesPerDistributionSet(); final int maxModules = quotaManagement.getMaxSoftwareModulesPerDistributionSet();
final List<Long> modules = Lists.newArrayList(); final List<Long> modules = new ArrayList<>();
for (int i = 0; i < maxModules + 1; ++i) { for (int i = 0; i < maxModules + 1; ++i) {
modules.add(testdataFactory.createSoftwareModuleApp("sm" + i).getId()); modules.add(testdataFactory.createSoftwareModuleApp("sm" + i).getId());
} }

View File

@@ -17,6 +17,7 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.Set;
import jakarta.validation.ConstraintViolationException; import jakarta.validation.ConstraintViolationException;
@@ -41,8 +42,6 @@ import org.eclipse.hawkbit.repository.test.matcher.Expect;
import org.eclipse.hawkbit.repository.test.matcher.ExpectEvents; import org.eclipse.hawkbit.repository.test.matcher.ExpectEvents;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import com.google.common.collect.Sets;
import io.qameta.allure.Description; import io.qameta.allure.Description;
import io.qameta.allure.Feature; import io.qameta.allure.Feature;
import io.qameta.allure.Step; import io.qameta.allure.Step;
@@ -206,13 +205,13 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
// add OS // add OS
distributionSetTypeManagement.assignMandatorySoftwareModuleTypes(updatableType.getId(), distributionSetTypeManagement.assignMandatorySoftwareModuleTypes(updatableType.getId(),
Sets.newHashSet(osType.getId())); Set.of(osType.getId()));
assertThat(distributionSetTypeManagement.getByKey("updatableType").get().getMandatoryModuleTypes()) assertThat(distributionSetTypeManagement.getByKey("updatableType").get().getMandatoryModuleTypes())
.containsOnly(osType); .containsOnly(osType);
// add JVM // add JVM
distributionSetTypeManagement.assignMandatorySoftwareModuleTypes(updatableType.getId(), distributionSetTypeManagement.assignMandatorySoftwareModuleTypes(updatableType.getId(),
Sets.newHashSet(runtimeType.getId())); Set.of(runtimeType.getId()));
assertThat(distributionSetTypeManagement.getByKey("updatableType").get().getMandatoryModuleTypes()) assertThat(distributionSetTypeManagement.getByKey("updatableType").get().getMandatoryModuleTypes())
.containsOnly(osType, runtimeType); .containsOnly(osType, runtimeType);
@@ -228,7 +227,7 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
final int quota = quotaManagement.getMaxSoftwareModuleTypesPerDistributionSetType(); final int quota = quotaManagement.getMaxSoftwareModuleTypesPerDistributionSetType();
// create software module types // create software module types
final List<Long> moduleTypeIds = Lists.newArrayList(); final List<Long> moduleTypeIds = new ArrayList<>();
for (int i = 0; i < quota + 1; ++i) { for (int i = 0; i < quota + 1; ++i) {
final SoftwareModuleTypeCreate smCreate = entityFactory.softwareModuleType().create().name("smType_" + i) final SoftwareModuleTypeCreate smCreate = entityFactory.softwareModuleType().create().name("smType_" + i)
.description("smType_" + i).maxAssignments(1).colour("blue").key("smType_" + i); .description("smType_" + i).maxAssignments(1).colour("blue").key("smType_" + i);
@@ -290,7 +289,7 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
final DistributionSetType nonUpdatableType = createDistributionSetTypeUsedByDs(); final DistributionSetType nonUpdatableType = createDistributionSetTypeUsedByDs();
assertThatThrownBy(() -> distributionSetTypeManagement assertThatThrownBy(() -> distributionSetTypeManagement
.assignMandatorySoftwareModuleTypes(nonUpdatableType.getId(), Sets.newHashSet(osType.getId()))) .assignMandatorySoftwareModuleTypes(nonUpdatableType.getId(), Set.of(osType.getId())))
.isInstanceOf(EntityReadOnlyException.class); .isInstanceOf(EntityReadOnlyException.class);
} }
@@ -311,7 +310,7 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
assertThat(distributionSetTypeManagement.getByKey("updatableType").get().getMandatoryModuleTypes()).isEmpty(); assertThat(distributionSetTypeManagement.getByKey("updatableType").get().getMandatoryModuleTypes()).isEmpty();
nonUpdatableType = distributionSetTypeManagement.assignMandatorySoftwareModuleTypes(nonUpdatableType.getId(), nonUpdatableType = distributionSetTypeManagement.assignMandatorySoftwareModuleTypes(nonUpdatableType.getId(),
Sets.newHashSet(osType.getId())); Set.of(osType.getId()));
distributionSetManagement.create(entityFactory.distributionSet().create().name("newtypesoft").version("1") distributionSetManagement.create(entityFactory.distributionSet().create().name("newtypesoft").version("1")
.type(nonUpdatableType.getKey())); .type(nonUpdatableType.getKey()));

View File

@@ -21,6 +21,7 @@ import java.util.Collections;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.Set;
import org.apache.commons.lang3.RandomUtils; import org.apache.commons.lang3.RandomUtils;
import org.eclipse.hawkbit.repository.builder.SoftwareModuleMetadataCreate; import org.eclipse.hawkbit.repository.builder.SoftwareModuleMetadataCreate;
@@ -29,7 +30,6 @@ import org.eclipse.hawkbit.repository.exception.AssignmentQuotaExceededException
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException; import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
import org.eclipse.hawkbit.repository.jpa.AbstractJpaIntegrationTest; import org.eclipse.hawkbit.repository.jpa.AbstractJpaIntegrationTest;
import org.eclipse.hawkbit.repository.jpa.RandomGeneratedInputStream; import org.eclipse.hawkbit.repository.jpa.RandomGeneratedInputStream;
import org.eclipse.hawkbit.repository.jpa.model.JpaAction;
import org.eclipse.hawkbit.repository.jpa.model.JpaAction_; import org.eclipse.hawkbit.repository.jpa.model.JpaAction_;
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSet; import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSet;
import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSet_; import org.eclipse.hawkbit.repository.jpa.model.JpaDistributionSet_;
@@ -56,9 +56,6 @@ import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction; import org.springframework.data.domain.Sort.Direction;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import io.qameta.allure.Description; import io.qameta.allure.Description;
import io.qameta.allure.Feature; import io.qameta.allure.Feature;
import io.qameta.allure.Story; import io.qameta.allure.Story;
@@ -309,7 +306,7 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
SoftwareModule assignedModule = createSoftwareModuleWithArtifacts(osType, "moduleX", "3.0.2", 2); SoftwareModule assignedModule = createSoftwareModuleWithArtifacts(osType, "moduleX", "3.0.2", 2);
// [STEP2]: Assign SoftwareModule to DistributionSet // [STEP2]: Assign SoftwareModule to DistributionSet
testdataFactory.createDistributionSet(Sets.newHashSet(assignedModule)); testdataFactory.createDistributionSet(Set.of(assignedModule));
// [STEP3]: Delete the assigned SoftwareModule // [STEP3]: Delete the assigned SoftwareModule
softwareModuleManagement.delete(assignedModule.getId()); softwareModuleManagement.delete(assignedModule.getId());
@@ -345,7 +342,7 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
SoftwareModule assignedModule = createSoftwareModuleWithArtifacts(osType, "moduleX", "3.0.2", 2); SoftwareModule assignedModule = createSoftwareModuleWithArtifacts(osType, "moduleX", "3.0.2", 2);
// [STEP2]: Assign SoftwareModule to DistributionSet // [STEP2]: Assign SoftwareModule to DistributionSet
final DistributionSet disSet = testdataFactory.createDistributionSet(Sets.newHashSet(assignedModule)); final DistributionSet disSet = testdataFactory.createDistributionSet(Set.of(assignedModule));
// [STEP3]: Assign DistributionSet to a Device // [STEP3]: Assign DistributionSet to a Device
assignDistributionSet(disSet, Collections.singletonList(target)); assignDistributionSet(disSet, Collections.singletonList(target));
@@ -446,11 +443,11 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
final Artifact artifactY = moduleY.getArtifacts().iterator().next(); final Artifact artifactY = moduleY.getArtifacts().iterator().next();
// [STEP3]: Assign SoftwareModuleX to DistributionSetX and to target // [STEP3]: Assign SoftwareModuleX to DistributionSetX and to target
final DistributionSet disSetX = testdataFactory.createDistributionSet(Sets.newHashSet(moduleX), "X"); final DistributionSet disSetX = testdataFactory.createDistributionSet(Set.of(moduleX), "X");
assignDistributionSet(disSetX, Collections.singletonList(target)); assignDistributionSet(disSetX, Collections.singletonList(target));
// [STEP4]: Assign SoftwareModuleY to DistributionSet and to target // [STEP4]: Assign SoftwareModuleY to DistributionSet and to target
final DistributionSet disSetY = testdataFactory.createDistributionSet(Sets.newHashSet(moduleY), "Y"); final DistributionSet disSetY = testdataFactory.createDistributionSet(Set.of(moduleY), "Y");
assignDistributionSet(disSetY, Collections.singletonList(target)); assignDistributionSet(disSetY, Collections.singletonList(target));
// [STEP5]: Delete SoftwareModuleX // [STEP5]: Delete SoftwareModuleX
@@ -549,8 +546,8 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
final SoftwareModule four = testdataFactory.createSoftwareModuleOs("e"); final SoftwareModule four = testdataFactory.createSoftwareModuleOs("e");
final DistributionSet set = distributionSetManagement final DistributionSet set = distributionSetManagement
.create(entityFactory.distributionSet().create().name("set").version("1").type(testDsType).modules(Lists .create(entityFactory.distributionSet().create().name("set").version("1").type(testDsType).modules(
.newArrayList(one.getId(), two.getId(), deleted.getId(), four.getId(), differentName.getId()))); List.of(one.getId(), two.getId(), deleted.getId(), four.getId(), differentName.getId())));
softwareModuleManagement.delete(deleted.getId()); softwareModuleManagement.delete(deleted.getId());
// with filter on name, version and module type // with filter on name, version and module type
@@ -610,8 +607,8 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
final SoftwareModule four = testdataFactory.createSoftwareModuleOs("e"); final SoftwareModule four = testdataFactory.createSoftwareModuleOs("e");
distributionSetManagement distributionSetManagement
.create(entityFactory.distributionSet().create().name("set").version("1").type(testDsType).modules(Lists .create(entityFactory.distributionSet().create().name("set").version("1").type(testDsType).modules(
.newArrayList(one.getId(), two.getId(), deleted.getId(), four.getId(), differentName.getId()))); List.of(one.getId(), two.getId(), deleted.getId(), four.getId(), differentName.getId())));
softwareModuleManagement.delete(deleted.getId()); softwareModuleManagement.delete(deleted.getId());
// test // test

View File

@@ -643,9 +643,9 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
final Long[] overdueMix = { lastTargetQueryAlwaysOverdue, lastTargetQueryNotOverdue, final Long[] overdueMix = { lastTargetQueryAlwaysOverdue, lastTargetQueryNotOverdue,
lastTargetQueryAlwaysOverdue, lastTargetNull, lastTargetQueryAlwaysOverdue }; lastTargetQueryAlwaysOverdue, lastTargetNull, lastTargetQueryAlwaysOverdue };
final List<Target> notAssigned = Lists.newArrayListWithExpectedSize(overdueMix.length); final List<Target> notAssigned = new ArrayList<>(overdueMix.length);
List<Target> targAssigned = Lists.newArrayListWithExpectedSize(overdueMix.length); List<Target> targAssigned = new ArrayList<>(overdueMix.length);
List<Target> targInstalled = Lists.newArrayListWithExpectedSize(overdueMix.length); List<Target> targInstalled = new ArrayList<>(overdueMix.length);
for (int i = 0; i < overdueMix.length; i++) { for (int i = 0; i < overdueMix.length; i++) {
notAssigned.add(targetManagement notAssigned.add(targetManagement

View File

@@ -54,7 +54,6 @@ import org.eclipse.hawkbit.repository.exception.RSQLParameterUnsupportedFieldExc
import org.eclipse.hawkbit.repository.exception.TenantNotExistException; import org.eclipse.hawkbit.repository.exception.TenantNotExistException;
import org.eclipse.hawkbit.repository.jpa.AbstractJpaIntegrationTest; import org.eclipse.hawkbit.repository.jpa.AbstractJpaIntegrationTest;
import org.eclipse.hawkbit.repository.jpa.model.JpaAction; import org.eclipse.hawkbit.repository.jpa.model.JpaAction;
import org.eclipse.hawkbit.repository.jpa.model.JpaAction_;
import org.eclipse.hawkbit.repository.jpa.model.JpaTarget; import org.eclipse.hawkbit.repository.jpa.model.JpaTarget;
import org.eclipse.hawkbit.repository.jpa.model.JpaTargetMetadata; import org.eclipse.hawkbit.repository.jpa.model.JpaTargetMetadata;
import org.eclipse.hawkbit.repository.model.Action; import org.eclipse.hawkbit.repository.model.Action;
@@ -79,8 +78,6 @@ import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Slice; import org.springframework.data.domain.Slice;
import com.google.common.collect.Iterables;
import io.qameta.allure.Description; import io.qameta.allure.Description;
import io.qameta.allure.Feature; import io.qameta.allure.Feature;
import io.qameta.allure.Step; import io.qameta.allure.Step;
@@ -674,7 +671,7 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
final int numberToDelete = 50; final int numberToDelete = 50;
final Collection<Target> targetsToDelete = firstList.subList(0, numberToDelete); final Collection<Target> targetsToDelete = firstList.subList(0, numberToDelete);
final Target[] deletedTargets = Iterables.toArray(targetsToDelete, Target.class); final Target[] deletedTargets = toArray(targetsToDelete, Target.class);
final List<Long> targetsIdsToDelete = targetsToDelete.stream().map(Target::getId).collect(Collectors.toList()); final List<Long> targetsIdsToDelete = targetsToDelete.stream().map(Target::getId).collect(Collectors.toList());
targetManagement.delete(targetsIdsToDelete); targetManagement.delete(targetsIdsToDelete);
@@ -708,14 +705,14 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
assertThat(targetTagManagement.findByTarget(PAGE, t11.getControllerId()).getContent()).as("Tag size is wrong") assertThat(targetTagManagement.findByTarget(PAGE, t11.getControllerId()).getContent()).as("Tag size is wrong")
.hasSize(noT1Tags).containsAll(t1Tags); .hasSize(noT1Tags).containsAll(t1Tags);
assertThat(targetTagManagement.findByTarget(PAGE, t11.getControllerId()).getContent()).as("Tag size is wrong") assertThat(targetTagManagement.findByTarget(PAGE, t11.getControllerId()).getContent()).as("Tag size is wrong")
.hasSize(noT1Tags).doesNotContain(Iterables.toArray(t2Tags, TargetTag.class)); .hasSize(noT1Tags).doesNotContain(toArray(t2Tags, TargetTag.class));
final Target t21 = targetManagement.getByControllerID(t2.getControllerId()) final Target t21 = targetManagement.getByControllerID(t2.getControllerId())
.orElseThrow(IllegalStateException::new); .orElseThrow(IllegalStateException::new);
assertThat(targetTagManagement.findByTarget(PAGE, t21.getControllerId()).getContent()).as("Tag size is wrong") assertThat(targetTagManagement.findByTarget(PAGE, t21.getControllerId()).getContent()).as("Tag size is wrong")
.hasSize(noT2Tags).containsAll(t2Tags); .hasSize(noT2Tags).containsAll(t2Tags);
assertThat(targetTagManagement.findByTarget(PAGE, t21.getControllerId()).getContent()).as("Tag size is wrong") assertThat(targetTagManagement.findByTarget(PAGE, t21.getControllerId()).getContent()).as("Tag size is wrong")
.hasSize(noT2Tags).doesNotContain(Iterables.toArray(t1Tags, TargetTag.class)); .hasSize(noT2Tags).doesNotContain(toArray(t1Tags, TargetTag.class));
} }
@Test @Test
@@ -758,16 +755,16 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
final List<Target> targetWithTagC = new ArrayList<>(); final List<Target> targetWithTagC = new ArrayList<>();
// storing target lists to enable easy evaluation // storing target lists to enable easy evaluation
Iterables.addAll(targetWithTagA, tagATargets); targetWithTagA.addAll(tagATargets);
Iterables.addAll(targetWithTagA, tagABTargets); targetWithTagA.addAll(tagABTargets);
Iterables.addAll(targetWithTagA, tagABCTargets); targetWithTagA.addAll(tagABCTargets);
Iterables.addAll(targetWithTagB, tagBTargets); targetWithTagB.addAll(tagBTargets);
Iterables.addAll(targetWithTagB, tagABTargets); targetWithTagB.addAll(tagABTargets);
Iterables.addAll(targetWithTagB, tagABCTargets); targetWithTagB.addAll(tagABCTargets);
Iterables.addAll(targetWithTagC, tagCTargets); targetWithTagC.addAll(tagCTargets);
Iterables.addAll(targetWithTagC, tagABCTargets); targetWithTagC.addAll(tagABCTargets);
// check the target lists as returned by assignTag // check the target lists as returned by assignTag
checkTargetHasTags(false, targetWithTagA, tagA); checkTargetHasTags(false, targetWithTagA, tagA);

View File

@@ -11,6 +11,7 @@ package org.eclipse.hawkbit.repository.jpa.rsql;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.eclipse.hawkbit.repository.SoftwareModuleMetadataFields; import org.eclipse.hawkbit.repository.SoftwareModuleMetadataFields;
@@ -24,8 +25,6 @@ import org.junit.jupiter.api.Test;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import com.google.common.collect.Lists;
import io.qameta.allure.Description; import io.qameta.allure.Description;
import io.qameta.allure.Feature; import io.qameta.allure.Feature;
import io.qameta.allure.Story; import io.qameta.allure.Story;
@@ -42,7 +41,7 @@ public class RSQLSoftwareModuleMetadataFieldsTest extends AbstractJpaIntegration
softwareModuleId = softwareModule.getId(); softwareModuleId = softwareModule.getId();
final List<SoftwareModuleMetadataCreate> metadata = Lists.newArrayListWithExpectedSize(5); final List<SoftwareModuleMetadataCreate> metadata = new ArrayList<>(5);
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
metadata.add( metadata.add(
entityFactory.softwareModuleMetadata().create(softwareModule.getId()).key("" + i).value("" + i)); entityFactory.softwareModuleMetadata().create(softwareModule.getId()).key("" + i).value("" + i));

View File

@@ -83,10 +83,6 @@
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId> <artifactId>spring-context-support</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId> <artifactId>spring-tx</artifactId>

View File

@@ -22,6 +22,9 @@ import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import com.google.common.collect.ConcurrentHashMultiset;
import com.google.common.collect.Multiset;
import com.google.common.collect.Sets;
import org.awaitility.Awaitility; import org.awaitility.Awaitility;
import org.awaitility.core.ConditionTimeoutException; import org.awaitility.core.ConditionTimeoutException;
import org.eclipse.hawkbit.repository.event.remote.RemoteIdEvent; import org.eclipse.hawkbit.repository.event.remote.RemoteIdEvent;
@@ -37,10 +40,6 @@ import org.springframework.context.event.ApplicationEventMulticaster;
import org.springframework.test.context.TestContext; import org.springframework.test.context.TestContext;
import org.springframework.test.context.support.AbstractTestExecutionListener; import org.springframework.test.context.support.AbstractTestExecutionListener;
import com.google.common.collect.ConcurrentHashMultiset;
import com.google.common.collect.Multiset;
import com.google.common.collect.Sets;
/** /**
* Test rule to setup and verify the event count for a method. * Test rule to setup and verify the event count for a method.
*/ */

View File

@@ -11,12 +11,11 @@ package org.eclipse.hawkbit.repository.test.util;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.util.HexFormat;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import com.google.common.io.BaseEncoding;
/** /**
* Hash digest utility. * Hash digest utility.
*/ */
@@ -66,7 +65,7 @@ public final class HashGeneratorUtils {
try { try {
final MessageDigest digest = MessageDigest.getInstance(algorithm); final MessageDigest digest = MessageDigest.getInstance(algorithm);
final byte[] hashedBytes = digest.digest(message); final byte[] hashedBytes = digest.digest(message);
return BaseEncoding.base16().lowerCase().encode(hashedBytes); return HexFormat.of().withLowerCase().formatHex(hashedBytes);
} catch (final NoSuchAlgorithmException e) { } catch (final NoSuchAlgorithmException e) {
LOG.error("Algorithm could not be found", e); LOG.error("Algorithm could not be found", e);
} }

View File

@@ -81,8 +81,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import com.google.common.collect.Lists;
/** /**
* Data generator utility for tests. * Data generator utility for tests.
*/ */
@@ -438,7 +436,7 @@ public class TestdataFactory {
*/ */
public List<DistributionSet> createDistributionSetsWithoutModules(final int number) { public List<DistributionSet> createDistributionSetsWithoutModules(final int number) {
final List<DistributionSet> sets = Lists.newArrayListWithExpectedSize(number); final List<DistributionSet> sets = new ArrayList<>(number);
for (int i = 0; i < number; i++) { for (int i = 0; i < number; i++) {
sets.add(distributionSetManagement sets.add(distributionSetManagement
.create(entityFactory.distributionSet().create().name("DS" + i).version(DEFAULT_VERSION + "." + i) .create(entityFactory.distributionSet().create().name("DS" + i).version(DEFAULT_VERSION + "." + i)
@@ -913,7 +911,7 @@ public class TestdataFactory {
} }
public List<Target> createTargets(final String prefix, final int offset, final int number) { public List<Target> createTargets(final String prefix, final int offset, final int number) {
final List<TargetCreate> targets = Lists.newArrayListWithExpectedSize(number); final List<TargetCreate> targets = new ArrayList<>(number);
for (int i = 0; i < number; i++) { for (int i = 0; i < number; i++) {
targets.add(entityFactory.target().create().controllerId(prefix + (offset + i))); targets.add(entityFactory.target().create().controllerId(prefix + (offset + i)));
} }
@@ -936,7 +934,7 @@ public class TestdataFactory {
public List<Target> createTargetsWithType(final int number, final String controllerIdPrefix, public List<Target> createTargetsWithType(final int number, final String controllerIdPrefix,
final TargetType targetType) { final TargetType targetType) {
final List<TargetCreate> targets = Lists.newArrayListWithExpectedSize(number); final List<TargetCreate> targets = new ArrayList<>(number);
for (int i = 0; i < number; i++) { for (int i = 0; i < number; i++) {
targets.add(entityFactory.target().create().controllerId(controllerIdPrefix + i) targets.add(entityFactory.target().create().controllerId(controllerIdPrefix + i)
.targetType(targetType.getId())); .targetType(targetType.getId()));
@@ -976,7 +974,7 @@ public class TestdataFactory {
* @return list of {@link Target} objects * @return list of {@link Target} objects
*/ */
private List<Target> generateTargets(final int start, final int numberOfTargets, final String controllerIdPrefix) { private List<Target> generateTargets(final int start, final int numberOfTargets, final String controllerIdPrefix) {
final List<Target> targets = Lists.newArrayListWithExpectedSize(numberOfTargets); final List<Target> targets = new ArrayList<>(numberOfTargets);
for (int i = start; i < start + numberOfTargets; i++) { for (int i = start; i < start + numberOfTargets; i++) {
targets.add(entityFactory.target().create().controllerId(controllerIdPrefix + i).build()); targets.add(entityFactory.target().create().controllerId(controllerIdPrefix + i).build());
} }
@@ -1075,7 +1073,7 @@ public class TestdataFactory {
* @return the created set of {@link TargetTag}s * @return the created set of {@link TargetTag}s
*/ */
public List<TargetTag> createTargetTags(final int number, final String tagPrefix) { public List<TargetTag> createTargetTags(final int number, final String tagPrefix) {
final List<TagCreate> result = Lists.newArrayListWithExpectedSize(number); final List<TagCreate> result = new ArrayList<>(number);
for (int i = 0; i < number; i++) { for (int i = 0; i < number; i++) {
result.add(entityFactory.tag().create().name(tagPrefix + i).description(tagPrefix + i) result.add(entityFactory.tag().create().name(tagPrefix + i).description(tagPrefix + i)
@@ -1094,7 +1092,7 @@ public class TestdataFactory {
* @return the persisted {@link DistributionSetTag}s * @return the persisted {@link DistributionSetTag}s
*/ */
public List<DistributionSetTag> createDistributionSetTags(final int number) { public List<DistributionSetTag> createDistributionSetTags(final int number) {
final List<TagCreate> result = Lists.newArrayListWithExpectedSize(number); final List<TagCreate> result = new ArrayList<>(number);
for (int i = 0; i < number; i++) { for (int i = 0; i < number; i++) {
result.add( result.add(
@@ -1450,7 +1448,7 @@ public class TestdataFactory {
* @return persisted {@link TargetType} * @return persisted {@link TargetType}
*/ */
public List<TargetType> createTargetTypes(final String targetTypePrefix, final int count) { public List<TargetType> createTargetTypes(final String targetTypePrefix, final int count) {
final List<TargetTypeCreate> result = Lists.newArrayListWithExpectedSize(count); final List<TargetTypeCreate> result = new ArrayList<>(count);
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
result.add(entityFactory.targetType().create() result.add(entityFactory.targetType().create()
.name(targetTypePrefix + i).description(targetTypePrefix + " description") .name(targetTypePrefix + i).description(targetTypePrefix + " description")

View File

@@ -64,10 +64,5 @@
<artifactId>allure-junit5</artifactId> <artifactId>allure-junit5</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@@ -13,11 +13,11 @@ package org.eclipse.hawkbit.ddi.json.model;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import java.io.IOException; import java.io.IOException;
import java.util.Set;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.google.common.collect.ImmutableSet;
import com.google.common.reflect.ClassPath; import com.google.common.reflect.ClassPath;
import io.qameta.allure.Description; import io.qameta.allure.Description;
@@ -37,7 +37,7 @@ public class JsonIgnorePropertiesAnnotationTest {
final ClassLoader loader = Thread.currentThread().getContextClassLoader(); final ClassLoader loader = Thread.currentThread().getContextClassLoader();
final String packageName = this.getClass().getPackage().getName(); final String packageName = this.getClass().getPackage().getName();
final ImmutableSet<ClassPath.ClassInfo> topLevelClasses = ClassPath.from(loader) final Set<ClassPath.ClassInfo> topLevelClasses = ClassPath.from(loader)
.getTopLevelClasses(packageName); .getTopLevelClasses(packageName);
for (final ClassPath.ClassInfo classInfo : topLevelClasses) { for (final ClassPath.ClassInfo classInfo : topLevelClasses) {
final Class<?> modelClass = classInfo.load(); final Class<?> modelClass = classInfo.load();

View File

@@ -41,10 +41,6 @@
<groupId>org.springframework.plugin</groupId> <groupId>org.springframework.plugin</groupId>
<artifactId>spring-plugin-core</artifactId> <artifactId>spring-plugin-core</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency> <dependency>
<groupId>jakarta.servlet</groupId> <groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId> <artifactId>jakarta.servlet-api</artifactId>

View File

@@ -44,12 +44,10 @@ import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.event.EventListener; import org.springframework.context.event.EventListener;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MvcResult; import org.springframework.test.web.servlet.MvcResult;
import com.google.common.base.Charsets;
import com.google.common.net.HttpHeaders;
import io.qameta.allure.Description; import io.qameta.allure.Description;
import io.qameta.allure.Feature; import io.qameta.allure.Feature;
import io.qameta.allure.Story; import io.qameta.allure.Story;
@@ -225,7 +223,7 @@ public class DdiArtifactDownloadTest extends AbstractDDiApiIntegrationTest {
.andReturn(); .andReturn();
assertThat(result.getResponse().getContentAsByteArray()) assertThat(result.getResponse().getContentAsByteArray())
.isEqualTo((artifact.getMd5Hash() + " " + artifact.getFilename()).getBytes(Charsets.US_ASCII)); .isEqualTo((artifact.getMd5Hash() + " " + artifact.getFilename()).getBytes(StandardCharsets.US_ASCII));
} }
@Test @Test

View File

@@ -40,8 +40,6 @@ import org.springframework.hateoas.MediaTypes;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ActiveProfiles;
import com.google.common.collect.Maps;
import io.qameta.allure.Description; import io.qameta.allure.Description;
import io.qameta.allure.Feature; import io.qameta.allure.Feature;
import io.qameta.allure.Step; import io.qameta.allure.Step;
@@ -99,7 +97,7 @@ class DdiConfigDataTest extends AbstractDDiApiIntegrationTest {
.getLastTargetQuery()) .getLastTargetQuery())
.isGreaterThanOrEqualTo(current); .isGreaterThanOrEqualTo(current);
final Map<String, String> attributes = Maps.newHashMapWithExpectedSize(1); final Map<String, String> attributes = new HashMap<>(1);
attributes.put("dsafsdf", "sdsds"); attributes.put("dsafsdf", "sdsds");
final Target updateControllerAttributes = controllerManagement final Target updateControllerAttributes = controllerManagement

View File

@@ -21,6 +21,7 @@ import org.eclipse.hawkbit.repository.model.Action;
import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.security.DosFilter; import org.eclipse.hawkbit.security.DosFilter;
import org.eclipse.hawkbit.security.HawkbitSecurityProperties;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
@@ -29,8 +30,6 @@ import org.springframework.test.web.servlet.MvcResult;
import org.springframework.test.web.servlet.setup.DefaultMockMvcBuilder; import org.springframework.test.web.servlet.setup.DefaultMockMvcBuilder;
import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.WebApplicationContext;
import com.google.common.net.HttpHeaders;
import io.qameta.allure.Description; import io.qameta.allure.Description;
import io.qameta.allure.Feature; import io.qameta.allure.Feature;
import io.qameta.allure.Story; import io.qameta.allure.Story;
@@ -44,6 +43,8 @@ import io.qameta.allure.Story;
@Story("Denial of Service protection filter") @Story("Denial of Service protection filter")
class DosFilterTest extends AbstractDDiApiIntegrationTest { class DosFilterTest extends AbstractDDiApiIntegrationTest {
private static final String X_FORWARDED_FOR = HawkbitSecurityProperties.Clients.X_FORWARDED_FOR;
@Override @Override
protected DefaultMockMvcBuilder createMvcWebAppContext(final WebApplicationContext context) { protected DefaultMockMvcBuilder createMvcWebAppContext(final WebApplicationContext context) {
return super.createMvcWebAppContext(context).addFilter( return super.createMvcWebAppContext(context).addFilter(
@@ -56,7 +57,7 @@ class DosFilterTest extends AbstractDDiApiIntegrationTest {
@Description("Ensures that clients that are on the blacklist are forbidden") @Description("Ensures that clients that are on the blacklist are forbidden")
void blackListedClientIsForbidden() throws Exception { void blackListedClientIsForbidden() throws Exception {
mvc.perform(get("/{tenant}/controller/v1/4711", tenantAware.getCurrentTenant()) mvc.perform(get("/{tenant}/controller/v1/4711", tenantAware.getCurrentTenant())
.header(HttpHeaders.X_FORWARDED_FOR, "192.168.0.4 , 10.0.0.1 ")).andExpect(status().isForbidden()); .header(X_FORWARDED_FOR, "192.168.0.4 , 10.0.0.1 ")).andExpect(status().isForbidden());
} }
@Test @Test
@@ -68,7 +69,7 @@ class DosFilterTest extends AbstractDDiApiIntegrationTest {
int requests = 0; int requests = 0;
do { do {
result = mvc.perform(get("/{tenant}/controller/v1/4711", tenantAware.getCurrentTenant()) result = mvc.perform(get("/{tenant}/controller/v1/4711", tenantAware.getCurrentTenant())
.header(HttpHeaders.X_FORWARDED_FOR, "10.0.0.1")).andReturn(); .header(X_FORWARDED_FOR, "10.0.0.1")).andReturn();
requests++; requests++;
// we give up after 1.000 requests // we give up after 1.000 requests
@@ -84,7 +85,7 @@ class DosFilterTest extends AbstractDDiApiIntegrationTest {
void unacceptableGetLoadButOnWhitelistIPv4() throws Exception { void unacceptableGetLoadButOnWhitelistIPv4() throws Exception {
for (int i = 0; i < 100; i++) { for (int i = 0; i < 100; i++) {
mvc.perform(get("/{tenant}/controller/v1/4711", tenantAware.getCurrentTenant()) mvc.perform(get("/{tenant}/controller/v1/4711", tenantAware.getCurrentTenant())
.header(HttpHeaders.X_FORWARDED_FOR, "127.0.0.1")).andExpect(status().isOk()); .header(X_FORWARDED_FOR, "127.0.0.1")).andExpect(status().isOk());
} }
} }
@@ -93,7 +94,7 @@ class DosFilterTest extends AbstractDDiApiIntegrationTest {
void unacceptableGetLoadButOnWhitelistIPv6() throws Exception { void unacceptableGetLoadButOnWhitelistIPv6() throws Exception {
for (int i = 0; i < 100; i++) { for (int i = 0; i < 100; i++) {
mvc.perform(get("/{tenant}/controller/v1/4711", tenantAware.getCurrentTenant()) mvc.perform(get("/{tenant}/controller/v1/4711", tenantAware.getCurrentTenant())
.header(HttpHeaders.X_FORWARDED_FOR, "0:0:0:0:0:0:0:1")).andExpect(status().isOk()); .header(X_FORWARDED_FOR, "0:0:0:0:0:0:0:1")).andExpect(status().isOk());
} }
} }
@@ -107,7 +108,7 @@ class DosFilterTest extends AbstractDDiApiIntegrationTest {
Thread.sleep(1100); Thread.sleep(1100);
for (int i = 0; i < 9; i++) { for (int i = 0; i < 9; i++) {
mvc.perform(get("/{tenant}/controller/v1/4711", tenantAware.getCurrentTenant()) mvc.perform(get("/{tenant}/controller/v1/4711", tenantAware.getCurrentTenant())
.header(HttpHeaders.X_FORWARDED_FOR, "10.0.0.1")).andExpect(status().isOk()); .header(X_FORWARDED_FOR, "10.0.0.1")).andExpect(status().isOk());
} }
} }
} }
@@ -122,7 +123,7 @@ class DosFilterTest extends AbstractDDiApiIntegrationTest {
int requests = 0; int requests = 0;
do { do {
result = mvc.perform(post("/{tenant}/controller/v1/4711/deploymentBase/" + actionId + "/feedback", result = mvc.perform(post("/{tenant}/controller/v1/4711/deploymentBase/" + actionId + "/feedback",
tenantAware.getCurrentTenant()).header(HttpHeaders.X_FORWARDED_FOR, "10.0.0.1").content(feedback) tenantAware.getCurrentTenant()).header(X_FORWARDED_FOR, "10.0.0.1").content(feedback)
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
.andReturn(); .andReturn();
requests++; requests++;
@@ -149,7 +150,7 @@ class DosFilterTest extends AbstractDDiApiIntegrationTest {
for (int i = 0; i < 9; i++) { for (int i = 0; i < 9; i++) {
mvc.perform(post("/{tenant}/controller/v1/4711/deploymentBase/" + actionId + "/feedback", mvc.perform(post("/{tenant}/controller/v1/4711/deploymentBase/" + actionId + "/feedback",
tenantAware.getCurrentTenant()).header(HttpHeaders.X_FORWARDED_FOR, "10.0.0.1") tenantAware.getCurrentTenant()).header(X_FORWARDED_FOR, "10.0.0.1")
.content(feedback).contentType(MediaType.APPLICATION_JSON) .content(feedback).contentType(MediaType.APPLICATION_JSON)
.accept(MediaType.APPLICATION_JSON)) .accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk()); .andExpect(status().isOk());

View File

@@ -21,7 +21,6 @@
<artifactId>hawkbit-mgmt-resource</artifactId> <artifactId>hawkbit-mgmt-resource</artifactId>
<name>hawkBit :: REST :: Management Resources</name> <name>hawkBit :: REST :: Management Resources</name>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.eclipse.hawkbit</groupId> <groupId>org.eclipse.hawkbit</groupId>
@@ -42,10 +41,6 @@
<groupId>org.springframework.plugin</groupId> <groupId>org.springframework.plugin</groupId>
<artifactId>spring-plugin-core</artifactId> <artifactId>spring-plugin-core</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId> <artifactId>spring-context</artifactId>

View File

@@ -11,7 +11,7 @@ package org.eclipse.hawkbit.mgmt.rest.resource;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions; import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
@@ -24,7 +24,6 @@ import org.eclipse.hawkbit.repository.report.model.SystemUsageReportWithTenants;
import org.eclipse.hawkbit.repository.report.model.TenantUsage; import org.eclipse.hawkbit.repository.report.model.TenantUsage;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager; import org.springframework.cache.CacheManager;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
@@ -106,7 +105,10 @@ public class MgmtSystemManagementResource implements MgmtSystemManagementRestApi
public ResponseEntity<Collection<MgmtSystemCache>> getCaches() { public ResponseEntity<Collection<MgmtSystemCache>> getCaches() {
final Collection<String> cacheNames = cacheManager.getCacheNames(); final Collection<String> cacheNames = cacheManager.getCacheNames();
return ResponseEntity return ResponseEntity
.ok(cacheNames.stream().map(cacheManager::getCache).map(this::cacheRest).collect(Collectors.toList())); .ok(cacheNames.stream().map(cacheManager::getCache)
.filter(Objects::nonNull)
.map(cache -> new MgmtSystemCache(cache.getName(), Collections.emptyList()))
.collect(Collectors.toList()));
} }
/** /**
@@ -122,21 +124,4 @@ public class MgmtSystemManagementResource implements MgmtSystemManagementRestApi
cacheNames.forEach(cacheName -> cacheManager.getCache(cacheName).clear()); cacheNames.forEach(cacheName -> cacheManager.getCache(cacheName).clear());
return ResponseEntity.ok(cacheNames); return ResponseEntity.ok(cacheNames);
} }
private MgmtSystemCache cacheRest(final Cache cache) {
final Object nativeCache = cache.getNativeCache();
if (nativeCache instanceof com.google.common.cache.Cache) {
return guavaCache(cache, nativeCache);
} else {
return new MgmtSystemCache(cache.getName(), Collections.emptyList());
}
}
@SuppressWarnings("unchecked")
private MgmtSystemCache guavaCache(final Cache cache, final Object nativeCache) {
final com.google.common.cache.Cache<Object, Object> guavaCache = (com.google.common.cache.Cache<Object, Object>) nativeCache;
final List<String> keys = guavaCache.asMap().keySet().stream().map(key -> key.toString())
.collect(Collectors.toList());
return new MgmtSystemCache(cache.getName(), keys);
}
} }

View File

@@ -27,6 +27,7 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
@@ -72,8 +73,6 @@ import org.springframework.hateoas.MediaTypes;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MvcResult; import org.springframework.test.web.servlet.MvcResult;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.jayway.jsonpath.JsonPath; import com.jayway.jsonpath.JsonPath;
import io.qameta.allure.Description; import io.qameta.allure.Description;
@@ -218,7 +217,7 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
// verify quota enforcement // verify quota enforcement
final int maxSoftwareModules = quotaManagement.getMaxSoftwareModulesPerDistributionSet(); final int maxSoftwareModules = quotaManagement.getMaxSoftwareModulesPerDistributionSet();
final List<Long> moduleIDs = Lists.newArrayList(); final List<Long> moduleIDs = new ArrayList<>();
for (int i = 0; i < maxSoftwareModules + 1; ++i) { for (int i = 0; i < maxSoftwareModules + 1; ++i) {
moduleIDs.add(testdataFactory.createSoftwareModuleApp("sm" + i).getId()); moduleIDs.add(testdataFactory.createSoftwareModuleApp("sm" + i).getId());
} }
@@ -1271,8 +1270,7 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
final String knownValuePrefix = "knownValue"; final String knownValuePrefix = "knownValue";
final DistributionSet testDS = testdataFactory.createDistributionSet("one"); final DistributionSet testDS = testdataFactory.createDistributionSet("one");
for (int index = 0; index < totalMetadata; index++) { for (int index = 0; index < totalMetadata; index++) {
distributionSetManagement.createMetaData(testDS.getId(), Lists distributionSetManagement.createMetaData(testDS.getId(), List.of(entityFactory.generateDsMetadata(knownKeyPrefix + index, knownValuePrefix + index)));
.newArrayList(entityFactory.generateDsMetadata(knownKeyPrefix + index, knownValuePrefix + index)));
} }
mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/metadata", mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/{distributionSetId}/metadata",
@@ -1383,7 +1381,7 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
private Set<DistributionSet> createDistributionSetsAlphabetical(final int amount) { private Set<DistributionSet> createDistributionSetsAlphabetical(final int amount) {
char character = 'a'; char character = 'a';
final Set<DistributionSet> created = Sets.newHashSetWithExpectedSize(amount); final Set<DistributionSet> created = new HashSet<>(amount);
for (int index = 0; index < amount; index++) { for (int index = 0; index < amount; index++) {
final String str = String.valueOf(character); final String str = String.valueOf(character);
created.add(testdataFactory.createDistributionSet(str)); created.add(testdataFactory.createDistributionSet(str));

View File

@@ -23,6 +23,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@@ -256,7 +257,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
// create software module types // create software module types
final int maxSoftwareModuleTypes = quotaManagement.getMaxSoftwareModuleTypesPerDistributionSetType(); final int maxSoftwareModuleTypes = quotaManagement.getMaxSoftwareModuleTypesPerDistributionSetType();
final List<Long> moduleTypeIds = Lists.newArrayList(); final List<Long> moduleTypeIds = new ArrayList<>();
for (int i = 0; i < maxSoftwareModuleTypes + 1; ++i) { for (int i = 0; i < maxSoftwareModuleTypes + 1; ++i) {
final SoftwareModuleTypeCreate smCreate = entityFactory.softwareModuleType().create().name("smType_" + i) final SoftwareModuleTypeCreate smCreate = entityFactory.softwareModuleType().create().name("smType_" + i)
.description("smType_" + i).maxAssignments(1).colour("blue").key("smType_" + i); .description("smType_" + i).maxAssignments(1).colour("blue").key("smType_" + i);

View File

@@ -44,7 +44,6 @@ import java.util.stream.Stream;
import jakarta.validation.ConstraintViolationException; import jakarta.validation.ConstraintViolationException;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.Lists;
import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.lang3.RandomStringUtils;
import org.awaitility.Awaitility; import org.awaitility.Awaitility;
import org.eclipse.hawkbit.exception.SpServerError; import org.eclipse.hawkbit.exception.SpServerError;
@@ -2014,7 +2013,7 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest {
final String knownValuePrefix = "knownValue"; final String knownValuePrefix = "knownValue";
final Target testTarget = testdataFactory.createTarget("targetId"); final Target testTarget = testdataFactory.createTarget("targetId");
for (int index = 0; index < totalMetadata; index++) { for (int index = 0; index < totalMetadata; index++) {
targetManagement.createMetaData(testTarget.getControllerId(), Lists.newArrayList( targetManagement.createMetaData(testTarget.getControllerId(), List.of(
entityFactory.generateTargetMetadata(knownKeyPrefix + index, knownValuePrefix + index))); entityFactory.generateTargetMetadata(knownKeyPrefix + index, knownValuePrefix + index)));
} }

View File

@@ -544,7 +544,7 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest {
// create distribution set types // create distribution set types
final int maxDistributionSetTypes = quotaManagement.getMaxDistributionSetTypesPerTargetType(); final int maxDistributionSetTypes = quotaManagement.getMaxDistributionSetTypesPerTargetType();
final List<Long> dsTypeIds = Lists.newArrayList(); final List<Long> dsTypeIds = new ArrayList<>();
for (int i = 0; i < maxDistributionSetTypes + 1; ++i) { for (int i = 0; i < maxDistributionSetTypes + 1; ++i) {
final DistributionSetType ds = testdataFactory.findOrCreateDistributionSetType("dsType_" + i, final DistributionSetType ds = testdataFactory.findOrCreateDistributionSetType("dsType_" + i,
"dsType_" + i); "dsType_" + i);

View File

@@ -27,10 +27,6 @@
<artifactId>hawkbit-core</artifactId> <artifactId>hawkbit-core</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.apache.commons</groupId> <groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId> <artifactId>commons-lang3</artifactId>

View File

@@ -34,8 +34,6 @@ import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.method.annotation.HandlerMethodValidationException; import org.springframework.web.method.annotation.HandlerMethodValidationException;
import org.springframework.web.multipart.MultipartException; import org.springframework.web.multipart.MultipartException;
import com.google.common.collect.Iterables;
/** /**
* General controller advice for exception handling. * General controller advice for exception handling.
*/ */
@@ -247,7 +245,7 @@ public class ResponseExceptionHandler {
logRequest(request, ex); logRequest(request, ex);
final List<Throwable> throwables = ExceptionUtils.getThrowableList(ex); final List<Throwable> throwables = ExceptionUtils.getThrowableList(ex);
final Throwable responseCause = Iterables.getLast(throwables); final Throwable responseCause = throwables.get(throwables.size() - 1);
if (responseCause.getMessage().isEmpty()) { if (responseCause.getMessage().isEmpty()) {
LOG.warn("Request {} lead to MultipartException without root cause message:\n{}", request.getRequestURL(), LOG.warn("Request {} lead to MultipartException without root cause message:\n{}", request.getRequestURL(),

View File

@@ -18,11 +18,13 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import jakarta.servlet.ServletOutputStream; import jakarta.servlet.ServletOutputStream;
import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import org.apache.commons.io.IOUtils;
import org.eclipse.hawkbit.artifact.repository.model.DbArtifact; import org.eclipse.hawkbit.artifact.repository.model.DbArtifact;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -31,10 +33,6 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import com.google.common.base.Preconditions;
import com.google.common.io.ByteStreams;
import com.google.common.math.DoubleMath;
/** /**
* Utility class for artifact file streaming. * Utility class for artifact file streaming.
*/ */
@@ -138,7 +136,7 @@ public final class FileStreamingUtil {
// set the x-content-type options header to prevent browsers from doing // set the x-content-type options header to prevent browsers from doing
// MIME-sniffing when downloading an artifact, as this could cause a // MIME-sniffing when downloading an artifact, as this could cause a
// security vulnerability // security vulnerability
response.setHeader(com.google.common.net.HttpHeaders.X_CONTENT_TYPE_OPTIONS, "nosniff"); response.setHeader("X-Content-Type-Options", "nosniff");
if (lastModified > 0) { if (lastModified > 0) {
response.setDateHeader(HttpHeaders.LAST_MODIFIED, lastModified); response.setDateHeader(HttpHeaders.LAST_MODIFIED, lastModified);
} }
@@ -334,13 +332,13 @@ public final class FileStreamingUtil {
final long startMillis = System.currentTimeMillis(); final long startMillis = System.currentTimeMillis();
LOG.trace("Start of copy-streams of file {} from {} to {}", filename, start, length); LOG.trace("Start of copy-streams of file {} from {} to {}", filename, start, length);
Preconditions.checkNotNull(from); Objects.requireNonNull(from);
Preconditions.checkNotNull(to); Objects.requireNonNull(to);
final byte[] buf = new byte[BUFFER_SIZE]; final byte[] buf = new byte[BUFFER_SIZE];
long total = 0; long total = 0;
int progressPercent = 1; int progressPercent = 1;
ByteStreams.skipFully(from, start); IOUtils.skipFully(from, start);
long toRead = length; long toRead = length;
boolean toContinue = true; boolean toContinue = true;
@@ -365,7 +363,7 @@ public final class FileStreamingUtil {
} }
if (progressListener != null) { if (progressListener != null) {
final int newPercent = DoubleMath.roundToInt(total * 100.0 / length, RoundingMode.DOWN); final int newPercent = (int)Math.floor(total * 100.0 / length);
// every 10 percent an event // every 10 percent an event
if (newPercent == 100 || newPercent > progressPercent + 10) { if (newPercent == 100 || newPercent > progressPercent + 10) {

View File

@@ -9,7 +9,6 @@
*/ */
package org.eclipse.hawkbit.ui.simple.view.util; package org.eclipse.hawkbit.ui.simple.view.util;
import com.google.common.collect.Streams;
import com.vaadin.flow.component.grid.Grid; import com.vaadin.flow.component.grid.Grid;
import com.vaadin.flow.component.grid.GridVariant; import com.vaadin.flow.component.grid.GridVariant;
import com.vaadin.flow.data.provider.Query; import com.vaadin.flow.data.provider.Query;
@@ -55,7 +54,7 @@ public class SelectionGrid<T,ID> extends Grid<T> {
// if matching keeps old entries instead of new the new ones in order to // if matching keeps old entries instead of new the new ones in order to
// select them in case refresh is made with keepSelection // select them in case refresh is made with keepSelection
// this however means that if they are changed the old state will be shown!!! // this however means that if they are changed the old state will be shown!!!
return Streams.concat(selected.stream(), return Stream.concat(selected.stream(),
fetch.filter(next -> !selectedIds.contains(entityRepresentation.idFn.apply(next)))); fetch.filter(next -> !selectedIds.contains(entityRepresentation.idFn.apply(next))));
} }
}); });

View File

@@ -68,11 +68,5 @@
<artifactId>allure-junit5</artifactId> <artifactId>allure-junit5</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@@ -183,6 +183,8 @@ public class HawkbitSecurityProperties {
*/ */
public static class Clients { public static class Clients {
public static final String X_FORWARDED_FOR = "X-Forwarded-For";
/** /**
* Blacklisted client (IP addresses) for for DDI and Management API. * Blacklisted client (IP addresses) for for DDI and Management API.
*/ */
@@ -191,7 +193,7 @@ public class HawkbitSecurityProperties {
/** /**
* Name of the http header from which the remote ip is extracted. * Name of the http header from which the remote ip is extracted.
*/ */
private String remoteIpHeader = "X-Forwarded-For"; private String remoteIpHeader = X_FORWARDED_FOR;
/** /**
* Set to <code>true</code> if DDI clients remote IP should be stored. * Set to <code>true</code> if DDI clients remote IP should be stored.

View File

@@ -9,7 +9,6 @@
*/ */
package org.eclipse.hawkbit.util; package org.eclipse.hawkbit.util;
import static com.google.common.net.HttpHeaders.X_FORWARDED_FOR;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.reset; import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.times; import static org.mockito.Mockito.times;
@@ -37,6 +36,7 @@ import org.mockito.junit.jupiter.MockitoExtension;
@Story("IP Util Test") @Story("IP Util Test")
public class IpUtilTest { public class IpUtilTest {
private static final String X_FORWARDED_FOR = HawkbitSecurityProperties.Clients.X_FORWARDED_FOR;
private static final String KNOWN_REQUEST_HEADER = "bumlux"; private static final String KNOWN_REQUEST_HEADER = "bumlux";
@Mock @Mock

64
pom.xml
View File

@@ -757,38 +757,6 @@
<version>${spring-amqp.version}</version> <version>${spring-amqp.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>${guava.version}</version>
<!-- https://github.com/google/guava/issues/2824 -->
<exclusions>
<exclusion>
<groupId>com.google.j2objc</groupId>
<artifactId>j2objc-annotations</artifactId>
</exclusion>
<exclusion>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
</exclusion>
<exclusion>
<groupId>org.checkerframework</groupId>
<artifactId>checker-compat-qual</artifactId>
</exclusion>
<exclusion>
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_annotations</artifactId>
</exclusion>
<exclusion>
<groupId>com.google.j2objc</groupId>
<artifactId>j2objc-annotations</artifactId>
</exclusion>
<exclusion>
<groupId>org.codehaus.mojo</groupId>
<artifactId>animal-sniffer-annotations</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency> <dependency>
<groupId>org.awaitility</groupId> <groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId> <artifactId>awaitility</artifactId>
@@ -803,5 +771,37 @@
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>${guava.version}</version>
<!-- https://github.com/google/guava/issues/2824 -->
<exclusions>
<exclusion>
<groupId>com.google.j2objc</groupId>
<artifactId>j2objc-annotations</artifactId>
</exclusion>
<exclusion>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
</exclusion>
<exclusion>
<groupId>org.checkerframework</groupId>
<artifactId>checker-compat-qual</artifactId>
</exclusion>
<exclusion>
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_annotations</artifactId>
</exclusion>
<exclusion>
<groupId>com.google.j2objc</groupId>
<artifactId>j2objc-annotations</artifactId>
</exclusion>
<exclusion>
<groupId>org.codehaus.mojo</groupId>
<artifactId>animal-sniffer-annotations</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies> </dependencies>
</project> </project>