diff --git a/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiActionFeedbackTest.java b/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiActionFeedbackTest.java index a0520a579..4743adc38 100644 --- a/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiActionFeedbackTest.java +++ b/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiActionFeedbackTest.java @@ -14,7 +14,6 @@ import static org.assertj.core.api.Assertions.assertThat; 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; @@ -68,7 +67,7 @@ class DdiActionFeedbackTest { @Test @Description("Verify that deserialization fails for known properties with a wrong datatype") - void shouldFailForObjectWithWrongDataTypes() throws IOException { + void shouldFailForObjectWithWrongDataTypes() { // Setup final String serializedDdiActionFeedback = """ { diff --git a/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiActionHistoryTest.java b/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiActionHistoryTest.java index ac3f706b7..5693fefa1 100644 --- a/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiActionHistoryTest.java +++ b/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiActionHistoryTest.java @@ -29,13 +29,13 @@ import org.junit.jupiter.api.Test; */ @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 messages = Arrays.asList("Action status message 1", "Action status message 2"); @@ -50,7 +50,7 @@ public class DdiActionHistoryTest { @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 = """ { @@ -66,7 +66,7 @@ public class DdiActionHistoryTest { @Test @Description("Verify that deserialization fails for known properties with a wrong datatype") - public void shouldFailForObjectWithWrongDataTypes() throws IOException { + void shouldFailForObjectWithWrongDataTypes() { // Setup final String serializedDdiActionFeedback = """ { diff --git a/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiArtifactHashTest.java b/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiArtifactHashTest.java index 5b625fc4b..77ccbba70 100644 --- a/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiArtifactHashTest.java +++ b/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiArtifactHashTest.java @@ -27,13 +27,13 @@ import org.junit.jupiter.api.Test; */ @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"; @@ -51,7 +51,7 @@ public class DdiArtifactHashTest { @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\"}"; @@ -64,7 +64,7 @@ public class DdiArtifactHashTest { @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\""; diff --git a/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiArtifactTest.java b/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiArtifactTest.java index a9c2b2e4f..25dd5824f 100644 --- a/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiArtifactTest.java +++ b/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiArtifactTest.java @@ -27,13 +27,13 @@ import org.junit.jupiter.api.Test; */ @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"); @@ -57,7 +57,7 @@ public class DdiArtifactTest { @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\"}"; @@ -72,7 +72,7 @@ public class DdiArtifactTest { @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\":[]}"; diff --git a/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiCancelActionToStopTest.java b/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiCancelActionToStopTest.java index 30f7bf775..df1c6159a 100644 --- a/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiCancelActionToStopTest.java +++ b/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiCancelActionToStopTest.java @@ -27,13 +27,13 @@ import org.junit.jupiter.api.Test; */ @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); @@ -48,7 +48,7 @@ public class DdiCancelActionToStopTest { @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\"}"; @@ -60,7 +60,7 @@ public class DdiCancelActionToStopTest { @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\"]}"; diff --git a/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiCancelTest.java b/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiCancelTest.java index 75d45ff1b..7727cfbdc 100644 --- a/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiCancelTest.java +++ b/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiCancelTest.java @@ -27,13 +27,13 @@ import org.junit.jupiter.api.Test; */ @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"); @@ -49,7 +49,7 @@ public class DdiCancelTest { @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\"}"; @@ -61,7 +61,7 @@ public class DdiCancelTest { @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\"}}"; diff --git a/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiChunkTest.java b/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiChunkTest.java index a99adf9aa..82150a69e 100644 --- a/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiChunkTest.java +++ b/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiChunkTest.java @@ -29,13 +29,13 @@ import org.junit.jupiter.api.Test; */ @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"; @@ -50,12 +50,12 @@ public class DdiChunkTest { 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\"}"; @@ -64,12 +64,12 @@ public class DdiChunkTest { 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\":[]}"; diff --git a/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiConfigDataTest.java b/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiConfigDataTest.java index d8cc23ef6..ab3f2eef6 100644 --- a/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiConfigDataTest.java +++ b/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiConfigDataTest.java @@ -29,13 +29,13 @@ import org.junit.jupiter.api.Test; */ @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 data = new HashMap<>(); data.put("test", "data"); @@ -50,7 +50,7 @@ public class DdiConfigDataTest { @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\"}"; @@ -61,7 +61,7 @@ public class DdiConfigDataTest { @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\"}"; @@ -72,7 +72,7 @@ public class DdiConfigDataTest { @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 diff --git a/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiConfigTest.java b/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiConfigTest.java index 207db068a..1aff6c394 100644 --- a/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiConfigTest.java +++ b/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiConfigTest.java @@ -27,13 +27,13 @@ import org.junit.jupiter.api.Test; */ @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); @@ -47,7 +47,7 @@ public class DdiConfigTest { @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\"}"; @@ -58,7 +58,7 @@ public class DdiConfigTest { @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\"]}}"; diff --git a/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiConfirmationBaseTest.java b/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiConfirmationBaseTest.java index 41b6202c4..a5a1dda62 100644 --- a/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiConfirmationBaseTest.java +++ b/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiConfirmationBaseTest.java @@ -59,8 +59,8 @@ class DdiConfirmationBaseTest { 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 @@ -86,7 +86,7 @@ class DdiConfirmationBaseTest { @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\"," + diff --git a/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiControllerBaseTest.java b/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiControllerBaseTest.java index cb979020a..800979c71 100644 --- a/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiControllerBaseTest.java +++ b/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiControllerBaseTest.java @@ -27,13 +27,13 @@ import org.junit.jupiter.api.Test; */ @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); @@ -48,7 +48,7 @@ public class DdiControllerBaseTest { @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\"}"; @@ -59,7 +59,7 @@ public class DdiControllerBaseTest { @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\"}"; diff --git a/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiDeploymentBaseTest.java b/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiDeploymentBaseTest.java index 1c915d0c3..85bd32905 100644 --- a/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiDeploymentBaseTest.java +++ b/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiDeploymentBaseTest.java @@ -32,13 +32,13 @@ import org.junit.jupiter.api.Test; */ @Feature("Unit Tests - Direct Device Integration API") @Story("Serializability of DDI api Models") -public class DdiDeploymentBaseTest { +class DdiDeploymentBaseTest { 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 id = "1234"; final DdiDeployment ddiDeployment = new DdiDeployment(FORCED, ATTEMPT, Collections.emptyList(), AVAILABLE); @@ -54,12 +54,12 @@ public class DdiDeploymentBaseTest { assertThat(deserializedDdiDeploymentBase.getDeployment().getDownload()).isEqualTo(ddiDeployment.getDownload()); assertThat(deserializedDdiDeploymentBase.getDeployment().getUpdate()).isEqualTo(ddiDeployment.getUpdate()); assertThat(deserializedDdiDeploymentBase.getDeployment().getMaintenanceWindow()).isEqualTo(ddiDeployment.getMaintenanceWindow()); - assertThat(deserializedDdiDeploymentBase.getActionHistory().toString()).isEqualTo(ddiActionHistory.toString()); + assertThat(deserializedDdiDeploymentBase.getActionHistory()).hasToString(ddiActionHistory.toString()); } @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 serializedDdiDeploymentBase = "{\"id\":\"1234\",\"deployment\":{\"download\":\"forced\"," + "\"update\":\"attempt\",\"maintenanceWindow\":\"available\",\"chunks\":[]}," + @@ -75,7 +75,7 @@ public class DdiDeploymentBaseTest { @Test @Description("Verify that deserialization fails for known properties with a wrong datatype") - public void shouldFailForObjectWithWrongDataTypes() throws IOException { + void shouldFailForObjectWithWrongDataTypes() { // Setup final String serializedDdiDeploymentBase = "{\"id\":[\"1234\"],\"deployment\":{\"download\":\"forced\"," + "\"update\":\"attempt\",\"maintenanceWindow\":\"available\",\"chunks\":[]}," + diff --git a/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiDeploymentTest.java b/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiDeploymentTest.java index 0d926cc1f..d88731c32 100644 --- a/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiDeploymentTest.java +++ b/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiDeploymentTest.java @@ -31,13 +31,13 @@ import org.junit.jupiter.api.Test; */ @Feature("Unit Tests - Direct Device Integration API") @Story("Serializability of DDI api Models") -public class DdiDeploymentTest { +class DdiDeploymentTest { 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 DdiDeployment ddiDeployment = new DdiDeployment(FORCED, ATTEMPT, Collections.emptyList(), AVAILABLE); @@ -53,7 +53,7 @@ public class DdiDeploymentTest { @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 serializedDdiDeployment = "{\"download\":\"forced\",\"update\":\"attempt\", " + "\"maintenanceWindow\":\"available\",\"chunks\":[],\"unknownProperty\":\"test\"}"; @@ -67,7 +67,7 @@ public class DdiDeploymentTest { @Test @Description("Verify that deserialization fails for known properties with a wrong datatype") - public void shouldFailForObjectWithWrongDataTypes() throws IOException { + void shouldFailForObjectWithWrongDataTypes() { // Setup final String serializedDdiDeployment = "{\"download\":[\"forced\"],\"update\":\"attempt\", " + "\"maintenanceWindow\":\"available\",\"chunks\":[]}"; diff --git a/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiMetadataTest.java b/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiMetadataTest.java index dea717ea2..c1ce5009b 100644 --- a/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiMetadataTest.java +++ b/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiMetadataTest.java @@ -27,13 +27,13 @@ import org.junit.jupiter.api.Test; */ @Feature("Unit Tests - Direct Device Integration API") @Story("Serializability of DDI api Models") -public class DdiMetadataTest { +class DdiMetadataTest { 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 key = "testKey"; final String value = "testValue"; @@ -49,7 +49,7 @@ public class DdiMetadataTest { @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 serializedDdiMetadata = "{\"key\":\"testKey\",\"value\":\"testValue\",\"unknownProperty\":\"test\"}"; @@ -61,7 +61,7 @@ public class DdiMetadataTest { @Test @Description("Verify that deserialization fails for known properties with a wrong datatype") - public void shouldFailForObjectWithWrongDataTypes() throws IOException { + void shouldFailForObjectWithWrongDataTypes() { // Setup final String serializedDdiMetadata = "{\"key\":[\"testKey\"],\"value\":\"testValue\"}"; diff --git a/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiPollingTest.java b/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiPollingTest.java index c51c17aa9..9e9cb029e 100644 --- a/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiPollingTest.java +++ b/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiPollingTest.java @@ -27,13 +27,13 @@ import org.junit.jupiter.api.Test; */ @Feature("Unit Tests - Direct Device Integration API") @Story("Serializability of DDI api Models") -public class DdiPollingTest { +class DdiPollingTest { 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"); @@ -46,7 +46,7 @@ public class DdiPollingTest { @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 serializedDdiPolling = "{\"sleep\":\"10\",\"unknownProperty\":\"test\"}"; @@ -57,7 +57,7 @@ public class DdiPollingTest { @Test @Description("Verify that deserialization fails for known properties with a wrong datatype") - public void shouldFailForObjectWithWrongDataTypes() throws IOException { + void shouldFailForObjectWithWrongDataTypes() { // Setup final String serializedDdiPolling = "{\"sleep\":[\"10\"]}"; diff --git a/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiProgressTest.java b/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiProgressTest.java index 550ed47f8..68b8f648e 100644 --- a/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiProgressTest.java +++ b/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiProgressTest.java @@ -27,13 +27,13 @@ import org.junit.jupiter.api.Test; */ @Feature("Unit Tests - Direct Device Integration API") @Story("Serializability of DDI api Models") -public class DdiProgressTest { +class DdiProgressTest { 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 DdiProgress ddiProgress = new DdiProgress(30, 100); @@ -47,7 +47,7 @@ public class DdiProgressTest { @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 serializedDdiProgress = "{\"cnt\":30,\"of\":100,\"unknownProperty\":\"test\"}"; @@ -59,7 +59,7 @@ public class DdiProgressTest { @Test @Description("Verify that deserialization fails for known properties with a wrong datatype") - public void shouldFailForObjectWithWrongDataTypes() throws IOException { + void shouldFailForObjectWithWrongDataTypes() { // Setup final String serializedDdiProgress = "{\"cnt\":[30],\"of\":100}"; diff --git a/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiResultTest.java b/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiResultTest.java index 2b901449d..be9f05a12 100644 --- a/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiResultTest.java +++ b/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiResultTest.java @@ -28,13 +28,13 @@ import org.junit.jupiter.api.Test; */ @Feature("Unit Tests - Direct Device Integration API") @Story("Serializability of DDI api Models") -public class DdiResultTest { +class DdiResultTest { 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 DdiProgress ddiProgress = new DdiProgress(30, 100); final DdiResult ddiResult = new DdiResult(NONE, ddiProgress); @@ -50,7 +50,7 @@ public class DdiResultTest { @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 serializedDdiResult = "{\"finished\":\"none\",\"progress\":{\"cnt\":30,\"of\":100},\"unknownProperty\":\"test\"}"; @@ -63,7 +63,7 @@ public class DdiResultTest { @Test @Description("Verify that deserialization fails for known properties with a wrong datatype") - public void shouldFailForObjectWithWrongDataTypes() throws IOException { + void shouldFailForObjectWithWrongDataTypes() { // Setup final String serializedDdiResult = "{\"finished\":[\"none\"],\"progress\":{\"cnt\":30,\"of\":100}}"; diff --git a/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiStatusTest.java b/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiStatusTest.java index f0b88049c..27b5bf0d5 100644 --- a/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiStatusTest.java +++ b/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/DdiStatusTest.java @@ -34,14 +34,14 @@ import org.junit.jupiter.params.provider.MethodSource; */ @Feature("Unit Tests - Direct Device Integration API") @Story("Serializability of DDI api Models") -public class DdiStatusTest { +class DdiStatusTest { private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); @ParameterizedTest @MethodSource("ddiStatusPossibilities") @Description("Verify the correct serialization and deserialization of the model") - public void shouldSerializeAndDeserializeObject(final DdiResult ddiResult, final DdiStatus ddiStatus) throws IOException { + void shouldSerializeAndDeserializeObject(final DdiResult ddiResult, final DdiStatus ddiStatus) throws IOException { // Test final String serializedDdiStatus = OBJECT_MAPPER.writeValueAsString(ddiStatus); final DdiStatus deserializedDdiStatus = OBJECT_MAPPER.readValue(serializedDdiStatus, DdiStatus.class); @@ -56,7 +56,7 @@ public class DdiStatusTest { @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 serializedDdiStatus = "{\"execution\":\"proceeding\",\"result\":{\"finished\":\"none\"," + "\"progress\":{\"cnt\":30,\"of\":100}},\"details\":[],\"unknownProperty\":\"test\"}"; @@ -72,7 +72,7 @@ public class DdiStatusTest { @Test @Description("Verify the correct deserialization of a model with a provided code (optional)") - public void shouldDeserializeObjectWithOptionalCode() throws IOException { + void shouldDeserializeObjectWithOptionalCode() throws IOException { // Setup final String serializedDdiStatus = "{\"execution\":\"proceeding\",\"result\":{\"finished\":\"none\"," + "\"progress\":{\"cnt\":30,\"of\":100}},\"code\": 12,\"details\":[]}"; @@ -88,7 +88,7 @@ public class DdiStatusTest { @Test @Description("Verify that deserialization fails for known properties with a wrong datatype") - public void shouldFailForObjectWithWrongDataTypes() throws IOException { + void shouldFailForObjectWithWrongDataTypes() { // Setup final String serializedDdiStatus = "{\"execution\":[\"proceeding\"],\"result\":{\"finished\":\"none\"," + "\"progress\":{\"cnt\":30,\"of\":100}},\"details\":[]}"; diff --git a/hawkbit-ddi/hawkbit-ddi-resource/src/main/java/org/eclipse/hawkbit/ddi/rest/resource/DataConversionHelper.java b/hawkbit-ddi/hawkbit-ddi-resource/src/main/java/org/eclipse/hawkbit/ddi/rest/resource/DataConversionHelper.java index 00c854228..e53c19df2 100644 --- a/hawkbit-ddi/hawkbit-ddi-resource/src/main/java/org/eclipse/hawkbit/ddi/rest/resource/DataConversionHelper.java +++ b/hawkbit-ddi/hawkbit-ddi-resource/src/main/java/org/eclipse/hawkbit/ddi/rest/resource/DataConversionHelper.java @@ -136,14 +136,14 @@ public final class DataConversionHelper { final HttpRequest request, final ControllerManagement controllerManagement) { final Map> metadata = controllerManagement .findTargetVisibleMetaDataBySoftwareModuleId(uAction.getDistributionSet().getModules().stream() - .map(SoftwareModule::getId).collect(Collectors.toList())); + .map(SoftwareModule::getId).toList()); return new ResponseList<>(uAction.getDistributionSet().getModules().stream() .map(module -> new DdiChunk(mapChunkLegacyKeys(module.getType().getKey()), module.getVersion(), module.getName(), module.isEncrypted() ? Boolean.TRUE : null, createArtifacts(target, module, artifactUrlHandler, systemManagement, request), mapMetadata(metadata.get(module.getId())))) - .collect(Collectors.toList())); + .toList()); } @@ -153,13 +153,13 @@ public final class DataConversionHelper { return new ResponseList<>(module.getArtifacts().stream() .map(artifact -> createArtifact(target, artifactUrlHandler, artifact, systemManagement, request)) - .collect(Collectors.toList())); + .toList()); } private static List mapMetadata(final List metadata) { return CollectionUtils.isEmpty(metadata) ? null - : metadata.stream().map(md -> new DdiMetadata(md.getKey(), md.getValue())).collect(Collectors.toList()); + : metadata.stream().map(md -> new DdiMetadata(md.getKey(), md.getValue())).toList(); } private static String mapChunkLegacyKeys(final String key) { diff --git a/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiArtifactDownloadTest.java b/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiArtifactDownloadTest.java index 5ca2bc210..33c261d63 100644 --- a/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiArtifactDownloadTest.java +++ b/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiArtifactDownloadTest.java @@ -163,7 +163,7 @@ public class DdiArtifactDownloadTest extends AbstractDDiApiIntegrationTest { public void downloadArtifactThroughFileName() throws Exception { downLoadProgress = 1; shippedBytes = 0; - assertThat(softwareModuleManagement.findAll(PAGE)).hasSize(0); + assertThat(softwareModuleManagement.findAll(PAGE)).isEmpty(); // create target final Target target = testdataFactory.createTarget(); @@ -251,7 +251,7 @@ public class DdiArtifactDownloadTest extends AbstractDDiApiIntegrationTest { final Artifact artifact = artifactManagement.create( new ArtifactUpload(new ByteArrayInputStream(random), getOsModule(ds), "file1", false, resultLength)); - assertThat(random.length).isEqualTo(resultLength); + assertThat(random).hasSize(resultLength); // now assign and download successful assignDistributionSet(ds, targets); diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/BaseAmqpServiceTest.java b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/BaseAmqpServiceTest.java index 189ede489..86d14213a 100644 --- a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/BaseAmqpServiceTest.java +++ b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/BaseAmqpServiceTest.java @@ -35,7 +35,7 @@ import org.springframework.amqp.support.converter.MessageConversionException; @ExtendWith(MockitoExtension.class) @Feature("Component Tests - Device Management Federation API") @Story("Base Amqp Service Test") -public class BaseAmqpServiceTest { +class BaseAmqpServiceTest { @Mock private RabbitTemplate rabbitTemplate; @@ -43,13 +43,13 @@ public class BaseAmqpServiceTest { private BaseAmqpService baseAmqpService; @BeforeEach - public void setup() { + void setup() { baseAmqpService = new BaseAmqpService(rabbitTemplate); } @Test @Description("Verify that the message conversion works") - public void convertMessageTest() { + void convertMessageTest() { final DmfActionUpdateStatus actionUpdateStatus = createActionStatus(); when(rabbitTemplate.getMessageConverter()).thenReturn(new Jackson2JsonMessageConverter()); @@ -64,7 +64,7 @@ public class BaseAmqpServiceTest { @Test @Description("Tests invalid null message content") @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) }) - public void convertMessageWithNullContent() { + void convertMessageWithNullContent() { final Message message = createMessage("".getBytes()); assertThatExceptionOfType(MessageConversionException.class) .as("Expected MessageConversionException for invalid JSON") @@ -74,7 +74,7 @@ public class BaseAmqpServiceTest { @Test @Description("Tests invalid empty message content") @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) }) - public void updateActionStatusWithEmptyContent() { + void updateActionStatusWithEmptyContent() { final Message message = createMessage("".getBytes()); assertThatExceptionOfType(MessageConversionException.class) .as("Expected MessageConversionException for invalid JSON") @@ -84,7 +84,7 @@ public class BaseAmqpServiceTest { @Test @Description("Tests invalid json message content") @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) }) - public void updateActionStatusWithInvalidJsonContent() { + void updateActionStatusWithInvalidJsonContent() { final Message message = createMessage("Invalid Json".getBytes()); when(rabbitTemplate.getMessageConverter()).thenReturn(new Jackson2JsonMessageConverter()); diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/DelegatingAmqpErrorHandlerTest.java b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/DelegatingAmqpErrorHandlerTest.java index ccd0d6aa9..c632a8c16 100644 --- a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/DelegatingAmqpErrorHandlerTest.java +++ b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/DelegatingAmqpErrorHandlerTest.java @@ -22,11 +22,11 @@ import org.springframework.util.ErrorHandler; @Feature("Unit Tests - Delegating Conditional Error Handler") @Story("Delegating Conditional Error Handler") -public class DelegatingAmqpErrorHandlerTest { +class DelegatingAmqpErrorHandlerTest { @Test @Description("Verifies that with a list of conditional error handlers, the error is delegated to specific handler.") - public void verifyDelegationHandling() { + void verifyDelegationHandling() { List handlers = new ArrayList<>(); handlers.add(new IllegalArgumentExceptionHandler()); handlers.add(new IndexOutOfBoundsExceptionHandler()); @@ -38,7 +38,7 @@ public class DelegatingAmqpErrorHandlerTest { @Test @Description("Verifies that default handler is used if no handlers are defined for the specific exception.") - public void verifyDefaultDelegationHandling() { + void verifyDefaultDelegationHandling() { List handlers = new ArrayList<>(); handlers.add(new IllegalArgumentExceptionHandler()); handlers.add(new IndexOutOfBoundsExceptionHandler()); @@ -49,7 +49,7 @@ public class DelegatingAmqpErrorHandlerTest { } // Test class - public class IllegalArgumentExceptionHandler implements AmqpErrorHandler { + static class IllegalArgumentExceptionHandler implements AmqpErrorHandler { @Override public void doHandle(final Throwable t, final AmqpErrorHandlerChain chain) { @@ -62,7 +62,7 @@ public class DelegatingAmqpErrorHandlerTest { } // Test class - public class IndexOutOfBoundsExceptionHandler implements AmqpErrorHandler { + static class IndexOutOfBoundsExceptionHandler implements AmqpErrorHandler { @Override public void doHandle(final Throwable t, final AmqpErrorHandlerChain chain) { @@ -75,11 +75,10 @@ public class DelegatingAmqpErrorHandlerTest { } // Test class - public class DefaultErrorHandler implements ErrorHandler { + static class DefaultErrorHandler implements ErrorHandler { @Override - public void - handleError(Throwable t) { + public void handleError(final Throwable t) { throw new RuntimeException(t); } } diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpMessageDispatcherServiceIntegrationTest.java b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpMessageDispatcherServiceIntegrationTest.java index ea658da64..fcf7e1bf0 100644 --- a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpMessageDispatcherServiceIntegrationTest.java +++ b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpMessageDispatcherServiceIntegrationTest.java @@ -661,8 +661,9 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt final Message message = replyToListener.getLatestEventMessage(topic); final Map headers = message.getMessageProperties().getHeaders(); - assertThat(headers).containsEntry("type", EVENT.toString()); - assertThat(headers).containsEntry("topic", topic.toString()); + assertThat(headers) + .containsEntry("type", EVENT.toString()) + .containsEntry("topic", topic.toString()); final DmfBatchDownloadAndUpdateRequest batchRequest = (DmfBatchDownloadAndUpdateRequest) getDmfClient() .getMessageConverter().fromMessage(message); @@ -711,10 +712,8 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt private List getLatestMultiActionMessages(final String expectedControllerId) { final Message multiactionMessage = replyToListener.getLatestEventMessage(EventTopic.MULTI_ACTION); - assertThat(multiactionMessage.getMessageProperties().getHeaders().get(MessageHeaderKey.THING_ID)) - .isEqualTo(expectedControllerId); - return ((DmfMultiActionRequest) getDmfClient().getMessageConverter().fromMessage(multiactionMessage)) - .getElements(); + assertThat(multiactionMessage.getMessageProperties().getHeaders()).containsEntry(MessageHeaderKey.THING_ID, expectedControllerId); + return ((DmfMultiActionRequest) getDmfClient().getMessageConverter().fromMessage(multiactionMessage)).getElements(); } private void updateActionViaDmfClient(final String controllerId, final long actionId, @@ -762,10 +761,9 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt private void assertLatestMultiActionMessageContainsInstallMessages(final String controllerId, final List> smIdsOfActionsExpected) { final Message multiactionMessage = replyToListener.getLatestEventMessage(EventTopic.MULTI_ACTION); - assertThat(multiactionMessage.getMessageProperties().getHeaders().get(MessageHeaderKey.THING_ID)) - .isEqualTo(controllerId); - final DmfMultiActionRequest multiActionRequest = (DmfMultiActionRequest) getDmfClient().getMessageConverter() - .fromMessage(multiactionMessage); + assertThat(multiactionMessage.getMessageProperties().getHeaders()).containsEntry(MessageHeaderKey.THING_ID, controllerId); + final DmfMultiActionRequest multiActionRequest = + (DmfMultiActionRequest) getDmfClient().getMessageConverter().fromMessage(multiactionMessage); final List> smIdsOfActionsFound = getDownloadAndUpdateRequests(multiActionRequest).stream() .map(AmqpMessageDispatcherServiceIntegrationTest::getSmIds).toList(); diff --git a/hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DmfConfirmRequest.java b/hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DmfConfirmRequest.java index b04ea173d..18af09312 100644 --- a/hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DmfConfirmRequest.java +++ b/hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DmfConfirmRequest.java @@ -17,12 +17,14 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; /** * JSON representation of confirm request. */ +@EqualsAndHashCode(callSuper = true) @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) public class DmfConfirmRequest extends DmfActionRequest { diff --git a/hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DmfDownloadAndUpdateRequest.java b/hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DmfDownloadAndUpdateRequest.java index 52c205c63..50470ef03 100644 --- a/hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DmfDownloadAndUpdateRequest.java +++ b/hawkbit-dmf/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DmfDownloadAndUpdateRequest.java @@ -17,15 +17,19 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.EqualsAndHashCode; import lombok.Getter; +import lombok.Setter; /** * JSON representation of download and update request. */ +@EqualsAndHashCode(callSuper = true) @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) public class DmfDownloadAndUpdateRequest extends DmfActionRequest { + @Setter @Getter @JsonProperty private String targetSecurityToken; @@ -33,10 +37,6 @@ public class DmfDownloadAndUpdateRequest extends DmfActionRequest { @JsonProperty private List softwareModules; - public void setTargetSecurityToken(final String targetSecurityToken) { - this.targetSecurityToken = targetSecurityToken; - } - public List getSoftwareModules() { if (softwareModules == null) { return Collections.emptyList(); @@ -45,17 +45,11 @@ public class DmfDownloadAndUpdateRequest extends DmfActionRequest { return Collections.unmodifiableList(softwareModules); } - /** - * Add a Software module. - * - * @param createSoftwareModule the module - */ public void addSoftwareModule(final DmfSoftwareModule createSoftwareModule) { if (softwareModules == null) { softwareModules = new ArrayList<>(); } softwareModules.add(createSoftwareModule); - } } \ No newline at end of file diff --git a/hawkbit-mgmt/hawkbit-mgmt-server/src/test/java/org/eclipse/hawkbit/app/mgmt/CorsTest.java b/hawkbit-mgmt/hawkbit-mgmt-server/src/test/java/org/eclipse/hawkbit/app/mgmt/CorsTest.java index c0e7a8b2f..b7ae524e4 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-server/src/test/java/org/eclipse/hawkbit/app/mgmt/CorsTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-server/src/test/java/org/eclipse/hawkbit/app/mgmt/CorsTest.java @@ -36,18 +36,18 @@ import org.springframework.test.web.servlet.ResultActions; HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN }) @Feature("Integration Test - Security") @Story("CORS") -public class CorsTest extends AbstractSecurityTest { +class CorsTest extends AbstractSecurityTest { - final static String ALLOWED_ORIGIN_FIRST = "http://test.first.origin"; - final static String ALLOWED_ORIGIN_SECOND = "http://test.second.origin"; + static final String ALLOWED_ORIGIN_FIRST = "http://test.first.origin"; + static final String ALLOWED_ORIGIN_SECOND = "http://test.second.origin"; - private final static String INVALID_ORIGIN = "http://test.invalid.origin"; - private final static String INVALID_CORS_REQUEST = "Invalid CORS request"; + private static final String INVALID_ORIGIN = "http://test.invalid.origin"; + private static final String INVALID_CORS_REQUEST = "Invalid CORS request"; @Test @Description("Ensures that Cors is working.") @WithUser(authorities = SpRole.TENANT_ADMIN, autoCreateTenant = false) - public void validateCorsRequest() throws Exception { + void validateCorsRequest() throws Exception { performOptionsRequestToRestWithOrigin(ALLOWED_ORIGIN_FIRST).andExpect(status().isOk()) .andExpect(header().string(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN, ALLOWED_ORIGIN_FIRST)); performOptionsRequestToRestWithOrigin(ALLOWED_ORIGIN_SECOND).andExpect(status().isOk()) diff --git a/hawkbit-monolith/hawkbit-update-server/src/test/java/org/eclipse/hawkbit/app/CorsTest.java b/hawkbit-monolith/hawkbit-update-server/src/test/java/org/eclipse/hawkbit/app/CorsTest.java index 8269dd4c1..0212775bb 100644 --- a/hawkbit-monolith/hawkbit-update-server/src/test/java/org/eclipse/hawkbit/app/CorsTest.java +++ b/hawkbit-monolith/hawkbit-update-server/src/test/java/org/eclipse/hawkbit/app/CorsTest.java @@ -36,18 +36,18 @@ import org.springframework.test.web.servlet.ResultActions; HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN }) @Feature("Integration Test - Security") @Story("CORS") -public class CorsTest extends AbstractSecurityTest { +class CorsTest extends AbstractSecurityTest { - final static String ALLOWED_ORIGIN_FIRST = "http://test.first.origin"; - final static String ALLOWED_ORIGIN_SECOND = "http://test.second.origin"; + static final String ALLOWED_ORIGIN_FIRST = "http://test.first.origin"; + static final String ALLOWED_ORIGIN_SECOND = "http://test.second.origin"; - private final static String INVALID_ORIGIN = "http://test.invalid.origin"; - private final static String INVALID_CORS_REQUEST = "Invalid CORS request"; + private static final String INVALID_ORIGIN = "http://test.invalid.origin"; + private static final String INVALID_CORS_REQUEST = "Invalid CORS request"; @Test @Description("Ensures that Cors is working.") @WithUser(authorities = SpRole.TENANT_ADMIN, autoCreateTenant = false) - public void validateCorsRequest() throws Exception { + void validateCorsRequest() throws Exception { performOptionsRequestToRestWithOrigin(ALLOWED_ORIGIN_FIRST).andExpect(status().isOk()) .andExpect(header().string(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN, ALLOWED_ORIGIN_FIRST)); performOptionsRequestToRestWithOrigin(ALLOWED_ORIGIN_SECOND).andExpect(status().isOk()) diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/event/remote/DownloadProgressEvent.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/event/remote/DownloadProgressEvent.java index 0a8f48603..9942df424 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/event/remote/DownloadProgressEvent.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/event/remote/DownloadProgressEvent.java @@ -11,6 +11,7 @@ package org.eclipse.hawkbit.repository.event.remote; import java.io.Serial; +import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; import org.eclipse.hawkbit.repository.model.ActionStatus; @@ -18,6 +19,7 @@ import org.eclipse.hawkbit.repository.model.ActionStatus; * TenantAwareEvent that contains an updated download progress for a given * ActionStatus that was written for a download request. */ +@EqualsAndHashCode(callSuper = true) @NoArgsConstructor // for serialization libs like jackson public class DownloadProgressEvent extends RemoteTenantAwareEvent { diff --git a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/event/remote/entity/DistributionSetUpdatedEvent.java b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/event/remote/entity/DistributionSetUpdatedEvent.java index 42e87e061..e625a916d 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/event/remote/entity/DistributionSetUpdatedEvent.java +++ b/hawkbit-repository/hawkbit-repository-api/src/main/java/org/eclipse/hawkbit/repository/event/remote/entity/DistributionSetUpdatedEvent.java @@ -11,6 +11,7 @@ package org.eclipse.hawkbit.repository.event.remote.entity; import java.io.Serial; +import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; import org.eclipse.hawkbit.repository.event.entity.EntityUpdatedEvent; import org.eclipse.hawkbit.repository.model.DistributionSet; @@ -19,6 +20,7 @@ import org.eclipse.hawkbit.repository.model.DistributionSet; * Defines the remote event for updating a {@link DistributionSet}. */ @NoArgsConstructor // for serialization libs like jackson +@EqualsAndHashCode(callSuper = true) public class DistributionSetUpdatedEvent extends RemoteEntityEvent implements EntityUpdatedEvent { @Serial diff --git a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractTagUpdateCreate.java b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractTagUpdateCreate.java index 1ed0ffd5c..2cc76eb73 100644 --- a/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractTagUpdateCreate.java +++ b/hawkbit-repository/hawkbit-repository-core/src/main/java/org/eclipse/hawkbit/repository/builder/AbstractTagUpdateCreate.java @@ -12,7 +12,6 @@ package org.eclipse.hawkbit.repository.builder; import java.util.Optional; import org.eclipse.hawkbit.repository.ValidString; -import org.springframework.util.StringUtils; /** * Create and update builder DTO. diff --git a/hawkbit-repository/hawkbit-repository-core/src/test/java/org/eclipse/hawkbit/event/BusProtoStuffMessageConverterTest.java b/hawkbit-repository/hawkbit-repository-core/src/test/java/org/eclipse/hawkbit/event/BusProtoStuffMessageConverterTest.java index 2e8106309..b0cba6c25 100644 --- a/hawkbit-repository/hawkbit-repository-core/src/test/java/org/eclipse/hawkbit/event/BusProtoStuffMessageConverterTest.java +++ b/hawkbit-repository/hawkbit-repository-core/src/test/java/org/eclipse/hawkbit/event/BusProtoStuffMessageConverterTest.java @@ -30,7 +30,7 @@ import org.springframework.messaging.MessageHeaders; import org.springframework.messaging.converter.MessageConversionException; @ExtendWith(MockitoExtension.class) -public class BusProtoStuffMessageConverterTest { +class BusProtoStuffMessageConverterTest { private final BusProtoStuffMessageConverter underTest = new BusProtoStuffMessageConverter(); @@ -41,13 +41,13 @@ public class BusProtoStuffMessageConverterTest { private Message messageMock; @BeforeEach - public void before() { + void before() { when(targetMock.getId()).thenReturn(1L); } @Test @Description("Verifies that the TargetCreatedEvent can be successfully serialized and deserialized") - public void successfullySerializeAndDeserializeEvent() { + void successfullySerializeAndDeserializeEvent() { final TargetCreatedEvent targetCreatedEvent = new TargetCreatedEvent(targetMock, "1"); // serialize final Object serializedEvent = underTest.convertToInternal(targetCreatedEvent, @@ -63,7 +63,7 @@ public class BusProtoStuffMessageConverterTest { @Test @Description("Verifies that a MessageConversationException is thrown on missing event-type information encoding") - public void missingEventTypeMappingThrowsMessageConversationException() { + void missingEventTypeMappingThrowsMessageConversationException() { final DummyRemoteEntityEvent dummyEvent = new DummyRemoteEntityEvent(targetMock, "applicationId"); final MessageHeaders messageHeaders = new MessageHeaders(new HashMap<>()); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/CustomBaseRepositoryFactoryBean.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/CustomBaseRepositoryFactoryBean.java index 1886d935a..fbbd8b423 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/CustomBaseRepositoryFactoryBean.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/CustomBaseRepositoryFactoryBean.java @@ -26,15 +26,13 @@ import org.springframework.data.repository.core.support.RepositoryFactorySupport * @param * @param */ -public class CustomBaseRepositoryFactoryBean, S, ID> - extends JpaRepositoryFactoryBean { +public class CustomBaseRepositoryFactoryBean, S, ID> extends JpaRepositoryFactoryBean { @Autowired BaseRepositoryTypeProvider baseRepoProvider; /** - * Creates a new {@link JpaRepositoryFactoryBean} for the given repository - * interface. + * Creates a new {@link JpaRepositoryFactoryBean} for the given repository interface. * * @param repositoryInterface must not be {@literal null}. */ diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/DefaultRolloutApprovalStrategy.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/DefaultRolloutApprovalStrategy.java index 256c49ef3..d9a61967f 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/DefaultRolloutApprovalStrategy.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/DefaultRolloutApprovalStrategy.java @@ -23,7 +23,7 @@ import org.springframework.security.core.Authentication; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.userdetails.User; -import org.springframework.util.StringUtils; +import org.springframework.util.ObjectUtils; /** * Default implementation of {@link RolloutApprovalStrategy}. Decides whether @@ -93,7 +93,7 @@ public class DefaultRolloutApprovalStrategy implements RolloutApprovalStrategy { if (RolloutStatus.CREATING == rollout.getStatus()) { final String actor = rollout.getLastModifiedBy() != null ? rollout.getLastModifiedBy() : rollout.getCreatedBy(); - if (!StringUtils.isEmpty(actor)) { + if (!ObjectUtils.isEmpty(actor)) { return systemSecurityContext.runAsSystem( () -> userAuthoritiesResolver.getUserAuthorities(rollout.getTenant(), actor)); } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/DistributionSetTypeElement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/DistributionSetTypeElement.java index 4644c7a9a..eb81729f9 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/DistributionSetTypeElement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/model/DistributionSetTypeElement.java @@ -16,7 +16,6 @@ import jakarta.persistence.Column; import jakarta.persistence.ConstraintMode; import jakarta.persistence.EmbeddedId; import jakarta.persistence.Entity; -import jakarta.persistence.FetchType; import jakarta.persistence.ForeignKey; import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/repository/BaseEntityRepository.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/repository/BaseEntityRepository.java index 8487b17ed..cdddd9ef7 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/repository/BaseEntityRepository.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/repository/BaseEntityRepository.java @@ -124,8 +124,8 @@ public interface BaseEntityRepository Specification byIdsSpec(final Iterable ids) { final Collection collection; - if (ids instanceof Collection) { - collection = (Collection) ids; + if (ids instanceof Collection idCollection) { + collection = idCollection; } else { collection = new LinkedList<>(); ids.forEach(collection::add); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/repository/BaseEntityRepositoryACM.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/repository/BaseEntityRepositoryACM.java index e6d4d1b30..9bc6d8ecb 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/repository/BaseEntityRepositoryACM.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/repository/BaseEntityRepositoryACM.java @@ -326,8 +326,7 @@ public class BaseEntityRepositoryACM try { // TODO - cache mapping so to speed things final Method delegateMethod = - BaseEntityRepositoryACM.class.getDeclaredMethod( - method.getName(), method.getParameterTypes()); + BaseEntityRepositoryACM.class.getDeclaredMethod(method.getName(), method.getParameterTypes()); return delegateMethod.invoke(repositoryACM, args); } catch (final NoSuchMethodException e) { // call to repository itself @@ -369,7 +368,7 @@ public class BaseEntityRepositoryACM } @SuppressWarnings({ "rawtypes", "unchecked" }) - private static Set toSetDistinct(final Iterable i) { + private static Set toSetDistinct(final Iterable i) { final Set set = new HashSet<>(); i.forEach(set::add); return set; diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/entity/DistributionSetCreatedEventTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/entity/DistributionSetCreatedEventTest.java index 9e1ec0593..f3be0eee5 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/entity/DistributionSetCreatedEventTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/entity/DistributionSetCreatedEventTest.java @@ -20,11 +20,11 @@ import org.junit.jupiter.api.Test; */ @Feature("Component Tests - Repository") @Story("Test DistributionSetCreatedEvent") -public class DistributionSetCreatedEventTest extends AbstractRemoteEntityEventTest { +class DistributionSetCreatedEventTest extends AbstractRemoteEntityEventTest { @Test @Description("Verifies that the distribution set entity reloading by remote created event works") - public void testDistributionSetCreatedEvent() { + void testDistributionSetCreatedEvent() { assertAndCreateRemoteEvent(DistributionSetCreatedEvent.class); } @@ -33,5 +33,4 @@ public class DistributionSetCreatedEventTest extends AbstractRemoteEntityEventTe return distributionSetManagement.create(entityFactory.distributionSet().create() .name("incomplete").version("2").description("incomplete").type("os")); } - -} +} \ No newline at end of file diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/entity/DistributionSetTagEventTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/entity/DistributionSetTagEventTest.java index 868e2e6d5..1fcefab2f 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/entity/DistributionSetTagEventTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/entity/DistributionSetTagEventTest.java @@ -20,17 +20,17 @@ import org.junit.jupiter.api.Test; */ @Feature("Component Tests - Repository") @Story("Test DistributionSetTagCreatedEvent and DistributionSetTagUpdateEvent") -public class DistributionSetTagEventTest extends AbstractRemoteEntityEventTest { +class DistributionSetTagEventTest extends AbstractRemoteEntityEventTest { @Test @Description("Verifies that the distribution set tag entity reloading by remote created event works") - public void testDistributionSetTagCreatedEvent() { + void testDistributionSetTagCreatedEvent() { assertAndCreateRemoteEvent(DistributionSetTagCreatedEvent.class); } @Test @Description("Verifies that the distribution set tag entity reloading by remote updated event works") - public void testDistributionSetTagUpdateEvent() { + void testDistributionSetTagUpdateEvent() { assertAndCreateRemoteEvent(DistributionSetTagUpdatedEvent.class); } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/entity/DistributionSetUpdatedEventTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/entity/DistributionSetUpdatedEventTest.java index 1a7082546..c71e55df1 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/entity/DistributionSetUpdatedEventTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/entity/DistributionSetUpdatedEventTest.java @@ -20,11 +20,11 @@ import org.junit.jupiter.api.Test; */ @Feature("Component Tests - Repository") @Story("Test DistributionSetUpdateEvent") -public class DistributionSetUpdatedEventTest extends AbstractRemoteEntityEventTest { +class DistributionSetUpdatedEventTest extends AbstractRemoteEntityEventTest { @Test @Description("Verifies that the distribution set entity reloading by remote updated event works") - public void testDistributionSetUpdateEvent() { + void testDistributionSetUpdateEvent() { assertAndCreateRemoteEvent(DistributionSetUpdatedEvent.class); } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/entity/SoftwareModuleEventTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/entity/SoftwareModuleEventTest.java index 885dd31ac..224318c58 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/entity/SoftwareModuleEventTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/entity/SoftwareModuleEventTest.java @@ -20,17 +20,17 @@ import org.junit.jupiter.api.Test; */ @Feature("Component Tests - Repository") @Story("Test SoftwareModuleCreatedEvent, SoftwareModuleUpdatedEvent") -public class SoftwareModuleEventTest extends AbstractRemoteEntityEventTest { +class SoftwareModuleEventTest extends AbstractRemoteEntityEventTest { @Test @Description("Verifies that the software module entity reloading by remote created event works") - public void testTargetCreatedEvent() { + void testTargetCreatedEvent() { assertAndCreateRemoteEvent(SoftwareModuleCreatedEvent.class); } @Test @Description("Verifies that the software module entity reloading by remote updated event works") - public void testTargetUpdatedEvent() { + void testTargetUpdatedEvent() { assertAndCreateRemoteEvent(SoftwareModuleUpdatedEvent.class); } @@ -38,5 +38,4 @@ public class SoftwareModuleEventTest extends AbstractRemoteEntityEventTest actions = assignDistributionSets( Arrays.asList(toDeploymentRequest(controllerId, dsId), toDeploymentRequest(controllerId, dsId2))) - .stream().flatMap(s -> s.getAssignedEntity().stream()).collect(Collectors.toList()); + .stream().flatMap(s -> s.getAssignedEntity().stream()).toList(); assertThat(actions).hasSize(2); assertThat(confirmationManagement.findActiveActionsWaitingConfirmation(controllerId)).hasSize(2) diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ControllerManagementTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ControllerManagementTest.java index 129af52ce..3d315359e 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ControllerManagementTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ControllerManagementTest.java @@ -23,7 +23,6 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import java.io.ByteArrayInputStream; -import java.net.URISyntaxException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -39,7 +38,6 @@ import io.qameta.allure.Description; import io.qameta.allure.Feature; import io.qameta.allure.Step; import io.qameta.allure.Story; -import org.apache.commons.lang3.RandomUtils; import org.assertj.core.api.Assertions; import org.eclipse.hawkbit.im.authentication.SpPermission; import org.eclipse.hawkbit.repository.RepositoryProperties; @@ -199,7 +197,6 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { .status(Action.Status.RUNNING).occurredAt(System.currentTimeMillis()) .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()) @@ -307,7 +304,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { assertThat(actionStatusRepository.count()).isEqualTo(2); assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(2); - assertThat(activeActionExistsForControllerId(DEFAULT_CONTROLLER_ID)).isEqualTo(true); + assertThat(activeActionExistsForControllerId(DEFAULT_CONTROLLER_ID)).isTrue(); } @Test @@ -338,7 +335,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = SoftwareModuleCreatedEvent.class, count = 1) }) - void entityQueriesReferringToNotExistingEntitiesThrowsException() throws URISyntaxException { + void entityQueriesReferringToNotExistingEntitiesThrowsException() { final Target target = testdataFactory.createTarget(); final SoftwareModule module = testdataFactory.createSoftwareModuleOs(); @@ -622,7 +619,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { @Expect(type = TargetAssignDistributionSetEvent.class, count = 1) }) void hasTargetArtifactAssignedIsTrueWithMultipleArtifacts() { final int artifactSize = 5 * 1024; - final byte[] random = RandomUtils.nextBytes(artifactSize); + final byte[] random = randomBytes(artifactSize); final DistributionSet ds = testdataFactory.createDistributionSet(""); final DistributionSet ds2 = testdataFactory.createDistributionSet("2"); @@ -1164,7 +1161,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { assertThat(actionStatusRepository.count()).isEqualTo(2); assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(2); - assertThat(activeActionExistsForControllerId(DEFAULT_CONTROLLER_ID)).isEqualTo(false); + assertThat(activeActionExistsForControllerId(DEFAULT_CONTROLLER_ID)).isFalse(); } @Test @@ -1191,7 +1188,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { assertThat(actionStatusRepository.count()).isEqualTo(3); assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(3); - assertThat(activeActionExistsForControllerId(DEFAULT_CONTROLLER_ID)).isEqualTo(false); + assertThat(activeActionExistsForControllerId(DEFAULT_CONTROLLER_ID)).isFalse(); } @Test @@ -1219,7 +1216,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { assertThat(actionStatusRepository.count()).isEqualTo(4); assertThat(controllerManagement.findActionStatusByAction(PAGE, actionId).getNumberOfElements()).isEqualTo(4); - assertThat(activeActionExistsForControllerId(DEFAULT_CONTROLLER_ID)).isEqualTo(false); + assertThat(activeActionExistsForControllerId(DEFAULT_CONTROLLER_ID)).isFalse(); } @Test @@ -1564,7 +1561,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { controllerManagement.deleteExistingTarget(target.getControllerId()); - assertThat(targetRepository.count()).as("target should not exist anymore").isEqualTo(0L); + assertThat(targetRepository.count()).as("target should not exist anymore").isZero(); } @Test @@ -1574,7 +1571,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { assertThatExceptionOfType(EntityNotFoundException.class) .as("No EntityNotFoundException thrown when deleting a non-existing target") .isThrownBy(() -> controllerManagement.deleteExistingTarget("BB")); - assertThat(targetRepository.count()).as("target should not exist").isEqualTo(0L); + assertThat(targetRepository.count()).as("target should not exist").isZero(); } @Test @@ -1589,7 +1586,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { assertThat(targetRepository.count()).as("target exists and is ready for deletion").isEqualTo(1L); controllerManagement.deleteExistingTarget(target.getControllerId()); - assertThat(targetRepository.count()).as("target should not exist anymore").isEqualTo(0L); + assertThat(targetRepository.count()).as("target should not exist anymore").isZero(); assertThatExceptionOfType(EntityNotFoundException.class) .as("No EntityNotFoundException thrown when deleting a non-existing target") @@ -1769,7 +1766,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { // verify attribute removal final Map updatedAttributes = targetManagement.getControllerAttributes(controllerId); - assertThat(updatedAttributes.size()).isEqualTo(previousSize - 2); + assertThat(updatedAttributes).hasSize(previousSize - 2); assertThat(updatedAttributes).doesNotContainKeys("k1", "k3"); } @@ -1786,9 +1783,9 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { // verify attribute merge final Map updatedAttributes = targetManagement.getControllerAttributes(controllerId); - assertThat(updatedAttributes.size()).isEqualTo(4); + assertThat(updatedAttributes).hasSize(4); assertThat(updatedAttributes).containsAllEntriesOf(mergeAttributes); - assertThat(updatedAttributes.get("k1")).isEqualTo("v1_modified_again"); + assertThat(updatedAttributes).containsEntry("k1", "v1_modified_again"); attributes.keySet().forEach(assertThat(updatedAttributes)::containsKey); } @@ -1806,9 +1803,9 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { // verify attribute replacement final Map updatedAttributes = targetManagement.getControllerAttributes(controllerId); - assertThat(updatedAttributes.size()).isEqualTo(replacementAttributes.size()); + assertThat(updatedAttributes).hasSameSizeAs(replacementAttributes); assertThat(updatedAttributes).containsAllEntriesOf(replacementAttributes); - assertThat(updatedAttributes.get("k1")).isEqualTo("v1_modified"); + assertThat(updatedAttributes).containsEntry("k1", "v1_modified"); attributes.entrySet().forEach(assertThat(updatedAttributes)::doesNotContain); } @@ -1822,7 +1819,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { // verify initial attributes final Map updatedAttributes = targetManagement.getControllerAttributes(controllerId); - assertThat(updatedAttributes.size()).isEqualTo(attributes.size()); + assertThat(updatedAttributes).hasSameSizeAs(attributes); assertThat(updatedAttributes).containsAllEntriesOf(attributes); } @@ -1849,7 +1846,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { .addUpdateActionStatus(entityFactory.actionStatus().create(actionId).status(Status.DOWNLOADED)); controllerManagement.addUpdateActionStatus(entityFactory.actionStatus().create(actionId).status(status)); - assertThat(activeActionExistsForControllerId(DEFAULT_CONTROLLER_ID)).isEqualTo(false); + assertThat(activeActionExistsForControllerId(DEFAULT_CONTROLLER_ID)).isFalse(); } @Step @@ -1883,7 +1880,7 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { } private void assertNoActiveActionsExistsForControllerId(final String controllerId) { - assertThat(activeActionExistsForControllerId(controllerId)).isEqualTo(false); + assertThat(activeActionExistsForControllerId(controllerId)).isFalse(); } private boolean activeActionExistsForControllerId(final String controllerId) { diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DeploymentManagementTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DeploymentManagementTest.java index e947c9376..0443de3de 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DeploymentManagementTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DeploymentManagementTest.java @@ -23,9 +23,7 @@ import java.util.Collections; 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; import jakarta.validation.ConstraintViolationException; @@ -108,7 +106,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { @Test @Description("Tests that an exception is thrown when a target is assigned to an incomplete distribution set") - public void verifyAssignTargetsToIncompleteDistribution() { + void verifyAssignTargetsToIncompleteDistribution() { final DistributionSet distributionSet = testdataFactory.createIncompleteDistributionSet(); final Target target = testdataFactory.createTarget(); @@ -119,7 +117,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { @Test @Description("Tests that an exception is thrown when a target is assigned to an invalidated distribution set") - public void verifyAssignTargetsToInvalidDistribution() { + void verifyAssignTargetsToInvalidDistribution() { final DistributionSet distributionSet = testdataFactory.createAndInvalidateDistributionSet(); final Target target = testdataFactory.createTarget(); @@ -484,7 +482,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { void assignedDistributionSet() { final List controllerIds = testdataFactory.createTargets(10).stream().map(Target::getControllerId) - .collect(Collectors.toList()); + .toList(); final List onlineAssignedTargets = testdataFactory.createTargets(10, "2"); controllerIds.addAll(onlineAssignedTargets.stream().map(Target::getControllerId).toList()); @@ -494,12 +492,12 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { final long current = System.currentTimeMillis(); final List> offlineAssignments = controllerIds.stream() - .map(targetId -> new SimpleEntry<>(targetId, ds.getId())).collect(Collectors.toList()); + .map(targetId -> (Entry)new SimpleEntry<>(targetId, ds.getId())).toList(); final List assignmentResults = deploymentManagement .offlineAssignedDistributionSets(offlineAssignments); assertThat(assignmentResults).hasSize(1); final List targets = assignmentResults.get(0).getAssignedEntity().stream().map(Action::getTarget) - .collect(Collectors.toList()); + .toList(); assertThat(actionRepository.count()).isEqualTo(20); assertThat(findActionsByDistributionSet(PAGE, ds.getId())).as("Offline actions are not active") @@ -547,7 +545,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { .isEqualTo(tenantAware.getCurrentUsername()); return a; }) - .map(action -> action.getDistributionSet().getId()).collect(Collectors.toList()); + .map(action -> action.getDistributionSet().getId()).toList(); assertThat(assignedDsIds).containsExactlyInAnyOrderElementsOf(dsIds); }); } @@ -610,7 +608,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { void previousAssignmentsAreNotCanceledInMultiAssignMode() { enableMultiAssignments(); final List targets = testdataFactory.createTargets(10); - final List targetIds = targets.stream().map(Target::getControllerId).collect(Collectors.toList()); + final List targetIds = targets.stream().map(Target::getControllerId).toList(); // First assignment final DistributionSet ds1 = testdataFactory.createDistributionSet("Multi-assign-1"); @@ -648,7 +646,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { .assignDistributionSets(deploymentRequests); assertThat(getResultingActionCount(results)).isEqualTo(deploymentRequests.size()); - final List dsIds = distributionSets.stream().map(DistributionSet::getId).collect(Collectors.toList()); + final List dsIds = distributionSets.stream().map(DistributionSet::getId).toList(); targets.forEach(target -> { final List assignedDsIds = deploymentManagement.findActionsByTarget(target.getControllerId(), PAGE) .stream() @@ -658,7 +656,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { .isEqualTo(tenantAware.getCurrentUsername()); return a; }) - .map(action -> action.getDistributionSet().getId()).collect(Collectors.toList()); + .map(action -> action.getDistributionSet().getId()).toList(); assertThat(assignedDsIds).containsExactlyInAnyOrderElementsOf(dsIds); }); } @@ -689,7 +687,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { assertThat(getResultingActionCount(results)).isEqualTo(deploymentRequests.size()); - final List dsIds = distributionSets.stream().map(DistributionSet::getId).collect(Collectors.toList()); + final List dsIds = distributionSets.stream().map(DistributionSet::getId).toList(); targets.forEach(target -> deploymentManagement.findActionsByTarget(target.getControllerId(), PAGE).forEach(action -> { assertThat(action.getDistributionSet().getId()).isIn(dsIds); @@ -748,8 +746,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { @ValueSource(booleans = { true, false }) @Description("Assignments with confirmation flow active will result in actions in 'WAIT_FOR_CONFIRMATION' state") void assignmentWithConfirmationFlowActive(final boolean confirmationRequired) { - final List controllerIds = testdataFactory.createTargets(1).stream().map(Target::getControllerId) - .collect(Collectors.toList()); + final List controllerIds = testdataFactory.createTargets(1).stream().map(Target::getControllerId).toList(); final DistributionSet distributionSet = testdataFactory.createDistributionSet(); enableConfirmationFlow(); @@ -859,16 +856,14 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { @Test @Description("Assignments with confirmation flow deactivated will result in actions in only in 'RUNNING' state") void verifyConfirmationRequiredFlagHaveNoInfluenceIfFlowIsDeactivated() { - final List targets1 = testdataFactory.createTargets("group1", 1).stream().map(Target::getControllerId) - .collect(Collectors.toList()); - final List targets2 = testdataFactory.createTargets("group2", 1).stream().map(Target::getControllerId) - .collect(Collectors.toList()); + final List targets1 = testdataFactory.createTargets("group1", 1).stream().map(Target::getControllerId).toList(); + final List targets2 = testdataFactory.createTargets("group2", 1).stream().map(Target::getControllerId).toList(); final DistributionSet distributionSet = testdataFactory.createDistributionSet(); final List results = Stream .concat(assignDistributionSetToTargets(distributionSet, targets1, true).stream(), // assignDistributionSetToTargets(distributionSet, targets2, false).stream()) // - .collect(Collectors.toList()); + .toList(); final List controllerIds = Stream.concat(targets1.stream(), targets2.stream()).toList(); @@ -1073,7 +1068,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { @Expect(type = TargetCreatedEvent.class, count = 10), @Expect(type = ActionCreatedEvent.class, count = 10), @Expect(type = TargetUpdatedEvent.class, count = 10) }) - void failDistributionSetAssigmentThatIsNotComplete() throws InterruptedException { + void failDistributionSetAssigmentThatIsNotComplete() { final List targets = testdataFactory.createTargets(10); final SoftwareModule ah = testdataFactory.createSoftwareModuleApp(); @@ -1131,7 +1126,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { assertThat(page.getTotalElements()).as("wrong size of actions") .isEqualTo(noOfDeployedTargets * noOfDistributionSets); - // only records retrieved from the DB can be evaluated to be sure that all fields are populated; + // only records retrieved from the DB can be evaluated to be sure that all fields are populated final List allFoundTargets = targetRepository.findAll(); final List deployedTargetsFromDB = targetRepository.findAllById(deployedTargetIDs); @@ -1203,7 +1198,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { final List updatedTsDsA = testdataFactory .sendUpdateActionStatusToTargets(deployResWithDsA.getDeployedTargets(), Status.FINISHED, Collections.singletonList("alles gut")) - .stream().map(Action::getTarget).collect(Collectors.toList()); + .stream().map(Action::getTarget).toList(); // verify, that dsA is deployed correctly for (final Target t_ : updatedTsDsA) { @@ -1223,12 +1218,12 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { // activeActions, add a corresponding cancelAction and another // UpdateAction for dsA final List deployed2DS = assignDistributionSet(dsA, deployResWithDsB.getDeployedTargets()) - .getAssignedEntity().stream().map(Action::getTarget).collect(Collectors.toList()); + .getAssignedEntity().stream().map(Action::getTarget).toList(); findActionsByDistributionSet(pageRequest, dsA.getId()).getContent().get(1); // get final updated version of targets final List deployResWithDsBTargets = targetManagement.getByControllerID(deployResWithDsB - .getDeployedTargets().stream().map(Target::getControllerId).collect(Collectors.toList())); + .getDeployedTargets().stream().map(Target::getControllerId).toList()); assertThat(deployed2DS).as("deployed ds is wrong").usingElementComparator(controllerIdComparator()) .containsAll(deployResWithDsBTargets); @@ -1285,7 +1280,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { // verify that deleted attribute is used correctly List allFoundDS = distributionSetManagement.findByCompleted(PAGE, true).getContent(); - assertThat(allFoundDS.size()).as("no ds should be founded").isZero(); + assertThat(allFoundDS).as("no ds should be founded").isEmpty(); assertThat(distributionSetRepository.findAll(SpecificationsBuilder.combineWithAnd(Arrays .asList(DistributionSetSpecification.isDeleted(true), DistributionSetSpecification.isCompleted(true))), @@ -1302,7 +1297,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { // successfully and no activeAction is referring to created distribution // sets allFoundDS = distributionSetManagement.findByCompleted(pageRequest, true).getContent(); - assertThat(allFoundDS.size()).as("no ds should be founded").isZero(); + assertThat(allFoundDS).as("no ds should be founded").isEmpty(); assertThat(distributionSetRepository.findAll(SpecificationsBuilder.combineWithAnd(Arrays .asList(DistributionSetSpecification.isDeleted(true), DistributionSetSpecification.isCompleted(true))), PAGE).getContent()).as("wrong size of founded ds").hasSize(noOfDistributionSets); @@ -1349,7 +1344,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { // doing the assignment targs = assignDistributionSet(dsA, targs).getAssignedEntity().stream().map(Action::getTarget) - .collect(Collectors.toList()); + .toList(); implicitLock(dsA); Target targ = targetManagement.getByControllerID(targs.iterator().next().getControllerId()).get(); @@ -1392,7 +1387,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { "wrong installed ds"); targs = assignDistributionSet(dsB.getId(), "target-id-A").getAssignedEntity().stream().map(Action::getTarget) - .collect(Collectors.toList()); + .toList(); implicitLock(dsB); targ = targs.iterator().next(); @@ -1696,7 +1691,7 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { // deployedTargets for (final DistributionSet ds : dsList) { deployedTargets = assignDistributionSet(ds, deployedTargets).getAssignedEntity().stream() - .map(Action::getTarget).collect(Collectors.toList()); + .map(Action::getTarget).toList(); implicitLock(ds); } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetInvalidationManagementTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetInvalidationManagementTest.java index f7d9ff3fd..66101ae48 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetInvalidationManagementTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetInvalidationManagementTest.java @@ -69,7 +69,7 @@ class DistributionSetInvalidationManagementTest extends AbstractJpaIntegrationTe // if status is pending, the assignment has not been canceled assertThat(targetRepository.findById(target.getId()).get().getUpdateStatus()) .isEqualTo(TargetUpdateStatus.PENDING); - assertThat(findActionsByTarget(target).size()).isEqualTo(1); + assertThat(findActionsByTarget(target)).hasSize(1); assertThat(findActionsByTarget(target).get(0).getStatus()).isEqualTo(Status.RUNNING); } } @@ -101,7 +101,7 @@ class DistributionSetInvalidationManagementTest extends AbstractJpaIntegrationTe assertThat( targetRepository.findById(invalidationTestData.getTargets().get(0).getId()).get().getUpdateStatus()) .isEqualTo(TargetUpdateStatus.PENDING); - assertThat(findActionsByTarget(target).size()).isEqualTo(1); + assertThat(findActionsByTarget(target)).hasSize(1); assertThat(findActionsByTarget(target).get(0).getStatus()).isEqualTo(Status.RUNNING); } } @@ -131,7 +131,7 @@ class DistributionSetInvalidationManagementTest extends AbstractJpaIntegrationTe for (final Target target : invalidationTestData.getTargets()) { assertThat(targetRepository.findById(target.getId()).get().getUpdateStatus()) .isEqualTo(TargetUpdateStatus.IN_SYNC); - assertThat(findActionsByTarget(target).size()).isEqualTo(1); + assertThat(findActionsByTarget(target)).hasSize(1); assertThat(findActionsByTarget(target).get(0).getStatus()).isEqualTo(Status.CANCELED); } } @@ -158,7 +158,7 @@ class DistributionSetInvalidationManagementTest extends AbstractJpaIntegrationTe for (final Target target : invalidationTestData.getTargets()) { assertThat(targetRepository.findById(target.getId()).get().getUpdateStatus()) .isEqualTo(TargetUpdateStatus.PENDING); - assertThat(findActionsByTarget(target).size()).isEqualTo(1); + assertThat(findActionsByTarget(target)).hasSize(1); assertThat(findActionsByTarget(target).get(0).getStatus()).isEqualTo(Status.CANCELING); } } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetManagementSecurityTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetManagementSecurityTest.java index 71c69cbb3..1301c0441 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetManagementSecurityTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetManagementSecurityTest.java @@ -46,7 +46,7 @@ class DistributionSetManagementSecurityTest @Test @Description("Tests ManagementAPI PreAuthorized method with correct and insufficient permissions.") - public void assignSoftwareModulesPermissionsCheck() { + void assignSoftwareModulesPermissionsCheck() { assertPermissions(() -> distributionSetManagement.assignSoftwareModules(1L, List.of(1L)), List.of(SpPermission.UPDATE_REPOSITORY)); } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetManagementTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetManagementTest.java index 635331773..4516715f8 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetManagementTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetManagementTest.java @@ -320,20 +320,21 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest { final DistributionSetTag tag = distributionSetTagManagement.create(entityFactory.tag().create().name(TAG1_NAME)); final List assignedDS = distributionSetManagement.assignTag(assignDS, tag.getId()); - assertThat(assignedDS.size()).as("assigned ds has wrong size").isEqualTo(4); - assignedDS.stream().map(JpaDistributionSet.class::cast).forEach(ds -> assertThat(ds.getTags().size()) + assertThat(assignedDS).as("assigned ds has wrong size").hasSize(4); + assignedDS.stream().map(JpaDistributionSet.class::cast).forEach(ds -> assertThat(ds.getTags()) .as("ds has wrong tag size") - .isEqualTo(1)); + .hasSize(1)); final DistributionSetTag findDistributionSetTag = getOrThrow(distributionSetTagManagement.findByName(TAG1_NAME)); - assertThat(assignedDS.size()).as("assigned ds has wrong size") - .isEqualTo(distributionSetManagement.findByTag(tag.getId(), PAGE).getNumberOfElements()); + assertThat(assignedDS) + .as("assigned ds has wrong size") + .hasSize(distributionSetManagement.findByTag(tag.getId(), PAGE).getNumberOfElements()); final JpaDistributionSet unAssignDS = (JpaDistributionSet) distributionSetManagement .unassignTag(List.of(assignDS.get(0)), findDistributionSetTag.getId()).get(0); assertThat(unAssignDS.getId()).as("unassigned ds is wrong").isEqualTo(assignDS.get(0)); - assertThat(unAssignDS.getTags().size()).as("unassigned ds has wrong tag size").isZero(); + assertThat(unAssignDS.getTags()).as("unassigned ds has wrong tag size").isEmpty(); assertThat(distributionSetTagManagement.findByName(TAG1_NAME)).isPresent(); assertThat(distributionSetManagement.findByTag(tag.getId(), PAGE).getNumberOfElements()) .as("ds tag ds has wrong ds size").isEqualTo(3); @@ -559,7 +560,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest { final DistributionSet dsNewType = distributionSetManagement.create( entityFactory.distributionSet().create().name("newtype").version("1").type(newType.getKey()).modules( - dsDeleted.getModules().stream().map(SoftwareModule::getId).collect(Collectors.toList()))); + dsDeleted.getModules().stream().map(SoftwareModule::getId).toList())); assignDistributionSet(dsDeleted, testdataFactory.createTargets(5)); distributionSetManagement.delete(dsDeleted.getId()); @@ -616,7 +617,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest { distributionSetManagement.get(distributionSet.getId()).map(DistributionSet::isLocked).orElse(false)) .isTrue(); // assert software modules are locked - assertThat(distributionSet.getModules().size()).isNotEqualTo(0); + assertThat(distributionSet.getModules().size()).isNotZero(); distributionSetManagement.getWithDetails(distributionSet.getId()).map(DistributionSet::getModules) .orElseThrow().forEach(module -> assertThat(module.isLocked()).isTrue()); } @@ -667,7 +668,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest { .orElse(true)) .isFalse(); // assert software modules are not unlocked - assertThat(distributionSet.getModules().size()).isNotEqualTo(0); + assertThat(distributionSet.getModules().size()).isNotZero(); distributionSetManagement.getWithDetails(distributionSet.getId()).map(DistributionSet::getModules) .orElseThrow().forEach(module -> assertThat(module.isLocked()).isTrue()); } @@ -677,7 +678,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest { void lockDistributionSetApplied() { final DistributionSet distributionSet = testdataFactory.createDistributionSet("ds-1"); final int softwareModuleCount = distributionSet.getModules().size(); - assertThat(softwareModuleCount).isNotEqualTo(0); + assertThat(softwareModuleCount).isNotZero(); distributionSetManagement.lock(distributionSet.getId()); assertThat( distributionSetManagement.get(distributionSet.getId()).map(DistributionSet::isLocked).orElse(false)) @@ -688,18 +689,18 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest { .as("Attempt to modify a locked DS software modules should throw an exception") .isThrownBy(() -> distributionSetManagement.assignSoftwareModules( distributionSet.getId(), List.of(testdataFactory.createSoftwareModule("sm-1").getId()))); - assertThat(distributionSetManagement.getWithDetails(distributionSet.getId()).get().getModules().size()) + assertThat(distributionSetManagement.getWithDetails(distributionSet.getId()).get().getModules()) .as("Software module shall not be added to a locked DS.") - .isEqualTo(softwareModuleCount); + .hasSize(softwareModuleCount); // try remove assertThatExceptionOfType(LockedException.class) .as("Attempt to modify a locked DS software modules should throw an exception") .isThrownBy(() -> distributionSetManagement.unassignSoftwareModule( distributionSet.getId(), distributionSet.getModules().stream().findFirst().get().getId())); - assertThat(distributionSetManagement.getWithDetails(distributionSet.getId()).get().getModules().size()) + assertThat(distributionSetManagement.getWithDetails(distributionSet.getId()).get().getModules()) .as("Software module shall not be removed from a locked DS.") - .isEqualTo(softwareModuleCount); + .hasSize(softwareModuleCount); } @Test @@ -853,7 +854,7 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest { assertThat(foundDs).hasSize(3); - final List collect = foundDs.stream().map(DistributionSet::getId).collect(Collectors.toList()); + final List collect = foundDs.stream().map(DistributionSet::getId).toList(); assertThat(collect).containsAll(searchIds); } @@ -1029,7 +1030,6 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest { @Step private void createAndUpdateDistributionSetWithInvalidVersion(final DistributionSet set) { - assertThatExceptionOfType(ConstraintViolationException.class) .as("entity with too long version should not be created") .isThrownBy(() -> distributionSetManagement.create(entityFactory.distributionSet().create().name("a") diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetTagManagementSecurityTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetTagManagementSecurityTest.java index 94324caf2..1beb795e3 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetTagManagementSecurityTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetTagManagementSecurityTest.java @@ -26,8 +26,7 @@ import org.springframework.data.domain.Pageable; @Feature("SecurityTests - DistributionSetTagManagement") @Story("SecurityTests DistributionSetTagManagement") -public class DistributionSetTagManagementSecurityTest - extends AbstractRepositoryManagementSecurityTest { +class DistributionSetTagManagementSecurityTest extends AbstractRepositoryManagementSecurityTest { @Override protected RepositoryManagement getRepositoryManagement() { diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetTypeManagementSecurityTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetTypeManagementSecurityTest.java index 118259b0f..b05c73415 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetTypeManagementSecurityTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetTypeManagementSecurityTest.java @@ -25,7 +25,7 @@ import org.junit.jupiter.api.Test; @Feature("SecurityTests - DistributionSetTypeManagement") @Story("SecurityTests DistributionSetTypeManagement") -public class DistributionSetTypeManagementSecurityTest +class DistributionSetTypeManagementSecurityTest extends AbstractRepositoryManagementSecurityTest { @Override diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetTypeManagementTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetTypeManagementTest.java index d3801dcdd..cadc0b91c 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetTypeManagementTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetTypeManagementTest.java @@ -156,8 +156,7 @@ class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTest { distributionSetTypeManagement.assignMandatorySoftwareModuleTypes(dsType2.getId(), moduleTypeIds.subList(0, quota)); assertThat(distributionSetTypeManagement.get(dsType2.getId())).isNotEmpty(); - assertThat(distributionSetTypeManagement.get(dsType2.getId()).get().getMandatoryModuleTypes().size()) - .isEqualTo(quota); + assertThat(distributionSetTypeManagement.get(dsType2.getId()).get().getMandatoryModuleTypes()).hasSize(quota); // assign one more to trigger the quota exceeded error assertThatExceptionOfType(AssignmentQuotaExceededException.class) .isThrownBy(() -> distributionSetTypeManagement.assignMandatorySoftwareModuleTypes(dsType2.getId(), @@ -168,8 +167,7 @@ class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTest { .create(entityFactory.distributionSetType().create().key("dst3").name("dst3")); distributionSetTypeManagement.assignOptionalSoftwareModuleTypes(dsType3.getId(), moduleTypeIds.subList(0, quota)); assertThat(distributionSetTypeManagement.get(dsType3.getId())).isNotEmpty(); - assertThat(distributionSetTypeManagement.get(dsType3.getId()).get().getOptionalModuleTypes().size()) - .isEqualTo(quota); + assertThat(distributionSetTypeManagement.get(dsType3.getId()).get().getOptionalModuleTypes()).hasSize(quota); // assign one more to trigger the quota exceeded error assertThatExceptionOfType(AssignmentQuotaExceededException.class) .isThrownBy(() -> distributionSetTypeManagement.assignOptionalSoftwareModuleTypes(dsType3.getId(), diff --git a/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/AbstractIntegrationTest.java b/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/AbstractIntegrationTest.java index c8c720c9b..a8aa690c5 100644 --- a/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/AbstractIntegrationTest.java +++ b/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/AbstractIntegrationTest.java @@ -346,9 +346,8 @@ public abstract class AbstractIntegrationTest { return distributionSetAssignmentResults; } - protected DistributionSetAssignmentResult assignDistributionSet(final DistributionSet ds, - final List targets) { - final List targetIds = targets.stream().map(Target::getControllerId).collect(Collectors.toList()); + protected DistributionSetAssignmentResult assignDistributionSet(final DistributionSet ds, final List targets) { + final List targetIds = targets.stream().map(Target::getControllerId).toList(); return assignDistributionSet(ds.getId(), targetIds, ActionType.FORCED); } diff --git a/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/DatasourceContext.java b/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/DatasourceContext.java index d9b7e1829..e69cadbd2 100644 --- a/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/DatasourceContext.java +++ b/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/DatasourceContext.java @@ -33,9 +33,6 @@ public class DatasourceContext { private final String password; private final String randomSchemaName = RANDOM_DB_PREFIX + TestdataFactory.randomString(10); - /** - * Constructor - */ public DatasourceContext(final String database, final String datasourceUrl, final String username, final String password) { this.database = database; this.datasourceUrl = datasourceUrl; diff --git a/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/TestdataFactory.java b/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/TestdataFactory.java index b2fd1998d..e456b360f 100644 --- a/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/TestdataFactory.java +++ b/hawkbit-repository/hawkbit-repository-test/src/main/java/org/eclipse/hawkbit/repository/test/util/TestdataFactory.java @@ -93,6 +93,8 @@ public class TestdataFactory { public static final String INVISIBLE_SM_MD_KEY = "invisibleMetdataKey"; public static final String INVISIBLE_SM_MD_VALUE = "invisibleMetdataValue"; + public static final RandomStringUtils RANDOM_STRING_UTILS = RandomStringUtils.secure(); + /** * default {@link Target#getControllerId()}. */ @@ -119,27 +121,22 @@ public class TestdataFactory { public static final String DS_TYPE_DEFAULT = "test_default_ds_type"; /** - * Key of test "os" {@link SoftwareModuleType} : mandatory firmware in - * {@link #DS_TYPE_DEFAULT}. + * Key of test "os" {@link SoftwareModuleType} : mandatory firmware in {@link #DS_TYPE_DEFAULT}. */ public static final String SM_TYPE_OS = "os"; /** - * Key of test "runtime" {@link SoftwareModuleType} : optional firmware in - * {@link #DS_TYPE_DEFAULT}. + * Key of test "runtime" {@link SoftwareModuleType} : optional firmware in {@link #DS_TYPE_DEFAULT}. */ public static final String SM_TYPE_RT = "runtime"; /** - * Key of test "application" {@link SoftwareModuleType} : optional software in - * {@link #DS_TYPE_DEFAULT}. + * Key of test "application" {@link SoftwareModuleType} : optional software in {@link #DS_TYPE_DEFAULT}. */ public static final String SM_TYPE_APP = "application"; public static final String DEFAULT_COLOUR = "#000000"; - public static final RandomStringUtils RANDOM_STRING_UTILS = RandomStringUtils.secure(); - private static final String SPACE_AND_DESCRIPTION = " description"; @Autowired diff --git a/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/security/DosFilter.java b/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/security/DosFilter.java index 2bfa2dc04..1c1fba4bf 100644 --- a/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/security/DosFilter.java +++ b/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/security/DosFilter.java @@ -133,7 +133,7 @@ public class DosFilter extends OncePerRequestFilter { } private static boolean checkIpFails(final String ip) { - return ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip); + return ip == null || ip.isEmpty() || "unknown".equalsIgnoreCase(ip); } private static boolean handleMissingIpAddress(final HttpServletResponse response) { diff --git a/hawkbit-sdk/hawkbit-sdk-device/src/main/java/org/eclipse/hawkbit/sdk/device/DdiController.java b/hawkbit-sdk/hawkbit-sdk-device/src/main/java/org/eclipse/hawkbit/sdk/device/DdiController.java index 8f67710ef..606f3fcc8 100644 --- a/hawkbit-sdk/hawkbit-sdk-device/src/main/java/org/eclipse/hawkbit/sdk/device/DdiController.java +++ b/hawkbit-sdk/hawkbit-sdk-device/src/main/java/org/eclipse/hawkbit/sdk/device/DdiController.java @@ -189,11 +189,8 @@ public class DdiController { executor.schedule(this::poll, getPollMillis(controllerBase), TimeUnit.MILLISECONDS); } }, - () -> { - // error has occurred or no controller base hasn't been acquired - executor.schedule(this::poll, DEFAULT_POLL_MS, TimeUnit.MILLISECONDS); - } - )); + () -> // error has occurred or no controller base hasn't been acquired + executor.schedule(this::poll, DEFAULT_POLL_MS, TimeUnit.MILLISECONDS))); } private Optional getControllerBase() { diff --git a/hawkbit-security/hawkbit-security-controller/src/main/java/org/eclipse/hawkbit/security/controller/ControllerPreAuthenticateSecurityTokenFilter.java b/hawkbit-security/hawkbit-security-controller/src/main/java/org/eclipse/hawkbit/security/controller/ControllerPreAuthenticateSecurityTokenFilter.java index 83d0087d5..836b003b5 100644 --- a/hawkbit-security/hawkbit-security-controller/src/main/java/org/eclipse/hawkbit/security/controller/ControllerPreAuthenticateSecurityTokenFilter.java +++ b/hawkbit-security/hawkbit-security-controller/src/main/java/org/eclipse/hawkbit/security/controller/ControllerPreAuthenticateSecurityTokenFilter.java @@ -78,8 +78,8 @@ public class ControllerPreAuthenticateSecurityTokenFilter extends AbstractContro return controllerManagement.getByControllerId(securityToken.getControllerId()); }, securityToken.getTenant()); - return target.map(t -> new HeaderAuthentication(t.getControllerId(), - systemSecurityContext.runAsSystemAsTenant(() -> t.getSecurityToken(), securityToken.getTenant()))) + return target.map(t -> new HeaderAuthentication( + t.getControllerId(), systemSecurityContext.runAsSystemAsTenant(t::getSecurityToken, securityToken.getTenant()))) .orElse(null); } diff --git a/hawkbit-security/hawkbit-security-controller/src/main/java/org/eclipse/hawkbit/security/controller/ControllerPreAuthenticatedSecurityHeaderFilter.java b/hawkbit-security/hawkbit-security-controller/src/main/java/org/eclipse/hawkbit/security/controller/ControllerPreAuthenticatedSecurityHeaderFilter.java index b1662bb42..7df8c9813 100644 --- a/hawkbit-security/hawkbit-security-controller/src/main/java/org/eclipse/hawkbit/security/controller/ControllerPreAuthenticatedSecurityHeaderFilter.java +++ b/hawkbit-security/hawkbit-security-controller/src/main/java/org/eclipse/hawkbit/security/controller/ControllerPreAuthenticatedSecurityHeaderFilter.java @@ -105,8 +105,7 @@ public class ControllerPreAuthenticatedSecurityHeaderFilter extends AbstractCont : securityToken.getControllerId()); final List knownHashes = splitMultiHashBySemicolon(authorityNameConfigurationValue); - return knownHashes.stream().map(hashItem -> new HeaderAuthentication(controllerId, hashItem)) - .collect(Collectors.toSet()); + return knownHashes.stream().map(hashItem -> new HeaderAuthentication(controllerId, hashItem)).collect(Collectors.toSet()); } @Override @@ -115,7 +114,7 @@ public class ControllerPreAuthenticatedSecurityHeaderFilter extends AbstractCont } private static List splitMultiHashBySemicolon(final String knownIssuerHashes) { - return Arrays.stream(knownIssuerHashes.split("[;,]")).map(String::toLowerCase).collect(Collectors.toList()); + return Arrays.stream(knownIssuerHashes.split("[;,]")).map(String::toLowerCase).toList(); } /** diff --git a/hawkbit-security/hawkbit-security-controller/src/test/java/org/eclipse/hawkbit/security/controller/ControllerPreAuthenticatedAnonymousDownloadTest.java b/hawkbit-security/hawkbit-security-controller/src/test/java/org/eclipse/hawkbit/security/controller/ControllerPreAuthenticatedAnonymousDownloadTest.java index d6e492885..8e28c46c7 100644 --- a/hawkbit-security/hawkbit-security-controller/src/test/java/org/eclipse/hawkbit/security/controller/ControllerPreAuthenticatedAnonymousDownloadTest.java +++ b/hawkbit-security/hawkbit-security-controller/src/test/java/org/eclipse/hawkbit/security/controller/ControllerPreAuthenticatedAnonymousDownloadTest.java @@ -24,13 +24,10 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.security.core.authority.SimpleGrantedAuthority; -/** - * - */ @Feature("Unit Tests - Security") @Story("Exclude path aware shallow ETag filter") @ExtendWith(MockitoExtension.class) -public class ControllerPreAuthenticatedAnonymousDownloadTest { +class ControllerPreAuthenticatedAnonymousDownloadTest { private ControllerPreAuthenticatedAnonymousDownload underTest; @@ -41,19 +38,19 @@ public class ControllerPreAuthenticatedAnonymousDownloadTest { private TenantAware tenantAwareMock; @BeforeEach - public void before() { + void before() { underTest = new ControllerPreAuthenticatedAnonymousDownload(tenantConfigurationManagementMock, tenantAwareMock, new SystemSecurityContext(tenantAwareMock)); } @Test - public void useCorrectTenantConfiguationKey() { + void useCorrectTenantConfiguationKey() { assertThat(underTest.getTenantConfigurationKey()).as("Should be using the correct tenant configuration key") .isEqualTo(underTest.getTenantConfigurationKey()); } @Test - public void successfulAuthenticationAdditionalAuthoritiesForDownload() { + void successfulAuthenticationAdditionalAuthoritiesForDownload() { assertThat(underTest.getSuccessfulAuthenticationAuthorities()) .as("Additional authorities should be containing the download anonymous role") .contains(new SimpleGrantedAuthority(SpringEvalExpressions.CONTROLLER_ROLE)); diff --git a/hawkbit-security/hawkbit-security-controller/src/test/java/org/eclipse/hawkbit/security/controller/ControllerPreAuthenticatedSecurityHeaderFilterTest.java b/hawkbit-security/hawkbit-security-controller/src/test/java/org/eclipse/hawkbit/security/controller/ControllerPreAuthenticatedSecurityHeaderFilterTest.java index e9df6e294..792f46161 100644 --- a/hawkbit-security/hawkbit-security-controller/src/test/java/org/eclipse/hawkbit/security/controller/ControllerPreAuthenticatedSecurityHeaderFilterTest.java +++ b/hawkbit-security/hawkbit-security-controller/src/test/java/org/eclipse/hawkbit/security/controller/ControllerPreAuthenticatedSecurityHeaderFilterTest.java @@ -33,7 +33,7 @@ import org.mockito.junit.jupiter.MockitoExtension; @Feature("Unit Tests - Security") @Story("Issuer hash based authentication") @ExtendWith(MockitoExtension.class) -public class ControllerPreAuthenticatedSecurityHeaderFilterTest { +class ControllerPreAuthenticatedSecurityHeaderFilterTest { private static final String CA_COMMON_NAME = "ca-cn"; private static final String CA_COMMON_NAME_VALUE = "box1"; @@ -63,7 +63,7 @@ public class ControllerPreAuthenticatedSecurityHeaderFilterTest { private SecurityContextSerializer securityContextSerializer; @BeforeEach - public void before() { + void before() { final SecurityContextTenantAware tenantAware = new SecurityContextTenantAware(authoritiesResolver, securityContextSerializer); underTest = new ControllerPreAuthenticatedSecurityHeaderFilter( CA_COMMON_NAME, "X-Ssl-Issuer-Hash-%d", @@ -72,7 +72,7 @@ public class ControllerPreAuthenticatedSecurityHeaderFilterTest { @Test @Description("Tests the filter for issuer hash based authentication with a single known hash") - public void testIssuerHashBasedAuthenticationWithSingleKnownHash() { + void testIssuerHashBasedAuthenticationWithSingleKnownHash() { final ControllerSecurityToken securityToken = prepareSecurityToken(SINGLE_HASH); // use single known hash when(tenantConfigurationManagementMock.getConfigurationValue( @@ -83,7 +83,7 @@ public class ControllerPreAuthenticatedSecurityHeaderFilterTest { @Test @Description("Tests the filter for issuer hash based authentication with multiple known hashes") - public void testIssuerHashBasedAuthenticationWithMultipleKnownHashes() { + void testIssuerHashBasedAuthenticationWithMultipleKnownHashes() { // use multiple known hashes when(tenantConfigurationManagementMock.getConfigurationValue( TenantConfigurationKey.AUTHENTICATION_MODE_HEADER_AUTHORITY_NAME, String.class)) @@ -95,7 +95,7 @@ public class ControllerPreAuthenticatedSecurityHeaderFilterTest { @Test @Description("Tests the filter for issuer hash based authentication with unknown hash") - public void testIssuerHashBasedAuthenticationWithUnknownHash() { + void testIssuerHashBasedAuthenticationWithUnknownHash() { final ControllerSecurityToken securityToken = prepareSecurityToken(UNKNOWN_HASH); // use single known hash when(tenantConfigurationManagementMock.getConfigurationValue( @@ -106,7 +106,7 @@ public class ControllerPreAuthenticatedSecurityHeaderFilterTest { @Test @Description("Tests different values for issuer hash header and inspects the credentials") - public void useDifferentValuesForIssuerHashHeader() { + void useDifferentValuesForIssuerHashHeader() { final ControllerSecurityToken securityToken1 = prepareSecurityToken(SINGLE_HASH); final ControllerSecurityToken securityToken2 = prepareSecurityToken(SECOND_HASH);