Upgrade sonar to new 6.2 installation (#456)
* Upgrade to new sonar instance. Fix new identified issues. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
@@ -121,7 +121,7 @@ public class TenantUsage {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (!(obj instanceof TenantUsage)) {
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final TenantUsage other = (TenantUsage) obj;
|
||||
@@ -137,9 +137,6 @@ public class TenantUsage {
|
||||
if (targets != other.targets) {
|
||||
return false;
|
||||
}
|
||||
if (!this.getUsageData().equals(other.getUsageData())) {
|
||||
return false;
|
||||
}
|
||||
if (tenantName == null) {
|
||||
if (other.tenantName != null) {
|
||||
return false;
|
||||
@@ -147,6 +144,13 @@ public class TenantUsage {
|
||||
} else if (!tenantName.equals(other.tenantName)) {
|
||||
return false;
|
||||
}
|
||||
if (usageData == null) {
|
||||
if (other.usageData != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!usageData.equals(other.usageData)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -58,10 +58,12 @@ public class JpaArtifactManagement implements ArtifactManagement {
|
||||
|
||||
private static Artifact checkForExistingArtifact(final String filename, final boolean overrideExisting,
|
||||
final SoftwareModule softwareModule) {
|
||||
if (softwareModule.getArtifactByFilename(filename).isPresent()) {
|
||||
final Optional<Artifact> artifact = softwareModule.getArtifactByFilename(filename);
|
||||
|
||||
if (artifact.isPresent()) {
|
||||
if (overrideExisting) {
|
||||
LOG.debug("overriding existing artifact with new filename {}", filename);
|
||||
return softwareModule.getArtifactByFilename(filename).get();
|
||||
return artifact.get();
|
||||
} else {
|
||||
throw new EntityAlreadyExistsException("File with that name already exists in the Software Module");
|
||||
}
|
||||
|
||||
@@ -70,7 +70,6 @@ import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
|
||||
import org.eclipse.hawkbit.repository.model.TargetWithActionType;
|
||||
import org.eclipse.hawkbit.repository.rsql.VirtualPropertyReplacer;
|
||||
import org.hibernate.validator.constraints.NotEmpty;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -350,14 +349,6 @@ public class JpaDeploymentManagement implements DeploymentManagement {
|
||||
|
||||
}
|
||||
|
||||
private DistributionSetAssignmentResult assignDistributionSetByTargetId(@NotNull final JpaDistributionSet set,
|
||||
@NotEmpty final List<String> tIDs, final ActionType actionType, final long forcedTime) {
|
||||
|
||||
return assignDistributionSetToTargets(set, tIDs.stream()
|
||||
.map(t -> new TargetWithActionType(t, actionType, forcedTime)).collect(Collectors.toList()), null, null,
|
||||
null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Modifying
|
||||
@Transactional(isolation = Isolation.READ_COMMITTED)
|
||||
@@ -383,8 +374,7 @@ public class JpaDeploymentManagement implements DeploymentManagement {
|
||||
|
||||
return saveAction;
|
||||
} else {
|
||||
throw new CancelActionNotAllowedException(
|
||||
"Action [id: " + action.getId() + "] is not active and cannot be canceled");
|
||||
throw new CancelActionNotAllowedException(action.getId() + " is not active and cannot be canceled");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -416,12 +406,11 @@ public class JpaDeploymentManagement implements DeploymentManagement {
|
||||
|
||||
if (!action.isCancelingOrCanceled()) {
|
||||
throw new ForceQuitActionNotAllowedException(
|
||||
"Action [id: " + action.getId() + "] is not canceled yet and cannot be force quit");
|
||||
action.getId() + " is not canceled yet and cannot be force quit");
|
||||
}
|
||||
|
||||
if (!action.isActive()) {
|
||||
throw new ForceQuitActionNotAllowedException(
|
||||
"Action [id: " + action.getId() + "] is not active and cannot be force quit");
|
||||
throw new ForceQuitActionNotAllowedException(action.getId() + " is not active and cannot be force quit");
|
||||
}
|
||||
|
||||
LOG.warn("action ({}) was still activ and has been force quite.", action);
|
||||
|
||||
@@ -658,13 +658,6 @@ public class JpaSoftwareManagement implements SoftwareManagement {
|
||||
return Optional.ofNullable(softwareModuleMetadataRepository.findOne(new SwMetadataCompositeKey(moduleId, key)));
|
||||
}
|
||||
|
||||
private void checkAndThrowAlreadyExistsIfSoftwareModuleMetadataExists(final SwMetadataCompositeKey metadataId) {
|
||||
if (softwareModuleMetadataRepository.exists(metadataId)) {
|
||||
throw new EntityAlreadyExistsException(
|
||||
"Metadata entry with key '" + metadataId.getKey() + "' already exists");
|
||||
}
|
||||
}
|
||||
|
||||
private static void throwMetadataKeyAlreadyExists(final String metadataKey) {
|
||||
throw new EntityAlreadyExistsException("Metadata entry with key '" + metadataKey + "' already exists");
|
||||
}
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.jpa.rsql;
|
||||
|
||||
import static org.eclipse.hawkbit.repository.FieldNameProvider.SUB_ATTRIBUTE_SEPERATOR;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@@ -214,7 +212,7 @@ public final class RSQLUtility {
|
||||
simpleTypeConverter = new SimpleTypeConverter();
|
||||
}
|
||||
|
||||
private void beginLevel(boolean isOr) {
|
||||
private void beginLevel(final boolean isOr) {
|
||||
level++;
|
||||
isOrLevel = isOr;
|
||||
joinsInLevel.put(level, new HashSet<>(2));
|
||||
@@ -227,19 +225,18 @@ public final class RSQLUtility {
|
||||
}
|
||||
|
||||
private Set<Join<Object, Object>> getCurrentJoins() {
|
||||
if(level > 0) {
|
||||
if (level > 0) {
|
||||
return joinsInLevel.get(level);
|
||||
}
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
private Optional<Join<Object, Object>> findCurrentJoinOfType(final Class<?> type) {
|
||||
return getCurrentJoins().stream()
|
||||
.filter(j -> type.equals(j.getJavaType())).findAny();
|
||||
return getCurrentJoins().stream().filter(j -> type.equals(j.getJavaType())).findAny();
|
||||
}
|
||||
|
||||
private void addCurrentJoin(Join<Object, Object> join) {
|
||||
if(level > 0) {
|
||||
private void addCurrentJoin(final Join<Object, Object> join) {
|
||||
if (level > 0) {
|
||||
getCurrentJoins().add(join);
|
||||
}
|
||||
}
|
||||
@@ -272,7 +269,7 @@ public final class RSQLUtility {
|
||||
|
||||
private String getAndValidatePropertyFieldName(final A propertyEnum, final ComparisonNode node) {
|
||||
|
||||
final String[] graph = node.getSelector().split("\\" + SUB_ATTRIBUTE_SEPERATOR);
|
||||
final String[] graph = node.getSelector().split("\\" + FieldNameProvider.SUB_ATTRIBUTE_SEPERATOR);
|
||||
|
||||
validateMapParamter(propertyEnum, node, graph);
|
||||
|
||||
@@ -286,7 +283,7 @@ public final class RSQLUtility {
|
||||
for (int i = 1; i < graph.length; i++) {
|
||||
|
||||
final String propertyField = graph[i];
|
||||
fieldNameBuilder.append(SUB_ATTRIBUTE_SEPERATOR).append(propertyField);
|
||||
fieldNameBuilder.append(FieldNameProvider.SUB_ATTRIBUTE_SEPERATOR).append(propertyField);
|
||||
|
||||
// the key of map is not in the graph
|
||||
if (propertyEnum.isMap() && graph.length == (i + 1)) {
|
||||
@@ -347,7 +344,7 @@ public final class RSQLUtility {
|
||||
*/
|
||||
private Path<Object> getFieldPath(final A enumField, final String finalProperty) {
|
||||
Path<Object> fieldPath = null;
|
||||
final String[] split = finalProperty.split("\\" + SUB_ATTRIBUTE_SEPERATOR);
|
||||
final String[] split = finalProperty.split("\\" + FieldNameProvider.SUB_ATTRIBUTE_SEPERATOR);
|
||||
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
final boolean isMapKeyField = enumField.isMap() && i == (split.length - 1);
|
||||
@@ -360,13 +357,13 @@ public final class RSQLUtility {
|
||||
if (fieldPath instanceof PluralJoin) {
|
||||
final Join<Object, ?> join = (Join<Object, ?>) fieldPath;
|
||||
final From<?, Object> joinParent = join.getParent();
|
||||
Optional<Join<Object, Object>> currentJoinOfType = findCurrentJoinOfType(join.getJavaType());
|
||||
if(currentJoinOfType.isPresent() && isOrLevel) {
|
||||
final Optional<Join<Object, Object>> currentJoinOfType = findCurrentJoinOfType(join.getJavaType());
|
||||
if (currentJoinOfType.isPresent() && isOrLevel) {
|
||||
// remove the additional join and use the existing one
|
||||
joinParent.getJoins().remove(join);
|
||||
fieldPath = currentJoinOfType.get();
|
||||
} else {
|
||||
Join<Object, Object> newJoin = joinParent.join(fieldNameSplit, JoinType.LEFT);
|
||||
final Join<Object, Object> newJoin = joinParent.join(fieldNameSplit, JoinType.LEFT);
|
||||
addCurrentJoin(newJoin);
|
||||
fieldPath = newJoin;
|
||||
}
|
||||
@@ -414,7 +411,7 @@ public final class RSQLUtility {
|
||||
final String enumFieldName = enumField.name().toLowerCase();
|
||||
|
||||
if (enumField.isMap()) {
|
||||
return enumFieldName + SUB_ATTRIBUTE_SEPERATOR + "keyName";
|
||||
return enumFieldName + FieldNameProvider.SUB_ATTRIBUTE_SEPERATOR + "keyName";
|
||||
}
|
||||
|
||||
return enumFieldName;
|
||||
@@ -423,7 +420,8 @@ public final class RSQLUtility {
|
||||
final List<String> expectedSubFieldList = Arrays.stream(enumType.getEnumConstants())
|
||||
.filter(enumField -> !enumField.getSubEntityAttributes().isEmpty()).flatMap(enumField -> {
|
||||
final List<String> subEntity = enumField.getSubEntityAttributes().stream()
|
||||
.map(fieldName -> enumField.name().toLowerCase() + SUB_ATTRIBUTE_SEPERATOR + fieldName)
|
||||
.map(fieldName -> enumField.name().toLowerCase()
|
||||
+ FieldNameProvider.SUB_ATTRIBUTE_SEPERATOR + fieldName)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return subEntity.stream();
|
||||
@@ -434,7 +432,7 @@ public final class RSQLUtility {
|
||||
|
||||
private A getFieldEnumByName(final ComparisonNode node) {
|
||||
String enumName = node.getSelector();
|
||||
final String[] graph = enumName.split("\\" + SUB_ATTRIBUTE_SEPERATOR);
|
||||
final String[] graph = enumName.split("\\" + FieldNameProvider.SUB_ATTRIBUTE_SEPERATOR);
|
||||
if (graph.length != 0) {
|
||||
enumName = graph[0];
|
||||
}
|
||||
@@ -613,7 +611,7 @@ public final class RSQLUtility {
|
||||
if (!enumField.isMap()) {
|
||||
return null;
|
||||
}
|
||||
final String[] graph = node.getSelector().split("\\" + SUB_ATTRIBUTE_SEPERATOR);
|
||||
final String[] graph = node.getSelector().split("\\" + FieldNameProvider.SUB_ATTRIBUTE_SEPERATOR);
|
||||
final String keyValue = graph[graph.length - 1];
|
||||
if (fieldPath instanceof MapJoin) {
|
||||
// Currently we support only string key .So below cast is safe.
|
||||
|
||||
@@ -274,7 +274,7 @@ public class RsqlParserValidationOracle implements RsqlValidationOracle {
|
||||
.map(field -> field.toString().toLowerCase()).collect(Collectors.toSet());
|
||||
|
||||
private static final Map<String, List<String>> SUB_NAMES = Arrays.stream(TargetFields.values()).collect(
|
||||
Collectors.toMap(field -> field.toString().toLowerCase(), field -> field.getSubEntityAttributes()));
|
||||
Collectors.toMap(field -> field.toString().toLowerCase(), TargetFields::getSubEntityAttributes));
|
||||
|
||||
private FieldNameDescription() {
|
||||
|
||||
@@ -292,8 +292,7 @@ public class RsqlParserValidationOracle implements RsqlValidationOracle {
|
||||
final String finalTmpTokenName = tmpTokenName;
|
||||
return Arrays.stream(TargetFields.values())
|
||||
.filter(field -> field.toString().equalsIgnoreCase(finalTmpTokenName))
|
||||
.map(field -> field.getSubEntityAttributes()).flatMap(subentities -> subentities.stream())
|
||||
.count() > 0;
|
||||
.map(TargetFields::getSubEntityAttributes).flatMap(List::stream).count() > 0;
|
||||
}
|
||||
|
||||
private static List<SuggestToken> toTopSuggestToken(final int beginToken, final int endToken,
|
||||
@@ -306,7 +305,7 @@ public class RsqlParserValidationOracle implements RsqlValidationOracle {
|
||||
private static List<SuggestToken> toSubSuggestToken(final int beginToken, final int endToken,
|
||||
final String topToken, final String tokenImageName) {
|
||||
return Arrays.stream(TargetFields.values()).filter(field -> field.toString().equalsIgnoreCase(topToken))
|
||||
.map(field -> field.getSubEntityAttributes()).flatMap(list -> list.stream())
|
||||
.map(TargetFields::getSubEntityAttributes).flatMap(List::stream)
|
||||
.map(subentity -> new SuggestToken(beginToken, endToken, tokenImageName, subentity))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
@@ -318,8 +317,7 @@ public class RsqlParserValidationOracle implements RsqlValidationOracle {
|
||||
final String[] split = imageName.split("\\.");
|
||||
if (split.length > 1 && FIELD_NAMES.contains(split[0].toLowerCase())) {
|
||||
return SUB_NAMES.get(split[0].toLowerCase()).stream()
|
||||
.filter(subname -> new String(split[0] + "." + subname).equalsIgnoreCase(imageName))
|
||||
.count() > 0;
|
||||
.filter(subname -> (split[0] + "." + subname).equalsIgnoreCase(imageName)).count() > 0;
|
||||
}
|
||||
return FIELD_NAMES.stream().filter(value -> value.equalsIgnoreCase(imageName)).count() > 0;
|
||||
}
|
||||
|
||||
@@ -9,13 +9,12 @@
|
||||
|
||||
package org.eclipse.hawkbit.repository.test.matcher;
|
||||
|
||||
import static java.util.Optional.ofNullable;
|
||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.hawkbit.repository.test.util.TestContextProvider;
|
||||
@@ -60,7 +59,7 @@ public class EventVerifier implements TestRule {
|
||||
}
|
||||
|
||||
private Optional<Expect[]> getExpectationsFrom(final Description description) {
|
||||
return ofNullable(description.getAnnotation(ExpectEvents.class)).map(ExpectEvents::value);
|
||||
return Optional.ofNullable(description.getAnnotation(ExpectEvents.class)).map(ExpectEvents::value);
|
||||
}
|
||||
|
||||
private void beforeTest() {
|
||||
@@ -78,8 +77,8 @@ public class EventVerifier implements TestRule {
|
||||
|
||||
for (final Expect expectedEvent : expectedEvents) {
|
||||
try {
|
||||
Awaitility.await().atMost(5, SECONDS).until(() -> eventCaptor.getCountFor(expectedEvent.type()),
|
||||
equalTo(expectedEvent.count()));
|
||||
Awaitility.await().atMost(5, TimeUnit.SECONDS)
|
||||
.until(() -> eventCaptor.getCountFor(expectedEvent.type()), equalTo(expectedEvent.count()));
|
||||
|
||||
} catch (final ConditionTimeoutException ex) {
|
||||
Assert.fail("Did not receive the expected amount of events form " + expectedEvent.type() + " Expected: "
|
||||
|
||||
Reference in New Issue
Block a user