diff --git a/hawkbit-artifact/hawkbit-artifact-api/src/test/java/org/eclipse/hawkbit/artifact/repository/urlhandler/Base62UtilTest.java b/hawkbit-artifact/hawkbit-artifact-api/src/test/java/org/eclipse/hawkbit/artifact/repository/urlhandler/Base62UtilTest.java index 0593dc522..42d3c0a39 100644 --- a/hawkbit-artifact/hawkbit-artifact-api/src/test/java/org/eclipse/hawkbit/artifact/repository/urlhandler/Base62UtilTest.java +++ b/hawkbit-artifact/hawkbit-artifact-api/src/test/java/org/eclipse/hawkbit/artifact/repository/urlhandler/Base62UtilTest.java @@ -22,7 +22,8 @@ class Base62UtilTest { /** * Convert Base10 numbers to Base62 ASCII strings. */ - @Test void fromBase10() { + @Test + void fromBase10() { assertThat(Base62Util.fromBase10(0L)).isEqualTo("0"); assertThat(Base62Util.fromBase10(11L)).isEqualTo("B"); assertThat(Base62Util.fromBase10(36L)).isEqualTo("a"); @@ -32,7 +33,8 @@ class Base62UtilTest { /** * Convert Base62 ASCII strings to Base10 numbers. */ - @Test void toBase10() { + @Test + void toBase10() { assertThat(Base62Util.toBase10("0")).isZero(); assertThat(Base62Util.toBase10("B")).isEqualTo(11); assertThat(Base62Util.toBase10("a")).isEqualTo(36L); diff --git a/hawkbit-artifact/hawkbit-artifact-api/src/test/java/org/eclipse/hawkbit/artifact/repository/urlhandler/PropertyBasedArtifactUrlHandlerTest.java b/hawkbit-artifact/hawkbit-artifact-api/src/test/java/org/eclipse/hawkbit/artifact/repository/urlhandler/PropertyBasedArtifactUrlHandlerTest.java index 0f5f8d18b..632affc64 100644 --- a/hawkbit-artifact/hawkbit-artifact-api/src/test/java/org/eclipse/hawkbit/artifact/repository/urlhandler/PropertyBasedArtifactUrlHandlerTest.java +++ b/hawkbit-artifact/hawkbit-artifact-api/src/test/java/org/eclipse/hawkbit/artifact/repository/urlhandler/PropertyBasedArtifactUrlHandlerTest.java @@ -62,7 +62,8 @@ class PropertyBasedArtifactUrlHandlerTest { /** * Tests the generation of http download url. */ - @Test void urlGenerationWithDefaultConfiguration() { + @Test + void urlGenerationWithDefaultConfiguration() { properties.getProtocols().put("download-http", new UrlProtocol()); final List ddiUrls = urlHandlerUnderTest.getUrls(placeHolder, ApiType.DDI); @@ -77,7 +78,8 @@ class PropertyBasedArtifactUrlHandlerTest { /** * Tests the generation of custom download url with a CoAP example that supports DMF only. */ - @Test void urlGenerationWithCustomConfiguration() { + @Test + void urlGenerationWithCustomConfiguration() { final UrlProtocol proto = new UrlProtocol(); proto.setIp("127.0.0.1"); proto.setPort(5683); @@ -97,7 +99,8 @@ class PropertyBasedArtifactUrlHandlerTest { /** * Tests the generation of custom download url using Base62 references with a CoAP example that supports DMF only. */ - @Test void urlGenerationWithCustomShortConfiguration() { + @Test + void urlGenerationWithCustomShortConfiguration() { final UrlProtocol proto = new UrlProtocol(); proto.setIp("127.0.0.1"); proto.setPort(5683); @@ -117,7 +120,8 @@ class PropertyBasedArtifactUrlHandlerTest { /** * Verifies that the full qualified host of the statically defined hostname is replaced with the host of the request. */ - @Test void urlGenerationWithHostFromRequest() throws URISyntaxException { + @Test + void urlGenerationWithHostFromRequest() throws URISyntaxException { final String testHost = "ddi.host.com"; final UrlProtocol proto = new UrlProtocol(); @@ -138,7 +142,8 @@ class PropertyBasedArtifactUrlHandlerTest { /** * Verifies that the protocol of the statically defined hostname is replaced with the protocol of the request. */ - @Test void urlGenerationWithProtocolFromRequest() throws URISyntaxException { + @Test + void urlGenerationWithProtocolFromRequest() throws URISyntaxException { final String testHost = "ddi.host.com"; final UrlProtocol proto = new UrlProtocol(); @@ -154,7 +159,8 @@ class PropertyBasedArtifactUrlHandlerTest { /** * Verifies that the port of the statically defined hostname is replaced with the port of the request. */ - @Test void urlGenerationWithPortFromRequest() throws URISyntaxException { + @Test + void urlGenerationWithPortFromRequest() throws URISyntaxException { final UrlProtocol proto = new UrlProtocol(); proto.setRef("{protocol}://{hostname}:{portRequest}/{tenant}/controller/v1/{controllerId}/softwaremodules/{softwareModuleId}/artifacts/{artifactFileName}"); @@ -176,7 +182,8 @@ class PropertyBasedArtifactUrlHandlerTest { /** * Verifies that if default protocol port in request is used then url is returned without port */ - @Test void urlGenerationWithPortFromRequestForHttps() throws URISyntaxException { + @Test + void urlGenerationWithPortFromRequestForHttps() throws URISyntaxException { final String protocol = "https"; final UrlProtocol proto = new UrlProtocol(); proto.setRef("{protocolRequest}://{hostnameRequest}:{portRequest}/{tenant}/controller/v1/{controllerId}/softwaremodules/{softwareModuleId}/artifacts/{artifactFileName}"); @@ -195,7 +202,8 @@ class PropertyBasedArtifactUrlHandlerTest { /** * Verifies that the domain of the statically defined hostname is replaced with the domain of the request. */ - @Test void urlGenerationWithDomainFromRequest() throws URISyntaxException { + @Test + void urlGenerationWithDomainFromRequest() throws URISyntaxException { final UrlProtocol proto = new UrlProtocol(); proto.setHostname("host.bumlux.net"); proto.setRef("{protocol}://{domainRequest}/{tenant}/controller/v1/{controllerId}/softwaremodules/{softwareModuleId}/artifacts/{artifactFileName}"); diff --git a/hawkbit-artifact/hawkbit-artifact-api/src/test/java/org/eclipse/hawkbit/artifact/repository/urlhandler/URLPlaceholderTest.java b/hawkbit-artifact/hawkbit-artifact-api/src/test/java/org/eclipse/hawkbit/artifact/repository/urlhandler/URLPlaceholderTest.java index 644dac240..0fb791543 100644 --- a/hawkbit-artifact/hawkbit-artifact-api/src/test/java/org/eclipse/hawkbit/artifact/repository/urlhandler/URLPlaceholderTest.java +++ b/hawkbit-artifact/hawkbit-artifact-api/src/test/java/org/eclipse/hawkbit/artifact/repository/urlhandler/URLPlaceholderTest.java @@ -30,7 +30,8 @@ class URLPlaceholderTest { /** * Same object should be equal */ - @Test // Exception squid:S5785 - JUnit assertTrue/assertFalse should be simplified to the corresponding dedicated assertion + @Test + // Exception squid:S5785 - JUnit assertTrue/assertFalse should be simplified to the corresponding dedicated assertion // Need to test the equals method and need to bypass magic logic in utility classes @SuppressWarnings({ "squid:S5838" }) void sameObjectShouldBeEqual() { @@ -41,7 +42,8 @@ class URLPlaceholderTest { /** * Different object should not be equal */ - @Test @SuppressWarnings({ "squid:S5838" }) + @Test + @SuppressWarnings({ "squid:S5838" }) void differentObjectShouldNotBeEqual() { final URLPlaceholder.SoftwareData softwareData2 = new URLPlaceholder.SoftwareData(2L, "file.txt", 123L, "someHash123"); final URLPlaceholder placeholder2 = new URLPlaceholder("SuperCorp", 123L, "Super-2", 2L, softwareData2); @@ -57,7 +59,8 @@ class URLPlaceholderTest { /** * Different objects with same properties should be equal */ - @Test void differentObjectsWithSamePropertiesShouldBeEqual() { + @Test + void differentObjectsWithSamePropertiesShouldBeEqual() { final URLPlaceholder placeholderWithSameProperties = new URLPlaceholder(placeholder.getTenant(), placeholder.getTenantId(), placeholder.getControllerId(), placeholder.getTargetId(), softwareData); assertThat(placeholder).isEqualTo(placeholderWithSameProperties); @@ -67,7 +70,8 @@ class URLPlaceholderTest { /** * Should not equal null */ - @Test // Exception squid:S5785 - JUnit assertTrue/assertFalse should be simplified to + @Test + // Exception squid:S5785 - JUnit assertTrue/assertFalse should be simplified to // the corresponding dedicated assertion // Need to test the equals method and need to bypass magic logic in utility // classes @@ -80,7 +84,8 @@ class URLPlaceholderTest { /** * HashCode should not change */ - @Test void hashCodeShouldNotChange() { + @Test + void hashCodeShouldNotChange() { final URLPlaceholder placeholderWithSameProperties = new URLPlaceholder(placeholder.getTenant(), placeholder.getTenantId(), placeholder.getControllerId(), placeholder.getTargetId(), softwareData); assertThat(placeholder).hasSameHashCodeAs(placeholder).hasSameHashCodeAs(placeholderWithSameProperties); diff --git a/hawkbit-artifact/hawkbit-artifact-repository-filesystem/src/test/java/org/eclipse/hawkbit/artifact/repository/ArtifactFilesystemRepositoryTest.java b/hawkbit-artifact/hawkbit-artifact-repository-filesystem/src/test/java/org/eclipse/hawkbit/artifact/repository/ArtifactFilesystemRepositoryTest.java index c7d78b70d..ce098400a 100644 --- a/hawkbit-artifact/hawkbit-artifact-repository-filesystem/src/test/java/org/eclipse/hawkbit/artifact/repository/ArtifactFilesystemRepositoryTest.java +++ b/hawkbit-artifact/hawkbit-artifact-repository-filesystem/src/test/java/org/eclipse/hawkbit/artifact/repository/ArtifactFilesystemRepositoryTest.java @@ -59,7 +59,8 @@ class ArtifactFilesystemRepositoryTest { /** * Verifies that an artifact can be successfully stored in the file-system repository */ - @Test void storeSuccessfully() throws IOException { + @Test + void storeSuccessfully() throws IOException { final byte[] fileContent = randomBytes(); final AbstractDbArtifact artifact = storeRandomArtifact(fileContent); @@ -71,7 +72,8 @@ class ArtifactFilesystemRepositoryTest { /** * Verifies that an artifact can be successfully stored in the file-system repository */ - @Test void getStoredArtifactBasedOnSHA1Hash() throws IOException { + @Test + void getStoredArtifactBasedOnSHA1Hash() throws IOException { final byte[] fileContent = randomBytes(); final AbstractDbArtifact artifact = storeRandomArtifact(fileContent); @@ -81,7 +83,8 @@ class ArtifactFilesystemRepositoryTest { /** * Verifies that an artifact can be deleted in the file-system repository */ - @Test void deleteStoredArtifactBySHA1Hash() throws IOException { + @Test + void deleteStoredArtifactBySHA1Hash() throws IOException { final AbstractDbArtifact artifact = storeRandomArtifact(randomBytes()); artifactFilesystemRepository.deleteBySha1(TENANT, artifact.getHashes().getSha1()); @@ -91,7 +94,8 @@ class ArtifactFilesystemRepositoryTest { /** * Verifies that all artifacts of a tenant can be deleted in the file-system repository */ - @Test void deleteStoredArtifactOfTenant() throws IOException { + @Test + void deleteStoredArtifactOfTenant() throws IOException { final AbstractDbArtifact artifact = storeRandomArtifact(randomBytes()); artifactFilesystemRepository.deleteByTenant(TENANT); @@ -101,7 +105,8 @@ class ArtifactFilesystemRepositoryTest { /** * Verifies that an artifact which does not exists is deleted quietly in the file-system repository */ - @Test void deleteArtifactWhichDoesNotExistsBySHA1HashWithoutException() throws IOException { + @Test + void deleteArtifactWhichDoesNotExistsBySHA1HashWithoutException() throws IOException { try { artifactFilesystemRepository.deleteBySha1(TENANT, "sha1HashWhichDoesNotExists"); } catch (final Exception e) { diff --git a/hawkbit-artifact/hawkbit-artifact-repository-filesystem/src/test/java/org/eclipse/hawkbit/artifact/repository/ArtifactFilesystemTest.java b/hawkbit-artifact/hawkbit-artifact-repository-filesystem/src/test/java/org/eclipse/hawkbit/artifact/repository/ArtifactFilesystemTest.java index 6dbb44fca..843beb1d5 100644 --- a/hawkbit-artifact/hawkbit-artifact-repository-filesystem/src/test/java/org/eclipse/hawkbit/artifact/repository/ArtifactFilesystemTest.java +++ b/hawkbit-artifact/hawkbit-artifact-repository-filesystem/src/test/java/org/eclipse/hawkbit/artifact/repository/ArtifactFilesystemTest.java @@ -29,7 +29,8 @@ class ArtifactFilesystemTest { /** * Verifies that an exception is thrown on opening an InputStream when file does not exists */ - @Test void getInputStreamOfNonExistingFileThrowsException() { + @Test + void getInputStreamOfNonExistingFileThrowsException() { final File file = new File("fileWhichTotalDoesNotExists"); final ArtifactFilesystem underTest = new ArtifactFilesystem( file, "fileWhichTotalDoesNotExists", @@ -42,7 +43,8 @@ class ArtifactFilesystemTest { /** * Verifies that an InputStream can be opened if file exists */ - @Test void getInputStreamOfExistingFile() throws IOException { + @Test + void getInputStreamOfExistingFile() throws IOException { final ArtifactFilesystem underTest = new ArtifactFilesystem( AbstractArtifactRepository.createTempFile(false), ArtifactFilesystemTest.class.getSimpleName(), new DbArtifactHash("1", "2", "3"), 0L, null); diff --git a/hawkbit-core/src/test/java/org/eclipse/hawkbit/repository/FileNameFieldsTest.java b/hawkbit-core/src/test/java/org/eclipse/hawkbit/repository/FileNameFieldsTest.java index 295cb098c..7624c32b9 100644 --- a/hawkbit-core/src/test/java/org/eclipse/hawkbit/repository/FileNameFieldsTest.java +++ b/hawkbit-core/src/test/java/org/eclipse/hawkbit/repository/FileNameFieldsTest.java @@ -23,7 +23,8 @@ class FileNameFieldsTest { /** * Verifies that fields classes are correctly implemented */ - @Test @SuppressWarnings("unchecked") + @Test + @SuppressWarnings("unchecked") void repositoryManagementMethodsArePreAuthorizedAnnotated() { final String packageName = getClass().getPackage().getName(); try (final ScanResult scanResult = new ClassGraph().acceptPackages(packageName).scan()) { 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 4417bec46..1b70f1d95 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 @@ -34,7 +34,8 @@ class DdiActionFeedbackTest { /** * Verify the correct serialization and deserialization of the model with minimal payload */ - @Test void shouldSerializeAndDeserializeObjectWithoutOptionalValues() throws IOException { + @Test + void shouldSerializeAndDeserializeObjectWithoutOptionalValues() throws IOException { // Setup final DdiStatus ddiStatus = new DdiStatus(DdiStatus.ExecutionStatus.CLOSED, null, null, Collections.emptyList()); final DdiActionFeedback ddiActionFeedback = new DdiActionFeedback(ddiStatus); @@ -50,7 +51,8 @@ class DdiActionFeedbackTest { /** * Verify the correct serialization and deserialization of the model with all values provided */ - @Test void shouldSerializeAndDeserializeObjectWithOptionalValues() throws IOException { + @Test + void shouldSerializeAndDeserializeObjectWithOptionalValues() throws IOException { // Setup final Long timestamp = System.currentTimeMillis(); final DdiResult ddiResult = new DdiResult(DdiResult.FinalResult.SUCCESS, new DdiProgress(10, 10)); @@ -68,7 +70,8 @@ class DdiActionFeedbackTest { /** * Verify that deserialization fails for known properties with a wrong datatype */ - @Test void shouldFailForObjectWithWrongDataTypes() { + @Test + void shouldFailForObjectWithWrongDataTypes() { // Setup final String serializedDdiActionFeedback = """ { @@ -87,7 +90,8 @@ class DdiActionFeedbackTest { /** * Verify that deserialization works if optional fields are not parsed */ - @Test void shouldConvertItWithoutOptionalFieldTimestamp() throws JsonProcessingException { + @Test + void shouldConvertItWithoutOptionalFieldTimestamp() throws JsonProcessingException { // 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 49731cb7f..89ec7bf11 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 @@ -34,7 +34,8 @@ class DdiActionHistoryTest { /** * Verify the correct serialization and deserialization of the model */ - @Test void shouldSerializeAndDeserializeObject() throws IOException { + @Test + void shouldSerializeAndDeserializeObject() throws IOException { // Setup final String actionStatus = "TestAction"; final List messages = Arrays.asList("Action status message 1", "Action status message 2"); @@ -50,7 +51,8 @@ class DdiActionHistoryTest { /** * Verify the correct deserialization of a model with a additional unknown property */ - @Test void shouldDeserializeObjectWithUnknownProperty() throws IOException { + @Test + void shouldDeserializeObjectWithUnknownProperty() throws IOException { // Setup final String serializedDdiActionHistory = """ { @@ -67,7 +69,8 @@ class DdiActionHistoryTest { /** * Verify that deserialization fails for known properties with a wrong datatype */ - @Test void shouldFailForObjectWithWrongDataTypes() { + @Test + 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 eb3812665..a71dd6d05 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 @@ -32,7 +32,8 @@ class DdiArtifactHashTest { /** * Verify the correct serialization and deserialization of the model */ - @Test void shouldSerializeAndDeserializeObject() throws IOException { + @Test + void shouldSerializeAndDeserializeObject() throws IOException { // Setup final String sha1Hash = "11111"; final String md5Hash = "22222"; @@ -51,7 +52,8 @@ class DdiArtifactHashTest { /** * Verify the correct deserialization of a model with a additional unknown property */ - @Test void shouldDeserializeObjectWithUnknownProperty() throws IOException { + @Test + void shouldDeserializeObjectWithUnknownProperty() throws IOException { // Setup final String serializedDdiArtifact = "{\"sha1\": \"123\", \"md5\": \"456\", \"sha256\": \"789\", \"unknownProperty\": \"test\"}"; @@ -65,7 +67,8 @@ class DdiArtifactHashTest { /** * Verify that deserialization fails for known properties with a wrong datatype */ - @Test void shouldFailForObjectWithWrongDataTypes() { + @Test + 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 29aed3ba3..667959571 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 @@ -32,7 +32,8 @@ class DdiArtifactTest { /** * Verify the correct serialization and deserialization of the model */ - @Test void shouldSerializeAndDeserializeObject() throws IOException { + @Test + void shouldSerializeAndDeserializeObject() throws IOException { // Setup final String filename = "testfile.txt"; final DdiArtifactHash hashes = new DdiArtifactHash("123", "456", "789"); @@ -54,7 +55,8 @@ class DdiArtifactTest { /** * Verify the correct deserialization of a model with a additional unknown property */ - @Test void shouldDeserializeObjectWithUnknownProperty() throws IOException { + @Test + void shouldDeserializeObjectWithUnknownProperty() throws IOException { // Setup final String serializedDdiArtifact = "{\"filename\":\"test.file\",\"hashes\":{\"sha1\":\"123\",\"md5\":\"456\",\"sha256\":\"789\"},\"size\":111,\"links\":[],\"unknownProperty\": \"test\"}"; @@ -70,7 +72,8 @@ class DdiArtifactTest { /** * Verify that deserialization fails for known properties with a wrong datatype */ - @Test void shouldFailForObjectWithWrongDataTypes() { + @Test + 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 431892a86..b6513dafc 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 @@ -32,7 +32,8 @@ class DdiCancelActionToStopTest { /** * Verify the correct serialization and deserialization of the model */ - @Test void shouldSerializeAndDeserializeObject() throws IOException { + @Test + void shouldSerializeAndDeserializeObject() throws IOException { // Setup final String stopId = "1234"; final DdiCancelActionToStop ddiCancelActionToStop = new DdiCancelActionToStop(stopId); @@ -48,7 +49,8 @@ class DdiCancelActionToStopTest { /** * Verify the correct deserialization of a model with a additional unknown property */ - @Test void shouldDeserializeObjectWithUnknownProperty() throws IOException { + @Test + void shouldDeserializeObjectWithUnknownProperty() throws IOException { // Setup final String serializedDdiCancelActionToStop = "{\"stopId\":\"12345\",\"unknownProperty\":\"test\"}"; @@ -61,7 +63,8 @@ class DdiCancelActionToStopTest { /** * Verify that deserialization fails for known properties with a wrong datatype */ - @Test void shouldFailForObjectWithWrongDataTypes() { + @Test + 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 d449089ff..675b4a06b 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 @@ -32,7 +32,8 @@ class DdiCancelTest { /** * Verify the correct serialization and deserialization of the model */ - @Test void shouldSerializeAndDeserializeObject() throws IOException { + @Test + void shouldSerializeAndDeserializeObject() throws IOException { // Setup final String ddiCancelId = "1234"; final DdiCancelActionToStop ddiCancelActionToStop = new DdiCancelActionToStop("1234"); @@ -49,7 +50,8 @@ class DdiCancelTest { /** * Verify the correct deserialization of a model with a additional unknown property */ - @Test void shouldDeserializeObjectWithUnknownProperty() throws IOException { + @Test + void shouldDeserializeObjectWithUnknownProperty() throws IOException { // Setup final String serializedDdiCancel = "{\"id\":\"1234\",\"cancelAction\":{\"stopId\":\"1234\"}, \"unknownProperty\": \"test\"}"; @@ -62,7 +64,8 @@ class DdiCancelTest { /** * Verify that deserialization fails for known properties with a wrong datatype */ - @Test void shouldFailForObjectWithWrongDataTypes() { + @Test + 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 7c636a9eb..004627bfe 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 @@ -34,7 +34,8 @@ class DdiChunkTest { /** * Verify the correct serialization and deserialization of the model */ - @Test void shouldSerializeAndDeserializeObject() throws IOException { + @Test + void shouldSerializeAndDeserializeObject() throws IOException { // Setup final String part = "1234"; final String version = "1.0"; @@ -55,7 +56,8 @@ class DdiChunkTest { /** * Verify the correct deserialization of a model with a additional unknown property */ - @Test void shouldDeserializeObjectWithUnknownProperty() throws IOException { + @Test + void shouldDeserializeObjectWithUnknownProperty() throws IOException { // Setup final String serializedDdiChunk = "{\"part\":\"1234\",\"version\":\"1.0\",\"name\":\"Dummy-Artifact\",\"artifacts\":[],\"unknownProperty\":\"test\"}"; @@ -70,7 +72,8 @@ class DdiChunkTest { /** * Verify that deserialization fails for known properties with a wrong datatype */ - @Test void shouldFailForObjectWithWrongDataTypes() { + @Test + 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 dce0ca539..28602ea2b 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 @@ -34,7 +34,8 @@ class DdiConfigDataTest { /** * Verify the correct serialization and deserialization of the model */ - @Test void shouldSerializeAndDeserializeObject() throws IOException { + @Test + void shouldSerializeAndDeserializeObject() throws IOException { // Setup final Map data = new HashMap<>(); data.put("test", "data"); @@ -50,7 +51,8 @@ class DdiConfigDataTest { /** * Verify the correct deserialization of a model with an additional unknown property */ - @Test void shouldDeserializeObjectWithUnknownProperty() throws IOException { + @Test + void shouldDeserializeObjectWithUnknownProperty() throws IOException { // Setup final String serializedDdiConfigData = "{\"data\":{\"test\":\"data\"},\"mode\":\"replace\",\"unknownProperty\":\"test\"}"; @@ -62,7 +64,8 @@ class DdiConfigDataTest { /** * Verify that deserialization fails for known properties with a wrong datatype */ - @Test void shouldFailForObjectWithWrongDataTypes() { + @Test + void shouldFailForObjectWithWrongDataTypes() { // Setup final String serializedDdiConfigData = "{\"data\":{\"test\":\"data\"},\"mode\":[\"replace\"],\"unknownProperty\":\"test\"}"; @@ -74,7 +77,8 @@ class DdiConfigDataTest { /** * Verify the correct deserialization of a model with removed unused status property */ - @Test void shouldDeserializeObjectWithStatusProperty() throws IOException { + @Test + 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 72d57e945..aab6220e3 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 @@ -32,7 +32,8 @@ class DdiConfigTest { /** * Verify the correct serialization and deserialization of the model */ - @Test void shouldSerializeAndDeserializeObject() throws IOException { + @Test + void shouldSerializeAndDeserializeObject() throws IOException { // Setup final DdiPolling ddiPolling = new DdiPolling("10"); final DdiConfig ddiConfig = new DdiConfig(ddiPolling); @@ -47,7 +48,8 @@ class DdiConfigTest { /** * Verify the correct deserialization of a model with a additional unknown property */ - @Test void shouldDeserializeObjectWithUnknownProperty() throws IOException { + @Test + void shouldDeserializeObjectWithUnknownProperty() throws IOException { // Setup final String serializedDdiConfig = "{\"polling\":{\"sleep\":\"123\"},\"unknownProperty\":\"test\"}"; @@ -59,7 +61,8 @@ class DdiConfigTest { /** * Verify that deserialization fails for known properties with a wrong datatype */ - @Test void shouldFailForObjectWithWrongDataTypes() { + @Test + 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 c14897f41..074b1b5c6 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 @@ -37,7 +37,8 @@ class DdiConfirmationBaseTest { /** * Verify the correct serialization and deserialization of the model */ - @Test void shouldSerializeAndDeserializeObject() throws IOException { + @Test + void shouldSerializeAndDeserializeObject() throws IOException { // Setup final String id = "1234"; final DdiDeployment ddiDeployment = new DdiDeployment(FORCED, ATTEMPT, Collections.emptyList(), AVAILABLE); @@ -65,7 +66,8 @@ class DdiConfirmationBaseTest { /** * Verify the correct deserialization of a model with a additional unknown property */ - @Test void shouldDeserializeObjectWithUnknownProperty() throws IOException { + @Test + void shouldDeserializeObjectWithUnknownProperty() throws IOException { // Setup final String serializedDdiConfirmationBase = "{" + "\"id\":\"1234\",\"confirmation\":{\"download\":\"forced\"," + @@ -87,7 +89,8 @@ class DdiConfirmationBaseTest { /** * Verify that deserialization fails for known properties with a wrong datatype */ - @Test void shouldFailForObjectWithWrongDataTypes() { + @Test + 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 48591d637..0a0fed698 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 @@ -32,7 +32,8 @@ class DdiControllerBaseTest { /** * Verify the correct serialization and deserialization of the model */ - @Test void shouldSerializeAndDeserializeObject() throws IOException { + @Test + void shouldSerializeAndDeserializeObject() throws IOException { // Setup final DdiPolling ddiPolling = new DdiPolling("10"); final DdiConfig ddiConfig = new DdiConfig(ddiPolling); @@ -48,7 +49,8 @@ class DdiControllerBaseTest { /** * Verify the correct deserialization of a model with a additional unknown property */ - @Test void shouldDeserializeObjectWithUnknownProperty() throws IOException { + @Test + void shouldDeserializeObjectWithUnknownProperty() throws IOException { // Setup final String serializedDdiControllerBase = "{\"config\":{\"polling\":{\"sleep\":\"123\"}},\"links\":[],\"unknownProperty\":\"test\"}"; @@ -60,7 +62,8 @@ class DdiControllerBaseTest { /** * Verify that deserialization fails for known properties with a wrong datatype */ - @Test void shouldFailForObjectWithWrongDataTypes() { + @Test + 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 3fd1bd043..791aa72e9 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 @@ -37,7 +37,8 @@ class DdiDeploymentBaseTest { /** * Verify the correct serialization and deserialization of the model */ - @Test void shouldSerializeAndDeserializeObject() throws IOException { + @Test + void shouldSerializeAndDeserializeObject() throws IOException { // Setup final String id = "1234"; final DdiDeployment ddiDeployment = new DdiDeployment(FORCED, ATTEMPT, Collections.emptyList(), AVAILABLE); @@ -59,7 +60,8 @@ class DdiDeploymentBaseTest { /** * Verify the correct deserialization of a model with a additional unknown property */ - @Test void shouldDeserializeObjectWithUnknownProperty() throws IOException { + @Test + void shouldDeserializeObjectWithUnknownProperty() throws IOException { // Setup final String serializedDdiDeploymentBase = "{\"id\":\"1234\",\"deployment\":{\"download\":\"forced\"," + "\"update\":\"attempt\",\"maintenanceWindow\":\"available\",\"chunks\":[]}," + @@ -76,7 +78,8 @@ class DdiDeploymentBaseTest { /** * Verify that deserialization fails for known properties with a wrong datatype */ - @Test void shouldFailForObjectWithWrongDataTypes() { + @Test + 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 a870ab760..3798eb489 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 @@ -36,7 +36,8 @@ class DdiDeploymentTest { /** * Verify the correct serialization and deserialization of the model */ - @Test void shouldSerializeAndDeserializeObject() throws IOException { + @Test + void shouldSerializeAndDeserializeObject() throws IOException { // Setup final DdiDeployment ddiDeployment = new DdiDeployment(FORCED, ATTEMPT, Collections.emptyList(), AVAILABLE); @@ -53,7 +54,8 @@ class DdiDeploymentTest { /** * Verify the correct deserialization of a model with a additional unknown property */ - @Test void shouldDeserializeObjectWithUnknownProperty() throws IOException { + @Test + void shouldDeserializeObjectWithUnknownProperty() throws IOException { // Setup final String serializedDdiDeployment = "{\"download\":\"forced\",\"update\":\"attempt\", " + "\"maintenanceWindow\":\"available\",\"chunks\":[],\"unknownProperty\":\"test\"}"; @@ -68,7 +70,8 @@ class DdiDeploymentTest { /** * Verify that deserialization fails for known properties with a wrong datatype */ - @Test void shouldFailForObjectWithWrongDataTypes() { + @Test + 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 d3cf9542e..7e70ba706 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 @@ -32,7 +32,8 @@ class DdiMetadataTest { /** * Verify the correct serialization and deserialization of the model */ - @Test void shouldSerializeAndDeserializeObject() throws IOException { + @Test + void shouldSerializeAndDeserializeObject() throws IOException { // Setup final String key = "testKey"; final String value = "testValue"; @@ -49,7 +50,8 @@ class DdiMetadataTest { /** * Verify the correct deserialization of a model with a additional unknown property */ - @Test void shouldDeserializeObjectWithUnknownProperty() throws IOException { + @Test + void shouldDeserializeObjectWithUnknownProperty() throws IOException { // Setup final String serializedDdiMetadata = "{\"key\":\"testKey\",\"value\":\"testValue\",\"unknownProperty\":\"test\"}"; @@ -62,7 +64,8 @@ class DdiMetadataTest { /** * Verify that deserialization fails for known properties with a wrong datatype */ - @Test void shouldFailForObjectWithWrongDataTypes() { + @Test + 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 624a825a6..7a09c8283 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 @@ -32,7 +32,8 @@ class DdiPollingTest { /** * Verify the correct serialization and deserialization of the model */ - @Test void shouldSerializeAndDeserializeObject() throws IOException { + @Test + void shouldSerializeAndDeserializeObject() throws IOException { // Setup final DdiPolling ddiPolling = new DdiPolling("10"); @@ -46,7 +47,8 @@ class DdiPollingTest { /** * Verify the correct deserialization of a model with a additional unknown property */ - @Test void shouldDeserializeObjectWithUnknownProperty() throws IOException { + @Test + void shouldDeserializeObjectWithUnknownProperty() throws IOException { // Setup final String serializedDdiPolling = "{\"sleep\":\"10\",\"unknownProperty\":\"test\"}"; @@ -58,7 +60,8 @@ class DdiPollingTest { /** * Verify that deserialization fails for known properties with a wrong datatype */ - @Test void shouldFailForObjectWithWrongDataTypes() { + @Test + 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 99a98a271..f8e8de752 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 @@ -32,7 +32,8 @@ class DdiProgressTest { /** * Verify the correct serialization and deserialization of the model */ - @Test void shouldSerializeAndDeserializeObject() throws IOException { + @Test + void shouldSerializeAndDeserializeObject() throws IOException { // Setup final DdiProgress ddiProgress = new DdiProgress(30, 100); @@ -47,7 +48,8 @@ class DdiProgressTest { /** * Verify the correct deserialization of a model with a additional unknown property */ - @Test void shouldDeserializeObjectWithUnknownProperty() throws IOException { + @Test + void shouldDeserializeObjectWithUnknownProperty() throws IOException { // Setup final String serializedDdiProgress = "{\"cnt\":30,\"of\":100,\"unknownProperty\":\"test\"}"; @@ -60,7 +62,8 @@ class DdiProgressTest { /** * Verify that deserialization fails for known properties with a wrong datatype */ - @Test void shouldFailForObjectWithWrongDataTypes() { + @Test + 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 7e40ccb81..7c51e8016 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 @@ -33,7 +33,8 @@ class DdiResultTest { /** * Verify the correct serialization and deserialization of the model */ - @Test void shouldSerializeAndDeserializeObject() throws IOException { + @Test + void shouldSerializeAndDeserializeObject() throws IOException { // Setup final DdiProgress ddiProgress = new DdiProgress(30, 100); final DdiResult ddiResult = new DdiResult(NONE, ddiProgress); @@ -50,7 +51,8 @@ class DdiResultTest { /** * Verify the correct deserialization of a model with a additional unknown property */ - @Test void shouldDeserializeObjectWithUnknownProperty() throws IOException { + @Test + void shouldDeserializeObjectWithUnknownProperty() throws IOException { // Setup final String serializedDdiResult = "{\"finished\":\"none\",\"progress\":{\"cnt\":30,\"of\":100},\"unknownProperty\":\"test\"}"; @@ -64,7 +66,8 @@ class DdiResultTest { /** * Verify that deserialization fails for known properties with a wrong datatype */ - @Test void shouldFailForObjectWithWrongDataTypes() { + @Test + 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 25c2715e6..ecd4458da 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 @@ -57,7 +57,8 @@ class DdiStatusTest { /** * Verify the correct deserialization of a model with a additional unknown property */ - @Test void shouldDeserializeObjectWithUnknownProperty() throws IOException { + @Test + void shouldDeserializeObjectWithUnknownProperty() throws IOException { // Setup final String serializedDdiStatus = "{\"execution\":\"proceeding\",\"result\":{\"finished\":\"none\"," + "\"progress\":{\"cnt\":30,\"of\":100}},\"details\":[],\"unknownProperty\":\"test\"}"; @@ -74,7 +75,8 @@ class DdiStatusTest { /** * Verify the correct deserialization of a model with a provided code (optional) */ - @Test void shouldDeserializeObjectWithOptionalCode() throws IOException { + @Test + void shouldDeserializeObjectWithOptionalCode() throws IOException { // Setup final String serializedDdiStatus = "{\"execution\":\"proceeding\",\"result\":{\"finished\":\"none\"," + "\"progress\":{\"cnt\":30,\"of\":100}},\"code\": 12,\"details\":[]}"; @@ -91,7 +93,8 @@ class DdiStatusTest { /** * Verify that deserialization fails for known properties with a wrong datatype */ - @Test void shouldFailForObjectWithWrongDataTypes() { + @Test + void shouldFailForObjectWithWrongDataTypes() { // Setup final String serializedDdiStatus = "{\"execution\":[\"proceeding\"],\"result\":{\"finished\":\"none\"," + "\"progress\":{\"cnt\":30,\"of\":100}},\"details\":[]}"; diff --git a/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/JsonIgnorePropertiesAnnotationTest.java b/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/JsonIgnorePropertiesAnnotationTest.java index 2dd54aef0..76b5b4dbc 100644 --- a/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/JsonIgnorePropertiesAnnotationTest.java +++ b/hawkbit-ddi/hawkbit-ddi-api/src/test/java/org/eclipse/hawkbit/ddi/json/model/JsonIgnorePropertiesAnnotationTest.java @@ -31,7 +31,8 @@ class JsonIgnorePropertiesAnnotationTest { /** * This test verifies that all model classes within the 'org.eclipse.hawkbit.ddi.json.model' package are annotated with '@JsonIgnoreProperties(ignoreUnknown = true)' */ - @Test void shouldCheckAnnotationsForAllModelClasses() { + @Test + void shouldCheckAnnotationsForAllModelClasses() { final String packageName = getClass().getPackage().getName(); try (final ScanResult scanResult = new ClassGraph().acceptPackages(packageName).scan()) { final List> matchingClasses = scanResult.getAllClasses() 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 03f0c147e..bc2160713 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 @@ -70,7 +70,8 @@ class DdiArtifactDownloadTest extends AbstractDDiApiIntegrationTest { /** * Tests non allowed requests on the artifact ressource, e.g. invalid URI, wrong if-match, wrong command. */ - @Test void invalidRequestsOnArtifactResource() throws Exception { + @Test + void invalidRequestsOnArtifactResource() throws Exception { // create target final Target target = testdataFactory.createTarget(); final List targets = Collections.singletonList(target); @@ -207,7 +208,8 @@ class DdiArtifactDownloadTest extends AbstractDDiApiIntegrationTest { /** * Tests valid MD5SUm file downloads through the artifact resource by identifying the artifact by ID. */ - @Test void downloadMd5sumThroughControllerApi() throws Exception { + @Test + void downloadMd5sumThroughControllerApi() throws Exception { // create target final Target target = testdataFactory.createTarget(); diff --git a/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiCancelActionTest.java b/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiCancelActionTest.java index fec7de98c..e89355b9d 100644 --- a/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiCancelActionTest.java +++ b/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiCancelActionTest.java @@ -55,7 +55,8 @@ class DdiCancelActionTest extends AbstractDDiApiIntegrationTest { /** * Tests that the cancel action resource can be used with CBOR. */ - @Test void cancelActionCbor() throws Exception { + @Test + void cancelActionCbor() throws Exception { final DistributionSet ds = testdataFactory.createDistributionSet(""); testdataFactory.createTarget(); final Long actionId = getFirstAssignedActionId( @@ -89,7 +90,8 @@ class DdiCancelActionTest extends AbstractDDiApiIntegrationTest { /** * Test of the controller can continue a started update even after a cancel command if it so desires. */ - @Test void rootRsCancelActionButContinueAnyway() throws Exception { + @Test + void rootRsCancelActionButContinueAnyway() throws Exception { // prepare test data final DistributionSet ds = testdataFactory.createDistributionSet(""); final Target savedTarget = testdataFactory.createTarget(); @@ -150,7 +152,8 @@ class DdiCancelActionTest extends AbstractDDiApiIntegrationTest { /** * Test for cancel operation of a update action. */ - @Test void rootRsCancelAction() throws Exception { + @Test + void rootRsCancelAction() throws Exception { final DistributionSet ds = testdataFactory.createDistributionSet(""); final Target savedTarget = testdataFactory.createTarget(); @@ -232,7 +235,8 @@ class DdiCancelActionTest extends AbstractDDiApiIntegrationTest { /** * Tests various bad requests and if the server handles them as expected. */ - @Test void badCancelAction() throws Exception { + @Test + void badCancelAction() throws Exception { // not allowed methods mvc.perform(post("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/cancelAction/1", @@ -269,7 +273,8 @@ class DdiCancelActionTest extends AbstractDDiApiIntegrationTest { /** * Tests the feedback channel of the cancel operation. */ - @Test void rootRsCancelActionFeedback() throws Exception { + @Test + void rootRsCancelActionFeedback() throws Exception { final DistributionSet ds = testdataFactory.createDistributionSet(""); @@ -350,7 +355,8 @@ class DdiCancelActionTest extends AbstractDDiApiIntegrationTest { /** * Tests the feeback chanel of for multiple open cancel operations on the same target. */ - @Test void multipleCancelActionFeedback() throws Exception { + @Test + void multipleCancelActionFeedback() throws Exception { final DistributionSet ds = testdataFactory.createDistributionSet("", true); final DistributionSet ds2 = testdataFactory.createDistributionSet("2", true); final DistributionSet ds3 = testdataFactory.createDistributionSet("3", true); @@ -482,7 +488,8 @@ class DdiCancelActionTest extends AbstractDDiApiIntegrationTest { /** * Tests the feeback channel closing for too many feedbacks, i.e. denial of service prevention. */ - @Test void tooMuchCancelActionFeedback() throws Exception { + @Test + void tooMuchCancelActionFeedback() throws Exception { testdataFactory.createTarget(); final DistributionSet ds = testdataFactory.createDistributionSet(""); @@ -511,7 +518,8 @@ class DdiCancelActionTest extends AbstractDDiApiIntegrationTest { /** * test the correct rejection of various invalid feedback requests */ - @Test void badCancelActionFeedback() throws Exception { + @Test + void badCancelActionFeedback() throws Exception { final Action cancelAction = createCancelAction(TestdataFactory.DEFAULT_CONTROLLER_ID); createCancelAction("4715"); diff --git a/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiConfigDataTest.java b/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiConfigDataTest.java index 5d3189781..e2e734869 100644 --- a/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiConfigDataTest.java +++ b/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiConfigDataTest.java @@ -58,7 +58,8 @@ class DdiConfigDataTest extends AbstractDDiApiIntegrationTest { /** * Verify that config data can be uploaded as CBOR */ - @Test void putConfigDataAsCbor() throws Exception { + @Test + void putConfigDataAsCbor() throws Exception { testdataFactory.createTarget(TARGET1_ID); final Map attributes = new HashMap<>(); @@ -209,7 +210,8 @@ class DdiConfigDataTest extends AbstractDDiApiIntegrationTest { /** * Verifies that invalid config data attributes are handled correctly. */ - @Test void putConfigDataWithInvalidAttributes() throws Exception { + @Test + void putConfigDataWithInvalidAttributes() throws Exception { // create a target testdataFactory.createTarget(TARGET2_ID); putAndVerifyConfigDataWithKeyTooLong(); @@ -219,7 +221,8 @@ class DdiConfigDataTest extends AbstractDDiApiIntegrationTest { /** * Verify that config data (device attributes) can be updated by the controller using different update modes (merge, replace, remove). */ - @Test void putConfigDataWithDifferentUpdateModes() throws Exception { + @Test + void putConfigDataWithDifferentUpdateModes() throws Exception { // create a target testdataFactory.createTarget(TARGET1_ID); diff --git a/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiConfirmationBaseTest.java b/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiConfirmationBaseTest.java index 1e7dc248a..1deb91b6d 100644 --- a/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiConfirmationBaseTest.java +++ b/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiConfirmationBaseTest.java @@ -70,7 +70,8 @@ class DdiConfirmationBaseTest extends AbstractDDiApiIntegrationTest { /** * Forced deployment to a controller. Checks if the confirmation resource response payload for a given deployment is as expected. */ - @Test void verifyConfirmationReferencesInControllerBase(@Autowired ActionStatusRepository actionStatusRepository) throws Exception { + @Test + void verifyConfirmationReferencesInControllerBase(@Autowired ActionStatusRepository actionStatusRepository) throws Exception { enableConfirmationFlow(); // Prepare test data final DistributionSet ds = testdataFactory.createDistributionSet("", true); @@ -135,7 +136,8 @@ class DdiConfirmationBaseTest extends AbstractDDiApiIntegrationTest { /** * Ensure that the deployment resource is available as CBOR */ - @Test void confirmationResourceCbor() throws Exception { + @Test + void confirmationResourceCbor() throws Exception { enableConfirmationFlow(); final Target target = testdataFactory.createTarget(); final DistributionSet distributionSet = testdataFactory.createDistributionSet(""); @@ -160,7 +162,8 @@ class DdiConfirmationBaseTest extends AbstractDDiApiIntegrationTest { /** * Ensure that the confirmation endpoint is not available. */ - @Test void confirmationEndpointNotExposed() throws Exception { + @Test + void confirmationEndpointNotExposed() throws Exception { final DistributionSet ds = testdataFactory.createDistributionSet(""); Target savedTarget = testdataFactory.createTarget("988"); savedTarget = getFirstAssignedTarget(assignDistributionSet(ds.getId(), savedTarget.getControllerId())); @@ -182,7 +185,8 @@ class DdiConfirmationBaseTest extends AbstractDDiApiIntegrationTest { /** * Ensure that the deploymentBase endpoint is not available for action ins WFC state. */ - @Test void deploymentEndpointNotAccessibleForActionsWFC() throws Exception { + @Test + void deploymentEndpointNotAccessibleForActionsWFC() throws Exception { enableConfirmationFlow(); final DistributionSet ds = testdataFactory.createDistributionSet(""); @@ -212,7 +216,8 @@ class DdiConfirmationBaseTest extends AbstractDDiApiIntegrationTest { /** * Ensure that the confirmation endpoints are still available after deactivating the confirmation flow. */ - @Test void verifyConfirmationBaseEndpointsArePresentAfterDisablingConfirmationFlow() throws Exception { + @Test + void verifyConfirmationBaseEndpointsArePresentAfterDisablingConfirmationFlow() throws Exception { enableConfirmationFlow(); final DistributionSet ds = testdataFactory.createDistributionSet(""); @@ -249,7 +254,8 @@ class DdiConfirmationBaseTest extends AbstractDDiApiIntegrationTest { /** * Controller sends a confirmed action state. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @@ -285,7 +291,8 @@ class DdiConfirmationBaseTest extends AbstractDDiApiIntegrationTest { /** * Confirmation base provides right values if auto-confirm not active. */ - @Test void getConfirmationBaseProvidesAutoConfirmStatusNotActive() throws Exception { + @Test + void getConfirmationBaseProvidesAutoConfirmStatusNotActive() throws Exception { enableConfirmationFlow(); final String controllerId = testdataFactory.createTarget("989").getControllerId(); @@ -362,7 +369,8 @@ class DdiConfirmationBaseTest extends AbstractDDiApiIntegrationTest { /** * Verify auto-confirm deactivation is handled correctly. */ - @Test void deactivateAutoConfirmation() throws Exception { + @Test + void deactivateAutoConfirmation() throws Exception { final String controllerId = testdataFactory.createTarget("988").getControllerId(); confirmationManagement.activateAutoConfirmation(controllerId, null, null); @@ -377,7 +385,8 @@ class DdiConfirmationBaseTest extends AbstractDDiApiIntegrationTest { /** * Controller sends a denied action state. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @@ -423,7 +432,8 @@ class DdiConfirmationBaseTest extends AbstractDDiApiIntegrationTest { /** * Test to verify that only a specific count of messages are returned based on the input actionHistory for getControllerDeploymentActionFeedback endpoint. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3), diff --git a/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiDeploymentBaseTest.java b/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiDeploymentBaseTest.java index 1327ac456..aac924196 100644 --- a/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiDeploymentBaseTest.java +++ b/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiDeploymentBaseTest.java @@ -83,7 +83,8 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest { /** * Ensure that the deployment resource is available as CBOR */ - @Test void deploymentResourceCbor() throws Exception { + @Test + void deploymentResourceCbor() throws Exception { final Target target = testdataFactory.createTarget(); final DistributionSet distributionSet = testdataFactory.createDistributionSet(""); @@ -111,7 +112,8 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest { /** * Ensures that artifacts are not found, when software module does not exists. */ - @Test void artifactsNotFound() throws Exception { + @Test + void artifactsNotFound() throws Exception { final Target target = testdataFactory.createTarget(); performGet(SOFTWARE_MODULE_ARTIFACTS, MediaType.APPLICATION_JSON, status().isNotFound(), tenantAware.getCurrentTenant(), target.getControllerId(), "1"); @@ -120,7 +122,8 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest { /** * Ensures that artifacts are found, when software module exists. */ - @Test void artifactsExists() throws Exception { + @Test + void artifactsExists() throws Exception { final Target target = testdataFactory.createTarget(); final DistributionSet distributionSet = testdataFactory.createDistributionSet(""); @@ -140,7 +143,8 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest { /** * Forced deployment to a controller. Checks if the resource response payload for a given deployment is as expected. */ - @Test void deploymentForceAction() throws Exception { + @Test + void deploymentForceAction() throws Exception { // Prepare test data final DistributionSet ds = testdataFactory.createDistributionSet("", true); final DistributionSet ds2 = testdataFactory.createDistributionSet("2", true); @@ -198,7 +202,8 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest { /** * Checks that the deploymentBase URL changes when the action is switched from soft to forced in TIMEFORCED case. */ - @Test void changeEtagIfActionSwitchesFromSoftToForced() throws Exception { + @Test + void changeEtagIfActionSwitchesFromSoftToForced() throws Exception { // Prepare test data final Target target = testdataFactory.createTarget(DEFAULT_CONTROLLER_ID); final DistributionSet ds = testdataFactory.createDistributionSet("", true); @@ -235,7 +240,8 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest { /** * Attempt/soft deployment to a controller. Checks if the resource response payload for a given deployment is as expected. */ - @Test void deploymentAttemptAction() throws Exception { + @Test + void deploymentAttemptAction() throws Exception { // Prepare test data final DistributionSet ds = testdataFactory.createDistributionSet("", true); final DistributionSet ds2 = testdataFactory.createDistributionSet("2", true); @@ -299,7 +305,8 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest { /** * Attempt/soft deployment to a controller including automated switch to hard. Checks if the resource response payload for a given deployment is as expected. */ - @Test void deploymentAutoForceAction() throws Exception { + @Test + void deploymentAutoForceAction() throws Exception { // Prepare test data final DistributionSet ds = testdataFactory.createDistributionSet("", true); final DistributionSet ds2 = testdataFactory.createDistributionSet("2", true); @@ -358,7 +365,8 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest { /** * Test download-only (forced + skip) deployment to a controller. Checks if the resource response payload for a given deployment is as expected. */ - @Test void deploymentDownloadOnlyAction() throws Exception { + @Test + void deploymentDownloadOnlyAction() throws Exception { // Prepare test data final DistributionSet ds = testdataFactory.createDistributionSet("", true); final DistributionSet ds2 = testdataFactory.createDistributionSet("2", true); @@ -420,7 +428,8 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest { /** * Test various invalid access attempts to the deployment resource und the expected behaviour of the server. */ - @Test void badDeploymentAction() throws Exception { + @Test + void badDeploymentAction() throws Exception { final Target target = testdataFactory.createTarget(DEFAULT_CONTROLLER_ID); // not allowed methods @@ -507,7 +516,8 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest { /** * Multiple uploads of deployment status feedback to the server. */ - @Test void multipleDeploymentActionFeedback() throws Exception { + @Test + void multipleDeploymentActionFeedback() throws Exception { testdataFactory.createTarget(DEFAULT_CONTROLLER_ID); testdataFactory.createTarget("4713"); testdataFactory.createTarget("4714"); @@ -548,7 +558,8 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest { /** * Verifies that an update action is correctly set to error if the controller provides error feedback. */ - @Test void rootRsSingleDeploymentActionWithErrorFeedback() throws Exception { + @Test + void rootRsSingleDeploymentActionWithErrorFeedback() throws Exception { DistributionSet ds = testdataFactory.createDistributionSet(""); final Target savedTarget = testdataFactory.createTarget(DEFAULT_CONTROLLER_ID); @@ -585,7 +596,8 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest { /** * Verifies that the controller can provided as much feedback entries as necessary as long as it is in the configured limits. */ - @Test void rootRsSingleDeploymentActionFeedback() throws Exception { + @Test + void rootRsSingleDeploymentActionFeedback() throws Exception { final DistributionSet ds = testdataFactory.createDistributionSet(""); final Long actionId = getFirstAssignedActionId( assignDistributionSet(ds, @@ -626,7 +638,8 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest { /** * Various forbidden request attempts on the feedback resource. Ensures correct answering behaviour as expected to these kind of errors. */ - @Test void badDeploymentActionFeedback() throws Exception { + @Test + void badDeploymentActionFeedback() throws Exception { final DistributionSet savedSet = testdataFactory.createDistributionSet(""); final DistributionSet savedSet2 = testdataFactory.createDistributionSet("1"); @@ -665,7 +678,8 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest { /** * Ensures that an invalid id in feedback body returns a bad request. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @@ -687,7 +701,8 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest { /** * Ensures that a missing feedback result in feedback body returns a bad request. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @@ -713,7 +728,8 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest { /** * Ensures that a missing finished result in feedback body returns a bad request. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3), diff --git a/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiInstalledBaseTest.java b/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiInstalledBaseTest.java index fb1c37604..795b1723d 100644 --- a/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiInstalledBaseTest.java +++ b/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiInstalledBaseTest.java @@ -77,7 +77,8 @@ class DdiInstalledBaseTest extends AbstractDDiApiIntegrationTest { /** * Ensure that the installed base resource is available as CBOR */ - @Test void installedBaseResourceCbor() throws Exception { + @Test + void installedBaseResourceCbor() throws Exception { final Target target = testdataFactory.createTarget(); final DistributionSet ds = testdataFactory.createDistributionSet(""); @@ -100,7 +101,8 @@ class DdiInstalledBaseTest extends AbstractDDiApiIntegrationTest { /** * Ensure that assigned version is self assigned version */ - @Test void installedVersion() throws Exception { + @Test + void installedVersion() throws Exception { final Target target = createTargetAndAssertNoActiveActions(); final DistributionSet ds = testdataFactory.createDistributionSet(""); @@ -116,7 +118,8 @@ class DdiInstalledBaseTest extends AbstractDDiApiIntegrationTest { /** * Ensure that installedVersion is version self assigned */ - @Test void installedVersionNotExist() throws Exception { + @Test + void installedVersionNotExist() throws Exception { final Target target = createTargetAndAssertNoActiveActions(); final String dsName = "unknown"; final String dsVersion = "1.0.0"; @@ -130,7 +133,8 @@ class DdiInstalledBaseTest extends AbstractDDiApiIntegrationTest { /** * Test several deployments to a controller. Checks that action is represented as installedBase after installation. */ - @Test void deploymentSeveralActionsInInstalledBase() throws Exception { + @Test + void deploymentSeveralActionsInInstalledBase() throws Exception { // Prepare test data final Target target = createTargetAndAssertNoActiveActions(); @@ -199,7 +203,8 @@ class DdiInstalledBaseTest extends AbstractDDiApiIntegrationTest { /** * Test several deployments of same ds to a controller. Checks that cancelled action in history is not linked as installedBase. */ - @Test void deploymentActionsOfSameDsWithCancelledActionInHistory() throws Exception { + @Test + void deploymentActionsOfSameDsWithCancelledActionInHistory() throws Exception { // Prepare test data final Target target = createTargetAndAssertNoActiveActions(); @@ -256,7 +261,8 @@ class DdiInstalledBaseTest extends AbstractDDiApiIntegrationTest { /** * Test several deployments of same ds to a controller. Checks that latest cancelled action does not override actual installed ds. */ - @Test void deploymentActionsOfSameDsWithCancelledAction() throws Exception { + @Test + void deploymentActionsOfSameDsWithCancelledAction() throws Exception { // Prepare test data final Target target = createTargetAndAssertNoActiveActions(); @@ -314,7 +320,8 @@ class DdiInstalledBaseTest extends AbstractDDiApiIntegrationTest { /** * Test several deployments of same ds to a controller. Checks that latest running action does not override actual installed ds. */ - @Test void deploymentActionsOfSameDsWithRunningAction() throws Exception { + @Test + void deploymentActionsOfSameDsWithRunningAction() throws Exception { // Prepare test data final Target target = createTargetAndAssertNoActiveActions(); @@ -368,7 +375,8 @@ class DdiInstalledBaseTest extends AbstractDDiApiIntegrationTest { /** * Test open deployment to a controller. Checks that installedBase returns 404 for a pending action. */ - @Test void installedBaseReturns404ForPendingAction() throws Exception { + @Test + void installedBaseReturns404ForPendingAction() throws Exception { // Prepare test data final Target target = createTargetAndAssertNoActiveActions(); final DistributionSet ds = testdataFactory.createDistributionSet(""); @@ -392,7 +400,8 @@ class DdiInstalledBaseTest extends AbstractDDiApiIntegrationTest { /** * Ensures that artifacts are found, after the action was already closed. */ - @Test void artifactsOfInstalledActionExist() throws Exception { + @Test + void artifactsOfInstalledActionExist() throws Exception { final Target target = createTargetAndAssertNoActiveActions(); final DistributionSet ds = testdataFactory.createDistributionSet(""); @@ -470,7 +479,8 @@ class DdiInstalledBaseTest extends AbstractDDiApiIntegrationTest { /** * Test download-only deployment to a controller. Checks that download-only is not represented as installedBase. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @@ -547,7 +557,8 @@ class DdiInstalledBaseTest extends AbstractDDiApiIntegrationTest { /** * Test to verify that only a specific count of messages are returned based on the input actionHistory for getControllerInstalledAction endpoint. */ - @Test void testActionHistoryCount() throws Exception { + @Test + void testActionHistoryCount() throws Exception { final DistributionSet ds = testdataFactory.createDistributionSet(""); Target savedTarget = testdataFactory.createTarget("911"); savedTarget = getFirstAssignedTarget(assignDistributionSet(ds.getId(), savedTarget.getControllerId())); @@ -599,7 +610,8 @@ class DdiInstalledBaseTest extends AbstractDDiApiIntegrationTest { /** * Test various invalid access attempts to the installed resource und the expected behaviour of the server. */ - @Test void badInstalledAction() throws Exception { + @Test + void badInstalledAction() throws Exception { final Target target = testdataFactory.createTarget(CONTROLLER_ID); // not allowed methods diff --git a/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiRootControllerTest.java b/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiRootControllerTest.java index 4fa97bd84..918f11043 100644 --- a/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiRootControllerTest.java +++ b/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DdiRootControllerTest.java @@ -85,7 +85,8 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest { /** * Ensure that the root poll resource is available as CBOR */ - @Test void rootPollResourceCbor() throws Exception { + @Test + void rootPollResourceCbor() throws Exception { mvc.perform(get(CONTROLLER_BASE, tenantAware.getCurrentTenant(), 4711).accept(DdiRestConstants.MEDIA_TYPE_CBOR)) .andDo(MockMvcResultPrinter.print()) .andExpect(content().contentType(DdiRestConstants.MEDIA_TYPE_CBOR)) @@ -95,7 +96,8 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest { /** * Ensures that the API returns JSON when no Accept header is specified by the client. */ - @Test void apiReturnsJSONByDefault() throws Exception { + @Test + void apiReturnsJSONByDefault() throws Exception { final MvcResult result = mvc.perform(get(CONTROLLER_BASE, tenantAware.getCurrentTenant(), 4711)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) @@ -109,7 +111,8 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest { /** * Ensures that target poll request does not change audit data on the entity. */ - @Test @WithUser(principal = "knownPrincipal", authorities = { SpPermission.READ_TARGET, SpPermission.UPDATE_TARGET, SpPermission.CREATE_TARGET }) + @Test + @WithUser(principal = "knownPrincipal", authorities = { SpPermission.READ_TARGET, SpPermission.UPDATE_TARGET, SpPermission.CREATE_TARGET }) @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 1), @@ -142,7 +145,8 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest { /** * Ensures that server returns a not found response in case of empty controller ID. */ - @Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) }) + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) }) void rootRsWithoutId() throws Exception { mvc.perform(get("/controller/v1/")) .andDo(MockMvcResultPrinter.print()) @@ -152,7 +156,8 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest { /** * Ensures that the system creates a new target in plug and play manner, i.e. target is authenticated but does not exist yet. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1) }) void rootRsPlugAndPlay() throws Exception { @@ -188,7 +193,8 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest { /** * Ensures that tenant specific polling time, which is saved in the db, is delivered to the controller. */ - @Test @WithUser(principal = "knownpricipal", allSpPermissions = false) + @Test + @WithUser(principal = "knownpricipal", allSpPermissions = false) @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1), @@ -213,7 +219,8 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest { /** * Ensures that etag check results in not modified response if provided etag by client is identical to entity in repository. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 6), @Expect(type = TargetAssignDistributionSetEvent.class, count = 2), @@ -342,7 +349,8 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest { /** * Ensures that the source IP address of the polling target is correctly stored in repository */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1) }) void rootRsPlugAndPlayIpAddress() throws Exception { @@ -371,7 +379,8 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest { /** * Ensures that the source IP address of the polling target is not stored in repository if disabled */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1) }) void rootRsIpAddressNotStoredIfDisabled() throws Exception { @@ -393,7 +402,8 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest { /** * Controller trys to finish an update process after it has been finished by an error action status. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @@ -425,7 +435,8 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest { /** * Controller sends attribute update request after device successfully closed software update. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @@ -456,7 +467,8 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest { /** * Test to verify that only a specific count of messages are returned based on the input actionHistory for getControllerDeploymentActionFeedback endpoint. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @@ -501,7 +513,8 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest { /** * Test to verify that a zero input value of actionHistory results in no action history appended for getControllerDeploymentActionFeedback endpoint. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @@ -546,7 +559,8 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest { /** * Test to verify that entire action history is returned if the input value for actionHistory is -1, for getControllerDeploymentActionFeedback endpoint. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @@ -591,7 +605,8 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest { /** * Test the polling time based on different maintenance window start and end time. */ - @Test void sleepTimeResponseForDifferentMaintenanceWindowParameters() throws Exception { + @Test + void sleepTimeResponseForDifferentMaintenanceWindowParameters() throws Exception { final DistributionSet ds = testdataFactory.createDistributionSet(""); SecurityContextSwitch.runAs(SecurityContextSwitch.withUser("tenantadmin", TENANT_CONFIGURATION), @@ -642,7 +657,8 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest { /** * Test download and update values before maintenance window start time. */ - @Test void downloadAndUpdateStatusBeforeMaintenanceWindowStartTime() throws Exception { + @Test + void downloadAndUpdateStatusBeforeMaintenanceWindowStartTime() throws Exception { Target savedTarget = testdataFactory.createTarget("1911"); final DistributionSet ds = testdataFactory.createDistributionSet(""); savedTarget = getFirstAssignedTarget(assignDistributionSetWithMaintenanceWindow(ds.getId(), @@ -665,7 +681,8 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest { /** * Test download and update values after maintenance window start time. */ - @Test void downloadAndUpdateStatusDuringMaintenanceWindow() throws Exception { + @Test + void downloadAndUpdateStatusDuringMaintenanceWindow() throws Exception { Target savedTarget = testdataFactory.createTarget("1911"); final DistributionSet ds = testdataFactory.createDistributionSet(""); savedTarget = getFirstAssignedTarget(assignDistributionSetWithMaintenanceWindow(ds.getId(), @@ -688,7 +705,8 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest { /** * Assign multiple DS in multi-assignment mode. The earliest active Action is exposed to the controller. */ - @Test void earliestActionIsExposedToControllerInMultiAssignMode() throws Exception { + @Test + void earliestActionIsExposedToControllerInMultiAssignMode() throws Exception { enableMultiAssignments(); final Target target = testdataFactory.createTarget(); final DistributionSet ds1 = testdataFactory.createDistributionSet(UUID.randomUUID().toString()); @@ -704,7 +722,8 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest { /** * The system should not create a new target because of a too long controller id. */ - @Test void rootRsWithInvalidControllerId() throws Exception { + @Test + void rootRsWithInvalidControllerId() throws Exception { final String invalidControllerId = randomString(Target.CONTROLLER_ID_MAX_SIZE + 1); mvc.perform(get(CONTROLLER_BASE, tenantAware.getCurrentTenant(), invalidControllerId)) .andExpect(status().isBadRequest()); diff --git a/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DosFilterTest.java b/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DosFilterTest.java index 06fb137eb..97934ff60 100644 --- a/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DosFilterTest.java +++ b/hawkbit-ddi/hawkbit-ddi-resource/src/test/java/org/eclipse/hawkbit/ddi/rest/resource/DosFilterTest.java @@ -51,7 +51,8 @@ class DosFilterTest extends AbstractDDiApiIntegrationTest { /** * Ensures that clients that are on the blacklist are forbidden */ - @Test void blackListedClientIsForbidden() throws Exception { + @Test + void blackListedClientIsForbidden() throws Exception { mvc.perform(get("/{tenant}/controller/v1/4711", tenantAware.getCurrentTenant()) .header(X_FORWARDED_FOR, "192.168.0.4 , 10.0.0.1 ")) .andExpect(status().isForbidden()); @@ -60,7 +61,8 @@ class DosFilterTest extends AbstractDDiApiIntegrationTest { /** * Ensures that a READ DoS attempt is blocked */ - @Test void getFloodingAttackThatIsPrevented() throws Exception { + @Test + void getFloodingAttackThatIsPrevented() throws Exception { int requests = 0; MvcResult result; do { @@ -80,7 +82,8 @@ class DosFilterTest extends AbstractDDiApiIntegrationTest { /** * Ensures that an assumed READ DoS attempt is not blocked as the client (with IPv4 address) is on a whitelist */ - @Test void unacceptableGetLoadButOnWhitelistIPv4() throws Exception { + @Test + void unacceptableGetLoadButOnWhitelistIPv4() throws Exception { for (int i = 0; i < 100; i++) { mvc.perform(get("/{tenant}/controller/v1/4711", tenantAware.getCurrentTenant()) .header(X_FORWARDED_FOR, "127.0.0.1")) @@ -91,7 +94,8 @@ class DosFilterTest extends AbstractDDiApiIntegrationTest { /** * Ensures that an assumed READ DoS attempt is not blocked as the client (with IPv6 address) is on a whitelist */ - @Test void unacceptableGetLoadButOnWhitelistIPv6() throws Exception { + @Test + void unacceptableGetLoadButOnWhitelistIPv6() throws Exception { for (int i = 0; i < 100; i++) { mvc.perform(get("/{tenant}/controller/v1/4711", tenantAware.getCurrentTenant()) .header(X_FORWARDED_FOR, "0:0:0:0:0:0:0:1")) @@ -102,7 +106,8 @@ class DosFilterTest extends AbstractDDiApiIntegrationTest { /** * Ensures that a relatively high number of READ requests is allowed if it is below the DoS detection threshold */ - @Test // No idea how to get rid of the Thread.sleep here + @Test + // No idea how to get rid of the Thread.sleep here @SuppressWarnings("squid:S2925") void acceptableGetLoad() throws Exception { for (int x = 0; x < 3; x++) { @@ -119,7 +124,8 @@ class DosFilterTest extends AbstractDDiApiIntegrationTest { /** * Ensures that a WRITE DoS attempt is blocked */ - @Test void putPostFloddingAttackThatisPrevented() throws Exception { + @Test + void putPostFloddingAttackThatisPrevented() throws Exception { final Long actionId = prepareDeploymentBase(); final String feedback = getJsonProceedingDeploymentActionFeedback(); @@ -143,7 +149,8 @@ class DosFilterTest extends AbstractDDiApiIntegrationTest { /** * Ensures that a relatively high number of WRITE requests is allowed if it is below the DoS detection threshold */ - @Test // No idea how to get rid of the Thread.sleep here + @Test + // No idea how to get rid of the Thread.sleep here @SuppressWarnings("squid:S2925") void acceptablePutPostLoad() throws Exception { final Long actionId = prepareDeploymentBase(); diff --git a/hawkbit-ddi/hawkbit-ddi-security/src/test/java/org/eclipse/hawkbit/security/controller/GatewayTokenAuthenticatorTest.java b/hawkbit-ddi/hawkbit-ddi-security/src/test/java/org/eclipse/hawkbit/security/controller/GatewayTokenAuthenticatorTest.java index 9c24ffb4c..ce3141708 100644 --- a/hawkbit-ddi/hawkbit-ddi-security/src/test/java/org/eclipse/hawkbit/security/controller/GatewayTokenAuthenticatorTest.java +++ b/hawkbit-ddi/hawkbit-ddi-security/src/test/java/org/eclipse/hawkbit/security/controller/GatewayTokenAuthenticatorTest.java @@ -63,7 +63,8 @@ class GatewayTokenAuthenticatorTest { /** * Tests successful authentication with gateway token */ - @Test void testWithGwToken() { + @Test + void testWithGwToken() { final ControllerSecurityToken securityToken = prepareSecurityToken(GATEWAY_TOKEN); when(tenantConfigurationManagementMock.getConfigurationValue( TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_KEY, String.class)) @@ -80,7 +81,8 @@ class GatewayTokenAuthenticatorTest { /** * Tests that if gateway token doesn't match, the authentication fails */ - @Test void testWithBadGwToken() { + @Test + void testWithBadGwToken() { final ControllerSecurityToken securityToken = prepareSecurityToken(UNKNOWN_TOKEN); when(tenantConfigurationManagementMock.getConfigurationValue( TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_KEY, String.class)) @@ -95,14 +97,16 @@ class GatewayTokenAuthenticatorTest { /** * Tests that if gateway token miss, the authentication fails */ - @Test void testWithoutGwToken() { + @Test + void testWithoutGwToken() { assertThat(authenticator.authenticate(new ControllerSecurityToken("DEFAULT", CONTROLLER_ID))).isNull(); } /** * Tests that if disabled, the authentication fails */ - @Test void testWithGwTokenButDisabled() { + @Test + void testWithGwTokenButDisabled() { final ControllerSecurityToken securityToken = prepareSecurityToken(GATEWAY_TOKEN); when(tenantConfigurationManagementMock.getConfigurationValue( TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_ENABLED, Boolean.class)) diff --git a/hawkbit-ddi/hawkbit-ddi-security/src/test/java/org/eclipse/hawkbit/security/controller/SecurityHeaderAuthenticatorTest.java b/hawkbit-ddi/hawkbit-ddi-security/src/test/java/org/eclipse/hawkbit/security/controller/SecurityHeaderAuthenticatorTest.java index b345e96ff..02bb75292 100644 --- a/hawkbit-ddi/hawkbit-ddi-security/src/test/java/org/eclipse/hawkbit/security/controller/SecurityHeaderAuthenticatorTest.java +++ b/hawkbit-ddi/hawkbit-ddi-security/src/test/java/org/eclipse/hawkbit/security/controller/SecurityHeaderAuthenticatorTest.java @@ -74,7 +74,8 @@ class SecurityHeaderAuthenticatorTest { /** * Tests successful authentication with multiple a single hashes */ - @Test void testWithSingleKnownHash() { + @Test + void testWithSingleKnownHash() { final ControllerSecurityToken securityToken = prepareSecurityToken(SINGLE_HASH); when(tenantConfigurationManagementMock.getConfigurationValue( TenantConfigurationKey.AUTHENTICATION_MODE_HEADER_AUTHORITY_NAME, String.class)) @@ -91,7 +92,8 @@ class SecurityHeaderAuthenticatorTest { /** * Tests successful authentication with multiple hashes */ - @Test void testWithMultipleKnownHashes() { + @Test + void testWithMultipleKnownHashes() { when(tenantConfigurationManagementMock.getConfigurationValue( TenantConfigurationKey.AUTHENTICATION_MODE_HEADER_AUTHORITY_NAME, String.class)) .thenReturn(CONFIG_VALUE_MULTI_HASH); @@ -113,7 +115,8 @@ class SecurityHeaderAuthenticatorTest { /** * Tests that if the hash is unknown, the authentication fails */ - @Test void testWithUnknownHash() { + @Test + void testWithUnknownHash() { final ControllerSecurityToken securityToken = prepareSecurityToken(UNKNOWN_HASH); when(tenantConfigurationManagementMock.getConfigurationValue( TenantConfigurationKey.AUTHENTICATION_MODE_HEADER_AUTHORITY_NAME, String.class)) @@ -128,7 +131,8 @@ class SecurityHeaderAuthenticatorTest { /** * Tests that if CN doesn't match the CN in the security token, the authentication fails */ - @Test void testWithNonMatchingCN() { + @Test + void testWithNonMatchingCN() { final ControllerSecurityToken securityToken = new ControllerSecurityToken("DEFAULT", "otherControllerID"); securityToken.putHeader(CA_COMMON_NAME, CA_COMMON_NAME_VALUE); securityToken.putHeader(X_SSL_ISSUER_HASH_1, SINGLE_HASH); @@ -139,14 +143,16 @@ class SecurityHeaderAuthenticatorTest { /** * Tests that if the hash miss, the authentication fails */ - @Test void testWithoutHash() { + @Test + void testWithoutHash() { assertThat(authenticator.authenticate(new ControllerSecurityToken("DEFAULT", CA_COMMON_NAME_VALUE))).isNull(); } /** * Tests that if disabled, the authentication fails */ - @Test void testWithSingleKnownHashButDisabled() { + @Test + void testWithSingleKnownHashButDisabled() { final ControllerSecurityToken securityToken = prepareSecurityToken(SINGLE_HASH); when(tenantConfigurationManagementMock.getConfigurationValue( TenantConfigurationKey.AUTHENTICATION_MODE_HEADER_ENABLED, Boolean.class)) diff --git a/hawkbit-ddi/hawkbit-ddi-security/src/test/java/org/eclipse/hawkbit/security/controller/SecurityTokenAuthenticatorTest.java b/hawkbit-ddi/hawkbit-ddi-security/src/test/java/org/eclipse/hawkbit/security/controller/SecurityTokenAuthenticatorTest.java index 971953eba..6e11191ea 100644 --- a/hawkbit-ddi/hawkbit-ddi-security/src/test/java/org/eclipse/hawkbit/security/controller/SecurityTokenAuthenticatorTest.java +++ b/hawkbit-ddi/hawkbit-ddi-security/src/test/java/org/eclipse/hawkbit/security/controller/SecurityTokenAuthenticatorTest.java @@ -68,7 +68,8 @@ class SecurityTokenAuthenticatorTest { /** * Tests successful authentication with gateway token */ - @Test void testWithSecToken() { + @Test + void testWithSecToken() { final ControllerSecurityToken securityToken = prepareSecurityToken(SECURITY_TOKEN); when(tenantConfigurationManagementMock.getConfigurationValue( TenantConfigurationKey.AUTHENTICATION_MODE_TARGET_SECURITY_TOKEN_ENABLED, Boolean.class)) @@ -87,7 +88,8 @@ class SecurityTokenAuthenticatorTest { /** * Tests that if gateway token doesn't match, the authentication fails */ - @Test void testWithBadSecToken() { + @Test + void testWithBadSecToken() { final ControllerSecurityToken securityToken = prepareSecurityToken(UNKNOWN_TOKEN); when(tenantConfigurationManagementMock.getConfigurationValue( TenantConfigurationKey.AUTHENTICATION_MODE_TARGET_SECURITY_TOKEN_ENABLED, Boolean.class)) @@ -99,14 +101,16 @@ class SecurityTokenAuthenticatorTest { /** * Tests that if gateway token miss, the authentication fails */ - @Test void testWithoutSecToken() { + @Test + void testWithoutSecToken() { assertThat(authenticator.authenticate(new ControllerSecurityToken("DEFAULT", CONTROLLER_ID))).isNull(); } /** * Tests that if disabled, the authentication fails */ - @Test void testWithSecTokenButDisabled() { + @Test + void testWithSecTokenButDisabled() { final ControllerSecurityToken securityToken = prepareSecurityToken(SECURITY_TOKEN); when(tenantConfigurationManagementMock.getConfigurationValue( TenantConfigurationKey.AUTHENTICATION_MODE_TARGET_SECURITY_TOKEN_ENABLED, Boolean.class)) diff --git a/hawkbit-ddi/hawkbit-ddi-server/src/test/java/org/eclipse/hawkbit/app/ddi/AllowedHostNamesTest.java b/hawkbit-ddi/hawkbit-ddi-server/src/test/java/org/eclipse/hawkbit/app/ddi/AllowedHostNamesTest.java index 9993261d9..7a93f7e66 100644 --- a/hawkbit-ddi/hawkbit-ddi-server/src/test/java/org/eclipse/hawkbit/app/ddi/AllowedHostNamesTest.java +++ b/hawkbit-ddi/hawkbit-ddi-server/src/test/java/org/eclipse/hawkbit/app/ddi/AllowedHostNamesTest.java @@ -29,7 +29,8 @@ class AllowedHostNamesTest extends AbstractSecurityTest { /** * Tests whether a RequestRejectedException is thrown when not allowed host is used */ - @Test void allowedHostNameWithNotAllowedHost() throws Exception { + @Test + void allowedHostNameWithNotAllowedHost() throws Exception { mvc.perform(get("/").header(HttpHeaders.HOST, "www.google.com")) .andExpect(status().isBadRequest()); } @@ -37,7 +38,8 @@ class AllowedHostNamesTest extends AbstractSecurityTest { /** * Tests whether request is redirected when allowed host is used */ - @Test void allowedHostNameWithAllowedHost() throws Exception { + @Test + void allowedHostNameWithAllowedHost() throws Exception { mvc.perform(get("/").header(HttpHeaders.HOST, "localhost")) .andExpect(status().is3xxRedirection()); } @@ -45,7 +47,8 @@ class AllowedHostNamesTest extends AbstractSecurityTest { /** * Tests whether request without allowed host name and with ignored path end up with a client error */ - @Test void notAllowedHostnameWithIgnoredPath() throws Exception { + @Test + void notAllowedHostnameWithIgnoredPath() throws Exception { mvc.perform(get("/index.html").header(HttpHeaders.HOST, "www.google.com")) .andExpect(status().is4xxClientError()); } diff --git a/hawkbit-ddi/hawkbit-ddi-server/src/test/java/org/eclipse/hawkbit/app/ddi/PreAuthorizeEnabledTest.java b/hawkbit-ddi/hawkbit-ddi-server/src/test/java/org/eclipse/hawkbit/app/ddi/PreAuthorizeEnabledTest.java index d6d87a0f4..a7b2ccec5 100644 --- a/hawkbit-ddi/hawkbit-ddi-server/src/test/java/org/eclipse/hawkbit/app/ddi/PreAuthorizeEnabledTest.java +++ b/hawkbit-ddi/hawkbit-ddi-server/src/test/java/org/eclipse/hawkbit/app/ddi/PreAuthorizeEnabledTest.java @@ -28,7 +28,8 @@ class PreAuthorizeEnabledTest extends AbstractSecurityTest { /** * Tests whether request fail if a role is forbidden for the user */ - @Test @WithUser(authorities = { SpPermission.READ_TARGET }, autoCreateTenant = false) + @Test + @WithUser(authorities = { SpPermission.READ_TARGET }, autoCreateTenant = false) void failIfNoRole() throws Exception { mvc.perform(get("/DEFAULT/controller/v1/controllerId")) .andExpect(result -> assertThat(result.getResponse().getStatus()).isEqualTo(HttpStatus.FORBIDDEN.value())); @@ -37,7 +38,8 @@ class PreAuthorizeEnabledTest extends AbstractSecurityTest { /** * Tests whether request succeed if a role is granted for the user */ - @Test @WithUser(authorities = { SpPermission.SpringEvalExpressions.CONTROLLER_ROLE }, autoCreateTenant = false) + @Test + @WithUser(authorities = { SpPermission.SpringEvalExpressions.CONTROLLER_ROLE }, autoCreateTenant = false) void successIfHasRole() throws Exception { mvc.perform(get("/DEFAULT/controller/v1/controllerId")) .andExpect(result -> assertThat(result.getResponse().getStatus()).isEqualTo(HttpStatus.OK.value())); diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherServiceTest.java b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherServiceTest.java index 979f0a5f3..922ddff1b 100644 --- a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherServiceTest.java +++ b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherServiceTest.java @@ -118,7 +118,8 @@ class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest { /** * Verifies that download and install event with 3 software modules and no artifacts works */ - @Test void testSendDownloadRequestWithSoftwareModulesAndNoArtifacts() { + @Test + void testSendDownloadRequestWithSoftwareModulesAndNoArtifacts() { final DistributionSet createDistributionSet = testdataFactory .createDistributionSet(UUID.randomUUID().toString()); testdataFactory.addSoftwareModuleMetadata(createDistributionSet); @@ -158,7 +159,8 @@ class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest { /** * Verifies that download and install event with software modules and artifacts works */ - @Test void testSendDownloadRequest() { + @Test + void testSendDownloadRequest() { DistributionSet dsA = testdataFactory.createDistributionSet(UUID.randomUUID().toString()); SoftwareModule module = dsA.getModules().iterator().next(); final List receivedList = new ArrayList<>(); @@ -210,7 +212,8 @@ class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest { /** * Verifies that sending update controller attributes event works. */ - @Test void sendUpdateAttributesRequest() { + @Test + void sendUpdateAttributesRequest() { final String amqpUri = "amqp://anyhost"; final TargetAttributesRequestedEvent targetAttributesRequestedEvent = new TargetAttributesRequestedEvent(TENANT, 1L, CONTROLLER_ID, amqpUri, Target.class, serviceMatcher.getBusId()); @@ -224,7 +227,8 @@ class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest { /** * Verifies that send cancel event works */ - @Test void testSendCancelRequest() { + @Test + void testSendCancelRequest() { final Action action = mock(Action.class); when(action.getId()).thenReturn(1L); when(action.getTenant()).thenReturn(TENANT); @@ -241,7 +245,8 @@ class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest { /** * Verifies that sending a delete message when receiving a delete event works. */ - @Test void sendDeleteRequest() { + @Test + void sendDeleteRequest() { // setup final String amqpUri = "amqp://anyhost"; @@ -259,7 +264,8 @@ class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest { /** * Verifies that a delete message is not send if the address is not an amqp address. */ - @Test void sendDeleteRequestWithNoAmqpAddress() { + @Test + void sendDeleteRequestWithNoAmqpAddress() { // setup final String noAmqpUri = "http://anyhost"; @@ -276,7 +282,8 @@ class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest { /** * Verifies that a delete message is not send if the address is null. */ - @Test void sendDeleteRequestWithNullAddress() { + @Test + void sendDeleteRequestWithNullAddress() { // setup final String noAmqpUri = null; diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerServiceTest.java b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerServiceTest.java index da25db311..197a7a0e4 100644 --- a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerServiceTest.java +++ b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerServiceTest.java @@ -145,7 +145,8 @@ class AmqpMessageHandlerServiceTest { /** * Tests not allowed content-type in message */ - @Test void wrongContentType() { + @Test + void wrongContentType() { final MessageProperties messageProperties = new MessageProperties(); messageProperties.setContentType("xml"); final Message message = new Message(new byte[0], messageProperties); @@ -159,7 +160,8 @@ class AmqpMessageHandlerServiceTest { /** * Tests the creation of a target/thing by calling the same method that incoming RabbitMQ messages would access. */ - @Test void createThing() { + @Test + void createThing() { final String knownThingId = "1"; processThingCreatedMessage(knownThingId, null); @@ -171,7 +173,8 @@ class AmqpMessageHandlerServiceTest { /** * Tests the creation of a target/thing with specified name by calling the same method that incoming RabbitMQ messages would access. */ - @Test void createThingWithName() { + @Test + void createThingWithName() { final String knownThingId = "2"; final String knownThingName = "NonDefaultTargetName"; @@ -187,7 +190,8 @@ class AmqpMessageHandlerServiceTest { /** * Tests the creation of a target/thing with specified type name by calling the same method that incoming RabbitMQ messages would access. */ - @Test void createThingWithType() { + @Test + void createThingWithType() { final String knownThingId = "2"; final String knownThingTypeName = "TargetTypeName"; @@ -203,7 +207,8 @@ class AmqpMessageHandlerServiceTest { /** * Tests not allowed body in message */ - @Test void createThingWithWrongBody() { + @Test + void createThingWithWrongBody() { final Message message = createMessage("Not allowed Body".getBytes(), getThingCreatedMessageProperties("3")); final String type = MessageType.THING_CREATED.name(); assertThatExceptionOfType(MessageConversionException.class) @@ -214,7 +219,8 @@ class AmqpMessageHandlerServiceTest { /** * Tests the creation of a target/thing with specified attributes by calling the same method that incoming RabbitMQ messages would access. */ - @Test void createThingWithAttributes() { + @Test + void createThingWithAttributes() { final String knownThingId = "4"; final DmfAttributeUpdate attributeUpdate = dmfAttributeUpdate(); @@ -231,7 +237,8 @@ class AmqpMessageHandlerServiceTest { /** * Tests the creation of a target/thing with specified name and attributes by calling the same method that incoming RabbitMQ messages would access. */ - @Test void createThingWithNameAndAttributes() { + @Test + void createThingWithNameAndAttributes() { final String knownThingId = "5"; final String knownThingName = "NonDefaultTargetName"; @@ -250,7 +257,8 @@ class AmqpMessageHandlerServiceTest { /** * Tests the target attribute update by calling the same method that incoming RabbitMQ messages would access. */ - @Test void updateAttributes() { + @Test + void updateAttributes() { final String knownThingId = "1"; final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT); messageProperties.setHeader(MessageHeaderKey.THING_ID, knownThingId); @@ -271,7 +279,8 @@ class AmqpMessageHandlerServiceTest { /** * Verifies that the update mode is retrieved from the UPDATE_ATTRIBUTES message and passed to the controller management. */ - @Test void attributeUpdateModes() { + @Test + void attributeUpdateModes() { final String knownThingId = "1"; final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT); messageProperties.setHeader(MessageHeaderKey.THING_ID, knownThingId); @@ -322,7 +331,8 @@ class AmqpMessageHandlerServiceTest { /** * Tests the creation of a thing without a 'reply to' header in message. */ - @Test void createThingWithoutReplyTo() { + @Test + void createThingWithoutReplyTo() { final MessageProperties messageProperties = createMessageProperties(MessageType.THING_CREATED, null); messageProperties.setHeader(MessageHeaderKey.THING_ID, "1"); final Message message = createMessage("", messageProperties); @@ -335,7 +345,8 @@ class AmqpMessageHandlerServiceTest { /** * Tests the creation of a target/thing without a thingID by calling the same method that incoming RabbitMQ messages would access. */ - @Test void createThingWithoutID() { + @Test + void createThingWithoutID() { final MessageProperties messageProperties = createMessageProperties(MessageType.THING_CREATED); final Message message = createMessage(new byte[0], messageProperties); final String type = MessageType.THING_CREATED.name(); @@ -347,7 +358,8 @@ class AmqpMessageHandlerServiceTest { /** * Tests the call of the same method that incoming RabbitMQ messages would access with an unknown message type. */ - @Test void unknownMessageType() { + @Test + void unknownMessageType() { final String type = "bumlux"; final MessageProperties messageProperties = createMessageProperties(MessageType.THING_CREATED); messageProperties.setHeader(MessageHeaderKey.THING_ID, ""); @@ -361,7 +373,8 @@ class AmqpMessageHandlerServiceTest { /** * Tests a invalid message without event topic */ - @Test void invalidEventTopic() { + @Test + void invalidEventTopic() { final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT); final Message message = new Message(new byte[0], messageProperties); @@ -384,7 +397,8 @@ class AmqpMessageHandlerServiceTest { /** * Tests the update of an action of a target without a exist action id */ - @Test void updateActionStatusWithoutActionId() { + @Test + void updateActionStatusWithoutActionId() { when(controllerManagementMock.findActionWithDetails(anyLong())).thenReturn(Optional.empty()); final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT); messageProperties.setHeader(MessageHeaderKey.TOPIC, EventTopic.UPDATE_ACTION_STATUS.name()); @@ -399,7 +413,8 @@ class AmqpMessageHandlerServiceTest { /** * Tests the update of an action of a target without a exist action id */ - @Test void updateActionStatusWithoutExistActionId() { + @Test + void updateActionStatusWithoutExistActionId() { final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT); messageProperties.setHeader(MessageHeaderKey.TOPIC, EventTopic.UPDATE_ACTION_STATUS.name()); when(controllerManagementMock.findActionWithDetails(anyLong())).thenReturn(Optional.empty()); @@ -416,7 +431,8 @@ class AmqpMessageHandlerServiceTest { /** * Tests that messages which cause quota violations are not re-added to message queue so they would block other communication. */ - @Test void quotaExceeded() { + @Test + void quotaExceeded() { final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT); messageProperties.setHeader(MessageHeaderKey.TOPIC, EventTopic.UPDATE_ACTION_STATUS.name()); @@ -442,7 +458,8 @@ class AmqpMessageHandlerServiceTest { /** * Test next update is provided on finished action */ - @Test void lookupNextUpdateActionAfterFinished() throws IllegalAccessException { + @Test + void lookupNextUpdateActionAfterFinished() throws IllegalAccessException { // Mock final Action action = createActionWithTarget(22L); @@ -480,7 +497,8 @@ class AmqpMessageHandlerServiceTest { /** * Test feedback code is persisted in messages when provided with DmfActionUpdateStatus */ - @Test void feedBackCodeIsPersistedInMessages() throws IllegalAccessException { + @Test + void feedBackCodeIsPersistedInMessages() throws IllegalAccessException { // Mock final Action action = createActionWithTarget(22L); when(controllerManagementMock.findActionWithDetails(anyLong())).thenReturn(Optional.of(action)); @@ -515,7 +533,8 @@ class AmqpMessageHandlerServiceTest { /** * Tests the deletion of a target/thing, requested by the target itself. */ - @Test void deleteThing() { + @Test + void deleteThing() { // prepare valid message final String knownThingId = "1"; final MessageProperties messageProperties = createMessageProperties(MessageType.THING_REMOVED); @@ -532,7 +551,8 @@ class AmqpMessageHandlerServiceTest { /** * Tests the deletion of a target/thing with missing thingId */ - @Test void deleteThingWithoutThingId() { + @Test + void deleteThingWithoutThingId() { // prepare invalid message final MessageProperties messageProperties = createMessageProperties(MessageType.THING_REMOVED); final Message message = createMessage(new byte[0], messageProperties); @@ -546,7 +566,8 @@ class AmqpMessageHandlerServiceTest { /** * Tests activating auto-confirmation on a target. */ - @Test void setAutoConfirmationStateActive() { + @Test + void setAutoConfirmationStateActive() { final String knownThingId = "1"; final String initiator = "iAmTheInitiator"; final String remark = "remarkForTesting"; @@ -573,7 +594,8 @@ class AmqpMessageHandlerServiceTest { /** * Tests deactivating auto-confirmation on a target. */ - @Test void setAutoConfirmationStateDeactivated() { + @Test + void setAutoConfirmationStateDeactivated() { final String knownThingId = "1"; final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT); 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 75c533d49..ae10258c0 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 @@ -51,7 +51,8 @@ class BaseAmqpServiceTest { /** * Verify that the message conversion works */ - @Test void convertMessageTest() { + @Test + void convertMessageTest() { final DmfActionUpdateStatus actionUpdateStatus = createActionStatus(); when(rabbitTemplate.getMessageConverter()).thenReturn(new Jackson2JsonMessageConverter()); @@ -63,7 +64,8 @@ class BaseAmqpServiceTest { /** * Tests invalid null message content */ - @Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) }) + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) }) void convertMessageWithNullContent() { assertThatExceptionOfType(IllegalArgumentException.class) .as("Expected IllegalArgumentException for invalid (null) JSON") @@ -73,7 +75,8 @@ class BaseAmqpServiceTest { /** * Tests invalid empty message content */ - @Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) }) + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) }) void updateActionStatusWithEmptyContent() { final Message message = createMessage("".getBytes()); assertThatExceptionOfType(MessageConversionException.class) @@ -84,7 +87,8 @@ class BaseAmqpServiceTest { /** * Tests invalid json message content */ - @Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) }) + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) }) 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/RequestExceptionStrategyTest.java b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/RequestExceptionStrategyTest.java index 2fe131f8f..bfa729a0f 100644 --- a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/RequestExceptionStrategyTest.java +++ b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/RequestExceptionStrategyTest.java @@ -30,7 +30,8 @@ class RequestExceptionStrategyTest { /** * Verifies that default handler is used if no handlers are defined for the specific exception. */ - @Test void verifyDefaultFatal() { + @Test + void verifyDefaultFatal() { assertThat(requeueExceptionStrategy.isFatal(new MessageConversionException("t"))).as("Non Fatal error").isTrue(); assertThat(requeueExceptionStrategy.isFatal(new Throwable(new MessageConversionException("t")))).as("Non Fatal error").isTrue(); } @@ -38,7 +39,8 @@ class RequestExceptionStrategyTest { /** * Verifies additional fatal exception types are fatal. */ - @Test void verifyAdditionalFatal() { + @Test + void verifyAdditionalFatal() { assertThat(requeueExceptionStrategy.isFatal(new IllegalArgumentException())).isTrue(); assertThat(requeueExceptionStrategy.isFatal(new IndexOutOfBoundsException())).isTrue(); } @@ -46,7 +48,8 @@ class RequestExceptionStrategyTest { /** * Verifies additional fatal exception types are fatal. */ - @Test void verifyAdditionalWrappedFatal() { + @Test + void verifyAdditionalWrappedFatal() { assertThat(requeueExceptionStrategy.isFatal(new Throwable(new IllegalArgumentException()))).isTrue(); assertThat(requeueExceptionStrategy.isFatal(new Throwable(new IndexOutOfBoundsException()))).isTrue(); } @@ -54,7 +57,8 @@ class RequestExceptionStrategyTest { /** * Verifies that default handler is used if no handlers are defined for the specific exception. */ - @Test void verifyNonFatal() { + @Test + void verifyNonFatal() { assertThat(requeueExceptionStrategy.isFatal(new NullPointerException())).isFalse(); assertThat(requeueExceptionStrategy.isFatal(new Throwable(new NullPointerException()))).isFalse(); } 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 394012a07..5f3936e43 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 @@ -91,7 +91,8 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt /** * Verify that a distribution assignment send a download and install message. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1), @@ -112,7 +113,8 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt /** * Verify that a distribution assignment sends a download message with window configured but before maintenance window start time. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1), @@ -138,7 +140,8 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt /** * Verify that a distribution assignment sends a download and install message with window configured and during maintenance window start time. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1), @@ -164,7 +167,8 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt /** * Verify that a distribution assignment multiple times send cancel and assign events with right softwaremodules */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 2), @Expect(type = CancelTargetAssignmentEvent.class, count = 1), @@ -211,7 +215,8 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt /** * If multi assignment is enabled multi-action messages are sent. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = MultiActionAssignEvent.class, count = 2), @Expect(type = TargetAssignDistributionSetEvent.class, count = 0), @@ -244,7 +249,8 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt /** * Verify payload of multi action messages. */ - @Test void assertMultiActionMessagePayloads() { + @Test + void assertMultiActionMessagePayloads() { final int expectedWeightIfNotSet = 1000; final int weight1 = 600; final String controllerId = UUID.randomUUID().toString(); @@ -294,7 +300,8 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt /** * Handle cancelation process of an action in multi assignment mode. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 2), @Expect(type = TargetPollEvent.class, count = 1), @@ -334,7 +341,8 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt /** * Handle finishing an action in multi assignment mode. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = MultiActionAssignEvent.class, count = 2), @Expect(type = TargetAttributesRequestedEvent.class, count = 1), @@ -368,7 +376,8 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt /** * If multi assignment is enabled assigning a DS multiple times creates a new action every time. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = MultiActionAssignEvent.class, count = 2), @Expect(type = TargetAssignDistributionSetEvent.class, count = 0), @@ -401,7 +410,8 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt /** * If multi assignment is enabled multiple rollouts with the same DS lead to multiple actions. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = MultiActionAssignEvent.class, count = 2), @Expect(type = TargetAssignDistributionSetEvent.class, count = 0), @@ -440,7 +450,8 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt /** * If multi assignment is enabled finishing one rollout does not affect other rollouts of the target. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = MultiActionAssignEvent.class, count = 3), @Expect(type = ActionCreatedEvent.class, count = 3), @@ -492,7 +503,8 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt /** * Verify that a cancel assignment send a cancel message. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = CancelTargetAssignmentEvent.class, count = 1), @@ -517,7 +529,8 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt /** * Verify that when a target is deleted a target delete message is send. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1), @Expect(type = TargetDeletedEvent.class, count = 1) }) @@ -532,7 +545,8 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt /** * Verify that attribute update is requested after device successfully closed software update. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 2), @Expect(type = ActionUpdatedEvent.class, count = 2), @@ -562,7 +576,8 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt /** * Tests the download_only assignment: asserts correct dmf Message topic, and assigned DS */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1), @@ -597,14 +612,16 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt /** * Verify payload of batch assignment download and install message. */ - @Test void assertBatchAssignmentsDownloadAndInstall() { + @Test + void assertBatchAssignmentsDownloadAndInstall() { assertBatchAssignmentsMessagePayload(BATCH_DOWNLOAD_AND_INSTALL); } /** * Verify payload of batch assignments download only message. */ - @Test void assertBatchAssignmentsDownloadOnly() { + @Test + void assertBatchAssignmentsDownloadOnly() { assertBatchAssignmentsMessagePayload(BATCH_DOWNLOAD); } @@ -635,7 +652,8 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt /** * Verify that batch and multi-assignments can't be activated at the same time. */ - @Test void assertBatchAndMultiAssignmentsNotCompatible() { + @Test + void assertBatchAndMultiAssignmentsNotCompatible() { enableBatchAssignments(); assertThatExceptionOfType(TenantConfigurationValueChangeNotAllowedException.class) .isThrownBy(() -> enableMultiAssignments()); @@ -694,7 +712,8 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt /** * Verify that a distribution assignment send a confirm message. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1), diff --git a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpMessageHandlerServiceIntegrationTest.java b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpMessageHandlerServiceIntegrationTest.java index e2fb76931..7b66b4a95 100644 --- a/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpMessageHandlerServiceIntegrationTest.java +++ b/hawkbit-dmf/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/integration/AmqpMessageHandlerServiceIntegrationTest.java @@ -94,7 +94,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr /** * Tests DMF PING request and expected response. */ - @Test void pingDmfInterface() { + @Test + void pingDmfInterface() { final Message pingMessage = createPingMessage(CORRELATION_ID, TENANT_EXIST); getDmfClient().send(pingMessage); @@ -106,7 +107,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr /** * Tests register target */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 2), @Expect(type = TargetPollEvent.class, count = 3) }) void registerTargets() { @@ -123,7 +125,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr /** * Tests register target with name */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 2) }) @@ -142,7 +145,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr /** * Tests register target with attributes */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 2), @Expect(type = TargetPollEvent.class, count = 2) }) @@ -164,7 +168,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr /** * Tests register target with name and attributes */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 3), @Expect(type = TargetPollEvent.class, count = 2) }) @@ -201,7 +206,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr /** * Tests register invalid target with too long controller id */ - @Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) }) + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) }) void registerInvalidTargetWithTooLongControllerId() { createAndSendThingCreated(randomString(Target.CONTROLLER_ID_MAX_SIZE + 1)); assertAllTargetsCount(0); @@ -211,7 +217,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr /** * Tests null reply to property in message header. This message should forwarded to the deadletter queue */ - @Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) }) + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) }) void missingReplyToProperty() { final String controllerId = TARGET_PREFIX + "missingReplyToProperty"; final Message createTargetMessage = createTargetMessage(controllerId, TENANT_EXIST); @@ -225,7 +232,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr /** * Tests missing reply to property in message header. This message should forwarded to the deadletter queue */ - @Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) }) + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) }) void emptyReplyToProperty() { final String controllerId = TARGET_PREFIX + "emptyReplyToProperty"; final Message createTargetMessage = createTargetMessage(controllerId, TENANT_EXIST); @@ -239,7 +247,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr /** * Tests missing thing id property in message. This message should forwarded to the deadletter queue */ - @Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) }) + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) }) void missingThingIdProperty() { final Message createTargetMessage = createTargetMessage(null, TENANT_EXIST); createTargetMessage.getMessageProperties().getHeaders().remove(MessageHeaderKey.THING_ID); @@ -252,7 +261,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr /** * Tests null thing id property in message. This message should forwarded to the deadletter queue */ - @Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) }) + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) }) void nullThingIdProperty() { final Message createTargetMessage = createTargetMessage(null, TENANT_EXIST); getDmfClient().send(createTargetMessage); @@ -264,7 +274,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr /** * Tests missing tenant message header. This message should forwarded to the deadletter queue */ - @Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) }) + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) }) void missingTenantHeader() { final String controllerId = TARGET_PREFIX + "missingTenantHeader"; final Message createTargetMessage = createTargetMessage(controllerId, TENANT_EXIST); @@ -278,7 +289,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr /** * Tests null tenant message header. This message should forwarded to the deadletter queue */ - @Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) }) + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) }) void nullTenantHeader() { final String controllerId = TARGET_PREFIX + "nullTenantHeader"; final Message createTargetMessage = createTargetMessage(controllerId, null); @@ -291,7 +303,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr /** * Tests empty tenant message header. This message should forwarded to the deadletter queue */ - @Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) }) + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) }) void emptyTenantHeader() { final String controllerId = TARGET_PREFIX + "emptyTenantHeader"; final Message createTargetMessage = createTargetMessage(controllerId, ""); @@ -304,7 +317,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr /** * Tests missing type message header. This message should forwarded to the deadletter queue */ - @Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) }) + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) }) void missingTypeHeader() { final Message createTargetMessage = createTargetMessage(null, TENANT_EXIST); createTargetMessage.getMessageProperties().getHeaders().remove(MessageHeaderKey.TYPE); @@ -348,7 +362,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr /** * Tests missing topic message header. This message should forwarded to the deadletter queue */ - @Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) }) + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) }) void missingTopicHeader() { final Message eventMessage = createUpdateActionEventMessage(""); eventMessage.getMessageProperties().getHeaders().remove(MessageHeaderKey.TOPIC); @@ -373,7 +388,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr /** * Tests invalid topic message header. This message should forwarded to the deadletter queue */ - @Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) }) + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) }) void updateActionStatusWithInvalidActionId() { final DmfActionUpdateStatus actionUpdateStatus = new DmfActionUpdateStatus(1L, DmfActionStatus.RUNNING); final Message eventMessage = createUpdateActionEventMessage(actionUpdateStatus); @@ -384,7 +400,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr /** * Tests register target and send finished message */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = ActionUpdatedEvent.class, count = 1), @@ -404,7 +421,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr /** * Register a target and send a update action status (running). Verify if the updated action status is correct. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = ActionUpdatedEvent.class), @@ -423,7 +441,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr /** * Register a target and send an update action status (downloaded). Verify if the updated action status is correct. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = ActionUpdatedEvent.class), @@ -442,7 +461,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr /** * Register a target and send a update action status (download). Verify if the updated action status is correct. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1), @@ -460,7 +480,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr /** * Register a target and send a update action status (error). Verify if the updated action status is correct. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = ActionUpdatedEvent.class, count = 1), @@ -479,7 +500,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr /** * Register a target and send a update action status (warning). Verify if the updated action status is correct. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1), @@ -497,7 +519,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr /** * Register a target and send a update action status (retrieved). Verify if the updated action status is correct. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1), @@ -515,7 +538,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr /** * Register a target and send a invalid update action status (cancel). This message should forwarded to the deadletter queue */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1), @@ -534,7 +558,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr /** * Verify receiving a download and install message if a deployment is done before the target has polled the first time. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1), @@ -564,7 +589,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr /** * Verify receiving a download message if a deployment is done with window configured but before maintenance window start time. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1), @@ -595,7 +621,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr /** * Verify receiving a download_and_install message if a deployment is done with window configured and during maintenance window start time. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1), @@ -626,7 +653,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr /** * Verify receiving a cancel update message if a deployment is canceled before the target has polled the first time. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1), @@ -659,7 +687,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr /** * Register a target and send a invalid update action status (canceled). The current status (pending) is not a canceling state. This message should forwarded to the deadletter queue */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = ActionUpdatedEvent.class, count = 1), @@ -684,7 +713,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr /** * Register a target and send a invalid update action status (cancel_rejected). This message should forwarded to the deadletter queue */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1), @@ -703,7 +733,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr /** * Register a target and send a valid update action status (cancel_rejected). Verify if the updated action status is correct. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = CancelTargetAssignmentEvent.class, count = 1), @@ -732,7 +763,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr /** * Verify that sending an update controller attribute message to an existing target works. Verify that different update modes (merge, replace, remove) can be used. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 4), @Expect(type = TargetPollEvent.class, count = 1) }) @@ -759,7 +791,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr /** * Verify that sending an update controller attribute message with no thingid header to an existing target does not work. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class), @Expect(type = TargetPollEvent.class, count = 1) }) @@ -786,7 +819,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr /** * Verify that sending an update controller attribute message with invalid body to an existing target does not work. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class), @Expect(type = TargetPollEvent.class, count = 1) }) @@ -805,7 +839,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr /** * Verifies that sending an UPDATE_ATTRIBUTES message with invalid attributes is handled correctly. */ - @Test void updateAttributesWithInvalidValues() { + @Test + void updateAttributesWithInvalidValues() { registerAndAssertTargetWithExistingTenant(UPDATE_ATTR_TEST_CONTROLLER_ID); sendUpdateAttributesMessageWithGivenAttributes(TargetTestData.ATTRIBUTE_KEY_TOO_LONG, TargetTestData.ATTRIBUTE_VALUE_VALID); @@ -818,7 +853,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr /** * Tests the download_only assignment: tests the handling of a target reporting DOWNLOADED */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = ActionUpdatedEvent.class, count = 1), @@ -853,7 +889,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr /** * Tests the download_only assignment: tests the handling of a target reporting FINISHED */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = ActionUpdatedEvent.class, count = 2), @@ -896,7 +933,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr /** * Messages that result into certain exceptions being raised should not be requeued. This message should forwarded to the deadletter queue */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) }) void ignoredExceptionTypesShouldNotBeRequeued() { final ControllerManagement mockedControllerManagement = Mockito.mock(ControllerManagement.class); @@ -922,7 +960,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr /** * Register a target and send a update action status (confirmed). Verify if the updated action status is correct. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = ActionUpdatedEvent.class, count = 1), @@ -951,7 +990,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr /** * Verify the DMF confirmed feedback can be provided if confirmation flow is disabled */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = ActionUpdatedEvent.class, count = 1), @@ -986,7 +1026,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr /** * Verify the DMF confirmed feedback can be provided if confirmation flow is disabled */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = ActionUpdatedEvent.class, count = 0), @@ -1017,7 +1058,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr /** * Verify the DMF download and install message is send directly if auto-confirmation is active */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 2), @Expect(type = TargetPollEvent.class, count = 1), @@ -1052,7 +1094,8 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr /** * Register a target and send a update action status (denied). Verify if the updated action status is correct. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = ActionUpdatedEvent.class), diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/test/java/org/eclipse/hawkbit/mgmt/json/model/PagedListTest.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/test/java/org/eclipse/hawkbit/mgmt/json/model/PagedListTest.java index d250668bb..29947fd6a 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/test/java/org/eclipse/hawkbit/mgmt/json/model/PagedListTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/test/java/org/eclipse/hawkbit/mgmt/json/model/PagedListTest.java @@ -26,7 +26,8 @@ class PagedListTest { /** * Ensures that a null payload entity throws an exception. */ - @Test void createListWithNullContentThrowsException() { + @Test + void createListWithNullContentThrowsException() { assertThatThrownBy(() -> new PagedList<>(null, 0)) .isInstanceOf(NullPointerException.class); } @@ -34,7 +35,8 @@ class PagedListTest { /** * Create list with payload and verify content. */ - @Test void createListWithContent() { + @Test + void createListWithContent() { final long knownTotal = 2; final List knownContentList = new ArrayList<>(); knownContentList.add("content1"); @@ -46,7 +48,8 @@ class PagedListTest { /** * Create list with payload and verify size values. */ - @Test void createListWithSmallerTotalThanContentSizeIsOk() { + @Test + void createListWithSmallerTotalThanContentSizeIsOk() { final long knownTotal = 0; final List knownContentList = new ArrayList<>(); knownContentList.add("content1"); diff --git a/hawkbit-mgmt/hawkbit-mgmt-api/src/test/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtTargetAssignmentResponseBodyTest.java b/hawkbit-mgmt/hawkbit-mgmt-api/src/test/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtTargetAssignmentResponseBodyTest.java index fdb767421..0b42af64a 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-api/src/test/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtTargetAssignmentResponseBodyTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-api/src/test/java/org/eclipse/hawkbit/mgmt/json/model/distributionset/MgmtTargetAssignmentResponseBodyTest.java @@ -33,7 +33,8 @@ class MgmtTargetAssignmentResponseBodyTest { /** * Tests that the ActionIds are serialized correctly in MgmtTargetAssignmentResponseBody */ - @Test void testActionIdsSerialization() throws IOException { + @Test + void testActionIdsSerialization() throws IOException { final MgmtTargetAssignmentResponseBody responseBody = generateResponseBody(); final ObjectMapper objectMapper = new ObjectMapper(); final String responseBodyAsString = objectMapper.writeValueAsString(responseBody); diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtActionResourceTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtActionResourceTest.java index 6390cf18d..35734b8d7 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtActionResourceTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtActionResourceTest.java @@ -64,21 +64,24 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { /** * Handles the GET request of retrieving a specific action. */ - @Test public void getAction() throws Exception { + @Test + void getAction() throws Exception { getAction(false); } /** * Handles the GET request of retrieving a specific action with external reference. */ - @Test public void getActionExtRef() throws Exception { + @Test + void getActionExtRef() throws Exception { getAction(true); } /** * Verifies that actions can be filtered based on action status. */ - @Test void filterActionsByStatus() throws Exception { + @Test + void filterActionsByStatus() throws Exception { // prepare test final DistributionSet dsA = testdataFactory.createDistributionSet(""); @@ -116,7 +119,8 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { /** * Verifies that actions can be filtered based on the detailed action status. */ - @Test void filterActionsByDetailStatus() throws Exception { + @Test + void filterActionsByDetailStatus() throws Exception { // prepare test final DistributionSet dsA = testdataFactory.createDistributionSet(""); assignDistributionSet(dsA, Collections.singletonList(testdataFactory.createTarget("knownTargetId"))); @@ -154,7 +158,8 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { /** * Verifies that actions can be filtered based on extRef. */ - @Test void filterActionsByExternalRef() throws Exception { + @Test + void filterActionsByExternalRef() throws Exception { // prepare test final String knownTargetId = "targetId"; final List actions = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId); @@ -198,7 +203,8 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { /** * Verifies that actions can be filtered based on the action status code that was reported last. */ - @Test void filterActionsByLastStatusCode() throws Exception { + @Test + void filterActionsByLastStatusCode() throws Exception { // assign a distribution set to three targets final DistributionSet dsA = testdataFactory.createDistributionSet(""); final DistributionSetAssignmentResult assignmentResult = assignDistributionSet(dsA, @@ -234,7 +240,8 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { /** * Verifies that actions can be filtered based on distribution set fields. */ - @Test void filterActionsByDistributionSet() throws Exception { + @Test + void filterActionsByDistributionSet() throws Exception { // prepare test final DistributionSet ds = testdataFactory.createDistributionSet(""); assignDistributionSet(ds, Collections.singletonList(testdataFactory.createTarget("knownTargetId"))); @@ -280,7 +287,8 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { /** * Verifies that actions can be filtered based on rollout fields. */ - @Test void filterActionsByRollout() throws Exception { + @Test + void filterActionsByRollout() throws Exception { // prepare test final DistributionSet ds = testdataFactory.createDistributionSet(); final Target target0 = testdataFactory.createTarget("t0"); @@ -322,7 +330,8 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { /** * Verifies that actions can be filtered based on target fields. */ - @Test void filterActionsByTargetProperties() throws Exception { + @Test + void filterActionsByTargetProperties() throws Exception { // prepare test final Target target = testdataFactory.createTarget("knownTargetId", "knownTargetName", "http://0.0.0.0"); final DistributionSet ds = testdataFactory.createDistributionSet(""); @@ -337,21 +346,24 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { /** * Verifies that all available actions are returned if the complete collection is requested. */ - @Test void getActions() throws Exception { + @Test + void getActions() throws Exception { getActions(false); } /** * Verifies that all available actions (whit ext refs) are returned if the complete collection is requested. */ - @Test void getActionsExtRef() throws Exception { + @Test + void getActionsExtRef() throws Exception { getActions(true); } /** * Verifies that a full representation of all actions is returned if the collection is requested for representation mode 'full'. */ - @Test void getActionsFullRepresentation() throws Exception { + @Test + void getActionsFullRepresentation() throws Exception { final String knownTargetId = "targetId"; final List actions = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId); @@ -394,7 +406,8 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { /** * Verifies that the get request for actions returns an empty collection if no assignments have been done yet. */ - @Test void getActionsWithEmptyResult() throws Exception { + @Test + void getActionsWithEmptyResult() throws Exception { mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) @@ -406,7 +419,8 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { /** * Verifies paging is respected as expected. */ - @Test void getMultipleActionsWithPagingLimitRequestParameter() throws Exception { + @Test + void getMultipleActionsWithPagingLimitRequestParameter() throws Exception { final String knownTargetId = "targetId"; final List actions = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId); @@ -458,7 +472,8 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { /** * Verifies that the actions resource is read-only. */ - @Test void invalidRequestsOnActionResource() throws Exception { + @Test + void invalidRequestsOnActionResource() throws Exception { final String knownTargetId = "targetId"; generateTargetWithTwoUpdatesWithOneOverride(knownTargetId); @@ -478,7 +493,8 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { /** * Verifies that the correct action is returned */ - @Test void shouldRetrieveCorrectActionById() throws Exception { + @Test + void shouldRetrieveCorrectActionById() throws Exception { final String knownTargetId = "targetId"; final List actions = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId); @@ -493,7 +509,8 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { /** * Verifies that NOT_FOUND is returned when there is no such action. */ - @Test void requestActionThatDoesNotExistsLeadsToNotFound() throws Exception { + @Test + void requestActionThatDoesNotExistsLeadsToNotFound() throws Exception { mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "/" + 101)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNotFound()); diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtBasicAuthResourceTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtBasicAuthResourceTest.java index 05d0568b2..ec6ccaa2d 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtBasicAuthResourceTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtBasicAuthResourceTest.java @@ -87,7 +87,8 @@ class MgmtBasicAuthResourceTest { /** * Test of userinfo api with basic auth validation */ - @Test @WithUser(principal = TEST_USER, authorities = {"READ", "WRITE", "DELETE"}) + @Test + @WithUser(principal = TEST_USER, authorities = {"READ", "WRITE", "DELETE"}) void validateBasicAuthWithUserDetails() throws Exception { withSecurityMock().perform(get(MgmtRestConstants.AUTH_V1_REQUEST_MAPPING)) .andDo(MockMvcResultPrinter.print()) @@ -103,7 +104,8 @@ class MgmtBasicAuthResourceTest { /** * Test of userinfo api with invalid basic auth fails */ - @Test void validateBasicAuthFailsWithInvalidCredentials() throws Exception { + @Test + void validateBasicAuthFailsWithInvalidCredentials() throws Exception { defaultMock.perform(get(MgmtRestConstants.AUTH_V1_REQUEST_MAPPING) .header(HttpHeaders.AUTHORIZATION, getBasicAuth("wrongUser", "wrongSecret"))) .andDo(MockMvcResultPrinter.print()) diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtContentTypeTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtContentTypeTest.java index 7a1d9ecf6..acdf76214 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtContentTypeTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtContentTypeTest.java @@ -56,7 +56,8 @@ public class MgmtContentTypeTest extends AbstractManagementApiIntegrationTest { /** * The response of a POST request shall contain charset=utf-8 */ - @Test public void postDistributionSet_ContentTypeJsonUtf8_woAccept() throws Exception { + @Test + void postDistributionSet_ContentTypeJsonUtf8_woAccept() throws Exception { final MvcResult result = mvc.perform( post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING).content(JsonBuilder.distributionSets( Collections.singletonList(ds))) @@ -72,7 +73,8 @@ public class MgmtContentTypeTest extends AbstractManagementApiIntegrationTest { /** * The response of a POST request shall contain charset=utf-8 */ - @Test public void postDistributionSet_ContentTypeJsonUtf8_wAcceptJson() throws Exception { + @Test + void postDistributionSet_ContentTypeJsonUtf8_wAcceptJson() throws Exception { final MvcResult result = mvc.perform( post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING).content(JsonBuilder.distributionSets( Collections.singletonList(ds))) @@ -88,7 +90,8 @@ public class MgmtContentTypeTest extends AbstractManagementApiIntegrationTest { /** * The response of a POST request shall contain charset=utf-8 */ - @Test public void postDistributionSet_ContentTypeJsonUtf8_wAcceptJsonUtf8() throws Exception { + @Test + void postDistributionSet_ContentTypeJsonUtf8_wAcceptJsonUtf8() throws Exception { final MvcResult result = mvc.perform( post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING).content(JsonBuilder.distributionSets( Collections.singletonList(ds))) @@ -104,7 +107,8 @@ public class MgmtContentTypeTest extends AbstractManagementApiIntegrationTest { /** * The response of a POST request shall contain charset=utf-8 */ - @Test public void postDistributionSet_ContentTypeJsonUtf8_wAcceptHalJson() throws Exception { + @Test + void postDistributionSet_ContentTypeJsonUtf8_wAcceptHalJson() throws Exception { final MvcResult result = mvc.perform( post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING).content(JsonBuilder.distributionSets( Collections.singletonList(ds))) @@ -120,7 +124,8 @@ public class MgmtContentTypeTest extends AbstractManagementApiIntegrationTest { /** * The response of a POST request shall contain charset=utf-8 */ - @Test public void postDistributionSet_ContentTypeJson_woAccept() throws Exception { + @Test + void postDistributionSet_ContentTypeJson_woAccept() throws Exception { final MvcResult result = mvc.perform( post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING).content(JsonBuilder.distributionSets( Collections.singletonList(ds))) @@ -136,7 +141,8 @@ public class MgmtContentTypeTest extends AbstractManagementApiIntegrationTest { /** * The response of a POST request shall contain charset=utf-8 */ - @Test public void postDistributionSet_ContentTypeJson_wAcceptJson() throws Exception { + @Test + void postDistributionSet_ContentTypeJson_wAcceptJson() throws Exception { final MvcResult result = mvc.perform( post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING).content(JsonBuilder.distributionSets( Collections.singletonList(ds))) @@ -152,7 +158,8 @@ public class MgmtContentTypeTest extends AbstractManagementApiIntegrationTest { /** * The response of a POST request shall contain charset=utf-8 */ - @Test public void postDistributionSet_ContentTypeJson_wAcceptJsonUtf8() throws Exception { + @Test + void postDistributionSet_ContentTypeJson_wAcceptJsonUtf8() throws Exception { final MvcResult result = mvc.perform(post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING) .content(JsonBuilder.distributionSets(Collections.singletonList(ds))).contentType(MediaType.APPLICATION_JSON) .accept(MediaType.APPLICATION_JSON_UTF8)) @@ -167,7 +174,8 @@ public class MgmtContentTypeTest extends AbstractManagementApiIntegrationTest { /** * The response of a POST request shall contain charset=utf-8 */ - @Test public void postDistributionSet_ContentTypeJson_wAcceptHalJson() throws Exception { + @Test + void postDistributionSet_ContentTypeJson_wAcceptHalJson() throws Exception { final MvcResult result = mvc.perform(post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING) .content(JsonBuilder.distributionSets(Collections.singletonList(ds))).contentType(MediaType.APPLICATION_JSON) .accept(MediaTypes.HAL_JSON)) @@ -182,7 +190,8 @@ public class MgmtContentTypeTest extends AbstractManagementApiIntegrationTest { /** * The response of a GET request shall contain charset=utf-8 */ - @Test public void getDistributionSet_woAccept() throws Exception { + @Test + void getDistributionSet_woAccept() throws Exception { final MvcResult result = mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) @@ -194,7 +203,8 @@ public class MgmtContentTypeTest extends AbstractManagementApiIntegrationTest { /** * The response of a GET request shall contain charset=utf-8 */ - @Test public void getDistributionSet_wAcceptJson() throws Exception { + @Test + void getDistributionSet_wAcceptJson() throws Exception { final MvcResult result = mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) @@ -206,7 +216,8 @@ public class MgmtContentTypeTest extends AbstractManagementApiIntegrationTest { /** * The response of a GET request shall contain charset=utf-8 */ - @Test public void getDistributionSet_wAcceptJsonUtf8() throws Exception { + @Test + void getDistributionSet_wAcceptJsonUtf8() throws Exception { final MvcResult result = mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING).accept(MediaType.APPLICATION_JSON_UTF8)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) @@ -218,7 +229,8 @@ public class MgmtContentTypeTest extends AbstractManagementApiIntegrationTest { /** * The response of a GET request shall contain charset=utf-8 */ - @Test public void getDistributionSet_wAcceptHalJson() throws Exception { + @Test + void getDistributionSet_wAcceptHalJson() throws Exception { final MvcResult result = mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING).accept(MediaTypes.HAL_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResourceTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResourceTest.java index ea724d1db..c5c8bfaaa 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResourceTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResourceTest.java @@ -87,7 +87,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * This test verifies the call of all Software Modules that are assigned to a Distribution Set through the RESTful API. */ - @Test void getSoftwareModules() throws Exception { + @Test + void getSoftwareModules() throws Exception { // Create DistributionSet with three software modules final DistributionSet set = testdataFactory.createDistributionSet("SMTest"); mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + set.getId() + "/assignedSM")) @@ -99,7 +100,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * Handles the GET request of retrieving assigned software modules of a single distribution set within SP with given page size and offset including sorting by version descending and filter down to all sets which name starts with 'one'. */ - @Test void getSoftwareModulesWithParameters() throws Exception { + @Test + void getSoftwareModulesWithParameters() throws Exception { final DistributionSet set = testdataFactory.createUpdatedDistributionSet(); // post assignment @@ -114,7 +116,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * This test verifies the deletion of a assigned Software Module of a Distribution Set can not be achieved when that Distribution Set has been assigned or installed to a target. */ - @Test void deleteFailureWhenDistributionSetInUse() throws Exception { + @Test + void deleteFailureWhenDistributionSetInUse() throws Exception { // create DisSet final DistributionSet disSet = testdataFactory.createDistributionSetWithNoSoftwareModules("Eris", "560a"); final List smIDs = new ArrayList<>(); @@ -159,7 +162,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * This test verifies that the assignment of a Software Module to a Distribution Set can not be achieved when that Distribution Set has been assigned or installed to a target. */ - @Test void assignmentFailureWhenAssigningToUsedDistributionSet() throws Exception { + @Test + void assignmentFailureWhenAssigningToUsedDistributionSet() throws Exception { // create DisSet final DistributionSet disSet = testdataFactory.createDistributionSetWithNoSoftwareModules("Mars", "686,980"); final List smIDs = new ArrayList<>(); @@ -203,7 +207,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * This test verifies the assignment of Software Modules to a Distribution Set through the RESTful API. */ - @Test void assignSoftwareModuleToDistributionSet() throws Exception { + @Test + void assignSoftwareModuleToDistributionSet() throws Exception { // create DisSet final DistributionSet disSet = testdataFactory.createDistributionSetWithNoSoftwareModules("Jupiter", "398,88"); // Test if size is 0 @@ -275,7 +280,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * This test verifies the removal of Software Modules of a Distribution Set through the RESTful API. */ - @Test void unassignSoftwareModuleFromDistributionSet() throws Exception { + @Test + void unassignSoftwareModuleFromDistributionSet() throws Exception { // Create DistributionSet with three software modules final DistributionSet set = testdataFactory.createDistributionSet("Venus"); int amountOfSM = set.getModules().size(); @@ -299,7 +305,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * Ensures that multi target assignment through API is reflected by the repository. */ - @Test void assignMultipleTargetsToDistributionSet() throws Exception { + @Test + void assignMultipleTargetsToDistributionSet() throws Exception { final DistributionSet createdDs = testdataFactory.createDistributionSet(); // prepare targets @@ -323,7 +330,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * Ensures that targets can be assigned even if the specified controller IDs are in different case (e.g. 'TARGET1' instead of 'target1'. */ - @Test void assignTargetsToDistributionSetIgnoreCase() throws Exception { + @Test + void assignTargetsToDistributionSetIgnoreCase() throws Exception { final DistributionSet createdDs = testdataFactory.createDistributionSet(); // prepare targets @@ -347,7 +355,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * Trying to create a DS from already marked as deleted type - should get as response 400 Bad Request */ - @Test void createDsFromAlreadyMarkedAsDeletedType() throws Exception { + @Test + void createDsFromAlreadyMarkedAsDeletedType() throws Exception { final SoftwareModule softwareModule = testdataFactory.createSoftwareModule("exampleKey"); final DistributionSetType type = testdataFactory.findOrCreateDistributionSetType( "testKey", "testType", Collections.singletonList(softwareModule.getType()), @@ -388,7 +397,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * Ensures that multi target assignment is protected by our getMaxTargetDistributionSetAssignmentsPerManualAssignment quota. */ - @Test void assignMultipleTargetsToDistributionSetUntilQuotaIsExceeded() throws Exception { + @Test + void assignMultipleTargetsToDistributionSetUntilQuotaIsExceeded() throws Exception { final int maxActions = quotaManagement.getMaxTargetDistributionSetAssignmentsPerManualAssignment(); final List targets = testdataFactory.createTargets(maxActions + 1); final DistributionSet ds = testdataFactory.createDistributionSet(); @@ -412,7 +422,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * Ensures that the 'max actions per target' quota is enforced if the distribution set assignment of a target is changed permanently */ - @Test void changeDistributionSetAssignmentForTargetUntilQuotaIsExceeded() throws Exception { + @Test + void changeDistributionSetAssignmentForTargetUntilQuotaIsExceeded() throws Exception { // create one target final Target testTarget = testdataFactory.createTarget("trg1"); @@ -439,7 +450,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * Ensures that offline reported multi target assignment through API is reflected by the repository. */ - @Test void offlineAssignmentOfMultipleTargetsToDistributionSet() throws Exception { + @Test + void offlineAssignmentOfMultipleTargetsToDistributionSet() throws Exception { final DistributionSet createdDs = testdataFactory.createDistributionSet(); final List targets = testdataFactory.createTargets(5); final JSONArray list = new JSONArray(); @@ -470,7 +482,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * Assigns multiple targets to distribution set with only maintenance schedule. */ - @Test void assignMultipleTargetsToDistributionSetWithMaintenanceWindowStartOnly() throws Exception { + @Test + void assignMultipleTargetsToDistributionSetWithMaintenanceWindowStartOnly() throws Exception { // prepare distribution set final DistributionSet createdDs = testdataFactory.createDistributionSet(); // prepare targets @@ -488,7 +501,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * Assigns multiple targets to distribution set with only maintenance window duration. */ - @Test void assignMultipleTargetsToDistributionSetWithMaintenanceWindowEndOnly() throws Exception { + @Test + void assignMultipleTargetsToDistributionSetWithMaintenanceWindowEndOnly() throws Exception { // prepare distribution set final DistributionSet createdDs = testdataFactory.createDistributionSet(); // prepare targets @@ -506,7 +520,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * Assigns multiple targets to distribution set with valid maintenance window. */ - @Test void assignMultipleTargetsToDistributionSetWithValidMaintenanceWindow() throws Exception { + @Test + void assignMultipleTargetsToDistributionSetWithValidMaintenanceWindow() throws Exception { // prepare distribution set final DistributionSet createdDs = testdataFactory.createDistributionSet(); // prepare targets @@ -525,7 +540,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * Assigns multiple targets to distribution set with last maintenance window scheduled before current time. */ - @Test void assignMultipleTargetsToDistributionSetWithMaintenanceWindowEndTimeBeforeStartTime() throws Exception { + @Test + void assignMultipleTargetsToDistributionSetWithMaintenanceWindowEndTimeBeforeStartTime() throws Exception { // prepare distribution set final DistributionSet createdDs = testdataFactory.createDistributionSet(); // prepare targets @@ -544,7 +560,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * Assigns multiple targets to distribution set with and without maintenance window. */ - @Test void assignMultipleTargetsToDistributionSetWithAndWithoutMaintenanceWindow() throws Exception { + @Test + void assignMultipleTargetsToDistributionSetWithAndWithoutMaintenanceWindow() throws Exception { // prepare distribution set final DistributionSet createdDs = testdataFactory.createDistributionSet(); // prepare targets @@ -572,7 +589,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * Assigning distribution set to the list of targets with a non-existing one leads to successful assignment of valid targets, while not found targets are silently ignored. */ - @Test void assignNotExistingTargetToDistributionSet() throws Exception { + @Test + void assignNotExistingTargetToDistributionSet() throws Exception { final DistributionSet createdDs = testdataFactory.createDistributionSet(); final String[] knownTargetIds = new String[] { "1", "2", "3" }; @@ -593,7 +611,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * Ensures that assigned targets of DS are returned as reflected by the repository. */ - @Test void getAssignedTargetsOfDistributionSet() throws Exception { + @Test + void getAssignedTargetsOfDistributionSet() throws Exception { // prepare distribution set final String knownTargetId = "knownTargetId1"; final DistributionSet createdDs = testdataFactory.createDistributionSet(); @@ -609,7 +628,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * Handles the GET request for retrieving assigned targets of a single distribution set with a defined page size and offset, sorted by name in descending order and filtered down to all targets which controllerID starts with 'target'. */ - @Test void getAssignedTargetsOfDistributionSetWithParameters() throws Exception { + @Test + void getAssignedTargetsOfDistributionSetWithParameters() throws Exception { final DistributionSet set = testdataFactory.createUpdatedDistributionSet(); assignDistributionSet(set, testdataFactory.createTargets(5, "targetMisc", "Test targets for query")) @@ -627,7 +647,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * Ensures that assigned targets of DS are returned as persisted in the repository. */ - @Test void getAssignedTargetsOfDistributionSetIsEmpty() throws Exception { + @Test + void getAssignedTargetsOfDistributionSetIsEmpty() throws Exception { final DistributionSet createdDs = testdataFactory.createDistributionSet(); mvc.perform(get( MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/assignedTargets")) @@ -639,7 +660,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * Ensures that installed targets of DS are returned as persisted in the repository. */ - @Test void getInstalledTargetsOfDistributionSet() throws Exception { + @Test + void getInstalledTargetsOfDistributionSet() throws Exception { // prepare distribution set final String knownTargetId = "knownTargetId1"; final DistributionSet createdDs = testdataFactory.createDistributionSet(); @@ -663,7 +685,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * Handles the GET request for retrieving installed targets of a single distribution set with a defined page size and offset, sortet by name in descending order and filtered down to all targets which controllerID starts with 'target'. */ - @Test void getInstalledTargetsOfDistributionSetWithParameters() throws Exception { + @Test + void getInstalledTargetsOfDistributionSetWithParameters() throws Exception { final DistributionSet set = testdataFactory.createUpdatedDistributionSet(); final List targets = assignDistributionSet(set, @@ -682,7 +705,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * Ensures that target filters with auto assign DS are returned as persisted in the repository. */ - @Test void getAutoAssignTargetFiltersOfDistributionSet() throws Exception { + @Test + void getAutoAssignTargetFiltersOfDistributionSet() throws Exception { // prepare distribution set final String knownFilterName = "a"; final DistributionSet createdDs = testdataFactory.createDistributionSet(); @@ -704,7 +728,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * Handles the GET request for retrieving assigned target filter queries of a single distribution set with a defined page size and offset, sorted by name in descending order and filtered down to all targets with a name that ends with '1'. */ - @Test void ggetAutoAssignTargetFiltersOfDistributionSetWithParameters() throws Exception { + @Test + void ggetAutoAssignTargetFiltersOfDistributionSetWithParameters() throws Exception { final DistributionSet set = testdataFactory.createUpdatedDistributionSet(); targetFilterQueryManagement.create(entityFactory.targetFilterQuery().create().name("filter1").query("name==a") .autoAssignDistributionSet(set)); @@ -721,7 +746,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * Ensures that an error is returned when the query is invalid. */ - @Test void getAutoAssignTargetFiltersOfDSWithInvalidFilter() throws Exception { + @Test + void getAutoAssignTargetFiltersOfDSWithInvalidFilter() throws Exception { // prepare distribution set final DistributionSet createdDs = testdataFactory.createDistributionSet(); final String invalidQuery = "unknownField=le=42"; @@ -734,7 +760,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * Ensures that target filters with auto assign DS are returned according to the query. */ - @Test void getMultipleAutoAssignTargetFiltersOfDistributionSet() throws Exception { + @Test + void getMultipleAutoAssignTargetFiltersOfDistributionSet() throws Exception { final String filterNamePrefix = "filter-"; final DistributionSet createdDs = testdataFactory.createDistributionSet(); final String query = "name==" + filterNamePrefix + "*"; @@ -752,7 +779,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * Ensures that no target filters are returned according to the non matching query. */ - @Test void getEmptyAutoAssignTargetFiltersOfDistributionSet() throws Exception { + @Test + void getEmptyAutoAssignTargetFiltersOfDistributionSet() throws Exception { final String filterNamePrefix = "filter-"; final DistributionSet createdDs = testdataFactory.createDistributionSet(); final String query = "name==doesNotExist"; @@ -768,7 +796,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * Ensures that DS in repository are listed with proper paging properties. */ - @Test void getDistributionSetsWithoutAdditionalRequestParameters() throws Exception { + @Test + void getDistributionSetsWithoutAdditionalRequestParameters() throws Exception { final int sets = 5; createDistributionSetsAlphabetical(sets); mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING)) @@ -782,7 +811,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * Ensures that DS in repository are listed with proper paging results with paging limit parameter. */ - @Test void getDistributionSetsWithPagingLimitRequestParameter() throws Exception { + @Test + void getDistributionSetsWithPagingLimitRequestParameter() throws Exception { final int sets = 5; final int limitSize = 1; createDistributionSetsAlphabetical(sets); @@ -798,7 +828,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * Ensures that DS in repository are listed with proper paging results with paging limit and offset parameter. */ - @Test void getDistributionSetsWithPagingLimitAndOffsetRequestParameter() throws Exception { + @Test + void getDistributionSetsWithPagingLimitAndOffsetRequestParameter() throws Exception { final int sets = 5; final int offsetParam = 2; final int expectedSize = sets - offsetParam; @@ -955,7 +986,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * Ensures that DS deletion request to API is reflected by the repository. */ - @Test void deleteUnassignedistributionSet() throws Exception { + @Test + void deleteUnassignedistributionSet() throws Exception { // prepare test data assertThat(distributionSetManagement.findByCompleted(true, PAGE)).isEmpty(); @@ -976,7 +1008,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * Ensures that DS deletion request to API on an entity that does not exist results in NOT_FOUND. */ - @Test void deleteDistributionSetThatDoesNotExistLeadsToNotFound() throws Exception { + @Test + void deleteDistributionSetThatDoesNotExistLeadsToNotFound() throws Exception { mvc.perform(delete("/rest/v1/distributionsets/1234")) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNotFound()); @@ -985,7 +1018,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * Ensures that assigned DS deletion request to API is reflected by the repository by means of deleted flag set. */ - @Test void deleteAssignedDistributionSet() throws Exception { + @Test + void deleteAssignedDistributionSet() throws Exception { // prepare test data assertThat(distributionSetManagement.findByCompleted(true, PAGE)).isEmpty(); @@ -1016,7 +1050,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * Ensures that DS property update request to API is reflected by the repository. */ - @Test void updateDistributionSet() throws Exception { + @Test + void updateDistributionSet() throws Exception { // prepare test data assertThat(distributionSetManagement.findByCompleted(true, PAGE)).isEmpty(); @@ -1046,7 +1081,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * Ensures that DS property update on requiredMigrationStep fails if DS is assigned to a target. */ - @Test void updateRequiredMigrationStepFailsIfDistributionSetisInUse() throws Exception { + @Test + void updateRequiredMigrationStepFailsIfDistributionSetisInUse() throws Exception { // prepare test data assertThat(distributionSetManagement.findByCompleted(true, PAGE)).isEmpty(); @@ -1072,7 +1108,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * Ensures that the server reacts properly to invalid requests (URI, Media Type, Methods) with correct reponses. */ - @Test void invalidRequestsOnDistributionSetsResource() throws Exception { + @Test + void invalidRequestsOnDistributionSetsResource() throws Exception { final DistributionSet set = testdataFactory.createDistributionSet("one"); final List sets = new ArrayList<>(); @@ -1134,7 +1171,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * Ensures that the metadata creation through API is reflected by the repository. */ - @Test void createMetadata() throws Exception { + @Test + void createMetadata() throws Exception { final DistributionSet testDS = testdataFactory.createDistributionSet("one"); final String knownKey1 = "known.key.1.1"; @@ -1177,7 +1215,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * Ensures that a metadata update through API is reflected by the repository. */ - @Test void updateMetadata() throws Exception { + @Test + void updateMetadata() throws Exception { // prepare and create metadata for update final String knownKey = "knownKey"; final String knownValue = "knownValue"; @@ -1199,7 +1238,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * Ensures that a metadata entry deletion through API is reflected by the repository. */ - @Test void deleteMetadata() throws Exception { + @Test + void deleteMetadata() throws Exception { // prepare and create metadata for deletion final String knownKey = "knownKey"; final String knownValue = "knownValue"; @@ -1222,7 +1262,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * Ensures that DS metadata deletion request to API on an entity that does not exist results in NOT_FOUND. */ - @Test void deleteMetadataThatDoesNotExistLeadsToNotFound() throws Exception { + @Test + void deleteMetadataThatDoesNotExistLeadsToNotFound() throws Exception { // prepare and create metadata for deletion final String knownKey = "knownKey"; final String knownValue = "knownValue"; @@ -1243,7 +1284,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * Ensures that a metadata entry selection through API reflects the repository content. */ - @Test void getMetadataKey() throws Exception { + @Test + void getMetadataKey() throws Exception { // prepare and create metadata final String knownKey = "knownKey"; final String knownValue = "knownValue"; @@ -1260,7 +1302,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * Get a paged list of meta data for a distribution set with standard page size. */ - @Test void getMetadata() throws Exception { + @Test + void getMetadata() throws Exception { final int totalMetadata = 4; final String knownKeyPrefix = "knownKey"; final String knownValuePrefix = "knownValue"; @@ -1278,7 +1321,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * Ensures that a DS search with query parameters returns the expected result. */ - @Test void searchDistributionSetRsql() throws Exception { + @Test + void searchDistributionSetRsql() throws Exception { final String dsSuffix = "test"; final int amount = 10; testdataFactory.createDistributionSets(dsSuffix, amount); @@ -1300,7 +1344,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * Ensures that a DS search with complete==true parameter returns only DS that are actually completely filled with mandatory modules. */ - @Test void filterDistributionSetComplete() throws Exception { + @Test + void filterDistributionSetComplete() throws Exception { final int amount = 10; testdataFactory.createDistributionSets(amount); distributionSetManagement @@ -1318,7 +1363,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * Ensures that a DS assigned target search with controllerId==1 parameter returns only the target with the given ID. */ - @Test void searchDistributionSetAssignedTargetsRsql() throws Exception { + @Test + void searchDistributionSetAssignedTargetsRsql() throws Exception { // prepare distribution set final Set createDistributionSetsAlphabetical = createDistributionSetsAlphabetical(1); final DistributionSet createdDs = createDistributionSetsAlphabetical.iterator().next(); @@ -1405,7 +1451,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * A request for assigning a target multiple times results in a Bad Request when multiassignment is disabled. */ - @Test void multiAssignmentRequestNotAllowedIfDisabled() throws Exception { + @Test + void multiAssignmentRequestNotAllowedIfDisabled() throws Exception { final String targetId = testdataFactory.createTarget().getControllerId(); final Long dsId = testdataFactory.createDistributionSet().getId(); @@ -1422,7 +1469,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * Identical assignments in a single request are removed when multiassignment is disabled. */ - @Test void identicalAssignmentInRequestAreRemovedIfMultiassignmentsDisabled() throws Exception { + @Test + void identicalAssignmentInRequestAreRemovedIfMultiassignmentsDisabled() throws Exception { final String targetId = testdataFactory.createTarget().getControllerId(); final Long dsId = testdataFactory.createDistributionSet().getId(); @@ -1440,7 +1488,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * Assigning targets multiple times to a DS in one request works in multiassignment mode. */ - @Test void multiAssignment() throws Exception { + @Test + void multiAssignment() throws Exception { final List targetIds = testdataFactory.createTargets(2).stream().map(Target::getControllerId) .toList(); final Long dsId = testdataFactory.createDistributionSet().getId(); @@ -1462,7 +1511,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * An assignment request containing a weight is only accepted when weight is valide and multi assignment is on. */ - @Test void weightValidation() throws Exception { + @Test + void weightValidation() throws Exception { final String targetId = testdataFactory.createTarget().getControllerId(); final Long dsId = testdataFactory.createDistributionSet().getId(); final int weight = 78; @@ -1494,7 +1544,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * Request to get the count of all Rollouts by status for specific Distribution set */ - @Test void statisticsForRolloutsCountByStatus() throws Exception { + @Test + void statisticsForRolloutsCountByStatus() throws Exception { testdataFactory.createTargets("targets", 4); DistributionSet ds1 = testdataFactory.createDistributionSet("DS1"); DistributionSet ds2 = testdataFactory.createDistributionSet("DS2"); @@ -1528,7 +1579,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * Request to get the count of all Actions by status for specific Distribution set */ - @Test void statisticsForActionsCountByStatus() throws Exception { + @Test + void statisticsForActionsCountByStatus() throws Exception { testdataFactory.createTargets("targets", 4); DistributionSet ds1 = testdataFactory.createDistributionSet("DS1"); @@ -1560,7 +1612,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * Request to get the count of all Auto Assignments for specific Distribution set */ - @Test void statisticsForAutoAssignmentsCount() throws Exception { + @Test + void statisticsForAutoAssignmentsCount() throws Exception { testdataFactory.createTargets("targets", 4); DistributionSet ds1 = testdataFactory.createDistributionSet("DS1"); DistributionSet ds2 = testdataFactory.createDistributionSet("DS2"); @@ -1593,7 +1646,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * Request to get full Statistics for specific Distribution set */ - @Test void statisticsForDistributionSet() throws Exception { + @Test + void statisticsForDistributionSet() throws Exception { testdataFactory.createTargets("targets", 4); testdataFactory.createTargets("autoAssignments", 4); DistributionSet ds1 = testdataFactory.createDistributionSet("DS1"); @@ -1630,7 +1684,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * Verify invalidation of distribution sets that removes distribution sets from auto assignments, stops rollouts and cancels assignments */ - @Test void invalidateDistributionSet() throws Exception { + @Test + void invalidateDistributionSet() throws Exception { final DistributionSet distributionSet = testdataFactory.createDistributionSet(); final List targets = testdataFactory.createTargets(5, "invalidateDistributionSet"); assignDistributionSet(distributionSet, targets); @@ -1665,7 +1720,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * Tests the lock. It is verified that the distribution set can be marked as locked through update operation. */ - @Test void lockDistributionSet() throws Exception { + @Test + void lockDistributionSet() throws Exception { // prepare test data assertThat(distributionSetManagement.findByCompleted(true, PAGE)).isEmpty(); @@ -1688,7 +1744,8 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe /** * Tests the unlock. */ - @Test void unlockDistributionSet() throws Exception { + @Test + void unlockDistributionSet() throws Exception { // prepare test data assertThat(distributionSetManagement.findByCompleted(true, PAGE)).isEmpty(); diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTagResourceTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTagResourceTest.java index f7bc2d55d..1ee2bce72 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTagResourceTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTagResourceTest.java @@ -60,7 +60,8 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio /** * Verifies that a paged result list of DS tags reflects the content on the repository side. */ - @Test @ExpectEvents({ @Expect(type = DistributionSetTagCreatedEvent.class, count = 2) }) + @Test + @ExpectEvents({ @Expect(type = DistributionSetTagCreatedEvent.class, count = 2) }) void getDistributionSetTags() throws Exception { final List tags = testdataFactory.createDistributionSetTags(2); final DistributionSetTag assigned = tags.get(0); @@ -82,7 +83,8 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio /** * Handles the GET request of retrieving all distribution set tags based by parameter */ - @Test void getDistributionSetTagsWithParameters() throws Exception { + @Test + void getDistributionSetTagsWithParameters() throws Exception { testdataFactory.createDistributionSetTags(2); mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "?limit=10&sort=name:ASC&offset=0&q=name==DsTag")) .andDo(MockMvcResultPrinter.print()) @@ -92,7 +94,8 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio /** * Verifies that a paged result list of DS tags reflects the content on the repository side when filtered by distribution set id. */ - @Test void getDistributionSetTagsByDistributionSetId() throws Exception { + @Test + void getDistributionSetTagsByDistributionSetId() throws Exception { final List tags = testdataFactory.createDistributionSetTags(2); final DistributionSetTag tag1 = tags.get(0); final DistributionSetTag tag2 = tags.get(1); @@ -132,7 +135,8 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio /** * Verifies that a paged result list of DS tags reflects the content on the repository side when filtered by distribution set id field AND tag field. */ - @Test void getDistributionSetTagsByDistributionSetIdAndTagDescription() throws Exception { + @Test + void getDistributionSetTagsByDistributionSetIdAndTagDescription() throws Exception { final List tags = testdataFactory.createDistributionSetTags(2); final DistributionSetTag tag1 = tags.get(0); final DistributionSetTag tag2 = tags.get(1); @@ -161,7 +165,8 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio /** * Verifies that a single result of a DS tag reflects the content on the repository side. */ - @Test @ExpectEvents({ @Expect(type = DistributionSetTagCreatedEvent.class, count = 2) }) + @Test + @ExpectEvents({ @Expect(type = DistributionSetTagCreatedEvent.class, count = 2) }) void getDistributionSetTag() throws Exception { final List tags = testdataFactory.createDistributionSetTags(2); final DistributionSetTag assigned = tags.get(0); @@ -180,7 +185,8 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio /** * Verifies that created DS tags are stored in the repository as send to the API. */ - @Test @ExpectEvents({ @Expect(type = DistributionSetTagCreatedEvent.class, count = 2) }) + @Test + @ExpectEvents({ @Expect(type = DistributionSetTagCreatedEvent.class, count = 2) }) void createDistributionSetTags() throws Exception { final Tag tagOne = entityFactory.tag().create().colour("testcol1").description("its a test1").name("thetest1") .build(); @@ -211,7 +217,8 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio /** * Verifies that an updated DS tag is stored in the repository as send to the API. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = DistributionSetTagCreatedEvent.class, count = 1), @Expect(type = DistributionSetTagUpdatedEvent.class, count = 1) }) void updateDistributionSetTag() throws Exception { @@ -241,7 +248,8 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio /** * Verifies that the delete call is reflected by the repository. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = DistributionSetTagCreatedEvent.class, count = 1), @Expect(type = DistributionSetTagDeletedEvent.class, count = 1) }) void deleteDistributionSetTag() throws Exception { @@ -258,7 +266,8 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio /** * Ensures that assigned DS to tag in repository are listed with proper paging results. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = DistributionSetTagCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 5), @Expect(type = DistributionSetUpdatedEvent.class, count = 5) }) @@ -279,7 +288,8 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio /** * Ensures that assigned DS to tag in repository are listed with proper paging results with paging limit parameter. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = DistributionSetTagCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 5), @Expect(type = DistributionSetUpdatedEvent.class, count = 5) }) @@ -302,7 +312,8 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio /** * Ensures that assigned DS to tag in repository are listed with proper paging results with paging limit and offset parameter. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = DistributionSetTagCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 5), @Expect(type = DistributionSetUpdatedEvent.class, count = 5) }) @@ -328,7 +339,8 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio /** * Verifies that tag assignments done through tag API command are correctly stored in the repository. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = DistributionSetTagCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetUpdatedEvent.class, count = 1) }) @@ -348,7 +360,8 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio /** * Verifies that tag assignments done through tag API command are correctly stored in the repository. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = DistributionSetTagCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 2), @Expect(type = DistributionSetUpdatedEvent.class, count = 2) }) @@ -370,7 +383,8 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio /** * Verifies that tag unassignments done through tag API command are correctly stored in the repository. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = DistributionSetTagCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 2), @Expect(type = DistributionSetUpdatedEvent.class, count = 3) }) @@ -396,7 +410,8 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio /** * Verifies that tag unassignments done through tag API command are correctly stored in the repository. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = DistributionSetTagCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 3), @Expect(type = DistributionSetUpdatedEvent.class, count = 5) }) @@ -423,7 +438,8 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio /** * Verifies that tag assignments (multi targets) done through tag API command are correctly stored in the repository. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = DistributionSetTagCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 2) }) void assignDistributionSetsNotFound() throws Exception { diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeResourceTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeResourceTest.java index 1dce4c056..09defe691 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeResourceTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetTypeResourceTest.java @@ -406,7 +406,8 @@ class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIntegrati /** * Handles the GET request of retrieving all distribution set types within SP based on parameter. */ - @Test void getDistributionSetTypesWithParameter() throws Exception { + @Test + void getDistributionSetTypesWithParameter() throws Exception { mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING + "?limit=10&sort=name:ASC&offset=0&q=name==a")) .andDo(MockMvcResultPrinter.print()) @@ -434,7 +435,8 @@ class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIntegrati /** * Ensures that DS type deletion request to API on an entity that does not exist results in NOT_FOUND. */ - @Test void deleteDistributionSetTypeThatDoesNotExistLeadsToNotFound() throws Exception { + @Test + void deleteDistributionSetTypeThatDoesNotExistLeadsToNotFound() throws Exception { mvc.perform(delete("/rest/v1/distributionsettypes/1234")) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNotFound()); @@ -476,7 +478,8 @@ class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIntegrati /** * Checks the correct behaviour of /rest/v1/distributionsettypes/{ID} PUT requests. */ - @Test void updateDistributionSetTypeColourDescriptionAndNameUntouched() throws Exception { + @Test + void updateDistributionSetTypeColourDescriptionAndNameUntouched() throws Exception { final DistributionSetType testType = distributionSetTypeManagement.create(entityFactory.distributionSetType() .create().key("test123").name("TestName123").description("Desc123").colour("col")); @@ -498,7 +501,8 @@ class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIntegrati /** * Handles the PUT request for a single distribution set type within SP. */ - @Test void updateDistributionSetTypeDescriptionAndColor() throws Exception { + @Test + void updateDistributionSetTypeDescriptionAndColor() throws Exception { final DistributionSetType testType = distributionSetTypeManagement.update(entityFactory.distributionSetType() .update(testdataFactory.createDistributionSet().getType().getId()).description("Desc1234")); final String body = new JSONObject() @@ -515,7 +519,8 @@ class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIntegrati /** * Tests the update of the deletion flag. It is verfied that the distribution set type can't be marked as deleted through update operation. */ - @Test void updateDistributionSetTypeDeletedFlag() throws Exception { + @Test + void updateDistributionSetTypeDeletedFlag() throws Exception { final DistributionSetType testType = distributionSetTypeManagement .create(entityFactory.distributionSetType().create().key("test123").name("TestName123").colour("col")); @@ -532,7 +537,8 @@ class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIntegrati /** * Checks the correct behaviour of /rest/v1/distributionsettypes GET requests with paging. */ - @Test void getDistributionSetTypesWithoutAddtionalRequestParameters() throws Exception { + @Test + void getDistributionSetTypesWithoutAddtionalRequestParameters() throws Exception { // 4 types overall (3 hawkbit tenant default, 1 test default final int types = 4; @@ -547,7 +553,8 @@ class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIntegrati /** * Checks the correct behaviour of /rest/v1/distributionsettypes GET requests with paging. */ - @Test void getDistributionSetTypesWithPagingLimitRequestParameter() throws Exception { + @Test + void getDistributionSetTypesWithPagingLimitRequestParameter() throws Exception { final int types = DEFAULT_DS_TYPES; final int limitSize = 1; @@ -563,7 +570,8 @@ class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIntegrati /** * Checks the correct behaviour of /rest/v1/distributionsettypes GET requests with paging. */ - @Test void getDistributionSetTypesWithPagingLimitAndOffsetRequestParameter() throws Exception { + @Test + void getDistributionSetTypesWithPagingLimitAndOffsetRequestParameter() throws Exception { final int types = DEFAULT_DS_TYPES; final int offsetParam = 2; final int expectedSize = types - offsetParam; @@ -580,7 +588,8 @@ class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIntegrati /** * Ensures that the server is behaving as expected on invalid requests (wrong media type, wrong ID etc.). */ - @Test void invalidRequestsOnDistributionSetTypesResource() throws Exception { + @Test + void invalidRequestsOnDistributionSetTypesResource() throws Exception { final SoftwareModuleType testSmType = softwareModuleTypeManagement .create(entityFactory.softwareModuleType().create().key("test123").name("TestName123")); @@ -694,7 +703,8 @@ class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIntegrati /** * Search erquest of software module types. */ - @Test void searchDistributionSetTypeRsql() throws Exception { + @Test + void searchDistributionSetTypeRsql() throws Exception { distributionSetTypeManagement .create(entityFactory.distributionSetType().create().key("test123").name("TestName123")); distributionSetTypeManagement diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutResourceTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutResourceTest.java index df5f8c0a8..1cb3da29a 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutResourceTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtRolloutResourceTest.java @@ -94,7 +94,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { /** * Handles the GET request of retrieving a single rollout. */ - @Test public void getRollout() throws Exception { + @Test + void getRollout() throws Exception { enableMultiAssignments(); approvalStrategy.setApprovalNeeded(true); try { @@ -130,7 +131,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { /** * Handles the GET request of retrieving a all targets of a specific deploy group of a rollout. */ - @Test public void getRolloutDeployGroupTargetsWithParameters() throws Exception { + @Test + void getRolloutDeployGroupTargetsWithParameters() throws Exception { testdataFactory.createTargets(4, "rollout", "description"); final DistributionSet dsA = testdataFactory.createDistributionSet(""); final Rollout rollout = createRollout("rollout1", 2, dsA.getId(), "controllerId==rollout*"); @@ -149,7 +151,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { /** * Handles the POST request of approving a rollout. */ - @Test public void approveRollout() throws Exception { + @Test + void approveRollout() throws Exception { approvalStrategy.setApprovalNeeded(true); try { testdataFactory.createTargets(4, "rollout", "description"); @@ -186,7 +189,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { /** * Check if approvalDecidedBy and approvalRemark are present when rollout is approved */ - @Test public void validateIfApprovalFieldsArePresentAfterApproval() throws Exception { + @Test + void validateIfApprovalFieldsArePresentAfterApproval() throws Exception { approvalStrategy.setApprovalNeeded(true); approvalStrategy.setApproveDecidedBy("testUser"); final int amountTargets = 2; @@ -218,7 +222,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { /** * Retry rollout test scenario */ - @Test public void retryRolloutTest() throws Exception { + @Test + void retryRolloutTest() throws Exception { final DistributionSet dsA = testdataFactory.createDistributionSet(""); final List successTargets = testdataFactory.createTargets("retryRolloutTargetSuccess-", 6); @@ -288,7 +293,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { /** * Retrying a running rollout should not be allowed. */ - @Test public void retryNotFinishedRolloutShouldNotBeAllowed() throws Exception { + @Test + void retryNotFinishedRolloutShouldNotBeAllowed() throws Exception { final DistributionSet dsA = testdataFactory.createDistributionSet(""); testdataFactory.createTargets("retryRolloutTarget-", 10); postRollout("rolloutToBeRetried", 1, dsA.getId(), "id==retryRolloutTarget*", 10, Action.ActionType.FORCED); @@ -307,7 +313,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { /** * Retrying a non-existing rollout should lead to NOT FOUND. */ - @Test public void retryNonExistingRolloutShouldLeadToNotFound() throws Exception { + @Test + void retryNonExistingRolloutShouldLeadToNotFound() throws Exception { mvc.perform(post("/rest/v1/rollouts/{rolloutId}/retry", 6782623)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNotFound()); @@ -316,7 +323,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { /** * Testing that creating rollout with wrong body returns bad request */ - @Test void createRolloutWithInvalidBodyReturnsBadRequest() throws Exception { + @Test + void createRolloutWithInvalidBodyReturnsBadRequest() throws Exception { mvc.perform(post("/rest/v1/rollouts").content("invalid body").contentType(MediaType.APPLICATION_JSON) .accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) @@ -327,7 +335,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { /** * Testing that creating rollout with insufficient permission returns forbidden */ - @Test @WithUser(allSpPermissions = true, removeFromAllPermission = "CREATE_ROLLOUT") + @Test + @WithUser(allSpPermissions = true, removeFromAllPermission = "CREATE_ROLLOUT") void createRolloutWithInsufficientPermissionReturnsForbidden() throws Exception { final DistributionSet dsA = testdataFactory.createDistributionSet(""); mvc.perform(post("/rest/v1/rollouts") @@ -341,7 +350,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { /** * Testing that creating rollout with not existing distribution set returns not found */ - @Test void createRolloutWithNotExistingDistributionSetReturnsNotFound() throws Exception { + @Test + void createRolloutWithNotExistingDistributionSetReturnsNotFound() throws Exception { mvc.perform(post("/rest/v1/rollouts").content(JsonBuilder.rollout("name", "desc", 10, 1234, "name==test", null)) .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) @@ -352,7 +362,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { /** * Testing that creating rollout with not valid formed target filter query returns bad request */ - @Test void createRolloutWithNotWellFormedFilterReturnsBadRequest() throws Exception { + @Test + void createRolloutWithNotWellFormedFilterReturnsBadRequest() throws Exception { final DistributionSet dsA = testdataFactory.createDistributionSet(""); mvc.perform(post("/rest/v1/rollouts") .content(JsonBuilder.rollout("name", "desc", 5, dsA.getId(), "name=test", null)) @@ -366,7 +377,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { /** * Ensures that the repository refuses to create rollout without a defined target filter set. */ - @Test void missingTargetFilterQueryInRollout() throws Exception { + @Test + void missingTargetFilterQueryInRollout() throws Exception { final String targetFilterQuery = null; @@ -384,7 +396,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { /** * Testing that rollout can be created */ - @Test void createRollout() throws Exception { + @Test + void createRollout() throws Exception { testdataFactory.createTargets(20, "target", "rollout"); final DistributionSet dsA = testdataFactory.createDistributionSet(""); @@ -394,7 +407,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { /** * Verifies that rollout cannot be created if too many rollout groups are specified. */ - @Test void createRolloutWithTooManyRolloutGroups() throws Exception { + @Test + void createRolloutWithTooManyRolloutGroups() throws Exception { final int maxGroups = quotaManagement.getMaxRolloutGroupsPerRollout(); testdataFactory.createTargets(20, "target", "rollout"); @@ -414,7 +428,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { /** * Verifies that rollout cannot be created if the 'max targets per rollout group' quota would be violated for one of the groups. */ - @Test void createRolloutFailsIfRolloutGroupQuotaIsViolated() throws Exception { + @Test + void createRolloutFailsIfRolloutGroupQuotaIsViolated() throws Exception { final int maxTargets = quotaManagement.getMaxTargetsPerRolloutGroup(); testdataFactory.createTargets(maxTargets + 1, "target", "rollout"); @@ -434,7 +449,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { /** * Testing that rollout can be created with groups */ - @Test void createRolloutWithGroupDefinitions() throws Exception { + @Test + void createRolloutWithGroupDefinitions() throws Exception { final DistributionSet dsA = testdataFactory.createDistributionSet("ro"); final int amountTargets = 10; @@ -464,7 +480,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { /** * Testing dynamic rollouts with default dynamic group definition */ - @Test void createDynamicRolloutWithDefaultDynamicGroupDefinition() throws Exception { + @Test + void createDynamicRolloutWithDefaultDynamicGroupDefinition() throws Exception { final DistributionSet dsA = testdataFactory.createDistributionSet("ro"); final int amountTargets = 10; @@ -548,7 +565,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { /** * Testing that no rollout with groups that have illegal percentages can be created */ - @Test void createRolloutWithTooLowPercentage() throws Exception { + @Test + void createRolloutWithTooLowPercentage() throws Exception { final DistributionSet dsA = testdataFactory.createDistributionSet("ro2"); final int amountTargets = 10; @@ -575,7 +593,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { /** * Testing that no rollout with groups that have illegal percentages can be created */ - @Test void createRolloutWithTooHighPercentage() throws Exception { + @Test + void createRolloutWithTooHighPercentage() throws Exception { final DistributionSet dsA = testdataFactory.createDistributionSet("ro2"); final int amountTargets = 10; @@ -602,7 +621,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { /** * Testing that rollout can be updated */ - @Test void updateRollout() throws Exception { + @Test + void updateRollout() throws Exception { testdataFactory.createTargets(4, "rollout", "description"); final DistributionSet dsA = testdataFactory.createDistributionSet(""); // create a running rollout for the created targets @@ -629,7 +649,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { /** * Testing the empty list is returned if no rollout exists */ - @Test void noRolloutReturnsEmptyList() throws Exception { + @Test + void noRolloutReturnsEmptyList() throws Exception { mvc.perform(get("/rest/v1/rollouts").accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) @@ -641,7 +662,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { /** * Retrieves single rollout from management API including extra data that is delivered only for single rollout access. */ - @Test void retrieveSingleRollout() throws Exception { + @Test + void retrieveSingleRollout() throws Exception { testdataFactory.createTargets(20, "rollout", "rollout"); final DistributionSet dsA = testdataFactory.createDistributionSet(""); @@ -661,7 +683,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { /** * Retrieves the list of rollouts with representation mode 'full'. */ - @Test void retrieveRolloutListFullRepresentation() throws Exception { + @Test + void retrieveRolloutListFullRepresentation() throws Exception { testdataFactory.createTargets(20, "rollout", "rollout"); final DistributionSet dsA = testdataFactory.createDistributionSet(""); @@ -704,7 +727,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { /** * Retrieves the list of rollouts with representation mode 'full'. */ - @Test void retrieveRolloutListFullRepresentationWithFilter() throws Exception { + @Test + void retrieveRolloutListFullRepresentationWithFilter() throws Exception { testdataFactory.createTargets(20, "rollout", "rollout"); final DistributionSet dsA = testdataFactory.createDistributionSet(""); @@ -804,7 +828,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { /** * Confirmation required flag will be read from the Rollout, if specified. */ - @Test void verifyRolloutGroupWillUseRolloutPropertyFirst() throws Exception { + @Test + void verifyRolloutGroupWillUseRolloutPropertyFirst() throws Exception { enableConfirmationFlow(); final DistributionSet dsA = testdataFactory.createDistributionSet("ro"); @@ -848,7 +873,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { /** * Confirmation required flag will be read from the tenant config (confirmation flow state), if never specified. */ - @Test void verifyRolloutGroupWillUseConfigIfNotProvidedWithRollout() throws Exception { + @Test + void verifyRolloutGroupWillUseConfigIfNotProvidedWithRollout() throws Exception { enableConfirmationFlow(); final DistributionSet dsA = testdataFactory.createDistributionSet("ro"); @@ -892,7 +918,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { /** * Testing that rollout paged list contains rollouts */ - @Test void rolloutPagedListContainsAllRollouts() throws Exception { + @Test + void rolloutPagedListContainsAllRollouts() throws Exception { final DistributionSet dsA = testdataFactory.createDistributionSet(""); testdataFactory.createTargets(20, "target", "rollout"); @@ -955,7 +982,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { /** * Testing representation mode of rollout paged list */ - @Test void rolloutPagedListRepresentationMode() throws Exception { + @Test + void rolloutPagedListRepresentationMode() throws Exception { final DistributionSet dsA = testdataFactory.createDistributionSet(""); testdataFactory.createTargets(20, "target", "rollout"); @@ -974,7 +1002,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { /** * Testing that rollout paged list is limited by the query param limit */ - @Test void rolloutPagedListIsLimitedToQueryParam() throws Exception { + @Test + void rolloutPagedListIsLimitedToQueryParam() throws Exception { final DistributionSet dsA = testdataFactory.createDistributionSet(""); testdataFactory.createTargets(20, "target", "rollout"); @@ -1043,7 +1072,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { /** * The relation between deploy group and rollout should be validated. */ - @Test void deployGroupsShouldValidateRelationWithRollout() throws Exception { + @Test + void deployGroupsShouldValidateRelationWithRollout() throws Exception { // setup final int amountTargets = 8; testdataFactory.createTargets(amountTargets, "rollout", "rollout"); @@ -1073,7 +1103,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { /** * Testing that starting the rollout switches the state to starting and then to running */ - @Test void startingRolloutSwitchesIntoRunningState() throws Exception { + @Test + void startingRolloutSwitchesIntoRunningState() throws Exception { // setup final int amountTargets = 20; testdataFactory.createTargets(amountTargets, "rollout", "rollout"); @@ -1110,7 +1141,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { /** * Testing that pausing the rollout switches the state to paused */ - @Test void pausingRolloutSwitchesIntoPausedState() throws Exception { + @Test + void pausingRolloutSwitchesIntoPausedState() throws Exception { // setup final int amountTargets = 20; testdataFactory.createTargets(amountTargets, "rollout", "rollout"); @@ -1144,7 +1176,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { /** * Testing that resuming the rollout switches the state to running */ - @Test void resumingRolloutSwitchesIntoRunningState() throws Exception { + @Test + void resumingRolloutSwitchesIntoRunningState() throws Exception { // setup final int amountTargets = 20; testdataFactory.createTargets(amountTargets, "rollout", "rollout"); @@ -1183,7 +1216,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { /** * Testing that an already started rollout cannot be started again and returns bad request */ - @Test void startingAlreadyStartedRolloutReturnsBadRequest() throws Exception { + @Test + void startingAlreadyStartedRolloutReturnsBadRequest() throws Exception { // setup final int amountTargets = 20; testdataFactory.createTargets(amountTargets, "rollout", "rollout"); @@ -1210,7 +1244,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { /** * Testing that resuming a rollout which is not started leads to bad request */ - @Test void resumingNotStartedRolloutReturnsBadRequest() throws Exception { + @Test + void resumingNotStartedRolloutReturnsBadRequest() throws Exception { // setup final int amountTargets = 20; testdataFactory.createTargets(amountTargets, "rollout", "rollout"); @@ -1229,7 +1264,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { /** * Testing that starting rollout the first rollout group is in running state */ - @Test void startingRolloutFirstRolloutGroupIsInRunningState() throws Exception { + @Test + void startingRolloutFirstRolloutGroupIsInRunningState() throws Exception { // setup final int amountTargets = 10; testdataFactory.createTargets(amountTargets, "rollout", "rollout"); @@ -1296,7 +1332,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { /** * Testing that the targets of rollout group can be retrieved */ - @Test void retrieveTargetsFromRolloutGroup() throws Exception { + @Test + void retrieveTargetsFromRolloutGroup() throws Exception { // setup final int amountTargets = 10; testdataFactory.createTargets(amountTargets, "rollout", "rollout"); @@ -1322,7 +1359,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { /** * Testing that the targets of rollout group can be retrieved with rsql query param */ - @Test void retrieveTargetsFromRolloutGroupWithQuery() throws Exception { + @Test + void retrieveTargetsFromRolloutGroupWithQuery() throws Exception { // setup final int amountTargets = 10; testdataFactory.createTargets(amountTargets, "rollout", "rollout"); @@ -1351,7 +1389,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { /** * Testing that the targets of rollout group can be retrieved after the rollout has been started */ - @Test void retrieveTargetsFromRolloutGroupAfterRolloutIsStarted() throws Exception { + @Test + void retrieveTargetsFromRolloutGroupAfterRolloutIsStarted() throws Exception { // setup final int amountTargets = 10; testdataFactory.createTargets(amountTargets, "rollout", "rollout"); @@ -1382,7 +1421,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { /** * Start the rollout in async mode */ - @Test void startingRolloutSwitchesIntoRunningStateAsync() throws Exception { + @Test + void startingRolloutSwitchesIntoRunningStateAsync() throws Exception { final int amountTargets = 50; testdataFactory.createTargets(amountTargets, "rollout", "rollout"); @@ -1406,7 +1446,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { /** * Deletion of a rollout */ - @Test void deleteRollout() throws Exception { + @Test + void deleteRollout() throws Exception { final int amountTargets = 10; testdataFactory.createTargets(amountTargets, "rolloutDelete", "rolloutDelete"); final DistributionSet dsA = testdataFactory.createDistributionSet(""); @@ -1424,7 +1465,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { /** * Soft deletion of a rollout: soft deletion appears when already running rollout is being deleted */ - @Test void deleteRunningRollout() throws Exception { + @Test + void deleteRunningRollout() throws Exception { final Rollout rollout = testdataFactory.createSoftDeletedRollout("softDeletedRollout"); mvc.perform(get("/rest/v1/rollouts/{rolloutid}", rollout.getId())) @@ -1438,7 +1480,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { /** * Testing that rollout paged list with rsql parameter */ - @Test void getRolloutWithRSQLParam() throws Exception { + @Test + void getRolloutWithRSQLParam() throws Exception { final int amountTargetsRollout1 = 25; final int amountTargetsRollout2 = 25; @@ -1485,7 +1528,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { /** * Testing that rolloutgroup paged list with rsql parameter */ - @Test void retrieveRolloutGroupsForSpecificRolloutWithRSQLParam() throws Exception { + @Test + void retrieveRolloutGroupsForSpecificRolloutWithRSQLParam() throws Exception { // setup final int amountTargets = 20; testdataFactory.createTargets(amountTargets, "rollout", "rollout"); @@ -1529,7 +1573,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { /** * Testing that the list of rollout groups can be requested with representation mode 'full'. */ - @Test void retrieveRolloutGroupsFullRepresentation() throws Exception { + @Test + void retrieveRolloutGroupsFullRepresentation() throws Exception { testdataFactory.createTargets(20, "rollout", "rollout"); final DistributionSet dsA = testdataFactory.createDistributionSet(""); @@ -1568,7 +1613,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { /** * Verifies that a DOWNLOAD_ONLY rollout is possible */ - @Test void createDownloadOnlyRollout() throws Exception { + @Test + void createDownloadOnlyRollout() throws Exception { testdataFactory.createTargets(20, "target", "rollout"); final DistributionSet dsA = testdataFactory.createDistributionSet(""); @@ -1578,7 +1624,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { /** * A rollout create request containing a weight is always accepted when weight is valid. */ - @Test void weightValidation() throws Exception { + @Test + void weightValidation() throws Exception { testdataFactory.createTargets(4, "rollout", "description"); final Long dsId = testdataFactory.createDistributionSet().getId(); final int weight = 66; @@ -1614,7 +1661,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { /** * Trigger next rollout group */ - @Test void triggeringNextGroupRollout() throws Exception { + @Test + void triggeringNextGroupRollout() throws Exception { // setup final int amountTargets = 20; testdataFactory.createTargets(amountTargets, "rollout", "rollout"); @@ -1637,7 +1685,8 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest { /** * Trigger next rollout group if rollout is in wrong state */ - @Test void triggeringNextGroupRolloutWrongState() throws Exception { + @Test + void triggeringNextGroupRolloutWrongState() throws Exception { final int amountTargets = 3; final List targets = testdataFactory.createTargets(amountTargets, "rollout"); final DistributionSet dsA = testdataFactory.createDistributionSet(""); diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResourceTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResourceTest.java index 5bb3163de..d6274e53c 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResourceTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleResourceTest.java @@ -100,7 +100,8 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes /** * Trying to create a SM from already marked as deleted type - should get as response 400 Bad Request */ - @Test public void createSMFromAlreadyMarkedAsDeletedType() throws Exception { + @Test + void createSMFromAlreadyMarkedAsDeletedType() throws Exception { final String SM_TYPE = "someSmType"; final SoftwareModule sm = testdataFactory.createSoftwareModule(SM_TYPE); testdataFactory.findOrCreateDistributionSetType( @@ -138,7 +139,8 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes /** * Handles the GET request of retrieving all meta data of artifacts assigned to a software module (in full representation mode including a download URL by the artifact provider). */ - @Test public void getArtifactsWithParameters() throws Exception { + @Test + void getArtifactsWithParameters() throws Exception { final SoftwareModule sm = testdataFactory.createSoftwareModuleOs(); final byte[] random = randomBytes(5); @@ -156,7 +158,8 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes /** * Get a paged list of meta data for a software module. */ - @Test public void getMetadata() throws Exception { + @Test + void getMetadata() throws Exception { final int totalMetadata = 4; final String knownKeyPrefix = "knownKey"; final String knownValuePrefix = "knownValue"; @@ -177,7 +180,8 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes /** * Get a paged list of meta data for a software module with defined page size and sorting by name descending and key starting with 'known'. */ - @Test public void getMetadataWithParameters() throws Exception { + @Test + void getMetadataWithParameters() throws Exception { final int totalMetadata = 4; final String knownKeyPrefix = "knownKey"; final String knownValuePrefix = "knownValue"; @@ -199,7 +203,8 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes /** * Get a single meta data value for a meta data key. */ - @Test public void getMetadataValue() throws Exception { + @Test + void getMetadataValue() throws Exception { // prepare and create metadata final String knownKey = "knownKey"; @@ -217,7 +222,8 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes /** * Tests the update of software module metadata. It is verfied that only the selected fields for the update are really updated and the modification values are filled (i.e. updated by and at). */ - @Test @WithUser(principal = "smUpdateTester", allSpPermissions = true) + @Test + @WithUser(principal = "smUpdateTester", allSpPermissions = true) void updateSoftwareModuleOnlyDescriptionAndVendorNameUntouched() throws Exception { final String knownSWName = "name1"; final String knownSWVersion = "version1"; @@ -272,7 +278,8 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes /** * Tests the update of the deletion flag. It is verified that the software module can't be marked as deleted through update operation. */ - @Test @WithUser(principal = "smUpdateTester", allSpPermissions = true) + @Test + @WithUser(principal = "smUpdateTester", allSpPermissions = true) void updateSoftwareModuleDeletedFlag() throws Exception { final String knownSWName = "name1"; final String knownSWVersion = "version1"; @@ -309,7 +316,8 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes /** * Tests the lock. It is verified that the software module can be marked as locked through update operation. */ - @Test @WithUser(principal = "smUpdateTester", allSpPermissions = true) + @Test + @WithUser(principal = "smUpdateTester", allSpPermissions = true) void lockSoftwareModule() throws Exception { final SoftwareModule sm = softwareModuleManagement.create( entityFactory.softwareModule().create().type(osType).name("name1").version("version1")); @@ -342,7 +350,8 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes /** * Tests the unlock. */ - @Test @WithUser(principal = "smUpdateTester", allSpPermissions = true) + @Test + @WithUser(principal = "smUpdateTester", allSpPermissions = true) void unlockSoftwareModule() throws Exception { final SoftwareModule sm = softwareModuleManagement.create( entityFactory.softwareModule().create().type(osType).name("name1").version("version1")); @@ -378,7 +387,8 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes /** * Tests the upload of an artifact binary. The upload is executed and the content checked in the repository for completeness. */ - @Test void uploadArtifact() throws Exception { + @Test + void uploadArtifact() throws Exception { final SoftwareModule sm = testdataFactory.createSoftwareModuleOs(); // create test file @@ -420,7 +430,8 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes /** * Verifies that artifacts which exceed the configured maximum size cannot be uploaded. */ - @Test void uploadArtifactFailsIfTooLarge() throws Exception { + @Test + void uploadArtifactFailsIfTooLarge() throws Exception { final SoftwareModule sm = testdataFactory.createSoftwareModule("quota", "quota", false); final long maxSize = quotaManagement.getMaxArtifactSize(); @@ -441,7 +452,8 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes /** * Verifies that artifact with invalid filename cannot be uploaded to prevent cross site scripting. */ - @Test void uploadArtifactFailsIfFilenameInvalide() throws Exception { + @Test + void uploadArtifactFailsIfFilenameInvalide() throws Exception { final SoftwareModule sm = testdataFactory.createSoftwareModule("quota", "quota", false); final String illegalFilename = ".xml"; @@ -458,7 +470,8 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes /** * Verifies that the system does not accept empty artifact uploads. Expected response: BAD REQUEST */ - @Test void emptyUploadArtifact() throws Exception { + @Test + void emptyUploadArtifact() throws Exception { assertThat(softwareModuleManagement.findAll(PAGE)).isEmpty(); assertThat(artifactManagement.count()).isZero(); @@ -475,7 +488,8 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes /** * Verifies that the system does not accept identical artifacts uploads for the same software module. Expected response: CONFLICT */ - @Test void duplicateUploadArtifact() throws Exception { + @Test + void duplicateUploadArtifact() throws Exception { final SoftwareModule sm = testdataFactory.createSoftwareModuleOs(); final byte[] random = randomBytes(5 * 1024); @@ -503,7 +517,8 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes /** * verifies that option to upload artifacts with a custom defined by metadata, i.e. not the file name of the binary itself. */ - @Test void uploadArtifactWithCustomName() throws Exception { + @Test + void uploadArtifactWithCustomName() throws Exception { final SoftwareModule sm = testdataFactory.createSoftwareModuleOs(); assertThat(artifactManagement.count()).isZero(); @@ -531,7 +546,8 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes /** * Verifies that the system refuses upload of an artifact where the provided hash sums do not match. Expected result: BAD REQUEST */ - @Test void uploadArtifactWithHashCheck() throws Exception { + @Test + void uploadArtifactWithHashCheck() throws Exception { final SoftwareModule sm = testdataFactory.createSoftwareModuleOs(); assertThat(artifactManagement.count()).isZero(); @@ -594,7 +610,8 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes /** * Verifies that only a limited number of artifacts can be uploaded for one software module. */ - @Test void uploadArtifactsUntilQuotaExceeded() throws Exception { + @Test + void uploadArtifactsUntilQuotaExceeded() throws Exception { final SoftwareModule sm = testdataFactory.createSoftwareModuleOs(); final long maxArtifacts = quotaManagement.getMaxArtifactsPerSoftwareModule(); @@ -637,7 +654,8 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes /** * Verifies that artifacts can only be added as long as the artifact storage quota is not exceeded. */ - @Test void uploadArtifactsUntilStorageQuotaExceeded() throws Exception { + @Test + void uploadArtifactsUntilStorageQuotaExceeded() throws Exception { final long storageLimit = quotaManagement.getMaxArtifactStorage(); @@ -686,7 +704,8 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes /** * Tests binary download of an artifact including verfication that the downloaded binary is consistent and that the etag header is as expected identical to the SHA1 hash of the file. */ - @Test void downloadArtifact() throws Exception { + @Test + void downloadArtifact() throws Exception { final SoftwareModule sm = testdataFactory.createSoftwareModuleOs(); final int artifactSize = 5 * 1024; @@ -707,7 +726,8 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes /** * Verifies the listing of one defined artifact assigned to a given software module. That includes the artifact metadata and download links. */ - @Test void getArtifact() throws Exception { + @Test + void getArtifact() throws Exception { // prepare data for test final SoftwareModule sm = testdataFactory.createSoftwareModuleOs(); @@ -777,7 +797,8 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes /** * Verifies the listing of an artifact that belongs to a soft deleted software module. */ - @Test void getArtifactSoftDeleted() throws Exception { + @Test + void getArtifactSoftDeleted() throws Exception { // prepare data for test final SoftwareModule sm = testdataFactory.createSoftwareModuleOs("softDeleted"); final Artifact artifact = testdataFactory.createArtifacts(sm.getId()).get(0); @@ -805,7 +826,8 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes /** * Verifies the listing of all artifacts assigned to a software module. That includes the artifact metadata. */ - @Test void getArtifacts() throws Exception { + @Test + void getArtifacts() throws Exception { final SoftwareModule sm = testdataFactory.createSoftwareModuleOs(); final int artifactSize = 5 * 1024; @@ -891,7 +913,8 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes /** * Verifies that the system refuses unsupported request types and answers as defined to them, e.g. NOT FOUND on a non existing resource. Or a HTTP POST for updating a resource results in METHOD NOT ALLOWED etc. */ - @Test void invalidRequestsOnArtifactResource() throws Exception { + @Test + void invalidRequestsOnArtifactResource() throws Exception { final int artifactSize = 5 * 1024; final byte[] random = randomBytes(artifactSize); @@ -948,7 +971,8 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes /** * Tests the deletion of an artifact including verification that the artifact is actually erased in the repository and removed from the software module. */ - @Test void deleteArtifact() throws Exception { + @Test + void deleteArtifact() throws Exception { // Create 1 SM final SoftwareModule sm = testdataFactory.createSoftwareModuleOs(); @@ -983,7 +1007,8 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes /** * Verifies that the system refuses unsupported request types and answers as defined to them, e.g. NOT FOUND on a non existing resource. Or a HTTP POST for updating a resource results in METHOD NOT ALLOWED etc. */ - @Test void invalidRequestsOnSoftwareModulesResource() throws Exception { + @Test + void invalidRequestsOnSoftwareModulesResource() throws Exception { final SoftwareModule sm = testdataFactory.createSoftwareModuleOs(); final List modules = Collections.singletonList(sm); @@ -1050,7 +1075,8 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes /** * Test of modules retrieval without any parameters. Will return all modules in the system as defined by standard page size. */ - @Test void getSoftwareModulesWithoutAdditionalRequestParameters() throws Exception { + @Test + void getSoftwareModulesWithoutAdditionalRequestParameters() throws Exception { final int modules = 5; createSoftwareModulesAlphabetical(modules); mvc.perform(get(MgmtRestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING)) @@ -1064,7 +1090,8 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes /** * Test of modules retrieval with paging limit parameter. Will return all modules in the system as defined by given page size. */ - @Test void detSoftwareModulesWithPagingLimitRequestParameter() throws Exception { + @Test + void detSoftwareModulesWithPagingLimitRequestParameter() throws Exception { final int modules = 5; final int limitSize = 1; createSoftwareModulesAlphabetical(modules); @@ -1080,7 +1107,8 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes /** * Test of modules retrieval with paging limit offset parameters. Will return all modules in the system as defined by given page size starting from given offset. */ - @Test void getSoftwareModulesWithPagingLimitAndOffsetRequestParameter() throws Exception { + @Test + void getSoftwareModulesWithPagingLimitAndOffsetRequestParameter() throws Exception { final int modules = 5; final int offsetParam = 2; final int expectedSize = modules - offsetParam; @@ -1135,7 +1163,8 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes /** * Test the various filter parameters, e.g. filter by name or type of the module. */ - @Test void getSoftwareModulesWithFilterParameters() throws Exception { + @Test + void getSoftwareModulesWithFilterParameters() throws Exception { final SoftwareModule os1 = testdataFactory.createSoftwareModuleOs("1"); final SoftwareModule app1 = testdataFactory.createSoftwareModuleApp("1"); testdataFactory.createSoftwareModuleOs("2"); @@ -1201,7 +1230,8 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes /** * Verifies that the system answers as defined in case of a wrong filter parameter syntax. Expected result: BAD REQUEST with error description. */ - @Test void getSoftwareModulesWithSyntaxErrorFilterParameter() throws Exception { + @Test + void getSoftwareModulesWithSyntaxErrorFilterParameter() throws Exception { mvc.perform(get("/rest/v1/softwaremodules?q=wrongFIQLSyntax").accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isBadRequest()) @@ -1211,7 +1241,8 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes /** * Verifies that the system answers as defined in case of a non existing field used in filter. Expected result: BAD REQUEST with error description. */ - @Test void getSoftwareModulesWithUnknownFieldErrorFilterParameter() throws Exception { + @Test + void getSoftwareModulesWithUnknownFieldErrorFilterParameter() throws Exception { mvc.perform(get("/rest/v1/softwaremodules?q=wrongField==abc").accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isBadRequest()) @@ -1326,7 +1357,8 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes /** * Verifies successfull deletion of software modules that are not in use, i.e. assigned to a DS. */ - @Test void deleteUnassignedSoftwareModule() throws Exception { + @Test + void deleteUnassignedSoftwareModule() throws Exception { final SoftwareModule sm = testdataFactory.createSoftwareModuleOs(); @@ -1351,7 +1383,8 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes /** * Verifies successfull deletion of a software module that is in use, i.e. assigned to a DS which should result in movinf the module to the archive. */ - @Test void deleteAssignedSoftwareModule() throws Exception { + @Test + void deleteAssignedSoftwareModule() throws Exception { final DistributionSet ds1 = testdataFactory.createDistributionSet("a"); final int artifactSize = 5 * 1024; @@ -1386,7 +1419,8 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes /** * Verifies the successful creation of metadata and the enforcement of the meta data quota. */ - @Test void createMetadata() throws Exception { + @Test + void createMetadata() throws Exception { final String knownKey1 = "knownKey1"; final String knownValue1 = "knownValue1"; final String knownKey2 = "knownKey2"; @@ -1429,7 +1463,8 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes /** * Verifies the successful update of metadata based on given key. */ - @Test void updateMetadataKey() throws Exception { + @Test + void updateMetadataKey() throws Exception { // prepare and create metadata for update final String knownKey = "knownKey"; final String knownValue = "knownValue"; @@ -1456,7 +1491,8 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes /** * Verifies the successful deletion of metadata entry. */ - @Test void deleteMetadata() throws Exception { + @Test + void deleteMetadata() throws Exception { // prepare and create metadata for deletion final String knownKey = "knownKey"; final String knownValue = "knownValue"; @@ -1476,7 +1512,8 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes /** * Ensures that module metadata deletion request to API on an entity that does not exist results in NOT_FOUND. */ - @Test void deleteModuleMetadataThatDoesNotExistLeadsToNotFound() throws Exception { + @Test + void deleteModuleMetadataThatDoesNotExistLeadsToNotFound() throws Exception { // prepare and create metadata for deletion final String knownKey = "knownKey"; final String knownValue = "knownValue"; @@ -1499,7 +1536,8 @@ class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTes /** * Ensures that module deletion request to API on an entity that does not exist results in NOT_FOUND. */ - @Test void deleteSoftwareModuleThatDoesNotExistLeadsToNotFound() throws Exception { + @Test + void deleteSoftwareModuleThatDoesNotExistLeadsToNotFound() throws Exception { mvc.perform(delete("/rest/v1/softwaremodules/1234")) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNotFound()); diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeResourceTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeResourceTest.java index 5a7cf2a88..d1c092b41 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeResourceTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtSoftwareModuleTypeResourceTest.java @@ -274,7 +274,8 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt /** * Ensures that module type deletion request to API on an entity that does not exist results in NOT_FOUND. */ - @Test public void deleteSoftwareModuleTypeThatDoesNotExistLeadsToNotFound() throws Exception { + @Test + void deleteSoftwareModuleTypeThatDoesNotExistLeadsToNotFound() throws Exception { mvc.perform(delete("/rest/v1/softwaremoduletypes/1234")) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isNotFound()); @@ -312,7 +313,8 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt /** * Checks the correct behaviour of /rest/v1/softwaremoduletypes/{ID} PUT requests. */ - @Test public void updateSoftwareModuleTypeColourDescriptionAndNameUntouched() throws Exception { + @Test + void updateSoftwareModuleTypeColourDescriptionAndNameUntouched() throws Exception { final SoftwareModuleType testType = createTestType(); final String body = new JSONObject().put("id", testType.getId()).put("description", "foobardesc") @@ -333,7 +335,8 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt /** * Tests the update of the deletion flag. It is verfied that the software module type can't be marked as deleted through update operation. */ - @Test public void updateSoftwareModuleTypeDeletedFlag() throws Exception { + @Test + void updateSoftwareModuleTypeDeletedFlag() throws Exception { SoftwareModuleType testType = createTestType(); final String body = new JSONObject().put("id", testType.getId()).put("deleted", true).toString(); @@ -354,7 +357,8 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt /** * Checks the correct behaviour of /rest/v1/softwaremoduletypes GET requests with paging. */ - @Test public void getSoftwareModuleTypesWithoutAddtionalRequestParameters() throws Exception { + @Test + void getSoftwareModuleTypesWithoutAddtionalRequestParameters() throws Exception { final int types = 3; mvc.perform(get(MgmtRestConstants.SOFTWAREMODULETYPE_V1_REQUEST_MAPPING)) .andDo(MockMvcResultPrinter.print()) @@ -367,7 +371,8 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt /** * Checks the correct behaviour of /rest/v1/softwaremoduletypes GET requests with paging. */ - @Test public void getSoftwareModuleTypesWithPagingLimitRequestParameter() throws Exception { + @Test + void getSoftwareModuleTypesWithPagingLimitRequestParameter() throws Exception { final int types = 3; final int limitSize = 1; mvc.perform(get(MgmtRestConstants.SOFTWAREMODULETYPE_V1_REQUEST_MAPPING) @@ -382,7 +387,8 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt /** * Checks the correct behaviour of /rest/v1/softwaremoduletypes GET requests with paging. */ - @Test public void getSoftwareModuleTypesWithPagingLimitAndOffsetRequestParameter() throws Exception { + @Test + void getSoftwareModuleTypesWithPagingLimitAndOffsetRequestParameter() throws Exception { final int types = 3; final int offsetParam = 2; final int expectedSize = types - offsetParam; @@ -399,7 +405,8 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt /** * Ensures that the server is behaving as expected on invalid requests (wrong media type, wrong ID etc.). */ - @Test public void invalidRequestsOnSoftwaremoduleTypesResource() throws Exception { + @Test + void invalidRequestsOnSoftwaremoduleTypesResource() throws Exception { final SoftwareModuleType testType = createTestType(); final List types = Collections.singletonList(testType); @@ -460,7 +467,8 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt /** * Search erquest of software module types. */ - @Test public void searchSoftwareModuleTypeRsql() throws Exception { + @Test + void searchSoftwareModuleTypeRsql() throws Exception { softwareModuleTypeManagement.create(entityFactory.softwareModuleType().create().key("test123") .name("TestName123").description("Desc123").maxAssignments(5)); softwareModuleTypeManagement.create(entityFactory.softwareModuleType().create().key("test1234") diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetFilterQueryResourceTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetFilterQueryResourceTest.java index 1aab90954..6417b4fa4 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetFilterQueryResourceTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetFilterQueryResourceTest.java @@ -94,7 +94,8 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte /** * Handles the GET request of retrieving all target filter queries within SP. */ - @Test public void getTargetFilterQueries() throws Exception { + @Test + void getTargetFilterQueries() throws Exception { final String filterName = "filter_01"; createSingleTargetFilterQuery(filterName, "name==test_01"); mvc.perform(get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING)) @@ -105,7 +106,8 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte /** * Handles the GET request of retrieving all target filter queries within SP based by parameter. Required Permission: READ_TARGET. */ - @Test public void getTargetFilterQueriesWithParameters() throws Exception { + @Test + void getTargetFilterQueriesWithParameters() throws Exception { mvc.perform(get(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "?limit=10&sort=name:ASC&offset=0&q=name==*1")) .andExpect(status().isOk()) .andDo(MockMvcResultPrinter.print()); @@ -114,7 +116,8 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte /** * Handles the POST request of creating a new target filter query within SP. */ - @Test public void createTargetFilterQuery() throws Exception { + @Test + void createTargetFilterQuery() throws Exception { final String name = "test_02"; final String filterQuery = "name==test_02"; final String body = new JSONObject() @@ -130,7 +133,8 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte /** * Ensures that deletion is executed if permitted. */ - @Test public void deleteTargetFilterQueryReturnsOK() throws Exception { + @Test + void deleteTargetFilterQueryReturnsOK() throws Exception { final String filterName = "filter_01"; final TargetFilterQuery filterQuery = createSingleTargetFilterQuery(filterName, "name==test_01"); @@ -143,7 +147,8 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte /** * Ensures that deletion is refused with not found if target does not exist. */ - @Test public void deleteTargetWhichDoesNotExistsLeadsToEntityNotFound() throws Exception { + @Test + void deleteTargetWhichDoesNotExistsLeadsToEntityNotFound() throws Exception { final String notExistingId = "4395"; mvc.perform(delete(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + notExistingId)) @@ -153,7 +158,8 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte /** * Ensures that update is refused with not found if target does not exist. */ - @Test public void updateTargetWhichDoesNotExistsLeadsToEntityNotFound() throws Exception { + @Test + void updateTargetWhichDoesNotExistsLeadsToEntityNotFound() throws Exception { final String notExistingId = "4395"; mvc.perform(put(MgmtRestConstants.TARGET_FILTER_V1_REQUEST_MAPPING + "/" + notExistingId).content("{}") .contentType(MediaType.APPLICATION_JSON)) @@ -164,7 +170,8 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte /** * Ensures that update request is reflected by repository. */ - @Test public void updateTargetFilterQueryQuery() throws Exception { + @Test + void updateTargetFilterQueryQuery() throws Exception { final String filterName = "filter_02"; final String filterQuery = "name==test_02"; final String filterQuery2 = "name==test_02_changed"; @@ -190,7 +197,8 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte /** * Ensures that update request is reflected by repository. */ - @Test public void updateTargetFilterQueryName() throws Exception { + @Test + void updateTargetFilterQueryName() throws Exception { final String filterName = "filter_03"; final String filterName2 = "filter_03_changed"; final String filterQuery = "name==test_03"; @@ -217,7 +225,8 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte /** * Ensures that request returns list of filters in defined format. */ - @Test public void getTargetFilterQueryWithoutAdditionalRequestParameters() throws Exception { + @Test + void getTargetFilterQueryWithoutAdditionalRequestParameters() throws Exception { final int knownTargetAmount = 3; final String idA = "a"; final String idB = "b"; @@ -248,7 +257,8 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte /** * Ensures that request returns list of filters in defined format in size reduced by given limit parameter. */ - @Test public void getTargetWithPagingLimitRequestParameter() throws Exception { + @Test + void getTargetWithPagingLimitRequestParameter() throws Exception { final int limitSize = 1; final int knownTargetAmount = 3; final String idA = "a"; @@ -317,7 +327,8 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte /** * Ensures that request returns list of filters in defined format in size reduced by given limit and offset parameter. */ - @Test public void getTargetWithPagingLimitAndOffsetRequestParameter() throws Exception { + @Test + void getTargetWithPagingLimitAndOffsetRequestParameter() throws Exception { final int knownTargetAmount = 5; final int offsetParam = 2; final int expectedSize = knownTargetAmount - offsetParam; @@ -354,7 +365,8 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte /** * Ensures that a single target filter query can be retrieved via its id. */ - @Test public void getSingleTarget() throws Exception { + @Test + void getSingleTarget() throws Exception { // create first a target which can be retrieved by rest interface final String knownQuery = "name==test01"; final String knownName = "someName"; @@ -375,7 +387,8 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte /** * Ensures that the retrieval of a non-existing target filter query results in a HTTP Not found error (404). */ - @Test public void getSingleTargetNoExistsResponseNotFound() throws Exception { + @Test + void getSingleTargetNoExistsResponseNotFound() throws Exception { final String targetIdNotExists = "546546"; // test @@ -393,7 +406,8 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte /** * Ensures that the creation of a target filter query based on an invalid request payload results in a HTTP Bad Request error (400). */ - @Test public void createTargetFilterQueryWithBadPayloadBadRequest() throws Exception { + @Test + void createTargetFilterQueryWithBadPayloadBadRequest() throws Exception { final String notJson = "abc"; final MvcResult mvcResult = mvc @@ -415,7 +429,8 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte /** * Ensures that the creation of a target filter query based on an invalid RSQL query results in a HTTP Bad Request error (400). */ - @Test public void createTargetFilterWithInvalidQuery() throws Exception { + @Test + void createTargetFilterWithInvalidQuery() throws Exception { final String invalidQuery = "name=abc"; final String body = new JSONObject().put("query", invalidQuery).put("name", "invalidFilter").toString(); @@ -524,7 +539,8 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte /** * Handles the GET request of retrieving a the auto assign distribution set of a target filter query within SP. */ - @Test public void getAssignDS() throws Exception { + @Test + void getAssignDS() throws Exception { final TargetFilterQuery filterQuery = createSingleTargetFilterQuery("filter_01", "name==test_01"); final DistributionSet ds = testdataFactory.createDistributionSet("ds"); targetFilterQueryManagement @@ -540,7 +556,8 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte /** * Handles the POST request of setting a distribution set for auto assignment within SP. */ - @Test public void createAutoAssignDS() throws Exception { + @Test + void createAutoAssignDS() throws Exception { enableMultiAssignments(); enableConfirmationFlow(); @@ -560,7 +577,8 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte /** * Handles the DELETE request of deleting the auto assign distribution set from a target filter query within SP. */ - @Test public void deleteAutoAssignDS() throws Exception { + @Test + void deleteAutoAssignDS() throws Exception { final String filterName = "filter_01"; final TargetFilterQuery filterQuery = createSingleTargetFilterQuery(filterName, "name==test_01"); mvc @@ -574,7 +592,8 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte /** * Ensures that the deletion of auto-assignment distribution set works as intended, deleting the auto-assignment action type as well */ - @Test public void deleteAutoAssignDistributionSetOfTargetFilterQuery() throws Exception { + @Test + void deleteAutoAssignDistributionSetOfTargetFilterQuery() throws Exception { final String knownQuery = "name==test06"; final String knownName = "filter06"; final String dsName = "testDS"; @@ -610,7 +629,8 @@ public class MgmtTargetFilterQueryResourceTest extends AbstractManagementApiInte /** * An auto assignment containing a weight is only accepted when weight is valide and multi assignment is on. */ - @Test public void weightValidation() throws Exception { + @Test + void weightValidation() throws Exception { final Long filterId = createSingleTargetFilterQuery("filter1", "name==*").getId(); final Long dsId = testdataFactory.createDistributionSet().getId(); diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResourceTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResourceTest.java index 757756e08..a20c97cd4 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResourceTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetResourceTest.java @@ -148,7 +148,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Ensures that when targetType value of -1 is provided the target type is unassigned from the target. */ - @Test void updateTargetAndUnassignTargetType() throws Exception { + @Test + void updateTargetAndUnassignTargetType() throws Exception { final String knownControllerId = "123"; final String knownNewAddress = "amqp://test123/foobar"; final String knownNameNotModify = "controllerName"; @@ -186,7 +187,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Ensures that when targetType value of -1 is provided the target type is unassigned from the target when updating multiple fields in target object. */ - @Test void updateTargetNameAndUnassignTargetType() throws Exception { + @Test + void updateTargetNameAndUnassignTargetType() throws Exception { final String knownControllerId = "123"; final String knownNewAddress = "amqp://test123/foobar"; final String knownNameNotModify = "controllerName"; @@ -227,7 +229,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Handles the GET request of retrieving all targets within SP.. */ - @Test void getTargets() throws Exception { + @Test + void getTargets() throws Exception { enableConfirmationFlow(); mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING)) .andExpect(status().isOk()) @@ -237,7 +240,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Handles the GET request of retrieving all targets within SP based by parameter. */ - @Test void getTargetsWithParameters() throws Exception { + @Test + void getTargetsWithParameters() throws Exception { mvc.perform(get(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "?limit=10&sort=name:ASC&offset=0&q=name==a")) .andExpect(status().isOk()) .andDo(MockMvcResultPrinter.print()); @@ -246,7 +250,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Handles the POST request to activate auto-confirm on a target. Payload can be provided to specify more details about the operation. */ - @Test void postActivateAutoConfirm() throws Exception { + @Test + void postActivateAutoConfirm() throws Exception { final Target testTarget = testdataFactory.createTarget("targetId"); final MgmtTargetAutoConfirmUpdate body = new MgmtTargetAutoConfirmUpdate("custom_initiator_value", @@ -262,7 +267,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Handles the POST request to deactivate auto-confirm on a target. */ - @Test void postDeactivateAutoConfirm() throws Exception { + @Test + void postDeactivateAutoConfirm() throws Exception { final Target testTarget = testdataFactory.createTarget("targetId"); confirmationManagement.activateAutoConfirmation(testTarget.getControllerId(), null, null); @@ -275,7 +281,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Test confirmation of single Action with confirm status. Check that Action goes into Running status with appropriate messages and status code */ - @Test void updateActionConfirmationWithConfirm() throws Exception { + @Test + void updateActionConfirmationWithConfirm() throws Exception { final int expectedStatusCode = 210; final String expectedStatusMessage1 = "some-custom-message1"; final String expectedStatusMessage2 = "some-custom-message2"; @@ -287,7 +294,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Test confirmation of single Action with deny status. Check that Action stays in WAIT_FOR_CONFIRMATION status with appropriate messages and status code */ - @Test void updateActionConfirmationWithDeny() throws Exception { + @Test + void updateActionConfirmationWithDeny() throws Exception { final int expectedStatusCode = 410; final String expectedStatusMessage1 = "some-error-custom-message1"; final String expectedStatusMessage2 = "some-error-custom-message2"; @@ -299,7 +307,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Test confirmation of single Action with wrong ControllerId - e.g. the given Action is not assigned to the given Target - confirmation call must fail. */ - @Test void updateActionConfirmationFailsIfActionNotAssignedToTarget() throws Exception { + @Test + void updateActionConfirmationFailsIfActionNotAssignedToTarget() throws Exception { final int payloadCallCode = 200; final String payloadCallMessage1 = "random1"; final String payloadCallMessage2 = "random2"; @@ -373,7 +382,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Ensures that actions list is in expected order. */ - @Test void getActionStatusReturnsCorrectType() throws Exception { + @Test + void getActionStatusReturnsCorrectType() throws Exception { final int limitSize = 2; final String knownTargetId = "targetId"; final List actions = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId); @@ -405,7 +415,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Ensures that security token is not returned if user does not have READ_TARGET_SEC_TOKEN permission. */ - @Test @WithUser(allSpPermissions = false, authorities = { SpPermission.READ_TARGET, SpPermission.CREATE_TARGET }) + @Test + @WithUser(allSpPermissions = false, authorities = { SpPermission.READ_TARGET, SpPermission.CREATE_TARGET }) void securityTokenIsNotInResponseIfMissingPermission() throws Exception { final String knownControllerId = "knownControllerId"; @@ -419,7 +430,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Ensures that security token is returned if user does have READ_TARGET_SEC_TOKEN permission. */ - @Test @WithUser(allSpPermissions = false, authorities = { SpPermission.READ_TARGET, SpPermission.CREATE_TARGET, + @Test + @WithUser(allSpPermissions = false, authorities = { SpPermission.READ_TARGET, SpPermission.CREATE_TARGET, SpPermission.READ_TARGET_SEC_TOKEN }) void securityTokenIsInResponseWithCorrectPermission() throws Exception { @@ -434,7 +446,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Ensures that that IP address is in result as stored in the repository. */ - @Test void addressAndIpAddressInTargetResult() throws Exception { + @Test + void addressAndIpAddressInTargetResult() throws Exception { // prepare targets with IP final String knownControllerId1 = "0815"; final String knownControllerId2 = "4711"; @@ -461,7 +474,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Ensures that actions history is returned as defined by filter status==pending,status==finished. */ - @Test void searchActionsRsql() throws Exception { + @Test + void searchActionsRsql() throws Exception { // prepare test final DistributionSet dsA = testdataFactory.createDistributionSet(""); @@ -503,7 +517,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Ensures that a deletion of an active action results in cancellation triggered. */ - @Test void cancelActionOK() throws Exception { + @Test + void cancelActionOK() throws Exception { // prepare test final Target tA = createTargetAndStartAction(); @@ -531,7 +546,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Ensures that method not allowed is returned if cancellation is triggered on already canceled action. */ - @Test void cancelAndCancelActionIsNotAllowed() throws Exception { + @Test + void cancelAndCancelActionIsNotAllowed() throws Exception { // prepare test final Target tA = createTargetAndStartAction(); @@ -554,7 +570,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Force Quit an Action, which is already canceled. Expected Result is an HTTP response code 204. */ - @Test void forceQuitAnCanceledActionReturnsOk() throws Exception { + @Test + void forceQuitAnCanceledActionReturnsOk() throws Exception { final Target tA = createTargetAndStartAction(); @@ -578,7 +595,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Force Quit an Action, which is not canceled. Expected Result is an HTTP response code 405. */ - @Test void forceQuitAnNotCanceledActionReturnsMethodNotAllowed() throws Exception { + @Test + void forceQuitAnNotCanceledActionReturnsMethodNotAllowed() throws Exception { final Target tA = createTargetAndStartAction(); @@ -594,7 +612,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Ensures that deletion is executed if permitted. */ - @Test void deleteTargetReturnsOK() throws Exception { + @Test + void deleteTargetReturnsOK() throws Exception { final String knownControllerId = "knownControllerIdDelete"; testdataFactory.createTarget(knownControllerId); @@ -607,7 +626,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Ensures that deletion is refused with not found if target does not exist. */ - @Test void deleteTargetWhichDoesNotExistsLeadsToNotFound() throws Exception { + @Test + void deleteTargetWhichDoesNotExistsLeadsToNotFound() throws Exception { final String knownControllerId = "knownControllerIdDelete"; mvc.perform(delete(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId)) @@ -617,7 +637,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Ensures that update is refused with not found if target does not exist. */ - @Test void updateTargetWhichDoesNotExistsLeadsToNotFound() throws Exception { + @Test + void updateTargetWhichDoesNotExistsLeadsToNotFound() throws Exception { final String knownControllerId = "knownControllerIdUpdate"; mvc.perform(put(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownControllerId).content("{}") .contentType(MediaType.APPLICATION_JSON)) @@ -628,7 +649,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Ensures that target update request is reflected by repository. */ - @Test void updateTargetDescription() throws Exception { + @Test + void updateTargetDescription() throws Exception { final String knownControllerId = "123"; final String knownNewDescription = "a new desc updated over rest"; final String knownNameNotModify = "nameNotModify"; @@ -654,7 +676,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Ensures that target update request fails is updated value fails against a constraint. */ - @Test void updateTargetDescriptionFailsIfInvalidLength() throws Exception { + @Test + void updateTargetDescriptionFailsIfInvalidLength() throws Exception { final String knownControllerId = "123"; final String knownNewDescription = randomString(513); final String knownNameNotModify = "nameNotModify"; @@ -676,7 +699,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Ensures that target update request is reflected by repository. */ - @Test void updateTargetSecurityToken() throws Exception { + @Test + void updateTargetSecurityToken() throws Exception { final String knownControllerId = "123"; final String knownNewToken = "6567576565"; final String knownNameNotModify = "nameNotModify"; @@ -702,7 +726,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Ensures that target update request is reflected by repository. */ - @Test void updateTargetAddress() throws Exception { + @Test + void updateTargetAddress() throws Exception { final String knownControllerId = "123"; final String knownNewAddress = "amqp://test123/foobar"; final String knownNameNotModify = "nameNotModify"; @@ -728,7 +753,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Ensures that target query returns list of targets in defined format. */ - @Test void getTargetWithoutAdditionalRequestParameters() throws Exception { + @Test + void getTargetWithoutAdditionalRequestParameters() throws Exception { final int knownTargetAmount = 3; final String idA = "a"; final String idB = "b"; @@ -773,7 +799,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Ensures that target query returns list of targets in defined format in size reduced by given limit parameter. */ - @Test void getTargetWithPagingLimitRequestParameter() throws Exception { + @Test + void getTargetWithPagingLimitRequestParameter() throws Exception { final int knownTargetAmount = 3; final int limitSize = 1; createTargetsAlphabetical(knownTargetAmount); @@ -800,7 +827,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Ensures that target query returns list of targets in defined format in size reduced by given limit and offset parameter. */ - @Test void getTargetWithPagingLimitAndOffsetRequestParameter() throws Exception { + @Test + void getTargetWithPagingLimitAndOffsetRequestParameter() throws Exception { final int knownTargetAmount = 5; final int offsetParam = 2; final int expectedSize = knownTargetAmount - offsetParam; @@ -847,7 +875,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Ensures that the get request for a target works. */ - @Test void getSingleTarget() throws Exception { + @Test + void getSingleTarget() throws Exception { // create first a target which can be retrieved by rest interface final String knownControllerId = "1"; final String knownName = "someName"; @@ -873,7 +902,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Ensures that target get request returns a not found if the target does not exits. */ - @Test void getSingleTargetNoExistsResponseNotFound() throws Exception { + @Test + void getSingleTargetNoExistsResponseNotFound() throws Exception { final String targetIdNotExists = "bubu"; @@ -892,7 +922,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Ensures that get request for asigned distribution sets returns no count if no distribution set has been assigned. */ - @Test void getAssignedDistributionSetOfTargetIsEmpty() throws Exception { + @Test + void getAssignedDistributionSetOfTargetIsEmpty() throws Exception { // create first a target which can be retrieved by rest interface final String knownControllerId = "1"; final String knownName = "someName"; @@ -908,7 +939,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Ensures that the get request for asigned distribution sets works. */ - @Test void getAssignedDistributionSetOfTarget() throws Exception { + @Test + void getAssignedDistributionSetOfTarget() throws Exception { // create first a target which can be retrieved by rest interface final String knownControllerId = "1"; final String knownName = "someName"; @@ -967,7 +999,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Ensures that get request for installed distribution sets returns no count if no distribution set has been installed. */ - @Test void getInstalledDistributionSetOfTargetIsEmpty() throws Exception { + @Test + void getInstalledDistributionSetOfTargetIsEmpty() throws Exception { // create first a target which can be retrieved by rest interface final String knownControllerId = "1"; final String knownName = "someName"; @@ -981,7 +1014,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Ensures that a target creation with empty name and a controllerId that exceeds the name length limitation is successful and the name gets truncated. */ - @Test void createTargetWithEmptyNameAndLongControllerId() throws Exception { + @Test + void createTargetWithEmptyNameAndLongControllerId() throws Exception { final String randomString = randomString(JpaTarget.CONTROLLER_ID_MAX_SIZE); final Target target = entityFactory.target().create().controllerId(randomString).build(); @@ -1003,7 +1037,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Ensures that post request for creating a target with no payload returns a bad request. */ - @Test void createTargetWithoutPayloadBadRequest() throws Exception { + @Test + void createTargetWithoutPayloadBadRequest() throws Exception { final MvcResult mvcResult = mvc .perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING).contentType(MediaType.APPLICATION_JSON)) @@ -1023,7 +1058,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Ensures that post request for creating a target with invalid payload returns a bad request. */ - @Test void createTargetWithBadPayloadBadRequest() throws Exception { + @Test + void createTargetWithBadPayloadBadRequest() throws Exception { final String notJson = "abc"; final MvcResult mvcResult = mvc @@ -1045,7 +1081,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Verifies that a mandatory properties of new targets are validated as not null. */ - @Test void createTargetWithMissingMandatoryPropertyBadRequest() throws Exception { + @Test + void createTargetWithMissingMandatoryPropertyBadRequest() throws Exception { final MvcResult mvcResult = mvc .perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING).content("[{\"name\":\"id1\"}]") .contentType(MediaType.APPLICATION_JSON)) @@ -1065,7 +1102,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Verifies that a properties of new targets are validated as in allowed size range. */ - @Test void createTargetWithInvalidPropertyBadRequest() throws Exception { + @Test + void createTargetWithInvalidPropertyBadRequest() throws Exception { final Target test1 = entityFactory.target().create().controllerId("id1") .name(randomString(NamedEntity.NAME_MAX_SIZE + 1)).build(); @@ -1089,7 +1127,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Ensures that a post request for creating multiple targets works. */ - @Test void createTargetsListReturnsSuccessful() throws Exception { + @Test + void createTargetsListReturnsSuccessful() throws Exception { final Target test1 = entityFactory.target().create().controllerId("id1").name("testname1") .securityToken("token").address("amqp://test123/foobar").description("testid1").build(); final Target test2 = entityFactory.target().create().controllerId("id2").name("testname2") @@ -1143,7 +1182,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Ensures that a post request for creating one target within a list works. */ - @Test void createTargetsSingleEntryListReturnsSuccessful() throws Exception { + @Test + void createTargetsSingleEntryListReturnsSuccessful() throws Exception { final String knownName = "someName"; final String knownControllerId = "controllerId1"; final String knownDescription = "someDescription"; @@ -1165,7 +1205,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Ensures that a post request for creating the same target again leads to a conflict response. */ - @Test void createTargetsSingleEntryListDoubleReturnConflict() throws Exception { + @Test + void createTargetsSingleEntryListDoubleReturnConflict() throws Exception { final String knownName = "someName"; final String knownControllerId = "controllerId1"; final String knownDescription = "someDescription"; @@ -1198,7 +1239,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Ensures that the get request for action of a target returns no actions if nothing has happened. */ - @Test void getActionWithEmptyResult() throws Exception { + @Test + void getActionWithEmptyResult() throws Exception { final String knownTargetId = "targetId"; testdataFactory.createTarget(knownTargetId); @@ -1214,7 +1256,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Ensures that the expected response is returned for update action. */ - @Test void getUpdateAction() throws Exception { + @Test + void getUpdateAction() throws Exception { final String knownTargetId = "targetId"; final List actions = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId); @@ -1238,7 +1281,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Ensures that the expected response is returned for update action with maintenance window. */ - @Test void getUpdateActionWithMaintenanceWindow() throws Exception { + @Test + void getUpdateActionWithMaintenanceWindow() throws Exception { final String knownTargetId = "targetId"; final String schedule = getTestSchedule(10); final String duration = getTestDuration(10); @@ -1270,7 +1314,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Ensures that the expected response is returned when update action was cancelled. */ - @Test void getCancelAction() throws Exception { + @Test + void getCancelAction() throws Exception { final String knownTargetId = "targetId"; final List actions = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId); @@ -1294,7 +1339,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Ensures that the expected response is returned when update action with maintenance window was cancelled. */ - @Test void getCancelActionWithMaintenanceWindow() throws Exception { + @Test + void getCancelActionWithMaintenanceWindow() throws Exception { final String knownTargetId = "targetId"; final String schedule = getTestSchedule(10); final String duration = getTestDuration(10); @@ -1326,21 +1372,24 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Ensures that the expected response of getting actions of a target is returned. */ - @Test void getActions() throws Exception { + @Test + void getActions() throws Exception { getActions(false); } /** * Ensures that the expected response of getting actions (with ext refs) of a target is returned. */ - @Test void getActionsExtRef() throws Exception { + @Test + void getActionsExtRef() throws Exception { getActions(true); } /** * Ensures that the expected response of getting actions with maintenance window of a target is returned. */ - @Test void getActionsWithMaintenanceWindow() throws Exception { + @Test + void getActionsWithMaintenanceWindow() throws Exception { final String knownTargetId = "targetId"; final String schedule = getTestSchedule(10); final String duration = getTestDuration(10); @@ -1380,7 +1429,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Verifies that the API returns the status list with expected content. */ - @Test void getActionsStatus() throws Exception { + @Test + void getActionsStatus() throws Exception { final String knownTargetId = "targetId"; final Action action = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId).get(0); // retrieve list in default descending order for actionstaus entries @@ -1410,7 +1460,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Verifies that the API returns the status list with expected content sorted by reportedAt field. */ - @Test void getActionsStatusSortedByReportedAt() throws Exception { + @Test + void getActionsStatusSortedByReportedAt() throws Exception { final String knownTargetId = "targetId"; final Action action = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId).get(0); final List actionStatus = deploymentManagement.findActionStatusByAction(action.getId(), PAGE) @@ -1459,7 +1510,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Verifies that the API returns the status list with expected content split into two pages. */ - @Test void getActionsStatusWithPagingLimitRequestParameter() throws Exception { + @Test + void getActionsStatusWithPagingLimitRequestParameter() throws Exception { final String knownTargetId = "targetId"; final Action action = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId).get(0); @@ -1502,7 +1554,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Verifies getting multiple actions with the paging request parameter. */ - @Test void getActionsWithPagingLimitRequestParameter() throws Exception { + @Test + void getActionsWithPagingLimitRequestParameter() throws Exception { final String knownTargetId = "targetId"; final List actions = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId); @@ -1544,7 +1597,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Verifies that an action is switched from soft to forced if requested by management API */ - @Test void updateAction() throws Exception { + @Test + void updateAction() throws Exception { final Target target = testdataFactory.createTarget(); final DistributionSet set = testdataFactory.createDistributionSet(); final Long actionId = getFirstAssignedActionId( @@ -1652,7 +1706,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Verifies that a DOWNLOAD_ONLY DS to target assignment is properly handled */ - @Test void assignDownloadOnlyDistributionSetToTarget() throws Exception { + @Test + void assignDownloadOnlyDistributionSetToTarget() throws Exception { final Target target = testdataFactory.createTarget(); final DistributionSet set = testdataFactory.createDistributionSet("one"); @@ -1736,7 +1791,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Assigns distribution set to target with only maintenance schedule. */ - @Test void assignDistributionSetToTargetWithMaintenanceWindowStartTimeOnly() throws Exception { + @Test + void assignDistributionSetToTargetWithMaintenanceWindowStartTimeOnly() throws Exception { final Target target = testdataFactory.createTarget("fsdfsd"); final DistributionSet set = testdataFactory.createDistributionSet("one"); @@ -1753,7 +1809,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Assigns distribution set to target with only maintenance window duration. */ - @Test void assignDistributionSetToTargetWithMaintenanceWindowEndTimeOnly() throws Exception { + @Test + void assignDistributionSetToTargetWithMaintenanceWindowEndTimeOnly() throws Exception { final Target target = testdataFactory.createTarget("fsdfsd"); final DistributionSet set = testdataFactory.createDistributionSet("one"); @@ -1770,7 +1827,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Assigns distribution set to target with valid maintenance window. */ - @Test void assignDistributionSetToTargetWithValidMaintenanceWindow() throws Exception { + @Test + void assignDistributionSetToTargetWithValidMaintenanceWindow() throws Exception { final Target target = testdataFactory.createTarget("fsdfsd"); final DistributionSet set = testdataFactory.createDistributionSet("one"); @@ -1789,7 +1847,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Assigns distribution set to target with maintenance window next execution start (should be ignored, calculated automaticaly based on schedule, duration and timezone) */ - @Test void assignDistributionSetToTargetWithMaintenanceWindowNextExecutionStart() throws Exception { + @Test + void assignDistributionSetToTargetWithMaintenanceWindowNextExecutionStart() throws Exception { final Target target = testdataFactory.createTarget("fsdfsd"); final DistributionSet set = testdataFactory.createDistributionSet("one"); @@ -1815,7 +1874,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Assigns distribution set to target with last maintenance window scheduled before current time. */ - @Test void assignDistributionSetToTargetWithMaintenanceWindowEndTimeBeforeStartTime() throws Exception { + @Test + void assignDistributionSetToTargetWithMaintenanceWindowEndTimeBeforeStartTime() throws Exception { final Target target = testdataFactory.createTarget("fsdfsd"); final DistributionSet set = testdataFactory.createDistributionSet("one"); @@ -1974,7 +2034,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Request update of Controller Attributes. */ - @Test void triggerControllerAttributesUpdate() throws Exception { + @Test + void triggerControllerAttributesUpdate() throws Exception { // create target with attributes final String knownTargetId = "targetIdNeedsUpdate"; final Map knownControllerAttrs = new HashMap<>(); @@ -2038,7 +2099,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Ensures that the metadata creation through API is reflected by the repository. */ - @Test void createMetadata() throws Exception { + @Test + void createMetadata() throws Exception { final String knownControllerId = "targetIdWithMetadata"; testdataFactory.createTarget(knownControllerId); @@ -2082,7 +2144,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Ensures that a metadata update through API is reflected by the repository. */ - @Test void updateMetadata() throws Exception { + @Test + void updateMetadata() throws Exception { final String knownControllerId = "targetIdWithMetadata"; final String updateValue = "valueForUpdate"; @@ -2103,7 +2166,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Ensures that a metadata entry deletion through API is reflected by the repository. */ - @Test void deleteMetadata() throws Exception { + @Test + void deleteMetadata() throws Exception { final String knownControllerId = "targetIdWithMetadata"; setupTargetWithMetadata(knownControllerId, KNOWN_KEY, KNOWN_VALUE); @@ -2123,7 +2187,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Ensures that target metadata deletion request to API on an entity that does not exist results in NOT_FOUND. */ - @Test void deleteMetadataThatDoesNotExistLeadsToNotFound() throws Exception { + @Test + void deleteMetadataThatDoesNotExistLeadsToNotFound() throws Exception { final String knownControllerId = "targetIdWithMetadata"; setupTargetWithMetadata(knownControllerId, KNOWN_KEY, KNOWN_VALUE); @@ -2142,7 +2207,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Ensures that a metadata entry selection through API reflects the repository content. */ - @Test void getMetadataKey() throws Exception { + @Test + void getMetadataKey() throws Exception { final String knownControllerId = "targetIdWithMetadata"; setupTargetWithMetadata(knownControllerId, KNOWN_KEY, KNOWN_VALUE); @@ -2157,7 +2223,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Ensures that a metadata entry paged list selection through API reflectes the repository content. */ - @Test void getMetadata() throws Exception { + @Test + void getMetadata() throws Exception { final String knownControllerId = "targetIdWithMetadata"; final int totalMetadata = 10; @@ -2194,7 +2261,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * A request for assigning multiple DS to a target results in a Bad Request when multiassignment in disabled. */ - @Test void multiAssignmentRequestNotAllowedIfDisabled() throws Exception { + @Test + void multiAssignmentRequestNotAllowedIfDisabled() throws Exception { final String targetId = testdataFactory.createTarget().getControllerId(); final List dsIds = testdataFactory.createDistributionSets(2).stream().map(DistributionSet::getId) .toList(); @@ -2211,7 +2279,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Passing an array in assignment request is allowed if multiassignment is disabled and array size in 1. */ - @Test void multiAssignmentRequestAllowedIfDisabledButHasSizeOne() throws Exception { + @Test + void multiAssignmentRequestAllowedIfDisabledButHasSizeOne() throws Exception { final String targetId = testdataFactory.createTarget().getControllerId(); final Long dsId = testdataFactory.createDistributionSet().getId(); @@ -2225,7 +2294,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Identical assignments in a single request are removed when multiassignment in disabled. */ - @Test void identicalAssignmentInRequestAreRemovedIfMultiassignmentsDisabled() throws Exception { + @Test + void identicalAssignmentInRequestAreRemovedIfMultiassignmentsDisabled() throws Exception { final String targetId = testdataFactory.createTarget().getControllerId(); final Long dsId = testdataFactory.createDistributionSet().getId(); @@ -2242,7 +2312,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Assign multiple DSs to a target in one request with multiassignments enabled. */ - @Test void multiAssignment() throws Exception { + @Test + void multiAssignment() throws Exception { final String targetId = testdataFactory.createTarget().getControllerId(); final List dsIds = testdataFactory.createDistributionSets(2).stream().map(DistributionSet::getId) .toList(); @@ -2261,7 +2332,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * An assignment request containing a weight is only accepted when weight is valid and multi assignment is on. */ - @Test void weightValidation() throws Exception { + @Test + void weightValidation() throws Exception { final String targetId = testdataFactory.createTarget().getControllerId(); final Long dsId = testdataFactory.createDistributionSet().getId(); final int weight = 98; @@ -2288,7 +2360,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * An assignment request containing a valid weight when multi assignment is off. */ - @Test void weightWithSingleAssignment() throws Exception { + @Test + void weightWithSingleAssignment() throws Exception { final String targetId = testdataFactory.createTarget().getControllerId(); final Long dsId = testdataFactory.createDistributionSet().getId(); @@ -2303,7 +2376,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * An assignment request containing a valid weight when multi assignment is on. */ - @Test void weightWithMultiAssignment() throws Exception { + @Test + void weightWithMultiAssignment() throws Exception { final String targetId = testdataFactory.createTarget().getControllerId(); final Long dsId = testdataFactory.createDistributionSet().getId(); final int weight = 98; @@ -2324,7 +2398,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Get weight of action */ - @Test void getActionWeight() throws Exception { + @Test + void getActionWeight() throws Exception { final String targetId = testdataFactory.createTarget().getControllerId(); final Long dsId = testdataFactory.createDistributionSet().getId(); final int customWeightHigh = 800; @@ -2346,7 +2421,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * An action provides information of the rollout it was created for (if any). */ - @Test void getActionWithRolloutInfo() throws Exception { + @Test + void getActionWithRolloutInfo() throws Exception { // setup final int amountTargets = 10; @@ -2384,7 +2460,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Ensures that a post request for creating targets with target type works. */ - @Test void createTargetsWithTargetType() throws Exception { + @Test + void createTargetsWithTargetType() throws Exception { final TargetType type1 = testdataFactory.createTargetType("typeWithDs", Collections.singletonList(standardDsType)); final TargetType type2 = testdataFactory.createTargetType("typeWithOutDs", @@ -2454,7 +2531,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Ensures that a post request for creating target with target type works. */ - @Test void createTargetWithExistingTargetType() throws Exception { + @Test + void createTargetWithExistingTargetType() throws Exception { // create target type final List targetTypes = testdataFactory.createTargetTypes("targettype", 1); assertThat(targetTypes).hasSize(1); @@ -2478,7 +2556,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Ensures that a put request for updating targets with target type works. */ - @Test void updateTargetTypeInTarget() throws Exception { + @Test + void updateTargetTypeInTarget() throws Exception { // create target type final List targetTypes = testdataFactory.createTargetTypes("targettype", 2); assertThat(targetTypes).hasSize(2); @@ -2502,7 +2581,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Ensures that a post request for creating targets with unknown target type fails. */ - @Test void addingNonExistingTargetTypeInTargetShouldFail() throws Exception { + @Test + void addingNonExistingTargetTypeInTargetShouldFail() throws Exception { final long unknownTargetTypeId = 999; final String errorMsg = String.format("TargetType with given identifier {%s} does not exist.", unknownTargetTypeId); @@ -2525,7 +2605,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Ensures that a post request for assign target type to target works. */ - @Test void assignTargetTypeToTarget() throws Exception { + @Test + void assignTargetTypeToTarget() throws Exception { // create target type final TargetType targetType = testdataFactory.findOrCreateTargetType("targettype"); assertThat(targetType).isNotNull(); @@ -2548,7 +2629,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Ensures that a post request for assign a invalid target type to target fails. */ - @Test void assignInvalidTargetTypeToTargetFails() throws Exception { + @Test + void assignInvalidTargetTypeToTargetFails() throws Exception { // Invalid target type ID final long invalidTargetTypeId = 999; @@ -2582,7 +2664,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Ensures that a delete request for unassign target type from target works. */ - @Test void unassignTargetTypeFromTarget() throws Exception { + @Test + void unassignTargetTypeFromTarget() throws Exception { // create target type final List targetTypes = testdataFactory.createTargetTypes("targettype", 1); assertThat(targetTypes).hasSize(1); @@ -2745,7 +2828,8 @@ class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest { /** * Verifies that the status code that was reported in the last action status update is correctly exposed via the action. */ - @Test void lastActionStatusCode() throws Exception { + @Test + void lastActionStatusCode() throws Exception { // prepare test final DistributionSet dsA = testdataFactory.createDistributionSet(""); diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTagResourceTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTagResourceTest.java index b03096e4f..8de0af2ab 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTagResourceTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTagResourceTest.java @@ -62,7 +62,8 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT /** * Verifies that a paged result list of target tags reflects the content on the repository side. */ - @Test @ExpectEvents({ @Expect(type = TargetTagCreatedEvent.class, count = 2) }) + @Test + @ExpectEvents({ @Expect(type = TargetTagCreatedEvent.class, count = 2) }) public void getTargetTags() throws Exception { final List tags = testdataFactory.createTargetTags(2, ""); final TargetTag assigned = tags.get(0); @@ -85,7 +86,8 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT /** * Handles the GET request of retrieving all targets tags within SP based by parameter */ - @Test public void getTargetTagsWithParameters() throws Exception { + @Test + void getTargetTagsWithParameters() throws Exception { testdataFactory.createTargetTags(2, ""); mvc.perform(get(MgmtRestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "?limit=10&sort=name:ASC&offset=0&q=name==targetTag")) .andExpect(status().isOk()) @@ -95,7 +97,8 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT /** * Verifies that a page result when listing tags reflects on the content in the repository when filtered by 2 fields - one tag field and one target field */ - @Test public void getTargetTagsFilteredByColor() throws Exception { + @Test + void getTargetTagsFilteredByColor() throws Exception { final String controllerId1 = "controllerTestId1"; final String controllerId2 = "controllerTestId2"; testdataFactory.createTarget(controllerId1); @@ -126,7 +129,8 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT /** * Verifies that a single result of a target tag reflects the content on the repository side. */ - @Test @ExpectEvents({ @Expect(type = TargetTagCreatedEvent.class, count = 2) }) + @Test + @ExpectEvents({ @Expect(type = TargetTagCreatedEvent.class, count = 2) }) public void getTargetTag() throws Exception { final List tags = testdataFactory.createTargetTags(2, ""); final TargetTag assigned = tags.get(0); @@ -146,7 +150,8 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT /** * Verifies that created target tags are stored in the repository as send to the API. */ - @Test @ExpectEvents({ @Expect(type = TargetTagCreatedEvent.class, count = 2) }) + @Test + @ExpectEvents({ @Expect(type = TargetTagCreatedEvent.class, count = 2) }) public void createTargetTags() throws Exception { final Tag tagOne = entityFactory.tag().create().colour("testcol1").description("its a test1").name("thetest1") .build(); @@ -177,7 +182,8 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT /** * Verifies that an updated target tag is stored in the repository as send to the API. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetTagCreatedEvent.class, count = 1), @Expect(type = TargetTagUpdatedEvent.class, count = 1) }) public void updateTargetTag() throws Exception { @@ -207,7 +213,8 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT /** * Verifies that the delete call is reflected by the repository. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetTagCreatedEvent.class, count = 1), @Expect(type = TargetTagDeletedEvent.class, count = 1) }) public void deleteTargetTag() throws Exception { @@ -224,7 +231,8 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT /** * Ensures that assigned targets to tag in repository are listed with proper paging results. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetTagCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 5), @Expect(type = TargetUpdatedEvent.class, count = 5) }) @@ -245,7 +253,8 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT /** * Ensures that assigned DS to tag in repository are listed with proper paging results with paging limit parameter. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetTagCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 5), @Expect(type = TargetUpdatedEvent.class, count = 5) }) @@ -268,7 +277,8 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT /** * Ensures that assigned targets to tag in repository are listed with proper paging results with paging limit and offset parameter. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetTagCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 5), @Expect(type = TargetUpdatedEvent.class, count = 5) }) @@ -294,7 +304,8 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT /** * Verifies that tag assignments done through tag API command are correctly stored in the repository. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetTagCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 1) }) @@ -314,7 +325,8 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT /** * Verifies that tag assignments (multi targets) done through tag API command are correctly stored in the repository. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetTagCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 2), @Expect(type = TargetUpdatedEvent.class, count = 2) }) @@ -338,7 +350,8 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT /** * Verifies that tag assignments (multi targets) done through tag API command are correctly stored in the repository. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetTagCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 2) }) public void assignTargetsNotFound() throws Exception { @@ -378,7 +391,8 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT /** * Verifies that tag assignments (multi targets) done through tag API command are correctly stored in the repository. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetTagCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 2), @Expect(type = TargetUpdatedEvent.class, count = 2) }) @@ -421,7 +435,8 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT /** * Verifies that tag assignments (multi targets) done through tag API command are correctly stored in the repository. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetTagCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 2), @Expect(type = TargetUpdatedEvent.class, count = 2) }) @@ -455,7 +470,8 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT /** * Verifies that tag unassignments done through tag API command are correctly stored in the repository. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetTagCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 2), @Expect(type = TargetUpdatedEvent.class, count = 3) }) @@ -480,7 +496,8 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT /** * Verifies that tag unassignments (multi targets) done through tag API command are correctly stored in the repository. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetTagCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 3), @Expect(type = TargetUpdatedEvent.class, count = 5) }) @@ -507,7 +524,8 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT /** * Verifies that tag assignments (multi targets) done through tag API command are correctly stored in the repository. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetTagCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 2), @Expect(type = TargetUpdatedEvent.class, count = 2) }) @@ -551,7 +569,8 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT /** * Verifies that tag assignments (multi targets) done through tag API command are correctly stored in the repository. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetTagCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 2), @Expect(type = TargetUpdatedEvent.class, count = 4) }) @@ -595,7 +614,8 @@ public class MgmtTargetTagResourceTest extends AbstractManagementApiIntegrationT /** * Verifies that tag assignments (multi targets) done through tag API command are correctly stored in the repository. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetTagCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 2), @Expect(type = TargetUpdatedEvent.class, count = 4) }) diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTypeResourceTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTypeResourceTest.java index edd67ed47..b8c6f6770 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTypeResourceTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTargetTypeResourceTest.java @@ -503,7 +503,8 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest { /** * Ensures that the server is behaving as expected on invalid requests (wrong media type, wrong ID etc.). */ - @Test void invalidRequestsOnTargetTypesResource() throws Exception { + @Test + void invalidRequestsOnTargetTypesResource() throws Exception { String typeName = "TestTypeInvalidReq"; final TargetType testType = createTestTargetTypeInDB(typeName, Collections.singletonList(standardDsType)); @@ -604,7 +605,8 @@ class MgmtTargetTypeResourceTest extends AbstractManagementApiIntegrationTest { /** * Search request of target types. */ - @Test void searchTargetTypeRsql() throws Exception { + @Test + void searchTargetTypeRsql() throws Exception { targetTypeManagement.create(entityFactory.targetType().create().name("TestName123")); targetTypeManagement.create(entityFactory.targetType().create().name("TestName1234")); diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTenantManagementResourceTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTenantManagementResourceTest.java index 8b3f81811..9204066d5 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTenantManagementResourceTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtTenantManagementResourceTest.java @@ -51,7 +51,8 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg /** * Handles GET request for receiving all tenant specific configurations. */ - @Test public void getTenantConfigurations() throws Exception { + @Test + void getTenantConfigurations() throws Exception { mvc.perform(get(MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs")) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) @@ -64,7 +65,8 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg /** * Handles GET request for receiving a tenant specific configuration. */ - @Test public void getTenantConfiguration() throws Exception { + @Test + void getTenantConfiguration() throws Exception { //Test TenantConfiguration property mvc.perform(get(MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}", TenantConfigurationProperties.TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_KEY)) @@ -75,7 +77,8 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg /** * Handles GET request for receiving (TenantMetadata - DefaultDsType) a tenant specific configuration. */ - @Test public void getTenantMetadata() throws Exception { + @Test + void getTenantMetadata() throws Exception { //Test TenantMetadata property mvc.perform(get(MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}", DEFAULT_DISTRIBUTION_SET_TYPE_KEY)) @@ -87,7 +90,8 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg /** * Handles PUT request for settings values in tenant specific configuration. */ - @Test public void putTenantConfiguration() throws Exception { + @Test + void putTenantConfiguration() throws Exception { final MgmtSystemTenantConfigurationValueRequest bodyPut = new MgmtSystemTenantConfigurationValueRequest(); bodyPut.setValue("exampleToken"); final ObjectMapper mapper = new ObjectMapper(); @@ -103,7 +107,8 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg /** * Handles PUT request for settings values (TenantMetadata - DefaultDsType) in tenant specific configuration, which is TenantMetadata */ - @Test public void putTenantMetadata() throws Exception { + @Test + void putTenantMetadata() throws Exception { final MgmtSystemTenantConfigurationValueRequest bodyPut = new MgmtSystemTenantConfigurationValueRequest(); long updatedTestDefaultDsType = createTestDistributionSetType(); @@ -126,7 +131,8 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg /** * Update DefaultDistributionSetType Fails if given DistributionSetType ID does not exist. */ - @Test public void putTenantMetadataFails() throws Exception { + @Test + void putTenantMetadataFails() throws Exception { long oldDefaultDsType = getActualDefaultDsType(); //try an invalid input String newDefaultDsType = new JSONObject().put("value", true).toString(); @@ -142,7 +148,8 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg /** * The 'multi.assignments.enabled' property must not be changed to false. */ - @Test public void deactivateMultiAssignment() throws Exception { + @Test + void deactivateMultiAssignment() throws Exception { final String bodyActivate = new JSONObject().put("value", true).toString(); final String bodyDeactivate = new JSONObject().put("value", false).toString(); @@ -160,7 +167,8 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg /** * The Batch configuration should not be applied, because of invalid TenantConfiguration props */ - @Test public void changeBatchConfigurationShouldFailOnInvalidTenantConfiguration() throws Exception { + @Test + void changeBatchConfigurationShouldFailOnInvalidTenantConfiguration() throws Exception { //in this scenario // some TenantConfiguration are not valid, // TenantMetadata - DefaultDSType ID is valid, @@ -176,7 +184,8 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg /** * The Batch configuration should not be applied, because of invalid TenantMetadata (DefaultDistributionSetType) */ - @Test public void changeBatchConfigurationShouldOnInvalidTenantMetadata() throws Exception { + @Test + void changeBatchConfigurationShouldOnInvalidTenantMetadata() throws Exception { //in this scenario // all TenantConfiguration have valid and new values - using old values, inverted // TenantMetadata - DefaultDSType ID is invalid @@ -208,7 +217,8 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg /** * The Batch configuration should be applied */ - @Test public void changeBatchConfiguration() throws Exception { + @Test + void changeBatchConfiguration() throws Exception { long updatedDistributionSetType = createTestDistributionSetType(); boolean updatedRolloutApprovalEnabled = true; boolean updatedAuthGatewayTokenEnabled = true; @@ -242,7 +252,8 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg /** * The 'repository.actions.autoclose.enabled' property must not be modified if Multi-Assignments is enabled. */ - @Test public void autoCloseCannotBeModifiedIfMultiAssignmentIsEnabled() throws Exception { + @Test + void autoCloseCannotBeModifiedIfMultiAssignmentIsEnabled() throws Exception { final String bodyActivate = new JSONObject().put("value", true).toString(); final String bodyDeactivate = new JSONObject().put("value", false).toString(); @@ -268,7 +279,8 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg /** * Handles DELETE request deleting a tenant specific configuration. */ - @Test public void deleteTenantConfiguration() throws Exception { + @Test + void deleteTenantConfiguration() throws Exception { mvc.perform(delete(MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}", TenantConfigurationProperties.TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_KEY)) .andDo(MockMvcResultPrinter.print()) @@ -278,7 +290,8 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg /** * Tests DELETE request must Fail for TenantMetadata properties. */ - @Test public void deleteTenantMetadataFail() throws Exception { + @Test + void deleteTenantMetadataFail() throws Exception { mvc.perform(delete(MgmtRestConstants.SYSTEM_V1_REQUEST_MAPPING + "/configs/{keyName}", DEFAULT_DISTRIBUTION_SET_TYPE_KEY)) .andDo(MockMvcResultPrinter.print()) @@ -288,7 +301,8 @@ public class MgmtTenantManagementResourceTest extends AbstractManagementApiInteg /** * Handles GET request for receiving all tenant specific configurations depending on read gateway token permissions. */ - @Test void getTenantConfigurationReadGWToken() throws Exception { + @Test + void getTenantConfigurationReadGWToken() throws Exception { SecurityContextSwitch.runAs(SecurityContextSwitch.withUser("tenant_admin", SpPermission.TENANT_CONFIGURATION), () -> { tenantConfigurationManagement.addOrUpdateConfiguration( TenantConfigurationProperties.TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_KEY, diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/util/SortUtilityTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/util/SortUtilityTest.java index 17b062760..28f42e44c 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/util/SortUtilityTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/util/SortUtilityTest.java @@ -38,7 +38,8 @@ class SortUtilityTest { /** * Ascending sorting based on name. */ - @Test void parseSortParam1() { + @Test + void parseSortParam1() { final List parse = SortUtility.parse(TargetFields.class, SORT_PARAM_1); assertThat(parse).as("Count of parsing parameter").hasSize(1); } @@ -46,7 +47,8 @@ class SortUtilityTest { /** * Ascending sorting based on name and descending sorting based on description. */ - @Test void parseSortParam2() { + @Test + void parseSortParam2() { final List parse = SortUtility.parse(TargetFields.class, SORT_PARAM_2); assertThat(parse).as("Count of parsing parameter").hasSize(2); } @@ -54,7 +56,8 @@ class SortUtilityTest { /** * Sorting with wrong syntax leads to SortParameterSyntaxErrorException. */ - @Test void parseWrongSyntaxParam() { + @Test + void parseWrongSyntaxParam() { assertThrows(SortParameterSyntaxErrorException.class, () -> SortUtility.parse(TargetFields.class, SYNTAX_FAILURE_SORT_PARAM)); } @@ -62,7 +65,8 @@ class SortUtilityTest { /** * Sorting based on name with case sensitive is possible. */ - @Test @SuppressWarnings("squid:S2699") // assert no error + @Test + @SuppressWarnings("squid:S2699") // assert no error void parsingIsNotCaseSensitive() { SortUtility.parse(TargetFields.class, CASE_INSENSITIVE_DIRECTION_PARAM); SortUtility.parse(TargetFields.class, CASE_INSENSITIVE_DIRECTION_PARAM_1); @@ -71,7 +75,8 @@ class SortUtilityTest { /** * Sorting with unknown direction order leads to SortParameterUnsupportedDirectionException. */ - @Test void parseWrongDirectionParam() { + @Test + void parseWrongDirectionParam() { assertThrows(SortParameterUnsupportedDirectionException.class, () -> SortUtility.parse(TargetFields.class, WRONG_DIRECTION_PARAM)); } @@ -79,7 +84,8 @@ class SortUtilityTest { /** * Sorting with unknown field leads to SortParameterUnsupportedFieldException. */ - @Test void parseWrongFieldParam() { + @Test + void parseWrongFieldParam() { assertThrows(SortParameterUnsupportedFieldException.class, () -> SortUtility.parse(TargetFields.class, WRONG_FIELD_PARAM)); } diff --git a/hawkbit-mgmt/hawkbit-mgmt-server/src/test/java/org/eclipse/hawkbit/app/mgmt/AllowedHostNamesTest.java b/hawkbit-mgmt/hawkbit-mgmt-server/src/test/java/org/eclipse/hawkbit/app/mgmt/AllowedHostNamesTest.java index f3b8d3866..6a2b507e5 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-server/src/test/java/org/eclipse/hawkbit/app/mgmt/AllowedHostNamesTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-server/src/test/java/org/eclipse/hawkbit/app/mgmt/AllowedHostNamesTest.java @@ -28,21 +28,24 @@ class AllowedHostNamesTest extends AbstractSecurityTest { /** * Tests whether a RequestRejectedException is thrown when not allowed host is used */ - @Test void allowedHostNameWithNotAllowedHost() throws Exception { + @Test + void allowedHostNameWithNotAllowedHost() throws Exception { mvc.perform(get("/").header(HttpHeaders.HOST, "www.google.com")).andExpect(status().isBadRequest()); } /** * Tests whether request is redirected when allowed host is used */ - @Test void allowedHostNameWithAllowedHost() throws Exception { + @Test + void allowedHostNameWithAllowedHost() throws Exception { mvc.perform(get("/").header(HttpHeaders.HOST, "localhost")).andExpect(status().is3xxRedirection()); } /** * Tests whether request without allowed host name and with ignored path end up with a client error */ - @Test void notAllowedHostnameWithIgnoredPath() throws Exception { + @Test + void notAllowedHostnameWithIgnoredPath() throws Exception { mvc.perform(get("/index.html").header(HttpHeaders.HOST, "www.google.com")) .andExpect(status().is4xxClientError()); } 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 9b16db97f..18fd18f0c 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 @@ -46,7 +46,8 @@ class CorsTest extends AbstractSecurityTest { /** * Ensures that Cors is working. */ - @Test @WithUser(authorities = SpRole.TENANT_ADMIN, autoCreateTenant = false) + @Test + @WithUser(authorities = SpRole.TENANT_ADMIN, autoCreateTenant = false) void validateCorsRequest() throws Exception { performOptionsRequestToRestWithOrigin(ALLOWED_ORIGIN_FIRST).andExpect(status().isOk()) .andExpect(header().string(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN, ALLOWED_ORIGIN_FIRST)); diff --git a/hawkbit-mgmt/hawkbit-mgmt-server/src/test/java/org/eclipse/hawkbit/app/mgmt/PreAuthorizeEnabledTest.java b/hawkbit-mgmt/hawkbit-mgmt-server/src/test/java/org/eclipse/hawkbit/app/mgmt/PreAuthorizeEnabledTest.java index 76e17a98d..06efb14be 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-server/src/test/java/org/eclipse/hawkbit/app/mgmt/PreAuthorizeEnabledTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-server/src/test/java/org/eclipse/hawkbit/app/mgmt/PreAuthorizeEnabledTest.java @@ -30,7 +30,8 @@ class PreAuthorizeEnabledTest extends AbstractSecurityTest { /** * Tests whether request fail if a role is forbidden for the user */ - @Test @WithUser(authorities = { SpPermission.READ_TARGET }, autoCreateTenant = false) + @Test + @WithUser(authorities = { SpPermission.READ_TARGET }, autoCreateTenant = false) void failIfNoRole() throws Exception { mvc.perform(get("/rest/v1/distributionsets")).andExpect(result -> assertThat(result.getResponse().getStatus()).isEqualTo(HttpStatus.FORBIDDEN.value())); @@ -39,7 +40,8 @@ class PreAuthorizeEnabledTest extends AbstractSecurityTest { /** * Tests whether request succeed if a role is granted for the user */ - @Test @WithUser(authorities = { SpPermission.READ_REPOSITORY }, autoCreateTenant = false) + @Test + @WithUser(authorities = { SpPermission.READ_REPOSITORY }, autoCreateTenant = false) void successIfHasRole() throws Exception { mvc.perform(get("/rest/v1/distributionsets")).andExpect(result -> assertThat(result.getResponse().getStatus()).isEqualTo(HttpStatus.OK.value())); @@ -48,7 +50,8 @@ class PreAuthorizeEnabledTest extends AbstractSecurityTest { /** * Tests whether request succeed if a role is granted for the user */ - @Test @WithUser(authorities = { SpRole.TENANT_ADMIN }, autoCreateTenant = false) + @Test + @WithUser(authorities = { SpRole.TENANT_ADMIN }, autoCreateTenant = false) void successIfHasTenantAdminRole() throws Exception { mvc.perform(get("/rest/v1/distributionsets")).andExpect(result -> assertThat(result.getResponse().getStatus()).isEqualTo(HttpStatus.OK.value())); @@ -57,7 +60,8 @@ class PreAuthorizeEnabledTest extends AbstractSecurityTest { /** * Tests whether read tenant config request fail if a tenant config (or read read) is not granted for the user */ - @Test @WithUser(authorities = { SpPermission.READ_TARGET }, autoCreateTenant = false) + @Test + @WithUser(authorities = { SpPermission.READ_TARGET }, autoCreateTenant = false) void onlyDSIfNoTenantConfig() throws Exception { mvc.perform(get("/rest/v1/system/configs")).andExpect(result -> { // returns default DS type because of READ_TARGET @@ -70,7 +74,8 @@ class PreAuthorizeEnabledTest extends AbstractSecurityTest { /** * Tests whether read tenant config request succeed if a tenant config (not read explicitly) is granted for the user */ - @Test @WithUser(authorities = { SpPermission.TENANT_CONFIGURATION }, autoCreateTenant = false) + @Test + @WithUser(authorities = { SpPermission.TENANT_CONFIGURATION }, autoCreateTenant = false) void successIfHasTenantConfig() throws Exception { mvc.perform(get("/rest/v1/system/configs")).andExpect(result -> assertThat(result.getResponse().getStatus()).isEqualTo(HttpStatus.OK.value())); diff --git a/hawkbit-monolith/hawkbit-update-server/src/test/java/org/eclipse/hawkbit/app/AllowedHostNamesTest.java b/hawkbit-monolith/hawkbit-update-server/src/test/java/org/eclipse/hawkbit/app/AllowedHostNamesTest.java index cdaa4d877..0eb48d7c8 100644 --- a/hawkbit-monolith/hawkbit-update-server/src/test/java/org/eclipse/hawkbit/app/AllowedHostNamesTest.java +++ b/hawkbit-monolith/hawkbit-update-server/src/test/java/org/eclipse/hawkbit/app/AllowedHostNamesTest.java @@ -29,21 +29,24 @@ class AllowedHostNamesTest extends AbstractSecurityTest { /** * Tests whether a RequestRejectedException is thrown when not allowed host is used */ - @Test void allowedHostNameWithNotAllowedHost() throws Exception { + @Test + void allowedHostNameWithNotAllowedHost() throws Exception { mvc.perform(get("/").header(HttpHeaders.HOST, "www.google.com")).andExpect(status().isBadRequest()); } /** * Tests whether request is redirected when allowed host is used */ - @Test void allowedHostNameWithAllowedHost() throws Exception { + @Test + void allowedHostNameWithAllowedHost() throws Exception { mvc.perform(get("/").header(HttpHeaders.HOST, "localhost")).andExpect(status().is3xxRedirection()); } /** * Tests whether request without allowed host name and with ignored path end up with a client error */ - @Test void notAllowedHostnameWithIgnoredPath() throws Exception { + @Test + void notAllowedHostnameWithIgnoredPath() throws Exception { mvc.perform(get("/index.html").header(HttpHeaders.HOST, "www.google.com")) .andExpect(status().is4xxClientError()); } 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 750b401f3..36bf3ab03 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 @@ -46,7 +46,8 @@ class CorsTest extends AbstractSecurityTest { /** * Ensures that Cors is working. */ - @Test @WithUser(authorities = SpRole.TENANT_ADMIN, autoCreateTenant = false) + @Test + @WithUser(authorities = SpRole.TENANT_ADMIN, autoCreateTenant = false) void validateCorsRequest() throws Exception { performOptionsRequestToRestWithOrigin(ALLOWED_ORIGIN_FIRST).andExpect(status().isOk()) .andExpect(header().string(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN, ALLOWED_ORIGIN_FIRST)); diff --git a/hawkbit-monolith/hawkbit-update-server/src/test/java/org/eclipse/hawkbit/app/PreAuthorizeEnabledTest.java b/hawkbit-monolith/hawkbit-update-server/src/test/java/org/eclipse/hawkbit/app/PreAuthorizeEnabledTest.java index d4c333ba7..71aeb62b5 100644 --- a/hawkbit-monolith/hawkbit-update-server/src/test/java/org/eclipse/hawkbit/app/PreAuthorizeEnabledTest.java +++ b/hawkbit-monolith/hawkbit-update-server/src/test/java/org/eclipse/hawkbit/app/PreAuthorizeEnabledTest.java @@ -30,7 +30,8 @@ class PreAuthorizeEnabledTest extends AbstractSecurityTest { /** * Tests whether request fail if a role is forbidden for the user */ - @Test @WithUser(authorities = { SpPermission.READ_TARGET }, autoCreateTenant = false) + @Test + @WithUser(authorities = { SpPermission.READ_TARGET }, autoCreateTenant = false) void failIfNoRole() throws Exception { mvc.perform(get("/rest/v1/distributionsets")) .andExpect(result -> assertThat(result.getResponse().getStatus()).isEqualTo(HttpStatus.FORBIDDEN.value())); @@ -39,7 +40,8 @@ class PreAuthorizeEnabledTest extends AbstractSecurityTest { /** * Tests whether request succeed if a role is granted for the user */ - @Test @WithUser(authorities = { SpPermission.READ_REPOSITORY }, autoCreateTenant = false) + @Test + @WithUser(authorities = { SpPermission.READ_REPOSITORY }, autoCreateTenant = false) void successIfHasRole() throws Exception { mvc.perform(get("/rest/v1/distributionsets")) .andExpect(result -> assertThat(result.getResponse().getStatus()).isEqualTo(HttpStatus.OK.value())); @@ -48,7 +50,8 @@ class PreAuthorizeEnabledTest extends AbstractSecurityTest { /** * Tests whether request succeed if a role is granted for the user */ - @Test @WithUser(authorities = { SpRole.TENANT_ADMIN }, autoCreateTenant = false) + @Test + @WithUser(authorities = { SpRole.TENANT_ADMIN }, autoCreateTenant = false) void successIfHasTenantAdminRole() throws Exception { mvc.perform(get("/rest/v1/distributionsets")) .andExpect(result -> assertThat(result.getResponse().getStatus()).isEqualTo(HttpStatus.OK.value())); @@ -57,7 +60,8 @@ class PreAuthorizeEnabledTest extends AbstractSecurityTest { /** * Tests whether read tenant config request fail if a tenant config (or read read) is not granted for the user */ - @Test @WithUser(authorities = { SpPermission.READ_TARGET }, autoCreateTenant = false) + @Test + @WithUser(authorities = { SpPermission.READ_TARGET }, autoCreateTenant = false) void onlyDSIfNoTenantConfig() throws Exception { mvc.perform(get("/rest/v1/system/configs")) .andExpect(result -> { @@ -71,7 +75,8 @@ class PreAuthorizeEnabledTest extends AbstractSecurityTest { /** * Tests whether read tenant config request succeed if a tenant config (not read explicitly) is granted for the user */ - @Test @WithUser(authorities = { SpPermission.TENANT_CONFIGURATION }, autoCreateTenant = false) + @Test + @WithUser(authorities = { SpPermission.TENANT_CONFIGURATION }, autoCreateTenant = false) void successIfHasTenantConfig() throws Exception { mvc.perform(get("/rest/v1/system/configs")) .andExpect(result -> assertThat(result.getResponse().getStatus()).isEqualTo(HttpStatus.OK.value())); diff --git a/hawkbit-repository/hawkbit-repository-api/src/test/java/org/eclipse/hawkbit/repository/ArtifactEncryptionServiceTest.java b/hawkbit-repository/hawkbit-repository-api/src/test/java/org/eclipse/hawkbit/repository/ArtifactEncryptionServiceTest.java index 67f578650..1f85134ef 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/test/java/org/eclipse/hawkbit/repository/ArtifactEncryptionServiceTest.java +++ b/hawkbit-repository/hawkbit-repository-api/src/test/java/org/eclipse/hawkbit/repository/ArtifactEncryptionServiceTest.java @@ -27,7 +27,8 @@ class ArtifactEncryptionServiceTest { /** * Verify that no artifact encryption support is given */ - @Test void verifyNoArtifactEncryptionSupport() { + @Test + void verifyNoArtifactEncryptionSupport() { final ArtifactEncryptionService artifactEncryptionService = ArtifactEncryptionService.getInstance(); assertThat(artifactEncryptionService.isEncryptionSupported()).isFalse(); diff --git a/hawkbit-repository/hawkbit-repository-api/src/test/java/org/eclipse/hawkbit/repository/MaintenanceScheduleHelperTest.java b/hawkbit-repository/hawkbit-repository-api/src/test/java/org/eclipse/hawkbit/repository/MaintenanceScheduleHelperTest.java index b68ab374e..7b5daf3ce 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/test/java/org/eclipse/hawkbit/repository/MaintenanceScheduleHelperTest.java +++ b/hawkbit-repository/hawkbit-repository-api/src/test/java/org/eclipse/hawkbit/repository/MaintenanceScheduleHelperTest.java @@ -28,7 +28,8 @@ class MaintenanceScheduleHelperTest { /** * Verifies that the Cron object is returned for valid cron expression */ - @Test void getCronFromExpressionValid() { + @Test + void getCronFromExpressionValid() { final String validCron = "0 0 0 ? * 6"; // at 00:00 every Saturday assertThat(MaintenanceScheduleHelper.getCronFromExpression(validCron)).isNotNull().isInstanceOf(Cron.class); } @@ -36,7 +37,8 @@ class MaintenanceScheduleHelperTest { /** * Verifies that the Duration object is returned for valid duration format (hh:mm or hh:mm:ss) */ - @Test void convertToISODurationValid() { + @Test + void convertToISODurationValid() { final String duration = "00:10"; assertThat(MaintenanceScheduleHelper.convertToISODuration(duration)).isNotNull().isInstanceOf(Duration.class); } @@ -44,7 +46,8 @@ class MaintenanceScheduleHelperTest { /** * Verifies that the InvalidMaintenanceScheduleException is thrown for invalid duration format */ - @Test void validateDurationInvalid() { + @Test + void validateDurationInvalid() { final String duration = "10"; assertThatThrownBy(() -> MaintenanceScheduleHelper.validateDuration(duration)) .isInstanceOf(InvalidMaintenanceScheduleException.class).hasMessage("Provided duration is not valid") @@ -54,7 +57,8 @@ class MaintenanceScheduleHelperTest { /** * Verifies that the InvalidMaintenanceScheduleException is thrown for invalid cron expression */ - @Test void validateCronScheduleInvalid() { + @Test + void validateCronScheduleInvalid() { final String invalidCron = "0 0 0 * * 6"; assertThatThrownBy(() -> MaintenanceScheduleHelper.validateCronSchedule(invalidCron)) .isInstanceOf(InvalidMaintenanceScheduleException.class) @@ -64,7 +68,8 @@ class MaintenanceScheduleHelperTest { /** * Verifies that there is a maintenance window available for correct schedule, duration and timezone */ - @Test void getNextMaintenanceWindowValid() { + @Test + void getNextMaintenanceWindowValid() { final ZonedDateTime currentTime = ZonedDateTime.now(); final String cronSchedule = String.format("0 %d %d %d %d ? %d", currentTime.getMinute(), currentTime.getHour(), currentTime.getDayOfMonth(), currentTime.getMonthValue(), currentTime.getYear()); @@ -76,7 +81,8 @@ class MaintenanceScheduleHelperTest { /** * Verifies the maintenance schedule when only one required field is present */ - @Test void validateMaintenanceScheduleAtLeastOneNotEmpty() { + @Test + void validateMaintenanceScheduleAtLeastOneNotEmpty() { final String duration = "00:10"; assertThatThrownBy(() -> MaintenanceScheduleHelper.validateMaintenanceSchedule(null, duration, null)) .isInstanceOf(InvalidMaintenanceScheduleException.class) @@ -86,7 +92,8 @@ class MaintenanceScheduleHelperTest { /** * Verifies that there is no valid maintenance window available, scheduled before current time */ - @Test void validateMaintenanceScheduleBeforeCurrentTime() { + @Test + void validateMaintenanceScheduleBeforeCurrentTime() { ZonedDateTime currentTime = ZonedDateTime.now(); currentTime = currentTime.plusMinutes(-30); final String cronSchedule = String.format("0 %d %d %d %d ? %d", currentTime.getMinute(), currentTime.getHour(), diff --git a/hawkbit-repository/hawkbit-repository-api/src/test/java/org/eclipse/hawkbit/repository/RegexCharTest.java b/hawkbit-repository/hawkbit-repository-api/src/test/java/org/eclipse/hawkbit/repository/RegexCharTest.java index 1ab2986e5..b508b58ec 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/test/java/org/eclipse/hawkbit/repository/RegexCharTest.java +++ b/hawkbit-repository/hawkbit-repository-api/src/test/java/org/eclipse/hawkbit/repository/RegexCharTest.java @@ -27,7 +27,8 @@ class RegexCharTest { /** * Verifies every RegexChar can be used to exclusively find the desired characters in a String. */ - @Test void allRegexCharsOnlyFindExpectedChars() { + @Test + void allRegexCharsOnlyFindExpectedChars() { for (final RegexChar character : RegexChar.values()) { switch (character) { case DIGITS: @@ -52,7 +53,8 @@ class RegexCharTest { /** * Verifies that combinations of RegexChars can be used to find the desired characters in a String. */ - @Test void combinedRegexCharsFindExpectedChars() { + @Test + void combinedRegexCharsFindExpectedChars() { final RegexCharacterCollection greaterAndLessThan = new RegexCharacterCollection(RegexChar.GREATER_THAN, RegexChar.LESS_THAN); final RegexCharacterCollection equalsAndQuestionMark = new RegexCharacterCollection(RegexChar.EQUALS_SYMBOL, diff --git a/hawkbit-repository/hawkbit-repository-api/src/test/java/org/eclipse/hawkbit/repository/RepositoryManagementMethodPreAuthorizeAnnotatedTest.java b/hawkbit-repository/hawkbit-repository-api/src/test/java/org/eclipse/hawkbit/repository/RepositoryManagementMethodPreAuthorizeAnnotatedTest.java index fcd89f329..da89b8c34 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/test/java/org/eclipse/hawkbit/repository/RepositoryManagementMethodPreAuthorizeAnnotatedTest.java +++ b/hawkbit-repository/hawkbit-repository-api/src/test/java/org/eclipse/hawkbit/repository/RepositoryManagementMethodPreAuthorizeAnnotatedTest.java @@ -35,7 +35,8 @@ class RepositoryManagementMethodPreAuthorizeAnnotatedTest { /** * Verifies that repository methods are @PreAuthorize annotated */ - @Test void repositoryManagementMethodsArePreAuthorizedAnnotated() { + @Test + void repositoryManagementMethodsArePreAuthorizedAnnotated() { final String packageName = getClass().getPackage().getName(); try (final ScanResult scanResult = new ClassGraph().acceptPackages(packageName).scan()) { final List> matchingClasses = scanResult.getAllClasses() diff --git a/hawkbit-repository/hawkbit-repository-api/src/test/java/org/eclipse/hawkbit/repository/model/TotalTargetCountStatusTest.java b/hawkbit-repository/hawkbit-repository-api/src/test/java/org/eclipse/hawkbit/repository/model/TotalTargetCountStatusTest.java index 46a740c08..7e1918ec0 100644 --- a/hawkbit-repository/hawkbit-repository-api/src/test/java/org/eclipse/hawkbit/repository/model/TotalTargetCountStatusTest.java +++ b/hawkbit-repository/hawkbit-repository-api/src/test/java/org/eclipse/hawkbit/repository/model/TotalTargetCountStatusTest.java @@ -71,7 +71,8 @@ class TotalTargetCountStatusTest { /** * DownloadOnly actions should be displayed as FINISHED when they have ActionStatus.DOWNLOADED */ - @Test void shouldCorrectlyMapActionStatusesInDownloadOnlyCase() { + @Test + void shouldCorrectlyMapActionStatusesInDownloadOnlyCase() { TotalTargetCountStatus status = new TotalTargetCountStatus(targetCountActionStatuses, 55L, Action.ActionType.DOWNLOAD_ONLY); assertThat(status.getTotalTargetCountByStatus(TotalTargetCountStatus.Status.SCHEDULED)).isEqualTo(1L); 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 19a3f3d4d..a6fbd61b4 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 @@ -47,7 +47,8 @@ class BusProtoStuffMessageConverterTest { /** * Verifies that the TargetCreatedEvent can be successfully serialized and deserialized */ - @Test void successfullySerializeAndDeserializeEvent() { + @Test + void successfullySerializeAndDeserializeEvent() { final TargetCreatedEvent targetCreatedEvent = new TargetCreatedEvent(targetMock, "1"); // serialize final Object serializedEvent = underTest.convertToInternal(targetCreatedEvent, @@ -65,7 +66,8 @@ class BusProtoStuffMessageConverterTest { /** * Verifies that a MessageConversationException is thrown on missing event-type information encoding */ - @Test void missingEventTypeMappingThrowsMessageConversationException() { + @Test + void missingEventTypeMappingThrowsMessageConversationException() { final DummyRemoteEntityEvent dummyEvent = new DummyRemoteEntityEvent(targetMock, "applicationId"); final MessageHeaders messageHeaders = new MessageHeaders(new HashMap<>()); diff --git a/hawkbit-repository/hawkbit-repository-jpa-eclipselink/src/test/java/org/eclipse/hawkbit/repository/jpa/HawkBitEclipseLinkJpaDialectTest.java b/hawkbit-repository/hawkbit-repository-jpa-eclipselink/src/test/java/org/eclipse/hawkbit/repository/jpa/HawkBitEclipseLinkJpaDialectTest.java index c925b5cd8..3e07332de 100644 --- a/hawkbit-repository/hawkbit-repository-jpa-eclipselink/src/test/java/org/eclipse/hawkbit/repository/jpa/HawkBitEclipseLinkJpaDialectTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa-eclipselink/src/test/java/org/eclipse/hawkbit/repository/jpa/HawkBitEclipseLinkJpaDialectTest.java @@ -35,7 +35,8 @@ class HawkBitEclipseLinkJpaDialectTest { /** * Use Case: PersistenceException that can be mapped by EclipseLinkJpaDialect into corresponding DataAccessException. */ - @Test void jpaOptimisticLockExceptionIsConcurrencyFailureException() { + @Test + void jpaOptimisticLockExceptionIsConcurrencyFailureException() { assertThat(hawkBitEclipseLinkJpaDialectUnderTest.translateExceptionIfPossible(mock(OptimisticLockException.class))) .isInstanceOf(ConcurrencyFailureException.class); } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/RemoteIdEventTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/RemoteIdEventTest.java index 7b4d21352..283793aaf 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/RemoteIdEventTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/RemoteIdEventTest.java @@ -37,21 +37,24 @@ class RemoteIdEventTest extends AbstractRemoteEventTest { /** * Verifies that the ds id is correct reloaded */ - @Test void testDistributionSetDeletedEvent() { + @Test + void testDistributionSetDeletedEvent() { assertAndCreateRemoteEvent(DistributionSetDeletedEvent.class); } /** * Verifies that the ds tag id is correct reloaded */ - @Test void testDistributionSetTagDeletedEvent() { + @Test + void testDistributionSetTagDeletedEvent() { assertAndCreateRemoteEvent(DistributionSetTagDeletedEvent.class); } /** * Verifies that the target id is correct reloaded */ - @Test void testTargetDeletedEvent() { + @Test + void testTargetDeletedEvent() { final TargetDeletedEvent deletedEvent = new TargetDeletedEvent(TENANT, ENTITY_ID, CONTROLLER_ID, ADDRESS, ENTITY_CLASS, NODE); assertEntity(deletedEvent); @@ -60,21 +63,24 @@ class RemoteIdEventTest extends AbstractRemoteEventTest { /** * Verifies that the target tag id is correct reloaded */ - @Test void testTargetTagDeletedEvent() { + @Test + void testTargetTagDeletedEvent() { assertAndCreateRemoteEvent(TargetTagDeletedEvent.class); } /** * Verifies that the software module id is correct reloaded */ - @Test void testSoftwareModuleDeletedEvent() { + @Test + void testSoftwareModuleDeletedEvent() { assertAndCreateRemoteEvent(SoftwareModuleDeletedEvent.class); } /** * Verifies that the rollout id is correct reloaded */ - @Test void testRolloutDeletedEvent() { + @Test + void testRolloutDeletedEvent() { assertAndCreateRemoteEvent(RolloutDeletedEvent.class); } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/RemoteTenantAwareEventTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/RemoteTenantAwareEventTest.java index 0d88d3c4a..3d5fd5b36 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/RemoteTenantAwareEventTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/RemoteTenantAwareEventTest.java @@ -33,7 +33,8 @@ class RemoteTenantAwareEventTest extends AbstractRemoteEventTest { /** * Verifies that a testMultiActionAssignEvent can be properly serialized and deserialized */ - @Test void testMultiActionAssignEvent() { + @Test + void testMultiActionAssignEvent() { final List controllerIds = List.of("id0", "id1", "id2", "id3", "id4loooooooooooooooooooooooooooooooooooonnnnnnnnnnnnnnnnnng"); final List actions = controllerIds.stream().map(this::createAction).toList(); @@ -52,7 +53,8 @@ class RemoteTenantAwareEventTest extends AbstractRemoteEventTest { /** * Verifies that a MultiActionCancelEvent can be properly serialized and deserialized */ - @Test void testMultiActionCancelEvent() { + @Test + void testMultiActionCancelEvent() { final List controllerIds = List.of("id0", "id1", "id2", "id3", "id4loooooooooooooooooooooooooooooooooooonnnnnnnnnnnnnnnnnng"); final List actions = controllerIds.stream().map(this::createAction).toList(); @@ -71,7 +73,8 @@ class RemoteTenantAwareEventTest extends AbstractRemoteEventTest { /** * Verifies that a DownloadProgressEvent can be properly serialized and deserialized */ - @Test void reloadDownloadProgressByRemoteEvent() { + @Test + void reloadDownloadProgressByRemoteEvent() { final DownloadProgressEvent downloadProgressEvent = new DownloadProgressEvent(TENANT_DEFAULT, 1L, 3L, APPLICATION_ID_DEFAULT); @@ -85,7 +88,8 @@ class RemoteTenantAwareEventTest extends AbstractRemoteEventTest { /** * Verifies that a TargetAssignDistributionSetEvent can be properly serialized and deserialized */ - @Test void testTargetAssignDistributionSetEvent() { + @Test + void testTargetAssignDistributionSetEvent() { final DistributionSet dsA = testdataFactory.createDistributionSet(""); @@ -113,7 +117,8 @@ class RemoteTenantAwareEventTest extends AbstractRemoteEventTest { /** * Verifies that a TargetAssignDistributionSetEvent can be properly serialized and deserialized */ - @Test void testCancelTargetAssignmentEvent() { + @Test + void testCancelTargetAssignmentEvent() { final DistributionSet dsA = testdataFactory.createDistributionSet(""); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/entity/ActionEventTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/entity/ActionEventTest.java index 7932ea44c..905081678 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/entity/ActionEventTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/entity/ActionEventTest.java @@ -30,14 +30,16 @@ class ActionEventTest extends AbstractRemoteEntityEventTest { /** * Verifies that the action entity reloading by remote created works */ - @Test void testActionCreatedEvent() { + @Test + void testActionCreatedEvent() { assertAndCreateRemoteEvent(ActionCreatedEvent.class); } /** * Verifies that the action entity reloading by remote updated works */ - @Test void testActionUpdatedEvent() { + @Test + void testActionUpdatedEvent() { assertAndCreateRemoteEvent(ActionUpdatedEvent.class); } 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 69a6aa93e..60d03a913 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 @@ -23,7 +23,8 @@ class DistributionSetCreatedEventTest extends AbstractRemoteEntityEventTest { /** * Verifies that the rollout entity reloading by remote updated event works */ - @Test void testRolloutUpdatedEvent() { + @Test + void testRolloutUpdatedEvent() { assertAndCreateRemoteEvent(RolloutUpdatedEvent.class); } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/entity/RolloutGroupEventTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/entity/RolloutGroupEventTest.java index 913b8a074..209e080e7 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/entity/RolloutGroupEventTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/entity/RolloutGroupEventTest.java @@ -33,7 +33,8 @@ class RolloutGroupEventTest extends AbstractRemoteEntityEventTest /** * Verifies that the rollout group entity reloading by remote created event works */ - @Test void testRolloutGroupCreatedEvent() { + @Test + void testRolloutGroupCreatedEvent() { final RolloutGroupCreatedEvent createdEvent = (RolloutGroupCreatedEvent) assertAndCreateRemoteEvent( RolloutGroupCreatedEvent.class); assertThat(createdEvent.getRolloutId()).isNotNull(); @@ -42,7 +43,8 @@ class RolloutGroupEventTest extends AbstractRemoteEntityEventTest /** * Verifies that the rollout group entity reloading by remote updated event works */ - @Test void testRolloutGroupUpdatedEvent() { + @Test + void testRolloutGroupUpdatedEvent() { assertAndCreateRemoteEvent(RolloutGroupUpdatedEvent.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 bf404b27d..9a524eaba 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 @@ -23,14 +23,16 @@ class SoftwareModuleEventTest extends AbstractRemoteEntityEventTest { /** * Verifies that the target entity reloading by remote created event works */ - @Test void testTargetCreatedEvent() { + @Test + void testTargetCreatedEvent() { assertAndCreateRemoteEvent(TargetCreatedEvent.class); } /** * Verifies that the target entity reloading by remote updated event works */ - @Test void testTargetUpdatedEvent() { + @Test + void testTargetUpdatedEvent() { assertAndCreateRemoteEvent(TargetUpdatedEvent.class); } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/entity/TargetTagEventTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/entity/TargetTagEventTest.java index 171920560..b064eda64 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/entity/TargetTagEventTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/event/remote/entity/TargetTagEventTest.java @@ -23,14 +23,16 @@ class TargetTagEventTest extends AbstractRemoteEntityEventTest { /** * Verifies that the target tag entity reloading by remote created event works */ - @Test void testTargetTagCreatedEvent() { + @Test + void testTargetTagCreatedEvent() { assertAndCreateRemoteEvent(TargetTagCreatedEvent.class); } /** * Verifies that the target tag entity reloading by remote updated event works */ - @Test void testTargetTagUpdateEventt() { + @Test + void testTargetTagUpdateEventt() { assertAndCreateRemoteEvent(TargetTagUpdatedEvent.class); } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/AbstractRepositoryManagementSecurityTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/AbstractRepositoryManagementSecurityTest.java index 18bb039db..8d36046cf 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/AbstractRepositoryManagementSecurityTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/AbstractRepositoryManagementSecurityTest.java @@ -36,28 +36,32 @@ public abstract class AbstractRepositoryManagementSecurityTest extends /** * Tests RepositoryManagement PreAuthorized method with correct and insufficient permissions. */ - @Test void createCollectionPermissionCheck() { + @Test + void createCollectionPermissionCheck() { assertPermissions(() -> getRepositoryManagement().create(List.of(getCreateObject())), List.of(SpPermission.CREATE_REPOSITORY, SpPermission.READ_REPOSITORY)); } /** * Tests RepositoryManagement PreAuthorized method with correct and insufficient permissions. */ - @Test void createPermissionCheck() { + @Test + void createPermissionCheck() { assertPermissions(() -> getRepositoryManagement().create(getCreateObject()), List.of(SpPermission.CREATE_REPOSITORY, SpPermission.READ_REPOSITORY)); } /** * Tests RepositoryManagement PreAuthorized method with correct and insufficient permissions. */ - @Test void updatePermissionCheck() { + @Test + void updatePermissionCheck() { assertPermissions(() -> getRepositoryManagement().update(getUpdateObject()), List.of(SpPermission.UPDATE_REPOSITORY)); } /** * Tests RepositoryManagement PreAuthorized method with correct and insufficient permissions. */ - @Test void deletePermissionCheck() { + @Test + void deletePermissionCheck() { assertPermissions(() -> { getRepositoryManagement().delete(1L); return null; @@ -67,7 +71,8 @@ public abstract class AbstractRepositoryManagementSecurityTest extends /** * Tests RepositoryManagement PreAuthorized method with correct and insufficient permissions. */ - @Test public void countPermissionCheck() { + @Test + void countPermissionCheck() { assertPermissions(() -> getRepositoryManagement().count(), List.of(SpPermission.READ_REPOSITORY)); } @@ -75,7 +80,8 @@ public abstract class AbstractRepositoryManagementSecurityTest extends /** * Tests RepositoryManagement PreAuthorized method with correct and insufficient permissions. */ - @Test public void deleteCollectionRepositoryManagement() { + @Test + void deleteCollectionRepositoryManagement() { assertPermissions(() -> { getRepositoryManagement().delete(List.of(1L)); return null; @@ -85,35 +91,40 @@ public abstract class AbstractRepositoryManagementSecurityTest extends /** * Tests RepositoryManagement PreAuthorized method with correct and insufficient permissions. */ - @Test public void getPermissionCheck() { + @Test + void getPermissionCheck() { assertPermissions(() -> getRepositoryManagement().get(1L), List.of(SpPermission.READ_REPOSITORY)); } /** * Tests RepositoryManagement PreAuthorized method with correct and insufficient permissions. */ - @Test public void getCollectionPermissionCheck() { + @Test + void getCollectionPermissionCheck() { assertPermissions(() -> getRepositoryManagement().get(List.of(1L)), List.of(SpPermission.READ_REPOSITORY)); } /** * Tests RepositoryManagement PreAuthorized method with correct and insufficient permissions. */ - @Test public void existsCollectionPermissionCheck() { + @Test + void existsCollectionPermissionCheck() { assertPermissions(() -> getRepositoryManagement().exists(1L), List.of(SpPermission.READ_REPOSITORY)); } /** * Tests RepositoryManagement PreAuthorized method with correct and insufficient permissions. */ - @Test public void findAllPermissionCheck() { + @Test + void findAllPermissionCheck() { assertPermissions(() -> getRepositoryManagement().findAll(Pageable.ofSize(1)), List.of(SpPermission.READ_REPOSITORY)); } /** * Tests RepositoryManagement PreAuthorized method with correct and insufficient permissions. */ - @Test public void findByRsqlPermissionCheck() { + @Test + void findByRsqlPermissionCheck() { assertPermissions(() -> getRepositoryManagement().findByRsql("(name==*)", Pageable.ofSize(1)), List.of(SpPermission.READ_REPOSITORY)); } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/ConcurrentDistributionSetInvalidationTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/ConcurrentDistributionSetInvalidationTest.java index d0df0a737..22ee0e46a 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/ConcurrentDistributionSetInvalidationTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/ConcurrentDistributionSetInvalidationTest.java @@ -54,7 +54,8 @@ class ConcurrentDistributionSetInvalidationTest extends AbstractJpaIntegrationTe /** * Verify that a large rollout causes a timeout when trying to invalidate a distribution set */ - @Test void verifyInvalidateDistributionSetWithLargeRolloutThrowsException() { + @Test + void verifyInvalidateDistributionSetWithLargeRolloutThrowsException() { final DistributionSet distributionSet = testdataFactory.createDistributionSet(); final Rollout rollout = createRollout(distributionSet); final String tenant = tenantAware.getCurrentTenant(); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/acm/context/ContextAwareTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/acm/context/ContextAwareTest.java index 1478365b0..c24ed5be3 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/acm/context/ContextAwareTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/acm/context/ContextAwareTest.java @@ -53,7 +53,8 @@ class ContextAwareTest extends AbstractJpaIntegrationTest { /** * Verifies acm context is persisted when creating Rollout */ - @Test void verifyAcmContextIsPersistedInCreatedRollout() { + @Test + void verifyAcmContextIsPersistedInCreatedRollout() { final SecurityContext securityContext = SecurityContextHolder.getContext(); assertThat(securityContext).isNotNull(); @@ -66,7 +67,8 @@ class ContextAwareTest extends AbstractJpaIntegrationTest { /** * Verifies acm context is reused when handling a rollout */ - @Test void verifyContextIsReusedWhenHandlingRollout() { + @Test + void verifyContextIsReusedWhenHandlingRollout() { final SecurityContext securityContext = SecurityContextHolder.getContext(); assertThat(securityContext).isNotNull(); @@ -78,7 +80,8 @@ class ContextAwareTest extends AbstractJpaIntegrationTest { /** * Verifies acm context is persisted when activating auto assignment */ - @Test void verifyContextIsPersistedInActiveAutoAssignment() { + @Test + void verifyContextIsPersistedInActiveAutoAssignment() { final SecurityContext securityContext = SecurityContextHolder.getContext(); assertThat(securityContext).isNotNull(); @@ -91,7 +94,8 @@ class ContextAwareTest extends AbstractJpaIntegrationTest { /** * Verifies acm context is used when performing auto assign check on all target */ - @Test void verifyContextIsReusedWhenCheckingForAutoAssignmentAllTargets() { + @Test + void verifyContextIsReusedWhenCheckingForAutoAssignmentAllTargets() { final SecurityContext securityContext = SecurityContextHolder.getContext(); assertThat(securityContext).isNotNull(); @@ -103,7 +107,8 @@ class ContextAwareTest extends AbstractJpaIntegrationTest { /** * Verifies acm context is used when performing auto assign check on single target */ - @Test void verifyContextIsReusedWhenCheckingForAutoAssignmentSingleTarget() { + @Test + void verifyContextIsReusedWhenCheckingForAutoAssignmentSingleTarget() { final SecurityContext securityContext = SecurityContextHolder.getContext(); assertThat(securityContext).isNotNull(); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/acm/controller/DistributionSetAccessControllerTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/acm/controller/DistributionSetAccessControllerTest.java index 541b832a2..3a470520e 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/acm/controller/DistributionSetAccessControllerTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/acm/controller/DistributionSetAccessControllerTest.java @@ -47,7 +47,8 @@ class DistributionSetAccessControllerTest extends AbstractAccessControllerTest { /** * Verifies read access rules for distribution sets */ - @Test void verifyDistributionSetReadOperations() { + @Test + void verifyDistributionSetReadOperations() { permitAllOperations(AccessController.Operation.READ); permitAllOperations(AccessController.Operation.CREATE); permitAllOperations(AccessController.Operation.UPDATE); @@ -119,7 +120,8 @@ class DistributionSetAccessControllerTest extends AbstractAccessControllerTest { /** * Verifies read access rules for distribution sets */ - @Test void verifyDistributionSetUpdates() { + @Test + void verifyDistributionSetUpdates() { // permit all operations first to prepare test setup permitAllOperations(AccessController.Operation.READ); permitAllOperations(AccessController.Operation.CREATE); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/acm/controller/TargetAccessControllerTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/acm/controller/TargetAccessControllerTest.java index cacb97ad0..a052e481e 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/acm/controller/TargetAccessControllerTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/acm/controller/TargetAccessControllerTest.java @@ -51,7 +51,8 @@ class TargetAccessControllerTest extends AbstractAccessControllerTest { /** * Verifies read access rules for targets */ - @Test void verifyTargetReadOperations() { + @Test + void verifyTargetReadOperations() { permitAllOperations(AccessController.Operation.CREATE); final Target permittedTarget = targetManagement @@ -206,7 +207,8 @@ class TargetAccessControllerTest extends AbstractAccessControllerTest { /** * Verifies rules for target assignment */ - @Test void verifyTargetAssignment() { + @Test + void verifyTargetAssignment() { permitAllOperations(AccessController.Operation.READ); permitAllOperations(AccessController.Operation.CREATE); permitAllOperations(AccessController.Operation.UPDATE); @@ -253,7 +255,8 @@ class TargetAccessControllerTest extends AbstractAccessControllerTest { /** * Verifies rules for target assignment */ - @Test void verifyTargetAssignmentOnNonUpdatableTarget() { + @Test + void verifyTargetAssignmentOnNonUpdatableTarget() { permitAllOperations(AccessController.Operation.READ); permitAllOperations(AccessController.Operation.CREATE); permitAllOperations(AccessController.Operation.UPDATE); @@ -294,7 +297,8 @@ class TargetAccessControllerTest extends AbstractAccessControllerTest { /** * Verifies only manageable targets are part of the rollout */ - @Test void verifyRolloutTargetScope() { + @Test + void verifyRolloutTargetScope() { permitAllOperations(AccessController.Operation.READ); permitAllOperations(AccessController.Operation.CREATE); permitAllOperations(AccessController.Operation.UPDATE); @@ -336,7 +340,8 @@ class TargetAccessControllerTest extends AbstractAccessControllerTest { /** * Verifies only manageable targets are part of an auto assignment. */ - @Test void verifyAutoAssignmentTargetScope() { + @Test + void verifyAutoAssignmentTargetScope() { permitAllOperations(AccessController.Operation.READ); permitAllOperations(AccessController.Operation.CREATE); permitAllOperations(AccessController.Operation.UPDATE); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/acm/controller/TargetTypeAccessControllerTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/acm/controller/TargetTypeAccessControllerTest.java index 7f43ddc48..7519d0fb2 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/acm/controller/TargetTypeAccessControllerTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/acm/controller/TargetTypeAccessControllerTest.java @@ -37,7 +37,8 @@ class TargetTypeAccessControllerTest extends AbstractAccessControllerTest { /** * Verifies read access rules for target types */ - @Test void verifyTargetTypeReadOperations() { + @Test + void verifyTargetTypeReadOperations() { permitAllOperations(AccessController.Operation.CREATE); final TargetType permittedTargetType = targetTypeManagement.create(entityFactory.targetType().create().name("type1")); final TargetType hiddenTargetType = targetTypeManagement.create(entityFactory.targetType().create().name("type2")); @@ -99,7 +100,8 @@ class TargetTypeAccessControllerTest extends AbstractAccessControllerTest { /** * Verifies delete access rules for target types */ - @Test void verifyTargetTypeDeleteOperations() { + @Test + void verifyTargetTypeDeleteOperations() { permitAllOperations(AccessController.Operation.CREATE); final TargetType manageableTargetType = targetTypeManagement.create(entityFactory.targetType().create().name("type1")); @@ -123,7 +125,8 @@ class TargetTypeAccessControllerTest extends AbstractAccessControllerTest { /** * Verifies update operation for target types */ - @Test void verifyTargetTypeUpdateOperations() { + @Test + void verifyTargetTypeUpdateOperations() { permitAllOperations(AccessController.Operation.CREATE); final TargetType manageableTargetType = targetTypeManagement .create(entityFactory.targetType().create().name("type1")); @@ -151,7 +154,8 @@ class TargetTypeAccessControllerTest extends AbstractAccessControllerTest { /** * Verifies create operation blocked by controller */ - @Test void verifyTargetTypeCreationBlockedByAccessController() { + @Test + void verifyTargetTypeCreationBlockedByAccessController() { defineAccess(AccessController.Operation.CREATE); // allows for none // verify targetTypeManagement#create for any type final TargetTypeCreate targetTypeCreate = entityFactory.targetType().create().name("type1"); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/autoassign/AutoAssignCheckerIntTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/autoassign/AutoAssignCheckerIntTest.java index 785b697e4..07dcf51de 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/autoassign/AutoAssignCheckerIntTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/autoassign/AutoAssignCheckerIntTest.java @@ -62,7 +62,8 @@ class AutoAssignCheckerIntTest extends AbstractJpaIntegrationTest { /** * Verifies that a running action is auto canceled by a AutoAssignment which assigns another distribution-set. */ - @Test void autoAssignDistributionSetAndAutoCloseOldActions() { + @Test + void autoAssignDistributionSetAndAutoCloseOldActions() { tenantConfigurationManagement .addOrUpdateConfiguration(TenantConfigurationKey.REPOSITORY_ACTIONS_AUTOCLOSE_ENABLED, true); @@ -107,7 +108,8 @@ class AutoAssignCheckerIntTest extends AbstractJpaIntegrationTest { /** * Test auto assignment of a DS to filtered targets */ - @Test void checkAutoAssign() { + @Test + void checkAutoAssign() { // will be auto assigned final DistributionSet setA = testdataFactory.createDistributionSet("dsA"); final DistributionSet setB = testdataFactory.createDistributionSet("dsB"); @@ -160,7 +162,8 @@ class AutoAssignCheckerIntTest extends AbstractJpaIntegrationTest { /** * Test auto assignment of a DS for a specific device */ - @Test void checkAutoAssignmentForDevice() { + @Test + void checkAutoAssignmentForDevice() { final DistributionSet toAssignDs = testdataFactory.createDistributionSet(); @@ -244,7 +247,8 @@ class AutoAssignCheckerIntTest extends AbstractJpaIntegrationTest { /** * Test auto assignment of an incomplete DS to filtered targets, that causes failures */ - @Test void checkAutoAssignWithFailures() { + @Test + void checkAutoAssignWithFailures() { // incomplete distribution set that will be assigned final DistributionSet setF = distributionSetManagement.create(entityFactory.distributionSet().create() @@ -294,7 +298,8 @@ class AutoAssignCheckerIntTest extends AbstractJpaIntegrationTest { /** * Test auto assignment of a distribution set with FORCED, SOFT and DOWNLOAD_ONLY action types */ - @Test void checkAutoAssignWithDifferentActionTypes() { + @Test + void checkAutoAssignWithDifferentActionTypes() { final DistributionSet distributionSet = testdataFactory.createDistributionSet(); final String targetDsAIdPref = "A"; final String targetDsBIdPref = "B"; @@ -324,7 +329,8 @@ class AutoAssignCheckerIntTest extends AbstractJpaIntegrationTest { /** * An auto assignment target filter with weight creates actions with weights */ - @Test void actionsWithWeightAreCreated() { + @Test + void actionsWithWeightAreCreated() { final int amountOfTargets = 5; final DistributionSet ds = testdataFactory.createDistributionSet(); final int weight = 32; @@ -344,7 +350,8 @@ class AutoAssignCheckerIntTest extends AbstractJpaIntegrationTest { /** * An auto assignment target filter without weight still works after multi assignment is enabled */ - @Test void filterWithoutWeightWorksInMultiAssignmentMode() { + @Test + void filterWithoutWeightWorksInMultiAssignmentMode() { final int amountOfTargets = 5; final DistributionSet ds = testdataFactory.createDistributionSet(); targetFilterQueryManagement.create( @@ -363,7 +370,8 @@ class AutoAssignCheckerIntTest extends AbstractJpaIntegrationTest { /** * Verifies an auto assignment only creates actions for compatible targets */ - @Test void checkAutoAssignmentWithIncompatibleTargets() { + @Test + void checkAutoAssignmentWithIncompatibleTargets() { final int TARGET_COUNT = 5; final DistributionSet testDs = testdataFactory.createDistributionSet(); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/autoassign/AutoAssignCheckerTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/autoassign/AutoAssignCheckerTest.java index cb59d50ef..0fedb3b00 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/autoassign/AutoAssignCheckerTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/autoassign/AutoAssignCheckerTest.java @@ -68,7 +68,8 @@ class AutoAssignCheckerTest { /** * Single device check triggers update for matching auto assignment filter. */ - @Test void checkForDevice() { + @Test + void checkForDevice() { mockRunningAsNonSystem(); final String target = getRandomString(); final long ds = getRandomLong(); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/autocleanup/AutoActionCleanupTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/autocleanup/AutoActionCleanupTest.java index d5104718c..376ca007d 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/autocleanup/AutoActionCleanupTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/autocleanup/AutoActionCleanupTest.java @@ -40,7 +40,8 @@ class AutoActionCleanupTest extends AbstractJpaIntegrationTest { /** * Verifies that running actions are not cleaned up. */ - @Test void runningActionsAreNotCleanedUp() { + @Test + void runningActionsAreNotCleanedUp() { // cleanup config for this test case setupCleanupConfiguration(true, 0, Action.Status.CANCELED, Action.Status.ERROR); @@ -64,7 +65,8 @@ class AutoActionCleanupTest extends AbstractJpaIntegrationTest { /** * Verifies that nothing is cleaned up if the cleanup is disabled. */ - @Test void cleanupDisabled() { + @Test + void cleanupDisabled() { // cleanup config for this test case setupCleanupConfiguration(false, 0, Action.Status.CANCELED); @@ -90,7 +92,8 @@ class AutoActionCleanupTest extends AbstractJpaIntegrationTest { /** * Verifies that canceled and failed actions are cleaned up. */ - @Test void canceledAndFailedActionsAreCleanedUp() { + @Test + void canceledAndFailedActionsAreCleanedUp() { // cleanup config for this test case setupCleanupConfiguration(true, 0, Action.Status.CANCELED, Action.Status.ERROR); @@ -122,7 +125,8 @@ class AutoActionCleanupTest extends AbstractJpaIntegrationTest { /** * Verifies that canceled actions are cleaned up. */ - @Test void canceledActionsAreCleanedUp() { + @Test + void canceledActionsAreCleanedUp() { // cleanup config for this test case setupCleanupConfiguration(true, 0, Action.Status.CANCELED); @@ -155,7 +159,8 @@ class AutoActionCleanupTest extends AbstractJpaIntegrationTest { /** * Verifies that canceled and failed actions are cleaned up once they expired. */ - @Test @SuppressWarnings("squid:S2925") + @Test + @SuppressWarnings("squid:S2925") void canceledAndFailedActionsAreCleanedUpWhenExpired() throws InterruptedException { // cleanup config for this test case setupCleanupConfiguration(true, 500, Action.Status.CANCELED, Action.Status.ERROR); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/autocleanup/AutoCleanupSchedulerTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/autocleanup/AutoCleanupSchedulerTest.java index 66c2c281e..81fbdac5e 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/autocleanup/AutoCleanupSchedulerTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/autocleanup/AutoCleanupSchedulerTest.java @@ -42,7 +42,8 @@ class AutoCleanupSchedulerTest extends AbstractJpaIntegrationTest { /** * Verifies that all cleanup handlers are executed regardless if one of them throws an error */ - @Test void executeHandlerChain() { + @Test + void executeHandlerChain() { new AutoCleanupScheduler(systemManagement, systemSecurityContext, lockRegistry, Arrays.asList( new SuccessfulCleanup(), new SuccessfulCleanup(), new FailingCleanup(), new SuccessfulCleanup())).run(); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/event/RepositoryEntityEventTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/event/RepositoryEntityEventTest.java index 1811377c2..5a4dab49d 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/event/RepositoryEntityEventTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/event/RepositoryEntityEventTest.java @@ -63,7 +63,8 @@ class RepositoryEntityEventTest extends AbstractJpaIntegrationTest { /** * Verifies that the target created event is published when a target has been created */ - @Test void targetCreatedEventIsPublished() throws InterruptedException { + @Test + void targetCreatedEventIsPublished() throws InterruptedException { final Target createdTarget = testdataFactory.createTarget("12345"); final TargetCreatedEvent targetCreatedEvent = eventListener.waitForEvent(TargetCreatedEvent.class); @@ -74,7 +75,8 @@ class RepositoryEntityEventTest extends AbstractJpaIntegrationTest { /** * Verifies that the target update event is published when a target has been updated */ - @Test void targetUpdateEventIsPublished() throws InterruptedException { + @Test + void targetUpdateEventIsPublished() throws InterruptedException { final Target createdTarget = testdataFactory.createTarget("12345"); targetManagement.update(entityFactory.target().update(createdTarget.getControllerId()).name("updateName")); @@ -86,7 +88,8 @@ class RepositoryEntityEventTest extends AbstractJpaIntegrationTest { /** * Verifies that the target deleted event is published when a target has been deleted */ - @Test void targetDeletedEventIsPublished() throws InterruptedException { + @Test + void targetDeletedEventIsPublished() throws InterruptedException { final Target createdTarget = testdataFactory.createTarget("12345"); targetManagement.deleteByControllerID("12345"); @@ -99,7 +102,8 @@ class RepositoryEntityEventTest extends AbstractJpaIntegrationTest { /** * Verifies that the target type created event is published when a target type has been created */ - @Test void targetTypeCreatedEventIsPublished() throws InterruptedException { + @Test + void targetTypeCreatedEventIsPublished() throws InterruptedException { final TargetType createdTargetType = testdataFactory.findOrCreateTargetType("targettype"); final TargetTypeCreatedEvent targetTypeCreatedEvent = eventListener.waitForEvent(TargetTypeCreatedEvent.class); @@ -110,7 +114,8 @@ class RepositoryEntityEventTest extends AbstractJpaIntegrationTest { /** * Verifies that the target type updated event is published when a target type has been updated */ - @Test void targetTypeUpdatedEventIsPublished() throws InterruptedException { + @Test + void targetTypeUpdatedEventIsPublished() throws InterruptedException { final TargetType createdTargetType = testdataFactory.findOrCreateTargetType("targettype"); targetTypeManagement .update(entityFactory.targetType().update(createdTargetType.getId()).name("updatedtargettype")); @@ -123,7 +128,8 @@ class RepositoryEntityEventTest extends AbstractJpaIntegrationTest { /** * Verifies that the target type deleted event is published when a target type has been deleted */ - @Test void targetTypeDeletedEventIsPublished() throws InterruptedException { + @Test + void targetTypeDeletedEventIsPublished() throws InterruptedException { final TargetType createdTargetType = testdataFactory.findOrCreateTargetType("targettype"); targetTypeManagement.delete(createdTargetType.getId()); @@ -135,7 +141,8 @@ class RepositoryEntityEventTest extends AbstractJpaIntegrationTest { /** * Verifies that the rollout deleted event is published when a rollout has been deleted */ - @Test void rolloutDeletedEventIsPublished() throws InterruptedException { + @Test + void rolloutDeletedEventIsPublished() throws InterruptedException { final int amountTargetsForRollout = 50; final int amountGroups = 5; final String successCondition = "50"; @@ -159,7 +166,8 @@ class RepositoryEntityEventTest extends AbstractJpaIntegrationTest { /** * Verifies that the distribution set created event is published when a distribution set has been created */ - @Test void distributionSetCreatedEventIsPublished() throws InterruptedException { + @Test + void distributionSetCreatedEventIsPublished() throws InterruptedException { final DistributionSet createDistributionSet = testdataFactory.createDistributionSet(); final DistributionSetCreatedEvent dsCreatedEvent = eventListener @@ -171,7 +179,8 @@ class RepositoryEntityEventTest extends AbstractJpaIntegrationTest { /** * Verifies that the distribution set deleted event is published when a distribution set has been deleted */ - @Test void distributionSetDeletedEventIsPublished() throws InterruptedException { + @Test + void distributionSetDeletedEventIsPublished() throws InterruptedException { final DistributionSet createDistributionSet = testdataFactory.createDistributionSet(); distributionSetManagement.delete(createDistributionSet.getId()); @@ -185,7 +194,8 @@ class RepositoryEntityEventTest extends AbstractJpaIntegrationTest { /** * Verifies that the software module created event is published when a software module has been created */ - @Test void softwareModuleCreatedEventIsPublished() throws InterruptedException { + @Test + void softwareModuleCreatedEventIsPublished() throws InterruptedException { final SoftwareModule softwareModule = testdataFactory.createSoftwareModuleApp(); final SoftwareModuleCreatedEvent softwareModuleCreatedEvent = eventListener @@ -197,7 +207,8 @@ class RepositoryEntityEventTest extends AbstractJpaIntegrationTest { /** * Verifies that the software module update event is published when a software module has been updated */ - @Test void softwareModuleUpdateEventIsPublished() throws InterruptedException { + @Test + void softwareModuleUpdateEventIsPublished() throws InterruptedException { final SoftwareModule softwareModule = testdataFactory.createSoftwareModuleApp(); softwareModuleManagement .update(entityFactory.softwareModule().update(softwareModule.getId()).description("New")); @@ -211,7 +222,8 @@ class RepositoryEntityEventTest extends AbstractJpaIntegrationTest { /** * Verifies that the software module deleted event is published when a software module has been deleted */ - @Test void softwareModuleDeletedEventIsPublished() throws InterruptedException { + @Test + void softwareModuleDeletedEventIsPublished() throws InterruptedException { final SoftwareModule softwareModule = testdataFactory.createSoftwareModuleApp(); softwareModuleManagement.delete(softwareModule.getId()); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ActionTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ActionTest.java index 95be12872..11c20001d 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ActionTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ActionTest.java @@ -37,7 +37,8 @@ class ActionTest extends AbstractJpaIntegrationTest { /** * Ensures that timeforced moded switch from soft to forces after defined timeframe. */ - @Test void timeForcedHitNewHasCodeIsGenerated() { + @Test + void timeForcedHitNewHasCodeIsGenerated() { // current time + 1 seconds final long sleepTime = 1000; final long timeForceTimeAt = System.currentTimeMillis() + sleepTime; @@ -53,7 +54,8 @@ class ActionTest extends AbstractJpaIntegrationTest { /** * Tests the action type mapping. */ - @Test void testActionTypeConvert() { + @Test + void testActionTypeConvert() { final long id = createAction().getId(); for (final ActionType actionType : ActionType.values()) { final JpaAction action = actionRepository.findById(id).orElseThrow(() -> new IllegalStateException("Action not found")); @@ -67,7 +69,8 @@ class ActionTest extends AbstractJpaIntegrationTest { /** * Tests the status mapping. */ - @Test void testStatusConvert() { + @Test + void testStatusConvert() { final long id = createAction().getId(); for (final Status status : Status.values()) { final JpaAction action = actionRepository.findById(id).orElseThrow(() -> new IllegalStateException("Action not found")); @@ -81,7 +84,8 @@ class ActionTest extends AbstractJpaIntegrationTest { /** * Tests the action status status mapping. */ - @Test void testActionsStatusStatusConvert() { + @Test + void testActionsStatusStatusConvert() { for (final Status status : Status.values()) { final long id = createAction().getId(); controllerManagement.addUpdateActionStatus(entityFactory.actionStatus().create(id).status(status)); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ArtifactManagementSecurityTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ArtifactManagementSecurityTest.java index 8337f6170..c065d9ab2 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ArtifactManagementSecurityTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ArtifactManagementSecurityTest.java @@ -27,7 +27,8 @@ class ArtifactManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ArtifactManagement#count() method */ - @Test @WithUser(principal = "user", authorities = { SpPermission.READ_REPOSITORY }) + @Test + @WithUser(principal = "user", authorities = { SpPermission.READ_REPOSITORY }) void countPermissionCheck() { assertPermissions(() -> artifactManagement.count(), List.of(SpPermission.READ_REPOSITORY)); } @@ -35,7 +36,8 @@ class ArtifactManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ArtifactManagement#create() method */ - @Test void createPermissionCheck() { + @Test + void createPermissionCheck() { ArtifactUpload artifactUpload = new ArtifactUpload(new ByteArrayInputStream("RandomString".getBytes()), 1L, "filename", false, 1024); assertPermissions(() -> artifactManagement.create(artifactUpload), List.of(SpPermission.CREATE_REPOSITORY)); } @@ -43,7 +45,8 @@ class ArtifactManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ArtifactManagement#delete() method */ - @Test void deletePermissionCheck() { + @Test + void deletePermissionCheck() { assertPermissions(() -> { artifactManagement.delete(1); return null; @@ -53,7 +56,8 @@ class ArtifactManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ArtifactManagement#get() method */ - @Test void getPermissionCheck() { + @Test + void getPermissionCheck() { assertPermissions(() -> artifactManagement.get(1L), List.of(SpPermission.READ_REPOSITORY)); assertPermissions(() -> artifactManagement.get(1L), List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE), List.of(SpPermission.CREATE_REPOSITORY)); } @@ -61,7 +65,8 @@ class ArtifactManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ArtifactManagement#getByFilenameAndSoftwareModule() method */ - @Test void getByFilenameAndSoftwareModulePermissionCheck() { + @Test + void getByFilenameAndSoftwareModulePermissionCheck() { assertPermissions(() -> artifactManagement.getByFilenameAndSoftwareModule("filename", 1L), List.of(SpPermission.READ_REPOSITORY), List.of(SpPermission.CREATE_REPOSITORY)); assertPermissions(() -> artifactManagement.getByFilenameAndSoftwareModule("filename", 1L), @@ -71,7 +76,8 @@ class ArtifactManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ArtifactManagement#findFirstBySHA1() method */ - @Test void findFirstBySHA1PermissionCheck() { + @Test + void findFirstBySHA1PermissionCheck() { assertPermissions(() -> artifactManagement.findFirstBySHA1("sha1"), List.of(SpPermission.READ_REPOSITORY)); assertPermissions(() -> artifactManagement.findFirstBySHA1("sha1"), List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE), List.of(SpPermission.CREATE_REPOSITORY)); } @@ -79,7 +85,8 @@ class ArtifactManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ArtifactManagement#getByFilename() method */ - @Test void getByFilenamePermissionCheck() { + @Test + void getByFilenamePermissionCheck() { assertPermissions(() -> artifactManagement.getByFilename("filename"), List.of(SpPermission.READ_REPOSITORY)); assertPermissions(() -> artifactManagement.getByFilename("filename"), List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE), List.of(SpPermission.CREATE_REPOSITORY)); } @@ -87,21 +94,24 @@ class ArtifactManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ArtifactManagement#findBySoftwareModule() method */ - @Test void findBySoftwareModulePermissionCheck() { + @Test + void findBySoftwareModulePermissionCheck() { assertPermissions(() -> artifactManagement.findBySoftwareModule(1L, PAGE), List.of(SpPermission.READ_REPOSITORY)); } /** * Tests ArtifactManagement#countBySoftwareModule() method */ - @Test void countBySoftwareModulePermissionCheck() { + @Test + void countBySoftwareModulePermissionCheck() { assertPermissions(() -> artifactManagement.countBySoftwareModule(1L), List.of(SpPermission.READ_REPOSITORY)); } /** * Tests ArtifactManagement#loadArtifactBinary() method */ - @Test void loadArtifactBinaryPermissionCheck() { + @Test + void loadArtifactBinaryPermissionCheck() { assertPermissions(() -> artifactManagement.loadArtifactBinary("sha1", 1L, false), List.of(SpPermission.DOWNLOAD_REPOSITORY_ARTIFACT), List.of(SpPermission.CREATE_REPOSITORY)); assertPermissions(() -> artifactManagement.loadArtifactBinary("sha1", 1L, false), List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE), List.of(SpPermission.CREATE_REPOSITORY)); } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ArtifactManagementTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ArtifactManagementTest.java index 7c51fbbd3..41693518c 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ArtifactManagementTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ArtifactManagementTest.java @@ -63,7 +63,8 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest { /** * Verifies that management get access react as specfied on calls for non existing entities by means of Optional not present. */ - @Test @ExpectEvents({ @Expect(type = SoftwareModuleCreatedEvent.class, count = 1) }) + @Test + @ExpectEvents({ @Expect(type = SoftwareModuleCreatedEvent.class, count = 1) }) void nonExistingEntityAccessReturnsNotPresent() { final SoftwareModule module = testdataFactory.createSoftwareModuleOs(); @@ -104,7 +105,8 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest { /** * Test if a local artifact can be created by API including metadata. */ - @Test void createArtifact() throws IOException { + @Test + void createArtifact() throws IOException { // check baseline assertThat(softwareModuleRepository.findAll()).isEmpty(); assertThat(artifactRepository.findAll()).isEmpty(); @@ -148,7 +150,8 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest { /** * Verifies that artifact management does not create artifacts with illegal filename. */ - @Test void entityQueryWithIllegalFilenameThrowsException() { + @Test + void entityQueryWithIllegalFilenameThrowsException() { final String illegalFilename = ".xml"; final String artifactData = "test"; final int artifactSize = artifactData.length(); @@ -163,7 +166,8 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest { /** * Verifies that the quota specifying the maximum number of artifacts per software module is enforced. */ - @Test void createArtifactsUntilQuotaIsExceeded() throws IOException { + @Test + void createArtifactsUntilQuotaIsExceeded() throws IOException { // create a software module final long smId = softwareModuleRepository.save(new JpaSoftwareModule(osType, "sm1", "1.0")).getId(); @@ -193,7 +197,8 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest { /** * Verifies that the quota specifying the maximum artifact storage is enforced (across software modules). */ - @Test void createArtifactsUntilStorageQuotaIsExceeded() throws IOException { + @Test + void createArtifactsUntilStorageQuotaIsExceeded() throws IOException { // create as many small artifacts as possible w/o violating the storage quota final long maxBytes = quotaManagement.getMaxArtifactStorage(); final List artifactIds = new ArrayList<>(); @@ -221,7 +226,8 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest { /** * Verifies that you cannot create artifacts which exceed the configured maximum size. */ - @Test void createArtifactFailsIfTooLarge() { + @Test + void createArtifactFailsIfTooLarge() { // create a software module final long smId = softwareModuleRepository.save(new JpaSoftwareModule(osType, "sm1", "1.0")).getId(); @@ -234,7 +240,8 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest { /** * Tests hard delete directly on repository. */ - @Test void hardDeleteSoftwareModule() throws IOException { + @Test + void hardDeleteSoftwareModule() throws IOException { final JpaSoftwareModule sm = softwareModuleRepository.save(new JpaSoftwareModule(osType, "name 1", "version 1")); createArtifactForSoftwareModule("file1", sm.getId(), 5 * 1024); @@ -250,7 +257,8 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest { /** * Tests the deletion of a local artifact including metadata. */ - @Test void deleteArtifact() throws IOException { + @Test + void deleteArtifact() throws IOException { final JpaSoftwareModule sm = softwareModuleRepository.save(new JpaSoftwareModule(osType, "name 1", "version 1")); final JpaSoftwareModule sm2 = softwareModuleRepository.save(new JpaSoftwareModule(osType, "name 2", "version 2")); @@ -322,7 +330,8 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest { /** * Verifies that you cannot delete an artifact which exists with the same hash, in the same tenant and the SoftwareModule is not deleted . */ - @Test void deleteArtifactWithSameHashAndSoftwareModuleIsNotDeletedInSameTenants() throws IOException { + @Test + void deleteArtifactWithSameHashAndSoftwareModuleIsNotDeletedInSameTenants() throws IOException { final JpaSoftwareModule sm = softwareModuleRepository.save(new JpaSoftwareModule(osType, "name 1", "version 1")); final JpaSoftwareModule sm2 = softwareModuleRepository.save(new JpaSoftwareModule(osType, "name 2", "version 2")); @@ -360,7 +369,8 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest { /** * Verifies that you can not delete artifacts from another tenant which exists in another tenant with the same hash and the SoftwareModule is not deleted */ - @Test void deleteArtifactWithSameHashAndSoftwareModuleIsNotDeletedInDifferentTenants() throws Exception { + @Test + void deleteArtifactWithSameHashAndSoftwareModuleIsNotDeletedInDifferentTenants() throws Exception { final String tenant1 = "mytenant"; final String tenant2 = "tenant2"; @@ -388,7 +398,8 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest { /** * Loads an local artifact based on given ID. */ - @Test void findArtifact() throws IOException { + @Test + void findArtifact() throws IOException { final int artifactSize = 5 * 1024; try (final InputStream inputStream = new RandomGeneratedInputStream(artifactSize)) { final Artifact artifact = createArtifactForSoftwareModule( @@ -400,7 +411,8 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest { /** * Loads an artifact binary based on given ID. */ - @Test void loadStreamOfArtifact() throws IOException { + @Test + void loadStreamOfArtifact() throws IOException { final int artifactSize = 5 * 1024; final byte[] randomBytes = randomBytes(artifactSize); try (final InputStream input = new ByteArrayInputStream(randomBytes)) { @@ -425,7 +437,8 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest { /** * Searches an artifact through the relations of a software module. */ - @Test void findArtifactBySoftwareModule() throws IOException { + @Test + void findArtifactBySoftwareModule() throws IOException { final SoftwareModule sm = testdataFactory.createSoftwareModuleOs(); assertThat(artifactManagement.findBySoftwareModule(sm.getId(), PAGE)).isEmpty(); @@ -439,7 +452,8 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest { /** * Searches an artifact through the relations of a software module and the filename. */ - @Test void findByFilenameAndSoftwareModule() throws IOException { + @Test + void findByFilenameAndSoftwareModule() throws IOException { final SoftwareModule sm = testdataFactory.createSoftwareModuleOs(); assertThat(artifactManagement.getByFilenameAndSoftwareModule("file1", sm.getId())).isNotPresent(); @@ -456,7 +470,8 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest { /** * Verifies that creation of an artifact with none matching hashes fails. */ - @Test void createArtifactWithNoneMatchingHashes() throws IOException, NoSuchAlgorithmException { + @Test + void createArtifactWithNoneMatchingHashes() throws IOException, NoSuchAlgorithmException { final SoftwareModule sm = testdataFactory.createSoftwareModuleOs(); final byte[] testData = randomBytes(100); @@ -490,7 +505,8 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest { /** * Verifies that creation of an artifact with matching hashes works. */ - @Test void createArtifactWithMatchingHashes() throws IOException, NoSuchAlgorithmException { + @Test + void createArtifactWithMatchingHashes() throws IOException, NoSuchAlgorithmException { final SoftwareModule sm = testdataFactory.createSoftwareModuleOs(); final byte[] testData = randomBytes(100); @@ -513,7 +529,8 @@ class ArtifactManagementTest extends AbstractJpaIntegrationTest { /** * Verifies that creation of an existing artifact returns a full hash list. */ - @Test void createExistingArtifactReturnsFullHashList() throws IOException, NoSuchAlgorithmException { + @Test + void createExistingArtifactReturnsFullHashList() throws IOException, NoSuchAlgorithmException { final SoftwareModule smOs = testdataFactory.createSoftwareModuleOs(); final SoftwareModule smApp = testdataFactory.createSoftwareModuleApp(); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ConfirmationManagementSecurityTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ConfirmationManagementSecurityTest.java index cb0466308..994e88b60 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ConfirmationManagementSecurityTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ConfirmationManagementSecurityTest.java @@ -24,14 +24,16 @@ class ConfirmationManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ConfirmationManagement#findActiveActionsWaitingConfirmation() method */ - @Test void findActiveActionsWaitingConfirmationPermissionsCheck() { + @Test + void findActiveActionsWaitingConfirmationPermissionsCheck() { assertPermissions(() -> confirmationManagement.findActiveActionsWaitingConfirmation("controllerId"), List.of(SpPermission.READ_TARGET)); } /** * Tests ConfirmationManagement#activateAutoConfirmation() method */ - @Test void activateAutoConfirmationPermissionsCheck() { + @Test + void activateAutoConfirmationPermissionsCheck() { assertPermissions(() -> confirmationManagement.activateAutoConfirmation("controllerId", "initiator", "remark"), List.of(SpPermission.READ_REPOSITORY, SpPermission.UPDATE_TARGET)); } @@ -39,7 +41,8 @@ class ConfirmationManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ConfirmationManagement#getStatus() method */ - @Test void getStatusPermissionsCheck() { + @Test + void getStatusPermissionsCheck() { assertPermissions(() -> confirmationManagement.getStatus("controllerId"), List.of(SpPermission.READ_TARGET), List.of(SpPermission.CREATE_TARGET)); assertPermissions(() -> confirmationManagement.getStatus("controllerId"), List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE), List.of(SpPermission.CREATE_TARGET)); @@ -48,7 +51,8 @@ class ConfirmationManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ConfirmationManagement#confirmAction() method */ - @Test void confirmActionPermissionsCheck() { + @Test + void confirmActionPermissionsCheck() { assertPermissions(() -> confirmationManagement.confirmAction(1L, null, null), List.of(SpPermission.READ_REPOSITORY, SpPermission.UPDATE_TARGET)); } @@ -56,7 +60,8 @@ class ConfirmationManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ConfirmationManagement#denyAction() method */ - @Test void denyActionPermissionsCheck() { + @Test + void denyActionPermissionsCheck() { assertPermissions(() -> confirmationManagement.denyAction(1L, null, null), List.of(SpPermission.READ_REPOSITORY, SpPermission.UPDATE_TARGET)); } @@ -64,7 +69,8 @@ class ConfirmationManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ConfirmationManagement#deactivateAutoConfirmation() method */ - @Test void deactivateAutoConfirmationPermissionsCheck() { + @Test + void deactivateAutoConfirmationPermissionsCheck() { assertPermissions(() -> { confirmationManagement.deactivateAutoConfirmation("controllerId"); return null; diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ConfirmationManagementTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ConfirmationManagementTest.java index 572994c67..184274e19 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ConfirmationManagementTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ConfirmationManagementTest.java @@ -44,7 +44,8 @@ class ConfirmationManagementTest extends AbstractJpaIntegrationTest { /** * Verify 'findActiveActionsWaitingConfirmation' method is filtering like expected */ - @Test void retrieveActionsWithConfirmationState() { + @Test + void retrieveActionsWithConfirmationState() { enableConfirmationFlow(); final String controllerId = testdataFactory.createTarget().getControllerId(); @@ -67,7 +68,8 @@ class ConfirmationManagementTest extends AbstractJpaIntegrationTest { /** * Verify 'findActiveActionsWaitingConfirmation' method is filtering like expected with multi assignment active */ - @Test void retrieveActionsWithConfirmationStateInMultiAssignment() { + @Test + void retrieveActionsWithConfirmationStateInMultiAssignment() { enableMultiAssignments(); enableConfirmationFlow(); @@ -97,7 +99,8 @@ class ConfirmationManagementTest extends AbstractJpaIntegrationTest { /** * Verify confirming an action will put it to the running state */ - @Test void confirmedActionWillSwitchToRunningState() { + @Test + void confirmedActionWillSwitchToRunningState() { enableConfirmationFlow(); final String controllerId = testdataFactory.createTarget().getControllerId(); @@ -126,7 +129,8 @@ class ConfirmationManagementTest extends AbstractJpaIntegrationTest { /** * Verify confirming an confirmed action will lead to a specific failure */ - @Test void confirmedActionCannotBeConfirmedAgain() { + @Test + void confirmedActionCannotBeConfirmedAgain() { enableConfirmationFlow(); final String controllerId = testdataFactory.createTarget().getControllerId(); @@ -148,7 +152,8 @@ class ConfirmationManagementTest extends AbstractJpaIntegrationTest { /** * Verify confirming a closed action will lead to a specific failure */ - @Test void confirmedActionCannotBeGivenOnFinishedAction() { + @Test + void confirmedActionCannotBeGivenOnFinishedAction() { enableConfirmationFlow(); final Long actionId = prepareFinishedUpdate().getId(); assertThatThrownBy(() -> confirmationManagement.confirmAction(actionId, null, null)) @@ -160,7 +165,8 @@ class ConfirmationManagementTest extends AbstractJpaIntegrationTest { /** * Verify denying an action will leave it in WFC state */ - @Test void deniedActionWillStayInWfcState() { + @Test + void deniedActionWillStayInWfcState() { enableConfirmationFlow(); final String controllerId = testdataFactory.createTarget().getControllerId(); @@ -189,7 +195,8 @@ class ConfirmationManagementTest extends AbstractJpaIntegrationTest { /** * Verify multiple actions in WFC state will be transferred in RUNNING state in case auto-confirmation is activated. */ - @Test void activateAutoConfirmationInMultiAssignment() { + @Test + void activateAutoConfirmationInMultiAssignment() { enableMultiAssignments(); enableConfirmationFlow(); @@ -216,7 +223,8 @@ class ConfirmationManagementTest extends AbstractJpaIntegrationTest { /** * Verify action in WFC state will be transferred in RUNNING state in case auto-confirmation is activated. */ - @Test void activateAutoConfirmationOnActiveAction() { + @Test + void activateAutoConfirmationOnActiveAction() { enableConfirmationFlow(); final String controllerId = testdataFactory.createTarget().getControllerId(); @@ -239,7 +247,8 @@ class ConfirmationManagementTest extends AbstractJpaIntegrationTest { /** * Verify created action after activating auto confirmation is directly in running state. */ - @Test void activateAutoConfirmationAndCreateAction() { + @Test + void activateAutoConfirmationAndCreateAction() { enableConfirmationFlow(); final String controllerId = testdataFactory.createTarget().getControllerId(); @@ -284,7 +293,8 @@ class ConfirmationManagementTest extends AbstractJpaIntegrationTest { /** * Verify activating already active auto confirmation will throw exception. */ - @Test void verifyActivateAlreadyActiveAutoConfirmationThrowException() { + @Test + void verifyActivateAlreadyActiveAutoConfirmationThrowException() { final String controllerId = testdataFactory.createTarget().getControllerId(); confirmationManagement.activateAutoConfirmation(controllerId, "any", "any"); @@ -298,7 +308,8 @@ class ConfirmationManagementTest extends AbstractJpaIntegrationTest { /** * Verify disabling already disabled auto confirmation will not have any affect. */ - @Test void disableAlreadyDisabledAutoConfirmationHaveNoAffect() { + @Test + void disableAlreadyDisabledAutoConfirmationHaveNoAffect() { final String controllerId = testdataFactory.createTarget().getControllerId(); verifyAutoConfirmationIsDisabled(controllerId); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ControllerManagementSecurityTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ControllerManagementSecurityTest.java index 93fa0f8ec..62ed348b4 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ControllerManagementSecurityTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/ControllerManagementSecurityTest.java @@ -30,7 +30,8 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ControllerManagement#cancelActionStatus() method */ - @Test void addCancelActionStatusPermissionsCheck() { + @Test + void addCancelActionStatusPermissionsCheck() { assertPermissions(() -> controllerManagement.addCancelActionStatus(entityFactory.actionStatus().create(0L)), List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE)); } @@ -38,14 +39,16 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ControllerManagement#getSoftwareModule() method */ - @Test void getSoftwareModulePermissionsCheck() { + @Test + void getSoftwareModulePermissionsCheck() { assertPermissions(() -> controllerManagement.getSoftwareModule(1L), List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE)); } /** * Tests ControllerManagement#findTargetVisibleMetaDataBySoftwareModuleId() method */ - @Test void findTargetVisibleMetaDataBySoftwareModuleIdPermissionsCheck() { + @Test + void findTargetVisibleMetaDataBySoftwareModuleIdPermissionsCheck() { assertPermissions(() -> controllerManagement.findTargetVisibleMetaDataBySoftwareModuleId(List.of(1L)), List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE)); } @@ -53,7 +56,8 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ControllerManagement#addInformationalActionStatus() method */ - @Test void addInformationalActionStatusPermissionsCheck() { + @Test + void addInformationalActionStatusPermissionsCheck() { assertPermissions(() -> controllerManagement.addInformationalActionStatus(entityFactory.actionStatus().create(0L)), List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE)); } @@ -61,7 +65,8 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ControllerManagement#addUpdateActionStatus() method */ - @Test void addUpdateActionStatusPermissionsCheck() { + @Test + void addUpdateActionStatusPermissionsCheck() { assertPermissions(() -> controllerManagement.addUpdateActionStatus(entityFactory.actionStatus().create(0L)), List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE)); } @@ -69,7 +74,8 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ControllerManagement#findActiveActionWithHighestWeight() method */ - @Test void findActiveActionWithHighestWeightPermissionsCheck() { + @Test + void findActiveActionWithHighestWeightPermissionsCheck() { assertPermissions(() -> controllerManagement.findActiveActionWithHighestWeight("controllerId"), List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE)); } @@ -77,7 +83,8 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ControllerManagement#findActiveActionsWithHighestWeight() method */ - @Test void findActiveActionsWithHighestWeightPermissionsCheck() { + @Test + void findActiveActionsWithHighestWeightPermissionsCheck() { assertPermissions(() -> controllerManagement.findActiveActionsWithHighestWeight("controllerId", 1), List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE)); } @@ -85,14 +92,16 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ControllerManagement#findActionWithDetails() method */ - @Test void findActionWithDetailsPermissionsCheck() { + @Test + void findActionWithDetailsPermissionsCheck() { assertPermissions(() -> controllerManagement.findActionWithDetails(1L), List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE)); } /** * Tests ControllerManagement#findActionStatusByAction() method */ - @Test void findActionStatusByActionPermissionsCheck() { + @Test + void findActionStatusByActionPermissionsCheck() { assertPermissions(() -> controllerManagement.findActionStatusByAction(1L, Pageable.unpaged()), List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE)); } @@ -100,7 +109,8 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ControllerManagement#findOrRegisterTargetIfItDoesNotExist() method */ - @Test void findOrRegisterTargetIfItDoesNotExistPermissionsCheck() { + @Test + void findOrRegisterTargetIfItDoesNotExistPermissionsCheck() { assertPermissions(() -> controllerManagement.findOrRegisterTargetIfItDoesNotExist("controllerId", URI.create("someaddress")), List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE)); } @@ -108,7 +118,8 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ControllerManagement#findOrRegisterTargetIfItDoesNotExist() method */ - @Test void findOrRegisterTargetIfItDoesNotExistWithDetailsPermissionsCheck() { + @Test + void findOrRegisterTargetIfItDoesNotExistWithDetailsPermissionsCheck() { assertPermissions( () -> controllerManagement.findOrRegisterTargetIfItDoesNotExist("controllerId", URI.create("someaddress"), "name", "type"), List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE)); @@ -117,7 +128,8 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ControllerManagement#getActionForDownloadByTargetAndSoftwareModule() method */ - @Test void getActionForDownloadByTargetAndSoftwareModulePermissionsCheck() { + @Test + void getActionForDownloadByTargetAndSoftwareModulePermissionsCheck() { assertPermissions(() -> controllerManagement.getActionForDownloadByTargetAndSoftwareModule("controllerId", 1L), List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE)); } @@ -125,21 +137,24 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ControllerManagement#getPollingTime() method */ - @Test void getPollingTimePermissionsCheck() { + @Test + void getPollingTimePermissionsCheck() { assertPermissions(() -> controllerManagement.getPollingTime(), List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE)); } /** * Tests ControllerManagement#getMinPollingTime() method */ - @Test void getMinPollingTimePermissionsCheck() { + @Test + void getMinPollingTimePermissionsCheck() { assertPermissions(() -> controllerManagement.getMinPollingTime(), List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE)); } /** * Tests ControllerManagement#getMaxPollingTime() method */ - @Test void getMaintenanceWindowPollCountPermissionsCheck() { + @Test + void getMaintenanceWindowPollCountPermissionsCheck() { assertPermissions(() -> controllerManagement.getMaintenanceWindowPollCount(), List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE)); } @@ -147,7 +162,8 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ControllerManagement#getPollingTimeForAction() method */ - @Test void getPollingTimeForActionPermissionsCheck() { + @Test + void getPollingTimeForActionPermissionsCheck() { final JpaAction action = new JpaAction(); action.setId(1L); assertPermissions(() -> { @@ -163,7 +179,8 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ControllerManagement#hasTargetArtifactAssigned() method */ - @Test void hasTargetArtifactAssignedPermissionsCheck() { + @Test + void hasTargetArtifactAssignedPermissionsCheck() { assertPermissions(() -> controllerManagement.hasTargetArtifactAssigned("controllerId", "sha1Hash"), List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE)); } @@ -171,7 +188,8 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ControllerManagement#hasTargetArtifactAssigned() method */ - @Test void hasTargetArtifactAssignedByIdPermissionsCheck() { + @Test + void hasTargetArtifactAssignedByIdPermissionsCheck() { assertPermissions(() -> controllerManagement.hasTargetArtifactAssigned(1L, "sha1Hash"), List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE)); } @@ -179,7 +197,8 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ControllerManagement#updateControllerAttributes() method */ - @Test void updateControllerAttributesPermissionsCheck() { + @Test + void updateControllerAttributesPermissionsCheck() { assertPermissions(() -> controllerManagement.updateControllerAttributes("controllerId", Map.of(), null), List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE)); } @@ -187,7 +206,8 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ControllerManagement#getByControllerId() method */ - @Test void getByControllerIdPermissionsCheck() { + @Test + void getByControllerIdPermissionsCheck() { assertPermissions(() -> controllerManagement.getByControllerId("controllerId"), List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE)); assertPermissions(() -> controllerManagement.getByControllerId("controllerId"), @@ -197,7 +217,8 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ControllerManagement#get() method */ - @Test void getPermissionsCheck() { + @Test + void getPermissionsCheck() { assertPermissions(() -> controllerManagement.get(1L), List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE)); assertPermissions(() -> controllerManagement.get(1L), List.of(SpPermission.SpringEvalExpressions.SYSTEM_ROLE)); } @@ -205,7 +226,8 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ControllerManagement#getActionHistoryMessages() method */ - @Test void getActionHistoryMessagesPermissionsCheck() { + @Test + void getActionHistoryMessagesPermissionsCheck() { assertPermissions(() -> controllerManagement.getActionHistoryMessages(1L, 1), List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE)); } @@ -213,7 +235,8 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ControllerManagement#cancelAction() method */ - @Test void cancelActionPermissionsCheck() { + @Test + void cancelActionPermissionsCheck() { final JpaAction action = new JpaAction(); action.setId(1L); assertPermissions(() -> { @@ -229,7 +252,8 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ControllerManagement#updateActionExternalRef() method */ - @Test void updateActionExternalRefPermissionsCheck() { + @Test + void updateActionExternalRefPermissionsCheck() { assertPermissions(() -> { controllerManagement.updateActionExternalRef(1L, "externalRef"); return null; @@ -239,7 +263,8 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ControllerManagement#getActionByExternalRef() method */ - @Test void getActionByExternalRefPermissionsCheck() { + @Test + void getActionByExternalRefPermissionsCheck() { assertPermissions(() -> controllerManagement.getActionByExternalRef("externalRef"), List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE)); } @@ -247,7 +272,8 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ControllerManagement#deleteExistingTarget() method */ - @Test void deleteExistingTargetPermissionsCheck() { + @Test + void deleteExistingTargetPermissionsCheck() { assertPermissions(() -> { controllerManagement.deleteExistingTarget("controllerId"); return null; @@ -257,7 +283,8 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ControllerManagement#getInstalledActionByTarget() method */ - @Test void getInstalledActionByTargetPermissionsCheck() { + @Test + void getInstalledActionByTargetPermissionsCheck() { final Target target = testdataFactory.createTarget(); assertPermissions( () -> controllerManagement.getInstalledActionByTarget(target), @@ -267,7 +294,8 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ControllerManagement#activateAutoConfirmation() method */ - @Test void activateAutoConfirmationPermissionsCheck() { + @Test + void activateAutoConfirmationPermissionsCheck() { assertPermissions( () -> controllerManagement.activateAutoConfirmation("controllerId", "initiator", "remark"), List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE)); @@ -276,7 +304,8 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ControllerManagement#deactivateAutoConfirmation() method */ - @Test void deactivateAutoConfirmationPermissionsCheck() { + @Test + void deactivateAutoConfirmationPermissionsCheck() { assertPermissions(() -> { controllerManagement.deactivateAutoConfirmation("controllerId"); return null; @@ -286,7 +315,8 @@ class ControllerManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ControllerManagement#updateOfflineAssignedVersion() method */ - @Test void updateOfflineAssignedVersionPermissionsCheck() { + @Test + void updateOfflineAssignedVersionPermissionsCheck() { assertPermissions(() -> controllerManagement.updateOfflineAssignedVersion("controllerId", "distributionName", "version"), List.of(SpPermission.SpringEvalExpressions.CONTROLLER_ROLE)); } 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 3f3b76df9..2de884c28 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 @@ -97,7 +97,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { /** * Ensures that target attribute update fails if quota hits. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 2) }) void updateTargetAttributesFailsIfTooManyEntries() throws Exception { @@ -137,7 +138,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { /** * Checks if invalid values of attribute-key and attribute-value are handled correctly */ - @Test void updateTargetAttributesFailsForInvalidAttributes() { + @Test + void updateTargetAttributesFailsForInvalidAttributes() { final String controllerId = "targetId123"; testdataFactory.createTarget(controllerId); @@ -168,7 +170,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { /** * Controller providing status entries fails if providing more than permitted by quota. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @@ -194,7 +197,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { /** * Test to verify the storage and retrieval of action history. */ - @Test void findMessagesByActionStatusId() { + @Test + void findMessagesByActionStatusId() { final DistributionSet testDs = testdataFactory.createDistributionSet("1"); final List testTarget = testdataFactory.createTargets(1); @@ -220,7 +224,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { /** * Verifies that the quota specifying the maximum number of status entries per action is enforced. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 2), @Expect(type = DistributionSetCreatedEvent.class, count = 2), @Expect(type = SoftwareModuleCreatedEvent.class, count = 6), @@ -259,7 +264,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { /** * Verifies that the quota specifying the maximum number of messages per action status is enforced. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @@ -290,7 +296,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { /** * Verifies that a DOWNLOAD_ONLY action is not marked complete when the controller reports DOWNLOAD */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @@ -380,7 +387,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { /** * Controller confirms successful update with FINISHED status. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @@ -408,7 +416,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { /** * Controller confirmation fails with invalid messages. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @@ -471,7 +480,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { /** * Update server rejects cancellation feedback if action is not in CANCELING state. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @@ -497,7 +507,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { /** * Controller confirms action cancellation with FINISHED status. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @@ -529,7 +540,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { /** * Controller confirms action cancellation with FINISHED status. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @@ -670,7 +682,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { /** * Register a controller which does not exist */ - @Test @WithUser(principal = "controller", authorities = { CONTROLLER_ROLE }) + @Test + @WithUser(principal = "controller", authorities = { CONTROLLER_ROLE }) @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 2) }) @@ -686,7 +699,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { /** * Register a controller with name which does not exist and update its name */ - @Test @WithUser(principal = "controller", authorities = { CONTROLLER_ROLE }) + @Test + @WithUser(principal = "controller", authorities = { CONTROLLER_ROLE }) @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 2), @@ -704,7 +718,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { /** * Register a controller which does not exist with existing target type and update its target type to another existing one */ - @Test @WithUser(principal = "controller", authorities = { CONTROLLER_ROLE }) + @Test + @WithUser(principal = "controller", authorities = { CONTROLLER_ROLE }) @ExpectEvents({ @Expect(type = TargetTypeCreatedEvent.class, count = 2), @Expect(type = TargetCreatedEvent.class, count = 1), @@ -728,7 +743,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { /** * Register a controller which does not exist with existing target type and update its target type to non existing one */ - @Test @WithUser(principal = "controller", authorities = { CONTROLLER_ROLE }) + @Test + @WithUser(principal = "controller", authorities = { CONTROLLER_ROLE }) @ExpectEvents({ @Expect(type = TargetTypeCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1), @@ -748,7 +764,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { /** * Register a controller which does not exist with existing target type and unassign its target type */ - @Test @WithUser(principal = "controller", authorities = { CONTROLLER_ROLE }) + @Test + @WithUser(principal = "controller", authorities = { CONTROLLER_ROLE }) @ExpectEvents({ @Expect(type = TargetTypeCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1), @@ -769,7 +786,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { /** * Register a controller which does not exist without target type and update its target type to existing one */ - @Test @WithUser(principal = "controller", authorities = { CONTROLLER_ROLE }) + @Test + @WithUser(principal = "controller", authorities = { CONTROLLER_ROLE }) @ExpectEvents({ @Expect(type = TargetTypeCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1), @@ -792,7 +810,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { /** * Register a controller which does not exist with non existing target type and update its target type to existing one */ - @Test @WithUser(principal = "controller", authorities = { CONTROLLER_ROLE }) + @Test + @WithUser(principal = "controller", authorities = { CONTROLLER_ROLE }) @ExpectEvents({ @Expect(type = TargetTypeCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1), @@ -815,7 +834,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { /** * Tries to register a target with an invalid controller id */ - @Test void findOrRegisterTargetIfItDoesNotExistThrowsExceptionForInvalidControllerIdParam() { + @Test + void findOrRegisterTargetIfItDoesNotExistThrowsExceptionForInvalidControllerIdParam() { assertThatExceptionOfType(ConstraintViolationException.class) .as("register target with null as controllerId should fail") .isThrownBy(() -> controllerManagement.findOrRegisterTargetIfItDoesNotExist(null, LOCALHOST)); @@ -890,7 +910,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { /** * Register a controller which does not exist, then update the controller twice, first time by providing a name property and second time without a new name */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 3), @Expect(type = TargetUpdatedEvent.class, count = 1) }) @@ -961,7 +982,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { /** * Verify that targetVisible metadata is returned from repository */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleUpdatedEvent.class, count = 6) }) @@ -979,7 +1001,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { /** * Verify that controller registration does not result in a TargetPollEvent if feature is disabled */ - @Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1) }) + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1) }) @SuppressWarnings("java:S2699") // java:S2699 - test tests the fired events, no need for assert void targetPollEventNotSendIfDisabled() { @@ -991,7 +1014,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { /** * Controller tries to finish an update process after it has been finished by an error action status. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @@ -1033,7 +1057,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { /** * Controller tries to finish an update process after it has been finished by an FINISHED action status. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @@ -1127,7 +1152,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { /** * Ensures that target attribute update is reflected by the repository. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 3) }) void updateTargetAttributes() throws Exception { @@ -1154,7 +1180,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { /** * Ensures that target attributes can be updated using different update modes. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 4) }) void updateTargetAttributesWithDifferentUpdateModes() { @@ -1177,7 +1204,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { /** * Verifies that a DOWNLOAD_ONLY action is marked complete once the controller reports DOWNLOADED */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @@ -1204,7 +1232,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { /** * Verifies that a controller can report a FINISHED event for a DOWNLOAD_ONLY non-active action. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @@ -1232,7 +1261,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { /** * Verifies that multiple DOWNLOADED events for a DOWNLOAD_ONLY action are handled. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @@ -1289,7 +1319,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { /** * Verifies that quota is enforced for UpdateActionStatus events for DOWNLOAD_ONLY assignments. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @@ -1337,7 +1368,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { /** * Verifies that quota is enforced for UpdateActionStatus events for FORCED assignments. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @@ -1384,7 +1416,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { /** * Verify that the attaching externalRef to an action is properly stored */ - @Test void updatedExternalRefOnActionIsReallyUpdated() { + @Test + void updatedExternalRefOnActionIsReallyUpdated() { final List allExternalRef = new ArrayList<>(); final List allActionId = new ArrayList<>(); final int numberOfActions = 3; @@ -1416,7 +1449,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { /** * Verify that getting a single action using externalRef works */ - @Test void getActionUsingSingleExternalRef() { + @Test + void getActionUsingSingleExternalRef() { final String knownControllerId = "controllerId"; final String knownExternalRef = "externalRefId"; @@ -1440,7 +1474,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { /** * Verify that assigning version form target works */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 1), @@ -1473,7 +1508,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { /** * Verify that a null externalRef cannot be assigned to an action */ - @Test void externalRefCannotBeNull() { + @Test + void externalRefCannotBeNull() { assertThatExceptionOfType(ConstraintViolationException.class) .as("No ConstraintViolationException thrown when a null externalRef was set on an action") .isThrownBy(() -> controllerManagement.updateActionExternalRef(1L, null)); @@ -1573,7 +1609,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { /** * Actions are exposed according to thier weight in multi assignment mode. */ - @Test void actionsAreExposedAccordingToTheirWeight() { + @Test + void actionsAreExposedAccordingToTheirWeight() { final String targetId = testdataFactory.createTarget().getControllerId(); final DistributionSet ds = testdataFactory.createDistributionSet(); final Long actionWeightNull = assignDistributionSet(ds.getId(), targetId).getAssignedEntity().get(0).getId(); @@ -1607,7 +1644,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { /** * Delete a target on requested target deletion from client side */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1), @Expect(type = TargetDeletedEvent.class, count = 1) }) @@ -1624,7 +1662,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { /** * Delete a target with a non existing thingId */ - @Test @ExpectEvents({ @Expect(type = TargetDeletedEvent.class, count = 0) }) + @Test + @ExpectEvents({ @Expect(type = TargetDeletedEvent.class, count = 0) }) void deleteTargetWithInvalidThingId() { assertThatExceptionOfType(EntityNotFoundException.class) .as("No EntityNotFoundException thrown when deleting a non-existing target") @@ -1635,7 +1674,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { /** * Delete a target after it has been deleted already */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1), @Expect(type = TargetDeletedEvent.class, count = 1) }) @@ -1656,7 +1696,8 @@ class ControllerManagementTest extends AbstractJpaIntegrationTest { /** * When action status code is provided in feedback it is also stored in the action field lastActionStatusCode */ - @Test void lastActionStatusCodeIsSet() { + @Test + void lastActionStatusCodeIsSet() { final Long actionId = createTargetAndAssignDs(); addUpdateActionStatusAndAssert(actionId, Action.Status.RUNNING, 10); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DeploymentManagementSecurityTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DeploymentManagementSecurityTest.java index 7ebe16982..8420dd93b 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DeploymentManagementSecurityTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DeploymentManagementSecurityTest.java @@ -29,7 +29,8 @@ class DeploymentManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void assignDistributionSetsPermissionsCheck() { + @Test + void assignDistributionSetsPermissionsCheck() { assertPermissions(() -> deploymentManagement.assignDistributionSets( List.of(new DeploymentRequest("controllerId", 1L, Action.ActionType.SOFT, 1L, 1, "maintenanceSchedule", "maintenanceWindowDuration", "maintenanceWindowTimeZone", true))), @@ -39,7 +40,8 @@ class DeploymentManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void assignDistributionSetsWithInitiatedByPermissionsCheck() { + @Test + void assignDistributionSetsWithInitiatedByPermissionsCheck() { assertPermissions(() -> deploymentManagement.assignDistributionSets("initiator", List.of(new DeploymentRequest("controllerId", 1L, Action.ActionType.SOFT, 1L, 1, "maintenanceSchedule", "maintenanceWindowDuration", "maintenanceWindowTimeZone", true)), "message"), @@ -49,14 +51,16 @@ class DeploymentManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void offlineAssignedDistributionSetsPermissionsCheck() { + @Test + void offlineAssignedDistributionSetsPermissionsCheck() { assertPermissions(() -> deploymentManagement.offlineAssignedDistributionSets(List.of()), List.of(SpPermission.READ_REPOSITORY)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void offlineAssignedDistributionSetsWithInitiatedByPermissionsCheck() { + @Test + void offlineAssignedDistributionSetsWithInitiatedByPermissionsCheck() { assertPermissions(() -> deploymentManagement.offlineAssignedDistributionSets(List.of(), "initiator"), List.of(SpPermission.READ_REPOSITORY, SpPermission.UPDATE_TARGET)); } @@ -64,42 +68,48 @@ class DeploymentManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void cancelActionPermissionsCheck() { + @Test + void cancelActionPermissionsCheck() { assertPermissions(() -> deploymentManagement.cancelAction(1L), List.of(SpPermission.UPDATE_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void countActionsByTargetWithFilterPermissionsCheck() { + @Test + void countActionsByTargetWithFilterPermissionsCheck() { assertPermissions(() -> deploymentManagement.countActionsByTarget("rsqlParam", "controllerId"), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void countActionsByTargetPermissionsCheck() { + @Test + void countActionsByTargetPermissionsCheck() { assertPermissions(() -> deploymentManagement.countActionsByTarget("controllerId"), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void countActionsAllPermissionsCheck() { + @Test + void countActionsAllPermissionsCheck() { assertPermissions(() -> deploymentManagement.countActionsAll(), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void countActionsPermissionsCheck() { + @Test + void countActionsPermissionsCheck() { assertPermissions(() -> deploymentManagement.countActions("id==1"), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findActionPermissionsCheck() { + @Test + void findActionPermissionsCheck() { assertPermissions(() -> deploymentManagement.findAction(1L), List.of(SpPermission.READ_TARGET)); } @@ -111,14 +121,16 @@ class DeploymentManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findActionsPermissionsCheck() { + @Test + void findActionsPermissionsCheck() { assertPermissions(() -> deploymentManagement.findActions("id==1", Pageable.unpaged()), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findActionsByTargetPermissionsCheck() { + @Test + void findActionsByTargetPermissionsCheck() { assertPermissions(() -> deploymentManagement.findActionsByTarget("rsql==param", "controllerId", Pageable.unpaged()), List.of(SpPermission.READ_TARGET)); } @@ -126,7 +138,8 @@ class DeploymentManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findActionsByTargetWithControllerIdPermissionsCheck() { + @Test + void findActionsByTargetWithControllerIdPermissionsCheck() { assertPermissions(() -> deploymentManagement.findActionsByTarget("controllerId", Pageable.unpaged()), List.of(SpPermission.READ_TARGET)); } @@ -134,35 +147,40 @@ class DeploymentManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findActionStatusByActionPermissionsCheck() { + @Test + void findActionStatusByActionPermissionsCheck() { assertPermissions(() -> deploymentManagement.findActionStatusByAction(1L, Pageable.unpaged()), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void countActionStatusByActionPermissionsCheck() { + @Test + void countActionStatusByActionPermissionsCheck() { assertPermissions(() -> deploymentManagement.countActionStatusByAction(1L), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findMessagesByActionStatusIdPermissionsCheck() { + @Test + void findMessagesByActionStatusIdPermissionsCheck() { assertPermissions(() -> deploymentManagement.findMessagesByActionStatusId(1L, PAGE), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findActionWithDetailsPermissionsCheck() { + @Test + void findActionWithDetailsPermissionsCheck() { assertPermissions(() -> deploymentManagement.findActionWithDetails(1L), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findActiveActionsByTargetPermissionsCheck() { + @Test + void findActiveActionsByTargetPermissionsCheck() { assertPermissions(() -> deploymentManagement.findActiveActionsByTarget("controllerId", Pageable.unpaged()), List.of(SpPermission.READ_TARGET)); } @@ -170,7 +188,8 @@ class DeploymentManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findInActiveActionsByTargetPermissionsCheck() { + @Test + void findInActiveActionsByTargetPermissionsCheck() { assertPermissions(() -> deploymentManagement.findInActiveActionsByTarget("controllerId", Pageable.unpaged()), List.of(SpPermission.READ_TARGET)); } @@ -178,28 +197,32 @@ class DeploymentManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findActiveActionsWithHighestWeightPermissionsCheck() { + @Test + void findActiveActionsWithHighestWeightPermissionsCheck() { assertPermissions(() -> deploymentManagement.findActiveActionsWithHighestWeight("controllerId", 1), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void forceQuitActionPermissionsCheck() { + @Test + void forceQuitActionPermissionsCheck() { assertPermissions(() -> deploymentManagement.forceQuitAction(1L), List.of(SpPermission.UPDATE_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void forceTargetActionPermissionsCheck() { + @Test + void forceTargetActionPermissionsCheck() { assertPermissions(() -> deploymentManagement.forceTargetAction(1L), List.of(SpPermission.UPDATE_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void cancelInactiveScheduledActionsForTargetsPermissionsCheck() { + @Test + void cancelInactiveScheduledActionsForTargetsPermissionsCheck() { assertPermissions(() -> { deploymentManagement.cancelInactiveScheduledActionsForTargets(List.of(1L)); return null; @@ -209,7 +232,8 @@ class DeploymentManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void startScheduledActionsByRolloutGroupParentPermissionsCheck() { + @Test + void startScheduledActionsByRolloutGroupParentPermissionsCheck() { assertPermissions(() -> { deploymentManagement.startScheduledActionsByRolloutGroupParent(1L, 1L, 1L); return null; @@ -219,7 +243,8 @@ class DeploymentManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void startScheduledActionsPermissionsCheck() { + @Test + void startScheduledActionsPermissionsCheck() { assertPermissions(() -> { deploymentManagement.startScheduledActions(List.of()); return null; @@ -229,21 +254,24 @@ class DeploymentManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void getAssignedDistributionSetPermissionsCheck() { + @Test + void getAssignedDistributionSetPermissionsCheck() { assertPermissions(() -> deploymentManagement.getAssignedDistributionSet("controllerId"), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void getInstalledDistributionSetPermissionsCheck() { + @Test + void getInstalledDistributionSetPermissionsCheck() { assertPermissions(() -> deploymentManagement.getInstalledDistributionSet("controllerId"), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void deleteActionsByStatusAndLastModifiedBeforePermissionsCheck() { + @Test + void deleteActionsByStatusAndLastModifiedBeforePermissionsCheck() { assertPermissions(() -> deploymentManagement.deleteActionsByStatusAndLastModifiedBefore(Set.of(Action.Status.CANCELED), 1L), List.of(SpPermission.SpringEvalExpressions.SYSTEM_ROLE)); } @@ -251,14 +279,16 @@ class DeploymentManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void hasPendingCancellationsPermissionsCheck() { + @Test + void hasPendingCancellationsPermissionsCheck() { assertPermissions(() -> deploymentManagement.hasPendingCancellations(1L), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void cancelActionsForDistributionSetPermissionsCheck() { + @Test + void cancelActionsForDistributionSetPermissionsCheck() { assertPermissions(() -> { deploymentManagement.cancelActionsForDistributionSet(DistributionSetInvalidation.CancelationType.FORCE, entityFactory.distributionSet().create().build()); 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 2a7c7d801..a54fca843 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 @@ -105,7 +105,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { /** * Tests that an exception is thrown when a target is assigned to an incomplete distribution set */ - @Test void verifyAssignTargetsToIncompleteDistribution() { + @Test + void verifyAssignTargetsToIncompleteDistribution() { final DistributionSet distributionSet = testdataFactory.createIncompleteDistributionSet(); final Target target = testdataFactory.createTarget(); @@ -117,7 +118,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { /** * Tests that an exception is thrown when a target is assigned to an invalidated distribution set */ - @Test void verifyAssignTargetsToInvalidDistribution() { + @Test + void verifyAssignTargetsToInvalidDistribution() { final DistributionSet distributionSet = testdataFactory.createAndInvalidateDistributionSet(); final Target target = testdataFactory.createTarget(); @@ -167,7 +169,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { /** * Test verifies that the repistory retrieves the action including all defined (lazy) details. */ - @Test void findActionWithLazyDetails() { + @Test + void findActionWithLazyDetails() { final DistributionSet testDs = testdataFactory.createDistributionSet("TestDs", "1.0", new ArrayList<>()); final List testTarget = testdataFactory.createTargets(1); @@ -185,7 +188,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { /** * Test verifies that actions of a target are found by using id-based search. */ - @Test void findActionByTargetId() { + @Test + void findActionByTargetId() { final DistributionSet testDs = testdataFactory.createDistributionSet("TestDs", "1.0", new ArrayList<>()); final List testTarget = testdataFactory.createTargets(1); // one action with one action status is generated @@ -202,7 +206,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { /** * Test verifies that the 'max actions per target' quota is enforced. */ - @Test void assertMaxActionsPerTargetQuotaIsEnforced() { + @Test + void assertMaxActionsPerTargetQuotaIsEnforced() { enableMultiAssignments(); final int maxActions = quotaManagement.getMaxActionsPerTarget(); @@ -221,7 +226,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { /** * An assignment request with more assignments than allowed by 'maxTargetDistributionSetAssignmentsPerManualAssignment' quota throws an exception. */ - @Test void assignmentRequestThatIsTooLarge() { + @Test + void assignmentRequestThatIsTooLarge() { final int maxActions = quotaManagement.getMaxTargetDistributionSetAssignmentsPerManualAssignment(); final DistributionSet ds1 = testdataFactory.createDistributionSet("1"); final DistributionSet ds2 = testdataFactory.createDistributionSet("2"); @@ -236,7 +242,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { /** * Test verifies that action-states of an action are found by using id-based search. */ - @Test void findActionStatusByActionId() { + @Test + void findActionStatusByActionId() { final DistributionSet testDs = testdataFactory.createDistributionSet("TestDs", "1.0", Collections.emptyList()); final List testTarget = testdataFactory.createTargets(1); // one action with one action status is generated @@ -254,7 +261,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { /** * Test verifies that messages of an action-status are found by using id-based search. */ - @Test void findMessagesByActionStatusId() { + @Test + void findMessagesByActionStatusId() { final DistributionSet testDs = testdataFactory.createDistributionSet("TestDs", "1.0", new ArrayList<>()); final List testTarget = testdataFactory.createTargets(1); // one action with one action status is generated @@ -281,7 +289,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { /** * Ensures that tag to distribution set assignment that does not exist will cause EntityNotFoundException. */ - @Test void assignDistributionSetToTagThatDoesNotExistThrowsException() { + @Test + void assignDistributionSetToTagThatDoesNotExistThrowsException() { final List assignDS = new ArrayList<>(5); for (int i = 0; i < 4; i++) { assignDS.add(testdataFactory.createDistributionSet("DS" + i, "1.0", Collections.emptyList()).getId()); @@ -300,7 +309,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { /** * Test verifies that an assignment with automatic cancelation works correctly even if the update is split into multiple partitions on the database. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 20), @Expect(type = TargetUpdatedEvent.class, count = 40), @Expect(type = TargetAssignDistributionSetEvent.class, count = 2), @@ -428,7 +438,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { /** * Force Quit an Assignment. Expected behaviour is that the action is canceled and is marked as deleted. The assigned Software module */ - @Test void forceQuitSetActionToInactive() { + @Test + void forceQuitSetActionToInactive() { final Action action = prepareFinishedUpdate("4712", "installed", true); final Target target = action.getTarget(); final DistributionSet dsInstalled = action.getDistributionSet(); @@ -464,7 +475,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { /** * Force Quit an not canceled Assignment. Expected behaviour is that the action can not be force quit and there is thrown an exception. */ - @Test void forceQuitNotAllowedThrowsException() { + @Test + void forceQuitNotAllowedThrowsException() { final Action action = prepareFinishedUpdate("4712", "installed", true); // verify initial status assertThat(targetManagement.getByControllerID("4712").get().getUpdateStatus()).as("wrong update status") @@ -533,7 +545,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { /** * Offline assign multiple DSs to a single Target in multiassignment mode. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 4), @Expect(type = ActionCreatedEvent.class, count = 4), @@ -570,7 +583,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { /** * Verifies that if an account is set to action autoclose running actions in case of a new assigned set get closed and set to CANCELED. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 10), @Expect(type = TargetUpdatedEvent.class, count = 20), @Expect(type = ActionCreatedEvent.class, count = 20), @@ -614,7 +628,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { /** * If multi-assignment is enabled, verify that the previous Distribution Set assignment is not canceled when a new one is assigned. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 10), @Expect(type = TargetUpdatedEvent.class, count = 20), @Expect(type = ActionCreatedEvent.class, count = 20), @@ -646,7 +661,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { /** * Assign multiple DSs to a single Target in one request in multiassignment mode. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 4), @Expect(type = ActionCreatedEvent.class, count = 4), @@ -684,7 +700,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { /** * Assign multiple DSs to single Target in one request in multiAssignment mode and cancel each created action afterwards. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 4), @Expect(type = ActionCreatedEvent.class, count = 4), @@ -721,7 +738,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { /** * A Request resulting in multiple assignments to a single target is only allowed when multiassignment is enabled. */ - @Test void multipleAssignmentsToTargetOnlyAllowedInMultiAssignMode() { + @Test + void multipleAssignmentsToTargetOnlyAllowedInMultiAssignMode() { final Target target = testdataFactory.createTarget(); final List distributionSets = testdataFactory.createDistributionSets(2); @@ -743,7 +761,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { /** * Assigning distribution set to the list of targets with a non-existing one leads to successful assignment of valid targets, while not found targets are silently ignored. */ - @Test void assignDistributionSetToNotExistingTarget() { + @Test + void assignDistributionSetToNotExistingTarget() { final String notExistingId = "notExistingTarget"; final DistributionSet createdDs = testdataFactory.createDistributionSet(); @@ -848,7 +867,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { /** * Multiple assignments with confirmation flow active will result in correct cancel behaviour */ - @Test void multipleAssignmentWithConfirmationFlowActiveVerifyCancelBehaviour() { + @Test + void multipleAssignmentWithConfirmationFlowActiveVerifyCancelBehaviour() { final Target target = testdataFactory.createTarget("firstDevice"); final DistributionSet firstDs = testdataFactory.createDistributionSet(); final DistributionSet secondDs = testdataFactory.createDistributionSet(); @@ -885,7 +905,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { /** * Assignments with confirmation flow deactivated will result in actions in only in 'RUNNING' state */ - @Test void verifyConfirmationRequiredFlagHaveNoInfluenceIfFlowIsDeactivated() { + @Test + void verifyConfirmationRequiredFlagHaveNoInfluenceIfFlowIsDeactivated() { 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(); @@ -911,7 +932,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { /** * Duplicate Assignments are removed from a request when multiassignment is disabled, otherwise not */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @@ -942,7 +964,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { /** * An assignment request is not accepted if it would lead to a target exceeding the max actions per target quota. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 21), // max actions per target are 20 for test @Expect(type = SoftwareModuleCreatedEvent.class, count = 3 * 21), @@ -972,7 +995,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { /** * An assignment request without a weight is ok when multi assignment in enabled. */ - @Test void weightNotRequiredInMultiAssignmentMode() { + @Test + void weightNotRequiredInMultiAssignmentMode() { final String targetId = testdataFactory.createTarget().getControllerId(); final Long dsId = testdataFactory.createDistributionSet().getId(); @@ -986,7 +1010,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { /** * An assignment request containing a weight don't causes an error when multi assignment in disabled. */ - @Test void weightAllowedWhenMultiAssignmentModeNotEnabled() { + @Test + void weightAllowedWhenMultiAssignmentModeNotEnabled() { final String targetId = testdataFactory.createTarget().getControllerId(); final Long dsId = testdataFactory.createDistributionSet().getId(); @@ -997,7 +1022,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { /** * Weights are validated and contained in the resulting Action. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @@ -1041,7 +1067,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { /** * Simple deployment or distribution set to target assignment test. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @@ -1098,7 +1125,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { /** * Test that it is not possible to assign a distribution set that is not complete. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = SoftwareModuleCreatedEvent.class, count = 2), @@ -1350,7 +1378,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { /** * Deletes multiple targets and verifies that all related metadata is also deleted. */ - @Test void deletesTargetsAndVerifyCascadeDeletes() { + @Test + void deletesTargetsAndVerifyCascadeDeletes() { final String undeployedTargetPrefix = "undep-T"; final int noOfUndeployedTargets = 2; @@ -1377,7 +1406,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { /** * Testing if changing target and the status without refreshing the entities from the DB (e.g. concurrent changes from UI and from controller) works */ - @Test void alternatingAssignmentAndAddUpdateActionStatus() { + @Test + void alternatingAssignmentAndAddUpdateActionStatus() { final DistributionSet dsA = testdataFactory.createDistributionSet("a"); final DistributionSet dsB = testdataFactory.createDistributionSet("b"); @@ -1471,7 +1501,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { /** * Tests the switch from a soft to hard update by API */ - @Test void forceSoftAction() { + @Test + void forceSoftAction() { // prepare final Target target = testdataFactory.createTarget("knownControllerId"); final DistributionSet ds = testdataFactory.createDistributionSet("a"); @@ -1494,7 +1525,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { /** * Tests the switch from a hard to hard update by API, e.g. which in fact should not change anything. */ - @Test void forceAlreadyForcedActionNothingChanges() { + @Test + void forceAlreadyForcedActionNothingChanges() { // prepare final Target target = testdataFactory.createTarget("knownControllerId"); final DistributionSet ds = testdataFactory.createDistributionSet("a"); @@ -1518,7 +1550,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { /** * Tests the computation of already assigned entities returned as a result of an assignment */ - @Test void testAlreadyAssignedAndAssignedActionsInAssignmentResult() { + @Test + void testAlreadyAssignedAndAssignedActionsInAssignmentResult() { // create target1, distributionSet, assign ds to target1 and finish // update (close all actions) final Action action = prepareFinishedUpdate("target1", "ds", false); @@ -1548,7 +1581,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { /** * Verify that the DistributionSetAssignmentResult not contains already assigned targets. */ - @Test void verifyDistributionSetAssignmentResultNotContainsAlreadyAssignedTargets() { + @Test + void verifyDistributionSetAssignmentResultNotContainsAlreadyAssignedTargets() { final DistributionSet dsToTargetAssigned = testdataFactory.createDistributionSet("ds-3"); // create assigned DS @@ -1566,7 +1600,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { /** * Verify that the DistributionSet assignments work for multiple targets of the same target type within the same request. */ - @Test void verifyDSAssignmentForMultipleTargetsWithSameTargetType() { + @Test + void verifyDSAssignmentForMultipleTargetsWithSameTargetType() { final DistributionSet ds = testdataFactory.createDistributionSet("test-ds"); final TargetType targetType = testdataFactory.createTargetType("test-type", Collections.singletonList(ds.getType())); @@ -1592,7 +1627,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { /** * Verify that the DistributionSet assignments work for multiple targets of different target types. */ - @Test void verifyDSAssignmentForMultipleTargetsWithDifferentTargetTypes() { + @Test + void verifyDSAssignmentForMultipleTargetsWithDifferentTargetTypes() { final DistributionSet ds = testdataFactory.createDistributionSet("test-ds"); final TargetType targetType1 = testdataFactory.createTargetType("test-type1", Collections.singletonList(ds.getType())); final TargetType targetType2 = testdataFactory.createTargetType("test-type2", Collections.singletonList(ds.getType())); @@ -1618,7 +1654,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { /** * Verify that the DistributionSet assignment fails for target with incompatible target type. */ - @Test void verifyDSAssignmentFailsForTargetsWithIncompatibleTargetTypes() { + @Test + void verifyDSAssignmentFailsForTargetsWithIncompatibleTargetTypes() { final DistributionSet ds = testdataFactory.createDistributionSet("test-ds"); final DistributionSetType dsType = testdataFactory.findOrCreateDistributionSetType("test-ds-type", "dsType"); final TargetType targetType = testdataFactory.createTargetType("target-type", @@ -1636,7 +1673,8 @@ class DeploymentManagementTest extends AbstractJpaIntegrationTest { /** * Verify that the DistributionSet assignment fails for target with target type that is not compatible with any dsType. */ - @Test void verifyDSAssignmentFailsForTargetsWithTargetTypesThatAreNotCompatibleWithAnyDs() { + @Test + void verifyDSAssignmentFailsForTargetsWithTargetTypesThatAreNotCompatibleWithAnyDs() { final DistributionSet ds = testdataFactory.createDistributionSet("test-ds"); final TargetType emptyTargetType = testdataFactory.createTargetType("target-type", Collections.emptyList()); final Target targetWithEmptyType = testdataFactory.createTarget("test-target", "test-target", 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 f3799a501..ffff68995 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 @@ -47,7 +47,8 @@ class DistributionSetInvalidationManagementTest extends AbstractJpaIntegrationTe /** * Verify invalidation of distribution sets that only removes distribution sets from auto assignments */ - @Test void verifyInvalidateDistributionSetStopAutoAssignment() { + @Test + void verifyInvalidateDistributionSetStopAutoAssignment() { final InvalidationTestData invalidationTestData = createInvalidationTestData("verifyInvalidateDistributionSetStopAutoAssignment"); final DistributionSetInvalidation distributionSetInvalidation = new DistributionSetInvalidation( @@ -76,7 +77,8 @@ class DistributionSetInvalidationManagementTest extends AbstractJpaIntegrationTe /** * Verify invalidation of distribution sets that removes distribution sets from auto assignments and stops rollouts */ - @Test void verifyInvalidateDistributionSetStopRollouts() { + @Test + void verifyInvalidateDistributionSetStopRollouts() { final InvalidationTestData invalidationTestData = createInvalidationTestData( "verifyInvalidateDistributionSetStopRollouts"); @@ -109,7 +111,8 @@ class DistributionSetInvalidationManagementTest extends AbstractJpaIntegrationTe /** * Verify invalidation of distribution sets that removes distribution sets from auto assignments, stops rollouts and force cancels assignments */ - @Test void verifyInvalidateDistributionSetStopAllAndForceCancel() { + @Test + void verifyInvalidateDistributionSetStopAllAndForceCancel() { final InvalidationTestData invalidationTestData = createInvalidationTestData( "verifyInvalidateDistributionSetStopAllAndForceCancel"); @@ -140,7 +143,8 @@ class DistributionSetInvalidationManagementTest extends AbstractJpaIntegrationTe /** * Verify invalidation of distribution sets that removes distribution sets from auto assignments, stops rollouts and cancels assignments */ - @Test void verifyInvalidateDistributionSetStopAll() { + @Test + void verifyInvalidateDistributionSetStopAll() { final InvalidationTestData invalidationTestData = createInvalidationTestData( "verifyInvalidateDistributionSetStopAll"); @@ -168,7 +172,8 @@ class DistributionSetInvalidationManagementTest extends AbstractJpaIntegrationTe /** * Verify that invalidating an incomplete distribution set throws an exception */ - @Test void verifyInvalidateIncompleteDistributionSetThrowsException() { + @Test + void verifyInvalidateIncompleteDistributionSetThrowsException() { final DistributionSet distributionSet = testdataFactory.createIncompleteDistributionSet(); final DistributionSetInvalidation distributionSetInvalidation = new DistributionSetInvalidation( @@ -194,7 +199,8 @@ class DistributionSetInvalidationManagementTest extends AbstractJpaIntegrationTe /** * Verify that a user that has authority READ_REPOSITORY and UPDATE_REPOSITORY is allowed to invalidate a distribution set */ - @Test @WithUser(authorities = { "READ_REPOSITORY", "UPDATE_REPOSITORY" }) + @Test + @WithUser(authorities = { "READ_REPOSITORY", "UPDATE_REPOSITORY" }) void verifyInvalidateWithReadAndUpdateRepoAuthority() { final InvalidationTestData invalidationTestData = systemSecurityContext .runAsSystem(() -> createInvalidationTestData("verifyInvalidateWithUpdateRepoAuthority")); @@ -210,7 +216,8 @@ class DistributionSetInvalidationManagementTest extends AbstractJpaIntegrationTe /** * Verify that a user that has authority READ_REPOSITORY, UPDATE_REPOSITORY and UPDATE_TARGET is allowed to invalidate a distribution set only without canceling rollouts */ - @Test @WithUser(authorities = { "READ_REPOSITORY", "UPDATE_REPOSITORY", "UPDATE_TARGET" }) + @Test + @WithUser(authorities = { "READ_REPOSITORY", "UPDATE_REPOSITORY", "UPDATE_TARGET" }) void verifyInvalidateWithReadAndUpdateRepoAndUpdateTargetAuthority() { final InvalidationTestData invalidationTestData = systemSecurityContext.runAsSystem( () -> createInvalidationTestData("verifyInvalidateWithUpdateRepoAndUpdateTargetAuthority")); @@ -232,7 +239,8 @@ class DistributionSetInvalidationManagementTest extends AbstractJpaIntegrationTe /** * Verify that a user that has authority READ_REPOSITORY, UPDATE_REPOSITORY, UPDATE_ROLLOUT and UPDATE_TARGET is allowed to invalidate a distribution */ - @Test @WithUser(authorities = { "READ_REPOSITORY", "UPDATE_REPOSITORY", "UPDATE_TARGET", "UPDATE_ROLLOUT" }) + @Test + @WithUser(authorities = { "READ_REPOSITORY", "UPDATE_REPOSITORY", "UPDATE_TARGET", "UPDATE_ROLLOUT" }) void verifyInvalidateWithReadAndUpdateRepoAndUpdateTargetAndUpdateRolloutAuthority() { final InvalidationTestData invalidationTestData = systemSecurityContext.runAsSystem( () -> createInvalidationTestData("verifyInvalidateWithUpdateRepoAndUpdateTargetAuthority")); 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 686611676..6c1bc933f 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 @@ -47,14 +47,16 @@ class DistributionSetManagementSecurityTest /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void assignSoftwareModulesPermissionsCheck() { + @Test + void assignSoftwareModulesPermissionsCheck() { assertPermissions(() -> distributionSetManagement.assignSoftwareModules(1L, List.of(1L)), List.of(SpPermission.UPDATE_REPOSITORY)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void assignTagPermissionsCheck() { + @Test + void assignTagPermissionsCheck() { assertPermissions(() -> distributionSetManagement.assignTag(List.of(1L), 1L), List.of(SpPermission.UPDATE_REPOSITORY, SpPermission.READ_REPOSITORY)); } @@ -62,7 +64,8 @@ class DistributionSetManagementSecurityTest /** * Tests that the method throws InsufficientPermissionException when the user does not have the correct permission */ - @Test void unassignTagPermissionsCheck() { + @Test + void unassignTagPermissionsCheck() { assertPermissions(() -> distributionSetManagement.unassignTag(List.of(1L), 1L), List.of(SpPermission.UPDATE_REPOSITORY, SpPermission.READ_REPOSITORY)); } @@ -70,7 +73,8 @@ class DistributionSetManagementSecurityTest /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void createMetadataPermissionsCheck() { + @Test + void createMetadataPermissionsCheck() { assertPermissions( () -> { distributionSetManagement.createMetadata(1L, Map.of("key", "value")); @@ -82,14 +86,16 @@ class DistributionSetManagementSecurityTest /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void getMetadataPermissiosCheck() { + @Test + void getMetadataPermissiosCheck() { assertPermissions(() -> distributionSetManagement.getMetadata(1L), List.of(SpPermission.READ_REPOSITORY)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void updateMetadataPermissionsCheck() { + @Test + void updateMetadataPermissionsCheck() { assertPermissions(() -> { distributionSetManagement.updateMetadata(1L,"key", "value"); return null; @@ -100,7 +106,8 @@ class DistributionSetManagementSecurityTest /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void deleteMetadataPermissionsCheck() { + @Test + void deleteMetadataPermissionsCheck() { assertPermissions(() -> { distributionSetManagement.deleteMetadata(1L, "key"); return null; @@ -110,7 +117,8 @@ class DistributionSetManagementSecurityTest /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void lockPermissionsCheck() { + @Test + void lockPermissionsCheck() { assertPermissions(() -> { distributionSetManagement.lock(1L); return null; @@ -120,7 +128,8 @@ class DistributionSetManagementSecurityTest /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void unlockPermissionsCheck() { + @Test + void unlockPermissionsCheck() { assertPermissions(() -> { distributionSetManagement.unlock(1L); return null; @@ -130,63 +139,72 @@ class DistributionSetManagementSecurityTest /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void getByActionPermissionsCheck() { + @Test + void getByActionPermissionsCheck() { assertPermissions(() -> distributionSetManagement.findByAction(1L), List.of(SpPermission.READ_REPOSITORY)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void getWithDetailsPermissionsCheck() { + @Test + void getWithDetailsPermissionsCheck() { assertPermissions(() -> distributionSetManagement.getWithDetails(1L), List.of(SpPermission.READ_REPOSITORY)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void getByNameAndVersionPermissionsCheck() { + @Test + void getByNameAndVersionPermissionsCheck() { assertPermissions(() -> distributionSetManagement.findByNameAndVersion("name", "version"), List.of(SpPermission.READ_REPOSITORY)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void getValidAndCompletePermissionsCheck() { + @Test + void getValidAndCompletePermissionsCheck() { assertPermissions(() -> distributionSetManagement.getValidAndComplete(1L), List.of(SpPermission.READ_REPOSITORY)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void getValidPermissionsCheck() { + @Test + void getValidPermissionsCheck() { assertPermissions(() -> distributionSetManagement.getValid(1L), List.of(SpPermission.READ_REPOSITORY)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void getOrElseThrowExceptionPermissionsCheck() { + @Test + void getOrElseThrowExceptionPermissionsCheck() { assertPermissions(() -> distributionSetManagement.getOrElseThrowException(1L), List.of(SpPermission.READ_REPOSITORY)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findByCompletedPermissionsCheck() { + @Test + void findByCompletedPermissionsCheck() { assertPermissions(() -> distributionSetManagement.findByCompleted(true, PAGE), List.of(SpPermission.READ_REPOSITORY)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void countByCompletedPermissionsCheck() { + @Test + void countByCompletedPermissionsCheck() { assertPermissions(() -> distributionSetManagement.countByCompleted(true), List.of(SpPermission.READ_REPOSITORY)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findByDistributionSetFilterPermissionsCheck() { + @Test + void findByDistributionSetFilterPermissionsCheck() { assertPermissions(() -> distributionSetManagement.findByDistributionSetFilter(DistributionSetFilter.builder().build(), PAGE), List.of(SpPermission.READ_REPOSITORY)); } @@ -194,7 +212,8 @@ class DistributionSetManagementSecurityTest /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void countByDistributionSetFilterPermissionsCheck() { + @Test + void countByDistributionSetFilterPermissionsCheck() { assertPermissions(() -> distributionSetManagement.countByDistributionSetFilter(DistributionSetFilter.builder().build()), List.of(SpPermission.READ_REPOSITORY)); } @@ -202,63 +221,72 @@ class DistributionSetManagementSecurityTest /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findByTagPermissionsCheck() { + @Test + void findByTagPermissionsCheck() { assertPermissions(() -> distributionSetManagement.findByTag(1L, PAGE), List.of(SpPermission.READ_REPOSITORY)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findByRsqlAndTagPermissionsCheck() { + @Test + void findByRsqlAndTagPermissionsCheck() { assertPermissions(() -> distributionSetManagement.findByRsqlAndTag("rsql", 1L, PAGE), List.of(SpPermission.READ_REPOSITORY)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void isInUsePermissionsCheck() { + @Test + void isInUsePermissionsCheck() { assertPermissions(() -> distributionSetManagement.isInUse(1L), List.of(SpPermission.READ_REPOSITORY)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void unassignSoftwareModulePermissionsCheck() { + @Test + void unassignSoftwareModulePermissionsCheck() { assertPermissions(() -> distributionSetManagement.unassignSoftwareModule(1L, 1L), List.of(SpPermission.UPDATE_REPOSITORY)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void countByTypeIdPermissionsCheck() { + @Test + void countByTypeIdPermissionsCheck() { assertPermissions(() -> distributionSetManagement.countByTypeId(1L), List.of(SpPermission.READ_REPOSITORY)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void countRolloutsByStatusForDistributionSetPermissionsCheck() { + @Test + void countRolloutsByStatusForDistributionSetPermissionsCheck() { assertPermissions(() -> distributionSetManagement.countRolloutsByStatusForDistributionSet(1L), List.of(SpPermission.READ_REPOSITORY)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void countActionsByStatusForDistributionSetPermissionsCheck() { + @Test + void countActionsByStatusForDistributionSetPermissionsCheck() { assertPermissions(() -> distributionSetManagement.countActionsByStatusForDistributionSet(1L), List.of(SpPermission.READ_REPOSITORY)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void countAutoAssignmentsForDistributionSetPermissionsCheck() { + @Test + void countAutoAssignmentsForDistributionSetPermissionsCheck() { assertPermissions(() -> distributionSetManagement.countAutoAssignmentsForDistributionSet(1L), List.of(SpPermission.READ_REPOSITORY)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void invalidatePermissionsCheck() { + @Test + void invalidatePermissionsCheck() { distributionSetTypeManagement.create(entityFactory.distributionSetType().create().key("type").name("name")); assertPermissions(() -> { distributionSetManagement.invalidate(entityFactory.distributionSet().create().name("name").version("1.0").type("type").build()); 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 730df8c22..469f8d566 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 @@ -83,7 +83,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest { /** * Verifies that management get access react as specified on calls for non existing entities by means of Optional not present. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3) }) void nonExistingEntityAccessReturnsNotPresent() { @@ -168,7 +169,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest { /** * Verify that a DistributionSet with invalid properties cannot be created or updated */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = DistributionSetUpdatedEvent.class) }) @@ -183,7 +185,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest { /** * Ensures that it is not possible to create a DS that already exists (unique constraint is on name,version for DS). */ - @Test void createDuplicateDistributionSetsFailsWithException() { + @Test + void createDuplicateDistributionSetsFailsWithException() { testdataFactory.createDistributionSet("a"); assertThatThrownBy(() -> testdataFactory.createDistributionSet("a")) @@ -193,7 +196,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest { /** * Verifies that a DS is of default type if not specified explicitly at creation time. */ - @Test void createDistributionSetWithImplicitType() { + @Test + void createDistributionSetWithImplicitType() { final DistributionSet set = distributionSetManagement .create(entityFactory.distributionSet().create().name("newtypesoft").version("1")); @@ -206,7 +210,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest { /** * Verifies that a DS cannot be created if another DS with same name and version exists. */ - @Test void createDistributionSetWithDuplicateNameAndVersionFails() { + @Test + void createDistributionSetWithDuplicateNameAndVersionFails() { final DistributionSetCreate distributionSetCreate = entityFactory.distributionSet().create().name("newtypesoft").version("1"); distributionSetManagement.create(distributionSetCreate); @@ -216,7 +221,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest { /** * Verifies that multiple DS are of default type if not specified explicitly at creation time. */ - @Test void createMultipleDistributionSetsWithImplicitType() { + @Test + void createMultipleDistributionSetsWithImplicitType() { final List creates = new ArrayList<>(10); for (int i = 0; i < 10; i++) { creates.add(entityFactory.distributionSet().create().name("newtypesoft" + i).version("1" + i)); @@ -236,7 +242,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest { /** * Checks that metadata for a distribution set can be created. */ - @Test void createMetadata() { + @Test + void createMetadata() { final String knownKey = "dsMetaKnownKey"; final String knownValue = "dsMetaKnownValue"; @@ -248,7 +255,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest { /** * Verifies the enforcement of the metadata quota per distribution set. */ - @Test void createMetadataUntilQuotaIsExceeded() { + @Test + void createMetadataUntilQuotaIsExceeded() { // add meta data one by one final DistributionSet ds1 = testdataFactory.createDistributionSet("ds1"); @@ -293,7 +301,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest { /** * Ensures that distribution sets can assigned and unassigned to a distribution set tag. */ - @Test void assignAndUnassignDistributionSetToTag() { + @Test + void assignAndUnassignDistributionSetToTag() { final List assignDS = new ArrayList<>(4); for (int i = 0; i < 4; i++) { assignDS.add(testdataFactory.createDistributionSet("DS" + i, "1.0", Collections.emptyList()).getId()); @@ -330,7 +339,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest { /** * Ensures that updates concerning the internal software structure of a DS are not possible if the DS is already assigned. */ - @Test void updateDistributionSetForbiddenWithIllegalUpdate() { + @Test + void updateDistributionSetForbiddenWithIllegalUpdate() { // prepare data final Target target = testdataFactory.createTarget(); @@ -360,7 +370,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest { /** * Ensures that it is not possible to add a software module that is not defined of the DS's type. */ - @Test void updateDistributionSetUnsupportedModuleFails() { + @Test + void updateDistributionSetUnsupportedModuleFails() { final Long setId = distributionSetManagement.create( entityFactory.distributionSet().create() .type(distributionSetTypeManagement.create( @@ -382,7 +393,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest { /** * Legal updates of a DS, e.g. name or description and module addition, removal while still unassigned. */ - @Test void updateDistributionSet() { + @Test + void updateDistributionSet() { // prepare data DistributionSet ds = testdataFactory.createDistributionSet(""); final SoftwareModule os = testdataFactory.createSoftwareModuleOs(); @@ -412,7 +424,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest { /** * Verifies that an exception is thrown when trying to update an invalid distribution set */ - @Test void updateInvalidDistributionSet() { + @Test + void updateInvalidDistributionSet() { final DistributionSet distributionSet = testdataFactory.createAndInvalidateDistributionSet(); final DistributionSetUpdate update = entityFactory.distributionSet().update(distributionSet.getId()).name("new_name"); @@ -423,7 +436,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest { /** * Verifies the enforcement of the software module quota per distribution set. */ - @Test void assignSoftwareModulesUntilQuotaIsExceeded() { + @Test + void assignSoftwareModulesUntilQuotaIsExceeded() { // create some software modules final int maxModules = quotaManagement.getMaxSoftwareModulesPerDistributionSet(); @@ -467,7 +481,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest { /** * Verifies that an exception is thrown when trying to assign software modules to an invalidated distribution set. */ - @Test void verifyAssignSoftwareModulesToInvalidDistributionSet() { + @Test + void verifyAssignSoftwareModulesToInvalidDistributionSet() { final Long distributionSetId = testdataFactory.createAndInvalidateDistributionSet().getId(); final List softwareModuleIds = List.of(testdataFactory.createSoftwareModuleOs().getId()); @@ -479,7 +494,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest { /** * Verifies that an exception is thrown when trying to unassign a software module from an invalidated distribution set. */ - @Test void verifyUnassignSoftwareModulesToInvalidDistributionSet() { + @Test + void verifyUnassignSoftwareModulesToInvalidDistributionSet() { final Long distributionSetId = testdataFactory.createDistributionSet().getId(); final Long softwareModuleId = testdataFactory.createSoftwareModuleOs().getId(); distributionSetManagement.assignSoftwareModules(distributionSetId, singletonList(softwareModuleId)); @@ -529,7 +545,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest { /** * searches for distribution sets based on the various filter options, e.g. name, version, desc., tags. */ - @Test void searchDistributionSetsOnFilters() { + @Test + void searchDistributionSetsOnFilters() { DistributionSetTag dsTagA = distributionSetTagManagement .create(entityFactory.tag().create().name("DistributionSetTag-A")); final DistributionSetTag dsTagB = distributionSetTagManagement @@ -595,7 +612,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest { /** * Simple DS load without the related data that should be loaded lazy. */ - @Test void findDistributionSetsWithoutLazy() { + @Test + void findDistributionSetsWithoutLazy() { testdataFactory.createDistributionSets(20); assertThat(distributionSetManagement.findByCompleted(true, PAGE)).hasSize(20); @@ -604,7 +622,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest { /** * Locks a DS. */ - @Test void lockDistributionSet() { + @Test + void lockDistributionSet() { final DistributionSet distributionSet = testdataFactory.createDistributionSet("ds-1"); assertThat( distributionSetManagement.get(distributionSet.getId()).map(DistributionSet::isLocked).orElse(true)) @@ -622,7 +641,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest { /** * Locked a DS could be hard deleted. */ - @Test void deleteUnassignedLockedDistributionSet() { + @Test + void deleteUnassignedLockedDistributionSet() { final DistributionSet distributionSet = testdataFactory.createDistributionSet("ds-1"); distributionSetManagement.lock(distributionSet.getId()); assertThat( @@ -637,7 +657,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest { /** * Locked an assigned DS could be soft deleted. */ - @Test void deleteAssignedLockedDistributionSet() { + @Test + void deleteAssignedLockedDistributionSet() { final DistributionSet distributionSet = testdataFactory.createDistributionSet("ds-1"); distributionSetManagement.lock(distributionSet.getId()); assertThat( @@ -655,7 +676,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest { /** * Unlocks a DS. */ - @Test void unlockDistributionSet() { + @Test + void unlockDistributionSet() { final DistributionSet distributionSet = testdataFactory.createDistributionSet("ds-1"); distributionSetManagement.lock(distributionSet.getId()); assertThat( @@ -676,7 +698,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest { /** * Software modules of a locked DS can't be modified. Expected behaviour is to throw an exception and to do not modify them. */ - @Test void lockDistributionSetApplied() { + @Test + void lockDistributionSetApplied() { final DistributionSet distributionSet = testdataFactory.createDistributionSet("ds-1"); final int softwareModuleCount = distributionSet.getModules().size(); assertThat(softwareModuleCount).isNotZero(); @@ -706,7 +729,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest { /** * Test implicit locks for a DS and skip tags. */ - @Test void isImplicitLockApplicableForDistributionSet() { + @Test + void isImplicitLockApplicableForDistributionSet() { final JpaDistributionSetManagement distributionSetManagement = (JpaDistributionSetManagement) this.distributionSetManagement; final DistributionSet distributionSet = testdataFactory.createDistributionSet("ds-non-skip"); // assert that implicit lock is applicable for non skip tags @@ -734,7 +758,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest { /** * Locks an incomplete DS. Expected behaviour is to throw an exception and to do not lock it. */ - @Test void lockIncompleteDistributionSetFails() { + @Test + void lockIncompleteDistributionSetFails() { final long incompleteDistributionSetId = testdataFactory.createIncompleteDistributionSet().getId(); assertThatExceptionOfType(IncompleteDistributionSetException.class) .as("Locking an incomplete distribution set should throw an exception") @@ -747,7 +772,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest { /** * Deletes a DS that is no in use. Expected behaviour is a hard delete on the database. */ - @Test void deleteUnassignedDistributionSet() { + @Test + void deleteUnassignedDistributionSet() { final DistributionSet ds1 = testdataFactory.createDistributionSet("ds-1"); testdataFactory.createDistributionSet("ds-2"); @@ -762,7 +788,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest { /** * Deletes an invalid distribution set */ - @Test void deleteInvalidDistributionSet() { + @Test + void deleteInvalidDistributionSet() { final DistributionSet set = testdataFactory.createAndInvalidateDistributionSet(); assertThat(distributionSetRepository.findById(set.getId())).isNotEmpty(); distributionSetManagement.delete(set.getId()); @@ -772,7 +799,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest { /** * Deletes an incomplete distribution set */ - @Test void deleteIncompleteDistributionSet() { + @Test + void deleteIncompleteDistributionSet() { final DistributionSet set = testdataFactory.createIncompleteDistributionSet(); assertThat(distributionSetRepository.findById(set.getId())).isNotEmpty(); distributionSetManagement.delete(set.getId()); @@ -782,7 +810,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest { /** * Queries and loads the metadata related to a given distribution set. */ - @Test void getMetadata() { + @Test + void getMetadata() { // create a DS final DistributionSet ds1 = testdataFactory.createDistributionSet("testDs1"); final DistributionSet ds2 = testdataFactory.createDistributionSet("testDs2"); @@ -832,7 +861,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest { /** * Verify that the find all by ids contains the entities which are looking for */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = DistributionSetCreatedEvent.class, count = 12), @Expect(type = SoftwareModuleCreatedEvent.class, count = 36) }) void verifyFindDistributionSetAllById() { @@ -855,7 +885,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest { /** * Verify that an exception is thrown when trying to get an invalid distribution set */ - @Test void verifyGetValid() { + @Test + void verifyGetValid() { final Long distributionSetId = testdataFactory.createAndInvalidateDistributionSet().getId(); assertThatExceptionOfType(InvalidDistributionSetException.class) @@ -869,7 +900,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest { /** * Verify that an exception is thrown when trying to get an incomplete distribution set */ - @Test void verifyGetValidAndComplete() { + @Test + void verifyGetValidAndComplete() { final Long distributionSetId = testdataFactory.createIncompleteDistributionSet().getId(); assertThatExceptionOfType(IncompleteDistributionSetException.class) .as("Incomplete distributionSet should throw an exception") @@ -879,7 +911,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest { /** * Verify that an exception is thrown when trying to create or update metadata for an invalid distribution set. */ - @Test void createMetadataForInvalidDistributionSet() { + @Test + void createMetadataForInvalidDistributionSet() { final String knownKey1 = "myKnownKey1"; final String knownKey2 = "myKnownKey2"; final String knownValue = "myKnownValue"; @@ -905,7 +938,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest { /** * Get the Rollouts count by status statistics for a specific Distribution Set */ - @Test void getRolloutsCountStatisticsForDistributionSet() { + @Test + void getRolloutsCountStatisticsForDistributionSet() { DistributionSet ds1 = testdataFactory.createDistributionSet("DS1"); DistributionSet ds2 = testdataFactory.createDistributionSet("DS2"); DistributionSet ds3 = testdataFactory.createDistributionSet("DS3"); @@ -935,7 +969,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest { /** * Get the Rollouts count by status statistics for a specific Distribution Set */ - @Test void getActionsCountStatisticsForDistributionSet() { + @Test + void getActionsCountStatisticsForDistributionSet() { final DistributionSet ds = testdataFactory.createDistributionSet("DS"); final DistributionSet ds2 = testdataFactory.createDistributionSet("DS2"); testdataFactory.createTargets("targets", 4); @@ -955,7 +990,8 @@ class DistributionSetManagementTest extends AbstractJpaIntegrationTest { /** * Get the Rollouts count by status statistics for a specific Distribution Set */ - @Test void getAutoAssignmentsCountStatisticsForDistributionSet() { + @Test + void getAutoAssignmentsCountStatisticsForDistributionSet() { DistributionSet ds = testdataFactory.createDistributionSet("DS"); DistributionSet ds2 = testdataFactory.createDistributionSet("DS2"); testdataFactory.createTargets("targets", 4); 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 4e333b32d..f74be68ab 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 @@ -45,14 +45,16 @@ class DistributionSetTagManagementSecurityTest extends AbstractRepositoryManagem /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void getByNameWitPermissionWorks() { + @Test + void getByNameWitPermissionWorks() { assertPermissions(() -> distributionSetTagManagement.findByName("tagName"), List.of(SpPermission.READ_REPOSITORY)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findByDistributionSetPermissionsCheck() { + @Test + void findByDistributionSetPermissionsCheck() { assertPermissions(() -> distributionSetTagManagement.findByDistributionSet(1L, Pageable.unpaged()), List.of(SpPermission.READ_REPOSITORY)); } @@ -60,7 +62,8 @@ class DistributionSetTagManagementSecurityTest extends AbstractRepositoryManagem /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void deleteDistributionSetTagPermissionsCheck() { + @Test + void deleteDistributionSetTagPermissionsCheck() { assertPermissions(() -> { distributionSetTagManagement.delete("tagName"); return null; diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetTagManagementTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetTagManagementTest.java index 1a5689b21..90519135d 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetTagManagementTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/DistributionSetTagManagementTest.java @@ -52,7 +52,8 @@ class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest { /** * Verifies that management get access reacts as specified on calls for non existing entities by means of Optional not present. */ - @Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) }) + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) }) void nonExistingEntityAccessReturnsNotPresent() { assertThat(distributionSetTagManagement.findByName(NOT_EXIST_ID)).isNotPresent(); assertThat(distributionSetTagManagement.get(NOT_EXIST_IDL)).isNotPresent(); @@ -77,7 +78,8 @@ class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest { /** * Full DS tag lifecycle tested. Create tags, assign them to sets and delete the tags. */ - @Test void createAndAssignAndDeleteDistributionSetTags() { + @Test + void createAndAssignAndDeleteDistributionSetTags() { final Collection dsAs = testdataFactory.createDistributionSets("DS-A", 20); final Collection dsBs = testdataFactory.createDistributionSets("DS-B", 10); final Collection dsCs = testdataFactory.createDistributionSets("DS-C", 25); @@ -140,7 +142,8 @@ class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest { /** * Verifies assign/unassign. */ - @Test void assignAndUnassignDistributionSetTags() { + @Test + void assignAndUnassignDistributionSetTags() { final Collection groupA = testdataFactory.createDistributionSets(20); final Collection groupB = testdataFactory.createDistributionSets("unassigned", 20); @@ -181,7 +184,8 @@ class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest { /** * Verifies that tagging of set containing missing DS throws meaningful and correct exception. */ - @Test void failOnMissingDs() { + @Test + void failOnMissingDs() { final Collection group = testdataFactory.createDistributionSets(5).stream().map(DistributionSet::getId).toList(); final DistributionSetTag tag = distributionSetTagManagement.create(entityFactory.tag().create().name("tag1").description("tagdesc1")); final List missing = new ArrayList<>(); @@ -210,7 +214,8 @@ class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest { /** * Ensures that a created tag is persisted in the repository as defined. */ - @Test void createDistributionSetTag() { + @Test + void createDistributionSetTag() { final Tag tag = distributionSetTagManagement .create(entityFactory.tag().create().name("kai1").description("kai2").colour("colour")); @@ -225,7 +230,8 @@ class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest { /** * Ensures that a deleted tag is removed from the repository as defined. */ - @Test void deleteDistributionSetTag() { + @Test + void deleteDistributionSetTag() { // create test data final Iterable tags = createDsSetsWithTags(); final DistributionSetTag toDelete = tags.iterator().next(); @@ -253,7 +259,8 @@ class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest { /** * Ensures that a tag cannot be created if one exists already with that name (ecpects EntityAlreadyExistsException). */ - @Test void failedDuplicateDsTagNameException() { + @Test + void failedDuplicateDsTagNameException() { final TagCreate tag = entityFactory.tag().create().name("A"); distributionSetTagManagement.create(tag); @@ -264,7 +271,8 @@ class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest { /** * Ensures that a tag cannot be updated to a name that already exists on another tag (ecpects EntityAlreadyExistsException). */ - @Test void failedDuplicateDsTagNameExceptionAfterUpdate() { + @Test + void failedDuplicateDsTagNameExceptionAfterUpdate() { distributionSetTagManagement.create(entityFactory.tag().create().name("A")); final DistributionSetTag tag = distributionSetTagManagement.create(entityFactory.tag().create().name("B")); @@ -276,7 +284,8 @@ class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest { /** * Tests the name update of a target tag. */ - @Test void updateDistributionSetTag() { + @Test + void updateDistributionSetTag() { // create test data final List tags = createDsSetsWithTags(); // change data @@ -293,7 +302,8 @@ class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest { /** * Ensures that all tags are retrieved through repository. */ - @Test void findDistributionSetTagsAll() { + @Test + void findDistributionSetTagsAll() { final List tags = createDsSetsWithTags(); // test @@ -305,7 +315,8 @@ class DistributionSetTagManagementTest extends AbstractJpaIntegrationTest { /** * Ensures that a created tags are persisted in the repository as defined. */ - @Test void createDistributionSetTags() { + @Test + void createDistributionSetTags() { final List tags = createDsSetsWithTags(); assertThat(distributionSetTagRepository.findAll()).as("Wrong size of tags created").hasSize(tags.size()); } 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 112d92b18..e03dd60a4 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 @@ -45,21 +45,24 @@ class DistributionSetTypeManagementSecurityTest /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void getByKeyPermissionsCheck() { + @Test + void getByKeyPermissionsCheck() { assertPermissions(() -> distributionSetTypeManagement.findByKey("key"), List.of(SpPermission.READ_REPOSITORY)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void getByNamePermissionsCheck() { + @Test + void getByNamePermissionsCheck() { assertPermissions(() -> distributionSetTypeManagement.findByName("name"), List.of(SpPermission.READ_REPOSITORY)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void assignOptionalSoftwareModuleTypesPermissionsCheck() { + @Test + void assignOptionalSoftwareModuleTypesPermissionsCheck() { assertPermissions(() -> distributionSetTypeManagement.assignOptionalSoftwareModuleTypes(1L, List.of(1L)), List.of(SpPermission.UPDATE_REPOSITORY)); } @@ -67,7 +70,8 @@ class DistributionSetTypeManagementSecurityTest /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void assignMandatorySoftwareModuleTypesPermissionsCheck() { + @Test + void assignMandatorySoftwareModuleTypesPermissionsCheck() { assertPermissions(() -> distributionSetTypeManagement.assignMandatorySoftwareModuleTypes(1L, List.of(1L)), List.of(SpPermission.UPDATE_REPOSITORY)); } @@ -75,7 +79,8 @@ class DistributionSetTypeManagementSecurityTest /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void unassignSoftwareModuleTypePermissionsCheck() { + @Test + void unassignSoftwareModuleTypePermissionsCheck() { assertPermissions(() -> distributionSetTypeManagement.unassignSoftwareModuleType(1L, 1L), List.of(SpPermission.UPDATE_REPOSITORY)); } } 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 50cd6cd53..465941f65 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 @@ -97,7 +97,8 @@ class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTest { /** * Verify that a DistributionSet with invalid properties cannot be created or updated */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = DistributionSetUpdatedEvent.class, count = 0) }) @@ -112,7 +113,8 @@ class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTest { /** * Tests the successful module update of unused distribution set type which is in fact allowed. */ - @Test void updateUnassignedDistributionSetTypeModules() { + @Test + void updateUnassignedDistributionSetTypeModules() { final DistributionSetType updatableType = distributionSetTypeManagement .create(entityFactory.distributionSetType().create().key("updatableType").name("to be deleted")); assertThat(distributionSetTypeManagement.findByKey("updatableType").get().getMandatoryModuleTypes()).isEmpty(); @@ -138,7 +140,8 @@ class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTest { /** * Verifies that the quota for software module types per distribution set type is enforced as expected. */ - @Test void quotaMaxSoftwareModuleTypes() { + @Test + void quotaMaxSoftwareModuleTypes() { final int quota = quotaManagement.getMaxSoftwareModuleTypesPerDistributionSetType(); // create software module types final List moduleTypeIds = new ArrayList<>(); @@ -186,7 +189,8 @@ class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTest { /** * Tests the successfull update of used distribution set type meta data which is in fact allowed. */ - @Test void updateAssignedDistributionSetTypeMetaData() { + @Test + void updateAssignedDistributionSetTypeMetaData() { final DistributionSetType nonUpdatableType = createDistributionSetTypeUsedByDs(); distributionSetTypeManagement.update( @@ -200,7 +204,8 @@ class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTest { /** * Tests the unsuccessful update of used distribution set type (module addition). */ - @Test void addModuleToAssignedDistributionSetTypeFails() { + @Test + void addModuleToAssignedDistributionSetTypeFails() { final Long nonUpdatableTypeId = createDistributionSetTypeUsedByDs().getId(); final Set osTypeId = Set.of(osType.getId()); assertThatThrownBy(() -> distributionSetTypeManagement @@ -211,7 +216,8 @@ class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTest { /** * Tests the unsuccessful update of used distribution set type (module removal). */ - @Test void removeModuleToAssignedDistributionSetTypeFails() { + @Test + void removeModuleToAssignedDistributionSetTypeFails() { DistributionSetType nonUpdatableType = distributionSetTypeManagement .create(entityFactory.distributionSetType().create().key("updatableType").name("to be deleted")); assertThat(distributionSetTypeManagement.findByKey("updatableType").get().getMandatoryModuleTypes()).isEmpty(); @@ -229,7 +235,8 @@ class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTest { /** * Tests the successfull deletion of unused (hard delete) distribution set types. */ - @Test void deleteUnassignedDistributionSetType() { + @Test + void deleteUnassignedDistributionSetType() { final JpaDistributionSetType hardDelete = (JpaDistributionSetType) distributionSetTypeManagement .create(entityFactory.distributionSetType().create().key("delete").name("to be deleted")); @@ -242,7 +249,8 @@ class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTest { /** * Tests the successfull deletion of used (soft delete) distribution set types. */ - @Test void deleteAssignedDistributionSetType() { + @Test + void deleteAssignedDistributionSetType() { final int existing = (int) distributionSetTypeManagement.count(); final JpaDistributionSetType toBeDeleted = (JpaDistributionSetType) distributionSetTypeManagement .create(entityFactory.distributionSetType().create().key("softdeleted").name("to be deleted")); @@ -263,7 +271,8 @@ class DistributionSetTypeManagementTest extends AbstractJpaIntegrationTest { /** * Verifies that when no SoftwareModules are assigned to a Distribution then the DistributionSet is not complete. */ - @Test void shouldFailWhenDistributionSetHasNoSoftwareModulesAssigned() { + @Test + void shouldFailWhenDistributionSetHasNoSoftwareModulesAssigned() { final JpaDistributionSetType jpaDistributionSetType = (JpaDistributionSetType) distributionSetTypeManagement .create(entityFactory.distributionSetType().create().key("newType").name("new Type")); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/LazyControllerManagementTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/LazyControllerManagementTest.java index 3b4f7232d..04c59af9e 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/LazyControllerManagementTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/LazyControllerManagementTest.java @@ -39,7 +39,8 @@ class LazyControllerManagementTest extends AbstractJpaIntegrationTest { /** * Verifies that lazy target poll update is executed as specified. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 2) }) void lazyFindOrRegisterTargetIfItDoesNotExist() throws InterruptedException { diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/RolloutGroupManagementSecurityTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/RolloutGroupManagementSecurityTest.java index 2a18eef20..7b383c9b1 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/RolloutGroupManagementSecurityTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/RolloutGroupManagementSecurityTest.java @@ -24,49 +24,56 @@ class RolloutGroupManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void getPermissionsCheck() { + @Test + void getPermissionsCheck() { assertPermissions(() -> rolloutGroupManagement.get(1L), List.of(SpPermission.READ_ROLLOUT)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void getWithDetailedStatusPermissionsCheck() { + @Test + void getWithDetailedStatusPermissionsCheck() { assertPermissions(() -> rolloutGroupManagement.getWithDetailedStatus(1L), List.of(SpPermission.READ_ROLLOUT)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void countByRolloutPermissionsCheck() { + @Test + void countByRolloutPermissionsCheck() { assertPermissions(() -> rolloutGroupManagement.countByRollout(1L), List.of(SpPermission.READ_ROLLOUT)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void countTargetsOfRolloutsGroupPermissionsCheck() { + @Test + void countTargetsOfRolloutsGroupPermissionsCheck() { assertPermissions(() -> rolloutGroupManagement.countTargetsOfRolloutsGroup(1L), List.of(SpPermission.READ_ROLLOUT)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findByRolloutPermissionsCheck() { + @Test + void findByRolloutPermissionsCheck() { assertPermissions(() -> rolloutGroupManagement.findByRollout(1L, PAGE), List.of(SpPermission.READ_ROLLOUT)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findByRolloutAndRsqlPermissionsCheck() { + @Test + void findByRolloutAndRsqlPermissionsCheck() { assertPermissions(() -> rolloutGroupManagement.findByRolloutAndRsql(1L, "name==*", PAGE), List.of(SpPermission.READ_ROLLOUT)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findTargetsOfRolloutGroupPermissionsCheck() { + @Test + void findTargetsOfRolloutGroupPermissionsCheck() { assertPermissions(() -> rolloutGroupManagement.findTargetsOfRolloutGroup(1L, PAGE), List.of(SpPermission.READ_ROLLOUT, SpPermission.READ_TARGET)); } @@ -74,7 +81,8 @@ class RolloutGroupManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findTargetsOfRolloutGroupByRsqlPermissionsCheck() { + @Test + void findTargetsOfRolloutGroupByRsqlPermissionsCheck() { assertPermissions(() -> rolloutGroupManagement.findTargetsOfRolloutGroupByRsql(1L, "name==*", PAGE), List.of(SpPermission.READ_ROLLOUT, SpPermission.READ_TARGET)); } @@ -82,7 +90,8 @@ class RolloutGroupManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findByRolloutAndRsqlWithDetailedStatusPermissionsCheck() { + @Test + void findByRolloutAndRsqlWithDetailedStatusPermissionsCheck() { assertPermissions(() -> rolloutGroupManagement.findByRolloutAndRsqlWithDetailedStatus(1L, "name==*", PAGE), List.of(SpPermission.READ_ROLLOUT)); } @@ -90,7 +99,8 @@ class RolloutGroupManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findByRolloutWithDetailedStatusPermissionsCheck() { + @Test + void findByRolloutWithDetailedStatusPermissionsCheck() { assertPermissions(() -> rolloutGroupManagement.findByRolloutWithDetailedStatus(1L, PAGE), List.of(SpPermission.READ_ROLLOUT)); } } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/RolloutGroupManagementTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/RolloutGroupManagementTest.java index ce46e4dc5..7f17cacf0 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/RolloutGroupManagementTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/RolloutGroupManagementTest.java @@ -76,7 +76,8 @@ class RolloutGroupManagementTest extends AbstractJpaIntegrationTest { /** * Tests the rollout group status mapping. */ - @Test void testRolloutGroupStatusConvert() { + @Test + void testRolloutGroupStatusConvert() { final long id = rolloutGroupRepository.findByRolloutId( testdataFactory.createAndStartRollout(1, 0, 1, "100", "80").getId(), PAGE).getContent() .get(0).getId(); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/RolloutManagementFlowTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/RolloutManagementFlowTest.java index 169c9e4d6..4e7fd0296 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/RolloutManagementFlowTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/RolloutManagementFlowTest.java @@ -47,7 +47,8 @@ class RolloutManagementFlowTest extends AbstractJpaIntegrationTest { /** * Verifies a simple rollout flow */ - @Test void rolloutFlow() { + @Test + void rolloutFlow() { final String rolloutName = "rollout-std"; final int amountGroups = 5; // static only final String targetPrefix = "controller-rollout-std-"; @@ -88,7 +89,8 @@ class RolloutManagementFlowTest extends AbstractJpaIntegrationTest { /** * Verifies a simple dynamic rollout flow */ - @Test void dynamicRolloutFlow() { + @Test + void dynamicRolloutFlow() { final String rolloutName = "dynamic-rollout-std"; final int amountGroups = 2; // static only final String targetPrefix = "controller-dynamic-rollout-std-"; @@ -203,7 +205,8 @@ class RolloutManagementFlowTest extends AbstractJpaIntegrationTest { /** * Verifies a simple dynamic rollout flow with a dynamic group template */ - @Test void dynamicRolloutTemplateFlow() { + @Test + void dynamicRolloutTemplateFlow() { final String rolloutName = "dynamic-template-rollout-std"; final int amountGroups = 3; // static only final String targetPrefix = "controller-template-dynamic-rollout-std-"; @@ -302,7 +305,8 @@ class RolloutManagementFlowTest extends AbstractJpaIntegrationTest { /** * Verifies a simple pure (no static groups) dynamic rollout flow with a dynamic group template */ - @Test void dynamicRolloutPureFlow() { + @Test + void dynamicRolloutPureFlow() { final String rolloutName = "pure-dynamic-rollout-std"; final String targetPrefix = "controller-pure-dynamic-rollout-std-"; final DistributionSet distributionSet = testdataFactory.createDistributionSet("dsFor" + rolloutName); @@ -384,7 +388,8 @@ class RolloutManagementFlowTest extends AbstractJpaIntegrationTest { /** * Verifies a simple rollout flow */ - @Test void rollout0ThresholdFlow() { + @Test + void rollout0ThresholdFlow() { final String rolloutName = "rollout-std-0threshold"; final int amountGroups = 5; // static only final String targetPrefix = "controller-rollout-std-0threshold-"; diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/RolloutManagementSecurityTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/RolloutManagementSecurityTest.java index 76585a310..70546f46c 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/RolloutManagementSecurityTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/RolloutManagementSecurityTest.java @@ -35,28 +35,32 @@ class RolloutManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void getPermissionsCheck() { + @Test + void getPermissionsCheck() { assertPermissions(() -> rolloutManagement.get(1L), List.of(SpPermission.READ_ROLLOUT)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void getByNamePermissionsCheck() { + @Test + void getByNamePermissionsCheck() { assertPermissions(() -> rolloutManagement.getByName("name"), List.of(SpPermission.READ_ROLLOUT)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void getWithDetailedStatusPermissionsCheck() { + @Test + void getWithDetailedStatusPermissionsCheck() { assertPermissions(() -> rolloutManagement.getWithDetailedStatus(1L), List.of(SpPermission.READ_ROLLOUT)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void approveOrDenyPermissionsCheck() { + @Test + void approveOrDenyPermissionsCheck() { assertPermissions(() -> rolloutManagement.approveOrDeny(1L, Rollout.ApprovalDecision.APPROVED), List.of(SpPermission.APPROVE_ROLLOUT)); assertPermissions(() -> rolloutManagement.approveOrDeny(1L, Rollout.ApprovalDecision.APPROVED, "comment"), List.of(SpPermission.APPROVE_ROLLOUT)); @@ -65,7 +69,8 @@ class RolloutManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void pauseRolloutPermissionsCheck() { + @Test + void pauseRolloutPermissionsCheck() { assertPermissions(() -> { rolloutManagement.pauseRollout(1L); return null; @@ -75,7 +80,8 @@ class RolloutManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void resumeRolloutPermissionsCheck() { + @Test + void resumeRolloutPermissionsCheck() { assertPermissions(() -> { rolloutManagement.resumeRollout(1L); return null; @@ -85,14 +91,16 @@ class RolloutManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findActiveRolloutsPermissionsCheck() { + @Test + void findActiveRolloutsPermissionsCheck() { assertPermissions(() -> rolloutManagement.findActiveRollouts(), List.of(SpPermission.READ_ROLLOUT)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void cancelRolloutsForDistributionSetPermissionsCheck() { + @Test + void cancelRolloutsForDistributionSetPermissionsCheck() { final DistributionSetTypeCreate key = entityFactory.distributionSetType().create().name("type").key("type"); distributionSetTypeManagement.create(key); final DistributionSetCreate dsCreate = entityFactory.distributionSet().create().name("name").version("1.0.0").type("type"); @@ -106,21 +114,24 @@ class RolloutManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void countPermissionsCheck() { + @Test + void countPermissionsCheck() { assertPermissions(() -> rolloutManagement.count(), List.of(SpPermission.READ_ROLLOUT)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void countByDistributionSetIdAndRolloutIsStoppablePermissionsCheck() { + @Test + void countByDistributionSetIdAndRolloutIsStoppablePermissionsCheck() { assertPermissions(() -> rolloutManagement.countByDistributionSetIdAndRolloutIsStoppable(1L), List.of(SpPermission.READ_ROLLOUT)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void createPermissionsCheck() { + @Test + void createPermissionsCheck() { assertPermissions(() -> rolloutManagement.create(entityFactory.rollout().create().distributionSetId(1L), 1, false, new RolloutGroupConditionBuilder().withDefaults().build()), List.of(SpPermission.CREATE_ROLLOUT, SpPermission.READ_REPOSITORY)); assertPermissions(() -> rolloutManagement.create(entityFactory.rollout().create().distributionSetId(1L), 1, false, @@ -136,28 +147,32 @@ class RolloutManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findAllPermissionsCheck() { + @Test + void findAllPermissionsCheck() { assertPermissions(() -> rolloutManagement.findAll(false, PAGE), List.of(SpPermission.READ_ROLLOUT)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findByRsqlPermissionsCheck() { + @Test + void findByRsqlPermissionsCheck() { assertPermissions(() -> rolloutManagement.findByRsql("id==1", false, PAGE), List.of(SpPermission.READ_ROLLOUT)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findAllWithDetailedStatusPermissionsCheck() { + @Test + void findAllWithDetailedStatusPermissionsCheck() { assertPermissions(() -> rolloutManagement.findAllWithDetailedStatus(false, PAGE), List.of(SpPermission.READ_ROLLOUT)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findByRsqlWithDetailedStatusPermissionsCheck() { + @Test + void findByRsqlWithDetailedStatusPermissionsCheck() { assertPermissions(() -> rolloutManagement.findByRsqlWithDetailedStatus("name==*", false, PAGE), List.of(SpPermission.READ_ROLLOUT)); } @@ -165,21 +180,24 @@ class RolloutManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void startPermissionsCheck() { + @Test + void startPermissionsCheck() { assertPermissions(() -> rolloutManagement.start(1L), List.of(SpPermission.HANDLE_ROLLOUT)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void updatePermissionsCheck() { + @Test + void updatePermissionsCheck() { assertPermissions(() -> rolloutManagement.update(entityFactory.rollout().update(1L)), List.of(SpPermission.UPDATE_ROLLOUT)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void deletePermissionsCheck() { + @Test + void deletePermissionsCheck() { assertPermissions(() -> { rolloutManagement.delete(1L); return null; @@ -189,7 +207,8 @@ class RolloutManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void triggerNextGroupPermissionsCheck() { + @Test + void triggerNextGroupPermissionsCheck() { assertPermissions(() -> { rolloutManagement.triggerNextGroup(1L); return null; @@ -218,7 +237,8 @@ class RolloutManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test @WithUser(principal = "user", authorities = { SpPermission.READ_ROLLOUT }) + @Test + @WithUser(principal = "user", authorities = { SpPermission.READ_ROLLOUT }) void findByRolloutAndRsqlWithDetailedStatusPermissionsCheck() { assertPermissions(() -> rolloutGroupManagement.findByRolloutAndRsqlWithDetailedStatus(1L, "name==*", PAGE), List.of(SpPermission.READ_ROLLOUT)); @@ -227,7 +247,8 @@ class RolloutManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findByRolloutWithDetailedStatusPermissionsCheck() { + @Test + void findByRolloutWithDetailedStatusPermissionsCheck() { assertPermissions(() -> rolloutGroupManagement.findByRolloutWithDetailedStatus(1L, PAGE), List.of(SpPermission.READ_ROLLOUT)); } } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/RolloutManagementTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/RolloutManagementTest.java index d6d926c63..a4764e391 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/RolloutManagementTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/RolloutManagementTest.java @@ -111,7 +111,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { /** * Dynamic group doesn't override newer static group assignments */ - @Test void dynamicGroupDoesntOverrideItsOrNewerStaticGroups() { + @Test + void dynamicGroupDoesntOverrideItsOrNewerStaticGroups() { final int amountGroups = 1; // static only final String targetPrefix = "controller-dynamic-rollout-"; final DistributionSet distributionSet = testdataFactory.createDistributionSet("ds"); @@ -176,7 +177,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { /** * Verifies that a running action with distribution-set (A) is not canceled by a rollout which tries to also assign a distribution-set (A) */ - @Test void rolloutShouldNotCancelRunningActionWithTheSameDistributionSet() { + @Test + void rolloutShouldNotCancelRunningActionWithTheSameDistributionSet() { // manually assign distribution set to target final String knownControllerId = "controller12345"; final DistributionSet knownDistributionSet = testdataFactory.createDistributionSet(); @@ -242,7 +244,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { /** * Verifies that a running action is auto canceled by a rollout which assigns another distribution-set. */ - @Test void rolloutAssignsNewDistributionSetAndAutoCloseActiveActions() { + @Test + void rolloutAssignsNewDistributionSetAndAutoCloseActiveActions() { tenantConfigurationManagement .addOrUpdateConfiguration(TenantConfigurationKey.REPOSITORY_ACTIONS_AUTOCLOSE_ENABLED, true); @@ -328,7 +331,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { /** * Verifying that the rollout is created correctly, executing the filter and split up the targets in the correct group size. */ - @Test void creatingRolloutIsCorrectPersisted() { + @Test + void creatingRolloutIsCorrectPersisted() { final int amountTargetsForRollout = 10; final int amountOtherTargets = 15; final int amountGroups = 5; @@ -348,7 +352,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { /** * Verifying that when the rollout is started the actions for all targets in the rollout is created and the state of the first group is running as well as the corresponding actions */ - @Test void startRolloutSetFirstGroupAndActionsInRunningStateAndOthersInScheduleState() { + @Test + void startRolloutSetFirstGroupAndActionsInRunningStateAndOthersInScheduleState() { final int amountTargetsForRollout = 10; final int amountOtherTargets = 15; final int amountGroups = 5; @@ -385,7 +390,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { /** * Verifying that a finish condition of a group is hit the next group of the rollout is also started */ - @Test void checkRunningRolloutsDoesNotStartNextGroupIfFinishConditionIsNotHit() { + @Test + void checkRunningRolloutsDoesNotStartNextGroupIfFinishConditionIsNotHit() { final int amountTargetsForRollout = 10; final int amountOtherTargets = 15; final int amountGroups = 5; @@ -428,7 +434,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { /** * Verifying that next group is started when targets of the group have been deleted. */ - @Test void checkRunningRolloutsStartsNextGroupIfTargetsDeleted() { + @Test + void checkRunningRolloutsStartsNextGroupIfTargetsDeleted() { final int amountTargetsForRollout = 15; final int amountOtherTargets = 0; final int amountGroups = 3; @@ -449,7 +456,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { /** * Verifying that the error handling action of a group is executed to pause the current rollout */ - @Test void checkErrorHitOfGroupCallsErrorActionToPauseTheRollout() { + @Test + void checkErrorHitOfGroupCallsErrorActionToPauseTheRollout() { final int amountTargetsForRollout = 10; final int amountOtherTargets = 15; final int amountGroups = 5; @@ -494,7 +502,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { /** * Verifying a paused rollout in case of error action hit can be resumed again */ - @Test void errorActionPausesRolloutAndRolloutGetsResumedStartsNextScheduledGroup() { + @Test + void errorActionPausesRolloutAndRolloutGetsResumedStartsNextScheduledGroup() { final int amountTargetsForRollout = 10; final int amountOtherTargets = 15; final int amountGroups = 5; @@ -547,7 +556,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { /** * Verifying that the rollout is starting group after group and gets finished at the end */ - @Test void rolloutStartsGroupAfterGroupAndGetsFinished() { + @Test + void rolloutStartsGroupAfterGroupAndGetsFinished() { final int amountTargetsForRollout = 10; final int amountOtherTargets = 15; final int amountGroups = 5; @@ -586,7 +596,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { /** * Verify that the targets have the right status during the rollout. */ - @Test void countCorrectStatusForEachTargetDuringRollout() { + @Test + void countCorrectStatusForEachTargetDuringRollout() { final int amountTargetsForRollout = 8; final int amountOtherTargets = 15; @@ -651,7 +662,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { /** * Verify that the targets have the right status during a download_only rollout. */ - @Test void countCorrectStatusForEachTargetDuringDownloadOnlyRollout() { + @Test + void countCorrectStatusForEachTargetDuringDownloadOnlyRollout() { final int amountTargetsForRollout = 8; final int amountOtherTargets = 15; @@ -720,7 +732,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { /** * Verify that the targets have the right status during the rollout when an error emerges. */ - @Test void countCorrectStatusForEachTargetDuringRolloutWithError() { + @Test + void countCorrectStatusForEachTargetDuringRolloutWithError() { final int amountTargetsForRollout = 8; final int amountOtherTargets = 15; @@ -759,7 +772,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { /** * Verify that the targets have the right status during the rollout when receiving the status of rollout groups. */ - @Test void countCorrectStatusForEachTargetGroupDuringRollout() { + @Test + void countCorrectStatusForEachTargetGroupDuringRollout() { final int amountTargetsForRollout = 9; final int amountOtherTargets = 15; @@ -802,7 +816,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { /** * Verify that target actions of rollout get canceled when a manuel distribution sets assignment is done. */ - @Test void targetsOfRolloutGetsManuelDsAssignment() { + @Test + void targetsOfRolloutGetsManuelDsAssignment() { final int amountTargetsForRollout = 10; final int amountOtherTargets = 0; @@ -847,7 +862,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { /** * Verify that target actions of a rollout get cancelled when another rollout with same targets gets started. */ - @Test void targetsOfRolloutGetDistributionSetAssignmentByOtherRollout() { + @Test + void targetsOfRolloutGetDistributionSetAssignmentByOtherRollout() { final int amountTargetsForRollout = 15; final int amountOtherTargets = 5; @@ -890,7 +906,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { /** * Verify that error status of DistributionSet installation during rollout can get rerun with second rollout so that all targets have some DistributionSet installed at the end. */ - @Test void startSecondRolloutAfterFirstRolloutEndsWithErrors() { + @Test + void startSecondRolloutAfterFirstRolloutEndsWithErrors() { final int amountTargetsForRollout = 15; final int amountOtherTargets = 0; @@ -950,7 +967,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { /** * Verify that the rollout moves to the next group when the success condition was achieved and the error condition was not exceeded. */ - @Test void successConditionAchievedAndErrorConditionNotExceeded() { + @Test + void successConditionAchievedAndErrorConditionNotExceeded() { final int amountTargetsForRollout = 10; final int amountOtherTargets = 0; @@ -977,7 +995,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { /** * Verify that the rollout does not move to the next group when the success condition was not achieved. */ - @Test void successConditionNotAchieved() { + @Test + void successConditionNotAchieved() { final int amountTargetsForRollout = 10; final int amountOtherTargets = 0; @@ -1004,7 +1023,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { /** * Verify that the rollout pauses when the error condition was exceeded. */ - @Test void errorConditionExceeded() { + @Test + void errorConditionExceeded() { final int amountTargetsForRollout = 10; final int amountOtherTargets = 0; @@ -1027,7 +1047,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { /** * Verify that all rollouts are return with expected target statuses. */ - @Test void findAllRolloutsWithDetailedStatus() { + @Test + void findAllRolloutsWithDetailedStatus() { final int amountTargetsForRollout = 12; final int amountGroups = 2; @@ -1104,7 +1125,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { /** * Verify the count of existing rollouts. */ - @Test void rightCountForAllRollouts() { + @Test + void rightCountForAllRollouts() { final int amountTargetsForRollout = 6; final int amountGroups = 2; @@ -1121,7 +1143,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { /** * Verify that the filtering and sorting ascending for rollout is working correctly. */ - @Test void findRolloutByFilters() { + @Test + void findRolloutByFilters() { final int amountTargetsForRollout = 6; final int amountGroups = 2; final String successCondition = "50"; @@ -1149,7 +1172,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { /** * Verify that the expected rollout is found by name. */ - @Test void findRolloutByName() { + @Test + void findRolloutByName() { final int amountTargetsForRollout = 12; final int amountGroups = 2; @@ -1167,7 +1191,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { /** * Verify that the percent count is acting like aspected when targets move to the status finished or error. */ - @Test void getFinishedPercentForRunningGroup() { + @Test + void getFinishedPercentForRunningGroup() { final int amountTargetsForRollout = 10; final int amountGroups = 2; @@ -1214,7 +1239,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { /** * Verify that the expected targets are returned for the rollout groups. */ - @Test void findRolloutGroupTargetsWithRsqlParam() { + @Test + void findRolloutGroupTargetsWithRsqlParam() { final int amountTargetsForRollout = 15; final int amountGroups = 3; @@ -1266,7 +1292,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { /** * Verify the creation of a Rollout without targets throws an Exception. */ - @Test void createRolloutNotMatchingTargets() { + @Test + void createRolloutNotMatchingTargets() { final int amountGroups = 5; final String successCondition = "50"; final String errorCondition = "80"; @@ -1284,7 +1311,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { /** * Verify the creation of a Rollout with the same name throws an Exception. */ - @Test void createDuplicateRollout() { + @Test + void createDuplicateRollout() { final int amountGroups = 5; final int amountTargetsForRollout = 10; final String successCondition = "50"; @@ -1306,7 +1334,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { /** * Verify the creation and the start of a Rollout with more groups than targets. */ - @Test void createAndStartRolloutWithEmptyGroups() { + @Test + void createAndStartRolloutWithEmptyGroups() { final int amountTargetsForRollout = 3; final int amountGroups = 5; final String successCondition = "50"; @@ -1352,7 +1381,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { /** * Verify the creation and the start of a rollout. */ - @Test void createAndStartRollout() { + @Test + void createAndStartRollout() { final int amountTargetsForRollout = 50; final int amountGroups = 5; @@ -1391,7 +1421,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { /** * Verify the creation and the start of a rollout. */ - @Test void createScheduledRollout() throws Exception { + @Test + void createScheduledRollout() throws Exception { final String rolloutName = "scheduledRolloutTest"; testdataFactory.createTargets(50, rolloutName + "-", rolloutName); final DistributionSet distributionSet = testdataFactory.createDistributionSet("dsFor" + rolloutName); @@ -1451,7 +1482,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { /** * Verify that a rollout cannot be created if the 'max targets per rollout group' quota is violated. */ - @Test void createRolloutFailsIfQuotaGroupQuotaIsViolated() { + @Test + void createRolloutFailsIfQuotaGroupQuotaIsViolated() { final int maxTargets = quotaManagement.getMaxTargetsPerRolloutGroup(); @@ -1479,7 +1511,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { /** * Verify that a rollout cannot be created based on group definitions if the 'max targets per rollout group' quota is violated for one of the groups. */ - @Test void createRolloutWithGroupDefinitionsFailsIfQuotaGroupQuotaIsViolated() { + @Test + void createRolloutWithGroupDefinitionsFailsIfQuotaGroupQuotaIsViolated() { final int maxTargets = quotaManagement.getMaxTargetsPerRolloutGroup(); final int amountTargetsForRollout = maxTargets * 2 + 2; @@ -1526,7 +1559,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { /** * Verify the update of a rollout */ - @Test void updateRollout() { + @Test + void updateRollout() { final int amountTargetsForRollout = 50; final int amountGroups = 5; final String successCondition = "50"; @@ -1555,7 +1589,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { /** * Verify the creation of a rollout with a groups definition. */ - @Test void createRolloutWithGroupDefinition() throws Exception { + @Test + void createRolloutWithGroupDefinition() throws Exception { final String rolloutName = "rolloutTest3"; final int amountTargetsInGroup1 = 10; @@ -1616,7 +1651,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { /** * Verify rollout execution with advanced group definition and confirmation flow active. */ - @Test void createRolloutWithGroupDefinitionAndConfirmationFlowActive() { + @Test + void createRolloutWithGroupDefinitionAndConfirmationFlowActive() { final String rolloutName = "rolloutTest4"; final int amountTargetsInGroup1 = 10; @@ -1693,7 +1729,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { /** * Verify rollout creation fails if group definition does not address all targets */ - @Test void createRolloutWithGroupsNotMatchingTargets() { + @Test + void createRolloutWithGroupsNotMatchingTargets() { final String rolloutName = "rolloutTest4"; final int amountTargetsForRollout = 500; final int percentTargetsInGroup1 = 20; @@ -1715,7 +1752,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { /** * Verify rollout creation fails if group definition specifies illegal target percentage */ - @Test void createRolloutWithIllegalPercentage() { + @Test + void createRolloutWithIllegalPercentage() { final String rolloutName = "rolloutTest6"; final int amountTargetsForRollout = 10; final int percentTargetsInGroup1 = 101; @@ -1737,7 +1775,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { /** * Verify rollout creation fails if the 'max rollout groups per rollout' quota is violated. */ - @Test void createRolloutWithIllegalAmountOfGroups() { + @Test + void createRolloutWithIllegalAmountOfGroups() { final String rolloutName = "rolloutTest5"; final int targets = 10; final int maxGroups = quotaManagement.getMaxRolloutGroupsPerRollout(); @@ -1753,7 +1792,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { /** * Verify the start of a Rollout does not work during creation phase. */ - @Test void createAndStartRolloutDuringCreationFails() { + @Test + void createAndStartRolloutDuringCreationFails() { final int amountTargetsForRollout = 3; final int amountGroups = 5; final String successCondition = "50"; @@ -1813,7 +1853,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { /** * Approving a rollout leads to transition to READY state. */ - @Test void approvedRolloutTransitionsToReadyState() { + @Test + void approvedRolloutTransitionsToReadyState() { approvalStrategy.setApprovalNeeded(true); final String successCondition = "50"; final String errorCondition = "80"; @@ -1829,7 +1870,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { /** * Denying approval for a rollout leads to transition to APPROVAL_DENIED state. */ - @Test void deniedRolloutTransitionsToApprovalDeniedState() { + @Test + void deniedRolloutTransitionsToApprovalDeniedState() { approvalStrategy.setApprovalNeeded(true); final String successCondition = "50"; final String errorCondition = "80"; @@ -1942,7 +1984,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { /** * Verifies that returned result considers provided sort parameter. */ - @Test void findAllRolloutsConsidersSorting() { + @Test + void findAllRolloutsConsidersSorting() { final String randomString = randomString(5); final DistributionSet testDs = testdataFactory.createDistributionSet(randomString + "-testDs"); testdataFactory.createTargets(10, randomString + "-testTarget-"); @@ -1982,7 +2025,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { /** * Creating a rollout without weight value when multi assignment in enabled. */ - @Test void weightNotRequiredInMultiAssignmentMode() { + @Test + void weightNotRequiredInMultiAssignmentMode() { enableMultiAssignments(); final Rollout rollout = testdataFactory.createSimpleTestRolloutWithTargetsAndDistributionSet(10, 10, 2, "50", "80", @@ -1993,7 +2037,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { /** * Creating a rollout with a weight causes an error when multi assignment in disabled. */ - @Test void weightAllowedWhenMultiAssignmentModeNotEnabled() { + @Test + void weightAllowedWhenMultiAssignmentModeNotEnabled() { assertThat( testdataFactory.createSimpleTestRolloutWithTargetsAndDistributionSet( 10, 10, 2, "50", "80", ActionType.FORCED, 66)) @@ -2003,7 +2048,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { /** * Weight is validated and saved to the Rollout. */ - @Test void weightValidatedAndSaved() { + @Test + void weightValidatedAndSaved() { final String targetPrefix = UUID.randomUUID().toString(); testdataFactory.createTargets(4, targetPrefix); enableMultiAssignments(); @@ -2032,7 +2078,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { /** * A Rollout with weight creates actions with weights */ - @Test void actionsWithWeightAreCreated() { + @Test + void actionsWithWeightAreCreated() { final int amountOfTargets = 5; final int weight = 99; enableMultiAssignments(); @@ -2050,7 +2097,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { /** * Rollout can be created without weight in single assignment and be started in multi assignment */ - @Test void createInSingleStartInMultiassignMode() { + @Test + void createInSingleStartInMultiassignMode() { final int amountOfTargets = 5; final Long rolloutId = testdataFactory.createSimpleTestRolloutWithTargetsAndDistributionSet(amountOfTargets, 2, amountOfTargets, @@ -2067,7 +2115,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { /** * Verifies that an exception is thrown when trying to create a rollout with an invalidated distribution set. */ - @Test void createRolloutWithInvalidDistributionSet() { + @Test + void createRolloutWithInvalidDistributionSet() { final DistributionSet distributionSet = testdataFactory.createAndInvalidateDistributionSet(); assertThatExceptionOfType(InvalidDistributionSetException.class) @@ -2079,7 +2128,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { /** * Verifies that an exception is thrown when trying to create a rollout with an incomplete distribution set. */ - @Test void createRolloutWithIncompleteDistributionSet() { + @Test + void createRolloutWithIncompleteDistributionSet() { final DistributionSet distributionSet = testdataFactory.createIncompleteDistributionSet(); assertThatExceptionOfType(IncompleteDistributionSetException.class) @@ -2091,7 +2141,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { /** * Verify the that only compatible targets are part of a Rollout. */ - @Test void createAndStartRolloutWithTargetTypes() { + @Test + void createAndStartRolloutWithTargetTypes() { final String rolloutName = "rolloutTestCompatibility"; final DistributionSet testDs = testdataFactory.createDistributionSet("test-ds"); @@ -2135,7 +2186,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { /** * Verifying that next group is started on manual trigger next group. */ - @Test void checkRunningRolloutsManualTriggerNextGroup() { + @Test + void checkRunningRolloutsManualTriggerNextGroup() { final int amountTargetsForRollout = 15; final int amountOtherTargets = 0; final int amountGroups = 3; @@ -2178,7 +2230,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { /** * Tests the rollout status mapping. */ - @Test void testRolloutStatusConvert() { + @Test + void testRolloutStatusConvert() { final long id = testdataFactory.createAndStartRollout(1, 0, 1, "100", "80").getId(); for (final RolloutStatus status : RolloutStatus.values()) { final JpaRollout rollout = ((JpaRollout) rolloutManagement.get(id).orElseThrow()); @@ -2191,7 +2244,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { /** * Tests the rollout action type mapping. */ - @Test void testActionTypeConvert() { + @Test + void testActionTypeConvert() { final long id = testdataFactory.createAndStartRollout(1, 0, 1, "100", "80").getId(); for (final ActionType actionType : ActionType.values()) { final JpaRollout rollout = ((JpaRollout) rolloutManagement.get(id).orElseThrow()); @@ -2204,7 +2258,8 @@ class RolloutManagementTest extends AbstractJpaIntegrationTest { /** * Trigger next rollout group if rollout is in wrong state */ - @Test void triggeringNextGroupRolloutWrongState() { + @Test + void triggeringNextGroupRolloutWrongState() { final int amountTargetsForRollout = 15; final int amountOtherTargets = 0; diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/SoftwareManagementSecurityTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/SoftwareManagementSecurityTest.java index 952439d9c..f85a0d470 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/SoftwareManagementSecurityTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/SoftwareManagementSecurityTest.java @@ -44,7 +44,8 @@ class SoftwareManagementSecurityTest /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void createMetaDataPermissionsCheck() { + @Test + void createMetaDataPermissionsCheck() { assertPermissions( () -> softwareModuleManagement.updateMetadata(entityFactory.softwareModuleMetadata().create(1L).key("key").value("value")), List.of(SpPermission.UPDATE_REPOSITORY)); @@ -58,7 +59,8 @@ class SoftwareManagementSecurityTest /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void deleteMetaDataPermissionsCheck() { + @Test + void deleteMetaDataPermissionsCheck() { assertPermissions(() -> { softwareModuleManagement.deleteMetadata(1L, "key"); return null; @@ -68,21 +70,24 @@ class SoftwareManagementSecurityTest /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findByAssignedToPermissionsCheck() { + @Test + void findByAssignedToPermissionsCheck() { assertPermissions(() -> softwareModuleManagement.findByAssignedTo(1L, PAGE), List.of(SpPermission.READ_REPOSITORY)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void countByAssignedToPermissionsCheck() { + @Test + void countByAssignedToPermissionsCheck() { assertPermissions(() -> softwareModuleManagement.countByAssignedTo(1L), List.of(SpPermission.READ_REPOSITORY)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findByTextAndTypePermissionsCheck() { + @Test + void findByTextAndTypePermissionsCheck() { assertPermissions(() -> softwareModuleManagement.findByTextAndType("text", 1L, PAGE), List.of(SpPermission.READ_REPOSITORY)); } @@ -95,21 +100,24 @@ class SoftwareManagementSecurityTest /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void getMetaDataBySoftwareModuleIdPermissionsCheck() { + @Test + void getMetaDataBySoftwareModuleIdPermissionsCheck() { assertPermissions(() -> softwareModuleManagement.getMetadata(1L, "key"), List.of(SpPermission.READ_REPOSITORY)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findMetaDataBySoftwareModuleIdPermissionsCheck() { + @Test + void findMetaDataBySoftwareModuleIdPermissionsCheck() { assertPermissions(() -> softwareModuleManagement.getMetadata(1L), List.of(SpPermission.READ_REPOSITORY)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findMetaDataBySoftwareModuleIdAndTargetVisiblePermissionsCheck() { + @Test + void findMetaDataBySoftwareModuleIdAndTargetVisiblePermissionsCheck() { assertPermissions(() -> softwareModuleManagement.findMetaDataBySoftwareModuleIdAndTargetVisible(1L, PAGE), List.of(SpPermission.READ_REPOSITORY)); } @@ -117,14 +125,16 @@ class SoftwareManagementSecurityTest /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findByTypePermissionsCheck() { + @Test + void findByTypePermissionsCheck() { assertPermissions(() -> softwareModuleManagement.findByType(1L, PAGE), List.of(SpPermission.READ_REPOSITORY)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void lockPermissionsCheck() { + @Test + void lockPermissionsCheck() { assertPermissions(() -> { softwareModuleManagement.lock(1L); return null; @@ -134,7 +144,8 @@ class SoftwareManagementSecurityTest /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void unlockPermissionsCheck() { + @Test + void unlockPermissionsCheck() { assertPermissions(() -> { softwareModuleManagement.unlock(1L); return null; @@ -144,7 +155,8 @@ class SoftwareManagementSecurityTest /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void updateMetaDataPermissionsCheck() { + @Test + void updateMetaDataPermissionsCheck() { assertPermissions( () -> softwareModuleManagement.updateMetadata(entityFactory.softwareModuleMetadata().update(1L, "key").value("value")), List.of(SpPermission.UPDATE_REPOSITORY)); @@ -153,7 +165,8 @@ class SoftwareManagementSecurityTest /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findMetaDataBySoftwareModuleIdsAndTargetVisiblePermissionsCheck() { + @Test + void findMetaDataBySoftwareModuleIdsAndTargetVisiblePermissionsCheck() { assertPermissions(() -> softwareModuleManagement.findMetaDataBySoftwareModuleIdsAndTargetVisible(List.of(1L)), List.of(SpPermission.READ_REPOSITORY)); } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/SoftwareModuleManagementTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/SoftwareModuleManagementTest.java index 5f6141f80..d16ae2b1f 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/SoftwareModuleManagementTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/SoftwareModuleManagementTest.java @@ -128,7 +128,8 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest { /** * Calling update without changing fields results in no recorded change in the repository including unchanged audit fields. */ - @Test void updateNothingResultsInUnchangedRepository() { + @Test + void updateNothingResultsInUnchangedRepository() { final SoftwareModule ah = testdataFactory.createSoftwareModuleOs(); final SoftwareModule updated = softwareModuleManagement @@ -142,7 +143,8 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest { /** * Calling update for changed fields results in change in the repository. */ - @Test void updateSoftwareModuleFieldsToNewValue() { + @Test + void updateSoftwareModuleFieldsToNewValue() { final SoftwareModule ah = testdataFactory.createSoftwareModuleOs(); final SoftwareModule updated = softwareModuleManagement @@ -158,7 +160,8 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest { /** * Create Software Module call fails when called for existing entity. */ - @Test void createModuleCallFailsForExistingModule() { + @Test + void createModuleCallFailsForExistingModule() { testdataFactory.createSoftwareModuleOs(); assertThatExceptionOfType(EntityAlreadyExistsException.class) .as("Should not have worked as module already exists.") @@ -168,7 +171,8 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest { /** * searched for software modules based on the various filter options, e.g. name,desc,type, version. */ - @Test void findSoftwareModuleByFilters() { + @Test + void findSoftwareModuleByFilters() { final SoftwareModule ah = softwareModuleManagement .create(entityFactory.softwareModule().create().type(appType).name("agent-hub").version("1.0.1")); final SoftwareModule jvm = softwareModuleManagement @@ -211,7 +215,8 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest { /** * Searches for software modules based on a list of IDs. */ - @Test void findSoftwareModulesById() { + @Test + void findSoftwareModulesById() { final List modules = Arrays.asList(testdataFactory.createSoftwareModuleOs().getId(), testdataFactory.createSoftwareModuleApp().getId(), 624355263L); @@ -222,7 +227,8 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest { /** * Searches for software modules by type. */ - @Test void findSoftwareModulesByType() { + @Test + void findSoftwareModulesByType() { // found in test final SoftwareModule one = testdataFactory.createSoftwareModuleOs("one"); final SoftwareModule two = testdataFactory.createSoftwareModuleOs("two"); @@ -238,7 +244,8 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest { /** * Counts all software modules in the repsitory that are not marked as deleted. */ - @Test void countSoftwareModulesAll() { + @Test + void countSoftwareModulesAll() { // found in test testdataFactory.createSoftwareModuleOs("one"); testdataFactory.createSoftwareModuleOs("two"); @@ -253,7 +260,8 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest { /** * Deletes an artifact, which is not assigned to a Distribution Set */ - @Test void hardDeleteOfNotAssignedArtifact() { + @Test + void hardDeleteOfNotAssignedArtifact() { // [STEP1]: Create SoftwareModuleX with Artifacts final SoftwareModule unassignedModule = createSoftwareModuleWithArtifacts(osType, "moduleX", "3.0.2", 2); @@ -280,7 +288,8 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest { /** * Deletes an artifact, which is assigned to a DistributionSet */ - @Test void softDeleteOfAssignedArtifact() { + @Test + void softDeleteOfAssignedArtifact() { // [STEP1]: Create SoftwareModuleX with ArtifactX SoftwareModule assignedModule = createSoftwareModuleWithArtifacts(osType, "moduleX", "3.0.2", 2); @@ -313,7 +322,8 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest { /** * Delete an artifact, which has been assigned to a rolled out DistributionSet in the past */ - @Test void softDeleteOfHistoricalAssignedArtifact() { + @Test + void softDeleteOfHistoricalAssignedArtifact() { // Init target final Target target = testdataFactory.createTarget(); @@ -354,7 +364,8 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest { /** * Delete an software module with an artifact, which is also used by another software module. */ - @Test void deleteSoftwareModulesWithSharedArtifact() { + @Test + void deleteSoftwareModulesWithSharedArtifact() { // Init artifact binary data, target and DistributionSets final int artifactSize = 1024; @@ -401,7 +412,8 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest { /** * Delete two assigned softwaremodules which share an artifact. */ - @Test void deleteMultipleSoftwareModulesWhichShareAnArtifact() { + @Test + void deleteMultipleSoftwareModulesWhichShareAnArtifact() { // Init artifact binary data, target and DistributionSets final int artifactSize = 1024; final byte[] source = randomBytes(artifactSize); @@ -461,7 +473,8 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest { /** * Verifies that all undeleted software modules are found in the repository. */ - @Test void countSoftwareModuleTypesAll() { + @Test + void countSoftwareModuleTypesAll() { testdataFactory.createSoftwareModuleOs(); // one soft deleted @@ -476,7 +489,8 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest { /** * Verifies that software modules are returned that are assigned to given DS. */ - @Test void findSoftwareModuleByAssignedTo() { + @Test + void findSoftwareModuleByAssignedTo() { // test modules final SoftwareModule one = testdataFactory.createSoftwareModuleOs(); testdataFactory.createSoftwareModuleOs("notassigned"); @@ -494,7 +508,8 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest { /** * Checks that metadata for a software module can be created. */ - @Test void createSoftwareModuleMetadata() { + @Test + void createSoftwareModuleMetadata() { final String knownKey1 = "myKnownKey1"; final String knownValue1 = "myKnownValue1"; @@ -537,7 +552,8 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest { /** * Verifies the enforcement of the metadata quota per software module. */ - @Test void createSoftwareModuleMetadataUntilQuotaIsExceeded() { + @Test + void createSoftwareModuleMetadataUntilQuotaIsExceeded() { // add meta data one by one final SoftwareModule module = testdataFactory.createSoftwareModuleApp("m1"); @@ -585,7 +601,8 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest { /** * Checks that metadata for a software module cannot be created for an existing key. */ - @Test void createSoftwareModuleMetadataFailsIfKeyExists() { + @Test + void createSoftwareModuleMetadataFailsIfKeyExists() { final String knownKey1 = "myKnownKey1"; final String knownValue1 = "myKnownValue1"; @@ -657,7 +674,8 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest { /** * Verifies that existing metadata can be deleted. */ - @Test void deleteSoftwareModuleMetadata() { + @Test + void deleteSoftwareModuleMetadata() { final String knownKey1 = "myKnownKey1"; final String knownValue1 = "myKnownValue1"; @@ -680,7 +698,8 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest { /** * Verifies that non existing metadata find results in exception. */ - @Test void findSoftwareModuleMetadataFailsIfEntryDoesNotExist() { + @Test + void findSoftwareModuleMetadataFailsIfEntryDoesNotExist() { final String knownKey1 = "myKnownKey1"; final String knownValue1 = "myKnownValue1"; @@ -696,7 +715,8 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest { /** * Queries and loads the metadata related to a given software module. */ - @Test void findAllSoftwareModuleMetadataBySwId() { + @Test + void findAllSoftwareModuleMetadataBySwId() { final SoftwareModule sw1 = testdataFactory.createSoftwareModuleApp(); final int metadataCountSw1 = 8; @@ -731,7 +751,8 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest { /** * Locks a SM. */ - @Test void lockSoftwareModule() { + @Test + void lockSoftwareModule() { final SoftwareModule softwareModule = testdataFactory.createSoftwareModule("sm-1"); assertThat( softwareModuleManagement.get(softwareModule.getId()).map(SoftwareModule::isLocked).orElse(true)) @@ -745,7 +766,8 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest { /** * Unlocks a SM. */ - @Test void unlockSoftwareModule() { + @Test + void unlockSoftwareModule() { final SoftwareModule softwareModule = testdataFactory.createSoftwareModule("sm-1"); softwareModuleManagement.lock(softwareModule.getId()); assertThat( @@ -760,7 +782,8 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest { /** * Artifacts of a locked SM can't be modified. Expected behaviour is to throw an exception and to do not modify them. */ - @Test void lockSoftwareModuleApplied() { + @Test + void lockSoftwareModuleApplied() { final Long softwareModuleId = testdataFactory.createSoftwareModule("sm-1").getId(); artifactManagement.create( new ArtifactUpload(new ByteArrayInputStream(new byte[] { 1 }), softwareModuleId, "artifact1", false, 1)); @@ -796,7 +819,8 @@ class SoftwareModuleManagementTest extends AbstractJpaIntegrationTest { /** * Artifacts of a locked SM can't be modified. Expected behaviour is to throw an exception and to do not modify them. */ - @Test void lockedContainingDistributionSetApplied() { + @Test + void lockedContainingDistributionSetApplied() { final DistributionSet distributionSet = testdataFactory.createDistributionSet("ds-1"); final List modules = distributionSet.getModules().stream().toList(); assertThat(modules).hasSizeGreaterThan(1); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/SoftwareModuleTypeManagementSecurityTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/SoftwareModuleTypeManagementSecurityTest.java index 0daef9aa2..97b6824a9 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/SoftwareModuleTypeManagementSecurityTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/SoftwareModuleTypeManagementSecurityTest.java @@ -45,14 +45,16 @@ class SoftwareModuleTypeManagementSecurityTest /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void getByKeyPermissionsCheck() { + @Test + void getByKeyPermissionsCheck() { assertPermissions(() -> softwareModuleTypeManagement.findByKey("key"), List.of(SpPermission.READ_REPOSITORY)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void getByNamePermissionsCheck() { + @Test + void getByNamePermissionsCheck() { assertPermissions(() -> softwareModuleTypeManagement.findByName("name"), List.of(SpPermission.READ_REPOSITORY)); } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/SoftwareModuleTypeManagementTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/SoftwareModuleTypeManagementTest.java index 61ad12524..355a4ab1c 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/SoftwareModuleTypeManagementTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/SoftwareModuleTypeManagementTest.java @@ -63,7 +63,8 @@ class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest { /** * Calling update without changing fields results in no recorded change in the repository including unchanged audit fields. */ - @Test void updateNothingResultsInUnchangedRepositoryForType() { + @Test + void updateNothingResultsInUnchangedRepositoryForType() { final SoftwareModuleType created = softwareModuleTypeManagement .create(entityFactory.softwareModuleType().create().key("test-key").name("test-name")); @@ -78,7 +79,8 @@ class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest { /** * Calling update for changed fields results in change in the repository. */ - @Test void updateSoftwareModuleTypeFieldsToNewValue() { + @Test + void updateSoftwareModuleTypeFieldsToNewValue() { final SoftwareModuleType created = softwareModuleTypeManagement .create(entityFactory.softwareModuleType().create().key("test-key").name("test-name")); @@ -94,7 +96,8 @@ class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest { /** * Create Software Module Types call fails when called for existing entities. */ - @Test void createModuleTypesCallFailsForExistingTypes() { + @Test + void createModuleTypesCallFailsForExistingTypes() { final List created = Arrays.asList( entityFactory.softwareModuleType().create().key("test-key").name("test-name"), entityFactory.softwareModuleType().create().key("test-key2").name("test-name2")); @@ -107,7 +110,8 @@ class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest { /** * Tests the successfull deletion of software module types. Both unused (hard delete) and used ones (soft delete). */ - @Test void deleteAssignedAndUnassignedSoftwareModuleTypes() { + @Test + void deleteAssignedAndUnassignedSoftwareModuleTypes() { assertThat(softwareModuleTypeManagement.findAll(PAGE)).hasSize(3).contains(osType, runtimeType, appType); SoftwareModuleType type = softwareModuleTypeManagement @@ -144,7 +148,8 @@ class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest { /** * Checks that software module typeis found based on given name. */ - @Test void findSoftwareModuleTypeByName() { + @Test + void findSoftwareModuleTypeByName() { testdataFactory.createSoftwareModuleOs(); final SoftwareModuleType found = softwareModuleTypeManagement .create(entityFactory.softwareModuleType().create().key("thetype").name("thename")); @@ -157,7 +162,8 @@ class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest { /** * Verifies that it is not possible to create a type that alrady exists. */ - @Test void createSoftwareModuleTypeFailsWithExistingEntity() { + @Test + void createSoftwareModuleTypeFailsWithExistingEntity() { final SoftwareModuleTypeCreate create = entityFactory.softwareModuleType().create().key("thetype").name("thename"); softwareModuleTypeManagement.create(create); assertThatExceptionOfType(EntityAlreadyExistsException.class) @@ -169,7 +175,8 @@ class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest { /** * Verifies that it is not possible to create a list of types where one already exists. */ - @Test void createSoftwareModuleTypesFailsWithExistingEntity() { + @Test + void createSoftwareModuleTypesFailsWithExistingEntity() { softwareModuleTypeManagement.create(entityFactory.softwareModuleType().create().key("thetype").name("thename")); final List creates = List.of( entityFactory.softwareModuleType().create().key("thetype").name("thename"), @@ -182,7 +189,8 @@ class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest { /** * Verifies that the creation of a softwareModuleType is failing because of invalid max assignment */ - @Test void createSoftwareModuleTypesFailsWithInvalidMaxAssignment() { + @Test + void createSoftwareModuleTypesFailsWithInvalidMaxAssignment() { final SoftwareModuleTypeCreate create = entityFactory.softwareModuleType().create().key("type").name("name").maxAssignments(0); assertThatExceptionOfType(ConstraintViolationException.class) .as("should not have worked as max assignment is invalid. Should be greater than 0") @@ -192,7 +200,8 @@ class SoftwareModuleTypeManagementTest extends AbstractJpaIntegrationTest { /** * Verifies that multiple types are created as requested. */ - @Test void createMultipleSoftwareModuleTypes() { + @Test + void createMultipleSoftwareModuleTypes() { final List created = softwareModuleTypeManagement .create(Arrays.asList(entityFactory.softwareModuleType().create().key("thetype").name("thename"), entityFactory.softwareModuleType().create().key("thetype2").name("thename2"))); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/SystemManagementSecurityTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/SystemManagementSecurityTest.java index 6b451d520..86e3415c0 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/SystemManagementSecurityTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/SystemManagementSecurityTest.java @@ -26,14 +26,16 @@ class SystemManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findTenantsPermissionWorks() { + @Test + void findTenantsPermissionWorks() { assertPermissions(() -> systemManagement.findTenants(PAGE), List.of(SpPermission.SYSTEM_ADMIN)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void deleteTenantPermissionsCheck() { + @Test + void deleteTenantPermissionsCheck() { assertPermissions(() -> { systemManagement.deleteTenant("tenant"); return null; @@ -43,7 +45,8 @@ class SystemManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void forEachTenantTenantPermissionsCheck() { + @Test + void forEachTenantTenantPermissionsCheck() { assertPermissions(() -> { systemManagement.forEachTenant(log::info); return null; @@ -53,21 +56,24 @@ class SystemManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void getSystemUsageStatisticsWithTenantsPermissionsCheck() { + @Test + void getSystemUsageStatisticsWithTenantsPermissionsCheck() { assertPermissions(() -> systemManagement.getSystemUsageStatisticsWithTenants(), List.of(SpPermission.SYSTEM_ADMIN)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void getSystemUsageStatisticsPermissionsCheck() { + @Test + void getSystemUsageStatisticsPermissionsCheck() { assertPermissions(() -> systemManagement.getSystemUsageStatistics(), List.of(SpPermission.SYSTEM_ADMIN)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void getTenantMetadataPermissionsCheck() { + @Test + void getTenantMetadataPermissionsCheck() { assertPermissions(() -> systemManagement.getTenantMetadata(), List.of(SpPermission.READ_REPOSITORY), List.of(SpPermission.CREATE_REPOSITORY)); assertPermissions(() -> systemManagement.getTenantMetadata(), List.of(SpPermission.READ_TARGET), List.of(SpPermission.CREATE_REPOSITORY)); assertPermissions(() -> systemManagement.getTenantMetadata(), List.of(SpPermission.READ_TENANT_CONFIGURATION), List.of(SpPermission.CREATE_REPOSITORY)); @@ -77,7 +83,8 @@ class SystemManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void getTenantMetadataWithoutDetailsPermissionsCheck() { + @Test + void getTenantMetadataWithoutDetailsPermissionsCheck() { assertPermissions(() -> systemManagement.getTenantMetadataWithoutDetails(), List.of(SpPermission.READ_REPOSITORY), List.of(SpPermission.CREATE_REPOSITORY)); assertPermissions(() -> systemManagement.getTenantMetadataWithoutDetails(), List.of(SpPermission.READ_TARGET), List.of(SpPermission.CREATE_REPOSITORY)); assertPermissions(() -> systemManagement.getTenantMetadataWithoutDetails(), List.of(SpPermission.READ_TENANT_CONFIGURATION), List.of(SpPermission.CREATE_REPOSITORY)); @@ -87,21 +94,24 @@ class SystemManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void getTenantMetadataByTenantPermissionsCheck() { + @Test + void getTenantMetadataByTenantPermissionsCheck() { assertPermissions(() -> systemManagement.getTenantMetadata(1L), List.of(SpPermission.SpringEvalExpressions.SYSTEM_ROLE)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void createTenantMetadataPermissionsCheck() { + @Test + void createTenantMetadataPermissionsCheck() { assertPermissions(() -> systemManagement.createTenantMetadata("tenant"), List.of(SpPermission.SpringEvalExpressions.SYSTEM_ROLE)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void updateTenantMetadataPermissionsCheck() { + @Test + void updateTenantMetadataPermissionsCheck() { assertPermissions(() -> systemManagement.updateTenantMetadata(1L), List.of(SpPermission.TENANT_CONFIGURATION)); } } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/SystemManagementTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/SystemManagementTest.java index 172a3b469..760b982fd 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/SystemManagementTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/SystemManagementTest.java @@ -37,7 +37,8 @@ class SystemManagementTest extends AbstractJpaIntegrationTest { /** * Ensures that findTenants returns all tenants and not only restricted to the tenant which currently is logged in */ - @Test void findTenantsReturnsAllTenantsNotOnlyWhichLoggedIn() throws Exception { + @Test + void findTenantsReturnsAllTenantsNotOnlyWhichLoggedIn() throws Exception { assertThat(systemManagement.findTenants(PAGE).getContent()).hasSize(1); createTestTenantsForSystemStatistics(2, 0, 0, 0); @@ -48,7 +49,8 @@ class SystemManagementTest extends AbstractJpaIntegrationTest { /** * Ensures that getSystemUsageStatisticsWithTenants returns the usage of all tenants and not only the first 1000 (max page size). */ - @Test void systemUsageReportCollectsStatisticsOfManyTenants() throws Exception { + @Test + void systemUsageReportCollectsStatisticsOfManyTenants() throws Exception { // Prepare tenants createTestTenantsForSystemStatistics(1050, 0, 0, 0); @@ -59,7 +61,8 @@ class SystemManagementTest extends AbstractJpaIntegrationTest { /** * Checks that the system report calculates correctly the artifact size of all tenants in the system. It ignores deleted software modules with their artifacts. */ - @Test void systemUsageReportCollectsArtifactsOfAllTenants() throws Exception { + @Test + void systemUsageReportCollectsArtifactsOfAllTenants() throws Exception { // Prepare tenants createTestTenantsForSystemStatistics(2, 1234, 0, 0); @@ -84,7 +87,8 @@ class SystemManagementTest extends AbstractJpaIntegrationTest { /** * Checks that the system report calculates correctly the targets size of all tenants in the system */ - @Test void systemUsageReportCollectsTargetsOfAllTenants() throws Exception { + @Test + void systemUsageReportCollectsTargetsOfAllTenants() throws Exception { // Prepare tenants createTestTenantsForSystemStatistics(2, 0, 100, 0); @@ -105,7 +109,8 @@ class SystemManagementTest extends AbstractJpaIntegrationTest { /** * Checks that the system report calculates correctly the actions size of all tenants in the system */ - @Test void systemUsageReportCollectsActionsOfAllTenants() throws Exception { + @Test + void systemUsageReportCollectsActionsOfAllTenants() throws Exception { // Prepare tenants createTestTenantsForSystemStatistics(2, 0, 20, 2); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetFilterQueryManagementSecurityTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetFilterQueryManagementSecurityTest.java index 6e5ed76b6..ebc0633d3 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetFilterQueryManagementSecurityTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetFilterQueryManagementSecurityTest.java @@ -25,7 +25,8 @@ class TargetFilterQueryManagementSecurityTest extends AbstractJpaIntegrationTest /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void createPermissionsCheck() { + @Test + void createPermissionsCheck() { assertPermissions( () -> targetFilterQueryManagement.create(entityFactory.targetFilterQuery().create().name("name").query("controllerId==id")), List.of(SpPermission.CREATE_TARGET)); @@ -34,7 +35,8 @@ class TargetFilterQueryManagementSecurityTest extends AbstractJpaIntegrationTest /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void deletePermissionsCheck() { + @Test + void deletePermissionsCheck() { assertPermissions(() -> { targetFilterQueryManagement.delete(1L); return null; @@ -44,7 +46,8 @@ class TargetFilterQueryManagementSecurityTest extends AbstractJpaIntegrationTest /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void verifyTargetFilterQuerySyntaxPermissionsCheck() { + @Test + void verifyTargetFilterQuerySyntaxPermissionsCheck() { assertPermissions(() -> targetFilterQueryManagement.verifyTargetFilterQuerySyntax("controllerId==id"), List.of(SpPermission.READ_TARGET)); } @@ -52,56 +55,64 @@ class TargetFilterQueryManagementSecurityTest extends AbstractJpaIntegrationTest /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findAllPermissionsCheck() { + @Test + void findAllPermissionsCheck() { assertPermissions(() -> targetFilterQueryManagement.findAll(PAGE), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void countPermissionsCheck() { + @Test + void countPermissionsCheck() { assertPermissions(() -> targetFilterQueryManagement.count(), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void countByAutoAssignDistributionSetIdPermissionsCheck() { + @Test + void countByAutoAssignDistributionSetIdPermissionsCheck() { assertPermissions(() -> targetFilterQueryManagement.countByAutoAssignDistributionSetId(1L), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findByNamePermissionsCheck() { + @Test + void findByNamePermissionsCheck() { assertPermissions(() -> targetFilterQueryManagement.findByName("filterName", PAGE), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void countByNamePermissionsCheck() { + @Test + void countByNamePermissionsCheck() { assertPermissions(() -> targetFilterQueryManagement.countByName("filterName"), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findByRsqlPermissionsCheck() { + @Test + void findByRsqlPermissionsCheck() { assertPermissions(() -> targetFilterQueryManagement.findByRsql("name==id", PAGE), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findByQueryPermissionsCheck() { + @Test + void findByQueryPermissionsCheck() { assertPermissions(() -> targetFilterQueryManagement.findByQuery("controllerId==id", PAGE), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findByAutoAssignDistributionSetIdPermissionsCheck() { + @Test + void findByAutoAssignDistributionSetIdPermissionsCheck() { assertPermissions(() -> targetFilterQueryManagement.findByAutoAssignDistributionSetId(1L, PAGE), List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY)); } @@ -109,7 +120,8 @@ class TargetFilterQueryManagementSecurityTest extends AbstractJpaIntegrationTest /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findByAutoAssignDSAndRsqlPermissionsCheck() { + @Test + void findByAutoAssignDSAndRsqlPermissionsCheck() { assertPermissions(() -> targetFilterQueryManagement.findByAutoAssignDSAndRsql(1L, "rsqlParam", PAGE), List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY)); } @@ -117,28 +129,32 @@ class TargetFilterQueryManagementSecurityTest extends AbstractJpaIntegrationTest /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findWithAutoAssignDSPermissionsCheck() { + @Test + void findWithAutoAssignDSPermissionsCheck() { assertPermissions(() -> targetFilterQueryManagement.findWithAutoAssignDS(PAGE), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void getTargetFilterQueryByIdPermissionsCheck() { + @Test + void getTargetFilterQueryByIdPermissionsCheck() { assertPermissions(() -> targetFilterQueryManagement.get(1L), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void getTargetFilterQueryByNamePermissionsCheck() { + @Test + void getTargetFilterQueryByNamePermissionsCheck() { assertPermissions(() -> targetFilterQueryManagement.getByName("filterName"), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void updatePermissionsCheck() { + @Test + void updatePermissionsCheck() { assertPermissions(() -> targetFilterQueryManagement.update(entityFactory.targetFilterQuery().update(1L)), List.of(SpPermission.UPDATE_TARGET)); } @@ -146,7 +162,8 @@ class TargetFilterQueryManagementSecurityTest extends AbstractJpaIntegrationTest /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void updateAutoAssignDSPermissionsCheck() { + @Test + void updateAutoAssignDSPermissionsCheck() { assertPermissions(() -> targetFilterQueryManagement.updateAutoAssignDS(new AutoAssignDistributionSetUpdate(1L).weight(1)), List.of(SpPermission.UPDATE_TARGET)); } @@ -154,7 +171,8 @@ class TargetFilterQueryManagementSecurityTest extends AbstractJpaIntegrationTest /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void cancelAutoAssignmentForDistributionSetPermissionsCheck() { + @Test + void cancelAutoAssignmentForDistributionSetPermissionsCheck() { assertPermissions(() -> { targetFilterQueryManagement.cancelAutoAssignmentForDistributionSet(1L); return null; diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetFilterQueryManagementTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetFilterQueryManagementTest.java index fdd48ab38..990fdced6 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetFilterQueryManagementTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetFilterQueryManagementTest.java @@ -65,7 +65,8 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest { /** * Verifies that management get access reacts as specfied on calls for non existing entities by means of Optional not present. */ - @Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) }) + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) }) void nonExistingEntityAccessReturnsNotPresent() { assertThat(targetFilterQueryManagement.get(NOT_EXIST_IDL)).isNotPresent(); assertThat(targetFilterQueryManagement.getByName(NOT_EXIST_ID)).isNotPresent(); @@ -74,7 +75,8 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest { /** * Verifies that management queries react as specfied on calls for non existing entities by means of throwing EntityNotFoundException. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = TargetFilterQueryCreatedEvent.class, count = 1) }) @@ -110,7 +112,8 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest { /** * Test creation of target filter query. */ - @Test void createTargetFilterQuery() { + @Test + void createTargetFilterQuery() { final String filterName = "new target filter"; final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement .create(entityFactory.targetFilterQuery().create().name(filterName).query("name==PendingTargets001")); @@ -121,7 +124,8 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest { /** * Create a target filter query with an auto-assign distribution set and a query string that addresses too many targets. */ - @Test void createTargetFilterQueryThatExceedsQuota() { + @Test + void createTargetFilterQueryThatExceedsQuota() { // create targets final int maxTargets = quotaManagement.getMaxTargetsPerAutoAssignment(); @@ -138,7 +142,8 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest { /** * Test searching a target filter query. */ - @Test void searchTargetFilterQuery() { + @Test + void searchTargetFilterQuery() { final String filterName = "targetFilterQueryName"; final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement .create(entityFactory.targetFilterQuery().create().name(filterName).query("name==PendingTargets001")); @@ -155,7 +160,8 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest { /** * Test searching a target filter query with an invalid filter. */ - @Test void searchTargetFilterQueryInvalidField() { + @Test + void searchTargetFilterQueryInvalidField() { final PageRequest pageRequest = PageRequest.of(0, 10); Assertions.assertThatExceptionOfType(RSQLParameterUnsupportedFieldException.class) .isThrownBy(() -> targetFilterQueryManagement.findByRsql("unknownField==testValue", pageRequest)); @@ -164,7 +170,8 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest { /** * Checks if the EntityAlreadyExistsException is thrown if a targetFilterQuery with the same name are created more than once. */ - @Test void createDuplicateTargetFilterQuery() { + @Test + void createDuplicateTargetFilterQuery() { final String filterName = "new target filter duplicate"; final TargetFilterQueryCreate targetFilterQueryCreate = entityFactory.targetFilterQuery().create() .name(filterName).query("name==PendingTargets001"); @@ -179,7 +186,8 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest { /** * Test deletion of target filter query. */ - @Test void deleteTargetFilterQuery() { + @Test + void deleteTargetFilterQuery() { final String filterName = "delete_target_filter_query"; final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement.create(entityFactory.targetFilterQuery() .create().name(filterName).query("name==PendingTargets001")); @@ -192,7 +200,8 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest { /** * Test update of a target filter query. */ - @Test void updateTargetFilterQuery() { + @Test + void updateTargetFilterQuery() { final String filterName = "target_filter_01"; final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement .create(entityFactory.targetFilterQuery().create().name(filterName).query("name==PendingTargets001")); @@ -206,7 +215,8 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest { /** * Test assigning a distribution set for auto assignment with different action types */ - @Test void assignDistributionSet() { + @Test + void assignDistributionSet() { final String filterName = "target_filter_02"; final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement .create(entityFactory.targetFilterQuery().create().name(filterName).query("name==PendingTargets001")); @@ -223,7 +233,8 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest { /** * Assigns a distribution set to an existing filter query and verifies that the quota 'max targets per auto assignment' is enforced. */ - @Test void assignDistributionSetToTargetFilterQueryThatExceedsQuota() { + @Test + void assignDistributionSetToTargetFilterQueryThatExceedsQuota() { // create targets final int maxTargets = quotaManagement.getMaxTargetsPerAutoAssignment(); testdataFactory.createTargets(maxTargets + 1, "target%s"); @@ -244,7 +255,8 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest { /** * Updates an existing filter query with a query string that addresses too many targets. */ - @Test void updateTargetFilterQueryWithQueryThatExceedsQuota() { + @Test + void updateTargetFilterQueryWithQueryThatExceedsQuota() { // create targets final int maxTargets = quotaManagement.getMaxTargetsPerAutoAssignment(); testdataFactory.createTargets(maxTargets + 1, "target%s"); @@ -264,7 +276,8 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest { /** * Test removing distribution set while it has a relation to a target filter query */ - @Test void removeAssignDistributionSet() { + @Test + void removeAssignDistributionSet() { final String filterName = "target_filter_03"; final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement .create(entityFactory.targetFilterQuery().create().name(filterName).query("name==PendingTargets001")); @@ -292,7 +305,8 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest { /** * Test to implicitly remove the auto assign distribution set when the ds is soft deleted */ - @Test void implicitlyRemoveAssignDistributionSet() { + @Test + void implicitlyRemoveAssignDistributionSet() { final String filterName = "target_filter_03"; final DistributionSet distributionSet = testdataFactory.createDistributionSet("dist_set"); final Target target = testdataFactory.createTarget(); @@ -327,7 +341,8 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest { /** * Test finding and auto assign distribution set */ - @Test void findFiltersWithDistributionSet() { + @Test + void findFiltersWithDistributionSet() { final String filterName = "d"; assertEquals(0L, targetFilterQueryManagement.count()); targetFilterQueryManagement.create(entityFactory.targetFilterQuery().create().name("a").query("name==*")); @@ -359,7 +374,8 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest { /** * Creating or updating a target filter query with autoassignment and no-value weight when multi assignment in enabled. */ - @Test void weightNotRequiredInMultiAssignmentMode() { + @Test + void weightNotRequiredInMultiAssignmentMode() { enableMultiAssignments(); final DistributionSet ds = testdataFactory.createDistributionSet(); final Long filterId = targetFilterQueryManagement.create(entityFactory.targetFilterQuery().create().name("a").query("name==*")).getId(); @@ -377,7 +393,8 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest { /** * Creating or updating a target filter query with autoassignment with a weight causes an error when multi assignment in disabled. */ - @Test void weightAllowedWhenMultiAssignmentModeNotEnabled() { + @Test + void weightAllowedWhenMultiAssignmentModeNotEnabled() { final DistributionSet ds = testdataFactory.createDistributionSet(); final Long filterId = targetFilterQueryManagement.create(entityFactory.targetFilterQuery().create().name("a").query("name==*")).getId(); @@ -395,7 +412,8 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest { /** * Auto assignment can be removed from filter when multi assignment in enabled. */ - @Test void removeDsFromFilterWhenMultiAssignmentModeNotEnabled() { + @Test + void removeDsFromFilterWhenMultiAssignmentModeNotEnabled() { enableMultiAssignments(); final DistributionSet ds = testdataFactory.createDistributionSet(); final Long filterId = targetFilterQueryManagement.create( @@ -409,7 +427,8 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest { /** * Weight is validated and saved to the Filter. */ - @Test void weightValidatedAndSaved() { + @Test + void weightValidatedAndSaved() { enableMultiAssignments(); final DistributionSet ds = testdataFactory.createDistributionSet(); @@ -440,7 +459,8 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest { /** * Verifies that an exception is thrown when trying to create a target filter with an invalidated distribution set. */ - @Test void createTargetFilterWithInvalidDistributionSet() { + @Test + void createTargetFilterWithInvalidDistributionSet() { final DistributionSet distributionSet = testdataFactory.createAndInvalidateDistributionSet(); final TargetFilterQueryCreate targetFilterQueryCreate = entityFactory.targetFilterQuery().create() @@ -453,7 +473,8 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest { /** * Verifies that an exception is thrown when trying to create a target filter with an incomplete distribution set. */ - @Test void createTargetFilterWithIncompleteDistributionSet() { + @Test + void createTargetFilterWithIncompleteDistributionSet() { final DistributionSet distributionSet = testdataFactory.createIncompleteDistributionSet(); final TargetFilterQueryCreate targetFilterQueryCreate = entityFactory.targetFilterQuery().create() @@ -467,7 +488,8 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest { /** * Verifies that an exception is thrown when trying to update a target filter with an invalidated distribution set. */ - @Test void updateAutoAssignDsWithInvalidDistributionSet() { + @Test + void updateAutoAssignDsWithInvalidDistributionSet() { final DistributionSet distributionSet = testdataFactory.createDistributionSet(); final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement .create(entityFactory.targetFilterQuery().create().name("updateAutoAssignDsWithInvalidDistributionSet") @@ -484,7 +506,8 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest { /** * Verifies that an exception is thrown when trying to update a target filter with an incomplete distribution set. */ - @Test void updateAutoAssignDsWithIncompleteDistributionSet() { + @Test + void updateAutoAssignDsWithIncompleteDistributionSet() { final DistributionSet distributionSet = testdataFactory.createDistributionSet(); final TargetFilterQuery targetFilterQuery = targetFilterQueryManagement.create( entityFactory.targetFilterQuery().create().name("updateAutoAssignDsWithIncompleteDistributionSet") @@ -501,7 +524,8 @@ class TargetFilterQueryManagementTest extends AbstractJpaIntegrationTest { /** * Tests the auto assign action type mapping. */ - @Test void testAutoAssignActionTypeConvert() { + @Test + void testAutoAssignActionTypeConvert() { for (final ActionType actionType : ActionType.values()) { final Supplier create = () -> targetFilterQueryManagement.create( diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetManagementSearchTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetManagementSearchTest.java index 33f113d7e..cebd870b3 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetManagementSearchTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetManagementSearchTest.java @@ -40,7 +40,8 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest { /** * Verifies that targets with given target type are returned from repository. */ - @Test void findTargetByTargetType() { + @Test + void findTargetByTargetType() { final TargetType testType = testdataFactory.createTargetType("testType", Collections.singletonList(standardDsType)); final List unassigned = testdataFactory.createTargets(9, "unassigned"); @@ -190,7 +191,8 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest { /** * Verifies that targets with given assigned DS are returned from repository. */ - @Test void findTargetByAssignedDistributionSet() { + @Test + void findTargetByAssignedDistributionSet() { final DistributionSet assignedSet = testdataFactory.createDistributionSet(""); testdataFactory.createTargets(10, "unassigned", "unassigned"); List assignedtargets = testdataFactory.createTargets(10, "assigned", "assigned"); @@ -209,7 +211,8 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest { /** * Verifies that targets without given assigned DS are returned from repository. */ - @Test void findTargetWithoutAssignedDistributionSet() { + @Test + void findTargetWithoutAssignedDistributionSet() { final DistributionSet assignedSet = testdataFactory.createDistributionSet(""); final TargetFilterQuery tfq = targetFilterQueryManagement .create(entityFactory.targetFilterQuery().create().name("tfq").query("name==*")); @@ -228,7 +231,8 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest { /** * Verifies that targets with given installed DS are returned from repository. */ - @Test void findTargetByInstalledDistributionSet() { + @Test + void findTargetByInstalledDistributionSet() { final DistributionSet assignedSet = testdataFactory.createDistributionSet(""); final DistributionSet installedSet = testdataFactory.createDistributionSet("another"); testdataFactory.createTargets(10, "unassigned", "unassigned"); @@ -251,7 +255,8 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest { /** * Verifies that all compatible targets are returned from repository. */ - @Test void shouldFindAllTargetsCompatibleWithDS() { + @Test + void shouldFindAllTargetsCompatibleWithDS() { final DistributionSet testDs = testdataFactory.createDistributionSet(); final TargetType targetType = testdataFactory.createTargetType("testType", Collections.singletonList(testDs.getType())); @@ -271,7 +276,8 @@ class TargetManagementSearchTest extends AbstractJpaIntegrationTest { /** * Verifies that incompatible targets are not returned from repository. */ - @Test void shouldNotFindTargetsIncompatibleWithDS() { + @Test + void shouldNotFindTargetsIncompatibleWithDS() { final DistributionSetType dsType = testdataFactory.findOrCreateDistributionSetType("test-ds-type", "test-ds-type"); final DistributionSet testDs = createDistSetWithType(dsType); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetManagementSecurityTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetManagementSecurityTest.java index 7fcdedd52..0e86a64e4 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetManagementSecurityTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetManagementSecurityTest.java @@ -30,7 +30,8 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void countByAssignedDistributionSetPermissionsCheck() { + @Test + void countByAssignedDistributionSetPermissionsCheck() { assertPermissions(() -> targetManagement.countByAssignedDistributionSet(1L), List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY)); } @@ -38,7 +39,8 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void countByFiltersPermissionsCheck() { + @Test + void countByFiltersPermissionsCheck() { assertPermissions(() -> targetManagement.countByFilters(new FilterParams(null, null, null, null, null, null)), List.of(SpPermission.READ_TARGET)); } @@ -46,7 +48,8 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void countByInstalledDistributionSetPermissionsCheck() { + @Test + void countByInstalledDistributionSetPermissionsCheck() { assertPermissions(() -> targetManagement.countByInstalledDistributionSet(1L), List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY)); } @@ -54,7 +57,8 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void existsByInstalledOrAssignedDistributionSetPermissionsCheck() { + @Test + void existsByInstalledOrAssignedDistributionSetPermissionsCheck() { assertPermissions(() -> targetManagement.existsByInstalledOrAssignedDistributionSet(1L), List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY)); } @@ -62,28 +66,32 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void countByRsqlPermissionsCheck() { + @Test + void countByRsqlPermissionsCheck() { assertPermissions(() -> targetManagement.countByRsql("controllerId==id"), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void countByRsqlAndUpdatablePermissionsCheck() { + @Test + void countByRsqlAndUpdatablePermissionsCheck() { assertPermissions(() -> targetManagement.countByRsqlAndUpdatable("controllerId==id"), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void countByRsqlAndCompatiblePermissionsCheck() { + @Test + void countByRsqlAndCompatiblePermissionsCheck() { assertPermissions(() -> targetManagement.countByRsqlAndCompatible("controllerId==id", 1L), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void countByRsqlAndCompatibleAndUpdatablePermissionsCheck() { + @Test + void countByRsqlAndCompatibleAndUpdatablePermissionsCheck() { assertPermissions(() -> targetManagement.countByRsqlAndCompatibleAndUpdatable("controllerId==id", 1L), List.of(SpPermission.READ_TARGET)); } @@ -91,21 +99,24 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void countByFailedInRolloutPermissionsCheck() { + @Test + void countByFailedInRolloutPermissionsCheck() { assertPermissions(() -> targetManagement.countByFailedInRollout("1", 1L), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void countPermissionsCheck() { + @Test + void countPermissionsCheck() { assertPermissions(() -> targetManagement.count(), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void createPermissionsCheck() { + @Test + void createPermissionsCheck() { assertPermissions(() -> targetManagement.create(entityFactory.target().create().controllerId("controller").name("name")), List.of(SpPermission.CREATE_TARGET)); } @@ -113,7 +124,8 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void createCollectionPermissionsCheck() { + @Test + void createCollectionPermissionsCheck() { assertPermissions(() -> targetManagement.create(List.of(entityFactory.target().create().controllerId("controller").name("name"))), List.of(SpPermission.CREATE_TARGET)); } @@ -121,7 +133,8 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void deletePermissionsCheck() { + @Test + void deletePermissionsCheck() { assertPermissions(() -> { targetManagement.delete(List.of(1L)); return null; @@ -131,7 +144,8 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void deleteByControllerIDPermissionsCheck() { + @Test + void deleteByControllerIDPermissionsCheck() { assertPermissions(() -> { targetManagement.deleteByControllerID("controllerId"); return null; @@ -141,14 +155,16 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void countByTargetFilterQueryPermissionsCheck() { + @Test + void countByTargetFilterQueryPermissionsCheck() { assertPermissions(() -> targetManagement.countByTargetFilterQuery(1L), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findByTargetFilterQueryAndNonDSAndCompatibleAndUpdatablePermissionsCheck() { + @Test + void findByTargetFilterQueryAndNonDSAndCompatibleAndUpdatablePermissionsCheck() { assertPermissions(() -> targetManagement.findByTargetFilterQueryAndNonDSAndCompatibleAndUpdatable(1L, "controllerId==id", PAGE), List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY)); } @@ -156,7 +172,8 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void countByRsqlAndNonDSAndCompatibleAndUpdatablePermissionsCheck() { + @Test + void countByRsqlAndNonDSAndCompatibleAndUpdatablePermissionsCheck() { assertPermissions(() -> targetManagement.countByRsqlAndNonDSAndCompatibleAndUpdatable(1L, "controllerId==id"), List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY)); } @@ -164,7 +181,8 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findByRsqlAndNotInRolloutGroupsAndCompatibleAndUpdatablePermissionsCheck() { + @Test + void findByRsqlAndNotInRolloutGroupsAndCompatibleAndUpdatablePermissionsCheck() { assertPermissions( () -> targetManagement.findByRsqlAndNotInRolloutGroupsAndCompatibleAndUpdatable(List.of(1L), "controllerId==id", entityFactory.distributionSetType().create().build(), PAGE @@ -174,7 +192,8 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void countByActionsInRolloutGroupPermissionsCheck() { + @Test + void countByActionsInRolloutGroupPermissionsCheck() { assertPermissions(() -> targetManagement.countByActionsInRolloutGroup(1L), List.of(SpPermission.READ_TARGET, SpPermission.READ_ROLLOUT)); } @@ -182,7 +201,8 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void countByRsqlAndNotInRolloutGroupsAndCompatibleAndUpdatablePermissionsCheck() { + @Test + void countByRsqlAndNotInRolloutGroupsAndCompatibleAndUpdatablePermissionsCheck() { assertPermissions(() -> targetManagement.countByRsqlAndNotInRolloutGroupsAndCompatibleAndUpdatable("controllerId==id", List.of(1L), entityFactory.distributionSetType().create().build()), List.of(SpPermission.READ_TARGET, SpPermission.READ_ROLLOUT)); } @@ -190,7 +210,8 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findByFailedRolloutAndNotInRolloutGroupsPermissionsCheck() { + @Test + void findByFailedRolloutAndNotInRolloutGroupsPermissionsCheck() { assertPermissions(() -> targetManagement.findByFailedRolloutAndNotInRolloutGroups("1", List.of(1L), PAGE), List.of(SpPermission.READ_TARGET, SpPermission.READ_ROLLOUT)); } @@ -198,7 +219,8 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void countByFailedRolloutAndNotInRolloutGroupsPermissionsCheck() { + @Test + void countByFailedRolloutAndNotInRolloutGroupsPermissionsCheck() { assertPermissions(() -> targetManagement.countByFailedRolloutAndNotInRolloutGroups("1", List.of(1L)), List.of(SpPermission.READ_TARGET, SpPermission.READ_ROLLOUT)); } @@ -206,14 +228,16 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findByInRolloutGroupWithoutActionPermissionsCheck() { + @Test + void findByInRolloutGroupWithoutActionPermissionsCheck() { assertPermissions(() -> targetManagement.findByInRolloutGroupWithoutAction(1L, PAGE), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findByAssignedDistributionSetPermissionsCheck() { + @Test + void findByAssignedDistributionSetPermissionsCheck() { assertPermissions(() -> targetManagement.findByAssignedDistributionSet(1L, PAGE), List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY)); } @@ -221,7 +245,8 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findByAssignedDistributionSetAndRsqlPermissionsCheck() { + @Test + void findByAssignedDistributionSetAndRsqlPermissionsCheck() { assertPermissions(() -> targetManagement.findByAssignedDistributionSetAndRsql(1L, "controllerId==id", PAGE), List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY)); } @@ -229,21 +254,24 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void getByControllerCollectionIDPermissionsCheck() { + @Test + void getByControllerCollectionIDPermissionsCheck() { assertPermissions(() -> targetManagement.getByControllerID(List.of("controllerId")), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void getByControllerIDPermissionsCheck() { + @Test + void getByControllerIDPermissionsCheck() { assertPermissions(() -> targetManagement.getByControllerID("controllerId"), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findByFiltersPermissionsCheck() { + @Test + void findByFiltersPermissionsCheck() { assertPermissions(() -> targetManagement.findByFilters(new FilterParams(null, null, null, null, null, null), PAGE), List.of(SpPermission.READ_TARGET)); } @@ -251,7 +279,8 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findByInstalledDistributionSetPermissionsCheck() { + @Test + void findByInstalledDistributionSetPermissionsCheck() { assertPermissions(() -> targetManagement.findByInstalledDistributionSet(1L, PAGE), List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY)); } @@ -259,7 +288,8 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findByInstalledDistributionSetAndRsqlPermissionsCheck() { + @Test + void findByInstalledDistributionSetAndRsqlPermissionsCheck() { assertPermissions(() -> targetManagement.findByInstalledDistributionSetAndRsql(1L, "controllerId==id", PAGE), List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY)); } @@ -267,63 +297,72 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findByUpdateStatusPermissionsCheck() { + @Test + void findByUpdateStatusPermissionsCheck() { assertPermissions(() -> targetManagement.findByUpdateStatus(TargetUpdateStatus.IN_SYNC, PAGE), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findAllPermissionsCheck() { + @Test + void findAllPermissionsCheck() { assertPermissions(() -> targetManagement.findAll(PAGE), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findByRsqlPermissionsCheck() { + @Test + void findByRsqlPermissionsCheck() { assertPermissions(() -> targetManagement.findByRsql("controllerId==id", PAGE), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findByTargetFilterQueryPermissionsCheck() { + @Test + void findByTargetFilterQueryPermissionsCheck() { assertPermissions(() -> targetManagement.findByTargetFilterQuery(1L, PAGE), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findByTagPermissionsCheck() { + @Test + void findByTagPermissionsCheck() { assertPermissions(() -> targetManagement.findByTag(1L, PAGE), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findByRsqlAndTagPermissionsCheck() { + @Test + void findByRsqlAndTagPermissionsCheck() { assertPermissions(() -> targetManagement.findByRsqlAndTag("controllerId==id", 1L, PAGE), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void assignTypePermissionsCheck() { + @Test + void assignTypePermissionsCheck() { assertPermissions(() -> targetManagement.assignType(List.of("controllerId"), 1L), List.of(SpPermission.UPDATE_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void unassignTypeByIdPermissionsCheck() { + @Test + void unassignTypeByIdPermissionsCheck() { assertPermissions(() -> targetManagement.unassignType("controllerId"), List.of(SpPermission.UPDATE_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void assignTagWithHandlerPermissionsCheck() { + @Test + void assignTagWithHandlerPermissionsCheck() { assertPermissions(() -> targetManagement.assignTag(List.of("controllerId"), 1L, strings -> {}), List.of(SpPermission.UPDATE_TARGET, SpPermission.READ_REPOSITORY)); } @@ -331,7 +370,8 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void assignTagPermissionsCheck() { + @Test + void assignTagPermissionsCheck() { assertPermissions(() -> targetManagement.assignTag(List.of("controllerId"), 1L), List.of(SpPermission.UPDATE_TARGET, SpPermission.READ_REPOSITORY)); } @@ -339,14 +379,16 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void unassignTagPermissionsCheck() { + @Test + void unassignTagPermissionsCheck() { assertPermissions(() -> targetManagement.unassignTag(List.of("controllerId"), 1L), List.of(SpPermission.UPDATE_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void unassignTagWithHandlerPermissionsCheck() { + @Test + void unassignTagWithHandlerPermissionsCheck() { assertPermissions(() -> targetManagement.unassignTag(List.of("controllerId"), 1L, strings -> {}), List.of(SpPermission.UPDATE_TARGET, SpPermission.READ_REPOSITORY)); } @@ -354,49 +396,56 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void unassignTypePermissionsCheck() { + @Test + void unassignTypePermissionsCheck() { assertPermissions(() -> targetManagement.unassignType(List.of("controllerId")), List.of(SpPermission.UPDATE_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void assignTypeByIdPermissionsCheck() { + @Test + void assignTypeByIdPermissionsCheck() { assertPermissions(() -> targetManagement.assignType("controllerId", 1L), List.of(SpPermission.UPDATE_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void updatePermissionsCheck() { + @Test + void updatePermissionsCheck() { assertPermissions(() -> targetManagement.update(entityFactory.target().update("controllerId")), List.of(SpPermission.UPDATE_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void getPermissionsCheck() { + @Test + void getPermissionsCheck() { assertPermissions(() -> targetManagement.get(1L), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void getCollectionPermissionsCheck() { + @Test + void getCollectionPermissionsCheck() { assertPermissions(() -> targetManagement.get(List.of(1L)), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void existsByControllerIdPermissionsCheck() { + @Test + void existsByControllerIdPermissionsCheck() { assertPermissions(() -> targetManagement.existsByControllerId("controllerId"), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void isTargetMatchingQueryAndDSNotAssignedAndCompatibleAndUpdatablePermissionsCheck() { + @Test + void isTargetMatchingQueryAndDSNotAssignedAndCompatibleAndUpdatablePermissionsCheck() { assertPermissions( () -> targetManagement.isTargetMatchingQueryAndDSNotAssignedAndCompatibleAndUpdatable("controllerId", 1L, "controllerId==id"), List.of(SpPermission.READ_TARGET, SpPermission.READ_REPOSITORY)); @@ -405,21 +454,24 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void getTagsPermissionsCheck() { + @Test + void getTagsPermissionsCheck() { assertPermissions(() -> targetManagement.getTags("controllerId"), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void getControllerAttributesPermissionsCheck() { + @Test + void getControllerAttributesPermissionsCheck() { assertPermissions(() -> targetManagement.getControllerAttributes("controllerId"), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void requestControllerAttributesPermissionsCheck() { + @Test + void requestControllerAttributesPermissionsCheck() { assertPermissions(() -> { targetManagement.requestControllerAttributes("controllerId"); return null; @@ -429,21 +481,24 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void isControllerAttributesRequestedPermissionsCheck() { + @Test + void isControllerAttributesRequestedPermissionsCheck() { assertPermissions(() -> targetManagement.isControllerAttributesRequested("controllerId"), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findByControllerAttributesRequestedPermissionsCheck() { + @Test + void findByControllerAttributesRequestedPermissionsCheck() { assertPermissions(() -> targetManagement.findByControllerAttributesRequested(PAGE), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void createMetadataPermissionsCheck() { + @Test + void createMetadataPermissionsCheck() { assertPermissions( () -> { targetManagement.createMetadata("controllerId", Map.of("key", "value")); @@ -455,14 +510,16 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void getMetadataPermissionsCheck() { + @Test + void getMetadataPermissionsCheck() { assertPermissions(() -> targetManagement.getMetadata("controllerId"), List.of(SpPermission.READ_REPOSITORY)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test @WithUser(principal = "user", authorities = { SpPermission.UPDATE_REPOSITORY }) + @Test + @WithUser(principal = "user", authorities = { SpPermission.UPDATE_REPOSITORY }) void updateMetadataPermissionsCheck() { assertPermissions(() -> { targetManagement.updateMetadata("controllerId", "key", "value"); @@ -474,7 +531,8 @@ class TargetManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void deleteMetadataPermissionsCheck() { + @Test + void deleteMetadataPermissionsCheck() { assertPermissions(() -> { targetManagement.deleteMetadata("controllerId", "key"); return null; diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetManagementTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetManagementTest.java index 769fb0ba8..d70dacbaf 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetManagementTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetManagementTest.java @@ -160,7 +160,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest { /** * Ensures that retrieving the target security is only permitted with the necessary permissions. */ - @Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1) }) + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1) }) void getTargetSecurityTokenOnlyWithCorrectPermission() throws Exception { final Target createdTarget = targetManagement .create(entityFactory.target().create().controllerId("targetWithSecurityToken").securityToken("token")); @@ -197,7 +198,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest { /** * Verify that a target with same controller ID than another device cannot be created. */ - @Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1) }) + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1) }) void createTargetThatViolatesUniqueConstraintFails() { final TargetCreate targetCreate = entityFactory.target().create().controllerId("123"); targetManagement.create(targetCreate); @@ -209,7 +211,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest { /** * Verify that a target with with invalid properties cannot be created or updated */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class) }) void createAndUpdateTargetWithInvalidFields() { @@ -225,7 +228,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest { /** * Ensures that targets can assigned and unassigned to a target tag. Not exists target will be ignored for the assignment. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 4), @Expect(type = TargetTagCreatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 5) }) @@ -262,7 +266,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest { /** * Ensures that targets can deleted e.g. test all cascades */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 12), @Expect(type = TargetDeletedEvent.class, count = 12), @Expect(type = TargetUpdatedEvent.class, count = 6) }) @@ -293,7 +298,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest { /** * Finds a target by given ID and checks if all data is in the response (including the data defined as lazy). */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = DistributionSetCreatedEvent.class, count = 2), @Expect(type = SoftwareModuleCreatedEvent.class, count = 6), @Expect(type = DistributionSetUpdatedEvent.class, count = 2), // implicit lock @@ -364,7 +370,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest { /** * Checks if the EntityAlreadyExistsException is thrown if the targets with the same controller ID are created twice. */ - @Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 5) }) + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 5) }) void createMultipleTargetsDuplicate() { testdataFactory.createTargets(5, "mySimpleTargs", "my simple targets"); assertThatExceptionOfType(EntityAlreadyExistsException.class) @@ -375,7 +382,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest { /** * Checks if the EntityAlreadyExistsException is thrown if a single target with the same controller ID are created twice. */ - @Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1) }) + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1) }) void createTargetDuplicate() { final TargetCreate targetCreate = entityFactory.target().create().controllerId("4711"); targetManagement.create(targetCreate); @@ -497,7 +505,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest { /** * Tests the assignment of tags to the a single target. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 2), @Expect(type = TargetTagCreatedEvent.class, count = 7), @Expect(type = TargetUpdatedEvent.class, count = 7) }) @@ -531,7 +540,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest { /** * Tests the assignment of tags to multiple targets. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 50), @Expect(type = TargetTagCreatedEvent.class, count = 4), @Expect(type = TargetUpdatedEvent.class, count = 80) }) @@ -602,7 +612,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest { /** * Tests the unassigment of tags to multiple targets. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetTagCreatedEvent.class, count = 3), @Expect(type = TargetCreatedEvent.class, count = 109), @Expect(type = TargetUpdatedEvent.class, count = 227) }) @@ -662,7 +673,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest { /** * Test that NO TAG functionality which gives all targets with no tag assigned. */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetTagCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 50), @Expect(type = TargetUpdatedEvent.class, count = 25) }) @@ -685,7 +697,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest { /** * Tests the a target can be read with only the read target permission */ - @Test @ExpectEvents({ + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1) }) void targetCanBeReadWithOnlyReadTargetPermission() throws Exception { @@ -705,7 +718,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest { /** * Test that RSQL filter finds targets with tags or specific ids. */ - @Test void findTargetsWithTagOrId() { + @Test + void findTargetsWithTagOrId() { final String rsqlFilter = "tag==Targ-A-Tag,id==target-id-B-00001,id==target-id-B-00008"; final TargetTag targTagA = targetTagManagement.create(entityFactory.tag().create().name("Targ-A-Tag")); final List targAs = testdataFactory.createTargets(25, "target-id-A", "first description").stream() @@ -725,7 +739,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest { /** * Verify that the find all targets by ids method contains the entities that we are looking for */ - @Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 12) }) + @Test + @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 12) }) void verifyFindTargetAllById() { final List searchIds = Arrays.asList(testdataFactory.createTarget("target-4").getId(), testdataFactory.createTarget("target-5").getId(), testdataFactory.createTarget("target-6").getId()); @@ -744,7 +759,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest { /** * Verify that the flag for requesting controller attributes is set correctly. */ - @Test void verifyRequestControllerAttributes() { + @Test + void verifyRequestControllerAttributes() { final String knownControllerId = "KnownControllerId"; final Target target = createTargetWithAttributes(knownControllerId); @@ -763,7 +779,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest { /** * Checks that metadata for a target can be created. */ - @Test void createMetadata() { + @Test + void createMetadata() { insertMetadata( "targetMetaKnownKey", "targetMetaKnownValue", testdataFactory.createTarget("targetIdWithMetadata")); // and validate @@ -772,7 +789,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest { /** * Verifies the enforcement of the metadata quota per target. */ - @Test void createMetadataUntilQuotaIsExceeded() { + @Test + void createMetadataUntilQuotaIsExceeded() { // add meta-data one by one final Target target1 = testdataFactory.createTarget("target1"); final int maxMetaData = quotaManagement.getMaxMetaDataEntriesPerTarget(); @@ -816,7 +834,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest { /** * Queries and loads the metadata related to a given target. */ - @Test void getMetadata() { + @Test + void getMetadata() { // create targets assertThat(targetManagement.getMetadata(testdataFactory.createTarget("target0").getControllerId())).isEmpty(); assertThat(targetManagement.getMetadata(createTargetWithMetadata("target1", 10).getControllerId())).hasSize(10); @@ -858,7 +877,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest { /** * Queries and loads the metadata related to a given target. */ - @Test void deleteMetadata() { + @Test + void deleteMetadata() { final String knownKey = "myKnownKey"; final String knownValue = "myKnownValue"; @@ -1043,7 +1063,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest { /** * Test that RSQL filter finds targets with metadata and/or controllerId. */ - @Test void findTargetsByRsqlWithMetadata() { + @Test + void findTargetsByRsqlWithMetadata() { final String controllerId1 = "target1"; final String controllerId2 = "target2"; createTargetWithMetadata(controllerId1, 2); @@ -1068,7 +1089,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest { /** * Test that RSQL filter finds targets with tag and metadata. */ - @Test void findTargetsByRsqlWithTypeAndMetadata() { + @Test + void findTargetsByRsqlWithTypeAndMetadata() { if (RsqlConfigHolder.getInstance().getRsqlToSpecBuilder() == LEGACY_G1) { // legacy visitor fail with that return; @@ -1091,7 +1113,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest { /** * Target matches filter. */ - @Test void matchesFilter() { + @Test + void matchesFilter() { final Target target = createTargetWithMetadata("target1", 2); final DistributionSet ds = testdataFactory.createDistributionSet(); final String filter = "metadata.key1==target1-value1"; @@ -1103,7 +1126,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest { /** * Target does not matches filter. */ - @Test void matchesFilterWrongFilter() { + @Test + void matchesFilterWrongFilter() { final Target target = testdataFactory.createTarget(); final DistributionSet ds = testdataFactory.createDistributionSet(); final String filter = "metadata.key==not_existing"; @@ -1115,7 +1139,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest { /** * Target matches filter but DS already assigned. */ - @Test void matchesFilterDsAssigned() { + @Test + void matchesFilterDsAssigned() { final Target target = testdataFactory.createTarget(); final DistributionSet ds1 = testdataFactory.createDistributionSet(); final DistributionSet ds2 = testdataFactory.createDistributionSet(); @@ -1130,7 +1155,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest { /** * Target matches filter for DS with wrong type. */ - @Test void matchesFilterWrongType() { + @Test + void matchesFilterWrongType() { final TargetType type = testdataFactory.createTargetType("type", Collections.emptyList()); final Target target = testdataFactory.createTarget("target", "target", type.getId()); final DistributionSet ds = testdataFactory.createDistributionSet(); @@ -1142,7 +1168,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest { /** * Target matches filter that is invalid. */ - @Test void matchesFilterInvalidFilter() { + @Test + void matchesFilterInvalidFilter() { final String target = testdataFactory.createTarget().getControllerId(); final Long ds = testdataFactory.createDistributionSet().getId(); @@ -1155,7 +1182,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest { /** * Target matches filter for not existing target. */ - @Test void matchesFilterTargetNotExists() { + @Test + void matchesFilterTargetNotExists() { final DistributionSet ds = testdataFactory.createDistributionSet(); assertThat(targetManagement.isTargetMatchingQueryAndDSNotAssignedAndCompatibleAndUpdatable( @@ -1168,7 +1196,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest { /** * Target matches filter no active action with ge weight. */ - @Test void findByTargetFilterQueryAndNoOverridingActionsAndNotInRolloutAndCompatibleAndUpdatable() { + @Test + void findByTargetFilterQueryAndNoOverridingActionsAndNotInRolloutAndCompatibleAndUpdatable() { final String targetPrefix = "dyn_action_filter_"; final DistributionSet distributionSet = testdataFactory.createDistributionSet(); final List targets = testdataFactory.createTargets(targetPrefix, 10); @@ -1220,7 +1249,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest { /** * Target matches filter for not existing DS. */ - @Test void matchesFilterDsNotExists() { + @Test + void matchesFilterDsNotExists() { final String target = testdataFactory.createTarget().getControllerId(); assertThatExceptionOfType(EntityNotFoundException.class).isThrownBy( @@ -1230,7 +1260,8 @@ class TargetManagementTest extends AbstractJpaIntegrationTest { /** * Test update status convert */ - @Test void testUpdateStatusConvert() { + @Test + void testUpdateStatusConvert() { final long id = testdataFactory.createTarget().getId(); for (final TargetUpdateStatus status : TargetUpdateStatus.values()) { final JpaTarget target = targetRepository.findById(id).orElseThrow(() -> new IllegalStateException("Target not found")); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetTagManagementSecurityTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetTagManagementSecurityTest.java index 7f0aac91b..81472909f 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetTagManagementSecurityTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetTagManagementSecurityTest.java @@ -26,21 +26,24 @@ class TargetTagManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void countPermissionsCheck() { + @Test + void countPermissionsCheck() { assertPermissions(() -> targetTagManagement.count(), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void createPermissionsCheck() { + @Test + void createPermissionsCheck() { assertPermissions(() -> targetTagManagement.create(entityFactory.tag().create().name("name")), List.of(SpPermission.CREATE_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void createCollectionPermissionsCheck() { + @Test + void createCollectionPermissionsCheck() { assertPermissions(() -> targetTagManagement.create(List.of(entityFactory.tag().create().name("name"))), List.of(SpPermission.CREATE_TARGET)); } @@ -48,7 +51,8 @@ class TargetTagManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void deletePermissionsCheck() { + @Test + void deletePermissionsCheck() { assertPermissions(() -> { targetTagManagement.delete("tag"); return null; @@ -58,42 +62,48 @@ class TargetTagManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findAllPermissionsCheck() { + @Test + void findAllPermissionsCheck() { assertPermissions(() -> targetTagManagement.findAll(PAGE), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findByRsqlPermissionsCheck() { + @Test + void findByRsqlPermissionsCheck() { assertPermissions(() -> targetTagManagement.findByRsql("name==tag", PAGE), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void getByNamePermissionsCheck() { + @Test + void getByNamePermissionsCheck() { assertPermissions(() -> targetTagManagement.getByName("tag"), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void getPermissionsCheck() { + @Test + void getPermissionsCheck() { assertPermissions(() -> targetTagManagement.get(1L), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void getCollectionPermissionsCheck() { + @Test + void getCollectionPermissionsCheck() { assertPermissions(() -> targetTagManagement.get(List.of(1L)), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void updatePermissionsCheck() { + @Test + void updatePermissionsCheck() { assertPermissions(() -> targetTagManagement.update(entityFactory.tag().update(1L)), List.of(SpPermission.UPDATE_TARGET)); } } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetTagManagementTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetTagManagementTest.java index e89d60392..b012bf693 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetTagManagementTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetTagManagementTest.java @@ -54,7 +54,8 @@ class TargetTagManagementTest extends AbstractJpaIntegrationTest { /** * Verifies that tagging of set containing missing DS throws meaningful and correct exception. */ - @Test void failOnMissingDs() { + @Test + void failOnMissingDs() { final Collection group = testdataFactory.createTargets(5).stream() .map(Target::getControllerId) .toList(); @@ -111,7 +112,8 @@ class TargetTagManagementTest extends AbstractJpaIntegrationTest { /** * Verify that a tag with with invalid properties cannot be created or updated */ - @Test void createAndUpdateTagWithInvalidFields() { + @Test + void createAndUpdateTagWithInvalidFields() { final TargetTag tag = targetTagManagement.create(entityFactory.tag().create().name("tag1").description("tagdesc1")); createAndUpdateTagWithInvalidDescription(tag); createAndUpdateTagWithInvalidColour(tag); @@ -121,7 +123,8 @@ class TargetTagManagementTest extends AbstractJpaIntegrationTest { /** * Verifies assign/unassign. */ - @Test void assignAndUnassignTargetTags() { + @Test + void assignAndUnassignTargetTags() { final List groupA = testdataFactory.createTargets(20); final List groupB = testdataFactory.createTargets(20, "groupb", "groupb"); @@ -159,7 +162,8 @@ class TargetTagManagementTest extends AbstractJpaIntegrationTest { /** * Ensures that all tags are retrieved through repository. */ - @Test void findAllTargetTags() { + @Test + void findAllTargetTags() { final List tags = createTargetsWithTags(); assertThat(targetTagRepository.findAll()).isEqualTo(targetTagRepository.findAll()).isEqualTo(tags) @@ -169,7 +173,8 @@ class TargetTagManagementTest extends AbstractJpaIntegrationTest { /** * Ensures that a created tag is persisted in the repository as defined. */ - @Test void createTargetTag() { + @Test + void createTargetTag() { final Tag tag = targetTagManagement .create(entityFactory.tag().create().name("kai1").description("kai2").colour("colour")); @@ -182,7 +187,8 @@ class TargetTagManagementTest extends AbstractJpaIntegrationTest { /** * Ensures that a deleted tag is removed from the repository as defined. */ - @Test void deleteTargetTags() { + @Test + void deleteTargetTags() { // create test data final Iterable tags = createTargetsWithTags(); final TargetTag toDelete = tags.iterator().next(); @@ -206,7 +212,8 @@ class TargetTagManagementTest extends AbstractJpaIntegrationTest { /** * Tests the name update of a target tag. */ - @Test void updateTargetTag() { + @Test + void updateTargetTag() { final List tags = createTargetsWithTags(); // change data @@ -227,7 +234,8 @@ class TargetTagManagementTest extends AbstractJpaIntegrationTest { /** * Ensures that a tag cannot be created if one exists already with that name (expects EntityAlreadyExistsException). */ - @Test void failedDuplicateTargetTagNameException() { + @Test + void failedDuplicateTargetTagNameException() { final TagCreate tagCreate = entityFactory.tag().create().name("A"); targetTagManagement.create(tagCreate); assertThatExceptionOfType(EntityAlreadyExistsException.class).isThrownBy(() -> targetTagManagement.create(tagCreate)); @@ -236,7 +244,8 @@ class TargetTagManagementTest extends AbstractJpaIntegrationTest { /** * Ensures that a tag cannot be updated to a name that already exists on another tag (expects EntityAlreadyExistsException). */ - @Test void failedDuplicateTargetTagNameExceptionAfterUpdate() { + @Test + void failedDuplicateTargetTagNameExceptionAfterUpdate() { targetTagManagement.create(entityFactory.tag().create().name("A")); final TargetTag tag = targetTagManagement.create(entityFactory.tag().create().name("B")); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetTypeManagementSecurityTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetTypeManagementSecurityTest.java index 87dd976f8..f07e7e424 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetTypeManagementSecurityTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetTypeManagementSecurityTest.java @@ -27,35 +27,40 @@ class TargetTypeManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void getByKeyPermissionsCheck() { + @Test + void getByKeyPermissionsCheck() { assertPermissions(() -> targetTypeManagement.getByKey("key"), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void getByNamePermissionsCheck() { + @Test + void getByNamePermissionsCheck() { assertPermissions(() -> targetTypeManagement.getByName("name"), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void countPermissionsCheck() { + @Test + void countPermissionsCheck() { assertPermissions(() -> targetTypeManagement.count(), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void countByNamePermissionsCheck() { + @Test + void countByNamePermissionsCheck() { assertPermissions(() -> targetTypeManagement.countByName("name"), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void createPermissionsCheck() { + @Test + void createPermissionsCheck() { assertPermissions(() -> targetTypeManagement.create(entityFactory.targetType().create().name("name")), List.of(SpPermission.CREATE_TARGET)); } @@ -63,7 +68,8 @@ class TargetTypeManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void createCollectionPermissionsCheck() { + @Test + void createCollectionPermissionsCheck() { assertPermissions(() -> targetTypeManagement.create(List.of(entityFactory.targetType().create().name("name"))), List.of(SpPermission.CREATE_TARGET)); } @@ -71,7 +77,8 @@ class TargetTypeManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void deletePermissionsCheck() { + @Test + void deletePermissionsCheck() { assertPermissions(() -> { targetTypeManagement.delete(1L); return null; @@ -81,49 +88,56 @@ class TargetTypeManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findAllPermissionsCheck() { + @Test + void findAllPermissionsCheck() { assertPermissions(() -> targetTypeManagement.findAll(PAGE), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findByRsqlPermissionsCheck() { + @Test + void findByRsqlPermissionsCheck() { assertPermissions(() -> targetTypeManagement.findByRsql("name==tag", PAGE), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void findByNamePermissionsCheck() { + @Test + void findByNamePermissionsCheck() { assertPermissions(() -> targetTypeManagement.findByName("name", PAGE), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void getPermissionsCheck() { + @Test + void getPermissionsCheck() { assertPermissions(() -> targetTypeManagement.get(1L), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void getCollectionPermissionsCheck() { + @Test + void getCollectionPermissionsCheck() { assertPermissions(() -> targetTypeManagement.get(List.of(1L)), List.of(SpPermission.READ_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void updatePermissionsCheck() { + @Test + void updatePermissionsCheck() { assertPermissions(() -> targetTypeManagement.update(entityFactory.targetType().update(1L)), List.of(SpPermission.UPDATE_TARGET)); } /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void assignCompatibleDistributionSetTypesPermissionsCheck() { + @Test + void assignCompatibleDistributionSetTypesPermissionsCheck() { assertPermissions(() -> targetTypeManagement.assignCompatibleDistributionSetTypes(1L, List.of(1L)), List.of(SpPermission.UPDATE_TARGET, SpPermission.READ_REPOSITORY)); } @@ -131,7 +145,8 @@ class TargetTypeManagementSecurityTest extends AbstractJpaIntegrationTest { /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test @WithUser(principal = "user", authorities = { SpPermission.UPDATE_TARGET, SpPermission.READ_REPOSITORY }) + @Test + @WithUser(principal = "user", authorities = { SpPermission.UPDATE_TARGET, SpPermission.READ_REPOSITORY }) void unassignDistributionSetTypePermissionsCheck() { assertPermissions(() -> targetTypeManagement.unassignDistributionSetType(1L, 1L), List.of(SpPermission.UPDATE_TARGET, SpPermission.READ_REPOSITORY)); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetTypeManagementTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetTypeManagementTest.java index 270a60947..ff9d16b2e 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetTypeManagementTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TargetTypeManagementTest.java @@ -65,7 +65,8 @@ class TargetTypeManagementTest extends AbstractJpaIntegrationTest { /** * Verify that a target type with invalid properties cannot be created or updated */ - @Test void createAndUpdateTargetTypeWithInvalidFields() { + @Test + void createAndUpdateTargetTypeWithInvalidFields() { final TargetType targetType = targetTypeManagement .create(entityFactory.targetType().create() .name("targettype1").description("targettypedes1") @@ -103,7 +104,8 @@ class TargetTypeManagementTest extends AbstractJpaIntegrationTest { /** * Tests the successful assignment of compatible distribution set types to a target type */ - @Test void assignCompatibleDistributionSetTypesToTargetType() { + @Test + void assignCompatibleDistributionSetTypesToTargetType() { final TargetType targetType = targetTypeManagement .create(entityFactory.targetType().create() .name("targettype1").description("targettypedes1") @@ -119,7 +121,8 @@ class TargetTypeManagementTest extends AbstractJpaIntegrationTest { /** * Tests the successful removal of compatible distribution set types to a target type */ - @Test void unassignCompatibleDistributionSetTypesToTargetType() { + @Test + void unassignCompatibleDistributionSetTypesToTargetType() { final TargetType targetType = targetTypeManagement .create(entityFactory.targetType().create() .name("targettype1").description("targettypedes1") @@ -138,7 +141,8 @@ class TargetTypeManagementTest extends AbstractJpaIntegrationTest { /** * Ensures that all types are retrieved through repository. */ - @Test void findAllTargetTypes() { + @Test + void findAllTargetTypes() { testdataFactory.createTargetTypes("targettype", 10); assertThat(targetTypeRepository.findAll()).as("Target type size").hasSize(10); } @@ -146,7 +150,8 @@ class TargetTypeManagementTest extends AbstractJpaIntegrationTest { /** * Ensures that a created target type is persisted in the repository as defined. */ - @Test void createTargetType() { + @Test + void createTargetType() { final String name = "targettype1"; final String key = "targettype1.key"; targetTypeManagement @@ -177,7 +182,8 @@ class TargetTypeManagementTest extends AbstractJpaIntegrationTest { /** * Ensures that a deleted target type is removed from the repository as defined. */ - @Test void deleteTargetType() { + @Test + void deleteTargetType() { // create test data final TargetType targetType = targetTypeManagement .create(entityFactory.targetType().create().name("targettype11").description("targettypedes11")); @@ -191,7 +197,8 @@ class TargetTypeManagementTest extends AbstractJpaIntegrationTest { /** * Tests the name update of a target type. */ - @Test void updateTargetType() { + @Test + void updateTargetType() { final TargetType targetType = targetTypeManagement .create(entityFactory.targetType().create().name("targettype111").description("targettypedes111")); assertThat(findByName("targettype111").get().getDescription()).as("type found") @@ -203,7 +210,8 @@ class TargetTypeManagementTest extends AbstractJpaIntegrationTest { /** * Ensures that a target type cannot be created if one exists already with that name (expects EntityAlreadyExistsException). */ - @Test void failedDuplicateTargetTypeNameException() { + @Test + void failedDuplicateTargetTypeNameException() { final TargetTypeCreate targetTypeCreate = entityFactory.targetType().create().name("targettype123"); targetTypeManagement.create(targetTypeCreate); assertThrows(EntityAlreadyExistsException.class, () -> targetTypeManagement.create(targetTypeCreate)); @@ -212,7 +220,8 @@ class TargetTypeManagementTest extends AbstractJpaIntegrationTest { /** * Ensures that a target type cannot be updated to a name that already exists (expects EntityAlreadyExistsException). */ - @Test void failedDuplicateTargetTypeNameExceptionAfterUpdate() { + @Test + void failedDuplicateTargetTypeNameExceptionAfterUpdate() { targetTypeManagement.create(entityFactory.targetType().create().name("targettype1234")); TargetType targetType = targetTypeManagement.create(entityFactory.targetType().create().name("targettype12345")); assertThrows(EntityAlreadyExistsException.class, diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TenantConfigurationManagementSecurityTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TenantConfigurationManagementSecurityTest.java index 93998f4f8..17a789303 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TenantConfigurationManagementSecurityTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TenantConfigurationManagementSecurityTest.java @@ -27,7 +27,8 @@ class TenantConfigurationManagementSecurityTest extends AbstractJpaIntegrationTe /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void addOrUpdateConfigurationPermissionsCheck() { + @Test + void addOrUpdateConfigurationPermissionsCheck() { assertPermissions(() -> tenantConfigurationManagement.addOrUpdateConfiguration("authentication.header.enabled", true), List.of(SpPermission.TENANT_CONFIGURATION)); } @@ -35,7 +36,8 @@ class TenantConfigurationManagementSecurityTest extends AbstractJpaIntegrationTe /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void addOrUpdateConfigurationWithMapPermissionsCheck() { + @Test + void addOrUpdateConfigurationWithMapPermissionsCheck() { assertPermissions(() -> tenantConfigurationManagement.addOrUpdateConfiguration(Map.of("authentication.header.enabled", true)), List.of(SpPermission.TENANT_CONFIGURATION)); } @@ -43,7 +45,8 @@ class TenantConfigurationManagementSecurityTest extends AbstractJpaIntegrationTe /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void deleteConfigurationPermissionsCheck() { + @Test + void deleteConfigurationPermissionsCheck() { assertPermissions(() -> { tenantConfigurationManagement.deleteConfiguration("authentication.header.enabled"); return null; @@ -53,7 +56,8 @@ class TenantConfigurationManagementSecurityTest extends AbstractJpaIntegrationTe /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void getConfigurationValuePermissionsCheck() { + @Test + void getConfigurationValuePermissionsCheck() { assertPermissions(() -> tenantConfigurationManagement.getConfigurationValue("authentication.header.enabled"), List.of(SpPermission.READ_TENANT_CONFIGURATION)); } @@ -61,7 +65,8 @@ class TenantConfigurationManagementSecurityTest extends AbstractJpaIntegrationTe /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void getConfigurationValueWithTypePermissionsCheck() { + @Test + void getConfigurationValueWithTypePermissionsCheck() { assertPermissions(() -> tenantConfigurationManagement.getConfigurationValue("authentication.header.enabled", Boolean.class), List.of(SpPermission.READ_TENANT_CONFIGURATION)); } @@ -69,7 +74,8 @@ class TenantConfigurationManagementSecurityTest extends AbstractJpaIntegrationTe /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void getGlobalConfigurationValuePermissionsCheck() { + @Test + void getGlobalConfigurationValuePermissionsCheck() { assertPermissions(() -> tenantConfigurationManagement.getGlobalConfigurationValue("authentication.header.enabled", Boolean.class), List.of(SpPermission.READ_TENANT_CONFIGURATION)); } @@ -77,7 +83,8 @@ class TenantConfigurationManagementSecurityTest extends AbstractJpaIntegrationTe /** * Tests ManagementAPI PreAuthorized method with correct and insufficient permissions. */ - @Test void pollStatusResolverPermissionsCheck() { + @Test + void pollStatusResolverPermissionsCheck() { assertPermissions(() -> tenantConfigurationManagement.pollStatusResolver(), List.of(SpPermission.READ_TARGET)); } } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TenantConfigurationManagementTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TenantConfigurationManagementTest.java index 74c4de302..2c4944477 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TenantConfigurationManagementTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/management/TenantConfigurationManagementTest.java @@ -44,7 +44,8 @@ class TenantConfigurationManagementTest extends AbstractJpaIntegrationTest imple /** * Tests that tenant specific configuration can be persisted and in case the tenant does not have specific configuration the default from environment is used instead. */ - @Test void storeTenantSpecificConfigurationAsString() { + @Test + void storeTenantSpecificConfigurationAsString() { final String envPropertyDefault = environment.getProperty("hawkbit.server.ddi.security.authentication.gatewaytoken.key"); assertThat(envPropertyDefault).isNotNull(); @@ -73,7 +74,8 @@ class TenantConfigurationManagementTest extends AbstractJpaIntegrationTest imple /** * Tests that the tenant specific configuration can be updated */ - @Test void updateTenantSpecificConfiguration() { + @Test + void updateTenantSpecificConfiguration() { final String configKey = TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_KEY; final String value1 = "firstValue"; final String value2 = "secondValue"; @@ -90,7 +92,8 @@ class TenantConfigurationManagementTest extends AbstractJpaIntegrationTest imple /** * Tests that the tenant specific configuration can be batch updated */ - @Test void batchUpdateTenantSpecificConfiguration() { + @Test + void batchUpdateTenantSpecificConfiguration() { Map configuration = new HashMap<>() {{ put(TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_KEY, "token_123"); put(TenantConfigurationKey.ROLLOUT_APPROVAL_ENABLED, true); @@ -109,7 +112,8 @@ class TenantConfigurationManagementTest extends AbstractJpaIntegrationTest imple /** * Tests that the configuration value can be converted from String to Integer automatically */ - @Test void storeAndUpdateTenantSpecificConfigurationAsBoolean() { + @Test + void storeAndUpdateTenantSpecificConfigurationAsBoolean() { final String configKey = TenantConfigurationKey.AUTHENTICATION_MODE_HEADER_ENABLED; final Boolean value1 = true; tenantConfigurationManagement.addOrUpdateConfiguration(configKey, value1); @@ -122,7 +126,8 @@ class TenantConfigurationManagementTest extends AbstractJpaIntegrationTest imple /** * Tests that the get configuration throws exception in case the value cannot be automatically converted from String to Boolean */ - @Test void wrongTenantConfigurationValueTypeThrowsException() { + @Test + void wrongTenantConfigurationValueTypeThrowsException() { final String configKey = TenantConfigurationKey.AUTHENTICATION_MODE_HEADER_ENABLED; final String value1 = "thisIsNotABoolean"; @@ -135,7 +140,8 @@ class TenantConfigurationManagementTest extends AbstractJpaIntegrationTest imple /** * Tests that the get configuration throws exception in case the value is the wrong type */ - @Test void batchWrongTenantConfigurationValueTypeThrowsException() { + @Test + void batchWrongTenantConfigurationValueTypeThrowsException() { final Map configuration = new HashMap<>() {{ put(TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_KEY, "token_123"); put(TenantConfigurationKey.ROLLOUT_APPROVAL_ENABLED, true); @@ -160,7 +166,8 @@ class TenantConfigurationManagementTest extends AbstractJpaIntegrationTest imple /** * Tests that a deletion of a tenant specific configuration deletes it from the database. */ - @Test void deleteConfigurationReturnNullConfiguration() { + @Test + void deleteConfigurationReturnNullConfiguration() { final String configKey = TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_KEY; // gateway token does not have default value so no configuration value should be available @@ -186,7 +193,8 @@ class TenantConfigurationManagementTest extends AbstractJpaIntegrationTest imple /** * Test that an Exception is thrown, when an integer is stored but a string expected. */ - @Test void storesIntegerWhenStringIsExpected() { + @Test + void storesIntegerWhenStringIsExpected() { final String configKey = TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_KEY; final Integer wrongDatType = 123; assertThatThrownBy(() -> tenantConfigurationManagement.addOrUpdateConfiguration(configKey, wrongDatType)) @@ -197,7 +205,8 @@ class TenantConfigurationManagementTest extends AbstractJpaIntegrationTest imple /** * Test that an Exception is thrown, when an integer is stored but a boolean expected. */ - @Test void storesIntegerWhenBooleanIsExpected() { + @Test + void storesIntegerWhenBooleanIsExpected() { final String configKey = TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_ENABLED; final Integer wrongDataType = 123; assertThatThrownBy(() -> tenantConfigurationManagement.addOrUpdateConfiguration(configKey, wrongDataType)) @@ -208,7 +217,8 @@ class TenantConfigurationManagementTest extends AbstractJpaIntegrationTest imple /** * Test that an Exception is thrown, when an integer is stored as PollingTime. */ - @Test void storesIntegerWhenPollingIntervalIsExpected() { + @Test + void storesIntegerWhenPollingIntervalIsExpected() { final String configKey = TenantConfigurationKey.POLLING_TIME_INTERVAL; final Integer wrongDataType = 123; assertThatThrownBy(() -> tenantConfigurationManagement.addOrUpdateConfiguration(configKey, wrongDataType)) @@ -219,7 +229,8 @@ class TenantConfigurationManagementTest extends AbstractJpaIntegrationTest imple /** * Test that an Exception is thrown, when an invalid formatted string is stored as PollingTime. */ - @Test void storesWrongFormattedStringAsPollingInterval() { + @Test + void storesWrongFormattedStringAsPollingInterval() { final String configKey = TenantConfigurationKey.POLLING_TIME_INTERVAL; final String wrongFormatted = "wrongFormatted"; assertThatThrownBy(() -> tenantConfigurationManagement.addOrUpdateConfiguration(configKey, wrongFormatted)) @@ -230,7 +241,8 @@ class TenantConfigurationManagementTest extends AbstractJpaIntegrationTest imple /** * Test that an Exception is thrown, when an invalid formatted string is stored as PollingTime. */ - @Test void storesTooSmallDurationAsPollingInterval() { + @Test + void storesTooSmallDurationAsPollingInterval() { final String configKey = TenantConfigurationKey.POLLING_TIME_INTERVAL; final String tooSmallDuration = DurationHelper @@ -243,7 +255,8 @@ class TenantConfigurationManagementTest extends AbstractJpaIntegrationTest imple /** * Stores a correct formatted PollignTime and reads it again. */ - @Test void storesCorrectDurationAsPollingInterval() { + @Test + void storesCorrectDurationAsPollingInterval() { final String configKey = TenantConfigurationKey.POLLING_TIME_INTERVAL; final Duration duration = DurationHelper.getDurationByTimeValues(1, 2, 0); @@ -258,7 +271,8 @@ class TenantConfigurationManagementTest extends AbstractJpaIntegrationTest imple /** * Request a config value in a wrong Value */ - @Test void requestConfigValueWithWrongType() { + @Test + void requestConfigValueWithWrongType() { assertThatThrownBy(() -> tenantConfigurationManagement.getConfigurationValue( TenantConfigurationKey.POLLING_TIME_INTERVAL, Serializable.class)) .isInstanceOf(TenantConfigurationValidatorException.class); @@ -267,7 +281,8 @@ class TenantConfigurationManagementTest extends AbstractJpaIntegrationTest imple /** * Verifies that every TenenatConfiguraationKeyName exists only once */ - @Test void verifyThatAllKeysAreDifferent() { + @Test + void verifyThatAllKeysAreDifferent() { final Map keyNames = new HashMap<>(); tenantConfigurationProperties.getConfigurationKeys().forEach(key -> { assertThat(keyNames) @@ -280,7 +295,8 @@ class TenantConfigurationManagementTest extends AbstractJpaIntegrationTest imple /** * Get TenantConfigurationKeyByName */ - @Test void getTenantConfigurationKeyByName() { + @Test + void getTenantConfigurationKeyByName() { final String configKey = TenantConfigurationKey.POLLING_TIME_INTERVAL; assertThat(tenantConfigurationProperties.fromKeyName(configKey).getKeyName()).isEqualTo(configKey); } @@ -288,7 +304,8 @@ class TenantConfigurationManagementTest extends AbstractJpaIntegrationTest imple /** * Tenant configuration which is not declared throws exception */ - @Test void storeTenantConfigurationWhichIsNotDeclaredThrowsException() { + @Test + void storeTenantConfigurationWhichIsNotDeclaredThrowsException() { final String configKeyWhichDoesNotExists = "configKeyWhichDoesNotExists"; assertThatThrownBy(() -> tenantConfigurationManagement.addOrUpdateConfiguration(configKeyWhichDoesNotExists, "value")) .as("Expected InvalidTenantConfigurationKeyException for tenant configuration key which is not declared") diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/model/EntityInterceptorListenerTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/model/EntityInterceptorListenerTest.java index 499035a95..b7ae116f2 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/model/EntityInterceptorListenerTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/model/EntityInterceptorListenerTest.java @@ -35,21 +35,24 @@ class EntityInterceptorListenerTest extends AbstractJpaIntegrationTest { /** * Verifies that the pre persist is called after a entity creation. */ - @Test void prePersistIsCalledWhenPersistingATarget() { + @Test + void prePersistIsCalledWhenPersistingATarget() { executePersistAndAssertCallbackResult(new PrePersistEntityListener()); } /** * Verifies that the post persist is called after a entity creation. */ - @Test void postPersistIsCalledWhenPersistingATarget() { + @Test + void postPersistIsCalledWhenPersistingATarget() { executePersistAndAssertCallbackResult(new PostPersistEntityListener()); } /** * Verifies that the post load is called after a entity is loaded. */ - @Test void postLoadIsCalledWhenLoadATarget() { + @Test + void postLoadIsCalledWhenLoadATarget() { final PostLoadEntityListener postLoadEntityListener = new PostLoadEntityListener(); EntityInterceptorHolder.getInstance().getEntityInterceptors().add(postLoadEntityListener); @@ -63,28 +66,32 @@ class EntityInterceptorListenerTest extends AbstractJpaIntegrationTest { /** * Verifies that the pre update is called after a entity update. */ - @Test void preUpdateIsCalledWhenUpdateATarget() { + @Test + void preUpdateIsCalledWhenUpdateATarget() { executeUpdateAndAssertCallbackResult(new PreUpdateEntityListener()); } /** * Verifies that the post update is called after a entity update. */ - @Test void postUpdateIsCalledWhenUpdateATarget() { + @Test + void postUpdateIsCalledWhenUpdateATarget() { executeUpdateAndAssertCallbackResult(new PostUpdateEntityListener()); } /** * Verifies that the pre remove is called after a entity deletion. */ - @Test void preRemoveIsCalledWhenDeletingATarget() { + @Test + void preRemoveIsCalledWhenDeletingATarget() { executeDeleteAndAssertCallbackResult(new PreRemoveEntityListener()); } /** * Verifies that the post remove is called after a entity deletion. */ - @Test void postRemoveIsCalledWhenDeletingATarget() { + @Test + void postRemoveIsCalledWhenDeletingATarget() { executeDeleteAndAssertCallbackResult(new PostRemoveEntityListener()); } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/model/ModelEqualsHashcodeTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/model/ModelEqualsHashcodeTest.java index 6a464a208..8f7b1e123 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/model/ModelEqualsHashcodeTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/model/ModelEqualsHashcodeTest.java @@ -24,7 +24,8 @@ class ModelEqualsHashcodeTest extends AbstractJpaIntegrationTest { /** * Verifies that different objects even with identical primary key, version and tenant return different hash codes. */ - @Test void differentEntitiesReturnDifferentHashCodes() { + @Test + void differentEntitiesReturnDifferentHashCodes() { assertThat(new JpaAction().hashCode()).as("action should have different hashcode than action status") .isNotEqualTo(new JpaActionStatus().hashCode()); assertThat(new JpaDistributionSet().hashCode()) @@ -41,7 +42,8 @@ class ModelEqualsHashcodeTest extends AbstractJpaIntegrationTest { /** * Verifies that different object even with identical primary key, version and tenant are not equal. */ - @Test void differentEntitiesAreNotEqual() { + @Test + void differentEntitiesAreNotEqual() { assertThat(new JpaAction().equals(new JpaActionStatus())).as("action equals action status").isFalse(); assertThat(new JpaDistributionSet().equals(new JpaSoftwareModule())) .as("Distribution set equals software module").isFalse(); @@ -54,7 +56,8 @@ class ModelEqualsHashcodeTest extends AbstractJpaIntegrationTest { /** * Verifies that updated entities are not equal. */ - @Test void changedEntitiesAreNotEqual() { + @Test + void changedEntitiesAreNotEqual() { final SoftwareModuleType type = softwareModuleTypeManagement .create(entityFactory.softwareModuleType().create().key("test").name("test")); assertThat(type).as("persited entity is not equal to regular object") @@ -68,7 +71,8 @@ class ModelEqualsHashcodeTest extends AbstractJpaIntegrationTest { /** * Verify that no proxy of the entity manager has an influence on the equals or hashcode result. */ - @Test void managedEntityIsEqualToUnamangedObjectWithSameKey() { + @Test + void managedEntityIsEqualToUnamangedObjectWithSameKey() { final SoftwareModuleType type = softwareModuleTypeManagement.create( entityFactory.softwareModuleType().create().key("test").name("test").description("test")); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLActionFieldsTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLActionFieldsTest.java index 2aad8de37..015accc25 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLActionFieldsTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLActionFieldsTest.java @@ -51,7 +51,8 @@ class RSQLActionFieldsTest extends AbstractJpaIntegrationTest { /** * Test filter action by id */ - @Test void testFilterByParameterId() { + @Test + void testFilterByParameterId() { assertRSQLQuery(ActionFields.ID.name() + "==" + action.getId(), 1); assertRSQLQuery(ActionFields.ID.name() + "!=" + action.getId(), 10); assertRSQLQuery(ActionFields.ID.name() + "==" + -1, 0); @@ -69,7 +70,8 @@ class RSQLActionFieldsTest extends AbstractJpaIntegrationTest { /** * Test action by status */ - @Test void testFilterByParameterStatus() { + @Test + void testFilterByParameterStatus() { assertRSQLQuery(ActionFields.STATUS.name() + "==pending", 5); assertRSQLQuery(ActionFields.STATUS.name() + "!=pending", 6); assertRSQLQuery(ActionFields.STATUS.name() + "=in=(pending)", 5); @@ -84,7 +86,8 @@ class RSQLActionFieldsTest extends AbstractJpaIntegrationTest { /** * Test action by status */ - @Test void testFilterByParameterExtRef() { + @Test + void testFilterByParameterExtRef() { assertRSQLQuery(ActionFields.EXTERNALREF.name() + "==extRef", 5); assertRSQLQuery(ActionFields.EXTERNALREF.name() + "!=extRef", 6); assertRSQLQuery(ActionFields.EXTERNALREF.name() + "==extRef*", 10); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLRolloutFieldTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLRolloutFieldTest.java index 749a03d30..edfa9be0f 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLRolloutFieldTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLRolloutFieldTest.java @@ -41,7 +41,8 @@ class RSQLRolloutFieldTest extends AbstractJpaIntegrationTest { /** * Test filter rollout by distrbution set type id */ - @Test void testFilterByDsType() { + @Test + void testFilterByDsType() { assertRSQLQuery(RolloutFields.DISTRIBUTIONSET.name() + ".type.id" + "==" + rollout.getDistributionSet().getType().getId() + 1, 0); assertRSQLQuery(RolloutFields.DISTRIBUTIONSET.name() + ".type.id" + "!=" + rollout.getDistributionSet().getType().getId() + 1, 1); assertRSQLQuery(RolloutFields.DISTRIBUTIONSET.name() + ".type.id" + "==" + rollout.getDistributionSet().getType().getId(), 1); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLRolloutGroupFieldTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLRolloutGroupFieldTest.java index 77d7aeb6b..4c2bc4c92 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLRolloutGroupFieldTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLRolloutGroupFieldTest.java @@ -47,7 +47,8 @@ class RSQLRolloutGroupFieldTest extends AbstractJpaIntegrationTest { /** * Test filter rollout group by id */ - @Test void testFilterByParameterId() { + @Test + void testFilterByParameterId() { assertRSQLQuery(RolloutGroupFields.ID.name() + "==" + rolloutGroupId, 1); assertRSQLQuery(RolloutGroupFields.ID.name() + "!=" + rolloutGroupId, 3); assertRSQLQuery(RolloutGroupFields.ID.name() + "==" + -1, 0); @@ -65,7 +66,8 @@ class RSQLRolloutGroupFieldTest extends AbstractJpaIntegrationTest { /** * Test filter rollout group by name */ - @Test void testFilterByParameterName() { + @Test + void testFilterByParameterName() { assertRSQLQuery(RolloutGroupFields.NAME.name() + "==group-1", 1); assertRSQLQuery(RolloutGroupFields.NAME.name() + "!=group-1", 3); assertRSQLQuery(RolloutGroupFields.NAME.name() + "==*", 4); @@ -77,7 +79,8 @@ class RSQLRolloutGroupFieldTest extends AbstractJpaIntegrationTest { /** * Test filter rollout group by description */ - @Test void testFilterByParameterDescription() { + @Test + void testFilterByParameterDescription() { assertRSQLQuery(RolloutGroupFields.DESCRIPTION.name() + "==group-1", 1); assertRSQLQuery(RolloutGroupFields.DESCRIPTION.name() + "!=group-1", 3); assertRSQLQuery(RolloutGroupFields.DESCRIPTION.name() + "==group*", 4); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLSoftwareModuleFieldTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLSoftwareModuleFieldTest.java index 536451b14..ceccd1178 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLSoftwareModuleFieldTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLSoftwareModuleFieldTest.java @@ -60,7 +60,8 @@ class RSQLSoftwareModuleFieldTest extends AbstractJpaIntegrationTest { /** * Test filter software module by id */ - @Test void testFilterByParameterId() { + @Test + void testFilterByParameterId() { assertRSQLQuery(SoftwareModuleFields.ID.name() + "==" + ah.getId(), 1); assertRSQLQuery(SoftwareModuleFields.ID.name() + "!=" + ah.getId(), 5); assertRSQLQuery(SoftwareModuleFields.ID.name() + "==" + -1, 0); @@ -78,7 +79,8 @@ class RSQLSoftwareModuleFieldTest extends AbstractJpaIntegrationTest { /** * Test filter software module by name */ - @Test void testFilterByParameterName() { + @Test + void testFilterByParameterName() { assertRSQLQuery(SoftwareModuleFields.NAME.name() + "==agent-hub", 1); assertRSQLQuery(SoftwareModuleFields.NAME.name() + "!=agent-hub", 5); assertRSQLQuery(SoftwareModuleFields.NAME.name() + "==agent-hub*", 2); @@ -100,7 +102,8 @@ class RSQLSoftwareModuleFieldTest extends AbstractJpaIntegrationTest { /** * Test filter software module by name which contain mutated vowels */ - @Test void testFilterByParameterNameWithUmlaut() { + @Test + void testFilterByParameterNameWithUmlaut() { assertRSQLQuery(SoftwareModuleFields.NAME.name() + "==*Ö*", 1); assertRSQLQuery(SoftwareModuleFields.NAME.name() + "==*Ä*", 1); assertRSQLQuery(SoftwareModuleFields.NAME.name() + "==*Ü*", 1); @@ -109,7 +112,8 @@ class RSQLSoftwareModuleFieldTest extends AbstractJpaIntegrationTest { /** * Test filter software module by description */ - @Test void testFilterByParameterDescription() { + @Test + void testFilterByParameterDescription() { assertRSQLQuery(SoftwareModuleFields.DESCRIPTION.name() + "==''", 1); assertRSQLQuery(SoftwareModuleFields.DESCRIPTION.name() + "!=''", 5); assertRSQLQuery(SoftwareModuleFields.DESCRIPTION.name() + "==agent-hub", 1); @@ -122,7 +126,8 @@ class RSQLSoftwareModuleFieldTest extends AbstractJpaIntegrationTest { /** * Test filter software module by version */ - @Test void testFilterByParameterVersion() { + @Test + void testFilterByParameterVersion() { assertRSQLQuery(SoftwareModuleFields.VERSION.name() + "==1.0.1", 2); assertRSQLQuery(SoftwareModuleFields.VERSION.name() + "!=v1.0", 6); assertRSQLQuery(SoftwareModuleFields.VERSION.name() + "=in=(1.0.1,1.0.2)", 2); @@ -132,7 +137,8 @@ class RSQLSoftwareModuleFieldTest extends AbstractJpaIntegrationTest { /** * Test filter software module by type key */ - @Test void testFilterByType() { + @Test + void testFilterByType() { assertRSQLQuery(SoftwareModuleFields.TYPE.name() + "==" + TestdataFactory.SM_TYPE_APP, 2); assertRSQLQuery(SoftwareModuleFields.TYPE.name() + "!=" + TestdataFactory.SM_TYPE_APP, 4); assertRSQLQuery(SoftwareModuleFields.TYPE.name() + "==noExist*", 0); @@ -143,7 +149,8 @@ class RSQLSoftwareModuleFieldTest extends AbstractJpaIntegrationTest { /** * Test filter software module by metadata */ - @Test void testFilterByMetadata() { + @Test + void testFilterByMetadata() { assertRSQLQuery(SoftwareModuleFields.METADATA.name() + ".metaKey==metaValue", 1); assertRSQLQuery(SoftwareModuleFields.METADATA.name() + ".metaKey!=metaValue", 1); assertRSQLQuery(SoftwareModuleFields.METADATA.name() + ".metaKey!=notexist", 2); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLSoftwareModuleTypeFieldsTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLSoftwareModuleTypeFieldsTest.java index 3348a1c9b..b1cd6542f 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLSoftwareModuleTypeFieldsTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLSoftwareModuleTypeFieldsTest.java @@ -29,7 +29,8 @@ class RSQLSoftwareModuleTypeFieldsTest extends AbstractJpaIntegrationTest { /** * Test filter software module test type by id */ - @Test void testFilterByParameterId() { + @Test + void testFilterByParameterId() { assertRSQLQuery(SoftwareModuleTypeFields.ID.name() + "==" + osType.getId(), 1); assertRSQLQuery(SoftwareModuleTypeFields.ID.name() + "!=" + osType.getId(), 2); assertRSQLQuery(SoftwareModuleTypeFields.ID.name() + "==" + -1, 0); @@ -47,7 +48,8 @@ class RSQLSoftwareModuleTypeFieldsTest extends AbstractJpaIntegrationTest { /** * Test filter software module test type by name */ - @Test void testFilterByParameterName() { + @Test + void testFilterByParameterName() { assertRSQLQuery(SoftwareModuleTypeFields.NAME.name() + "==" + Constants.SMT_DEFAULT_OS_NAME, 1); assertRSQLQuery(SoftwareModuleTypeFields.NAME.name() + "!=" + Constants.SMT_DEFAULT_OS_NAME, 2); } @@ -55,7 +57,8 @@ class RSQLSoftwareModuleTypeFieldsTest extends AbstractJpaIntegrationTest { /** * Test filter software module test type by description */ - @Test void testFilterByParameterDescription() { + @Test + void testFilterByParameterDescription() { assertRSQLQuery(SoftwareModuleTypeFields.DESCRIPTION.name() + "==''", 0); assertRSQLQuery(SoftwareModuleTypeFields.DESCRIPTION.name() + "!=''", 3); assertRSQLQuery(SoftwareModuleTypeFields.DESCRIPTION.name() + "==Updated*", 3); @@ -66,7 +69,8 @@ class RSQLSoftwareModuleTypeFieldsTest extends AbstractJpaIntegrationTest { /** * Test filter software module test type by key */ - @Test void testFilterByParameterKey() { + @Test + void testFilterByParameterKey() { assertRSQLQuery(SoftwareModuleTypeFields.KEY.name() + "==os", 1); assertRSQLQuery(SoftwareModuleTypeFields.KEY.name() + "!=os", 2); assertRSQLQuery(SoftwareModuleTypeFields.KEY.name() + "=in=(os)", 1); @@ -76,7 +80,8 @@ class RSQLSoftwareModuleTypeFieldsTest extends AbstractJpaIntegrationTest { /** * Test filter software module test type by max */ - @Test void testFilterByMaxAssignment() { + @Test + void testFilterByMaxAssignment() { assertRSQLQuery(SoftwareModuleTypeFields.MAXASSIGNMENTS.name() + "==1", 2); assertRSQLQuery(SoftwareModuleTypeFields.MAXASSIGNMENTS.name() + "!=1", 1); } diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLTagFieldsTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLTagFieldsTest.java index 395275531..a593d252f 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLTagFieldsTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLTagFieldsTest.java @@ -41,7 +41,8 @@ class RSQLTagFieldsTest extends AbstractJpaIntegrationTest { /** * Test filter target tag by name */ - @Test void testFilterTargetTagByParameterName() { + @Test + void testFilterTargetTagByParameterName() { assertRSQLQueryTarget(TagFields.NAME.name() + "==''", 0); assertRSQLQueryTarget(TagFields.NAME.name() + "!=''", 5); assertRSQLQueryTarget(TagFields.NAME.name() + "==1", 1); @@ -55,7 +56,8 @@ class RSQLTagFieldsTest extends AbstractJpaIntegrationTest { /** * Test filter target tag by description */ - @Test void testFilterTargetTagByParameterDescription() { + @Test + void testFilterTargetTagByParameterDescription() { assertRSQLQueryTarget(TagFields.DESCRIPTION.name() + "==''", 0); assertRSQLQueryTarget(TagFields.DESCRIPTION.name() + "!=''", 5); assertRSQLQueryTarget(TagFields.DESCRIPTION.name() + "==1", 1); @@ -69,7 +71,8 @@ class RSQLTagFieldsTest extends AbstractJpaIntegrationTest { /** * Test filter target tag by colour */ - @Test void testFilterTargetTagByParameterColour() { + @Test + void testFilterTargetTagByParameterColour() { assertRSQLQueryTarget(TagFields.COLOUR.name() + "==''", 0); assertRSQLQueryTarget(TagFields.COLOUR.name() + "!=''", 5); assertRSQLQueryTarget(TagFields.COLOUR.name() + "==red", 3); @@ -83,7 +86,8 @@ class RSQLTagFieldsTest extends AbstractJpaIntegrationTest { /** * Test filter distribution set tag by name */ - @Test void testFilterDistributionSetTagByParameterName() { + @Test + void testFilterDistributionSetTagByParameterName() { assertRSQLQueryDistributionSet(TagFields.NAME.name() + "==''", 0); assertRSQLQueryDistributionSet(TagFields.NAME.name() + "!=''", 5); assertRSQLQueryDistributionSet(TagFields.NAME.name() + "==1", 1); @@ -97,7 +101,8 @@ class RSQLTagFieldsTest extends AbstractJpaIntegrationTest { /** * Test filter distribution set by description */ - @Test void testFilterDistributionSetTagByParameterDescription() { + @Test + void testFilterDistributionSetTagByParameterDescription() { assertRSQLQueryDistributionSet(TagFields.DESCRIPTION.name() + "==''", 0); assertRSQLQueryDistributionSet(TagFields.DESCRIPTION.name() + "!=''", 5); assertRSQLQueryDistributionSet(TagFields.DESCRIPTION.name() + "==1", 1); @@ -111,7 +116,8 @@ class RSQLTagFieldsTest extends AbstractJpaIntegrationTest { /** * Test filter distribution set by colour */ - @Test void testFilterDistributionSetTagByParameterColour() { + @Test + void testFilterDistributionSetTagByParameterColour() { assertRSQLQueryDistributionSet(TagFields.COLOUR.name() + "==''", 0); assertRSQLQueryDistributionSet(TagFields.COLOUR.name() + "!=''", 5); assertRSQLQueryDistributionSet(TagFields.COLOUR.name() + "==red", 3); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLTargetFieldTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLTargetFieldTest.java index 925a11386..c69d0c05c 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLTargetFieldTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLTargetFieldTest.java @@ -109,7 +109,8 @@ class RSQLTargetFieldTest extends AbstractJpaIntegrationTest { /** * Test filter target by (controller) id */ - @Test void testFilterByParameterId() { + @Test + void testFilterByParameterId() { assertRSQLQuery(TargetFields.ID.name() + "==targetId123", 1); assertRSQLQuery(TargetFields.ID.name() + "!=targetId123", 4); assertRSQLQuery(TargetFields.ID.name() + "=in=(targetId123,notexist)", 1); @@ -119,7 +120,8 @@ class RSQLTargetFieldTest extends AbstractJpaIntegrationTest { /** * Test filter target by name */ - @Test void testFilterByParameterName() { + @Test + void testFilterByParameterName() { assertRSQLQuery(TargetFields.NAME.name() + "==targetName123", 1); assertRSQLQuery(TargetFields.NAME.name() + "==target*", 5); assertRSQLQuery(TargetFields.NAME.name() + "==noExist*", 0); @@ -131,7 +133,8 @@ class RSQLTargetFieldTest extends AbstractJpaIntegrationTest { /** * Test filter target by description */ - @Test void testFilterByParameterDescription() { + @Test + void testFilterByParameterDescription() { assertRSQLQuery(TargetFields.DESCRIPTION.name() + "==''", 3); assertRSQLQuery(TargetFields.DESCRIPTION.name() + "!=''", 2); assertRSQLQuery(TargetFields.DESCRIPTION.name() + "==targetDesc123", 1); @@ -145,7 +148,8 @@ class RSQLTargetFieldTest extends AbstractJpaIntegrationTest { /** * Test filter target by controller id */ - @Test void testFilterByParameterControllerId() { + @Test + void testFilterByParameterControllerId() { assertRSQLQuery(TargetFields.CONTROLLERID.name() + "==targetId123", 1); assertRSQLQuery(TargetFields.CONTROLLERID.name() + "==target*", 5); assertRSQLQuery(TargetFields.CONTROLLERID.name() + "==noExist*", 0); @@ -157,7 +161,8 @@ class RSQLTargetFieldTest extends AbstractJpaIntegrationTest { /** * Test filter target by status */ - @Test void testFilterByParameterUpdateStatus() { + @Test + void testFilterByParameterUpdateStatus() { assertRSQLQuery(TargetFields.UPDATESTATUS.name() + "==pending", 1); assertRSQLQuery(TargetFields.UPDATESTATUS.name() + "!=pending", 4); final String rsqlNoExistStar = TargetFields.UPDATESTATUS.name() + "==noExist*"; @@ -171,7 +176,8 @@ class RSQLTargetFieldTest extends AbstractJpaIntegrationTest { /** * Test filter target by attribute */ - @Test void testFilterByAttribute() { + @Test + void testFilterByAttribute() { controllerManagement.updateControllerAttributes( testdataFactory.createTarget().getControllerId(), Map.of( @@ -237,7 +243,8 @@ class RSQLTargetFieldTest extends AbstractJpaIntegrationTest { /** * Test filter target by assigned ds name */ - @Test void testFilterByAssignedDsName() { + @Test + void testFilterByAssignedDsName() { assertRSQLQuery(TargetFields.ASSIGNEDDS.name() + ".name==AssignedDs", 1); assertRSQLQuery(TargetFields.ASSIGNEDDS.name() + ".name==A*", 1); assertRSQLQuery(TargetFields.ASSIGNEDDS.name() + ".name==noExist*", 0); @@ -248,7 +255,8 @@ class RSQLTargetFieldTest extends AbstractJpaIntegrationTest { /** * Test filter target by assigned ds version */ - @Test void testFilterByAssignedDsVersion() { + @Test + void testFilterByAssignedDsVersion() { assertRSQLQuery(TargetFields.ASSIGNEDDS.name() + ".version==" + TestdataFactory.DEFAULT_VERSION, 1); assertRSQLQuery(TargetFields.ASSIGNEDDS.name() + ".version==*1*", 1); assertRSQLQuery(TargetFields.ASSIGNEDDS.name() + ".version==noExist*", 0); @@ -259,7 +267,8 @@ class RSQLTargetFieldTest extends AbstractJpaIntegrationTest { /** * Test filter target by tag name */ - @Test void testFilterByTag() { + @Test + void testFilterByTag() { assertRSQLQuery(TargetFields.TAG.name() + "==Tag1", 2); assertRSQLQuery(TargetFields.TAG.name() + "!=Tag1", 3); assertRSQLQuery(TargetFields.TAG.name() + "==T*", 4); @@ -282,7 +291,8 @@ class RSQLTargetFieldTest extends AbstractJpaIntegrationTest { /** * Test filter target by lastTargetQuery */ - @Test void testFilterByLastTargetQuery() { + @Test + void testFilterByLastTargetQuery() { assertRSQLQuery(TargetFields.LASTCONTROLLERREQUESTAT.name() + "==" + target.getLastTargetQuery(), 1); assertRSQLQuery(TargetFields.LASTCONTROLLERREQUESTAT.name() + "!=" + target.getLastTargetQuery(), 4); assertRSQLQuery(TargetFields.LASTCONTROLLERREQUESTAT.name() + "=lt=" + target.getLastTargetQuery(), 0); @@ -296,7 +306,8 @@ class RSQLTargetFieldTest extends AbstractJpaIntegrationTest { /** * Test filter target by metadata */ - @Test void testFilterByMetadata() { + @Test + void testFilterByMetadata() { targetManagement.createMetadata(testdataFactory.createTarget().getControllerId(), Map.of("key.dot", "value.dot")); assertRSQLQuery(TargetFields.METADATA.name() + ".metaKey==metaValue", 1); @@ -363,7 +374,8 @@ class RSQLTargetFieldTest extends AbstractJpaIntegrationTest { /** * Test filter based on more complex RSQL queries */ - @Test void testFilterByComplexQueries() { + @Test + void testFilterByComplexQueries() { assertRSQLQuery(TargetFields.NAME.name() + "!=targetName123" + AND + TargetFields.METADATA.name() + ".metaKey!=value", 0); assertRSQLQuery( "(" + TargetFields.TAG.name() + "!=TAG1" + OR + TargetFields.TAG.name() + "!=TAG2)" + @@ -373,7 +385,8 @@ class RSQLTargetFieldTest extends AbstractJpaIntegrationTest { /** * Testing allowed RSQL keys based on TargetFields definition */ - @Test void rsqlValidTargetFields() { + @Test + void rsqlValidTargetFields() { RSQLUtility.validateRsqlFor( "ID == '0123' and NAME == abcd and DESCRIPTION == absd and CREATEDAT =lt= 0123 and LASTMODIFIEDAT =gt= 0123" + " and CONTROLLERID == 0123 and UPDATESTATUS == PENDING and IPADDRESS == 0123 and LASTCONTROLLERREQUESTAT == 0123" + @@ -401,7 +414,8 @@ class RSQLTargetFieldTest extends AbstractJpaIntegrationTest { /** * Test filter by target type key */ - @Test void shouldFilterTargetsByTypeKey() { + @Test + void shouldFilterTargetsByTypeKey() { assertRSQLQuery("targettype." + TargetTypeFields.KEY.name() + "==" + targetType1.getKey(), 1); assertRSQLQuery("targettype." + TargetTypeFields.KEY.name() + "==*1.key", 1); assertRSQLQuery("targettype." + TargetTypeFields.KEY.name() + "!=" + targetType2.getKey(), 4); @@ -411,7 +425,8 @@ class RSQLTargetFieldTest extends AbstractJpaIntegrationTest { /** * Test filter by target type name */ - @Test void shouldFilterTargetsByTypeName() { + @Test + void shouldFilterTargetsByTypeName() { assertRSQLQuery("targettype." + TargetTypeFields.NAME.name() + "==" + targetType1.getName(), 1); assertRSQLQuery("targettype." + TargetTypeFields.NAME.name() + "==*1", 1); assertRSQLQuery("targettype." + TargetTypeFields.NAME.name() + "!=" + targetType2.getName(), 4); @@ -421,7 +436,8 @@ class RSQLTargetFieldTest extends AbstractJpaIntegrationTest { /** * Test filter by target type ID and description */ - @Test void shouldFilterTargetsByTypeIdAndDescription() { + @Test + void shouldFilterTargetsByTypeIdAndDescription() { assertThatExceptionOfType(RSQLParameterUnsupportedFieldException.class) .isThrownBy(() -> assertRSQLQuery("targettype.ID==1", 0)); assertThatExceptionOfType(RSQLParameterUnsupportedFieldException.class) diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLTargetFilterQueryFieldsTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLTargetFilterQueryFieldsTest.java index 73ca34365..890e9a3c4 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLTargetFilterQueryFieldsTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLTargetFilterQueryFieldsTest.java @@ -54,7 +54,8 @@ class RSQLTargetFilterQueryFieldsTest extends AbstractJpaIntegrationTest { /** * Test filter target filter query by id */ - @Test void testFilterByParameterId() { + @Test + void testFilterByParameterId() { assertRSQLQuery(TargetFilterQueryFields.ID.name() + "==" + filter1.getId(), 1); assertRSQLQuery(TargetFilterQueryFields.ID.name() + "!=" + filter1.getId(), 2); assertRSQLQuery(TargetFilterQueryFields.ID.name() + "==" + -1, 0); @@ -73,7 +74,8 @@ class RSQLTargetFilterQueryFieldsTest extends AbstractJpaIntegrationTest { /** * Test filter target filter query by name */ - @Test void testFilterByParameterName() { + @Test + void testFilterByParameterName() { assertRSQLQuery(TargetFilterQueryFields.NAME.name() + "==" + filter1.getName(), 1); assertRSQLQuery(TargetFilterQueryFields.NAME.name() + "==" + filter2.getName(), 1); assertRSQLQuery(TargetFilterQueryFields.NAME.name() + "==filter_*", 3); @@ -85,7 +87,8 @@ class RSQLTargetFilterQueryFieldsTest extends AbstractJpaIntegrationTest { /** * Test filter target filter query by auto assigned ds name */ - @Test void testFilterByAutoAssignedDsName() { + @Test + void testFilterByAutoAssignedDsName() { assertRSQLQuery(TargetFilterQueryFields.AUTOASSIGNDISTRIBUTIONSET.name() + ".name==" + filter1.getAutoAssignDistributionSet().getName(), 1); assertRSQLQuery(TargetFilterQueryFields.AUTOASSIGNDISTRIBUTIONSET.name() + ".name==" @@ -101,7 +104,8 @@ class RSQLTargetFilterQueryFieldsTest extends AbstractJpaIntegrationTest { /** * Test filter target filter query by auto assigned ds version */ - @Test void testFilterByAutoAssignedDsVersion() { + @Test + void testFilterByAutoAssignedDsVersion() { assertRSQLQuery(TargetFilterQueryFields.AUTOASSIGNDISTRIBUTIONSET.name() + ".version==" + TestdataFactory.DEFAULT_VERSION, 2); assertRSQLQuery(TargetFilterQueryFields.AUTOASSIGNDISTRIBUTIONSET.name() + ".version==*1*", 2); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLUtilityTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLUtilityTest.java index 6df9e6540..7b95d8c8d 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLUtilityTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/RSQLUtilityTest.java @@ -364,7 +364,8 @@ class RSQLUtilityTest { /** * Tests the resolution of overdue_ts placeholder in context of a RSQL expression. */ - @Test void correctRsqlWithOverdueMacro() { + @Test + void correctRsqlWithOverdueMacro() { reset0(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock); final String overdueProp = "overdue_ts"; final String overduePropPlaceholder = "${" + overdueProp + "}"; @@ -387,7 +388,8 @@ class RSQLUtilityTest { /** * Tests RSQL expression with an unknown placeholder. */ - @Test void correctRsqlWithUnknownMacro() { + @Test + void correctRsqlWithUnknownMacro() { reset0(baseSoftwareModuleRootMock, criteriaQueryMock, criteriaBuilderMock); final String overdueProp = "unknown"; final String overduePropPlaceholder = "${" + overdueProp + "}"; diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/VirtualPropertyResolverTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/VirtualPropertyResolverTest.java index 21d80b2f7..fb789b1f7 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/VirtualPropertyResolverTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/rsql/VirtualPropertyResolverTest.java @@ -63,7 +63,8 @@ class VirtualPropertyResolverTest { /** * Tests VirtualPropertyResolver with a placeholder unknown to VirtualPropertyResolver. */ - @Test void handleUnknownPlaceholder() { + @Test + void handleUnknownPlaceholder() { final String placeholder = "${unknown}"; final String testString = "lhs=lt=" + placeholder; @@ -74,7 +75,8 @@ class VirtualPropertyResolverTest { /** * Tests escape mechanism for placeholders (syntax is $${SOME_PLACEHOLDER}). */ - @Test void handleEscapedPlaceholder() { + @Test + void handleEscapedPlaceholder() { final String placeholder = "${OVERDUE_TS}"; final String escapedPlaceholder = StringSubstitutor.DEFAULT_ESCAPE + placeholder; final String testString = "lhs=lt=" + escapedPlaceholder; diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/specifications/SpecificationsBuilderTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/specifications/SpecificationsBuilderTest.java index 7fc8c8138..91cefdd82 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/specifications/SpecificationsBuilderTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/specifications/SpecificationsBuilderTest.java @@ -39,7 +39,8 @@ class SpecificationsBuilderTest { /** * Test the combination of specs on an empty list which returns null */ - @Test void combineWithAndEmptyList() { + @Test + void combineWithAndEmptyList() { final List> specList = Collections.emptyList(); assertThat(SpecificationsBuilder.combineWithAnd(specList)).isNull(); } @@ -47,7 +48,8 @@ class SpecificationsBuilderTest { /** * Test the combination of specs on an immutable list with one entry */ - @Test void combineWithAndSingleImmutableList() { + @Test + void combineWithAndSingleImmutableList() { final Specification spec = (root, query, cb) -> cb.equal(root.get("field1"), "testValue"); final List> specList = Collections.singletonList(spec); final Specification specifications = SpecificationsBuilder.combineWithAnd(specList); @@ -72,7 +74,8 @@ class SpecificationsBuilderTest { /** * Test the combination of specs on a list with multiple entries */ - @Test void combineWithAndList() { + @Test + void combineWithAndList() { final Specification spec1 = (root, query, cb) -> cb.equal(root.get("field1"), "testValue1"); final Specification spec2 = (root, query, cb) -> cb.equal(root.get("field2"), "testValue2"); diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/tenancy/MultiTenancyEntityTest.java b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/tenancy/MultiTenancyEntityTest.java index 0eb876957..d70d66055 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/tenancy/MultiTenancyEntityTest.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/test/java/org/eclipse/hawkbit/repository/jpa/tenancy/MultiTenancyEntityTest.java @@ -41,7 +41,8 @@ class MultiTenancyEntityTest extends AbstractJpaIntegrationTest { /** * Ensures that multiple targets with same controller-ID can be created for different tenants. */ - @Test void createMultipleTargetsWithSameIdForDifferentTenant() throws Exception { + @Test + void createMultipleTargetsWithSameIdForDifferentTenant() throws Exception { // known controller ID for overall tenants same final String knownControllerId = "controllerId"; @@ -65,7 +66,8 @@ class MultiTenancyEntityTest extends AbstractJpaIntegrationTest { /** * Ensures that targets created by a tenant are not visible by another tenant. */ - @Test @WithUser(tenantId = "mytenant", allSpPermissions = true) + @Test + @WithUser(tenantId = "mytenant", allSpPermissions = true) void queryTargetFromDifferentTenantIsNotVisible() throws Exception { // create target for another tenant final String anotherTenant = "anotherTenant"; @@ -86,7 +88,8 @@ class MultiTenancyEntityTest extends AbstractJpaIntegrationTest { /** * Ensures that tenant with proper permissions can read and delete other tenants. */ - @Test @WithUser(tenantId = "mytenant", allSpPermissions = true) + @Test + @WithUser(tenantId = "mytenant", allSpPermissions = true) void deleteAnotherTenantPossible() throws Exception { // create target for another tenant final String anotherTenant = "anotherTenant"; @@ -103,7 +106,8 @@ class MultiTenancyEntityTest extends AbstractJpaIntegrationTest { /** * Ensures that tenant metadata is retrieved for the current tenant. */ - @Test @WithUser(tenantId = "mytenant", autoCreateTenant = false, allSpPermissions = true) + @Test + @WithUser(tenantId = "mytenant", autoCreateTenant = false, allSpPermissions = true) void getTenanatMetdata() throws Exception { // logged in tenant mytenant - check if tenant default data is @@ -124,7 +128,8 @@ class MultiTenancyEntityTest extends AbstractJpaIntegrationTest { /** * Ensures that targets created from a different tenant cannot be deleted from other tenants */ - @Test @WithUser(tenantId = "mytenant", allSpPermissions = true) + @Test + @WithUser(tenantId = "mytenant", allSpPermissions = true) void deleteTargetFromOtherTenantIsNotPossible() throws Exception { // create target for another tenant final String anotherTenant = "anotherTenant"; @@ -151,7 +156,8 @@ class MultiTenancyEntityTest extends AbstractJpaIntegrationTest { /** * Ensures that multiple distribution sets with same name and version can be created for different tenants. */ - @Test void createMultipleDistributionSetsWithSameNameForDifferentTenants() throws Exception { + @Test + void createMultipleDistributionSetsWithSameNameForDifferentTenants() throws Exception { // known tenant names final String tenant = "aTenant"; diff --git a/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/json/model/ExceptionInfoTest.java b/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/json/model/ExceptionInfoTest.java index 9ae09bbbf..bc5b72155 100644 --- a/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/json/model/ExceptionInfoTest.java +++ b/hawkbit-rest-core/src/test/java/org/eclipse/hawkbit/rest/json/model/ExceptionInfoTest.java @@ -25,7 +25,8 @@ class ExceptionInfoTest { /** * Ensures that setters and getters match on teh payload. */ - @Test void setterAndGetterOnExceptionInfo() { + @Test + void setterAndGetterOnExceptionInfo() { final String knownExceptionClass = "hawkbit.test.exception.Class"; final String knownErrorCode = "hawkbit.error.code.Known"; final String knownMessage = "a known message"; diff --git a/hawkbit-security-core/src/test/java/org/eclipse/hawkbit/im/authentication/SpPermissionTest.java b/hawkbit-security-core/src/test/java/org/eclipse/hawkbit/im/authentication/SpPermissionTest.java index 85692cfd8..6c3bf0c71 100644 --- a/hawkbit-security-core/src/test/java/org/eclipse/hawkbit/im/authentication/SpPermissionTest.java +++ b/hawkbit-security-core/src/test/java/org/eclipse/hawkbit/im/authentication/SpPermissionTest.java @@ -29,7 +29,8 @@ final class SpPermissionTest { /** * Try to double check if all permissions works as expected */ - @Test void shouldReturnAllPermissions() { + @Test + void shouldReturnAllPermissions() { List expected = new LinkedList<>(); ReflectionUtils.doWithFields(SpPermission.class, f -> { if (ReflectionUtils.isPublicStaticFinal(f) && String.class.equals(f.getType())) { diff --git a/hawkbit-security-core/src/test/java/org/eclipse/hawkbit/util/IpUtilTest.java b/hawkbit-security-core/src/test/java/org/eclipse/hawkbit/util/IpUtilTest.java index abdb1fcdf..c035bd1bf 100644 --- a/hawkbit-security-core/src/test/java/org/eclipse/hawkbit/util/IpUtilTest.java +++ b/hawkbit-security-core/src/test/java/org/eclipse/hawkbit/util/IpUtilTest.java @@ -49,7 +49,8 @@ class IpUtilTest { /** * Tests create uri from request */ - @Test void getRemoteAddrFromRequestIfForwardedHeaderNotPresent() { + @Test + void getRemoteAddrFromRequestIfForwardedHeaderNotPresent() { final URI knownRemoteClientIP = IpUtil.createHttpUri("127.0.0.1"); when(requestMock.getRemoteAddr()).thenReturn(knownRemoteClientIP.getHost()); @@ -65,7 +66,8 @@ class IpUtilTest { /** * Tests create uri from request with masked IP when IP tracking is disabled */ - @Test void maskRemoteAddrIfDisabled() { + @Test + void maskRemoteAddrIfDisabled() { final URI knownRemoteClientIP = IpUtil.createHttpUri("***"); when(securityPropertyMock.getClients()).thenReturn(clientMock); when(clientMock.getRemoteIpHeader()).thenReturn(KNOWN_REQUEST_HEADER); @@ -82,7 +84,8 @@ class IpUtilTest { /** * Tests create uri from x forward header */ - @Test void getRemoteAddrFromXForwardedForHeader() { + @Test + void getRemoteAddrFromXForwardedForHeader() { final URI knownRemoteClientIP = IpUtil.createHttpUri("10.99.99.1"); when(requestMock.getHeader(X_FORWARDED_FOR)).thenReturn(knownRemoteClientIP.getHost()); @@ -97,7 +100,8 @@ class IpUtilTest { /** * Tests client uri from request */ - @Test void testCreateClientHttpUri() { + @Test + void testCreateClientHttpUri() { checkHostInfoResolution("0:0:0:0:0:0:0:1", "[0:0:0:0:0:0:0:1]", true); checkHostInfoResolution("127.0.0.1", "127.0.0.1", true); checkHostInfoResolution("127.0.0.1:93493", "127.0.0.1", true); @@ -111,7 +115,8 @@ class IpUtilTest { /** * Tests client uri from request */ - @Test void testResolveClientIpFromHeader() { + @Test + void testResolveClientIpFromHeader() { checkHostInfoResolution("0:0:0:0:0:0:0:1", "[0:0:0:0:0:0:0:1]", false); checkHostInfoResolution("127.0.0.1", "127.0.0.1", false); checkHostInfoResolution("127.0.0.1:93493", "127.0.0.1", false); @@ -122,7 +127,8 @@ class IpUtilTest { /** * Tests create http uri ipv4 and ipv6 */ - @Test void testCreateHttpUri() { + @Test + void testCreateHttpUri() { final String ipv4 = "10.99.99.1"; URI httpUri = IpUtil.createHttpUri(ipv4); assertHttpUri(ipv4, httpUri); @@ -139,7 +145,8 @@ class IpUtilTest { /** * Tests create amqp uri ipv4 and ipv6 */ - @Test void testCreateAmqpUri() { + @Test + void testCreateAmqpUri() { final String ipv4 = "10.99.99.1"; URI amqpUri = IpUtil.createAmqpUri(ipv4, "path"); assertAmqpUri(ipv4, amqpUri); @@ -167,7 +174,8 @@ class IpUtilTest { /** * Tests create invalid uri */ - @Test void testCreateInvalidUri() { + @Test + void testCreateInvalidUri() { final String host = "10.99.99.1"; final URI testUri = IpUtil.createUri("test", host);