Skip to content

Commit

Permalink
Sonar Fixes (5)
Browse files Browse the repository at this point in the history
Signed-off-by: Avgustin Marinov <[email protected]>
  • Loading branch information
avgustinmm committed Jan 21, 2025
1 parent 33a6250 commit d41f9ab
Show file tree
Hide file tree
Showing 59 changed files with 240 additions and 276 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;

import java.io.IOException;
import java.time.Instant;
import java.util.Collections;

import com.fasterxml.jackson.core.JsonProcessingException;
Expand Down Expand Up @@ -68,7 +67,7 @@ void shouldSerializeAndDeserializeObjectWithOptionalValues() throws IOException

@Test
@Description("Verify that deserialization fails for known properties with a wrong datatype")
void shouldFailForObjectWithWrongDataTypes() throws IOException {
void shouldFailForObjectWithWrongDataTypes() {
// Setup
final String serializedDdiActionFeedback = """
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
*/
@Feature("Unit Tests - Direct Device Integration API")
@Story("Serializability of DDI api Models")
public class DdiActionHistoryTest {
class DdiActionHistoryTest {

private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();

@Test
@Description("Verify the correct serialization and deserialization of the model")
public void shouldSerializeAndDeserializeObject() throws IOException {
void shouldSerializeAndDeserializeObject() throws IOException {
// Setup
final String actionStatus = "TestAction";
final List<String> messages = Arrays.asList("Action status message 1", "Action status message 2");
Expand All @@ -50,7 +50,7 @@ public void shouldSerializeAndDeserializeObject() throws IOException {

@Test
@Description("Verify the correct deserialization of a model with a additional unknown property")
public void shouldDeserializeObjectWithUnknownProperty() throws IOException {
void shouldDeserializeObjectWithUnknownProperty() throws IOException {
// Setup
final String serializedDdiActionHistory = """
{
Expand All @@ -66,7 +66,7 @@ public void shouldDeserializeObjectWithUnknownProperty() throws IOException {

@Test
@Description("Verify that deserialization fails for known properties with a wrong datatype")
public void shouldFailForObjectWithWrongDataTypes() throws IOException {
void shouldFailForObjectWithWrongDataTypes() {
// Setup
final String serializedDdiActionFeedback = """
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
*/
@Feature("Unit Tests - Direct Device Integration API")
@Story("Serializability of DDI api Models")
public class DdiArtifactHashTest {
class DdiArtifactHashTest {

private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();

@Test
@Description("Verify the correct serialization and deserialization of the model")
public void shouldSerializeAndDeserializeObject() throws IOException {
void shouldSerializeAndDeserializeObject() throws IOException {
// Setup
final String sha1Hash = "11111";
final String md5Hash = "22222";
Expand All @@ -51,7 +51,7 @@ public void shouldSerializeAndDeserializeObject() throws IOException {

@Test
@Description("Verify the correct deserialization of a model with a additional unknown property")
public void shouldDeserializeObjectWithUnknownProperty() throws IOException {
void shouldDeserializeObjectWithUnknownProperty() throws IOException {
// Setup
final String serializedDdiArtifact = "{\"sha1\": \"123\", \"md5\": \"456\", \"sha256\": \"789\", \"unknownProperty\": \"test\"}";

Expand All @@ -64,7 +64,7 @@ public void shouldDeserializeObjectWithUnknownProperty() throws IOException {

@Test
@Description("Verify that deserialization fails for known properties with a wrong datatype")
public void shouldFailForObjectWithWrongDataTypes() throws IOException {
void shouldFailForObjectWithWrongDataTypes() {
// Setup
final String serializedDdiArtifact = "{\"sha1\": [123], \"md5\": 456, \"sha256\": \"789\"";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
*/
@Feature("Unit Tests - Direct Device Integration API")
@Story("Serializability of DDI api Models")
public class DdiArtifactTest {
class DdiArtifactTest {

private final static ObjectMapper OBJECT_MAPPER = new ObjectMapper();
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();

@Test
@Description("Verify the correct serialization and deserialization of the model")
public void shouldSerializeAndDeserializeObject() throws IOException {
void shouldSerializeAndDeserializeObject() throws IOException {
// Setup
final String filename = "testfile.txt";
final DdiArtifactHash hashes = new DdiArtifactHash("123", "456", "789");
Expand All @@ -57,7 +57,7 @@ public void shouldSerializeAndDeserializeObject() throws IOException {

@Test
@Description("Verify the correct deserialization of a model with a additional unknown property")
public void shouldDeserializeObjectWithUnknownProperty() throws IOException {
void shouldDeserializeObjectWithUnknownProperty() throws IOException {
// Setup
final String serializedDdiArtifact = "{\"filename\":\"test.file\",\"hashes\":{\"sha1\":\"123\",\"md5\":\"456\",\"sha256\":\"789\"},\"size\":111,\"links\":[],\"unknownProperty\": \"test\"}";

Expand All @@ -72,7 +72,7 @@ public void shouldDeserializeObjectWithUnknownProperty() throws IOException {

@Test
@Description("Verify that deserialization fails for known properties with a wrong datatype")
public void shouldFailForObjectWithWrongDataTypes() throws IOException {
void shouldFailForObjectWithWrongDataTypes() {
// Setup
final String serializedDdiArtifact = "{\"filename\": [\"test.file\"],\"hashes\":{\"sha1\":\"123\",\"md5\":\"456\",\"sha256\":\"789\"},\"size\":111,\"links\":[]}";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
*/
@Feature("Unit Tests - Direct Device Integration API")
@Story("Serializability of DDI api Models")
public class DdiCancelActionToStopTest {
class DdiCancelActionToStopTest {

private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();

@Test
@Description("Verify the correct serialization and deserialization of the model")
public void shouldSerializeAndDeserializeObject() throws IOException {
void shouldSerializeAndDeserializeObject() throws IOException {
// Setup
final String stopId = "1234";
final DdiCancelActionToStop ddiCancelActionToStop = new DdiCancelActionToStop(stopId);
Expand All @@ -48,7 +48,7 @@ public void shouldSerializeAndDeserializeObject() throws IOException {

@Test
@Description("Verify the correct deserialization of a model with a additional unknown property")
public void shouldDeserializeObjectWithUnknownProperty() throws IOException {
void shouldDeserializeObjectWithUnknownProperty() throws IOException {
// Setup
final String serializedDdiCancelActionToStop = "{\"stopId\":\"12345\",\"unknownProperty\":\"test\"}";

Expand All @@ -60,7 +60,7 @@ public void shouldDeserializeObjectWithUnknownProperty() throws IOException {

@Test
@Description("Verify that deserialization fails for known properties with a wrong datatype")
public void shouldFailForObjectWithWrongDataTypes() throws IOException {
void shouldFailForObjectWithWrongDataTypes() {
// Setup
final String serializedDdiCancelActionToStop = "{\"stopId\": [\"12345\"]}";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
*/
@Feature("Unit Tests - Direct Device Integration API")
@Story("Serializability of DDI api Models")
public class DdiCancelTest {
class DdiCancelTest {

private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();

@Test
@Description("Verify the correct serialization and deserialization of the model")
public void shouldSerializeAndDeserializeObject() throws IOException {
void shouldSerializeAndDeserializeObject() throws IOException {
// Setup
final String ddiCancelId = "1234";
final DdiCancelActionToStop ddiCancelActionToStop = new DdiCancelActionToStop("1234");
Expand All @@ -49,7 +49,7 @@ public void shouldSerializeAndDeserializeObject() throws IOException {

@Test
@Description("Verify the correct deserialization of a model with a additional unknown property")
public void shouldDeserializeObjectWithUnknownProperty() throws IOException {
void shouldDeserializeObjectWithUnknownProperty() throws IOException {
// Setup
final String serializedDdiCancel = "{\"id\":\"1234\",\"cancelAction\":{\"stopId\":\"1234\"}, \"unknownProperty\": \"test\"}";

Expand All @@ -61,7 +61,7 @@ public void shouldDeserializeObjectWithUnknownProperty() throws IOException {

@Test
@Description("Verify that deserialization fails for known properties with a wrong datatype")
public void shouldFailForObjectWithWrongDataTypes() throws IOException {
void shouldFailForObjectWithWrongDataTypes() {
// Setup
final String serializedDdiCancel = "{\"id\":[\"1234\"],\"cancelAction\":{\"stopId\":\"1234\"}}";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
*/
@Feature("Unit Tests - Direct Device Integration API")
@Story("Serializability of DDI api Models")
public class DdiChunkTest {
class DdiChunkTest {

private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();

@Test
@Description("Verify the correct serialization and deserialization of the model")
public void shouldSerializeAndDeserializeObject() throws IOException {
void shouldSerializeAndDeserializeObject() throws IOException {
// Setup
final String part = "1234";
final String version = "1.0";
Expand All @@ -50,12 +50,12 @@ public void shouldSerializeAndDeserializeObject() throws IOException {
assertThat(deserializedDdiChunk.getPart()).isEqualTo(part);
assertThat(deserializedDdiChunk.getVersion()).isEqualTo(version);
assertThat(deserializedDdiChunk.getName()).isEqualTo(name);
assertThat(deserializedDdiChunk.getArtifacts().size()).isEqualTo(0);
assertThat(deserializedDdiChunk.getArtifacts()).isEmpty();
}

@Test
@Description("Verify the correct deserialization of a model with a additional unknown property")
public void shouldDeserializeObjectWithUnknownProperty() throws IOException {
void shouldDeserializeObjectWithUnknownProperty() throws IOException {
// Setup
final String serializedDdiChunk = "{\"part\":\"1234\",\"version\":\"1.0\",\"name\":\"Dummy-Artifact\",\"artifacts\":[],\"unknownProperty\":\"test\"}";

Expand All @@ -64,12 +64,12 @@ public void shouldDeserializeObjectWithUnknownProperty() throws IOException {
assertThat(ddiChunk.getPart()).isEqualTo("1234");
assertThat(ddiChunk.getVersion()).isEqualTo("1.0");
assertThat(ddiChunk.getName()).isEqualTo("Dummy-Artifact");
assertThat(ddiChunk.getArtifacts().size()).isEqualTo(0);
assertThat(ddiChunk.getArtifacts()).isEmpty();
}

@Test
@Description("Verify that deserialization fails for known properties with a wrong datatype")
public void shouldFailForObjectWithWrongDataTypes() throws IOException {
void shouldFailForObjectWithWrongDataTypes() {
// Setup
final String serializedDdiChunk = "{\"part\":[\"1234\"],\"version\":\"1.0\",\"name\":\"Dummy-Artifact\",\"artifacts\":[]}";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
*/
@Feature("Unit Tests - Direct Device Integration API")
@Story("Serializability of DDI api Models")
public class DdiConfigDataTest {
class DdiConfigDataTest {

private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();

@Test
@Description("Verify the correct serialization and deserialization of the model")
public void shouldSerializeAndDeserializeObject() throws IOException {
void shouldSerializeAndDeserializeObject() throws IOException {
// Setup
final Map<String, String> data = new HashMap<>();
data.put("test", "data");
Expand All @@ -50,7 +50,7 @@ public void shouldSerializeAndDeserializeObject() throws IOException {

@Test
@Description("Verify the correct deserialization of a model with an additional unknown property")
public void shouldDeserializeObjectWithUnknownProperty() throws IOException {
void shouldDeserializeObjectWithUnknownProperty() throws IOException {
// Setup
final String serializedDdiConfigData = "{\"data\":{\"test\":\"data\"},\"mode\":\"replace\",\"unknownProperty\":\"test\"}";

Expand All @@ -61,7 +61,7 @@ public void shouldDeserializeObjectWithUnknownProperty() throws IOException {

@Test
@Description("Verify that deserialization fails for known properties with a wrong datatype")
public void shouldFailForObjectWithWrongDataTypes() throws IOException {
void shouldFailForObjectWithWrongDataTypes() {
// Setup
final String serializedDdiConfigData = "{\"data\":{\"test\":\"data\"},\"mode\":[\"replace\"],\"unknownProperty\":\"test\"}";

Expand All @@ -72,7 +72,7 @@ public void shouldFailForObjectWithWrongDataTypes() throws IOException {

@Test
@Description("Verify the correct deserialization of a model with removed unused status property")
public void shouldDeserializeObjectWithStatusProperty() throws IOException {
void shouldDeserializeObjectWithStatusProperty() throws IOException {
// We formerly falsely required a 'status' property object when using the
// configData endpoint. It was removed as a requirement from code and
// documentation, as it was unused. This test ensures we still behave correctly
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
*/
@Feature("Unit Tests - Direct Device Integration API")
@Story("Serializability of DDI api Models")
public class DdiConfigTest {
class DdiConfigTest {

private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();

@Test
@Description("Verify the correct serialization and deserialization of the model")
public void shouldSerializeAndDeserializeObject() throws IOException {
void shouldSerializeAndDeserializeObject() throws IOException {
// Setup
final DdiPolling ddiPolling = new DdiPolling("10");
final DdiConfig ddiConfig = new DdiConfig(ddiPolling);
Expand All @@ -47,7 +47,7 @@ public void shouldSerializeAndDeserializeObject() throws IOException {

@Test
@Description("Verify the correct deserialization of a model with a additional unknown property")
public void shouldDeserializeObjectWithUnknownProperty() throws IOException {
void shouldDeserializeObjectWithUnknownProperty() throws IOException {
// Setup
final String serializedDdiConfig = "{\"polling\":{\"sleep\":\"123\"},\"unknownProperty\":\"test\"}";

Expand All @@ -58,7 +58,7 @@ public void shouldDeserializeObjectWithUnknownProperty() throws IOException {

@Test
@Description("Verify that deserialization fails for known properties with a wrong datatype")
public void shouldFailForObjectWithWrongDataTypes() throws IOException {
void shouldFailForObjectWithWrongDataTypes() {
// Setup
final String serializedDdiConfig = "{\"polling\":{\"sleep\":[\"10\"]}}";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ void shouldSerializeAndDeserializeObject() throws IOException {
assertThat(deserializedDdiConfigurationBase.getConfirmation().getUpdate()).isEqualTo(ddiDeployment.getUpdate());
assertThat(deserializedDdiConfigurationBase.getConfirmation().getMaintenanceWindow())
.isEqualTo(ddiDeployment.getMaintenanceWindow());
assertThat(deserializedDdiConfigurationBase.getActionHistory().toString())
.isEqualTo(ddiActionHistory.toString());
assertThat(deserializedDdiConfigurationBase.getActionHistory())
.hasToString(ddiActionHistory.toString());
}

@Test
Expand All @@ -86,7 +86,7 @@ void shouldDeserializeObjectWithUnknownProperty() throws IOException {

@Test
@Description("Verify that deserialization fails for known properties with a wrong datatype")
void shouldFailForObjectWithWrongDataTypes() throws IOException {
void shouldFailForObjectWithWrongDataTypes() {
// Setup
final String serializedDdiConfirmationBase = "{" +
"\"id\":[\"1234\"],\"confirmation\":{\"download\":\"forced\"," +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
*/
@Feature("Unit Tests - Direct Device Integration API")
@Story("Serializability of DDI api Models")
public class DdiControllerBaseTest {
class DdiControllerBaseTest {

private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();

@Test
@Description("Verify the correct serialization and deserialization of the model")
public void shouldSerializeAndDeserializeObject() throws IOException {
void shouldSerializeAndDeserializeObject() throws IOException {
// Setup
final DdiPolling ddiPolling = new DdiPolling("10");
final DdiConfig ddiConfig = new DdiConfig(ddiPolling);
Expand All @@ -48,7 +48,7 @@ public void shouldSerializeAndDeserializeObject() throws IOException {

@Test
@Description("Verify the correct deserialization of a model with a additional unknown property")
public void shouldDeserializeObjectWithUnknownProperty() throws IOException {
void shouldDeserializeObjectWithUnknownProperty() throws IOException {
// Setup
final String serializedDdiControllerBase = "{\"config\":{\"polling\":{\"sleep\":\"123\"}},\"links\":[],\"unknownProperty\":\"test\"}";

Expand All @@ -59,7 +59,7 @@ public void shouldDeserializeObjectWithUnknownProperty() throws IOException {

@Test
@Description("Verify that deserialization fails for known properties with a wrong datatype")
public void shouldFailForObjectWithWrongDataTypes() throws IOException {
void shouldFailForObjectWithWrongDataTypes() {
// Setup
final String serializedDdiControllerBase = "{\"config\":{\"polling\":{\"sleep\":[\"123\"]}},\"links\":[],\"unknownProperty\":\"test\"}";

Expand Down
Loading

0 comments on commit d41f9ab

Please sign in to comment.