Reduce dependency on Guava (#1589)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -88,10 +88,5 @@
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
||||
@@ -14,18 +14,16 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.google.common.reflect.ClassPath;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
||||
import com.google.common.reflect.ClassPath;
|
||||
|
||||
import io.qameta.allure.Description;
|
||||
import io.qameta.allure.Feature;
|
||||
import io.qameta.allure.Story;
|
||||
@@ -42,8 +40,7 @@ public class RepositoryManagementMethodPreAuthorizeAnnotatedTest {
|
||||
|
||||
@Test
|
||||
@Description("Verifies that repository methods are @PreAuthorize annotated")
|
||||
public void repositoryManagementMethodsArePreAuthorizedAnnotated()
|
||||
throws ClassNotFoundException, URISyntaxException, IOException {
|
||||
public void repositoryManagementMethodsArePreAuthorizedAnnotated() throws IOException {
|
||||
final List<Class<?>> findInterfacesInPackage = findInterfacesInPackage(getClass().getPackage(),
|
||||
Pattern.compile(".*Management"));
|
||||
|
||||
@@ -81,8 +78,7 @@ public class RepositoryManagementMethodPreAuthorizeAnnotatedTest {
|
||||
}
|
||||
}
|
||||
|
||||
private List<Class<?>> findInterfacesInPackage(final Package p, final Pattern includeFilter)
|
||||
throws URISyntaxException, IOException, ClassNotFoundException {
|
||||
private List<Class<?>> findInterfacesInPackage(final Package p, final Pattern includeFilter) throws IOException {
|
||||
return ClassPath.from(Thread.currentThread().getContextClassLoader()).getTopLevelClasses(p.getName()).stream()
|
||||
.filter(clazzInfo -> includeFilter.matcher(clazzInfo.getSimpleName()).matches())
|
||||
.map(clazzInfo -> clazzInfo.load()).filter(clazz -> clazz.isInterface()).collect(Collectors.toList());
|
||||
|
||||
@@ -29,10 +29,6 @@
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.ben-manes.caffeine</groupId>
|
||||
<artifactId>caffeine</artifactId>
|
||||
|
||||
@@ -69,10 +69,6 @@
|
||||
<groupId>cz.jirutka.rsql</groupId>
|
||||
<artifactId>rsql-parser</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jsoup</groupId>
|
||||
<artifactId>jsoup</artifactId>
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.jpa;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
@@ -198,8 +199,6 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
import org.springframework.transaction.jta.JtaTransactionManager;
|
||||
import org.springframework.validation.beanvalidation.MethodValidationPostProcessor;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
/**
|
||||
* General configuration for hawkBit's Repository.
|
||||
*
|
||||
@@ -483,7 +482,7 @@ public class RepositoryApplicationConfiguration extends JpaBaseConfiguration {
|
||||
@Override
|
||||
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
|
||||
properties.put(PersistenceUnitProperties.WEAVING, "false");
|
||||
// needed for reports
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.jpa.aspects;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -29,9 +31,6 @@ import org.springframework.dao.OptimisticLockingFailureException;
|
||||
import org.springframework.security.access.AccessDeniedException;
|
||||
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
|
||||
* 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 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
|
||||
* most specific mappable exception according to the type hierarchy of the
|
||||
* exception.
|
||||
*/
|
||||
private static final List<Class<?>> MAPPED_EXCEPTION_ORDER = Lists.newArrayListWithExpectedSize(4);
|
||||
private static final List<Class<?>> MAPPED_EXCEPTION_ORDER = new ArrayList<>(4);
|
||||
|
||||
static {
|
||||
|
||||
|
||||
@@ -21,6 +21,8 @@ import java.time.temporal.ChronoUnit;
|
||||
import java.time.temporal.TemporalUnit;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
@@ -31,6 +33,7 @@ import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.Query;
|
||||
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||
@@ -111,10 +114,6 @@ import org.springframework.transaction.support.TransactionCallback;
|
||||
import org.springframework.util.StringUtils;
|
||||
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.
|
||||
*
|
||||
@@ -450,7 +449,7 @@ public class JpaControllerManagement extends JpaActionManagement implements Cont
|
||||
|
||||
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);
|
||||
|
||||
if (drained <= 0) {
|
||||
@@ -494,7 +493,7 @@ public class JpaControllerManagement extends JpaActionManagement implements Cont
|
||||
* itself.
|
||||
*/
|
||||
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++) {
|
||||
paramMapping.put("cid" + i, chunk.get(i));
|
||||
|
||||
@@ -28,6 +28,7 @@ import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.Query;
|
||||
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||
@@ -111,8 +112,6 @@ import org.springframework.transaction.annotation.Isolation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
/**
|
||||
* JPA implementation for {@link DeploymentManagement}.
|
||||
*
|
||||
|
||||
@@ -89,8 +89,6 @@ import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
/**
|
||||
* JPA implementation of {@link DistributionSetManagement}.
|
||||
*
|
||||
@@ -600,7 +598,7 @@ public class JpaDistributionSetManagement implements DistributionSetManagement {
|
||||
|
||||
private static List<Specification<JpaDistributionSet>> buildDistributionSetSpecifications(
|
||||
final DistributionSetFilter distributionSetFilter) {
|
||||
final List<Specification<JpaDistributionSet>> specList = Lists.newArrayListWithExpectedSize(10);
|
||||
final List<Specification<JpaDistributionSet>> specList = new ArrayList<>(10);
|
||||
|
||||
Specification<JpaDistributionSet> spec;
|
||||
|
||||
|
||||
@@ -93,8 +93,6 @@ import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.concurrent.ListenableFuture;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
/**
|
||||
* JPA implementation of {@link RolloutManagement}.
|
||||
*/
|
||||
@@ -171,7 +169,7 @@ public class JpaRolloutManagement implements RolloutManagement {
|
||||
|
||||
@Override
|
||||
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(
|
||||
RSQLUtility.buildRsqlSpecification(rsqlParam, RolloutFields.class, virtualPropertyReplacer, database));
|
||||
specList.add(RolloutSpecification.isDeletedWithDistributionSet(deleted, pageable.getSort()));
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.jpa.management;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
@@ -63,8 +64,6 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import cz.jirutka.rsql.parser.RSQLParserException;
|
||||
|
||||
/**
|
||||
@@ -212,7 +211,7 @@ public class JpaTargetFilterQueryManagement implements TargetFilterQueryManageme
|
||||
final String rsqlFilter) {
|
||||
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));
|
||||
if (!ObjectUtils.isEmpty(rsqlFilter)) {
|
||||
specList.add(RSQLUtility.buildRsqlSpecification(rsqlFilter, TargetFilterQueryFields.class,
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||
import jakarta.persistence.criteria.CriteriaQuery;
|
||||
@@ -94,8 +95,6 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import static org.eclipse.hawkbit.repository.jpa.JpaManagementHelper.combineWithAnd;
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,6 +17,7 @@ import java.util.function.BooleanSupplier;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.eclipse.hawkbit.repository.QuotaManagement;
|
||||
import org.eclipse.hawkbit.repository.RepositoryConstants;
|
||||
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.helper.EventPublisherHolder;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
/**
|
||||
* AbstractDsAssignmentStrategy for offline assignments, i.e. not managed by
|
||||
* hawkBit.
|
||||
|
||||
@@ -18,6 +18,7 @@ import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.eclipse.hawkbit.repository.QuotaManagement;
|
||||
import org.eclipse.hawkbit.repository.RepositoryProperties;
|
||||
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.springframework.util.CollectionUtils;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
/**
|
||||
* AbstractDsAssignmentStrategy for online assignments, i.e. managed by hawkBit.
|
||||
*
|
||||
|
||||
@@ -14,6 +14,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import com.google.common.base.Splitter;
|
||||
import jakarta.persistence.CollectionTable;
|
||||
import jakarta.persistence.Column;
|
||||
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.ObjectTypeConverter;
|
||||
|
||||
import com.google.common.base.Splitter;
|
||||
|
||||
/**
|
||||
* Entity to store the status for a specific action.
|
||||
*/
|
||||
|
||||
@@ -35,7 +35,6 @@ import jakarta.persistence.criteria.Predicate;
|
||||
import jakarta.persistence.criteria.Root;
|
||||
import jakarta.persistence.criteria.Subquery;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import cz.jirutka.rsql.parser.ast.AndNode;
|
||||
import cz.jirutka.rsql.parser.ast.ComparisonNode;
|
||||
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 = '*';
|
||||
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 final Map<Integer, Set<Join<Object, Object>>> joinsInLevel = new HashMap<>(3);
|
||||
|
||||
@@ -11,6 +11,7 @@ package org.eclipse.hawkbit.repository.event.remote;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
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.databind.ObjectMapper;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
/**
|
||||
* Test the remote entity events.
|
||||
@@ -57,13 +57,13 @@ public abstract class AbstractRemoteEventTest extends AbstractJpaIntegrationTest
|
||||
}
|
||||
|
||||
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);
|
||||
return busProtoStuffMessageConverter.toMessage(event, new MutableMessageHeaders(headers));
|
||||
}
|
||||
|
||||
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);
|
||||
try {
|
||||
final String json = new ObjectMapper().writeValueAsString(event);
|
||||
@@ -76,7 +76,7 @@ public abstract class AbstractRemoteEventTest extends AbstractJpaIntegrationTest
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
@@ -9,9 +9,13 @@
|
||||
*/
|
||||
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.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.PersistenceContext;
|
||||
@@ -63,8 +67,6 @@ import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@ContextConfiguration(classes = {
|
||||
@@ -143,7 +145,7 @@ public abstract class AbstractJpaIntegrationTest extends AbstractIntegrationTest
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
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) {
|
||||
@@ -205,4 +207,17 @@ public abstract class AbstractJpaIntegrationTest extends AbstractIntegrationTest
|
||||
protected JpaRolloutGroup refresh(final RolloutGroup group) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@ import java.io.InputStream;
|
||||
import java.net.URISyntaxException;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HexFormat;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
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.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.Feature;
|
||||
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
|
||||
final long maxArtifacts = quotaManagement.getMaxArtifactsPerSoftwareModule();
|
||||
final List<Long> artifactIds = Lists.newArrayList();
|
||||
final List<Long> artifactIds = new ArrayList<>();
|
||||
final int artifactSize = 5 * 1024;
|
||||
for (int i = 0; i < maxArtifacts; ++i) {
|
||||
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
|
||||
// quota
|
||||
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
|
||||
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 {
|
||||
final MessageDigest messageDigest = MessageDigest.getInstance(algorithm);
|
||||
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)
|
||||
|
||||
@@ -86,9 +86,6 @@ import org.mockito.Mockito;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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.Feature;
|
||||
import io.qameta.allure.Step;
|
||||
@@ -156,7 +153,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
verifyThrownExceptionBy(() -> controllerManagement.registerRetrieved(NOT_EXIST_IDL, "test message"), "Action");
|
||||
|
||||
verifyThrownExceptionBy(
|
||||
() -> controllerManagement.updateControllerAttributes(NOT_EXIST_ID, Maps.newHashMap(), null), "Target");
|
||||
() -> controllerManagement.updateControllerAttributes(NOT_EXIST_ID, new HashMap<>(), null), "Target");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -973,7 +970,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
@Step
|
||||
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");
|
||||
controllerManagement.updateControllerAttributes(controllerId, testData, null);
|
||||
|
||||
@@ -983,7 +980,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
@Step
|
||||
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");
|
||||
controllerManagement.updateControllerAttributes(controllerId, testData, null);
|
||||
|
||||
@@ -994,7 +991,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
@Step
|
||||
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");
|
||||
|
||||
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,
|
||||
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++) {
|
||||
testData.put(keyPrefix + i, valuePrefix);
|
||||
}
|
||||
@@ -1212,13 +1209,13 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
controllerManagement.addUpdateActionStatus(entityFactory.actionStatus().create(actionId)
|
||||
.status(Action.Status.RUNNING).occurredAt(System.currentTimeMillis())
|
||||
.messages(Lists.newArrayList("proceeding message 1")));
|
||||
.messages(List.of("proceeding message 1")));
|
||||
|
||||
final long createTime = System.currentTimeMillis();
|
||||
waitNextMillis();
|
||||
controllerManagement.addUpdateActionStatus(entityFactory.actionStatus().create(actionId)
|
||||
.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);
|
||||
|
||||
@@ -1279,7 +1276,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest {
|
||||
assignDistributionSet(testdataFactory.createDistributionSet("ds1"), testdataFactory.createTargets(1)));
|
||||
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"));
|
||||
|
||||
assertThat(controllerManagement.addInformationalActionStatus(
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
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.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.Feature;
|
||||
import io.qameta.allure.Story;
|
||||
@@ -259,7 +256,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Test
|
||||
@Description("Ensures that tag to distribution set assignment that does not exist will cause EntityNotFoundException.")
|
||||
void assignDistributionSetToTagThatDoesNotExistThrowsException() {
|
||||
final List<Long> assignDS = Lists.newArrayListWithExpectedSize(5);
|
||||
final List<Long> assignDS = new ArrayList<>(5);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
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 String[] knownTargetIdsArray = { "1", "2" };
|
||||
final List<String> knownTargetIds = Lists.newArrayList(knownTargetIdsArray);
|
||||
testdataFactory.createTargets(knownTargetIdsArray);
|
||||
final List<String> knownTargetIds = new ArrayList<>();
|
||||
knownTargetIds.add( "1");
|
||||
knownTargetIds.add("2");
|
||||
testdataFactory.createTargets(knownTargetIds.toArray(new String[0]));
|
||||
|
||||
// add not existing target to targets
|
||||
knownTargetIds.add(notExistingId);
|
||||
@@ -1055,9 +1053,9 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(allFoundTargets).as("founded targets are wrong").containsAll(savedDeployedTargets)
|
||||
.containsAll(savedNakedTargets);
|
||||
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")
|
||||
.doesNotContain(Iterables.toArray(savedDeployedTargets, Target.class));
|
||||
.doesNotContain(toArray(savedDeployedTargets, Target.class));
|
||||
|
||||
for (final Target myt : savedNakedTargets) {
|
||||
final Target t = targetManagement.getByControllerID(myt.getControllerId()).get();
|
||||
@@ -1101,7 +1099,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
.isThrownBy(() -> assignDistributionSet(incomplete, targets));
|
||||
|
||||
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")
|
||||
.isEqualTo(10);
|
||||
@@ -1165,9 +1163,9 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
assertThat(deployedTargetsFromDB).as("content of deployed target is wrong")
|
||||
.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)
|
||||
.doesNotContain(Iterables.toArray(deployedTargetsFromDB, JpaTarget.class));
|
||||
.doesNotContain(toArray(deployedTargetsFromDB, JpaTarget.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1710,9 +1708,9 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest {
|
||||
final Iterable<DistributionSet> dss, final String deployedTargetPrefix,
|
||||
final String undeployedTargetPrefix, final String distributionSetPrefix) {
|
||||
|
||||
Iterables.addAll(deployedTargets, deployedTs);
|
||||
Iterables.addAll(undeployedTargets, undeployedTs);
|
||||
Iterables.addAll(distributionSets, dss);
|
||||
deployedTargets.addAll(toList(deployedTs));
|
||||
undeployedTargets.addAll(toList(undeployedTs));
|
||||
distributionSets.addAll(toList(dss));
|
||||
|
||||
deployedTargets.forEach(t -> deployedTargetIDs.add(t.getId()));
|
||||
|
||||
|
||||
@@ -18,10 +18,12 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
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.Direction;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import io.qameta.allure.Description;
|
||||
import io.qameta.allure.Feature;
|
||||
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.")
|
||||
void createMultipleDistributionSetsWithImplicitType() {
|
||||
|
||||
final List<DistributionSetCreate> creates = Lists.newArrayListWithExpectedSize(10);
|
||||
final List<DistributionSetCreate> creates = new ArrayList<>(10);
|
||||
for (int i = 0; i < 10; i++) {
|
||||
creates.add(entityFactory.distributionSet().create().name("newtypesoft" + i).version("1" + i));
|
||||
}
|
||||
@@ -406,7 +405,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
@Test
|
||||
@Description("Ensures that distribution sets can assigned and unassigned to a distribution set tag.")
|
||||
void assignAndUnassignDistributionSetToTag() {
|
||||
final List<Long> assignDS = Lists.newArrayListWithExpectedSize(4);
|
||||
final List<Long> assignDS = new ArrayList<>(4);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
assignDS.add(testdataFactory.createDistributionSet("DS" + i, "1.0", Collections.emptyList()).getId());
|
||||
}
|
||||
@@ -450,7 +449,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
final SoftwareModule os2 = testdataFactory.createSoftwareModuleOs();
|
||||
|
||||
// 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
|
||||
assignDistributionSet(ds.getId(), target.getControllerId());
|
||||
@@ -458,7 +457,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
final Long dsId = ds.getId();
|
||||
// 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);
|
||||
|
||||
// not allowed as it is assigned now
|
||||
@@ -482,7 +481,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
// update data
|
||||
assertThatThrownBy(
|
||||
() -> distributionSetManagement.assignSoftwareModules(set.getId(), Sets.newHashSet(module.getId())))
|
||||
() -> distributionSetManagement.assignSoftwareModules(set.getId(), Set.of(module.getId())))
|
||||
.isInstanceOf(UnsupportedSoftwareModuleForThisDistributionSetException.class);
|
||||
}
|
||||
|
||||
@@ -495,7 +494,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
// update data
|
||||
// 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()));
|
||||
assertThat(getOrThrow(ds.findFirstModuleByType(osType))).isEqualTo(os);
|
||||
|
||||
@@ -531,7 +530,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
// create some software modules
|
||||
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) {
|
||||
modules.add(testdataFactory.createSoftwareModuleApp("sm" + i).getId());
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
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.junit.jupiter.api.Test;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import io.qameta.allure.Description;
|
||||
import io.qameta.allure.Feature;
|
||||
import io.qameta.allure.Step;
|
||||
@@ -206,13 +205,13 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
|
||||
|
||||
// add OS
|
||||
distributionSetTypeManagement.assignMandatorySoftwareModuleTypes(updatableType.getId(),
|
||||
Sets.newHashSet(osType.getId()));
|
||||
Set.of(osType.getId()));
|
||||
assertThat(distributionSetTypeManagement.getByKey("updatableType").get().getMandatoryModuleTypes())
|
||||
.containsOnly(osType);
|
||||
|
||||
// add JVM
|
||||
distributionSetTypeManagement.assignMandatorySoftwareModuleTypes(updatableType.getId(),
|
||||
Sets.newHashSet(runtimeType.getId()));
|
||||
Set.of(runtimeType.getId()));
|
||||
assertThat(distributionSetTypeManagement.getByKey("updatableType").get().getMandatoryModuleTypes())
|
||||
.containsOnly(osType, runtimeType);
|
||||
|
||||
@@ -228,7 +227,7 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
|
||||
|
||||
final int quota = quotaManagement.getMaxSoftwareModuleTypesPerDistributionSetType();
|
||||
// create software module types
|
||||
final List<Long> moduleTypeIds = Lists.newArrayList();
|
||||
final List<Long> moduleTypeIds = new ArrayList<>();
|
||||
for (int i = 0; i < quota + 1; ++i) {
|
||||
final SoftwareModuleTypeCreate smCreate = entityFactory.softwareModuleType().create().name("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();
|
||||
|
||||
assertThatThrownBy(() -> distributionSetTypeManagement
|
||||
.assignMandatorySoftwareModuleTypes(nonUpdatableType.getId(), Sets.newHashSet(osType.getId())))
|
||||
.assignMandatorySoftwareModuleTypes(nonUpdatableType.getId(), Set.of(osType.getId())))
|
||||
.isInstanceOf(EntityReadOnlyException.class);
|
||||
}
|
||||
|
||||
@@ -311,7 +310,7 @@ public class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTes
|
||||
assertThat(distributionSetTypeManagement.getByKey("updatableType").get().getMandatoryModuleTypes()).isEmpty();
|
||||
|
||||
nonUpdatableType = distributionSetTypeManagement.assignMandatorySoftwareModuleTypes(nonUpdatableType.getId(),
|
||||
Sets.newHashSet(osType.getId()));
|
||||
Set.of(osType.getId()));
|
||||
distributionSetManagement.create(entityFactory.distributionSet().create().name("newtypesoft").version("1")
|
||||
.type(nonUpdatableType.getKey()));
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang3.RandomUtils;
|
||||
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.jpa.AbstractJpaIntegrationTest;
|
||||
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.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.Direction;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import io.qameta.allure.Description;
|
||||
import io.qameta.allure.Feature;
|
||||
import io.qameta.allure.Story;
|
||||
@@ -309,7 +306,7 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
SoftwareModule assignedModule = createSoftwareModuleWithArtifacts(osType, "moduleX", "3.0.2", 2);
|
||||
|
||||
// [STEP2]: Assign SoftwareModule to DistributionSet
|
||||
testdataFactory.createDistributionSet(Sets.newHashSet(assignedModule));
|
||||
testdataFactory.createDistributionSet(Set.of(assignedModule));
|
||||
|
||||
// [STEP3]: Delete the assigned SoftwareModule
|
||||
softwareModuleManagement.delete(assignedModule.getId());
|
||||
@@ -345,7 +342,7 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
SoftwareModule assignedModule = createSoftwareModuleWithArtifacts(osType, "moduleX", "3.0.2", 2);
|
||||
|
||||
// [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
|
||||
assignDistributionSet(disSet, Collections.singletonList(target));
|
||||
@@ -446,11 +443,11 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
final Artifact artifactY = moduleY.getArtifacts().iterator().next();
|
||||
|
||||
// [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));
|
||||
|
||||
// [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));
|
||||
|
||||
// [STEP5]: Delete SoftwareModuleX
|
||||
@@ -549,8 +546,8 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
final SoftwareModule four = testdataFactory.createSoftwareModuleOs("e");
|
||||
|
||||
final DistributionSet set = distributionSetManagement
|
||||
.create(entityFactory.distributionSet().create().name("set").version("1").type(testDsType).modules(Lists
|
||||
.newArrayList(one.getId(), two.getId(), deleted.getId(), four.getId(), differentName.getId())));
|
||||
.create(entityFactory.distributionSet().create().name("set").version("1").type(testDsType).modules(
|
||||
List.of(one.getId(), two.getId(), deleted.getId(), four.getId(), differentName.getId())));
|
||||
softwareModuleManagement.delete(deleted.getId());
|
||||
|
||||
// with filter on name, version and module type
|
||||
@@ -610,8 +607,8 @@ public class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest {
|
||||
final SoftwareModule four = testdataFactory.createSoftwareModuleOs("e");
|
||||
|
||||
distributionSetManagement
|
||||
.create(entityFactory.distributionSet().create().name("set").version("1").type(testDsType).modules(Lists
|
||||
.newArrayList(one.getId(), two.getId(), deleted.getId(), four.getId(), differentName.getId())));
|
||||
.create(entityFactory.distributionSet().create().name("set").version("1").type(testDsType).modules(
|
||||
List.of(one.getId(), two.getId(), deleted.getId(), four.getId(), differentName.getId())));
|
||||
softwareModuleManagement.delete(deleted.getId());
|
||||
|
||||
// test
|
||||
|
||||
@@ -643,9 +643,9 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest {
|
||||
final Long[] overdueMix = { lastTargetQueryAlwaysOverdue, lastTargetQueryNotOverdue,
|
||||
lastTargetQueryAlwaysOverdue, lastTargetNull, lastTargetQueryAlwaysOverdue };
|
||||
|
||||
final List<Target> notAssigned = Lists.newArrayListWithExpectedSize(overdueMix.length);
|
||||
List<Target> targAssigned = Lists.newArrayListWithExpectedSize(overdueMix.length);
|
||||
List<Target> targInstalled = Lists.newArrayListWithExpectedSize(overdueMix.length);
|
||||
final List<Target> notAssigned = new ArrayList<>(overdueMix.length);
|
||||
List<Target> targAssigned = new ArrayList<>(overdueMix.length);
|
||||
List<Target> targInstalled = new ArrayList<>(overdueMix.length);
|
||||
|
||||
for (int i = 0; i < overdueMix.length; i++) {
|
||||
notAssigned.add(targetManagement
|
||||
|
||||
@@ -54,7 +54,6 @@ import org.eclipse.hawkbit.repository.exception.RSQLParameterUnsupportedFieldExc
|
||||
import org.eclipse.hawkbit.repository.exception.TenantNotExistException;
|
||||
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.JpaTarget;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaTargetMetadata;
|
||||
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.Slice;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
import io.qameta.allure.Description;
|
||||
import io.qameta.allure.Feature;
|
||||
import io.qameta.allure.Step;
|
||||
@@ -674,7 +671,7 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
|
||||
final int numberToDelete = 50;
|
||||
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());
|
||||
|
||||
targetManagement.delete(targetsIdsToDelete);
|
||||
@@ -708,14 +705,14 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
assertThat(targetTagManagement.findByTarget(PAGE, t11.getControllerId()).getContent()).as("Tag size is wrong")
|
||||
.hasSize(noT1Tags).containsAll(t1Tags);
|
||||
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())
|
||||
.orElseThrow(IllegalStateException::new);
|
||||
assertThat(targetTagManagement.findByTarget(PAGE, t21.getControllerId()).getContent()).as("Tag size is wrong")
|
||||
.hasSize(noT2Tags).containsAll(t2Tags);
|
||||
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
|
||||
@@ -758,16 +755,16 @@ class TargetManagementTest extends AbstractJpaIntegrationTest {
|
||||
final List<Target> targetWithTagC = new ArrayList<>();
|
||||
|
||||
// storing target lists to enable easy evaluation
|
||||
Iterables.addAll(targetWithTagA, tagATargets);
|
||||
Iterables.addAll(targetWithTagA, tagABTargets);
|
||||
Iterables.addAll(targetWithTagA, tagABCTargets);
|
||||
targetWithTagA.addAll(tagATargets);
|
||||
targetWithTagA.addAll(tagABTargets);
|
||||
targetWithTagA.addAll(tagABCTargets);
|
||||
|
||||
Iterables.addAll(targetWithTagB, tagBTargets);
|
||||
Iterables.addAll(targetWithTagB, tagABTargets);
|
||||
Iterables.addAll(targetWithTagB, tagABCTargets);
|
||||
targetWithTagB.addAll(tagBTargets);
|
||||
targetWithTagB.addAll(tagABTargets);
|
||||
targetWithTagB.addAll(tagABCTargets);
|
||||
|
||||
Iterables.addAll(targetWithTagC, tagCTargets);
|
||||
Iterables.addAll(targetWithTagC, tagABCTargets);
|
||||
targetWithTagC.addAll(tagCTargets);
|
||||
targetWithTagC.addAll(tagABCTargets);
|
||||
|
||||
// check the target lists as returned by assignTag
|
||||
checkTargetHasTags(false, targetWithTagA, tagA);
|
||||
|
||||
@@ -11,6 +11,7 @@ package org.eclipse.hawkbit.repository.jpa.rsql;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
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.PageRequest;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import io.qameta.allure.Description;
|
||||
import io.qameta.allure.Feature;
|
||||
import io.qameta.allure.Story;
|
||||
@@ -42,7 +41,7 @@ public class RSQLSoftwareModuleMetadataFieldsTest extends AbstractJpaIntegration
|
||||
|
||||
softwareModuleId = softwareModule.getId();
|
||||
|
||||
final List<SoftwareModuleMetadataCreate> metadata = Lists.newArrayListWithExpectedSize(5);
|
||||
final List<SoftwareModuleMetadataCreate> metadata = new ArrayList<>(5);
|
||||
for (int i = 0; i < 5; i++) {
|
||||
metadata.add(
|
||||
entityFactory.softwareModuleMetadata().create(softwareModule.getId()).key("" + i).value("" + i));
|
||||
|
||||
@@ -83,10 +83,6 @@
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context-support</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-tx</artifactId>
|
||||
|
||||
@@ -22,6 +22,9 @@ import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
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.core.ConditionTimeoutException;
|
||||
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.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.
|
||||
*/
|
||||
|
||||
@@ -11,12 +11,11 @@ package org.eclipse.hawkbit.repository.test.util;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.HexFormat;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.common.io.BaseEncoding;
|
||||
|
||||
/**
|
||||
* Hash digest utility.
|
||||
*/
|
||||
@@ -66,7 +65,7 @@ public final class HashGeneratorUtils {
|
||||
try {
|
||||
final MessageDigest digest = MessageDigest.getInstance(algorithm);
|
||||
final byte[] hashedBytes = digest.digest(message);
|
||||
return BaseEncoding.base16().lowerCase().encode(hashedBytes);
|
||||
return HexFormat.of().withLowerCase().formatHex(hashedBytes);
|
||||
} catch (final NoSuchAlgorithmException e) {
|
||||
LOG.error("Algorithm could not be found", e);
|
||||
}
|
||||
|
||||
@@ -81,8 +81,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
/**
|
||||
* Data generator utility for tests.
|
||||
*/
|
||||
@@ -438,7 +436,7 @@ public class TestdataFactory {
|
||||
*/
|
||||
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++) {
|
||||
sets.add(distributionSetManagement
|
||||
.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) {
|
||||
final List<TargetCreate> targets = Lists.newArrayListWithExpectedSize(number);
|
||||
final List<TargetCreate> targets = new ArrayList<>(number);
|
||||
for (int i = 0; i < number; 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,
|
||||
final TargetType targetType) {
|
||||
|
||||
final List<TargetCreate> targets = Lists.newArrayListWithExpectedSize(number);
|
||||
final List<TargetCreate> targets = new ArrayList<>(number);
|
||||
for (int i = 0; i < number; i++) {
|
||||
targets.add(entityFactory.target().create().controllerId(controllerIdPrefix + i)
|
||||
.targetType(targetType.getId()));
|
||||
@@ -976,7 +974,7 @@ public class TestdataFactory {
|
||||
* @return list of {@link Target} objects
|
||||
*/
|
||||
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++) {
|
||||
targets.add(entityFactory.target().create().controllerId(controllerIdPrefix + i).build());
|
||||
}
|
||||
@@ -1075,7 +1073,7 @@ public class TestdataFactory {
|
||||
* @return the created set of {@link TargetTag}s
|
||||
*/
|
||||
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++) {
|
||||
result.add(entityFactory.tag().create().name(tagPrefix + i).description(tagPrefix + i)
|
||||
@@ -1094,7 +1092,7 @@ public class TestdataFactory {
|
||||
* @return the persisted {@link DistributionSetTag}s
|
||||
*/
|
||||
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++) {
|
||||
result.add(
|
||||
@@ -1450,7 +1448,7 @@ public class TestdataFactory {
|
||||
* @return persisted {@link TargetType}
|
||||
*/
|
||||
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++) {
|
||||
result.add(entityFactory.targetType().create()
|
||||
.name(targetTypePrefix + i).description(targetTypePrefix + " description")
|
||||
|
||||
Reference in New Issue
Block a user