Skip to content

Commit

Permalink
fixed sonar issues;
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Maute <stefan.maute@bosch.io>
  • Loading branch information
Stefan Maute committed Aug 31, 2022
1 parent 3d4293d commit 23b16f3
Show file tree
Hide file tree
Showing 215 changed files with 874 additions and 964 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,18 @@
import java.util.List;
import java.util.Objects;
import java.util.function.Predicate;
import java.util.stream.Collectors;

import javax.annotation.concurrent.Immutable;

import org.eclipse.ditto.base.model.entity.id.EntityId;
import org.eclipse.ditto.base.model.json.FieldType;
import org.eclipse.ditto.base.model.json.JsonSchemaVersion;
import org.eclipse.ditto.json.JsonArray;
import org.eclipse.ditto.json.JsonFactory;
import org.eclipse.ditto.json.JsonField;
import org.eclipse.ditto.json.JsonObject;
import org.eclipse.ditto.json.JsonObjectBuilder;
import org.eclipse.ditto.json.JsonValue;
import org.eclipse.ditto.base.model.entity.id.EntityId;
import org.eclipse.ditto.base.model.json.FieldType;
import org.eclipse.ditto.base.model.json.JsonSchemaVersion;

/**
* A dedicated {@link ShutdownReason} for purging a namespace.
Expand Down Expand Up @@ -57,15 +56,15 @@ public static PurgeEntitiesReason of(final List<EntityId> entityIdsToPurge) {
final List<String> stringEntityIdsToPurge = argumentNotEmpty(entityIdsToPurge, "entities to purge")
.stream()
.map(String::valueOf)
.collect(Collectors.toList());
.toList();

return new PurgeEntitiesReason(stringEntityIdsToPurge);
}

static PurgeEntitiesReason fromJson(final JsonObject jsonObject) {
final List<String> entityIdsToPurge = jsonObject.getValueOrThrow(JsonFields.DETAILS).asArray().stream()
.map(JsonValue::asString)
.collect(Collectors.toList());
.toList();

return new PurgeEntitiesReason(entityIdsToPurge);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@
import java.util.List;
import java.util.Objects;
import java.util.function.Predicate;
import java.util.stream.Collectors;

import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;

import org.eclipse.ditto.base.model.headers.DittoHeaders;
import org.eclipse.ditto.base.model.json.FieldType;
import org.eclipse.ditto.base.model.json.JsonParsableCommand;
import org.eclipse.ditto.base.model.json.JsonSchemaVersion;
import org.eclipse.ditto.base.model.signals.commands.CommandJsonDeserializer;
import org.eclipse.ditto.json.JsonArray;
import org.eclipse.ditto.json.JsonCollectors;
import org.eclipse.ditto.json.JsonFactory;
Expand All @@ -31,11 +35,6 @@
import org.eclipse.ditto.json.JsonObject;
import org.eclipse.ditto.json.JsonObjectBuilder;
import org.eclipse.ditto.json.JsonValue;
import org.eclipse.ditto.base.model.headers.DittoHeaders;
import org.eclipse.ditto.base.model.json.FieldType;
import org.eclipse.ditto.base.model.json.JsonParsableCommand;
import org.eclipse.ditto.base.model.json.JsonSchemaVersion;
import org.eclipse.ditto.base.model.signals.commands.CommandJsonDeserializer;

/**
* Command to retrieve the {@link org.eclipse.ditto.base.api.devops.LoggerConfig} for each configured Logger.
Expand Down Expand Up @@ -225,7 +224,7 @@ public static RetrieveLoggerConfig fromJson(final JsonObject jsonObject, final D
final List<String> extractedSpecificLoggers = loggersJsonArray.stream()
.filter(JsonValue::isString)
.map(JsonValue::asString)
.collect(Collectors.toList());
.toList();

return of(serviceName, instance, dittoHeaders, extractedSpecificLoggers);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import java.util.List;
import java.util.Objects;
import java.util.function.Predicate;
import java.util.stream.Collectors;

import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;
Expand Down Expand Up @@ -67,7 +66,7 @@ public final class RetrieveLoggerConfigResponse extends AbstractDevOpsCommandRes
.filter(JsonValue::isObject)
.map(JsonValue::asObject)
.map(ImmutableLoggerConfig::fromJson)
.collect(Collectors.toList());
.toList();

return new RetrieveLoggerConfigResponse(
jsonObject.getValue(DevOpsCommandResponse.JsonFields.JSON_SERVICE_NAME).orElse(null),
Expand Down Expand Up @@ -165,7 +164,7 @@ public RetrieveLoggerConfigResponse setEntity(final JsonValue entity) {
.filter(JsonValue::isObject)
.map(JsonValue::asObject)
.map(ImmutableLoggerConfig::fromJson)
.collect(Collectors.toList()),
.toList(),
getDittoHeaders());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@
import java.util.List;
import java.util.Objects;
import java.util.function.Predicate;
import java.util.stream.Collectors;

import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;

import org.eclipse.ditto.base.model.headers.DittoHeaders;
import org.eclipse.ditto.base.model.json.JsonParsableCommand;
import org.eclipse.ditto.base.model.json.JsonSchemaVersion;
import org.eclipse.ditto.base.model.signals.commands.CommandJsonDeserializer;
import org.eclipse.ditto.json.JsonArray;
import org.eclipse.ditto.json.JsonCollectors;
import org.eclipse.ditto.json.JsonFactory;
Expand All @@ -30,10 +33,6 @@
import org.eclipse.ditto.json.JsonObject;
import org.eclipse.ditto.json.JsonObjectBuilder;
import org.eclipse.ditto.json.JsonValue;
import org.eclipse.ditto.base.model.headers.DittoHeaders;
import org.eclipse.ditto.base.model.json.JsonParsableCommand;
import org.eclipse.ditto.base.model.json.JsonSchemaVersion;
import org.eclipse.ditto.base.model.signals.commands.CommandJsonDeserializer;

/**
* Command which retrieves publicly available statistics about the stored Things currently present.
Expand Down Expand Up @@ -200,7 +199,7 @@ public String toString() {
}

private static List<String> toStringListOrThrow(final JsonArray jsonArray) {
return jsonArray.stream().map(JsonValue::asString).collect(Collectors.toList());
return jsonArray.stream().map(JsonValue::asString).toList();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -652,11 +652,4 @@ private static Map<String, Header> preserveCaseSensitivity(final Map<String, Str
}
}

private void checkMetadataHeaders() {
if (headers.containsKey(DittoHeaderDefinition.GET_METADATA.getKey()) &&
headers.containsKey(DittoHeaderDefinition.DELETE_METADATA.getKey())) {

}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.eclipse.ditto.base.model.common.HttpStatus;
import org.eclipse.ditto.base.model.common.HttpStatusCodeOutOfRangeException;
import org.eclipse.ditto.base.model.entity.id.EntityId;
import org.eclipse.ditto.base.model.entity.id.NamespacedEntityId;
import org.eclipse.ditto.base.model.entity.type.EntityType;
import org.eclipse.ditto.base.model.exceptions.DittoRuntimeException;
import org.eclipse.ditto.base.model.headers.DittoHeaders;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.util.stream.IntStream;

import org.assertj.core.util.Lists;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.runners.Enclosed;
import org.junit.runner.RunWith;
Expand Down Expand Up @@ -56,7 +55,7 @@ public void tryToGetNewLabelForNull() {
public void newLabelReturnsExpected() {
final AcknowledgementLabel newLabel = AcknowledgementLabels.newLabel(KNOWN_LABEL_VALUE);

assertThat(newLabel.toString()).isEqualTo(KNOWN_LABEL_VALUE);
assertThat(newLabel.toString()).hasToString(KNOWN_LABEL_VALUE);
}

@Test
Expand Down Expand Up @@ -102,7 +101,7 @@ public void newLabelReturnsExpectedType() {
if (parameter.shouldBeValid) {
final AcknowledgementLabel acknowledgementLabel = AcknowledgementLabels.newLabel(labelValue);

assertThat(acknowledgementLabel.toString()).isEqualTo(labelValue);
assertThat(acknowledgementLabel.toString()).hasToString(labelValue);
} else {
assertThatExceptionOfType(AcknowledgementLabelInvalidException.class)
.isThrownBy(() -> AcknowledgementLabels.newLabel(labelValue))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import static org.mutabilitydetector.unittesting.MutabilityMatchers.areImmutable;

import org.assertj.core.api.AutoCloseableSoftAssertions;
import org.junit.Ignore;
import org.junit.Test;

import nl.jqno.equalsverifier.EqualsVerifier;
Expand Down Expand Up @@ -45,7 +44,7 @@ public void assertImmutability() {
public void toStringReturnsExpected() {
final ImmutableAcknowledgementLabel underTest = ImmutableAcknowledgementLabel.of(KNOWN_LABEL_VALUE);

assertThat(underTest.toString()).isEqualTo(KNOWN_LABEL_VALUE);
assertThat(underTest.toString()).hasToString(KNOWN_LABEL_VALUE);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import static org.mutabilitydetector.unittesting.MutabilityAssert.assertInstancesOf;
import static org.mutabilitydetector.unittesting.MutabilityMatchers.areImmutable;

import org.junit.Ignore;
import org.junit.Test;

import nl.jqno.equalsverifier.EqualsVerifier;
Expand Down Expand Up @@ -63,7 +62,7 @@ public void toStringReturnsExpected() {
final AcknowledgementLabel label = DittoAcknowledgementLabel.TWIN_PERSISTED;
final ImmutableAcknowledgementRequest underTest = ImmutableAcknowledgementRequest.getInstance(label);

assertThat(underTest.toString()).isEqualTo(label.toString());
assertThat(underTest.toString()).hasToString(label.toString());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.eclipse.ditto.json.JsonCollectors;
import org.eclipse.ditto.json.JsonFactory;
import org.eclipse.ditto.json.JsonObject;
import org.junit.Ignore;
import org.junit.Test;

import nl.jqno.equalsverifier.EqualsVerifier;
Expand Down Expand Up @@ -101,7 +100,7 @@ public void toStringReturnsExpected() {
final ImmutableFilteredAcknowledgementRequest underTest =
ImmutableFilteredAcknowledgementRequest.getInstance(INCLUDES, FILTER);

assertThat(underTest.toString()).isEqualTo(
assertThat(underTest.toString()).hasToString(
ImmutableFilteredAcknowledgementRequest.class.getSimpleName() + " [" +
"includes=" + INCLUDES +
", filter=" + FILTER +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import static org.mutabilitydetector.unittesting.MutabilityMatchers.areImmutable;

import org.assertj.core.api.AutoCloseableSoftAssertions;
import org.junit.Ignore;
import org.junit.Test;

import nl.jqno.equalsverifier.EqualsVerifier;
Expand All @@ -44,7 +43,7 @@ public void assertImmutability() {
public void toStringReturnsExpected() {
final ImmutableAuthorizationContextType underTest = ImmutableAuthorizationContextType.of(KNOWN_TYPE_VALUE);

assertThat(underTest.toString()).isEqualTo(KNOWN_TYPE_VALUE);
assertThat(underTest.toString()).hasToString(KNOWN_TYPE_VALUE);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import static org.mutabilitydetector.unittesting.MutabilityMatchers.areImmutable;

import org.assertj.core.api.AutoCloseableSoftAssertions;
import org.junit.Ignore;
import org.junit.Test;

import nl.jqno.equalsverifier.EqualsVerifier;
Expand Down Expand Up @@ -63,7 +62,7 @@ public void tryToGetInstanceWithEmptyValue() {
public void toStringReturnsExpected() {
final DefaultEntityType underTest = DefaultEntityType.of(KNOWN_VALUE);

assertThat(underTest.toString()).isEqualTo(KNOWN_VALUE);
assertThat(underTest.toString()).hasToString(KNOWN_VALUE);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public void createInstanceFromValidJson() {

@Test
public void retryAfterHeaderIsSet() {
assertThat(UNDER_TEST.getDittoHeaders().get(TooManyRequestsException.RETRY_AFTER)).isEqualTo("3600");
assertThat(UNDER_TEST.getDittoHeaders()).containsEntry(TooManyRequestsException.RETRY_AFTER, "3600");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ public void areCaseInsensitiveAndCasePreserving() {
final Map<String, String> headers = new HashMap<>();
headers.put("hElLo", "world");
final DittoHeaders underTest = ImmutableDittoHeaders.of(headers);
assertThat(underTest.get("hello")).isEqualTo("world");
assertThat(underTest).containsEntry("hello", "world");
final JsonObject serialized = underTest.toJson();
assertThat(serialized).containsExactly(JsonField.newInstance("hElLo", JsonValue.of("world")));
final DittoHeaders deserialized = DittoHeaders.newBuilder(serialized).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void parseShortBasicFormat() {
@Test
public void parseZuluTime() {
final OffsetDateTime time = DateTimeUtil.parseOffsetDateTime("19700123T012345Z");
assertThat(time.getOffset().getLong(ChronoField.OFFSET_SECONDS)).isEqualTo(0);
assertThat(time.getOffset().getLong(ChronoField.OFFSET_SECONDS)).isZero();
}

@Test(expected = DateTimeException.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;

import javax.annotation.Nonnull;
Expand Down Expand Up @@ -70,9 +69,9 @@ public List<LoggerConfig> getLoggerConfig() {
@Override
@Nonnull
public List<LoggerConfig> getLoggerConfig(@Nonnull final Iterable<String> loggerNames) {
final List<Logger> loggerList = StreamSupport.stream(loggerNames.spliterator(), false) //
.map(logger -> (Logger) LoggerFactory.getLogger(logger)) //
.collect(Collectors.toList());
final List<Logger> loggerList = StreamSupport.stream(loggerNames.spliterator(), false)
.map(logger -> (Logger) LoggerFactory.getLogger(logger))
.toList();

return loggerConfigsFor(loggerList);
}
Expand All @@ -90,4 +89,5 @@ private List<LoggerConfig> loggerConfigsFor(final Iterable<Logger> loggers) {

return loggerConfigList;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,25 @@
import java.util.List;
import java.util.Objects;
import java.util.function.Predicate;
import java.util.stream.Collectors;

import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;

import org.eclipse.ditto.json.JsonArray;
import org.eclipse.ditto.json.JsonCollectors;
import org.eclipse.ditto.json.JsonFactory;
import org.eclipse.ditto.json.JsonField;
import org.eclipse.ditto.json.JsonObject;
import org.eclipse.ditto.json.JsonValue;
import org.eclipse.ditto.base.model.headers.DittoHeaders;
import org.eclipse.ditto.base.model.json.JsonSchemaVersion;
import org.eclipse.ditto.base.model.json.Jsonifiable;
import org.eclipse.ditto.connectivity.model.ConnectivityModelFactory;
import org.eclipse.ditto.connectivity.model.Target;
import org.eclipse.ditto.internal.utils.cluster.MappingStrategies;
import org.eclipse.ditto.base.model.signals.JsonParsable;
import org.eclipse.ditto.base.model.signals.Signal;
import org.eclipse.ditto.base.model.signals.commands.Command;
import org.eclipse.ditto.connectivity.model.ConnectivityModelFactory;
import org.eclipse.ditto.connectivity.model.Target;
import org.eclipse.ditto.internal.utils.cluster.MappingStrategies;
import org.eclipse.ditto.json.JsonArray;
import org.eclipse.ditto.json.JsonCollectors;
import org.eclipse.ditto.json.JsonFactory;
import org.eclipse.ditto.json.JsonField;
import org.eclipse.ditto.json.JsonObject;
import org.eclipse.ditto.json.JsonValue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -88,7 +87,7 @@ public static OutboundSignal fromJson(final JsonObject jsonObject, final Mapping
.filter(JsonValue::isObject)
.map(JsonValue::asObject)
.map(ConnectivityModelFactory::targetFromJson)
.collect(Collectors.toList());
.toList();

return new UnmappedOutboundSignal((Signal<?>) signalJsonifiable, targets);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import static org.mutabilitydetector.unittesting.MutabilityMatchers.areImmutable;

import org.eclipse.ditto.base.model.entity.id.EntityId;
import org.junit.Ignore;
import org.junit.Test;

import nl.jqno.equalsverifier.EqualsVerifier;
Expand Down Expand Up @@ -58,7 +57,7 @@ public void connectionIdOfConnectionIdIsSameInstance() {
@Test
public void toStringEqualsInput() {
final ConnectionId connectionId = ConnectionId.of("myConnection");
assertThat(connectionId.toString()).isEqualTo("myConnection");
assertThat(connectionId.toString()).hasToString("myConnection");
}

}
Loading

0 comments on commit 23b16f3

Please sign in to comment.