Remove allure (phase2) (#2483)

Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2025-06-20 15:51:06 +03:00
committed by GitHub
parent 39593fc6b6
commit cb7f1107fe
406 changed files with 6993 additions and 5863 deletions

1
.gitignore vendored
View File

@@ -5,7 +5,6 @@ tmp
.classpath .classpath
target target
!hawkbit-rest/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/target !hawkbit-rest/hawkbit-mgmt-api/src/main/java/org/eclipse/hawkbit/mgmt/json/model/target
.allure
.vscode .vscode
.springbeans .springbeans
.metadata .metadata

View File

@@ -42,15 +42,13 @@ So we kindly ask contributors:
### Test documentation ### Test documentation
Please document the test cases that you contribute by means of [Allure](https://docs.qameta.io/allure/) annotations and You could document the test cases using the following format:
proper test method naming.
All test classes are documented with [Allure's](https://docs.qameta.io/allure/#_behaviours_mapping) **@Feature** and *
*@Story** annotations in the following format:
```java ```java
@Feature("TEST_TYPE - HAWKBIT_COMPONENT") /**
@Story("Test class description") * Feature: TEST_TYPE - HAWKBIT_COMPONENT<br/>
* Story: Test class description
*/
``` ```
Test types are: Test types are:
@@ -69,14 +67,6 @@ Examples for hawkBit components:
* Repository * Repository
* Security * Security
```java
@Feature("Component Tests - Management API")
@Story("Distribution Set Type Resource")
```
In addition all test method's name describes in **camel case** what the test is all about and has in addition a long
description in Allures **@Description** annotation.
## Legal considerations for your contribution ## Legal considerations for your contribution
Before your contribution can be accepted by the project team contributors must Before your contribution can be accepted by the project team contributors must

View File

@@ -11,27 +11,28 @@ package org.eclipse.hawkbit.artifact.repository.urlhandler;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
import io.qameta.allure.Story;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@Feature("Unit Tests - Artifact URL Handler") /**
@Story("Base62 Utility tests") * Feature: Unit Tests - Artifact URL Handler<br/>
* Story: Base62 Utility tests
*/
class Base62UtilTest { class Base62UtilTest {
@Test /**
@Description("Convert Base10 numbers to Base62 ASCII strings.") * Convert Base10 numbers to Base62 ASCII strings.
void fromBase10() { */
@Test void fromBase10() {
assertThat(Base62Util.fromBase10(0L)).isEqualTo("0"); assertThat(Base62Util.fromBase10(0L)).isEqualTo("0");
assertThat(Base62Util.fromBase10(11L)).isEqualTo("B"); assertThat(Base62Util.fromBase10(11L)).isEqualTo("B");
assertThat(Base62Util.fromBase10(36L)).isEqualTo("a"); assertThat(Base62Util.fromBase10(36L)).isEqualTo("a");
assertThat(Base62Util.fromBase10(999L)).isEqualTo("G7"); assertThat(Base62Util.fromBase10(999L)).isEqualTo("G7");
} }
@Test /**
@Description("Convert Base62 ASCII strings to Base10 numbers.") * Convert Base62 ASCII strings to Base10 numbers.
void toBase10() { */
@Test void toBase10() {
assertThat(Base62Util.toBase10("0")).isZero(); assertThat(Base62Util.toBase10("0")).isZero();
assertThat(Base62Util.toBase10("B")).isEqualTo(11); assertThat(Base62Util.toBase10("B")).isEqualTo(11);
assertThat(Base62Util.toBase10("a")).isEqualTo(36L); assertThat(Base62Util.toBase10("a")).isEqualTo(36L);

View File

@@ -15,9 +15,6 @@ import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.util.List; import java.util.List;
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
import io.qameta.allure.Story;
import org.eclipse.hawkbit.artifact.repository.urlhandler.ArtifactUrlHandlerProperties.UrlProtocol; import org.eclipse.hawkbit.artifact.repository.urlhandler.ArtifactUrlHandlerProperties.UrlProtocol;
import org.eclipse.hawkbit.artifact.repository.urlhandler.URLPlaceholder.SoftwareData; import org.eclipse.hawkbit.artifact.repository.urlhandler.URLPlaceholder.SoftwareData;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
@@ -27,9 +24,10 @@ import org.mockito.junit.jupiter.MockitoExtension;
/** /**
* Tests for creating urls to download artifacts. * Tests for creating urls to download artifacts.
* <p/>
* Feature: Unit Tests - Artifact URL Handler<br/>
* Story: Test to generate the artifact download URL
*/ */
@Feature("Unit Tests - Artifact URL Handler")
@Story("Test to generate the artifact download URL")
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
class PropertyBasedArtifactUrlHandlerTest { class PropertyBasedArtifactUrlHandlerTest {
@@ -61,9 +59,10 @@ class PropertyBasedArtifactUrlHandlerTest {
urlHandlerUnderTest = new PropertyBasedArtifactUrlHandler(properties, ""); urlHandlerUnderTest = new PropertyBasedArtifactUrlHandler(properties, "");
} }
@Test /**
@Description("Tests the generation of http download url.") * Tests the generation of http download url.
void urlGenerationWithDefaultConfiguration() { */
@Test void urlGenerationWithDefaultConfiguration() {
properties.getProtocols().put("download-http", new UrlProtocol()); properties.getProtocols().put("download-http", new UrlProtocol());
final List<ArtifactUrl> ddiUrls = urlHandlerUnderTest.getUrls(placeHolder, ApiType.DDI); final List<ArtifactUrl> ddiUrls = urlHandlerUnderTest.getUrls(placeHolder, ApiType.DDI);
@@ -75,9 +74,10 @@ class PropertyBasedArtifactUrlHandlerTest {
.isEqualTo(urlHandlerUnderTest.getUrls(placeHolder, ApiType.DMF)); .isEqualTo(urlHandlerUnderTest.getUrls(placeHolder, ApiType.DMF));
} }
@Test /**
@Description("Tests the generation of custom download url with a CoAP example that supports DMF only.") * Tests the generation of custom download url with a CoAP example that supports DMF only.
void urlGenerationWithCustomConfiguration() { */
@Test void urlGenerationWithCustomConfiguration() {
final UrlProtocol proto = new UrlProtocol(); final UrlProtocol proto = new UrlProtocol();
proto.setIp("127.0.0.1"); proto.setIp("127.0.0.1");
proto.setPort(5683); proto.setPort(5683);
@@ -94,9 +94,10 @@ class PropertyBasedArtifactUrlHandlerTest {
"coap://127.0.0.1:5683/fw/" + TENANT + "/" + CONTROLLER_ID + "/sha1/" + SHA1HASH)); "coap://127.0.0.1:5683/fw/" + TENANT + "/" + CONTROLLER_ID + "/sha1/" + SHA1HASH));
} }
@Test /**
@Description("Tests the generation of custom download url using Base62 references with a CoAP example that supports DMF only.") * Tests the generation of custom download url using Base62 references with a CoAP example that supports DMF only.
void urlGenerationWithCustomShortConfiguration() { */
@Test void urlGenerationWithCustomShortConfiguration() {
final UrlProtocol proto = new UrlProtocol(); final UrlProtocol proto = new UrlProtocol();
proto.setIp("127.0.0.1"); proto.setIp("127.0.0.1");
proto.setPort(5683); proto.setPort(5683);
@@ -113,9 +114,10 @@ class PropertyBasedArtifactUrlHandlerTest {
TEST_PROTO + "://127.0.0.1:5683/fws/" + TENANT + "/" + TARGET_ID_BASE62 + "/" + ARTIFACT_ID_BASE62)); TEST_PROTO + "://127.0.0.1:5683/fws/" + TENANT + "/" + TARGET_ID_BASE62 + "/" + ARTIFACT_ID_BASE62));
} }
@Test /**
@Description("Verifies that the full qualified host of the statically defined hostname is replaced with the host of the request.") * Verifies that the full qualified host of the statically defined hostname is replaced with the host of the request.
void urlGenerationWithHostFromRequest() throws URISyntaxException { */
@Test void urlGenerationWithHostFromRequest() throws URISyntaxException {
final String testHost = "ddi.host.com"; final String testHost = "ddi.host.com";
final UrlProtocol proto = new UrlProtocol(); final UrlProtocol proto = new UrlProtocol();
@@ -133,9 +135,10 @@ class PropertyBasedArtifactUrlHandlerTest {
TEST_PROTO + "://" + testHost + ":5683/fws/" + TENANT + "/" + TARGET_ID_BASE62 + "/" + ARTIFACT_ID_BASE62)); TEST_PROTO + "://" + testHost + ":5683/fws/" + TENANT + "/" + TARGET_ID_BASE62 + "/" + ARTIFACT_ID_BASE62));
} }
@Test /**
@Description("Verifies that the protocol of the statically defined hostname is replaced with the protocol of the request.") * Verifies that the protocol of the statically defined hostname is replaced with the protocol of the request.
void urlGenerationWithProtocolFromRequest() throws URISyntaxException { */
@Test void urlGenerationWithProtocolFromRequest() throws URISyntaxException {
final String testHost = "ddi.host.com"; final String testHost = "ddi.host.com";
final UrlProtocol proto = new UrlProtocol(); final UrlProtocol proto = new UrlProtocol();
@@ -148,9 +151,10 @@ class PropertyBasedArtifactUrlHandlerTest {
"https://localhost:8080/fws/" + TENANT + "/" + TARGET_ID_BASE62 + "/" + ARTIFACT_ID_BASE62)); "https://localhost:8080/fws/" + TENANT + "/" + TARGET_ID_BASE62 + "/" + ARTIFACT_ID_BASE62));
} }
@Test /**
@Description("Verifies that the port of the statically defined hostname is replaced with the port of the request.") * Verifies that the port of the statically defined hostname is replaced with the port of the request.
void urlGenerationWithPortFromRequest() throws URISyntaxException { */
@Test void urlGenerationWithPortFromRequest() throws URISyntaxException {
final UrlProtocol proto = new UrlProtocol(); final UrlProtocol proto = new UrlProtocol();
proto.setRef("{protocol}://{hostname}:{portRequest}/{tenant}/controller/v1/{controllerId}/softwaremodules/{softwareModuleId}/artifacts/{artifactFileName}"); proto.setRef("{protocol}://{hostname}:{portRequest}/{tenant}/controller/v1/{controllerId}/softwaremodules/{softwareModuleId}/artifacts/{artifactFileName}");
@@ -169,9 +173,10 @@ class PropertyBasedArtifactUrlHandlerTest {
CONTROLLER_ID + "/softwaremodules/" + SOFTWARE_MODULE_ID + "/artifacts/" + FILENAME_ENCODE)); CONTROLLER_ID + "/softwaremodules/" + SOFTWARE_MODULE_ID + "/artifacts/" + FILENAME_ENCODE));
} }
@Test /**
@Description("Verifies that if default protocol port in request is used then url is returned without port") * Verifies that if default protocol port in request is used then url is returned without port
void urlGenerationWithPortFromRequestForHttps() throws URISyntaxException { */
@Test void urlGenerationWithPortFromRequestForHttps() throws URISyntaxException {
final String protocol = "https"; final String protocol = "https";
final UrlProtocol proto = new UrlProtocol(); final UrlProtocol proto = new UrlProtocol();
proto.setRef("{protocolRequest}://{hostnameRequest}:{portRequest}/{tenant}/controller/v1/{controllerId}/softwaremodules/{softwareModuleId}/artifacts/{artifactFileName}"); proto.setRef("{protocolRequest}://{hostnameRequest}:{portRequest}/{tenant}/controller/v1/{controllerId}/softwaremodules/{softwareModuleId}/artifacts/{artifactFileName}");
@@ -187,9 +192,10 @@ class PropertyBasedArtifactUrlHandlerTest {
} }
@Test /**
@Description("Verifies that the domain of the statically defined hostname is replaced with the domain of the request.") * Verifies that the domain of the statically defined hostname is replaced with the domain of the request.
void urlGenerationWithDomainFromRequest() throws URISyntaxException { */
@Test void urlGenerationWithDomainFromRequest() throws URISyntaxException {
final UrlProtocol proto = new UrlProtocol(); final UrlProtocol proto = new UrlProtocol();
proto.setHostname("host.bumlux.net"); proto.setHostname("host.bumlux.net");
proto.setRef("{protocol}://{domainRequest}/{tenant}/controller/v1/{controllerId}/softwaremodules/{softwareModuleId}/artifacts/{artifactFileName}"); proto.setRef("{protocol}://{domainRequest}/{tenant}/controller/v1/{controllerId}/softwaremodules/{softwareModuleId}/artifacts/{artifactFileName}");

View File

@@ -11,13 +11,12 @@ package org.eclipse.hawkbit.artifact.repository.urlhandler;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
import io.qameta.allure.Story;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@Feature("Unit Tests - Artifact URL Handler") /**
@Story("URL placeholder tests") * Feature: Unit Tests - Artifact URL Handler<br/>
* Story: URL placeholder tests
*/
class URLPlaceholderTest { class URLPlaceholderTest {
private final URLPlaceholder.SoftwareData softwareData; private final URLPlaceholder.SoftwareData softwareData;
@@ -28,9 +27,10 @@ class URLPlaceholderTest {
this.placeholder = new URLPlaceholder("SuperCorp", 123L, "Super-1", 1L, softwareData); this.placeholder = new URLPlaceholder("SuperCorp", 123L, "Super-1", 1L, softwareData);
} }
@Test /**
@Description("Same object should be equal") * Same object should be equal
// 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 // Need to test the equals method and need to bypass magic logic in utility classes
@SuppressWarnings({ "squid:S5838" }) @SuppressWarnings({ "squid:S5838" })
void sameObjectShouldBeEqual() { void sameObjectShouldBeEqual() {
@@ -38,9 +38,10 @@ class URLPlaceholderTest {
assertThat(placeholder.equals(placeholder)).isTrue(); assertThat(placeholder.equals(placeholder)).isTrue();
} }
@Test /**
@Description("Different object should not be equal") * Different object should not be equal
@SuppressWarnings({ "squid:S5838" }) */
@Test @SuppressWarnings({ "squid:S5838" })
void differentObjectShouldNotBeEqual() { void differentObjectShouldNotBeEqual() {
final URLPlaceholder.SoftwareData softwareData2 = new URLPlaceholder.SoftwareData(2L, "file.txt", 123L, "someHash123"); final URLPlaceholder.SoftwareData softwareData2 = new URLPlaceholder.SoftwareData(2L, "file.txt", 123L, "someHash123");
final URLPlaceholder placeholder2 = new URLPlaceholder("SuperCorp", 123L, "Super-2", 2L, softwareData2); final URLPlaceholder placeholder2 = new URLPlaceholder("SuperCorp", 123L, "Super-2", 2L, softwareData2);
@@ -53,18 +54,20 @@ class URLPlaceholderTest {
assertThat(placeholder.equals(placeholderWithOtherSoftwareData)).isFalse(); assertThat(placeholder.equals(placeholderWithOtherSoftwareData)).isFalse();
} }
@Test /**
@Description("Different objects with same properties should be equal") * Different objects with same properties should be equal
void differentObjectsWithSamePropertiesShouldBeEqual() { */
@Test void differentObjectsWithSamePropertiesShouldBeEqual() {
final URLPlaceholder placeholderWithSameProperties = new URLPlaceholder(placeholder.getTenant(), placeholder.getTenantId(), final URLPlaceholder placeholderWithSameProperties = new URLPlaceholder(placeholder.getTenant(), placeholder.getTenantId(),
placeholder.getControllerId(), placeholder.getTargetId(), softwareData); placeholder.getControllerId(), placeholder.getTargetId(), softwareData);
assertThat(placeholder).isEqualTo(placeholderWithSameProperties); assertThat(placeholder).isEqualTo(placeholderWithSameProperties);
assertThat(placeholderWithSameProperties).isEqualTo(placeholder); assertThat(placeholderWithSameProperties).isEqualTo(placeholder);
} }
@Test /**
@Description("Should not equal null") * Should not equal null
// 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 // the corresponding dedicated assertion
// Need to test the equals method and need to bypass magic logic in utility // Need to test the equals method and need to bypass magic logic in utility
// classes // classes
@@ -74,9 +77,10 @@ class URLPlaceholderTest {
assertThat(softwareData.equals(null)).isFalse(); assertThat(softwareData.equals(null)).isFalse();
} }
@Test /**
@Description("HashCode should not change") * HashCode should not change
void hashCodeShouldNotChange() { */
@Test void hashCodeShouldNotChange() {
final URLPlaceholder placeholderWithSameProperties = new URLPlaceholder(placeholder.getTenant(), placeholder.getTenantId(), final URLPlaceholder placeholderWithSameProperties = new URLPlaceholder(placeholder.getTenant(), placeholder.getTenantId(),
placeholder.getControllerId(), placeholder.getTargetId(), softwareData); placeholder.getControllerId(), placeholder.getTargetId(), softwareData);
assertThat(placeholder).hasSameHashCodeAs(placeholder).hasSameHashCodeAs(placeholderWithSameProperties); assertThat(placeholder).hasSameHashCodeAs(placeholder).hasSameHashCodeAs(placeholderWithSameProperties);

View File

@@ -16,9 +16,6 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.Random; import java.util.Random;
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
import io.qameta.allure.Story;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
@@ -29,8 +26,10 @@ import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@Slf4j @Slf4j
@Feature("Unit Tests - Artifact File System Repository") /**
@Story("Test storing artifact binaries in the file-system") * Feature: Unit Tests - Artifact File System Repository<br/>
* Story: Test storing artifact binaries in the file-system
*/
class ArtifactFilesystemRepositoryTest { class ArtifactFilesystemRepositoryTest {
private static final String TENANT = "test_tenant"; private static final String TENANT = "test_tenant";
@@ -57,9 +56,10 @@ class ArtifactFilesystemRepositoryTest {
} }
} }
@Test /**
@Description("Verifies that an artifact can be successfully stored in the file-system repository") * Verifies that an artifact can be successfully stored in the file-system repository
void storeSuccessfully() throws IOException { */
@Test void storeSuccessfully() throws IOException {
final byte[] fileContent = randomBytes(); final byte[] fileContent = randomBytes();
final AbstractDbArtifact artifact = storeRandomArtifact(fileContent); final AbstractDbArtifact artifact = storeRandomArtifact(fileContent);
@@ -68,36 +68,40 @@ class ArtifactFilesystemRepositoryTest {
assertThat(readContent).isEqualTo(fileContent); assertThat(readContent).isEqualTo(fileContent);
} }
@Test /**
@Description("Verifies that an artifact can be successfully stored in the file-system repository") * Verifies that an artifact can be successfully stored in the file-system repository
void getStoredArtifactBasedOnSHA1Hash() throws IOException { */
@Test void getStoredArtifactBasedOnSHA1Hash() throws IOException {
final byte[] fileContent = randomBytes(); final byte[] fileContent = randomBytes();
final AbstractDbArtifact artifact = storeRandomArtifact(fileContent); final AbstractDbArtifact artifact = storeRandomArtifact(fileContent);
assertThat(artifactFilesystemRepository.getArtifactBySha1(TENANT, artifact.getHashes().getSha1())).isNotNull(); assertThat(artifactFilesystemRepository.getArtifactBySha1(TENANT, artifact.getHashes().getSha1())).isNotNull();
} }
@Test /**
@Description("Verifies that an artifact can be deleted in the file-system repository") * Verifies that an artifact can be deleted in the file-system repository
void deleteStoredArtifactBySHA1Hash() throws IOException { */
@Test void deleteStoredArtifactBySHA1Hash() throws IOException {
final AbstractDbArtifact artifact = storeRandomArtifact(randomBytes()); final AbstractDbArtifact artifact = storeRandomArtifact(randomBytes());
artifactFilesystemRepository.deleteBySha1(TENANT, artifact.getHashes().getSha1()); artifactFilesystemRepository.deleteBySha1(TENANT, artifact.getHashes().getSha1());
assertThat(artifactFilesystemRepository.getArtifactBySha1(TENANT, artifact.getHashes().getSha1())).isNull(); assertThat(artifactFilesystemRepository.getArtifactBySha1(TENANT, artifact.getHashes().getSha1())).isNull();
} }
@Test /**
@Description("Verifies that all artifacts of a tenant can be deleted in the file-system repository") * Verifies that all artifacts of a tenant can be deleted in the file-system repository
void deleteStoredArtifactOfTenant() throws IOException { */
@Test void deleteStoredArtifactOfTenant() throws IOException {
final AbstractDbArtifact artifact = storeRandomArtifact(randomBytes()); final AbstractDbArtifact artifact = storeRandomArtifact(randomBytes());
artifactFilesystemRepository.deleteByTenant(TENANT); artifactFilesystemRepository.deleteByTenant(TENANT);
assertThat(artifactFilesystemRepository.getArtifactBySha1(TENANT, artifact.getHashes().getSha1())).isNull(); assertThat(artifactFilesystemRepository.getArtifactBySha1(TENANT, artifact.getHashes().getSha1())).isNull();
} }
@Test /**
@Description("Verifies that an artifact which does not exists is deleted quietly in the file-system repository") * Verifies that an artifact which does not exists is deleted quietly in the file-system repository
void deleteArtifactWhichDoesNotExistsBySHA1HashWithoutException() throws IOException { */
@Test void deleteArtifactWhichDoesNotExistsBySHA1HashWithoutException() throws IOException {
try { try {
artifactFilesystemRepository.deleteBySha1(TENANT, "sha1HashWhichDoesNotExists"); artifactFilesystemRepository.deleteBySha1(TENANT, "sha1HashWhichDoesNotExists");
} catch (final Exception e) { } catch (final Exception e) {

View File

@@ -16,20 +16,20 @@ import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
import io.qameta.allure.Story;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.eclipse.hawkbit.artifact.repository.model.DbArtifactHash; import org.eclipse.hawkbit.artifact.repository.model.DbArtifactHash;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@Feature("Unit Tests - Artifact File System Repository") /**
@Story("Test storing artifact binaries in the file-system") * Feature: Unit Tests - Artifact File System Repository<br/>
* Story: Test storing artifact binaries in the file-system
*/
class ArtifactFilesystemTest { class ArtifactFilesystemTest {
@Test /**
@Description("Verifies that an exception is thrown on opening an InputStream when file does not exists") * Verifies that an exception is thrown on opening an InputStream when file does not exists
void getInputStreamOfNonExistingFileThrowsException() { */
@Test void getInputStreamOfNonExistingFileThrowsException() {
final File file = new File("fileWhichTotalDoesNotExists"); final File file = new File("fileWhichTotalDoesNotExists");
final ArtifactFilesystem underTest = new ArtifactFilesystem( final ArtifactFilesystem underTest = new ArtifactFilesystem(
file, "fileWhichTotalDoesNotExists", file, "fileWhichTotalDoesNotExists",
@@ -39,9 +39,10 @@ class ArtifactFilesystemTest {
.hasCauseInstanceOf(FileNotFoundException.class); .hasCauseInstanceOf(FileNotFoundException.class);
} }
@Test /**
@Description("Verifies that an InputStream can be opened if file exists") * Verifies that an InputStream can be opened if file exists
void getInputStreamOfExistingFile() throws IOException { */
@Test void getInputStreamOfExistingFile() throws IOException {
final ArtifactFilesystem underTest = new ArtifactFilesystem( final ArtifactFilesystem underTest = new ArtifactFilesystem(
AbstractArtifactRepository.createTempFile(false), ArtifactFilesystemTest.class.getSimpleName(), AbstractArtifactRepository.createTempFile(false), ArtifactFilesystemTest.class.getSimpleName(),
new DbArtifactHash("1", "2", "3"), 0L, null); new DbArtifactHash("1", "2", "3"), 0L, null);

View File

@@ -1 +0,0 @@
{"uuid":"06b4b435-29d7-4dd0-bcb6-b2ed361c31e2","name":"FileNameFieldsTest","children":["d701f914-7aff-400e-8230-a00f1339827c"],"befores":[],"afters":[],"start":1750415118826,"stop":1750415119036}

View File

@@ -1 +0,0 @@
{"uuid":"1e4882c6-e0fe-4cc1-ab20-30344dfd7f6c","name":"FileNameFieldsTest","children":["597ffb13-728c-4020-9afd-e776432afb0b"],"befores":[],"afters":[],"start":1750414146349,"stop":1750414146558}

View File

@@ -1 +0,0 @@
{"uuid":"1eb43d00-6013-4be4-8227-85e47d019d3c","name":"repositoryManagementMethodsArePreAuthorizedAnnotated()","children":["43d8b58c-e102-4ac5-9971-edfe8accda95"],"befores":[],"afters":[],"start":1750415256630,"stop":1750415256926}

View File

@@ -1 +0,0 @@
{"uuid":"1f78aaf3-6314-4839-8931-32fd25ee40a2","historyId":"fa14928b1c8c4668de3f864412a0b0ca","testCaseId":"[engine:junit-jupiter]/[class:org.eclipse.hawkbit.repository.FileNameFieldsTest]/[method:repositoryManagementMethodsArePreAuthorizedAnnotated()]","testCaseName":"repositoryManagementMethodsArePreAuthorizedAnnotated()","fullName":"org.eclipse.hawkbit.repository.FileNameFieldsTest.repositoryManagementMethodsArePreAuthorizedAnnotated","labels":[{"name":"junit.platform.uniqueid","value":"[engine:junit-jupiter]/[class:org.eclipse.hawkbit.repository.FileNameFieldsTest]/[method:repositoryManagementMethodsArePreAuthorizedAnnotated()]"},{"name":"host","value":"SF3-C-000FP"},{"name":"thread","value":"26175@SF3-C-000FP.main(1)"},{"name":"framework","value":"junit-platform"},{"name":"language","value":"java"},{"name":"package","value":"org.eclipse.hawkbit.repository.FileNameFieldsTest"},{"name":"testClass","value":"org.eclipse.hawkbit.repository.FileNameFieldsTest"},{"name":"testMethod","value":"repositoryManagementMethodsArePreAuthorizedAnnotated"},{"name":"suite","value":"org.eclipse.hawkbit.repository.FileNameFieldsTest"}],"links":[],"name":"repositoryManagementMethodsArePreAuthorizedAnnotated()","status":"passed","stage":"finished","description":"Verifies that fields classes are correctly implemented","steps":[],"attachments":[],"parameters":[],"start":1750414575060,"stop":1750414575211}

View File

@@ -1 +0,0 @@
{"uuid":"20e2a037-9c51-49d4-87a2-83439f64c3f5","name":"repositoryManagementMethodsArePreAuthorizedAnnotated()","children":["913eecd1-1800-4cd4-9c59-5094f1221293"],"befores":[],"afters":[],"start":1750414016526,"stop":1750414016717}

View File

@@ -1 +0,0 @@
{"uuid":"236f34e7-42a3-4022-a827-d28eee4739bd","name":"FileNameFieldsTest","children":["bdfb9b69-24d2-4eff-ba3c-1ef30b0519fd"],"befores":[],"afters":[],"start":1750414723330,"stop":1750414723507}

View File

@@ -1 +0,0 @@
{"uuid":"259e6e51-7aaf-4ae2-8eb4-0ccc2876d81f","name":"repositoryManagementMethodsArePreAuthorizedAnnotated()","children":["e82046fe-fd36-4dc0-981e-95e743b8d086"],"befores":[],"afters":[],"start":1750414349120,"stop":1750414349298}

View File

@@ -1 +0,0 @@
{"uuid":"26b493b3-066c-4930-a6ab-ffebee1f01c0","name":"repositoryManagementMethodsArePreAuthorizedAnnotated()","children":["3b629131-9a32-4374-b928-137aca4f2f30"],"befores":[],"afters":[],"start":1750414971559,"stop":1750414971740}

View File

@@ -1 +0,0 @@
{"uuid":"299732f9-e387-41ee-9f65-b7071c39dcc3","name":"FileNameFieldsTest","children":["1f78aaf3-6314-4839-8931-32fd25ee40a2"],"befores":[],"afters":[],"start":1750414575036,"stop":1750414575236}

View File

@@ -1 +0,0 @@
{"uuid":"3393d874-79c5-4b30-8098-6be0f22b98b8","name":"repositoryManagementMethodsArePreAuthorizedAnnotated()","children":["c7d19de8-5368-401c-9297-8c6c7bbf830e"],"befores":[],"afters":[],"start":1750415195491,"stop":1750415195674}

View File

@@ -1 +0,0 @@
{"uuid":"34038e21-ccba-4596-92af-8c1856ccc1e2","name":"FileNameFieldsTest","children":["5c548055-7762-4fcb-9795-5aaafe5329e2"],"befores":[],"afters":[],"start":1750414415618,"stop":1750414415801}

View File

@@ -1 +0,0 @@
{"uuid":"369f3516-266b-46ac-a730-c152c6afcf7a","name":"repositoryManagementMethodsArePreAuthorizedAnnotated()","children":["b3d07773-b904-4e05-9b16-bdd986547be7"],"befores":[],"afters":[],"start":1750415892802,"stop":1750415893121}

View File

@@ -1 +0,0 @@
{"uuid":"39f0b93a-754c-4948-8b59-056528a83d1c","name":"FileNameFieldsTest","children":["e82046fe-fd36-4dc0-981e-95e743b8d086"],"befores":[],"afters":[],"start":1750414349111,"stop":1750414349303}

View File

@@ -1 +0,0 @@
{"uuid":"3b629131-9a32-4374-b928-137aca4f2f30","historyId":"fa14928b1c8c4668de3f864412a0b0ca","testCaseId":"[engine:junit-jupiter]/[class:org.eclipse.hawkbit.repository.FileNameFieldsTest]/[method:repositoryManagementMethodsArePreAuthorizedAnnotated()]","testCaseName":"repositoryManagementMethodsArePreAuthorizedAnnotated()","fullName":"org.eclipse.hawkbit.repository.FileNameFieldsTest.repositoryManagementMethodsArePreAuthorizedAnnotated","labels":[{"name":"junit.platform.uniqueid","value":"[engine:junit-jupiter]/[class:org.eclipse.hawkbit.repository.FileNameFieldsTest]/[method:repositoryManagementMethodsArePreAuthorizedAnnotated()]"},{"name":"host","value":"SF3-C-000FP"},{"name":"thread","value":"27866@SF3-C-000FP.main(1)"},{"name":"framework","value":"junit-platform"},{"name":"language","value":"java"},{"name":"package","value":"org.eclipse.hawkbit.repository.FileNameFieldsTest"},{"name":"testClass","value":"org.eclipse.hawkbit.repository.FileNameFieldsTest"},{"name":"testMethod","value":"repositoryManagementMethodsArePreAuthorizedAnnotated"},{"name":"suite","value":"org.eclipse.hawkbit.repository.FileNameFieldsTest"}],"links":[],"name":"repositoryManagementMethodsArePreAuthorizedAnnotated()","status":"passed","stage":"finished","description":"Verifies that fields classes are correctly implemented","steps":[],"attachments":[],"parameters":[],"start":1750414971573,"stop":1750414971721}

View File

@@ -1 +0,0 @@
{"uuid":"3eb09005-eb9f-4349-916e-70229f574807","name":"FileNameFieldsTest","children":["3b629131-9a32-4374-b928-137aca4f2f30"],"befores":[],"afters":[],"start":1750414971551,"stop":1750414971746}

View File

@@ -1 +0,0 @@
{"uuid":"40fbbc60-c9f9-426f-8fc5-597b8d1eccbf","name":"FileNameFieldsTest","children":["43d8b58c-e102-4ac5-9971-edfe8accda95"],"befores":[],"afters":[],"start":1750415256621,"stop":1750415256932}

View File

@@ -1 +0,0 @@
{"uuid":"43d8b58c-e102-4ac5-9971-edfe8accda95","historyId":"fa14928b1c8c4668de3f864412a0b0ca","testCaseId":"[engine:junit-jupiter]/[class:org.eclipse.hawkbit.repository.FileNameFieldsTest]/[method:repositoryManagementMethodsArePreAuthorizedAnnotated()]","testCaseName":"repositoryManagementMethodsArePreAuthorizedAnnotated()","fullName":"org.eclipse.hawkbit.repository.FileNameFieldsTest.repositoryManagementMethodsArePreAuthorizedAnnotated","labels":[{"name":"junit.platform.uniqueid","value":"[engine:junit-jupiter]/[class:org.eclipse.hawkbit.repository.FileNameFieldsTest]/[method:repositoryManagementMethodsArePreAuthorizedAnnotated()]"},{"name":"host","value":"SF3-C-000FP"},{"name":"thread","value":"29124@SF3-C-000FP.main(1)"},{"name":"framework","value":"junit-platform"},{"name":"language","value":"java"},{"name":"package","value":"org.eclipse.hawkbit.repository.FileNameFieldsTest"},{"name":"testClass","value":"org.eclipse.hawkbit.repository.FileNameFieldsTest"},{"name":"testMethod","value":"repositoryManagementMethodsArePreAuthorizedAnnotated"},{"name":"suite","value":"org.eclipse.hawkbit.repository.FileNameFieldsTest"}],"links":[],"name":"repositoryManagementMethodsArePreAuthorizedAnnotated()","status":"passed","stage":"finished","description":"Verifies that fields classes are correctly implemented","steps":[],"attachments":[],"parameters":[],"start":1750415256641,"stop":1750415256888}

View File

@@ -1 +0,0 @@
{"uuid":"4b168869-3277-4726-ad64-e84bd2218c37","name":"FileNameFieldsTest","children":["81317a48-2ebf-44ec-a6ee-7e6d7024e1a2"],"befores":[],"afters":[],"start":1750414464506,"stop":1750414464697}

View File

@@ -1 +0,0 @@
{"uuid":"4d398a49-8f1e-4038-9342-a6270abf50f5","name":"repositoryManagementMethodsArePreAuthorizedAnnotated()","children":["5c548055-7762-4fcb-9795-5aaafe5329e2"],"befores":[],"afters":[],"start":1750414415626,"stop":1750414415795}

View File

@@ -1 +0,0 @@
{"uuid":"597ffb13-728c-4020-9afd-e776432afb0b","historyId":"fa14928b1c8c4668de3f864412a0b0ca","testCaseId":"[engine:junit-jupiter]/[class:org.eclipse.hawkbit.repository.FileNameFieldsTest]/[method:repositoryManagementMethodsArePreAuthorizedAnnotated()]","testCaseName":"repositoryManagementMethodsArePreAuthorizedAnnotated()","fullName":"org.eclipse.hawkbit.repository.FileNameFieldsTest.repositoryManagementMethodsArePreAuthorizedAnnotated","labels":[{"name":"junit.platform.uniqueid","value":"[engine:junit-jupiter]/[class:org.eclipse.hawkbit.repository.FileNameFieldsTest]/[method:repositoryManagementMethodsArePreAuthorizedAnnotated()]"},{"name":"host","value":"SF3-C-000FP"},{"name":"thread","value":"24408@SF3-C-000FP.main(1)"},{"name":"framework","value":"junit-platform"},{"name":"language","value":"java"},{"name":"package","value":"org.eclipse.hawkbit.repository.FileNameFieldsTest"},{"name":"testClass","value":"org.eclipse.hawkbit.repository.FileNameFieldsTest"},{"name":"testMethod","value":"repositoryManagementMethodsArePreAuthorizedAnnotated"},{"name":"suite","value":"org.eclipse.hawkbit.repository.FileNameFieldsTest"}],"links":[],"name":"repositoryManagementMethodsArePreAuthorizedAnnotated()","status":"passed","stage":"finished","description":"Verifies that fields classes are correctly implemented","steps":[],"attachments":[],"parameters":[],"start":1750414146373,"stop":1750414146533}

View File

@@ -1 +0,0 @@
{"uuid":"5b69aea3-f8ca-4017-8db8-f93cec3bab1a","name":"FileNameFieldsTest","children":["c7d19de8-5368-401c-9297-8c6c7bbf830e"],"befores":[],"afters":[],"start":1750415195482,"stop":1750415195679}

View File

@@ -1 +0,0 @@
{"uuid":"5c548055-7762-4fcb-9795-5aaafe5329e2","historyId":"fa14928b1c8c4668de3f864412a0b0ca","testCaseId":"[engine:junit-jupiter]/[class:org.eclipse.hawkbit.repository.FileNameFieldsTest]/[method:repositoryManagementMethodsArePreAuthorizedAnnotated()]","testCaseName":"repositoryManagementMethodsArePreAuthorizedAnnotated()","fullName":"org.eclipse.hawkbit.repository.FileNameFieldsTest.repositoryManagementMethodsArePreAuthorizedAnnotated","labels":[{"name":"junit.platform.uniqueid","value":"[engine:junit-jupiter]/[class:org.eclipse.hawkbit.repository.FileNameFieldsTest]/[method:repositoryManagementMethodsArePreAuthorizedAnnotated()]"},{"name":"host","value":"SF3-C-000FP"},{"name":"thread","value":"25467@SF3-C-000FP.main(1)"},{"name":"framework","value":"junit-platform"},{"name":"language","value":"java"},{"name":"package","value":"org.eclipse.hawkbit.repository.FileNameFieldsTest"},{"name":"testClass","value":"org.eclipse.hawkbit.repository.FileNameFieldsTest"},{"name":"testMethod","value":"repositoryManagementMethodsArePreAuthorizedAnnotated"},{"name":"suite","value":"org.eclipse.hawkbit.repository.FileNameFieldsTest"}],"links":[],"name":"repositoryManagementMethodsArePreAuthorizedAnnotated()","status":"passed","stage":"finished","description":"Verifies that fields classes are correctly implemented","steps":[],"attachments":[],"parameters":[],"start":1750414415639,"stop":1750414415776}

View File

@@ -1 +0,0 @@
{"uuid":"68e6b06c-dfd1-48bf-b383-f83cffa9411e","name":"repositoryManagementMethodsArePreAuthorizedAnnotated()","children":["81317a48-2ebf-44ec-a6ee-7e6d7024e1a2"],"befores":[],"afters":[],"start":1750414464515,"stop":1750414464691}

View File

@@ -1 +0,0 @@
{"uuid":"74aad84d-bfdd-4c01-aa36-f68b1c09a2fd","name":"repositoryManagementMethodsArePreAuthorizedAnnotated()","children":["1f78aaf3-6314-4839-8931-32fd25ee40a2"],"befores":[],"afters":[],"start":1750414575045,"stop":1750414575231}

View File

@@ -1 +0,0 @@
{"uuid":"81317a48-2ebf-44ec-a6ee-7e6d7024e1a2","historyId":"fa14928b1c8c4668de3f864412a0b0ca","testCaseId":"[engine:junit-jupiter]/[class:org.eclipse.hawkbit.repository.FileNameFieldsTest]/[method:repositoryManagementMethodsArePreAuthorizedAnnotated()]","testCaseName":"repositoryManagementMethodsArePreAuthorizedAnnotated()","fullName":"org.eclipse.hawkbit.repository.FileNameFieldsTest.repositoryManagementMethodsArePreAuthorizedAnnotated","labels":[{"name":"junit.platform.uniqueid","value":"[engine:junit-jupiter]/[class:org.eclipse.hawkbit.repository.FileNameFieldsTest]/[method:repositoryManagementMethodsArePreAuthorizedAnnotated()]"},{"name":"host","value":"SF3-C-000FP"},{"name":"thread","value":"25725@SF3-C-000FP.main(1)"},{"name":"framework","value":"junit-platform"},{"name":"language","value":"java"},{"name":"package","value":"org.eclipse.hawkbit.repository.FileNameFieldsTest"},{"name":"testClass","value":"org.eclipse.hawkbit.repository.FileNameFieldsTest"},{"name":"testMethod","value":"repositoryManagementMethodsArePreAuthorizedAnnotated"},{"name":"suite","value":"org.eclipse.hawkbit.repository.FileNameFieldsTest"}],"links":[],"name":"repositoryManagementMethodsArePreAuthorizedAnnotated()","status":"passed","stage":"finished","description":"Verifies that fields classes are correctly implemented","steps":[],"attachments":[],"parameters":[],"start":1750414464529,"stop":1750414464672}

View File

@@ -1 +0,0 @@
{"uuid":"85b10456-f9c4-476e-940e-1a4d6ae96684","name":"repositoryManagementMethodsArePreAuthorizedAnnotated()","children":["597ffb13-728c-4020-9afd-e776432afb0b"],"befores":[],"afters":[],"start":1750414146356,"stop":1750414146552}

View File

@@ -1 +0,0 @@
{"uuid":"8ca7e456-37f2-4cae-a692-ccdda74fb1d1","name":"repositoryManagementMethodsArePreAuthorizedAnnotated()","children":["bdfb9b69-24d2-4eff-ba3c-1ef30b0519fd"],"befores":[],"afters":[],"start":1750414723338,"stop":1750414723502}

View File

@@ -1 +0,0 @@
{"uuid":"913eecd1-1800-4cd4-9c59-5094f1221293","historyId":"fa14928b1c8c4668de3f864412a0b0ca","testCaseId":"[engine:junit-jupiter]/[class:org.eclipse.hawkbit.repository.FileNameFieldsTest]/[method:repositoryManagementMethodsArePreAuthorizedAnnotated()]","testCaseName":"repositoryManagementMethodsArePreAuthorizedAnnotated()","fullName":"org.eclipse.hawkbit.repository.FileNameFieldsTest.repositoryManagementMethodsArePreAuthorizedAnnotated","labels":[{"name":"junit.platform.uniqueid","value":"[engine:junit-jupiter]/[class:org.eclipse.hawkbit.repository.FileNameFieldsTest]/[method:repositoryManagementMethodsArePreAuthorizedAnnotated()]"},{"name":"host","value":"SF3-C-000FP"},{"name":"thread","value":"23930@SF3-C-000FP.main(1)"},{"name":"framework","value":"junit-platform"},{"name":"language","value":"java"},{"name":"package","value":"org.eclipse.hawkbit.repository.FileNameFieldsTest"},{"name":"testClass","value":"org.eclipse.hawkbit.repository.FileNameFieldsTest"},{"name":"testMethod","value":"repositoryManagementMethodsArePreAuthorizedAnnotated"},{"name":"suite","value":"org.eclipse.hawkbit.repository.FileNameFieldsTest"}],"links":[],"name":"repositoryManagementMethodsArePreAuthorizedAnnotated()","status":"passed","stage":"finished","description":"Verifies that fields classes are correctly implemented","steps":[],"attachments":[],"parameters":[],"start":1750414016543,"stop":1750414016696}

View File

@@ -1 +0,0 @@
{"uuid":"92653284-976b-412e-a112-7e96c3901dee","name":"repositoryManagementMethodsArePreAuthorizedAnnotated()","children":["9829198c-640d-4164-9557-cad7ac0832da"],"befores":[],"afters":[],"start":1750415144356,"stop":1750415144551}

View File

@@ -1 +0,0 @@
{"uuid":"93fedcb9-ba6d-4b94-bb29-0e219c3f8604","name":"FileNameFieldsTest","children":["f8b39d47-6a59-4f21-a52c-7c190cb1dfab"],"befores":[],"afters":[],"start":1750414804626,"stop":1750414804826}

View File

@@ -1 +0,0 @@
{"uuid":"9829198c-640d-4164-9557-cad7ac0832da","historyId":"fa14928b1c8c4668de3f864412a0b0ca","testCaseId":"[engine:junit-jupiter]/[class:org.eclipse.hawkbit.repository.FileNameFieldsTest]/[method:repositoryManagementMethodsArePreAuthorizedAnnotated()]","testCaseName":"repositoryManagementMethodsArePreAuthorizedAnnotated()","fullName":"org.eclipse.hawkbit.repository.FileNameFieldsTest.repositoryManagementMethodsArePreAuthorizedAnnotated","labels":[{"name":"junit.platform.uniqueid","value":"[engine:junit-jupiter]/[class:org.eclipse.hawkbit.repository.FileNameFieldsTest]/[method:repositoryManagementMethodsArePreAuthorizedAnnotated()]"},{"name":"host","value":"SF3-C-000FP"},{"name":"thread","value":"28593@SF3-C-000FP.main(1)"},{"name":"framework","value":"junit-platform"},{"name":"language","value":"java"},{"name":"package","value":"org.eclipse.hawkbit.repository.FileNameFieldsTest"},{"name":"testClass","value":"org.eclipse.hawkbit.repository.FileNameFieldsTest"},{"name":"testMethod","value":"repositoryManagementMethodsArePreAuthorizedAnnotated"},{"name":"suite","value":"org.eclipse.hawkbit.repository.FileNameFieldsTest"}],"links":[],"name":"repositoryManagementMethodsArePreAuthorizedAnnotated()","status":"passed","stage":"finished","description":"Verifies that fields classes are correctly implemented","steps":[],"attachments":[],"parameters":[],"start":1750415144374,"stop":1750415144530}

View File

@@ -1 +0,0 @@
{"uuid":"b3d07773-b904-4e05-9b16-bdd986547be7","historyId":"fa14928b1c8c4668de3f864412a0b0ca","testCaseId":"[engine:junit-jupiter]/[class:org.eclipse.hawkbit.repository.FileNameFieldsTest]/[method:repositoryManagementMethodsArePreAuthorizedAnnotated()]","testCaseName":"repositoryManagementMethodsArePreAuthorizedAnnotated()","fullName":"org.eclipse.hawkbit.repository.FileNameFieldsTest.repositoryManagementMethodsArePreAuthorizedAnnotated","labels":[{"name":"junit.platform.uniqueid","value":"[engine:junit-jupiter]/[class:org.eclipse.hawkbit.repository.FileNameFieldsTest]/[method:repositoryManagementMethodsArePreAuthorizedAnnotated()]"},{"name":"host","value":"SF3-C-000FP"},{"name":"thread","value":"31615@SF3-C-000FP.main(1)"},{"name":"framework","value":"junit-platform"},{"name":"language","value":"java"},{"name":"package","value":"org.eclipse.hawkbit.repository.FileNameFieldsTest"},{"name":"testClass","value":"org.eclipse.hawkbit.repository.FileNameFieldsTest"},{"name":"testMethod","value":"repositoryManagementMethodsArePreAuthorizedAnnotated"},{"name":"suite","value":"org.eclipse.hawkbit.repository.FileNameFieldsTest"}],"links":[],"name":"repositoryManagementMethodsArePreAuthorizedAnnotated()","status":"passed","stage":"finished","description":"Verifies that fields classes are correctly implemented","steps":[],"attachments":[],"parameters":[],"start":1750415892813,"stop":1750415893086}

View File

@@ -1 +0,0 @@
{"uuid":"bbcef88f-a5d4-44a4-bbb0-71bbf92f66f5","name":"FileNameFieldsTest","children":["9829198c-640d-4164-9557-cad7ac0832da"],"befores":[],"afters":[],"start":1750415144348,"stop":1750415144557}

View File

@@ -1 +0,0 @@
{"uuid":"bd35f9eb-0abf-4693-a4ab-89a4ef475c03","name":"FileNameFieldsTest","children":["913eecd1-1800-4cd4-9c59-5094f1221293"],"befores":[],"afters":[],"start":1750414016518,"stop":1750414016723}

View File

@@ -1 +0,0 @@
{"uuid":"bdfb9b69-24d2-4eff-ba3c-1ef30b0519fd","historyId":"fa14928b1c8c4668de3f864412a0b0ca","testCaseId":"[engine:junit-jupiter]/[class:org.eclipse.hawkbit.repository.FileNameFieldsTest]/[method:repositoryManagementMethodsArePreAuthorizedAnnotated()]","testCaseName":"repositoryManagementMethodsArePreAuthorizedAnnotated()","fullName":"org.eclipse.hawkbit.repository.FileNameFieldsTest.repositoryManagementMethodsArePreAuthorizedAnnotated","labels":[{"name":"junit.platform.uniqueid","value":"[engine:junit-jupiter]/[class:org.eclipse.hawkbit.repository.FileNameFieldsTest]/[method:repositoryManagementMethodsArePreAuthorizedAnnotated()]"},{"name":"host","value":"SF3-C-000FP"},{"name":"thread","value":"26751@SF3-C-000FP.main(1)"},{"name":"framework","value":"junit-platform"},{"name":"language","value":"java"},{"name":"package","value":"org.eclipse.hawkbit.repository.FileNameFieldsTest"},{"name":"testClass","value":"org.eclipse.hawkbit.repository.FileNameFieldsTest"},{"name":"testMethod","value":"repositoryManagementMethodsArePreAuthorizedAnnotated"},{"name":"suite","value":"org.eclipse.hawkbit.repository.FileNameFieldsTest"}],"links":[],"name":"repositoryManagementMethodsArePreAuthorizedAnnotated()","status":"passed","stage":"finished","description":"Verifies that fields classes are correctly implemented","steps":[],"attachments":[],"parameters":[],"start":1750414723352,"stop":1750414723483}

View File

@@ -1 +0,0 @@
{"uuid":"c54916fe-169c-435f-9751-0ff0c0c3ede7","name":"FileNameFieldsTest","children":["b3d07773-b904-4e05-9b16-bdd986547be7"],"befores":[],"afters":[],"start":1750415892794,"stop":1750415893127}

View File

@@ -1 +0,0 @@
{"uuid":"c7d19de8-5368-401c-9297-8c6c7bbf830e","historyId":"fa14928b1c8c4668de3f864412a0b0ca","testCaseId":"[engine:junit-jupiter]/[class:org.eclipse.hawkbit.repository.FileNameFieldsTest]/[method:repositoryManagementMethodsArePreAuthorizedAnnotated()]","testCaseName":"repositoryManagementMethodsArePreAuthorizedAnnotated()","fullName":"org.eclipse.hawkbit.repository.FileNameFieldsTest.repositoryManagementMethodsArePreAuthorizedAnnotated","labels":[{"name":"junit.platform.uniqueid","value":"[engine:junit-jupiter]/[class:org.eclipse.hawkbit.repository.FileNameFieldsTest]/[method:repositoryManagementMethodsArePreAuthorizedAnnotated()]"},{"name":"host","value":"SF3-C-000FP"},{"name":"thread","value":"28828@SF3-C-000FP.main(1)"},{"name":"framework","value":"junit-platform"},{"name":"language","value":"java"},{"name":"package","value":"org.eclipse.hawkbit.repository.FileNameFieldsTest"},{"name":"testClass","value":"org.eclipse.hawkbit.repository.FileNameFieldsTest"},{"name":"testMethod","value":"repositoryManagementMethodsArePreAuthorizedAnnotated"},{"name":"suite","value":"org.eclipse.hawkbit.repository.FileNameFieldsTest"}],"links":[],"name":"repositoryManagementMethodsArePreAuthorizedAnnotated()","status":"passed","stage":"finished","description":"Verifies that fields classes are correctly implemented","steps":[],"attachments":[],"parameters":[],"start":1750415195507,"stop":1750415195655}

View File

@@ -1 +0,0 @@
{"uuid":"cabd9766-d959-4d7d-bb53-541eea388c17","name":"repositoryManagementMethodsArePreAuthorizedAnnotated()","children":["e6bd41bd-a706-441a-ada6-e8d141013858"],"befores":[],"afters":[],"start":1750414269854,"stop":1750414270063}

View File

@@ -1 +0,0 @@
{"uuid":"d701f914-7aff-400e-8230-a00f1339827c","historyId":"fa14928b1c8c4668de3f864412a0b0ca","testCaseId":"[engine:junit-jupiter]/[class:org.eclipse.hawkbit.repository.FileNameFieldsTest]/[method:repositoryManagementMethodsArePreAuthorizedAnnotated()]","testCaseName":"repositoryManagementMethodsArePreAuthorizedAnnotated()","fullName":"org.eclipse.hawkbit.repository.FileNameFieldsTest.repositoryManagementMethodsArePreAuthorizedAnnotated","labels":[{"name":"junit.platform.uniqueid","value":"[engine:junit-jupiter]/[class:org.eclipse.hawkbit.repository.FileNameFieldsTest]/[method:repositoryManagementMethodsArePreAuthorizedAnnotated()]"},{"name":"host","value":"SF3-C-000FP"},{"name":"thread","value":"28442@SF3-C-000FP.main(1)"},{"name":"framework","value":"junit-platform"},{"name":"language","value":"java"},{"name":"package","value":"org.eclipse.hawkbit.repository.FileNameFieldsTest"},{"name":"testClass","value":"org.eclipse.hawkbit.repository.FileNameFieldsTest"},{"name":"testMethod","value":"repositoryManagementMethodsArePreAuthorizedAnnotated"},{"name":"suite","value":"org.eclipse.hawkbit.repository.FileNameFieldsTest"}],"links":[],"name":"repositoryManagementMethodsArePreAuthorizedAnnotated()","status":"passed","stage":"finished","description":"Verifies that fields classes are correctly implemented","steps":[],"attachments":[],"parameters":[],"start":1750415118850,"stop":1750415119008}

View File

@@ -1 +0,0 @@
{"uuid":"e0062d7c-0b58-485e-a615-1caa49d50682","name":"FileNameFieldsTest","children":["e6bd41bd-a706-441a-ada6-e8d141013858"],"befores":[],"afters":[],"start":1750414269846,"stop":1750414270068}

View File

@@ -1 +0,0 @@
{"uuid":"e6bd41bd-a706-441a-ada6-e8d141013858","historyId":"fa14928b1c8c4668de3f864412a0b0ca","testCaseId":"[engine:junit-jupiter]/[class:org.eclipse.hawkbit.repository.FileNameFieldsTest]/[method:repositoryManagementMethodsArePreAuthorizedAnnotated()]","testCaseName":"repositoryManagementMethodsArePreAuthorizedAnnotated()","fullName":"org.eclipse.hawkbit.repository.FileNameFieldsTest.repositoryManagementMethodsArePreAuthorizedAnnotated","labels":[{"name":"junit.platform.uniqueid","value":"[engine:junit-jupiter]/[class:org.eclipse.hawkbit.repository.FileNameFieldsTest]/[method:repositoryManagementMethodsArePreAuthorizedAnnotated()]"},{"name":"host","value":"SF3-C-000FP"},{"name":"thread","value":"24854@SF3-C-000FP.main(1)"},{"name":"framework","value":"junit-platform"},{"name":"language","value":"java"},{"name":"package","value":"org.eclipse.hawkbit.repository.FileNameFieldsTest"},{"name":"testClass","value":"org.eclipse.hawkbit.repository.FileNameFieldsTest"},{"name":"testMethod","value":"repositoryManagementMethodsArePreAuthorizedAnnotated"},{"name":"suite","value":"org.eclipse.hawkbit.repository.FileNameFieldsTest"}],"links":[],"name":"repositoryManagementMethodsArePreAuthorizedAnnotated()","status":"passed","stage":"finished","description":"Verifies that fields classes are correctly implemented","steps":[],"attachments":[],"parameters":[],"start":1750414269868,"stop":1750414270043}

View File

@@ -1 +0,0 @@
{"uuid":"e82046fe-fd36-4dc0-981e-95e743b8d086","historyId":"fa14928b1c8c4668de3f864412a0b0ca","testCaseId":"[engine:junit-jupiter]/[class:org.eclipse.hawkbit.repository.FileNameFieldsTest]/[method:repositoryManagementMethodsArePreAuthorizedAnnotated()]","testCaseName":"repositoryManagementMethodsArePreAuthorizedAnnotated()","fullName":"org.eclipse.hawkbit.repository.FileNameFieldsTest.repositoryManagementMethodsArePreAuthorizedAnnotated","labels":[{"name":"junit.platform.uniqueid","value":"[engine:junit-jupiter]/[class:org.eclipse.hawkbit.repository.FileNameFieldsTest]/[method:repositoryManagementMethodsArePreAuthorizedAnnotated()]"},{"name":"host","value":"SF3-C-000FP"},{"name":"thread","value":"25177@SF3-C-000FP.main(1)"},{"name":"framework","value":"junit-platform"},{"name":"language","value":"java"},{"name":"package","value":"org.eclipse.hawkbit.repository.FileNameFieldsTest"},{"name":"testClass","value":"org.eclipse.hawkbit.repository.FileNameFieldsTest"},{"name":"testMethod","value":"repositoryManagementMethodsArePreAuthorizedAnnotated"},{"name":"suite","value":"org.eclipse.hawkbit.repository.FileNameFieldsTest"}],"links":[],"name":"repositoryManagementMethodsArePreAuthorizedAnnotated()","status":"passed","stage":"finished","description":"Verifies that fields classes are correctly implemented","steps":[],"attachments":[],"parameters":[],"start":1750414349135,"stop":1750414349278}

View File

@@ -1 +0,0 @@
{"uuid":"ef752c83-c849-43f8-88f6-98fec388c199","name":"repositoryManagementMethodsArePreAuthorizedAnnotated()","children":["f8b39d47-6a59-4f21-a52c-7c190cb1dfab"],"befores":[],"afters":[],"start":1750414804633,"stop":1750414804821}

View File

@@ -1 +0,0 @@
{"uuid":"f8b39d47-6a59-4f21-a52c-7c190cb1dfab","historyId":"fa14928b1c8c4668de3f864412a0b0ca","testCaseId":"[engine:junit-jupiter]/[class:org.eclipse.hawkbit.repository.FileNameFieldsTest]/[method:repositoryManagementMethodsArePreAuthorizedAnnotated()]","testCaseName":"repositoryManagementMethodsArePreAuthorizedAnnotated()","fullName":"org.eclipse.hawkbit.repository.FileNameFieldsTest.repositoryManagementMethodsArePreAuthorizedAnnotated","labels":[{"name":"junit.platform.uniqueid","value":"[engine:junit-jupiter]/[class:org.eclipse.hawkbit.repository.FileNameFieldsTest]/[method:repositoryManagementMethodsArePreAuthorizedAnnotated()]"},{"name":"host","value":"SF3-C-000FP"},{"name":"thread","value":"27237@SF3-C-000FP.main(1)"},{"name":"framework","value":"junit-platform"},{"name":"language","value":"java"},{"name":"package","value":"org.eclipse.hawkbit.repository.FileNameFieldsTest"},{"name":"testClass","value":"org.eclipse.hawkbit.repository.FileNameFieldsTest"},{"name":"testMethod","value":"repositoryManagementMethodsArePreAuthorizedAnnotated"},{"name":"suite","value":"org.eclipse.hawkbit.repository.FileNameFieldsTest"}],"links":[],"name":"repositoryManagementMethodsArePreAuthorizedAnnotated()","status":"passed","stage":"finished","description":"Verifies that fields classes are correctly implemented","steps":[],"attachments":[],"parameters":[],"start":1750414804649,"stop":1750414804801}

View File

@@ -1 +0,0 @@
{"uuid":"fe17f3a0-aa11-4f29-97a0-423d009e546d","name":"repositoryManagementMethodsArePreAuthorizedAnnotated()","children":["d701f914-7aff-400e-8230-a00f1339827c"],"befores":[],"afters":[],"start":1750415118833,"stop":1750415119030}

View File

@@ -16,14 +16,14 @@ import java.util.List;
import io.github.classgraph.ClassGraph; import io.github.classgraph.ClassGraph;
import io.github.classgraph.ClassInfo; import io.github.classgraph.ClassInfo;
import io.github.classgraph.ScanResult; import io.github.classgraph.ScanResult;
import io.qameta.allure.Description;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
class FileNameFieldsTest { class FileNameFieldsTest {
@Test /**
@Description("Verifies that fields classes are correctly implemented") * Verifies that fields classes are correctly implemented
@SuppressWarnings("unchecked") */
@Test @SuppressWarnings("unchecked")
void repositoryManagementMethodsArePreAuthorizedAnnotated() { void repositoryManagementMethodsArePreAuthorizedAnnotated() {
final String packageName = getClass().getPackage().getName(); final String packageName = getClass().getPackage().getName();
try (final ScanResult scanResult = new ClassGraph().acceptPackages(packageName).scan()) { try (final ScanResult scanResult = new ClassGraph().acceptPackages(packageName).scan()) {

View File

@@ -19,23 +19,22 @@ import java.util.Collections;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.exc.MismatchedInputException; import com.fasterxml.jackson.databind.exc.MismatchedInputException;
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
import io.qameta.allure.Story;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
/** /**
* Test serialization of DDI api model 'DdiActionFeedback' * Test serialization of DDI api model 'DdiActionFeedback'
* <p/>
* Feature: Unit Tests - Direct Device Integration API<br/>
* Story: Serialization of DDI api Models
*/ */
@Feature("Unit Tests - Direct Device Integration API")
@Story("Serialization of DDI api Models")
class DdiActionFeedbackTest { class DdiActionFeedbackTest {
private final ObjectMapper mapper = new ObjectMapper(); private final ObjectMapper mapper = new ObjectMapper();
@Test /**
@Description("Verify the correct serialization and deserialization of the model with minimal payload") * Verify the correct serialization and deserialization of the model with minimal payload
void shouldSerializeAndDeserializeObjectWithoutOptionalValues() throws IOException { */
@Test void shouldSerializeAndDeserializeObjectWithoutOptionalValues() throws IOException {
// Setup // Setup
final DdiStatus ddiStatus = new DdiStatus(DdiStatus.ExecutionStatus.CLOSED, null, null, Collections.emptyList()); final DdiStatus ddiStatus = new DdiStatus(DdiStatus.ExecutionStatus.CLOSED, null, null, Collections.emptyList());
final DdiActionFeedback ddiActionFeedback = new DdiActionFeedback(ddiStatus); final DdiActionFeedback ddiActionFeedback = new DdiActionFeedback(ddiStatus);
@@ -48,9 +47,10 @@ class DdiActionFeedbackTest {
assertThat(deserializedDdiActionFeedback.getStatus()).hasToString(ddiStatus.toString()); assertThat(deserializedDdiActionFeedback.getStatus()).hasToString(ddiStatus.toString());
} }
@Test /**
@Description("Verify the correct serialization and deserialization of the model with all values provided") * Verify the correct serialization and deserialization of the model with all values provided
void shouldSerializeAndDeserializeObjectWithOptionalValues() throws IOException { */
@Test void shouldSerializeAndDeserializeObjectWithOptionalValues() throws IOException {
// Setup // Setup
final Long timestamp = System.currentTimeMillis(); final Long timestamp = System.currentTimeMillis();
final DdiResult ddiResult = new DdiResult(DdiResult.FinalResult.SUCCESS, new DdiProgress(10, 10)); final DdiResult ddiResult = new DdiResult(DdiResult.FinalResult.SUCCESS, new DdiProgress(10, 10));
@@ -65,9 +65,10 @@ class DdiActionFeedbackTest {
assertThat(deserializedDdiActionFeedback.getStatus()).hasToString(ddiStatus.toString()); assertThat(deserializedDdiActionFeedback.getStatus()).hasToString(ddiStatus.toString());
} }
@Test /**
@Description("Verify that deserialization fails for known properties with a wrong datatype") * Verify that deserialization fails for known properties with a wrong datatype
void shouldFailForObjectWithWrongDataTypes() { */
@Test void shouldFailForObjectWithWrongDataTypes() {
// Setup // Setup
final String serializedDdiActionFeedback = """ final String serializedDdiActionFeedback = """
{ {
@@ -83,9 +84,10 @@ class DdiActionFeedbackTest {
() -> mapper.readValue(serializedDdiActionFeedback, DdiActionFeedback.class)); () -> mapper.readValue(serializedDdiActionFeedback, DdiActionFeedback.class));
} }
@Test /**
@Description("Verify that deserialization works if optional fields are not parsed") * Verify that deserialization works if optional fields are not parsed
void shouldConvertItWithoutOptionalFieldTimestamp() throws JsonProcessingException { */
@Test void shouldConvertItWithoutOptionalFieldTimestamp() throws JsonProcessingException {
// Setup // Setup
final String serializedDdiActionFeedback = """ final String serializedDdiActionFeedback = """
{ {

View File

@@ -19,23 +19,22 @@ import java.util.List;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.exc.MismatchedInputException; import com.fasterxml.jackson.databind.exc.MismatchedInputException;
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
import io.qameta.allure.Story;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
/** /**
* Test serializability of DDI api model 'DdiActionHistory' * Test serializability of DDI api model 'DdiActionHistory'
* <p/>
* Feature: Unit Tests - Direct Device Integration API<br/>
* Story: Serializability of DDI api Models
*/ */
@Feature("Unit Tests - Direct Device Integration API")
@Story("Serializability of DDI api Models")
class DdiActionHistoryTest { class DdiActionHistoryTest {
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
@Test /**
@Description("Verify the correct serialization and deserialization of the model") * Verify the correct serialization and deserialization of the model
void shouldSerializeAndDeserializeObject() throws IOException { */
@Test void shouldSerializeAndDeserializeObject() throws IOException {
// Setup // Setup
final String actionStatus = "TestAction"; final String actionStatus = "TestAction";
final List<String> messages = Arrays.asList("Action status message 1", "Action status message 2"); final List<String> messages = Arrays.asList("Action status message 1", "Action status message 2");
@@ -48,9 +47,10 @@ class DdiActionHistoryTest {
assertThat(deserializedDdiActionHistory.toString()).contains(actionStatus, messages.get(0), messages.get(1)); assertThat(deserializedDdiActionHistory.toString()).contains(actionStatus, messages.get(0), messages.get(1));
} }
@Test /**
@Description("Verify the correct deserialization of a model with a additional unknown property") * Verify the correct deserialization of a model with a additional unknown property
void shouldDeserializeObjectWithUnknownProperty() throws IOException { */
@Test void shouldDeserializeObjectWithUnknownProperty() throws IOException {
// Setup // Setup
final String serializedDdiActionHistory = """ final String serializedDdiActionHistory = """
{ {
@@ -64,9 +64,10 @@ class DdiActionHistoryTest {
assertThat(ddiActionHistory.toString()).contains("SomeAction", "Some message"); assertThat(ddiActionHistory.toString()).contains("SomeAction", "Some message");
} }
@Test /**
@Description("Verify that deserialization fails for known properties with a wrong datatype") * Verify that deserialization fails for known properties with a wrong datatype
void shouldFailForObjectWithWrongDataTypes() { */
@Test void shouldFailForObjectWithWrongDataTypes() {
// Setup // Setup
final String serializedDdiActionFeedback = """ final String serializedDdiActionFeedback = """
{ {

View File

@@ -17,23 +17,22 @@ import java.io.IOException;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.exc.MismatchedInputException; import com.fasterxml.jackson.databind.exc.MismatchedInputException;
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
import io.qameta.allure.Story;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
/** /**
* Test serializability of DDI api model 'DdiArtifactHash' * Test serializability of DDI api model 'DdiArtifactHash'
* <p/>
* Feature: Unit Tests - Direct Device Integration API<br/>
* Story: Serializability of DDI api Models
*/ */
@Feature("Unit Tests - Direct Device Integration API")
@Story("Serializability of DDI api Models")
class DdiArtifactHashTest { class DdiArtifactHashTest {
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
@Test /**
@Description("Verify the correct serialization and deserialization of the model") * Verify the correct serialization and deserialization of the model
void shouldSerializeAndDeserializeObject() throws IOException { */
@Test void shouldSerializeAndDeserializeObject() throws IOException {
// Setup // Setup
final String sha1Hash = "11111"; final String sha1Hash = "11111";
final String md5Hash = "22222"; final String md5Hash = "22222";
@@ -49,9 +48,10 @@ class DdiArtifactHashTest {
assertThat(deserializedDdiArtifact.getSha256()).isEqualTo(sha256Hash); assertThat(deserializedDdiArtifact.getSha256()).isEqualTo(sha256Hash);
} }
@Test /**
@Description("Verify the correct deserialization of a model with a additional unknown property") * Verify the correct deserialization of a model with a additional unknown property
void shouldDeserializeObjectWithUnknownProperty() throws IOException { */
@Test void shouldDeserializeObjectWithUnknownProperty() throws IOException {
// Setup // Setup
final String serializedDdiArtifact = "{\"sha1\": \"123\", \"md5\": \"456\", \"sha256\": \"789\", \"unknownProperty\": \"test\"}"; final String serializedDdiArtifact = "{\"sha1\": \"123\", \"md5\": \"456\", \"sha256\": \"789\", \"unknownProperty\": \"test\"}";
@@ -62,9 +62,10 @@ class DdiArtifactHashTest {
assertThat(ddiArtifact.getSha256()).isEqualTo("789"); assertThat(ddiArtifact.getSha256()).isEqualTo("789");
} }
@Test /**
@Description("Verify that deserialization fails for known properties with a wrong datatype") * Verify that deserialization fails for known properties with a wrong datatype
void shouldFailForObjectWithWrongDataTypes() { */
@Test void shouldFailForObjectWithWrongDataTypes() {
// Setup // Setup
final String serializedDdiArtifact = "{\"sha1\": [123], \"md5\": 456, \"sha256\": \"789\""; final String serializedDdiArtifact = "{\"sha1\": [123], \"md5\": 456, \"sha256\": \"789\"";

View File

@@ -17,23 +17,22 @@ import java.io.IOException;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.exc.MismatchedInputException; import com.fasterxml.jackson.databind.exc.MismatchedInputException;
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
import io.qameta.allure.Story;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
/** /**
* Test serializability of DDI api model 'DdiArtifact' * Test serializability of DDI api model 'DdiArtifact'
* <p/>
* Feature: Unit Tests - Direct Device Integration API<br/>
* Story: Serializability of DDI api Models
*/ */
@Feature("Unit Tests - Direct Device Integration API")
@Story("Serializability of DDI api Models")
class DdiArtifactTest { class DdiArtifactTest {
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
@Test /**
@Description("Verify the correct serialization and deserialization of the model") * Verify the correct serialization and deserialization of the model
void shouldSerializeAndDeserializeObject() throws IOException { */
@Test void shouldSerializeAndDeserializeObject() throws IOException {
// Setup // Setup
final String filename = "testfile.txt"; final String filename = "testfile.txt";
final DdiArtifactHash hashes = new DdiArtifactHash("123", "456", "789"); final DdiArtifactHash hashes = new DdiArtifactHash("123", "456", "789");
@@ -52,9 +51,10 @@ class DdiArtifactTest {
assertThat(deserializedDdiArtifact.getHashes().getSha256()).isEqualTo(hashes.getSha256()); assertThat(deserializedDdiArtifact.getHashes().getSha256()).isEqualTo(hashes.getSha256());
} }
@Test /**
@Description("Verify the correct deserialization of a model with a additional unknown property") * Verify the correct deserialization of a model with a additional unknown property
void shouldDeserializeObjectWithUnknownProperty() throws IOException { */
@Test void shouldDeserializeObjectWithUnknownProperty() throws IOException {
// Setup // Setup
final String serializedDdiArtifact = "{\"filename\":\"test.file\",\"hashes\":{\"sha1\":\"123\",\"md5\":\"456\",\"sha256\":\"789\"},\"size\":111,\"links\":[],\"unknownProperty\": \"test\"}"; final String serializedDdiArtifact = "{\"filename\":\"test.file\",\"hashes\":{\"sha1\":\"123\",\"md5\":\"456\",\"sha256\":\"789\"},\"size\":111,\"links\":[],\"unknownProperty\": \"test\"}";
@@ -67,9 +67,10 @@ class DdiArtifactTest {
assertThat(ddiArtifact.getHashes().getSha256()).isEqualTo("789"); assertThat(ddiArtifact.getHashes().getSha256()).isEqualTo("789");
} }
@Test /**
@Description("Verify that deserialization fails for known properties with a wrong datatype") * Verify that deserialization fails for known properties with a wrong datatype
void shouldFailForObjectWithWrongDataTypes() { */
@Test void shouldFailForObjectWithWrongDataTypes() {
// Setup // Setup
final String serializedDdiArtifact = "{\"filename\": [\"test.file\"],\"hashes\":{\"sha1\":\"123\",\"md5\":\"456\",\"sha256\":\"789\"},\"size\":111,\"links\":[]}"; final String serializedDdiArtifact = "{\"filename\": [\"test.file\"],\"hashes\":{\"sha1\":\"123\",\"md5\":\"456\",\"sha256\":\"789\"},\"size\":111,\"links\":[]}";

View File

@@ -17,23 +17,22 @@ import java.io.IOException;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.exc.MismatchedInputException; import com.fasterxml.jackson.databind.exc.MismatchedInputException;
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
import io.qameta.allure.Story;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
/** /**
* Test serializability of DDI api model 'DdiCancelActionToStop' * Test serializability of DDI api model 'DdiCancelActionToStop'
* <p/>
* Feature: Unit Tests - Direct Device Integration API<br/>
* Story: Serializability of DDI api Models
*/ */
@Feature("Unit Tests - Direct Device Integration API")
@Story("Serializability of DDI api Models")
class DdiCancelActionToStopTest { class DdiCancelActionToStopTest {
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
@Test /**
@Description("Verify the correct serialization and deserialization of the model") * Verify the correct serialization and deserialization of the model
void shouldSerializeAndDeserializeObject() throws IOException { */
@Test void shouldSerializeAndDeserializeObject() throws IOException {
// Setup // Setup
final String stopId = "1234"; final String stopId = "1234";
final DdiCancelActionToStop ddiCancelActionToStop = new DdiCancelActionToStop(stopId); final DdiCancelActionToStop ddiCancelActionToStop = new DdiCancelActionToStop(stopId);
@@ -46,9 +45,10 @@ class DdiCancelActionToStopTest {
assertThat(deserializedDdiCancelActionToStop.getStopId()).isEqualTo(stopId); assertThat(deserializedDdiCancelActionToStop.getStopId()).isEqualTo(stopId);
} }
@Test /**
@Description("Verify the correct deserialization of a model with a additional unknown property") * Verify the correct deserialization of a model with a additional unknown property
void shouldDeserializeObjectWithUnknownProperty() throws IOException { */
@Test void shouldDeserializeObjectWithUnknownProperty() throws IOException {
// Setup // Setup
final String serializedDdiCancelActionToStop = "{\"stopId\":\"12345\",\"unknownProperty\":\"test\"}"; final String serializedDdiCancelActionToStop = "{\"stopId\":\"12345\",\"unknownProperty\":\"test\"}";
@@ -58,9 +58,10 @@ class DdiCancelActionToStopTest {
assertThat(ddiCancelActionToStop.getStopId()).contains("12345"); assertThat(ddiCancelActionToStop.getStopId()).contains("12345");
} }
@Test /**
@Description("Verify that deserialization fails for known properties with a wrong datatype") * Verify that deserialization fails for known properties with a wrong datatype
void shouldFailForObjectWithWrongDataTypes() { */
@Test void shouldFailForObjectWithWrongDataTypes() {
// Setup // Setup
final String serializedDdiCancelActionToStop = "{\"stopId\": [\"12345\"]}"; final String serializedDdiCancelActionToStop = "{\"stopId\": [\"12345\"]}";

View File

@@ -17,23 +17,22 @@ import java.io.IOException;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.exc.MismatchedInputException; import com.fasterxml.jackson.databind.exc.MismatchedInputException;
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
import io.qameta.allure.Story;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
/** /**
* Test serializability of DDI api model 'DdiArtifact' * Test serializability of DDI api model 'DdiArtifact'
* <p/>
* Feature: Unit Tests - Direct Device Integration API<br/>
* Story: Serializability of DDI api Models
*/ */
@Feature("Unit Tests - Direct Device Integration API")
@Story("Serializability of DDI api Models")
class DdiCancelTest { class DdiCancelTest {
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
@Test /**
@Description("Verify the correct serialization and deserialization of the model") * Verify the correct serialization and deserialization of the model
void shouldSerializeAndDeserializeObject() throws IOException { */
@Test void shouldSerializeAndDeserializeObject() throws IOException {
// Setup // Setup
final String ddiCancelId = "1234"; final String ddiCancelId = "1234";
final DdiCancelActionToStop ddiCancelActionToStop = new DdiCancelActionToStop("1234"); final DdiCancelActionToStop ddiCancelActionToStop = new DdiCancelActionToStop("1234");
@@ -47,9 +46,10 @@ class DdiCancelTest {
assertThat(deserializedDdiCancel.getCancelAction().getStopId()).isEqualTo(ddiCancelActionToStop.getStopId()); assertThat(deserializedDdiCancel.getCancelAction().getStopId()).isEqualTo(ddiCancelActionToStop.getStopId());
} }
@Test /**
@Description("Verify the correct deserialization of a model with a additional unknown property") * Verify the correct deserialization of a model with a additional unknown property
void shouldDeserializeObjectWithUnknownProperty() throws IOException { */
@Test void shouldDeserializeObjectWithUnknownProperty() throws IOException {
// Setup // Setup
final String serializedDdiCancel = "{\"id\":\"1234\",\"cancelAction\":{\"stopId\":\"1234\"}, \"unknownProperty\": \"test\"}"; final String serializedDdiCancel = "{\"id\":\"1234\",\"cancelAction\":{\"stopId\":\"1234\"}, \"unknownProperty\": \"test\"}";
@@ -59,9 +59,10 @@ class DdiCancelTest {
assertThat(ddiCancel.getCancelAction().getStopId()).matches("1234"); assertThat(ddiCancel.getCancelAction().getStopId()).matches("1234");
} }
@Test /**
@Description("Verify that deserialization fails for known properties with a wrong datatype") * Verify that deserialization fails for known properties with a wrong datatype
void shouldFailForObjectWithWrongDataTypes() { */
@Test void shouldFailForObjectWithWrongDataTypes() {
// Setup // Setup
final String serializedDdiCancel = "{\"id\":[\"1234\"],\"cancelAction\":{\"stopId\":\"1234\"}}"; final String serializedDdiCancel = "{\"id\":[\"1234\"],\"cancelAction\":{\"stopId\":\"1234\"}}";

View File

@@ -19,23 +19,22 @@ import java.util.List;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.exc.MismatchedInputException; import com.fasterxml.jackson.databind.exc.MismatchedInputException;
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
import io.qameta.allure.Story;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
/** /**
* Test serializability of DDI api model 'DdiChunk' * Test serializability of DDI api model 'DdiChunk'
* <p/>
* Feature: Unit Tests - Direct Device Integration API<br/>
* Story: Serializability of DDI api Models
*/ */
@Feature("Unit Tests - Direct Device Integration API")
@Story("Serializability of DDI api Models")
class DdiChunkTest { class DdiChunkTest {
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
@Test /**
@Description("Verify the correct serialization and deserialization of the model") * Verify the correct serialization and deserialization of the model
void shouldSerializeAndDeserializeObject() throws IOException { */
@Test void shouldSerializeAndDeserializeObject() throws IOException {
// Setup // Setup
final String part = "1234"; final String part = "1234";
final String version = "1.0"; final String version = "1.0";
@@ -53,9 +52,10 @@ class DdiChunkTest {
assertThat(deserializedDdiChunk.getArtifacts()).isEmpty(); assertThat(deserializedDdiChunk.getArtifacts()).isEmpty();
} }
@Test /**
@Description("Verify the correct deserialization of a model with a additional unknown property") * Verify the correct deserialization of a model with a additional unknown property
void shouldDeserializeObjectWithUnknownProperty() throws IOException { */
@Test void shouldDeserializeObjectWithUnknownProperty() throws IOException {
// Setup // Setup
final String serializedDdiChunk = "{\"part\":\"1234\",\"version\":\"1.0\",\"name\":\"Dummy-Artifact\",\"artifacts\":[],\"unknownProperty\":\"test\"}"; final String serializedDdiChunk = "{\"part\":\"1234\",\"version\":\"1.0\",\"name\":\"Dummy-Artifact\",\"artifacts\":[],\"unknownProperty\":\"test\"}";
@@ -67,9 +67,10 @@ class DdiChunkTest {
assertThat(ddiChunk.getArtifacts()).isEmpty(); assertThat(ddiChunk.getArtifacts()).isEmpty();
} }
@Test /**
@Description("Verify that deserialization fails for known properties with a wrong datatype") * Verify that deserialization fails for known properties with a wrong datatype
void shouldFailForObjectWithWrongDataTypes() { */
@Test void shouldFailForObjectWithWrongDataTypes() {
// Setup // Setup
final String serializedDdiChunk = "{\"part\":[\"1234\"],\"version\":\"1.0\",\"name\":\"Dummy-Artifact\",\"artifacts\":[]}"; final String serializedDdiChunk = "{\"part\":[\"1234\"],\"version\":\"1.0\",\"name\":\"Dummy-Artifact\",\"artifacts\":[]}";

View File

@@ -19,23 +19,22 @@ import java.util.Map;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.exc.MismatchedInputException; import com.fasterxml.jackson.databind.exc.MismatchedInputException;
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
import io.qameta.allure.Story;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
/** /**
* Test serializability of DDI api model 'DdiConfigData' * Test serializability of DDI api model 'DdiConfigData'
* <p/>
* Feature: Unit Tests - Direct Device Integration API<br/>
* Story: Serializability of DDI api Models
*/ */
@Feature("Unit Tests - Direct Device Integration API")
@Story("Serializability of DDI api Models")
class DdiConfigDataTest { class DdiConfigDataTest {
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
@Test /**
@Description("Verify the correct serialization and deserialization of the model") * Verify the correct serialization and deserialization of the model
void shouldSerializeAndDeserializeObject() throws IOException { */
@Test void shouldSerializeAndDeserializeObject() throws IOException {
// Setup // Setup
final Map<String, String> data = new HashMap<>(); final Map<String, String> data = new HashMap<>();
data.put("test", "data"); data.put("test", "data");
@@ -48,9 +47,10 @@ class DdiConfigDataTest {
assertThat(deserializedDdiConfigData.getMode()).isEqualTo(DdiUpdateMode.REPLACE); assertThat(deserializedDdiConfigData.getMode()).isEqualTo(DdiUpdateMode.REPLACE);
} }
@Test /**
@Description("Verify the correct deserialization of a model with an additional unknown property") * Verify the correct deserialization of a model with an additional unknown property
void shouldDeserializeObjectWithUnknownProperty() throws IOException { */
@Test void shouldDeserializeObjectWithUnknownProperty() throws IOException {
// Setup // Setup
final String serializedDdiConfigData = "{\"data\":{\"test\":\"data\"},\"mode\":\"replace\",\"unknownProperty\":\"test\"}"; final String serializedDdiConfigData = "{\"data\":{\"test\":\"data\"},\"mode\":\"replace\",\"unknownProperty\":\"test\"}";
@@ -59,9 +59,10 @@ class DdiConfigDataTest {
assertThat(ddiConfigData.getMode()).isEqualTo(DdiUpdateMode.REPLACE); assertThat(ddiConfigData.getMode()).isEqualTo(DdiUpdateMode.REPLACE);
} }
@Test /**
@Description("Verify that deserialization fails for known properties with a wrong datatype") * Verify that deserialization fails for known properties with a wrong datatype
void shouldFailForObjectWithWrongDataTypes() { */
@Test void shouldFailForObjectWithWrongDataTypes() {
// Setup // Setup
final String serializedDdiConfigData = "{\"data\":{\"test\":\"data\"},\"mode\":[\"replace\"],\"unknownProperty\":\"test\"}"; final String serializedDdiConfigData = "{\"data\":{\"test\":\"data\"},\"mode\":[\"replace\"],\"unknownProperty\":\"test\"}";
@@ -70,9 +71,10 @@ class DdiConfigDataTest {
.isThrownBy(() -> OBJECT_MAPPER.readValue(serializedDdiConfigData, DdiConfigData.class)); .isThrownBy(() -> OBJECT_MAPPER.readValue(serializedDdiConfigData, DdiConfigData.class));
} }
@Test /**
@Description("Verify the correct deserialization of a model with removed unused status property") * Verify the correct deserialization of a model with removed unused status property
void shouldDeserializeObjectWithStatusProperty() throws IOException { */
@Test void shouldDeserializeObjectWithStatusProperty() throws IOException {
// We formerly falsely required a 'status' property object when using the // We formerly falsely required a 'status' property object when using the
// configData endpoint. It was removed as a requirement from code and // configData endpoint. It was removed as a requirement from code and
// documentation, as it was unused. This test ensures we still behave correctly // documentation, as it was unused. This test ensures we still behave correctly

View File

@@ -17,23 +17,22 @@ import java.io.IOException;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.exc.MismatchedInputException; import com.fasterxml.jackson.databind.exc.MismatchedInputException;
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
import io.qameta.allure.Story;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
/** /**
* Test serializability of DDI api model 'DdiConfig' * Test serializability of DDI api model 'DdiConfig'
* <p/>
* Feature: Unit Tests - Direct Device Integration API<br/>
* Story: Serializability of DDI api Models
*/ */
@Feature("Unit Tests - Direct Device Integration API")
@Story("Serializability of DDI api Models")
class DdiConfigTest { class DdiConfigTest {
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
@Test /**
@Description("Verify the correct serialization and deserialization of the model") * Verify the correct serialization and deserialization of the model
void shouldSerializeAndDeserializeObject() throws IOException { */
@Test void shouldSerializeAndDeserializeObject() throws IOException {
// Setup // Setup
final DdiPolling ddiPolling = new DdiPolling("10"); final DdiPolling ddiPolling = new DdiPolling("10");
final DdiConfig ddiConfig = new DdiConfig(ddiPolling); final DdiConfig ddiConfig = new DdiConfig(ddiPolling);
@@ -45,9 +44,10 @@ class DdiConfigTest {
assertThat(deserializedDdiConfig.getPolling().getSleep()).isEqualTo("10"); assertThat(deserializedDdiConfig.getPolling().getSleep()).isEqualTo("10");
} }
@Test /**
@Description("Verify the correct deserialization of a model with a additional unknown property") * Verify the correct deserialization of a model with a additional unknown property
void shouldDeserializeObjectWithUnknownProperty() throws IOException { */
@Test void shouldDeserializeObjectWithUnknownProperty() throws IOException {
// Setup // Setup
final String serializedDdiConfig = "{\"polling\":{\"sleep\":\"123\"},\"unknownProperty\":\"test\"}"; final String serializedDdiConfig = "{\"polling\":{\"sleep\":\"123\"},\"unknownProperty\":\"test\"}";
@@ -56,9 +56,10 @@ class DdiConfigTest {
assertThat(ddiConfig.getPolling().getSleep()).isEqualTo("123"); assertThat(ddiConfig.getPolling().getSleep()).isEqualTo("123");
} }
@Test /**
@Description("Verify that deserialization fails for known properties with a wrong datatype") * Verify that deserialization fails for known properties with a wrong datatype
void shouldFailForObjectWithWrongDataTypes() { */
@Test void shouldFailForObjectWithWrongDataTypes() {
// Setup // Setup
final String serializedDdiConfig = "{\"polling\":{\"sleep\":[\"10\"]}}"; final String serializedDdiConfig = "{\"polling\":{\"sleep\":[\"10\"]}}";

View File

@@ -22,23 +22,22 @@ import java.util.List;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.exc.MismatchedInputException; import com.fasterxml.jackson.databind.exc.MismatchedInputException;
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
import io.qameta.allure.Story;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
/** /**
* Test serializability of DDI api model 'DdiConfirmationBase' * Test serializability of DDI api model 'DdiConfirmationBase'
* <p/>
* Feature: Unit Tests - Direct Device Integration API<br/>
* Story: CHeck JSON serialization of DDI api confirmation models
*/ */
@Feature("Unit Tests - Direct Device Integration API")
@Story("CHeck JSON serialization of DDI api confirmation models")
class DdiConfirmationBaseTest { class DdiConfirmationBaseTest {
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
@Test /**
@Description("Verify the correct serialization and deserialization of the model") * Verify the correct serialization and deserialization of the model
void shouldSerializeAndDeserializeObject() throws IOException { */
@Test void shouldSerializeAndDeserializeObject() throws IOException {
// Setup // Setup
final String id = "1234"; final String id = "1234";
final DdiDeployment ddiDeployment = new DdiDeployment(FORCED, ATTEMPT, Collections.emptyList(), AVAILABLE); final DdiDeployment ddiDeployment = new DdiDeployment(FORCED, ATTEMPT, Collections.emptyList(), AVAILABLE);
@@ -63,9 +62,10 @@ class DdiConfirmationBaseTest {
.hasToString(ddiActionHistory.toString()); .hasToString(ddiActionHistory.toString());
} }
@Test /**
@Description("Verify the correct deserialization of a model with a additional unknown property") * Verify the correct deserialization of a model with a additional unknown property
void shouldDeserializeObjectWithUnknownProperty() throws IOException { */
@Test void shouldDeserializeObjectWithUnknownProperty() throws IOException {
// Setup // Setup
final String serializedDdiConfirmationBase = "{" + final String serializedDdiConfirmationBase = "{" +
"\"id\":\"1234\",\"confirmation\":{\"download\":\"forced\"," + "\"id\":\"1234\",\"confirmation\":{\"download\":\"forced\"," +
@@ -84,9 +84,10 @@ class DdiConfirmationBaseTest {
.isEqualTo(AVAILABLE.getStatus()); .isEqualTo(AVAILABLE.getStatus());
} }
@Test /**
@Description("Verify that deserialization fails for known properties with a wrong datatype") * Verify that deserialization fails for known properties with a wrong datatype
void shouldFailForObjectWithWrongDataTypes() { */
@Test void shouldFailForObjectWithWrongDataTypes() {
// Setup // Setup
final String serializedDdiConfirmationBase = "{" + final String serializedDdiConfirmationBase = "{" +
"\"id\":[\"1234\"],\"confirmation\":{\"download\":\"forced\"," + "\"id\":[\"1234\"],\"confirmation\":{\"download\":\"forced\"," +

View File

@@ -17,23 +17,22 @@ import java.io.IOException;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.exc.MismatchedInputException; import com.fasterxml.jackson.databind.exc.MismatchedInputException;
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
import io.qameta.allure.Story;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
/** /**
* Test serializability of DDI api model 'DdiControllerBase' * Test serializability of DDI api model 'DdiControllerBase'
* <p/>
* Feature: Unit Tests - Direct Device Integration API<br/>
* Story: Serializability of DDI api Models
*/ */
@Feature("Unit Tests - Direct Device Integration API")
@Story("Serializability of DDI api Models")
class DdiControllerBaseTest { class DdiControllerBaseTest {
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
@Test /**
@Description("Verify the correct serialization and deserialization of the model") * Verify the correct serialization and deserialization of the model
void shouldSerializeAndDeserializeObject() throws IOException { */
@Test void shouldSerializeAndDeserializeObject() throws IOException {
// Setup // Setup
final DdiPolling ddiPolling = new DdiPolling("10"); final DdiPolling ddiPolling = new DdiPolling("10");
final DdiConfig ddiConfig = new DdiConfig(ddiPolling); final DdiConfig ddiConfig = new DdiConfig(ddiPolling);
@@ -46,9 +45,10 @@ class DdiControllerBaseTest {
assertThat(deserializedDdiControllerBase.getConfig().getPolling().getSleep()).isEqualTo(ddiPolling.getSleep()); assertThat(deserializedDdiControllerBase.getConfig().getPolling().getSleep()).isEqualTo(ddiPolling.getSleep());
} }
@Test /**
@Description("Verify the correct deserialization of a model with a additional unknown property") * Verify the correct deserialization of a model with a additional unknown property
void shouldDeserializeObjectWithUnknownProperty() throws IOException { */
@Test void shouldDeserializeObjectWithUnknownProperty() throws IOException {
// Setup // Setup
final String serializedDdiControllerBase = "{\"config\":{\"polling\":{\"sleep\":\"123\"}},\"links\":[],\"unknownProperty\":\"test\"}"; final String serializedDdiControllerBase = "{\"config\":{\"polling\":{\"sleep\":\"123\"}},\"links\":[],\"unknownProperty\":\"test\"}";
@@ -57,9 +57,10 @@ class DdiControllerBaseTest {
assertThat(ddiControllerBase.getConfig().getPolling().getSleep()).isEqualTo("123"); assertThat(ddiControllerBase.getConfig().getPolling().getSleep()).isEqualTo("123");
} }
@Test /**
@Description("Verify that deserialization fails for known properties with a wrong datatype") * Verify that deserialization fails for known properties with a wrong datatype
void shouldFailForObjectWithWrongDataTypes() { */
@Test void shouldFailForObjectWithWrongDataTypes() {
// Setup // Setup
final String serializedDdiControllerBase = "{\"config\":{\"polling\":{\"sleep\":[\"123\"]}},\"links\":[],\"unknownProperty\":\"test\"}"; final String serializedDdiControllerBase = "{\"config\":{\"polling\":{\"sleep\":[\"123\"]}},\"links\":[],\"unknownProperty\":\"test\"}";

View File

@@ -22,23 +22,22 @@ import java.util.List;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.exc.MismatchedInputException; import com.fasterxml.jackson.databind.exc.MismatchedInputException;
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
import io.qameta.allure.Story;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
/** /**
* Test serializability of DDI api model 'DdiDeploymentBase' * Test serializability of DDI api model 'DdiDeploymentBase'
* <p/>
* Feature: Unit Tests - Direct Device Integration API<br/>
* Story: Serializability of DDI api Models
*/ */
@Feature("Unit Tests - Direct Device Integration API")
@Story("Serializability of DDI api Models")
class DdiDeploymentBaseTest { class DdiDeploymentBaseTest {
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
@Test /**
@Description("Verify the correct serialization and deserialization of the model") * Verify the correct serialization and deserialization of the model
void shouldSerializeAndDeserializeObject() throws IOException { */
@Test void shouldSerializeAndDeserializeObject() throws IOException {
// Setup // Setup
final String id = "1234"; final String id = "1234";
final DdiDeployment ddiDeployment = new DdiDeployment(FORCED, ATTEMPT, Collections.emptyList(), AVAILABLE); final DdiDeployment ddiDeployment = new DdiDeployment(FORCED, ATTEMPT, Collections.emptyList(), AVAILABLE);
@@ -57,9 +56,10 @@ class DdiDeploymentBaseTest {
assertThat(deserializedDdiDeploymentBase.getActionHistory()).hasToString(ddiActionHistory.toString()); assertThat(deserializedDdiDeploymentBase.getActionHistory()).hasToString(ddiActionHistory.toString());
} }
@Test /**
@Description("Verify the correct deserialization of a model with a additional unknown property") * Verify the correct deserialization of a model with a additional unknown property
void shouldDeserializeObjectWithUnknownProperty() throws IOException { */
@Test void shouldDeserializeObjectWithUnknownProperty() throws IOException {
// Setup // Setup
final String serializedDdiDeploymentBase = "{\"id\":\"1234\",\"deployment\":{\"download\":\"forced\"," + final String serializedDdiDeploymentBase = "{\"id\":\"1234\",\"deployment\":{\"download\":\"forced\"," +
"\"update\":\"attempt\",\"maintenanceWindow\":\"available\",\"chunks\":[]}," + "\"update\":\"attempt\",\"maintenanceWindow\":\"available\",\"chunks\":[]}," +
@@ -73,9 +73,10 @@ class DdiDeploymentBaseTest {
assertThat(ddiDeploymentBase.getDeployment().getMaintenanceWindow().getStatus()).isEqualTo(AVAILABLE.getStatus()); assertThat(ddiDeploymentBase.getDeployment().getMaintenanceWindow().getStatus()).isEqualTo(AVAILABLE.getStatus());
} }
@Test /**
@Description("Verify that deserialization fails for known properties with a wrong datatype") * Verify that deserialization fails for known properties with a wrong datatype
void shouldFailForObjectWithWrongDataTypes() { */
@Test void shouldFailForObjectWithWrongDataTypes() {
// Setup // Setup
final String serializedDdiDeploymentBase = "{\"id\":[\"1234\"],\"deployment\":{\"download\":\"forced\"," + final String serializedDdiDeploymentBase = "{\"id\":[\"1234\"],\"deployment\":{\"download\":\"forced\"," +
"\"update\":\"attempt\",\"maintenanceWindow\":\"available\",\"chunks\":[]}," + "\"update\":\"attempt\",\"maintenanceWindow\":\"available\",\"chunks\":[]}," +

View File

@@ -21,23 +21,22 @@ import java.util.Collections;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.exc.MismatchedInputException; import com.fasterxml.jackson.databind.exc.MismatchedInputException;
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
import io.qameta.allure.Story;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
/** /**
* Test serializability of DDI api model 'DdiDeployment' * Test serializability of DDI api model 'DdiDeployment'
* <p/>
* Feature: Unit Tests - Direct Device Integration API<br/>
* Story: Serializability of DDI api Models
*/ */
@Feature("Unit Tests - Direct Device Integration API")
@Story("Serializability of DDI api Models")
class DdiDeploymentTest { class DdiDeploymentTest {
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
@Test /**
@Description("Verify the correct serialization and deserialization of the model") * Verify the correct serialization and deserialization of the model
void shouldSerializeAndDeserializeObject() throws IOException { */
@Test void shouldSerializeAndDeserializeObject() throws IOException {
// Setup // Setup
final DdiDeployment ddiDeployment = new DdiDeployment(FORCED, ATTEMPT, Collections.emptyList(), AVAILABLE); final DdiDeployment ddiDeployment = new DdiDeployment(FORCED, ATTEMPT, Collections.emptyList(), AVAILABLE);
@@ -51,9 +50,10 @@ class DdiDeploymentTest {
assertThat(deserializedDdiDeployment.getMaintenanceWindow().getStatus()).isEqualTo(ddiDeployment.getMaintenanceWindow().getStatus()); assertThat(deserializedDdiDeployment.getMaintenanceWindow().getStatus()).isEqualTo(ddiDeployment.getMaintenanceWindow().getStatus());
} }
@Test /**
@Description("Verify the correct deserialization of a model with a additional unknown property") * Verify the correct deserialization of a model with a additional unknown property
void shouldDeserializeObjectWithUnknownProperty() throws IOException { */
@Test void shouldDeserializeObjectWithUnknownProperty() throws IOException {
// Setup // Setup
final String serializedDdiDeployment = "{\"download\":\"forced\",\"update\":\"attempt\", " + final String serializedDdiDeployment = "{\"download\":\"forced\",\"update\":\"attempt\", " +
"\"maintenanceWindow\":\"available\",\"chunks\":[],\"unknownProperty\":\"test\"}"; "\"maintenanceWindow\":\"available\",\"chunks\":[],\"unknownProperty\":\"test\"}";
@@ -65,9 +65,10 @@ class DdiDeploymentTest {
assertThat(ddiDeployment.getMaintenanceWindow().getStatus()).isEqualTo(AVAILABLE.getStatus()); assertThat(ddiDeployment.getMaintenanceWindow().getStatus()).isEqualTo(AVAILABLE.getStatus());
} }
@Test /**
@Description("Verify that deserialization fails for known properties with a wrong datatype") * Verify that deserialization fails for known properties with a wrong datatype
void shouldFailForObjectWithWrongDataTypes() { */
@Test void shouldFailForObjectWithWrongDataTypes() {
// Setup // Setup
final String serializedDdiDeployment = "{\"download\":[\"forced\"],\"update\":\"attempt\", " + final String serializedDdiDeployment = "{\"download\":[\"forced\"],\"update\":\"attempt\", " +
"\"maintenanceWindow\":\"available\",\"chunks\":[]}"; "\"maintenanceWindow\":\"available\",\"chunks\":[]}";

View File

@@ -17,23 +17,22 @@ import java.io.IOException;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.exc.MismatchedInputException; import com.fasterxml.jackson.databind.exc.MismatchedInputException;
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
import io.qameta.allure.Story;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
/** /**
* Test serializability of DDI api model 'DdiMetadata' * Test serializability of DDI api model 'DdiMetadata'
* <p/>
* Feature: Unit Tests - Direct Device Integration API<br/>
* Story: Serializability of DDI api Models
*/ */
@Feature("Unit Tests - Direct Device Integration API")
@Story("Serializability of DDI api Models")
class DdiMetadataTest { class DdiMetadataTest {
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
@Test /**
@Description("Verify the correct serialization and deserialization of the model") * Verify the correct serialization and deserialization of the model
void shouldSerializeAndDeserializeObject() throws IOException { */
@Test void shouldSerializeAndDeserializeObject() throws IOException {
// Setup // Setup
final String key = "testKey"; final String key = "testKey";
final String value = "testValue"; final String value = "testValue";
@@ -47,9 +46,10 @@ class DdiMetadataTest {
assertThat(deserializedDdiMetadata.getValue()).isEqualTo(ddiMetadata.getValue()); assertThat(deserializedDdiMetadata.getValue()).isEqualTo(ddiMetadata.getValue());
} }
@Test /**
@Description("Verify the correct deserialization of a model with a additional unknown property") * Verify the correct deserialization of a model with a additional unknown property
void shouldDeserializeObjectWithUnknownProperty() throws IOException { */
@Test void shouldDeserializeObjectWithUnknownProperty() throws IOException {
// Setup // Setup
final String serializedDdiMetadata = "{\"key\":\"testKey\",\"value\":\"testValue\",\"unknownProperty\":\"test\"}"; final String serializedDdiMetadata = "{\"key\":\"testKey\",\"value\":\"testValue\",\"unknownProperty\":\"test\"}";
@@ -59,9 +59,10 @@ class DdiMetadataTest {
assertThat(ddiMetadata.getValue()).isEqualTo("testValue"); assertThat(ddiMetadata.getValue()).isEqualTo("testValue");
} }
@Test /**
@Description("Verify that deserialization fails for known properties with a wrong datatype") * Verify that deserialization fails for known properties with a wrong datatype
void shouldFailForObjectWithWrongDataTypes() { */
@Test void shouldFailForObjectWithWrongDataTypes() {
// Setup // Setup
final String serializedDdiMetadata = "{\"key\":[\"testKey\"],\"value\":\"testValue\"}"; final String serializedDdiMetadata = "{\"key\":[\"testKey\"],\"value\":\"testValue\"}";

View File

@@ -17,23 +17,22 @@ import java.io.IOException;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.exc.MismatchedInputException; import com.fasterxml.jackson.databind.exc.MismatchedInputException;
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
import io.qameta.allure.Story;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
/** /**
* Test serializability of DDI api model 'DdiPolling' * Test serializability of DDI api model 'DdiPolling'
* <p/>
* Feature: Unit Tests - Direct Device Integration API<br/>
* Story: Serializability of DDI api Models
*/ */
@Feature("Unit Tests - Direct Device Integration API")
@Story("Serializability of DDI api Models")
class DdiPollingTest { class DdiPollingTest {
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
@Test /**
@Description("Verify the correct serialization and deserialization of the model") * Verify the correct serialization and deserialization of the model
void shouldSerializeAndDeserializeObject() throws IOException { */
@Test void shouldSerializeAndDeserializeObject() throws IOException {
// Setup // Setup
final DdiPolling ddiPolling = new DdiPolling("10"); final DdiPolling ddiPolling = new DdiPolling("10");
@@ -44,9 +43,10 @@ class DdiPollingTest {
assertThat(deserializedDdiPolling.getSleep()).isEqualTo(ddiPolling.getSleep()); assertThat(deserializedDdiPolling.getSleep()).isEqualTo(ddiPolling.getSleep());
} }
@Test /**
@Description("Verify the correct deserialization of a model with a additional unknown property") * Verify the correct deserialization of a model with a additional unknown property
void shouldDeserializeObjectWithUnknownProperty() throws IOException { */
@Test void shouldDeserializeObjectWithUnknownProperty() throws IOException {
// Setup // Setup
final String serializedDdiPolling = "{\"sleep\":\"10\",\"unknownProperty\":\"test\"}"; final String serializedDdiPolling = "{\"sleep\":\"10\",\"unknownProperty\":\"test\"}";
@@ -55,9 +55,10 @@ class DdiPollingTest {
assertThat(ddiPolling.getSleep()).isEqualTo("10"); assertThat(ddiPolling.getSleep()).isEqualTo("10");
} }
@Test /**
@Description("Verify that deserialization fails for known properties with a wrong datatype") * Verify that deserialization fails for known properties with a wrong datatype
void shouldFailForObjectWithWrongDataTypes() { */
@Test void shouldFailForObjectWithWrongDataTypes() {
// Setup // Setup
final String serializedDdiPolling = "{\"sleep\":[\"10\"]}"; final String serializedDdiPolling = "{\"sleep\":[\"10\"]}";

View File

@@ -17,23 +17,22 @@ import java.io.IOException;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.exc.MismatchedInputException; import com.fasterxml.jackson.databind.exc.MismatchedInputException;
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
import io.qameta.allure.Story;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
/** /**
* Test serializability of DDI api model 'DdiProgress' * Test serializability of DDI api model 'DdiProgress'
* <p/>
* Feature: Unit Tests - Direct Device Integration API<br/>
* Story: Serializability of DDI api Models
*/ */
@Feature("Unit Tests - Direct Device Integration API")
@Story("Serializability of DDI api Models")
class DdiProgressTest { class DdiProgressTest {
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
@Test /**
@Description("Verify the correct serialization and deserialization of the model") * Verify the correct serialization and deserialization of the model
void shouldSerializeAndDeserializeObject() throws IOException { */
@Test void shouldSerializeAndDeserializeObject() throws IOException {
// Setup // Setup
final DdiProgress ddiProgress = new DdiProgress(30, 100); final DdiProgress ddiProgress = new DdiProgress(30, 100);
@@ -45,9 +44,10 @@ class DdiProgressTest {
assertThat(deserializedDdiProgress.getOf()).isEqualTo(ddiProgress.getOf()); assertThat(deserializedDdiProgress.getOf()).isEqualTo(ddiProgress.getOf());
} }
@Test /**
@Description("Verify the correct deserialization of a model with a additional unknown property") * Verify the correct deserialization of a model with a additional unknown property
void shouldDeserializeObjectWithUnknownProperty() throws IOException { */
@Test void shouldDeserializeObjectWithUnknownProperty() throws IOException {
// Setup // Setup
final String serializedDdiProgress = "{\"cnt\":30,\"of\":100,\"unknownProperty\":\"test\"}"; final String serializedDdiProgress = "{\"cnt\":30,\"of\":100,\"unknownProperty\":\"test\"}";
@@ -57,9 +57,10 @@ class DdiProgressTest {
assertThat(ddiProgress.getOf()).isEqualTo(100); assertThat(ddiProgress.getOf()).isEqualTo(100);
} }
@Test /**
@Description("Verify that deserialization fails for known properties with a wrong datatype") * Verify that deserialization fails for known properties with a wrong datatype
void shouldFailForObjectWithWrongDataTypes() { */
@Test void shouldFailForObjectWithWrongDataTypes() {
// Setup // Setup
final String serializedDdiProgress = "{\"cnt\":[30],\"of\":100}"; final String serializedDdiProgress = "{\"cnt\":[30],\"of\":100}";

View File

@@ -18,23 +18,22 @@ import java.io.IOException;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.exc.MismatchedInputException; import com.fasterxml.jackson.databind.exc.MismatchedInputException;
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
import io.qameta.allure.Story;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
/** /**
* Test serializability of DDI api model 'DdiResult' * Test serializability of DDI api model 'DdiResult'
* <p/>
* Feature: Unit Tests - Direct Device Integration API<br/>
* Story: Serializability of DDI api Models
*/ */
@Feature("Unit Tests - Direct Device Integration API")
@Story("Serializability of DDI api Models")
class DdiResultTest { class DdiResultTest {
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
@Test /**
@Description("Verify the correct serialization and deserialization of the model") * Verify the correct serialization and deserialization of the model
void shouldSerializeAndDeserializeObject() throws IOException { */
@Test void shouldSerializeAndDeserializeObject() throws IOException {
// Setup // Setup
final DdiProgress ddiProgress = new DdiProgress(30, 100); final DdiProgress ddiProgress = new DdiProgress(30, 100);
final DdiResult ddiResult = new DdiResult(NONE, ddiProgress); final DdiResult ddiResult = new DdiResult(NONE, ddiProgress);
@@ -48,9 +47,10 @@ class DdiResultTest {
assertThat(deserializedDdiResult.getProgress().getOf()).isEqualTo(ddiProgress.getOf()); assertThat(deserializedDdiResult.getProgress().getOf()).isEqualTo(ddiProgress.getOf());
} }
@Test /**
@Description("Verify the correct deserialization of a model with a additional unknown property") * Verify the correct deserialization of a model with a additional unknown property
void shouldDeserializeObjectWithUnknownProperty() throws IOException { */
@Test void shouldDeserializeObjectWithUnknownProperty() throws IOException {
// Setup // Setup
final String serializedDdiResult = "{\"finished\":\"none\",\"progress\":{\"cnt\":30,\"of\":100},\"unknownProperty\":\"test\"}"; final String serializedDdiResult = "{\"finished\":\"none\",\"progress\":{\"cnt\":30,\"of\":100},\"unknownProperty\":\"test\"}";
@@ -61,9 +61,10 @@ class DdiResultTest {
assertThat(ddiResult.getProgress().getOf()).isEqualTo(100); assertThat(ddiResult.getProgress().getOf()).isEqualTo(100);
} }
@Test /**
@Description("Verify that deserialization fails for known properties with a wrong datatype") * Verify that deserialization fails for known properties with a wrong datatype
void shouldFailForObjectWithWrongDataTypes() { */
@Test void shouldFailForObjectWithWrongDataTypes() {
// Setup // Setup
final String serializedDdiResult = "{\"finished\":[\"none\"],\"progress\":{\"cnt\":30,\"of\":100}}"; final String serializedDdiResult = "{\"finished\":[\"none\"],\"progress\":{\"cnt\":30,\"of\":100}}";

View File

@@ -21,9 +21,6 @@ import java.util.stream.Stream;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.exc.MismatchedInputException; import com.fasterxml.jackson.databind.exc.MismatchedInputException;
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
import io.qameta.allure.Story;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.Arguments;
@@ -31,16 +28,19 @@ import org.junit.jupiter.params.provider.MethodSource;
/** /**
* Test serializability of DDI api model 'DdiStatus' * Test serializability of DDI api model 'DdiStatus'
* <p/>
* Feature: Unit Tests - Direct Device Integration API<br/>
* Story: Serializability of DDI api Models
*/ */
@Feature("Unit Tests - Direct Device Integration API")
@Story("Serializability of DDI api Models")
class DdiStatusTest { class DdiStatusTest {
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
/**
* Verify the correct serialization and deserialization of the model
*/
@ParameterizedTest @ParameterizedTest
@MethodSource("ddiStatusPossibilities") @MethodSource("ddiStatusPossibilities")
@Description("Verify the correct serialization and deserialization of the model")
void shouldSerializeAndDeserializeObject(final DdiResult ddiResult, final DdiStatus ddiStatus) throws IOException { void shouldSerializeAndDeserializeObject(final DdiResult ddiResult, final DdiStatus ddiStatus) throws IOException {
// Test // Test
final String serializedDdiStatus = OBJECT_MAPPER.writeValueAsString(ddiStatus); final String serializedDdiStatus = OBJECT_MAPPER.writeValueAsString(ddiStatus);
@@ -54,9 +54,10 @@ class DdiStatusTest {
assertThat(deserializedDdiStatus.getDetails()).isEqualTo(ddiStatus.getDetails()); assertThat(deserializedDdiStatus.getDetails()).isEqualTo(ddiStatus.getDetails());
} }
@Test /**
@Description("Verify the correct deserialization of a model with a additional unknown property") * Verify the correct deserialization of a model with a additional unknown property
void shouldDeserializeObjectWithUnknownProperty() throws IOException { */
@Test void shouldDeserializeObjectWithUnknownProperty() throws IOException {
// Setup // Setup
final String serializedDdiStatus = "{\"execution\":\"proceeding\",\"result\":{\"finished\":\"none\"," + final String serializedDdiStatus = "{\"execution\":\"proceeding\",\"result\":{\"finished\":\"none\"," +
"\"progress\":{\"cnt\":30,\"of\":100}},\"details\":[],\"unknownProperty\":\"test\"}"; "\"progress\":{\"cnt\":30,\"of\":100}},\"details\":[],\"unknownProperty\":\"test\"}";
@@ -70,9 +71,10 @@ class DdiStatusTest {
assertThat(ddiStatus.getResult().getProgress().getOf()).isEqualTo(100); assertThat(ddiStatus.getResult().getProgress().getOf()).isEqualTo(100);
} }
@Test /**
@Description("Verify the correct deserialization of a model with a provided code (optional)") * Verify the correct deserialization of a model with a provided code (optional)
void shouldDeserializeObjectWithOptionalCode() throws IOException { */
@Test void shouldDeserializeObjectWithOptionalCode() throws IOException {
// Setup // Setup
final String serializedDdiStatus = "{\"execution\":\"proceeding\",\"result\":{\"finished\":\"none\"," + final String serializedDdiStatus = "{\"execution\":\"proceeding\",\"result\":{\"finished\":\"none\"," +
"\"progress\":{\"cnt\":30,\"of\":100}},\"code\": 12,\"details\":[]}"; "\"progress\":{\"cnt\":30,\"of\":100}},\"code\": 12,\"details\":[]}";
@@ -86,9 +88,10 @@ class DdiStatusTest {
assertThat(ddiStatus.getResult().getProgress().getOf()).isEqualTo(100); assertThat(ddiStatus.getResult().getProgress().getOf()).isEqualTo(100);
} }
@Test /**
@Description("Verify that deserialization fails for known properties with a wrong datatype") * Verify that deserialization fails for known properties with a wrong datatype
void shouldFailForObjectWithWrongDataTypes() { */
@Test void shouldFailForObjectWithWrongDataTypes() {
// Setup // Setup
final String serializedDdiStatus = "{\"execution\":[\"proceeding\"],\"result\":{\"finished\":\"none\"," + final String serializedDdiStatus = "{\"execution\":[\"proceeding\"],\"result\":{\"finished\":\"none\"," +
"\"progress\":{\"cnt\":30,\"of\":100}},\"details\":[]}"; "\"progress\":{\"cnt\":30,\"of\":100}},\"details\":[]}";

View File

@@ -18,21 +18,20 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.github.classgraph.ClassGraph; import io.github.classgraph.ClassGraph;
import io.github.classgraph.ClassInfo; import io.github.classgraph.ClassInfo;
import io.github.classgraph.ScanResult; import io.github.classgraph.ScanResult;
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
import io.qameta.allure.Story;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
/** /**
* Check DDI api model classes for '@JsonIgnoreProperties' annotation * Check DDI api model classes for '@JsonIgnoreProperties' annotation
* <p/>
* Feature: Unit Tests - Direct Device Integration API<br/>
* Story: Serialization of DDI api Models
*/ */
@Feature("Unit Tests - Direct Device Integration API")
@Story("Serialization of DDI api Models")
class JsonIgnorePropertiesAnnotationTest { class JsonIgnorePropertiesAnnotationTest {
@Test /**
@Description("This test verifies that all model classes within the 'org.eclipse.hawkbit.ddi.json.model' package are annotated with '@JsonIgnoreProperties(ignoreUnknown = true)'") * This test verifies that all model classes within the 'org.eclipse.hawkbit.ddi.json.model' package are annotated with '@JsonIgnoreProperties(ignoreUnknown = true)'
void shouldCheckAnnotationsForAllModelClasses() { */
@Test void shouldCheckAnnotationsForAllModelClasses() {
final String packageName = getClass().getPackage().getName(); final String packageName = getClass().getPackage().getName();
try (final ScanResult scanResult = new ClassGraph().acceptPackages(packageName).scan()) { try (final ScanResult scanResult = new ClassGraph().acceptPackages(packageName).scan()) {
final List<? extends Class<?>> matchingClasses = scanResult.getAllClasses() final List<? extends Class<?>> matchingClasses = scanResult.getAllClasses()

View File

@@ -30,9 +30,6 @@ import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.TimeZone; import java.util.TimeZone;
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
import io.qameta.allure.Story;
import org.eclipse.hawkbit.ddi.rest.resource.DdiArtifactDownloadTest.DownloadTestConfiguration; import org.eclipse.hawkbit.ddi.rest.resource.DdiArtifactDownloadTest.DownloadTestConfiguration;
import org.eclipse.hawkbit.repository.event.remote.DownloadProgressEvent; import org.eclipse.hawkbit.repository.event.remote.DownloadProgressEvent;
import org.eclipse.hawkbit.repository.model.Artifact; import org.eclipse.hawkbit.repository.model.Artifact;
@@ -53,9 +50,10 @@ import org.springframework.test.web.servlet.MvcResult;
/** /**
* Test artifact downloads from the controller. * Test artifact downloads from the controller.
* <p/>
* Feature: Component Tests - Direct Device Integration API<br/>
* Story: Artifact Download Resource
*/ */
@Feature("Component Tests - Direct Device Integration API")
@Story("Artifact Download Resource")
@SpringBootTest(classes = { DownloadTestConfiguration.class }) @SpringBootTest(classes = { DownloadTestConfiguration.class })
class DdiArtifactDownloadTest extends AbstractDDiApiIntegrationTest { class DdiArtifactDownloadTest extends AbstractDDiApiIntegrationTest {
@@ -69,9 +67,10 @@ class DdiArtifactDownloadTest extends AbstractDDiApiIntegrationTest {
dateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
} }
@Test /**
@Description("Tests non allowed requests on the artifact ressource, e.g. invalid URI, wrong if-match, wrong command.") * Tests non allowed requests on the artifact ressource, e.g. invalid URI, wrong if-match, wrong command.
void invalidRequestsOnArtifactResource() throws Exception { */
@Test void invalidRequestsOnArtifactResource() throws Exception {
// create target // create target
final Target target = testdataFactory.createTarget(); final Target target = testdataFactory.createTarget();
final List<Target> targets = Collections.singletonList(target); final List<Target> targets = Collections.singletonList(target);
@@ -157,9 +156,11 @@ class DdiArtifactDownloadTest extends AbstractDDiApiIntegrationTest {
.andExpect(status().isMethodNotAllowed()); .andExpect(status().isMethodNotAllowed());
} }
/**
* Tests valid downloads through the artifact resource by identifying the artifact not by ID but file name.
*/
@Test @Test
@WithUser(principal = "4712", authorities = "ROLE_CONTROLLER", allSpPermissions = true) @WithUser(principal = "4712", authorities = "ROLE_CONTROLLER", allSpPermissions = true)
@Description("Tests valid downloads through the artifact resource by identifying the artifact not by ID but file name.")
void downloadArtifactThroughFileName() throws Exception { void downloadArtifactThroughFileName() throws Exception {
downloadProgress = 1; downloadProgress = 1;
shippedBytes = 0; shippedBytes = 0;
@@ -203,9 +204,10 @@ class DdiArtifactDownloadTest extends AbstractDDiApiIntegrationTest {
assertThat(shippedBytes).isEqualTo(artifactSize); assertThat(shippedBytes).isEqualTo(artifactSize);
} }
@Test /**
@Description("Tests valid MD5SUm file downloads through the artifact resource by identifying the artifact by ID.") * Tests valid MD5SUm file downloads through the artifact resource by identifying the artifact by ID.
void downloadMd5sumThroughControllerApi() throws Exception { */
@Test void downloadMd5sumThroughControllerApi() throws Exception {
// create target // create target
final Target target = testdataFactory.createTarget(); final Target target = testdataFactory.createTarget();
@@ -233,9 +235,11 @@ class DdiArtifactDownloadTest extends AbstractDDiApiIntegrationTest {
.isEqualTo((artifact.getMd5Hash() + " " + artifact.getFilename()).getBytes(StandardCharsets.US_ASCII)); .isEqualTo((artifact.getMd5Hash() + " " + artifact.getFilename()).getBytes(StandardCharsets.US_ASCII));
} }
/**
* Test various HTTP range requests for artifact download, e.g. chunk download or download resume.
*/
@Test @Test
@WithUser(principal = TestdataFactory.DEFAULT_CONTROLLER_ID, authorities = "ROLE_CONTROLLER", allSpPermissions = true) @WithUser(principal = TestdataFactory.DEFAULT_CONTROLLER_ID, authorities = "ROLE_CONTROLLER", allSpPermissions = true)
@Description("Test various HTTP range requests for artifact download, e.g. chunk download or download resume.")
void rangeDownloadArtifact() throws Exception { void rangeDownloadArtifact() throws Exception {
// create target // create target
final Target target = testdataFactory.createTarget(); final Target target = testdataFactory.createTarget();

View File

@@ -25,9 +25,6 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
import io.qameta.allure.Story;
import org.eclipse.hawkbit.ddi.json.model.DdiResult; import org.eclipse.hawkbit.ddi.json.model.DdiResult;
import org.eclipse.hawkbit.ddi.json.model.DdiStatus; import org.eclipse.hawkbit.ddi.json.model.DdiStatus;
import org.eclipse.hawkbit.ddi.rest.api.DdiRestConstants; import org.eclipse.hawkbit.ddi.rest.api.DdiRestConstants;
@@ -46,17 +43,19 @@ import org.springframework.integration.json.JsonPathUtils;
/** /**
* Test cancel action from the controller. * Test cancel action from the controller.
* <p/>
* Feature: Component Tests - Direct Device Integration API<br/>
* Story: Cancel Action Resource
*/ */
@Feature("Component Tests - Direct Device Integration API")
@Story("Cancel Action Resource")
class DdiCancelActionTest extends AbstractDDiApiIntegrationTest { class DdiCancelActionTest extends AbstractDDiApiIntegrationTest {
@Autowired @Autowired
ActionStatusRepository actionStatusRepository; ActionStatusRepository actionStatusRepository;
@Test /**
@Description("Tests that the cancel action resource can be used with CBOR.") * Tests that the cancel action resource can be used with CBOR.
void cancelActionCbor() throws Exception { */
@Test void cancelActionCbor() throws Exception {
final DistributionSet ds = testdataFactory.createDistributionSet(""); final DistributionSet ds = testdataFactory.createDistributionSet("");
testdataFactory.createTarget(); testdataFactory.createTarget();
final Long actionId = getFirstAssignedActionId( final Long actionId = getFirstAssignedActionId(
@@ -87,9 +86,10 @@ class DdiCancelActionTest extends AbstractDDiApiIntegrationTest {
.andExpect(status().isOk()); .andExpect(status().isOk());
} }
@Test /**
@Description("Test of the controller can continue a started update even after a cancel command if it so desires.") * Test of the controller can continue a started update even after a cancel command if it so desires.
void rootRsCancelActionButContinueAnyway() throws Exception { */
@Test void rootRsCancelActionButContinueAnyway() throws Exception {
// prepare test data // prepare test data
final DistributionSet ds = testdataFactory.createDistributionSet(""); final DistributionSet ds = testdataFactory.createDistributionSet("");
final Target savedTarget = testdataFactory.createTarget(); final Target savedTarget = testdataFactory.createTarget();
@@ -147,9 +147,10 @@ class DdiCancelActionTest extends AbstractDDiApiIntegrationTest {
} }
@Test /**
@Description("Test for cancel operation of a update action.") * Test for cancel operation of a update action.
void rootRsCancelAction() throws Exception { */
@Test void rootRsCancelAction() throws Exception {
final DistributionSet ds = testdataFactory.createDistributionSet(""); final DistributionSet ds = testdataFactory.createDistributionSet("");
final Target savedTarget = testdataFactory.createTarget(); final Target savedTarget = testdataFactory.createTarget();
@@ -228,9 +229,10 @@ class DdiCancelActionTest extends AbstractDDiApiIntegrationTest {
} }
@Test /**
@Description("Tests various bad requests and if the server handles them as expected.") * Tests various bad requests and if the server handles them as expected.
void badCancelAction() throws Exception { */
@Test void badCancelAction() throws Exception {
// not allowed methods // not allowed methods
mvc.perform(post("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/cancelAction/1", mvc.perform(post("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/cancelAction/1",
@@ -264,9 +266,10 @@ class DdiCancelActionTest extends AbstractDDiApiIntegrationTest {
} }
@Test /**
@Description("Tests the feedback channel of the cancel operation.") * Tests the feedback channel of the cancel operation.
void rootRsCancelActionFeedback() throws Exception { */
@Test void rootRsCancelActionFeedback() throws Exception {
final DistributionSet ds = testdataFactory.createDistributionSet(""); final DistributionSet ds = testdataFactory.createDistributionSet("");
@@ -344,9 +347,10 @@ class DdiCancelActionTest extends AbstractDDiApiIntegrationTest {
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE)).isEmpty(); assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId(), PAGE)).isEmpty();
} }
@Test /**
@Description("Tests the feeback chanel of for multiple open cancel operations on the same target.") * Tests the feeback chanel of for multiple open cancel operations on the same target.
void multipleCancelActionFeedback() throws Exception { */
@Test void multipleCancelActionFeedback() throws Exception {
final DistributionSet ds = testdataFactory.createDistributionSet("", true); final DistributionSet ds = testdataFactory.createDistributionSet("", true);
final DistributionSet ds2 = testdataFactory.createDistributionSet("2", true); final DistributionSet ds2 = testdataFactory.createDistributionSet("2", true);
final DistributionSet ds3 = testdataFactory.createDistributionSet("3", true); final DistributionSet ds3 = testdataFactory.createDistributionSet("3", true);
@@ -475,9 +479,10 @@ class DdiCancelActionTest extends AbstractDDiApiIntegrationTest {
assertThat(deploymentManagement.countActionsByTarget(savedTarget.getControllerId())).isEqualTo(3); assertThat(deploymentManagement.countActionsByTarget(savedTarget.getControllerId())).isEqualTo(3);
} }
@Test /**
@Description("Tests the feeback channel closing for too many feedbacks, i.e. denial of service prevention.") * Tests the feeback channel closing for too many feedbacks, i.e. denial of service prevention.
void tooMuchCancelActionFeedback() throws Exception { */
@Test void tooMuchCancelActionFeedback() throws Exception {
testdataFactory.createTarget(); testdataFactory.createTarget();
final DistributionSet ds = testdataFactory.createDistributionSet(""); final DistributionSet ds = testdataFactory.createDistributionSet("");
@@ -503,9 +508,10 @@ class DdiCancelActionTest extends AbstractDDiApiIntegrationTest {
.andExpect(status().isForbidden()); .andExpect(status().isForbidden());
} }
@Test /**
@Description("test the correct rejection of various invalid feedback requests") * test the correct rejection of various invalid feedback requests
void badCancelActionFeedback() throws Exception { */
@Test void badCancelActionFeedback() throws Exception {
final Action cancelAction = createCancelAction(TestdataFactory.DEFAULT_CONTROLLER_ID); final Action cancelAction = createCancelAction(TestdataFactory.DEFAULT_CONTROLLER_ID);
createCancelAction("4715"); createCancelAction("4715");

View File

@@ -28,10 +28,6 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
import io.qameta.allure.Step;
import io.qameta.allure.Story;
import org.eclipse.hawkbit.ddi.rest.api.DdiRestConstants; import org.eclipse.hawkbit.ddi.rest.api.DdiRestConstants;
import org.eclipse.hawkbit.exception.SpServerError; import org.eclipse.hawkbit.exception.SpServerError;
import org.eclipse.hawkbit.repository.exception.AssignmentQuotaExceededException; import org.eclipse.hawkbit.repository.exception.AssignmentQuotaExceededException;
@@ -48,8 +44,10 @@ import org.springframework.test.context.ActiveProfiles;
* Test config data from the controller. * Test config data from the controller.
*/ */
@ActiveProfiles({ "im", "test" }) @ActiveProfiles({ "im", "test" })
@Feature("Component Tests - Direct Device Integration API") /**
@Story("Config Data Resource") * Feature: Component Tests - Direct Device Integration API<br/>
* Story: Config Data Resource
*/
class DdiConfigDataTest extends AbstractDDiApiIntegrationTest { class DdiConfigDataTest extends AbstractDDiApiIntegrationTest {
private static final String TARGET1_ID = "4717"; private static final String TARGET1_ID = "4717";
@@ -57,9 +55,10 @@ class DdiConfigDataTest extends AbstractDDiApiIntegrationTest {
private static final String TARGET2_ID = "4718"; private static final String TARGET2_ID = "4718";
private static final String TARGET2_CONFIG_DATA_PATH = "/{tenant}/controller/v1/" + TARGET2_ID + "/configData"; private static final String TARGET2_CONFIG_DATA_PATH = "/{tenant}/controller/v1/" + TARGET2_ID + "/configData";
@Test /**
@Description("Verify that config data can be uploaded as CBOR") * Verify that config data can be uploaded as CBOR
void putConfigDataAsCbor() throws Exception { */
@Test void putConfigDataAsCbor() throws Exception {
testdataFactory.createTarget(TARGET1_ID); testdataFactory.createTarget(TARGET1_ID);
final Map<String, String> attributes = new HashMap<>(); final Map<String, String> attributes = new HashMap<>();
@@ -73,9 +72,11 @@ class DdiConfigDataTest extends AbstractDDiApiIntegrationTest {
assertThat(targetManagement.getControllerAttributes(TARGET1_ID)).isEqualTo(attributes); assertThat(targetManagement.getControllerAttributes(TARGET1_ID)).isEqualTo(attributes);
} }
@Test @Test
@Description("We verify that the config data (i.e. device attributes like serial number, hardware revision etc.) " + /**
"are requested only once from the device.") * We verify that the config data (i.e. device attributes like serial number, hardware revision etc.) are requested only once from the device.")
*/
@SuppressWarnings("squid:S2925") @SuppressWarnings("squid:S2925")
void requestConfigDataIfEmpty() throws Exception { void requestConfigDataIfEmpty() throws Exception {
final Target savedTarget = testdataFactory.createTarget("4712"); final Target savedTarget = testdataFactory.createTarget("4712");
@@ -111,9 +112,11 @@ class DdiConfigDataTest extends AbstractDDiApiIntegrationTest {
.andExpect(jsonPath("$._links.configData.href").doesNotExist()); .andExpect(jsonPath("$._links.configData.href").doesNotExist());
} }
/**
* We verify that the config data (i.e. device attributes like serial number, hardware revision etc.)
* can be uploaded correctly by the controller.
*/
@Test @Test
@Description("We verify that the config data (i.e. device attributes like serial number, hardware revision etc.) " +
"can be uploaded correctly by the controller.")
void putConfigData() throws Exception { void putConfigData() throws Exception {
testdataFactory.createTarget(TARGET1_ID); testdataFactory.createTarget(TARGET1_ID);
@@ -136,10 +139,11 @@ class DdiConfigDataTest extends AbstractDDiApiIntegrationTest {
assertThat(targetManagement.getControllerAttributes(TARGET1_ID)).isEqualTo(attributes); assertThat(targetManagement.getControllerAttributes(TARGET1_ID)).isEqualTo(attributes);
} }
/**
* We verify that the config data (i.e. device attributes like serial number, hardware revision etc.)
* upload quota is enforced to protect the server from malicious attempts.""")
*/
@Test @Test
@Description("""
We verify that the config data (i.e. device attributes like serial number, hardware revision etc.)
upload quota is enforced to protect the server from malicious attempts.""")
void putTooMuchConfigData() throws Exception { void putTooMuchConfigData() throws Exception {
testdataFactory.createTarget(TARGET1_ID); testdataFactory.createTarget(TARGET1_ID);
@@ -161,9 +165,11 @@ class DdiConfigDataTest extends AbstractDDiApiIntegrationTest {
.andExpect(jsonPath("$.errorCode", equalTo(SpServerError.SP_QUOTA_EXCEEDED.getKey()))); .andExpect(jsonPath("$.errorCode", equalTo(SpServerError.SP_QUOTA_EXCEEDED.getKey())));
} }
/**
* We verify that the config data (i.e. device attributes like serial number, hardware revision etc.)
* resource behaves as expected in case of invalid request attempts.
*/
@Test @Test
@Description("We verify that the config data (i.e. device attributes like serial number, hardware revision etc.) "
+ "resource behaves as expected in case of invalid request attempts.")
void badConfigData() throws Exception { void badConfigData() throws Exception {
testdataFactory.createTarget("4712"); testdataFactory.createTarget("4712");
@@ -200,18 +206,20 @@ class DdiConfigDataTest extends AbstractDDiApiIntegrationTest {
.andExpect(status().isBadRequest()); .andExpect(status().isBadRequest());
} }
@Test /**
@Description("Verifies that invalid config data attributes are handled correctly.") * Verifies that invalid config data attributes are handled correctly.
void putConfigDataWithInvalidAttributes() throws Exception { */
@Test void putConfigDataWithInvalidAttributes() throws Exception {
// create a target // create a target
testdataFactory.createTarget(TARGET2_ID); testdataFactory.createTarget(TARGET2_ID);
putAndVerifyConfigDataWithKeyTooLong(); putAndVerifyConfigDataWithKeyTooLong();
putAndVerifyConfigDataWithValueTooLong(); putAndVerifyConfigDataWithValueTooLong();
} }
@Test /**
@Description("Verify that config data (device attributes) can be updated by the controller using different update modes (merge, replace, remove).") * Verify that config data (device attributes) can be updated by the controller using different update modes (merge, replace, remove).
void putConfigDataWithDifferentUpdateModes() throws Exception { */
@Test void putConfigDataWithDifferentUpdateModes() throws Exception {
// create a target // create a target
testdataFactory.createTarget(TARGET1_ID); testdataFactory.createTarget(TARGET1_ID);
@@ -231,7 +239,6 @@ class DdiConfigDataTest extends AbstractDDiApiIntegrationTest {
putConfigDataWithInvalidUpdateMode(); putConfigDataWithInvalidUpdateMode();
} }
@Step
private void putAndVerifyConfigDataWithKeyTooLong() throws Exception { private void putAndVerifyConfigDataWithKeyTooLong() throws Exception {
final Map<String, String> attributes = Collections.singletonMap(ATTRIBUTE_KEY_TOO_LONG, ATTRIBUTE_VALUE_VALID); final Map<String, String> attributes = Collections.singletonMap(ATTRIBUTE_KEY_TOO_LONG, ATTRIBUTE_VALUE_VALID);
mvc.perform(put(DdiConfigDataTest.TARGET2_CONFIG_DATA_PATH, tenantAware.getCurrentTenant()) mvc.perform(put(DdiConfigDataTest.TARGET2_CONFIG_DATA_PATH, tenantAware.getCurrentTenant())
@@ -241,7 +248,6 @@ class DdiConfigDataTest extends AbstractDDiApiIntegrationTest {
.andExpect(jsonPath("$.errorCode", equalTo(SpServerError.SP_TARGET_ATTRIBUTES_INVALID.getKey()))); .andExpect(jsonPath("$.errorCode", equalTo(SpServerError.SP_TARGET_ATTRIBUTES_INVALID.getKey())));
} }
@Step
private void putAndVerifyConfigDataWithValueTooLong() throws Exception { private void putAndVerifyConfigDataWithValueTooLong() throws Exception {
final Map<String, String> attributes = Collections.singletonMap(ATTRIBUTE_KEY_VALID, ATTRIBUTE_VALUE_TOO_LONG); final Map<String, String> attributes = Collections.singletonMap(ATTRIBUTE_KEY_VALID, ATTRIBUTE_VALUE_TOO_LONG);
mvc.perform(put(DdiConfigDataTest.TARGET2_CONFIG_DATA_PATH, tenantAware.getCurrentTenant()) mvc.perform(put(DdiConfigDataTest.TARGET2_CONFIG_DATA_PATH, tenantAware.getCurrentTenant())
@@ -251,7 +257,6 @@ class DdiConfigDataTest extends AbstractDDiApiIntegrationTest {
.andExpect(jsonPath("$.errorCode", equalTo(SpServerError.SP_TARGET_ATTRIBUTES_INVALID.getKey()))); .andExpect(jsonPath("$.errorCode", equalTo(SpServerError.SP_TARGET_ATTRIBUTES_INVALID.getKey())));
} }
@Step
private void putConfigDataWithInvalidUpdateMode() throws Exception { private void putConfigDataWithInvalidUpdateMode() throws Exception {
// create some attriutes // create some attriutes
final Map<String, String> attributes = Map.of( final Map<String, String> attributes = Map.of(
@@ -266,7 +271,6 @@ class DdiConfigDataTest extends AbstractDDiApiIntegrationTest {
.andExpect(status().isBadRequest()); .andExpect(status().isBadRequest());
} }
@Step
private void putConfigDataWithUpdateModeRemove() throws Exception { private void putConfigDataWithUpdateModeRemove() throws Exception {
// get the current attributes // get the current attributes
final int previousSize = targetManagement.getControllerAttributes(DdiConfigDataTest.TARGET1_ID).size(); final int previousSize = targetManagement.getControllerAttributes(DdiConfigDataTest.TARGET1_ID).size();
@@ -290,7 +294,6 @@ class DdiConfigDataTest extends AbstractDDiApiIntegrationTest {
} }
@Step
private void putConfigDataWithUpdateModeMerge() throws Exception { private void putConfigDataWithUpdateModeMerge() throws Exception {
// get the current attributes // get the current attributes
final Map<String, String> attributes = new HashMap<>(targetManagement.getControllerAttributes(DdiConfigDataTest.TARGET1_ID)); final Map<String, String> attributes = new HashMap<>(targetManagement.getControllerAttributes(DdiConfigDataTest.TARGET1_ID));
@@ -313,7 +316,6 @@ class DdiConfigDataTest extends AbstractDDiApiIntegrationTest {
attributes.keySet().forEach(assertThat(updatedAttributes)::containsKey); attributes.keySet().forEach(assertThat(updatedAttributes)::containsKey);
} }
@Step
private void putConfigDataWithUpdateModeReplace() throws Exception { private void putConfigDataWithUpdateModeReplace() throws Exception {
// get the current attributes // get the current attributes
final Map<String, String> attributes = new HashMap<>(targetManagement.getControllerAttributes(DdiConfigDataTest.TARGET1_ID)); final Map<String, String> attributes = new HashMap<>(targetManagement.getControllerAttributes(DdiConfigDataTest.TARGET1_ID));
@@ -337,7 +339,6 @@ class DdiConfigDataTest extends AbstractDDiApiIntegrationTest {
attributes.entrySet().forEach(assertThat(updatedAttributes)::doesNotContain); attributes.entrySet().forEach(assertThat(updatedAttributes)::doesNotContain);
} }
@Step
private void putConfigDataWithoutUpdateMode() throws Exception { private void putConfigDataWithoutUpdateMode() throws Exception {
// create some attributes // create some attributes
final Map<String, String> attributes = Map.of( final Map<String, String> attributes = Map.of(

View File

@@ -23,10 +23,6 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.stream.Stream; import java.util.stream.Stream;
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
import io.qameta.allure.Step;
import io.qameta.allure.Story;
import org.eclipse.hawkbit.ddi.json.model.DdiActivateAutoConfirmation; import org.eclipse.hawkbit.ddi.json.model.DdiActivateAutoConfirmation;
import org.eclipse.hawkbit.ddi.json.model.DdiConfirmationFeedback; import org.eclipse.hawkbit.ddi.json.model.DdiConfirmationFeedback;
import org.eclipse.hawkbit.ddi.rest.api.DdiRestConstants; import org.eclipse.hawkbit.ddi.rest.api.DdiRestConstants;
@@ -63,16 +59,18 @@ import org.springframework.test.web.servlet.ResultActions;
/** /**
* Test confirmation base from the controller. * Test confirmation base from the controller.
* <p/>
* Feature: Component Tests - Direct Device Integration API<br/>
* Story: Confirmation Action Resource
*/ */
@Feature("Component Tests - Direct Device Integration API")
@Story("Confirmation Action Resource")
class DdiConfirmationBaseTest extends AbstractDDiApiIntegrationTest { class DdiConfirmationBaseTest extends AbstractDDiApiIntegrationTest {
private static final String DEFAULT_CONTROLLER_ID = "4747"; private static final String DEFAULT_CONTROLLER_ID = "4747";
@Test /**
@Description("Forced deployment to a controller. Checks if the confirmation resource response payload for a given deployment is as expected.") * Forced deployment to a controller. Checks if the confirmation resource response payload for a given deployment is as expected.
void verifyConfirmationReferencesInControllerBase(@Autowired ActionStatusRepository actionStatusRepository) throws Exception { */
@Test void verifyConfirmationReferencesInControllerBase(@Autowired ActionStatusRepository actionStatusRepository) throws Exception {
enableConfirmationFlow(); enableConfirmationFlow();
// Prepare test data // Prepare test data
final DistributionSet ds = testdataFactory.createDistributionSet("", true); final DistributionSet ds = testdataFactory.createDistributionSet("", true);
@@ -134,9 +132,10 @@ class DdiConfirmationBaseTest extends AbstractDDiApiIntegrationTest {
.allMatch(status -> status.getStatus() == Action.Status.WAIT_FOR_CONFIRMATION); .allMatch(status -> status.getStatus() == Action.Status.WAIT_FOR_CONFIRMATION);
} }
@Test /**
@Description("Ensure that the deployment resource is available as CBOR") * Ensure that the deployment resource is available as CBOR
void confirmationResourceCbor() throws Exception { */
@Test void confirmationResourceCbor() throws Exception {
enableConfirmationFlow(); enableConfirmationFlow();
final Target target = testdataFactory.createTarget(); final Target target = testdataFactory.createTarget();
final DistributionSet distributionSet = testdataFactory.createDistributionSet(""); final DistributionSet distributionSet = testdataFactory.createDistributionSet("");
@@ -158,9 +157,10 @@ class DdiConfirmationBaseTest extends AbstractDDiApiIntegrationTest {
String.valueOf(softwareModuleId)); String.valueOf(softwareModuleId));
} }
@Test /**
@Description("Ensure that the confirmation endpoint is not available.") * Ensure that the confirmation endpoint is not available.
void confirmationEndpointNotExposed() throws Exception { */
@Test void confirmationEndpointNotExposed() throws Exception {
final DistributionSet ds = testdataFactory.createDistributionSet(""); final DistributionSet ds = testdataFactory.createDistributionSet("");
Target savedTarget = testdataFactory.createTarget("988"); Target savedTarget = testdataFactory.createTarget("988");
savedTarget = getFirstAssignedTarget(assignDistributionSet(ds.getId(), savedTarget.getControllerId())); savedTarget = getFirstAssignedTarget(assignDistributionSet(ds.getId(), savedTarget.getControllerId()));
@@ -179,9 +179,10 @@ class DdiConfirmationBaseTest extends AbstractDDiApiIntegrationTest {
.andExpect(status().isNotFound()); .andExpect(status().isNotFound());
} }
@Test /**
@Description("Ensure that the deploymentBase endpoint is not available for action ins WFC state.") * Ensure that the deploymentBase endpoint is not available for action ins WFC state.
void deploymentEndpointNotAccessibleForActionsWFC() throws Exception { */
@Test void deploymentEndpointNotAccessibleForActionsWFC() throws Exception {
enableConfirmationFlow(); enableConfirmationFlow();
final DistributionSet ds = testdataFactory.createDistributionSet(""); final DistributionSet ds = testdataFactory.createDistributionSet("");
@@ -208,9 +209,10 @@ class DdiConfirmationBaseTest extends AbstractDDiApiIntegrationTest {
.andExpect(status().isNotFound()); .andExpect(status().isNotFound());
} }
@Test /**
@Description("Ensure that the confirmation endpoints are still available after deactivating the confirmation flow.") * Ensure that the confirmation endpoints are still available after deactivating the confirmation flow.
void verifyConfirmationBaseEndpointsArePresentAfterDisablingConfirmationFlow() throws Exception { */
@Test void verifyConfirmationBaseEndpointsArePresentAfterDisablingConfirmationFlow() throws Exception {
enableConfirmationFlow(); enableConfirmationFlow();
final DistributionSet ds = testdataFactory.createDistributionSet(""); final DistributionSet ds = testdataFactory.createDistributionSet("");
@@ -244,9 +246,10 @@ class DdiConfirmationBaseTest extends AbstractDDiApiIntegrationTest {
verifyActionInDeploymentBaseState(controllerId, savedAction.getId()); verifyActionInDeploymentBaseState(controllerId, savedAction.getId());
} }
@Test /**
@Description("Controller sends a confirmed action state.") * Controller sends a confirmed action state.
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@@ -279,9 +282,10 @@ class DdiConfirmationBaseTest extends AbstractDDiApiIntegrationTest {
verifyActionInDeploymentBaseState(controllerId, savedAction.getId()); verifyActionInDeploymentBaseState(controllerId, savedAction.getId());
} }
@Test /**
@Description("Confirmation base provides right values if auto-confirm not active.") * Confirmation base provides right values if auto-confirm not active.
void getConfirmationBaseProvidesAutoConfirmStatusNotActive() throws Exception { */
@Test void getConfirmationBaseProvidesAutoConfirmStatusNotActive() throws Exception {
enableConfirmationFlow(); enableConfirmationFlow();
final String controllerId = testdataFactory.createTarget("989").getControllerId(); final String controllerId = testdataFactory.createTarget("989").getControllerId();
@@ -305,9 +309,11 @@ class DdiConfirmationBaseTest extends AbstractDDiApiIntegrationTest {
.andExpect(jsonPath("$._links.deactivateAutoConfirm").doesNotExist()); .andExpect(jsonPath("$._links.deactivateAutoConfirm").doesNotExist());
} }
/**
* Confirmation base provides right values if auto-confirm is active.
*/
@ParameterizedTest @ParameterizedTest
@MethodSource("possibleActiveStates") @MethodSource("possibleActiveStates")
@Description("Confirmation base provides right values if auto-confirm is active.")
void getConfirmationBaseProvidesAutoConfirmStatusActive(final String initiator, final String remark) throws Exception { void getConfirmationBaseProvidesAutoConfirmStatusActive(final String initiator, final String remark) throws Exception {
final String controllerId = testdataFactory.createTarget("988").getControllerId(); final String controllerId = testdataFactory.createTarget("988").getControllerId();
@@ -331,9 +337,11 @@ class DdiConfirmationBaseTest extends AbstractDDiApiIntegrationTest {
.andExpect(jsonPath("$._links.activateAutoConfirm").doesNotExist()); .andExpect(jsonPath("$._links.activateAutoConfirm").doesNotExist());
} }
/**
* Verify auto-confirm activation is handled correctly.
*/
@ParameterizedTest @ParameterizedTest
@MethodSource("possibleActiveStates") @MethodSource("possibleActiveStates")
@Description("Verify auto-confirm activation is handled correctly.")
void activateAutoConfirmation(final String initiator, final String remark) throws Exception { void activateAutoConfirmation(final String initiator, final String remark) throws Exception {
final String controllerId = testdataFactory.createTarget("988").getControllerId(); final String controllerId = testdataFactory.createTarget("988").getControllerId();
@@ -351,9 +359,10 @@ class DdiConfirmationBaseTest extends AbstractDDiApiIntegrationTest {
}); });
} }
@Test /**
@Description("Verify auto-confirm deactivation is handled correctly.") * Verify auto-confirm deactivation is handled correctly.
void deactivateAutoConfirmation() throws Exception { */
@Test void deactivateAutoConfirmation() throws Exception {
final String controllerId = testdataFactory.createTarget("988").getControllerId(); final String controllerId = testdataFactory.createTarget("988").getControllerId();
confirmationManagement.activateAutoConfirmation(controllerId, null, null); confirmationManagement.activateAutoConfirmation(controllerId, null, null);
@@ -365,9 +374,10 @@ class DdiConfirmationBaseTest extends AbstractDDiApiIntegrationTest {
assertThat(confirmationManagement.getStatus(controllerId)).isEmpty(); assertThat(confirmationManagement.getStatus(controllerId)).isEmpty();
} }
@Test /**
@Description("Controller sends a denied action state.") * Controller sends a denied action state.
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@@ -410,9 +420,10 @@ class DdiConfirmationBaseTest extends AbstractDDiApiIntegrationTest {
.andExpect(status().isNotFound()); .andExpect(status().isNotFound());
} }
@Test /**
@Description("Test to verify that only a specific count of messages are returned based on the input actionHistory for getControllerDeploymentActionFeedback endpoint.") * Test to verify that only a specific count of messages are returned based on the input actionHistory for getControllerDeploymentActionFeedback endpoint.
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@@ -464,7 +475,6 @@ class DdiConfirmationBaseTest extends AbstractDDiApiIntegrationTest {
Arguments.of(null, null)); Arguments.of(null, null));
} }
@Step
private void verifyActionInDeploymentBaseState(final String controllerId, final long actionId) throws Exception { private void verifyActionInDeploymentBaseState(final String controllerId, final long actionId) throws Exception {
final String expectedDeploymentBaseLink = String.format( final String expectedDeploymentBaseLink = String.format(
"/%s/controller/v1/%s/deploymentBase/%d", "/%s/controller/v1/%s/deploymentBase/%d",
@@ -482,7 +492,6 @@ class DdiConfirmationBaseTest extends AbstractDDiApiIntegrationTest {
.andExpect(status().isOk()); .andExpect(status().isOk());
} }
@Step
private void verifyActionInConfirmationBaseState(final String controllerId, final long actionId) throws Exception { private void verifyActionInConfirmationBaseState(final String controllerId, final long actionId) throws Exception {
mvc.perform(get(CONTROLLER_BASE, tenantAware.getCurrentTenant(), controllerId).accept(MediaType.APPLICATION_JSON)) mvc.perform(get(CONTROLLER_BASE, tenantAware.getCurrentTenant(), controllerId).accept(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print()) .andDo(MockMvcResultPrinter.print())

View File

@@ -26,9 +26,6 @@ import java.util.Optional;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import com.jayway.jsonpath.JsonPath; import com.jayway.jsonpath.JsonPath;
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
import io.qameta.allure.Story;
import org.assertj.core.api.Condition; import org.assertj.core.api.Condition;
import org.eclipse.hawkbit.ddi.json.model.DdiResult; import org.eclipse.hawkbit.ddi.json.model.DdiResult;
import org.eclipse.hawkbit.ddi.json.model.DdiStatus; import org.eclipse.hawkbit.ddi.json.model.DdiStatus;
@@ -70,9 +67,10 @@ import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
/** /**
* Test deployment base from the controller. * Test deployment base from the controller.
* <p/>
* Feature: Component Tests - Direct Device Integration API<br/>
* Story: Deployment Action Resource
*/ */
@Feature("Component Tests - Direct Device Integration API")
@Story("Deployment Action Resource")
class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest { class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
private static final String DEFAULT_CONTROLLER_ID = "4712"; private static final String DEFAULT_CONTROLLER_ID = "4712";
@@ -82,9 +80,10 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
@Autowired @Autowired
private ActionStatusRepository actionStatusRepository; private ActionStatusRepository actionStatusRepository;
@Test /**
@Description("Ensure that the deployment resource is available as CBOR") * Ensure that the deployment resource is available as CBOR
void deploymentResourceCbor() throws Exception { */
@Test void deploymentResourceCbor() throws Exception {
final Target target = testdataFactory.createTarget(); final Target target = testdataFactory.createTarget();
final DistributionSet distributionSet = testdataFactory.createDistributionSet(""); final DistributionSet distributionSet = testdataFactory.createDistributionSet("");
@@ -109,17 +108,19 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
status().isOk()); status().isOk());
} }
@Test /**
@Description("Ensures that artifacts are not found, when software module does not exists.") * Ensures that artifacts are not found, when software module does not exists.
void artifactsNotFound() throws Exception { */
@Test void artifactsNotFound() throws Exception {
final Target target = testdataFactory.createTarget(); final Target target = testdataFactory.createTarget();
performGet(SOFTWARE_MODULE_ARTIFACTS, MediaType.APPLICATION_JSON, status().isNotFound(), tenantAware.getCurrentTenant(), performGet(SOFTWARE_MODULE_ARTIFACTS, MediaType.APPLICATION_JSON, status().isNotFound(), tenantAware.getCurrentTenant(),
target.getControllerId(), "1"); target.getControllerId(), "1");
} }
@Test /**
@Description("Ensures that artifacts are found, when software module exists.") * Ensures that artifacts are found, when software module exists.
void artifactsExists() throws Exception { */
@Test void artifactsExists() throws Exception {
final Target target = testdataFactory.createTarget(); final Target target = testdataFactory.createTarget();
final DistributionSet distributionSet = testdataFactory.createDistributionSet(""); final DistributionSet distributionSet = testdataFactory.createDistributionSet("");
@@ -136,9 +137,10 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
.andExpect(jsonPath("$.[?(@.filename=='filename2')]", hasSize(1))); .andExpect(jsonPath("$.[?(@.filename=='filename2')]", hasSize(1)));
} }
@Test /**
@Description("Forced deployment to a controller. Checks if the resource response payload for a given deployment is as expected.") * Forced deployment to a controller. Checks if the resource response payload for a given deployment is as expected.
void deploymentForceAction() throws Exception { */
@Test void deploymentForceAction() throws Exception {
// Prepare test data // Prepare test data
final DistributionSet ds = testdataFactory.createDistributionSet("", true); final DistributionSet ds = testdataFactory.createDistributionSet("", true);
final DistributionSet ds2 = testdataFactory.createDistributionSet("2", true); final DistributionSet ds2 = testdataFactory.createDistributionSet("2", true);
@@ -193,9 +195,10 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
assertThat(actionStatusMessage.getStatus()).isEqualTo(Status.RETRIEVED); assertThat(actionStatusMessage.getStatus()).isEqualTo(Status.RETRIEVED);
} }
@Test /**
@Description("Checks that the deploymentBase URL changes when the action is switched from soft to forced in TIMEFORCED case.") * Checks that the deploymentBase URL changes when the action is switched from soft to forced in TIMEFORCED case.
void changeEtagIfActionSwitchesFromSoftToForced() throws Exception { */
@Test void changeEtagIfActionSwitchesFromSoftToForced() throws Exception {
// Prepare test data // Prepare test data
final Target target = testdataFactory.createTarget(DEFAULT_CONTROLLER_ID); final Target target = testdataFactory.createTarget(DEFAULT_CONTROLLER_ID);
final DistributionSet ds = testdataFactory.createDistributionSet("", true); final DistributionSet ds = testdataFactory.createDistributionSet("", true);
@@ -229,9 +232,10 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
.toString()).isNotEqualTo(urlBeforeSwitch); .toString()).isNotEqualTo(urlBeforeSwitch);
} }
@Test /**
@Description("Attempt/soft deployment to a controller. Checks if the resource response payload for a given deployment is as expected.") * Attempt/soft deployment to a controller. Checks if the resource response payload for a given deployment is as expected.
void deploymentAttemptAction() throws Exception { */
@Test void deploymentAttemptAction() throws Exception {
// Prepare test data // Prepare test data
final DistributionSet ds = testdataFactory.createDistributionSet("", true); final DistributionSet ds = testdataFactory.createDistributionSet("", true);
final DistributionSet ds2 = testdataFactory.createDistributionSet("2", true); final DistributionSet ds2 = testdataFactory.createDistributionSet("2", true);
@@ -292,9 +296,10 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
assertThat(actionStatusMessage.getStatus()).isEqualTo(Status.RETRIEVED); assertThat(actionStatusMessage.getStatus()).isEqualTo(Status.RETRIEVED);
} }
@Test /**
@Description("Attempt/soft deployment to a controller including automated switch to hard. Checks if the resource response payload for a given deployment is as expected.") * Attempt/soft deployment to a controller including automated switch to hard. Checks if the resource response payload for a given deployment is as expected.
void deploymentAutoForceAction() throws Exception { */
@Test void deploymentAutoForceAction() throws Exception {
// Prepare test data // Prepare test data
final DistributionSet ds = testdataFactory.createDistributionSet("", true); final DistributionSet ds = testdataFactory.createDistributionSet("", true);
final DistributionSet ds2 = testdataFactory.createDistributionSet("2", true); final DistributionSet ds2 = testdataFactory.createDistributionSet("2", true);
@@ -350,9 +355,10 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
assertThat(actionStatusMessage.getStatus()).isEqualTo(Status.RETRIEVED); assertThat(actionStatusMessage.getStatus()).isEqualTo(Status.RETRIEVED);
} }
@Test /**
@Description("Test download-only (forced + skip) deployment to a controller. Checks if the resource response payload for a given deployment is as expected.") * Test download-only (forced + skip) deployment to a controller. Checks if the resource response payload for a given deployment is as expected.
void deploymentDownloadOnlyAction() throws Exception { */
@Test void deploymentDownloadOnlyAction() throws Exception {
// Prepare test data // Prepare test data
final DistributionSet ds = testdataFactory.createDistributionSet("", true); final DistributionSet ds = testdataFactory.createDistributionSet("", true);
final DistributionSet ds2 = testdataFactory.createDistributionSet("2", true); final DistributionSet ds2 = testdataFactory.createDistributionSet("2", true);
@@ -411,9 +417,10 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
assertThat(actionStatusMessage.getStatus()).isEqualTo(Status.RETRIEVED); assertThat(actionStatusMessage.getStatus()).isEqualTo(Status.RETRIEVED);
} }
@Test /**
@Description("Test various invalid access attempts to the deployment resource und the expected behaviour of the server.") * Test various invalid access attempts to the deployment resource und the expected behaviour of the server.
void badDeploymentAction() throws Exception { */
@Test void badDeploymentAction() throws Exception {
final Target target = testdataFactory.createTarget(DEFAULT_CONTROLLER_ID); final Target target = testdataFactory.createTarget(DEFAULT_CONTROLLER_ID);
// not allowed methods // not allowed methods
@@ -455,9 +462,11 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
.andExpect(status().isNotAcceptable()); .andExpect(status().isNotAcceptable());
} }
/**
* The server protects itself against to many feedback upload attempts. The test verifies that
* it is not possible to exceed the configured maximum number of feedback uploads.
*/
@Test @Test
@Description("The server protects itself against to many feedback upload attempts. The test verifies that " +
"it is not possible to exceed the configured maximum number of feedback uploads.")
void tooMuchDeploymentActionFeedback() throws Exception { void tooMuchDeploymentActionFeedback() throws Exception {
final Target target = testdataFactory.createTarget(DEFAULT_CONTROLLER_ID); final Target target = testdataFactory.createTarget(DEFAULT_CONTROLLER_ID);
final DistributionSet ds = testdataFactory.createDistributionSet(""); final DistributionSet ds = testdataFactory.createDistributionSet("");
@@ -474,9 +483,11 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
postDeploymentFeedback(DEFAULT_CONTROLLER_ID, action.getId(), feedback, status().isForbidden()); postDeploymentFeedback(DEFAULT_CONTROLLER_ID, action.getId(), feedback, status().isForbidden());
} }
/**
* The server protects itself against too large feedback bodies. The test verifies that
* it is not possible to exceed the configured maximum number of feedback details.
*/
@Test @Test
@Description("The server protects itself against too large feedback bodies. The test verifies that " +
"it is not possible to exceed the configured maximum number of feedback details.")
void tooMuchDeploymentActionMessagesInFeedback() throws Exception { void tooMuchDeploymentActionMessagesInFeedback() throws Exception {
final Target target = testdataFactory.createTarget(DEFAULT_CONTROLLER_ID); final Target target = testdataFactory.createTarget(DEFAULT_CONTROLLER_ID);
final DistributionSet ds = testdataFactory.createDistributionSet(""); final DistributionSet ds = testdataFactory.createDistributionSet("");
@@ -493,9 +504,10 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
postDeploymentFeedback(DEFAULT_CONTROLLER_ID, action.getId(), feedback, status().isForbidden()); postDeploymentFeedback(DEFAULT_CONTROLLER_ID, action.getId(), feedback, status().isForbidden());
} }
@Test /**
@Description("Multiple uploads of deployment status feedback to the server.") * Multiple uploads of deployment status feedback to the server.
void multipleDeploymentActionFeedback() throws Exception { */
@Test void multipleDeploymentActionFeedback() throws Exception {
testdataFactory.createTarget(DEFAULT_CONTROLLER_ID); testdataFactory.createTarget(DEFAULT_CONTROLLER_ID);
testdataFactory.createTarget("4713"); testdataFactory.createTarget("4713");
testdataFactory.createTarget("4714"); testdataFactory.createTarget("4714");
@@ -533,9 +545,10 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
assertStatusMessagesCount(6); assertStatusMessagesCount(6);
} }
@Test /**
@Description("Verifies that an update action is correctly set to error if the controller provides error feedback.") * Verifies that an update action is correctly set to error if the controller provides error feedback.
void rootRsSingleDeploymentActionWithErrorFeedback() throws Exception { */
@Test void rootRsSingleDeploymentActionWithErrorFeedback() throws Exception {
DistributionSet ds = testdataFactory.createDistributionSet(""); DistributionSet ds = testdataFactory.createDistributionSet("");
final Target savedTarget = testdataFactory.createTarget(DEFAULT_CONTROLLER_ID); final Target savedTarget = testdataFactory.createTarget(DEFAULT_CONTROLLER_ID);
@@ -569,9 +582,10 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
.haveAtLeast(1, new ActionStatusCondition(Status.FINISHED)); .haveAtLeast(1, new ActionStatusCondition(Status.FINISHED));
} }
@Test /**
@Description("Verifies that the controller can provided as much feedback entries as necessary as long as it is in the configured limits.") * Verifies that the controller can provided as much feedback entries as necessary as long as it is in the configured limits.
void rootRsSingleDeploymentActionFeedback() throws Exception { */
@Test void rootRsSingleDeploymentActionFeedback() throws Exception {
final DistributionSet ds = testdataFactory.createDistributionSet(""); final DistributionSet ds = testdataFactory.createDistributionSet("");
final Long actionId = getFirstAssignedActionId( final Long actionId = getFirstAssignedActionId(
assignDistributionSet(ds, assignDistributionSet(ds,
@@ -609,9 +623,10 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
assertThat(targetManagement.findByAssignedDistributionSet(ds.getId(), PAGE)).hasSize(1); assertThat(targetManagement.findByAssignedDistributionSet(ds.getId(), PAGE)).hasSize(1);
} }
@Test /**
@Description("Various forbidden request attempts on the feedback resource. Ensures correct answering behaviour as expected to these kind of errors.") * Various forbidden request attempts on the feedback resource. Ensures correct answering behaviour as expected to these kind of errors.
void badDeploymentActionFeedback() throws Exception { */
@Test void badDeploymentActionFeedback() throws Exception {
final DistributionSet savedSet = testdataFactory.createDistributionSet(""); final DistributionSet savedSet = testdataFactory.createDistributionSet("");
final DistributionSet savedSet2 = testdataFactory.createDistributionSet("1"); final DistributionSet savedSet2 = testdataFactory.createDistributionSet("1");
@@ -647,9 +662,10 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
.andExpect(status().isMethodNotAllowed()); .andExpect(status().isMethodNotAllowed());
} }
@Test /**
@Description("Ensures that an invalid id in feedback body returns a bad request.") * Ensures that an invalid id in feedback body returns a bad request.
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@@ -668,9 +684,10 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
postDeploymentFeedback("1080", action.getId(), invalidFeedback, status().isBadRequest()); postDeploymentFeedback("1080", action.getId(), invalidFeedback, status().isBadRequest());
} }
@Test /**
@Description("Ensures that a missing feedback result in feedback body returns a bad request.") * Ensures that a missing feedback result in feedback body returns a bad request.
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@@ -693,9 +710,10 @@ class DdiDeploymentBaseTest extends AbstractDDiApiIntegrationTest {
.andExpect(jsonPath("$.exceptionClass", equalTo(MessageNotReadableException.class.getName()))); .andExpect(jsonPath("$.exceptionClass", equalTo(MessageNotReadableException.class.getName())));
} }
@Test /**
@Description("Ensures that a missing finished result in feedback body returns a bad request.") * Ensures that a missing finished result in feedback body returns a bad request.
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),

View File

@@ -27,9 +27,6 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.stream.Stream; import java.util.stream.Stream;
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
import io.qameta.allure.Story;
import org.eclipse.hawkbit.ddi.json.model.DdiResult; import org.eclipse.hawkbit.ddi.json.model.DdiResult;
import org.eclipse.hawkbit.ddi.json.model.DdiStatus; import org.eclipse.hawkbit.ddi.json.model.DdiStatus;
import org.eclipse.hawkbit.ddi.rest.api.DdiRestConstants; import org.eclipse.hawkbit.ddi.rest.api.DdiRestConstants;
@@ -66,9 +63,10 @@ import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
/** /**
* Test installed base from the controller. * Test installed base from the controller.
* <p/>
* Feature: Component Tests - Direct Device Integration API<br/>
* Story: Installed Base Resource
*/ */
@Feature("Component Tests - Direct Device Integration API")
@Story("Installed Base Resource")
class DdiInstalledBaseTest extends AbstractDDiApiIntegrationTest { class DdiInstalledBaseTest extends AbstractDDiApiIntegrationTest {
@Autowired @Autowired
@@ -76,9 +74,10 @@ class DdiInstalledBaseTest extends AbstractDDiApiIntegrationTest {
private static final int ARTIFACT_SIZE = 5 * 1024; private static final int ARTIFACT_SIZE = 5 * 1024;
private static final String CONTROLLER_ID = "4715"; private static final String CONTROLLER_ID = "4715";
@Test /**
@Description("Ensure that the installed base resource is available as CBOR") * Ensure that the installed base resource is available as CBOR
void installedBaseResourceCbor() throws Exception { */
@Test void installedBaseResourceCbor() throws Exception {
final Target target = testdataFactory.createTarget(); final Target target = testdataFactory.createTarget();
final DistributionSet ds = testdataFactory.createDistributionSet(""); final DistributionSet ds = testdataFactory.createDistributionSet("");
@@ -98,9 +97,10 @@ class DdiInstalledBaseTest extends AbstractDDiApiIntegrationTest {
String.valueOf(softwareModuleId)); String.valueOf(softwareModuleId));
} }
@Test /**
@Description("Ensure that assigned version is self assigned version") * Ensure that assigned version is self assigned version
void installedVersion() throws Exception { */
@Test void installedVersion() throws Exception {
final Target target = createTargetAndAssertNoActiveActions(); final Target target = createTargetAndAssertNoActiveActions();
final DistributionSet ds = testdataFactory.createDistributionSet(""); final DistributionSet ds = testdataFactory.createDistributionSet("");
@@ -113,9 +113,10 @@ class DdiInstalledBaseTest extends AbstractDDiApiIntegrationTest {
putInstalledBase(target.getControllerId(), getJsonInstalledBase(ds.getName(), ds.getVersion()), status().isOk()); putInstalledBase(target.getControllerId(), getJsonInstalledBase(ds.getName(), ds.getVersion()), status().isOk());
} }
@Test /**
@Description("Ensure that installedVersion is version self assigned") * Ensure that installedVersion is version self assigned
void installedVersionNotExist() throws Exception { */
@Test void installedVersionNotExist() throws Exception {
final Target target = createTargetAndAssertNoActiveActions(); final Target target = createTargetAndAssertNoActiveActions();
final String dsName = "unknown"; final String dsName = "unknown";
final String dsVersion = "1.0.0"; final String dsVersion = "1.0.0";
@@ -126,9 +127,10 @@ class DdiInstalledBaseTest extends AbstractDDiApiIntegrationTest {
assertThat(deploymentManagement.getAssignedDistributionSet(target.getControllerId()).isEmpty()).isTrue(); assertThat(deploymentManagement.getAssignedDistributionSet(target.getControllerId()).isEmpty()).isTrue();
} }
@Test /**
@Description("Test several deployments to a controller. Checks that action is represented as installedBase after installation.") * Test several deployments to a controller. Checks that action is represented as installedBase after installation.
void deploymentSeveralActionsInInstalledBase() throws Exception { */
@Test void deploymentSeveralActionsInInstalledBase() throws Exception {
// Prepare test data // Prepare test data
final Target target = createTargetAndAssertNoActiveActions(); final Target target = createTargetAndAssertNoActiveActions();
@@ -194,9 +196,10 @@ class DdiInstalledBaseTest extends AbstractDDiApiIntegrationTest {
actionId1, ds1.findFirstModuleByType(osType).get().getId(), Action.ActionType.SOFT); actionId1, ds1.findFirstModuleByType(osType).get().getId(), Action.ActionType.SOFT);
} }
@Test /**
@Description("Test several deployments of same ds to a controller. Checks that cancelled action in history is not linked as installedBase.") * Test several deployments of same ds to a controller. Checks that cancelled action in history is not linked as installedBase.
void deploymentActionsOfSameDsWithCancelledActionInHistory() throws Exception { */
@Test void deploymentActionsOfSameDsWithCancelledActionInHistory() throws Exception {
// Prepare test data // Prepare test data
final Target target = createTargetAndAssertNoActiveActions(); final Target target = createTargetAndAssertNoActiveActions();
@@ -250,9 +253,10 @@ class DdiInstalledBaseTest extends AbstractDDiApiIntegrationTest {
.andExpect(status().isNotFound()); .andExpect(status().isNotFound());
} }
@Test /**
@Description("Test several deployments of same ds to a controller. Checks that latest cancelled action does not override actual installed ds.") * Test several deployments of same ds to a controller. Checks that latest cancelled action does not override actual installed ds.
void deploymentActionsOfSameDsWithCancelledAction() throws Exception { */
@Test void deploymentActionsOfSameDsWithCancelledAction() throws Exception {
// Prepare test data // Prepare test data
final Target target = createTargetAndAssertNoActiveActions(); final Target target = createTargetAndAssertNoActiveActions();
@@ -307,9 +311,10 @@ class DdiInstalledBaseTest extends AbstractDDiApiIntegrationTest {
.andExpect(status().isNotFound()); .andExpect(status().isNotFound());
} }
@Test /**
@Description("Test several deployments of same ds to a controller. Checks that latest running action does not override actual installed ds.") * Test several deployments of same ds to a controller. Checks that latest running action does not override actual installed ds.
void deploymentActionsOfSameDsWithRunningAction() throws Exception { */
@Test void deploymentActionsOfSameDsWithRunningAction() throws Exception {
// Prepare test data // Prepare test data
final Target target = createTargetAndAssertNoActiveActions(); final Target target = createTargetAndAssertNoActiveActions();
@@ -360,9 +365,10 @@ class DdiInstalledBaseTest extends AbstractDDiApiIntegrationTest {
.andExpect(status().isNotFound()); .andExpect(status().isNotFound());
} }
@Test /**
@Description("Test open deployment to a controller. Checks that installedBase returns 404 for a pending action.") * Test open deployment to a controller. Checks that installedBase returns 404 for a pending action.
void installedBaseReturns404ForPendingAction() throws Exception { */
@Test void installedBaseReturns404ForPendingAction() throws Exception {
// Prepare test data // Prepare test data
final Target target = createTargetAndAssertNoActiveActions(); final Target target = createTargetAndAssertNoActiveActions();
final DistributionSet ds = testdataFactory.createDistributionSet(""); final DistributionSet ds = testdataFactory.createDistributionSet("");
@@ -383,9 +389,10 @@ class DdiInstalledBaseTest extends AbstractDDiApiIntegrationTest {
.andExpect(status().isNotFound()); .andExpect(status().isNotFound());
} }
@Test /**
@Description("Ensures that artifacts are found, after the action was already closed.") * Ensures that artifacts are found, after the action was already closed.
void artifactsOfInstalledActionExist() throws Exception { */
@Test void artifactsOfInstalledActionExist() throws Exception {
final Target target = createTargetAndAssertNoActiveActions(); final Target target = createTargetAndAssertNoActiveActions();
final DistributionSet ds = testdataFactory.createDistributionSet(""); final DistributionSet ds = testdataFactory.createDistributionSet("");
@@ -404,9 +411,11 @@ class DdiInstalledBaseTest extends AbstractDDiApiIntegrationTest {
.andExpect(jsonPath("$.[?(@.filename=='filename2')]", hasSize(1))); .andExpect(jsonPath("$.[?(@.filename=='filename2')]", hasSize(1)));
} }
/**
* Test forced deployment to a controller. Checks that action is represented as installedBase after installation.
*/
@ParameterizedTest @ParameterizedTest
@MethodSource("org.eclipse.hawkbit.ddi.rest.resource.DdiInstalledBaseTest#actionTypeForDeployment") @MethodSource("org.eclipse.hawkbit.ddi.rest.resource.DdiInstalledBaseTest#actionTypeForDeployment")
@Description("Test forced deployment to a controller. Checks that action is represented as installedBase after installation.")
@ExpectEvents({ @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@@ -458,9 +467,10 @@ class DdiInstalledBaseTest extends AbstractDDiApiIntegrationTest {
assertThat(actionStatusMessage.getStatus()).isEqualTo(Action.Status.FINISHED); assertThat(actionStatusMessage.getStatus()).isEqualTo(Action.Status.FINISHED);
} }
@Test /**
@Description("Test download-only deployment to a controller. Checks that download-only is not represented as installedBase.") * Test download-only deployment to a controller. Checks that download-only is not represented as installedBase.
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@@ -498,9 +508,11 @@ class DdiInstalledBaseTest extends AbstractDDiApiIntegrationTest {
.andExpect(jsonPath("$._links.installedBase.href").doesNotExist()); .andExpect(jsonPath("$._links.installedBase.href").doesNotExist());
} }
/**
* Test a failed deployment to a controller. Checks that closed action is not represented as installedBase.
*/
@ParameterizedTest @ParameterizedTest
@MethodSource("org.eclipse.hawkbit.ddi.rest.resource.DdiInstalledBaseTest#actionTypeForDeployment") @MethodSource("org.eclipse.hawkbit.ddi.rest.resource.DdiInstalledBaseTest#actionTypeForDeployment")
@Description("Test a failed deployment to a controller. Checks that closed action is not represented as installedBase.")
void deploymentActionFailedNotInInstalledBase(final Action.ActionType actionType) throws Exception { void deploymentActionFailedNotInInstalledBase(final Action.ActionType actionType) throws Exception {
// Prepare test data // Prepare test data
final Target target = testdataFactory.createTarget(); final Target target = testdataFactory.createTarget();
@@ -532,9 +544,10 @@ class DdiInstalledBaseTest extends AbstractDDiApiIntegrationTest {
.andExpect(jsonPath("$._links.installedBase.href").doesNotExist()); .andExpect(jsonPath("$._links.installedBase.href").doesNotExist());
} }
@Test /**
@Description("Test to verify that only a specific count of messages are returned based on the input actionHistory for getControllerInstalledAction endpoint.") * Test to verify that only a specific count of messages are returned based on the input actionHistory for getControllerInstalledAction endpoint.
void testActionHistoryCount() throws Exception { */
@Test void testActionHistoryCount() throws Exception {
final DistributionSet ds = testdataFactory.createDistributionSet(""); final DistributionSet ds = testdataFactory.createDistributionSet("");
Target savedTarget = testdataFactory.createTarget("911"); Target savedTarget = testdataFactory.createTarget("911");
savedTarget = getFirstAssignedTarget(assignDistributionSet(ds.getId(), savedTarget.getControllerId())); savedTarget = getFirstAssignedTarget(assignDistributionSet(ds.getId(), savedTarget.getControllerId()));
@@ -583,9 +596,10 @@ class DdiInstalledBaseTest extends AbstractDDiApiIntegrationTest {
.andExpect(jsonPath("$.actionHistory.messages", hasItem(containsString("Installation scheduled")))); .andExpect(jsonPath("$.actionHistory.messages", hasItem(containsString("Installation scheduled"))));
} }
@Test /**
@Description("Test various invalid access attempts to the installed resource und the expected behaviour of the server.") * Test various invalid access attempts to the installed resource und the expected behaviour of the server.
void badInstalledAction() throws Exception { */
@Test void badInstalledAction() throws Exception {
final Target target = testdataFactory.createTarget(CONTROLLER_ID); final Target target = testdataFactory.createTarget(CONTROLLER_ID);
// not allowed methods // not allowed methods

View File

@@ -31,10 +31,6 @@ import java.util.Collections;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
import io.qameta.allure.Step;
import io.qameta.allure.Story;
import org.eclipse.hawkbit.ddi.json.model.DdiResult; import org.eclipse.hawkbit.ddi.json.model.DdiResult;
import org.eclipse.hawkbit.ddi.json.model.DdiStatus; import org.eclipse.hawkbit.ddi.json.model.DdiStatus;
import org.eclipse.hawkbit.ddi.rest.api.DdiRestConstants; import org.eclipse.hawkbit.ddi.rest.api.DdiRestConstants;
@@ -73,9 +69,10 @@ import org.springframework.test.web.servlet.ResultActions;
/** /**
* Test the root controller resources. * Test the root controller resources.
* <p/>
* Feature: Component Tests - Direct Device Integration API<br/>
* Story: Root Poll Resource
*/ */
@Feature("Component Tests - Direct Device Integration API")
@Story("Root Poll Resource")
class DdiRootControllerTest extends AbstractDDiApiIntegrationTest { class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
private static final String TARGET_COMPLETED_INSTALLATION_MSG = "Target completed installation."; private static final String TARGET_COMPLETED_INSTALLATION_MSG = "Target completed installation.";
@@ -85,18 +82,20 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
@Autowired @Autowired
private HawkbitSecurityProperties securityProperties; private HawkbitSecurityProperties securityProperties;
@Test /**
@Description("Ensure that the root poll resource is available as CBOR") * Ensure that the root poll resource is available as CBOR
void rootPollResourceCbor() throws Exception { */
@Test void rootPollResourceCbor() throws Exception {
mvc.perform(get(CONTROLLER_BASE, tenantAware.getCurrentTenant(), 4711).accept(DdiRestConstants.MEDIA_TYPE_CBOR)) mvc.perform(get(CONTROLLER_BASE, tenantAware.getCurrentTenant(), 4711).accept(DdiRestConstants.MEDIA_TYPE_CBOR))
.andDo(MockMvcResultPrinter.print()) .andDo(MockMvcResultPrinter.print())
.andExpect(content().contentType(DdiRestConstants.MEDIA_TYPE_CBOR)) .andExpect(content().contentType(DdiRestConstants.MEDIA_TYPE_CBOR))
.andExpect(status().isOk()); .andExpect(status().isOk());
} }
@Test /**
@Description("Ensures that the API returns JSON when no Accept header is specified by the client.") * Ensures that the API returns JSON when no Accept header is specified by the client.
void apiReturnsJSONByDefault() throws Exception { */
@Test void apiReturnsJSONByDefault() throws Exception {
final MvcResult result = mvc.perform(get(CONTROLLER_BASE, tenantAware.getCurrentTenant(), 4711)) final MvcResult result = mvc.perform(get(CONTROLLER_BASE, tenantAware.getCurrentTenant(), 4711))
.andDo(MockMvcResultPrinter.print()) .andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk()) .andExpect(status().isOk())
@@ -107,9 +106,10 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
assertThat(result.getRequest().getHeader("Accept")).isNull(); assertThat(result.getRequest().getHeader("Accept")).isNull();
} }
@Test /**
@Description("Ensures that target poll request does not change audit data on the entity.") * Ensures that target poll request does not change audit data on the entity.
@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({ @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 1),
@@ -139,18 +139,20 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
assertThat(targetVerify.getLastModifiedAt()).isEqualTo(findTargetByControllerID.getLastModifiedAt()); assertThat(targetVerify.getLastModifiedAt()).isEqualTo(findTargetByControllerID.getLastModifiedAt());
} }
@Test /**
@Description("Ensures that server returns a not found response in case of empty controller ID.") * Ensures that server returns a not found response in case of empty controller ID.
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) }) */
@Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
void rootRsWithoutId() throws Exception { void rootRsWithoutId() throws Exception {
mvc.perform(get("/controller/v1/")) mvc.perform(get("/controller/v1/"))
.andDo(MockMvcResultPrinter.print()) .andDo(MockMvcResultPrinter.print())
.andExpect(status().isNotFound()); .andExpect(status().isNotFound());
} }
@Test /**
@Description("Ensures that the system creates a new target in plug and play manner, i.e. target is authenticated but does not exist yet.") * Ensures that the system creates a new target in plug and play manner, i.e. target is authenticated but does not exist yet.
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetPollEvent.class, count = 1) }) @Expect(type = TargetPollEvent.class, count = 1) })
void rootRsPlugAndPlay() throws Exception { void rootRsPlugAndPlay() throws Exception {
@@ -183,9 +185,10 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
.andExpect(status().isMethodNotAllowed()); .andExpect(status().isMethodNotAllowed());
} }
@Test /**
@Description("Ensures that tenant specific polling time, which is saved in the db, is delivered to the controller.") * Ensures that tenant specific polling time, which is saved in the db, is delivered to the controller.
@WithUser(principal = "knownpricipal", allSpPermissions = false) */
@Test @WithUser(principal = "knownpricipal", allSpPermissions = false)
@ExpectEvents({ @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetPollEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1),
@@ -207,9 +210,10 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
}); });
} }
@Test /**
@Description("Ensures that etag check results in not modified response if provided etag by client is identical to entity in repository.") * Ensures that etag check results in not modified response if provided etag by client is identical to entity in repository.
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetPollEvent.class, count = 6), @Expect(type = TargetPollEvent.class, count = 6),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 2), @Expect(type = TargetAssignDistributionSetEvent.class, count = 2),
@@ -304,9 +308,11 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
} }
/**
* Ensures that the target state machine of a precomissioned target switches from
* UNKNOWN to REGISTERED when the target polls for the first time.
*/
@Test @Test
@Description("Ensures that the target state machine of a precomissioned target switches from "
+ "UNKNOWN to REGISTERED when the target polls for the first time.")
@ExpectEvents({ @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 1),
@@ -333,9 +339,10 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
.isEqualTo(TargetUpdateStatus.REGISTERED); .isEqualTo(TargetUpdateStatus.REGISTERED);
} }
@Test /**
@Description("Ensures that the source IP address of the polling target is correctly stored in repository") * Ensures that the source IP address of the polling target is correctly stored in repository
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetPollEvent.class, count = 1) }) @Expect(type = TargetPollEvent.class, count = 1) })
void rootRsPlugAndPlayIpAddress() throws Exception { void rootRsPlugAndPlayIpAddress() throws Exception {
@@ -361,9 +368,10 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
assertThat(target.getLastModifiedAt()).isGreaterThanOrEqualTo(create); assertThat(target.getLastModifiedAt()).isGreaterThanOrEqualTo(create);
} }
@Test /**
@Description("Ensures that the source IP address of the polling target is not stored in repository if disabled") * Ensures that the source IP address of the polling target is not stored in repository if disabled
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetPollEvent.class, count = 1) }) @Expect(type = TargetPollEvent.class, count = 1) })
void rootRsIpAddressNotStoredIfDisabled() throws Exception { void rootRsIpAddressNotStoredIfDisabled() throws Exception {
@@ -382,9 +390,10 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
securityProperties.getClients().setTrackRemoteIp(true); securityProperties.getClients().setTrackRemoteIp(true);
} }
@Test /**
@Description("Controller trys to finish an update process after it has been finished by an error action status.") * Controller trys to finish an update process after it has been finished by an error action status.
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@@ -413,9 +422,10 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
.andExpect(status().isGone()); .andExpect(status().isGone());
} }
@Test /**
@Description("Controller sends attribute update request after device successfully closed software update.") * Controller sends attribute update request after device successfully closed software update.
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@@ -443,9 +453,10 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
assertAttributesUpdateRequestedAfterSuccessfulDeployment(savedTarget, ds); assertAttributesUpdateRequestedAfterSuccessfulDeployment(savedTarget, ds);
} }
@Test /**
@Description("Test to verify that only a specific count of messages are returned based on the input actionHistory for getControllerDeploymentActionFeedback endpoint.") * Test to verify that only a specific count of messages are returned based on the input actionHistory for getControllerDeploymentActionFeedback endpoint.
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@@ -487,9 +498,10 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
not(hasItem(containsString(TARGET_SCHEDULED_INSTALLATION_MSG))))); not(hasItem(containsString(TARGET_SCHEDULED_INSTALLATION_MSG)))));
} }
@Test /**
@Description("Test to verify that a zero input value of actionHistory results in no action history appended for getControllerDeploymentActionFeedback endpoint.") * Test to verify that a zero input value of actionHistory results in no action history appended for getControllerDeploymentActionFeedback endpoint.
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@@ -531,9 +543,10 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
.andExpect(jsonPath("$.actionHistory.messages").doesNotExist()); .andExpect(jsonPath("$.actionHistory.messages").doesNotExist());
} }
@Test /**
@Description("Test to verify that entire action history is returned if the input value for actionHistory is -1, for getControllerDeploymentActionFeedback endpoint.") * Test to verify that entire action history is returned if the input value for actionHistory is -1, for getControllerDeploymentActionFeedback endpoint.
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = SoftwareModuleCreatedEvent.class, count = 3), @Expect(type = SoftwareModuleCreatedEvent.class, count = 3),
@@ -575,9 +588,10 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
hasItem(containsString(TARGET_COMPLETED_INSTALLATION_MSG)))); hasItem(containsString(TARGET_COMPLETED_INSTALLATION_MSG))));
} }
@Test /**
@Description("Test the polling time based on different maintenance window start and end time.") * Test the polling time based on different maintenance window start and end time.
void sleepTimeResponseForDifferentMaintenanceWindowParameters() throws Exception { */
@Test void sleepTimeResponseForDifferentMaintenanceWindowParameters() throws Exception {
final DistributionSet ds = testdataFactory.createDistributionSet(""); final DistributionSet ds = testdataFactory.createDistributionSet("");
SecurityContextSwitch.runAs(SecurityContextSwitch.withUser("tenantadmin", TENANT_CONFIGURATION), SecurityContextSwitch.runAs(SecurityContextSwitch.withUser("tenantadmin", TENANT_CONFIGURATION),
@@ -625,9 +639,10 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
.andExpect(jsonPath("$.config.polling.sleep", equalTo("00:05:00"))); .andExpect(jsonPath("$.config.polling.sleep", equalTo("00:05:00")));
} }
@Test /**
@Description("Test download and update values before maintenance window start time.") * Test download and update values before maintenance window start time.
void downloadAndUpdateStatusBeforeMaintenanceWindowStartTime() throws Exception { */
@Test void downloadAndUpdateStatusBeforeMaintenanceWindowStartTime() throws Exception {
Target savedTarget = testdataFactory.createTarget("1911"); Target savedTarget = testdataFactory.createTarget("1911");
final DistributionSet ds = testdataFactory.createDistributionSet(""); final DistributionSet ds = testdataFactory.createDistributionSet("");
savedTarget = getFirstAssignedTarget(assignDistributionSetWithMaintenanceWindow(ds.getId(), savedTarget = getFirstAssignedTarget(assignDistributionSetWithMaintenanceWindow(ds.getId(),
@@ -647,9 +662,10 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
.andExpect(jsonPath("$.deployment.maintenanceWindow", equalTo("unavailable"))); .andExpect(jsonPath("$.deployment.maintenanceWindow", equalTo("unavailable")));
} }
@Test /**
@Description("Test download and update values after maintenance window start time.") * Test download and update values after maintenance window start time.
void downloadAndUpdateStatusDuringMaintenanceWindow() throws Exception { */
@Test void downloadAndUpdateStatusDuringMaintenanceWindow() throws Exception {
Target savedTarget = testdataFactory.createTarget("1911"); Target savedTarget = testdataFactory.createTarget("1911");
final DistributionSet ds = testdataFactory.createDistributionSet(""); final DistributionSet ds = testdataFactory.createDistributionSet("");
savedTarget = getFirstAssignedTarget(assignDistributionSetWithMaintenanceWindow(ds.getId(), savedTarget = getFirstAssignedTarget(assignDistributionSetWithMaintenanceWindow(ds.getId(),
@@ -669,9 +685,10 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
.andExpect(jsonPath("$.deployment.maintenanceWindow", equalTo("available"))); .andExpect(jsonPath("$.deployment.maintenanceWindow", equalTo("available")));
} }
@Test /**
@Description("Assign multiple DS in multi-assignment mode. The earliest active Action is exposed to the controller.") * Assign multiple DS in multi-assignment mode. The earliest active Action is exposed to the controller.
void earliestActionIsExposedToControllerInMultiAssignMode() throws Exception { */
@Test void earliestActionIsExposedToControllerInMultiAssignMode() throws Exception {
enableMultiAssignments(); enableMultiAssignments();
final Target target = testdataFactory.createTarget(); final Target target = testdataFactory.createTarget();
final DistributionSet ds1 = testdataFactory.createDistributionSet(UUID.randomUUID().toString()); final DistributionSet ds1 = testdataFactory.createDistributionSet(UUID.randomUUID().toString());
@@ -684,15 +701,15 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
assertDeploymentActionIsExposedToTarget(target.getControllerId(), action2Id); assertDeploymentActionIsExposedToTarget(target.getControllerId(), action2Id);
} }
@Test /**
@Description("The system should not create a new target because of a too long controller id.") * The system should not create a new target because of a too long controller id.
void rootRsWithInvalidControllerId() throws Exception { */
@Test void rootRsWithInvalidControllerId() throws Exception {
final String invalidControllerId = randomString(Target.CONTROLLER_ID_MAX_SIZE + 1); final String invalidControllerId = randomString(Target.CONTROLLER_ID_MAX_SIZE + 1);
mvc.perform(get(CONTROLLER_BASE, tenantAware.getCurrentTenant(), invalidControllerId)) mvc.perform(get(CONTROLLER_BASE, tenantAware.getCurrentTenant(), invalidControllerId))
.andExpect(status().isBadRequest()); .andExpect(status().isBadRequest());
} }
@Step
private void assertAttributesUpdateNotRequestedAfterFailedDeployment(Target target, final DistributionSet ds) throws Exception { private void assertAttributesUpdateNotRequestedAfterFailedDeployment(Target target, final DistributionSet ds) throws Exception {
target = getFirstAssignedTarget(assignDistributionSet(ds.getId(), target.getControllerId())); target = getFirstAssignedTarget(assignDistributionSet(ds.getId(), target.getControllerId()));
final Action action = deploymentManagement.findActiveActionsByTarget(target.getControllerId(), PAGE).getContent().get(0); final Action action = deploymentManagement.findActiveActionsByTarget(target.getControllerId(), PAGE).getContent().get(0);
@@ -701,7 +718,6 @@ class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
assertThatAttributesUpdateIsNotRequested(target.getControllerId()); assertThatAttributesUpdateIsNotRequested(target.getControllerId());
} }
@Step
private void assertAttributesUpdateRequestedAfterSuccessfulDeployment(Target target, final DistributionSet ds) throws Exception { private void assertAttributesUpdateRequestedAfterSuccessfulDeployment(Target target, final DistributionSet ds) throws Exception {
target = getFirstAssignedTarget(assignDistributionSet(ds.getId(), target.getControllerId())); target = getFirstAssignedTarget(assignDistributionSet(ds.getId(), target.getControllerId()));
final Action action = deploymentManagement.findActiveActionsByTarget(target.getControllerId(), PAGE).getContent().get(0); final Action action = deploymentManagement.findActiveActionsByTarget(target.getControllerId(), PAGE).getContent().get(0);

View File

@@ -17,9 +17,6 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
import io.qameta.allure.Story;
import org.eclipse.hawkbit.repository.model.Action; import org.eclipse.hawkbit.repository.model.Action;
import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.Target;
@@ -37,8 +34,10 @@ import org.springframework.web.context.WebApplicationContext;
* Test potential DOS attack scenarios and check if the filter prevents them. * Test potential DOS attack scenarios and check if the filter prevents them.
*/ */
@ActiveProfiles({ "test" }) @ActiveProfiles({ "test" })
@Feature("Component Tests - REST Security") /**
@Story("Denial of Service protection filter") * Feature: Component Tests - REST Security<br/>
* Story: Denial of Service protection filter
*/
class DosFilterTest extends AbstractDDiApiIntegrationTest { class DosFilterTest extends AbstractDDiApiIntegrationTest {
private static final String X_FORWARDED_FOR = HawkbitSecurityProperties.Clients.X_FORWARDED_FOR; private static final String X_FORWARDED_FOR = HawkbitSecurityProperties.Clients.X_FORWARDED_FOR;
@@ -49,17 +48,19 @@ class DosFilterTest extends AbstractDDiApiIntegrationTest {
new DosFilter(null, 10, 10, "127\\.0\\.0\\.1|\\[0:0:0:0:0:0:0:1\\]", "(^192\\.168\\.)", "X-Forwarded-For")); new DosFilter(null, 10, 10, "127\\.0\\.0\\.1|\\[0:0:0:0:0:0:0:1\\]", "(^192\\.168\\.)", "X-Forwarded-For"));
} }
@Test /**
@Description("Ensures that clients that are on the blacklist are forbidden") * Ensures that clients that are on the blacklist are forbidden
void blackListedClientIsForbidden() throws Exception { */
@Test void blackListedClientIsForbidden() throws Exception {
mvc.perform(get("/{tenant}/controller/v1/4711", tenantAware.getCurrentTenant()) mvc.perform(get("/{tenant}/controller/v1/4711", tenantAware.getCurrentTenant())
.header(X_FORWARDED_FOR, "192.168.0.4 , 10.0.0.1 ")) .header(X_FORWARDED_FOR, "192.168.0.4 , 10.0.0.1 "))
.andExpect(status().isForbidden()); .andExpect(status().isForbidden());
} }
@Test /**
@Description("Ensures that a READ DoS attempt is blocked ") * Ensures that a READ DoS attempt is blocked
void getFloodingAttackThatIsPrevented() throws Exception { */
@Test void getFloodingAttackThatIsPrevented() throws Exception {
int requests = 0; int requests = 0;
MvcResult result; MvcResult result;
do { do {
@@ -76,9 +77,10 @@ class DosFilterTest extends AbstractDDiApiIntegrationTest {
assertThat(requests).isGreaterThanOrEqualTo(10); assertThat(requests).isGreaterThanOrEqualTo(10);
} }
@Test /**
@Description("Ensures that an assumed READ DoS attempt is not blocked as the client (with IPv4 address) is on a whitelist") * Ensures that an assumed READ DoS attempt is not blocked as the client (with IPv4 address) is on a whitelist
void unacceptableGetLoadButOnWhitelistIPv4() throws Exception { */
@Test void unacceptableGetLoadButOnWhitelistIPv4() throws Exception {
for (int i = 0; i < 100; i++) { for (int i = 0; i < 100; i++) {
mvc.perform(get("/{tenant}/controller/v1/4711", tenantAware.getCurrentTenant()) mvc.perform(get("/{tenant}/controller/v1/4711", tenantAware.getCurrentTenant())
.header(X_FORWARDED_FOR, "127.0.0.1")) .header(X_FORWARDED_FOR, "127.0.0.1"))
@@ -86,9 +88,10 @@ class DosFilterTest extends AbstractDDiApiIntegrationTest {
} }
} }
@Test /**
@Description("Ensures that an assumed READ DoS attempt is not blocked as the client (with IPv6 address) is on a whitelist") * Ensures that an assumed READ DoS attempt is not blocked as the client (with IPv6 address) is on a whitelist
void unacceptableGetLoadButOnWhitelistIPv6() throws Exception { */
@Test void unacceptableGetLoadButOnWhitelistIPv6() throws Exception {
for (int i = 0; i < 100; i++) { for (int i = 0; i < 100; i++) {
mvc.perform(get("/{tenant}/controller/v1/4711", tenantAware.getCurrentTenant()) mvc.perform(get("/{tenant}/controller/v1/4711", tenantAware.getCurrentTenant())
.header(X_FORWARDED_FOR, "0:0:0:0:0:0:0:1")) .header(X_FORWARDED_FOR, "0:0:0:0:0:0:0:1"))
@@ -96,9 +99,10 @@ class DosFilterTest extends AbstractDDiApiIntegrationTest {
} }
} }
@Test /**
@Description("Ensures that a relatively high number of READ requests is allowed if it is below the DoS detection threshold") * Ensures that a relatively high number of READ requests is allowed if it is below the DoS detection threshold
// 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") @SuppressWarnings("squid:S2925")
void acceptableGetLoad() throws Exception { void acceptableGetLoad() throws Exception {
for (int x = 0; x < 3; x++) { for (int x = 0; x < 3; x++) {
@@ -112,9 +116,10 @@ class DosFilterTest extends AbstractDDiApiIntegrationTest {
} }
} }
@Test /**
@Description("Ensures that a WRITE DoS attempt is blocked ") * Ensures that a WRITE DoS attempt is blocked
void putPostFloddingAttackThatisPrevented() throws Exception { */
@Test void putPostFloddingAttackThatisPrevented() throws Exception {
final Long actionId = prepareDeploymentBase(); final Long actionId = prepareDeploymentBase();
final String feedback = getJsonProceedingDeploymentActionFeedback(); final String feedback = getJsonProceedingDeploymentActionFeedback();
@@ -135,9 +140,10 @@ class DosFilterTest extends AbstractDDiApiIntegrationTest {
assertThat(requests).isGreaterThanOrEqualTo(10); assertThat(requests).isGreaterThanOrEqualTo(10);
} }
@Test /**
@Description("Ensures that a relatively high number of WRITE requests is allowed if it is below the DoS detection threshold") * Ensures that a relatively high number of WRITE requests is allowed if it is below the DoS detection threshold
// 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") @SuppressWarnings("squid:S2925")
void acceptablePutPostLoad() throws Exception { void acceptablePutPostLoad() throws Exception {
final Long actionId = prepareDeploymentBase(); final Long actionId = prepareDeploymentBase();

View File

@@ -12,9 +12,6 @@ package org.eclipse.hawkbit.security.controller;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
import io.qameta.allure.Story;
import org.eclipse.hawkbit.repository.TenantConfigurationManagement; import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
import org.eclipse.hawkbit.repository.model.TenantConfigurationValue; import org.eclipse.hawkbit.repository.model.TenantConfigurationValue;
import org.eclipse.hawkbit.security.SecurityContextSerializer; import org.eclipse.hawkbit.security.SecurityContextSerializer;
@@ -28,8 +25,10 @@ import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension; import org.mockito.junit.jupiter.MockitoExtension;
@Feature("Unit Tests - Security") /**
@Story("Gateway token authentication") * Feature: Unit Tests - Security<br/>
* Story: Gateway token authentication
*/
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
class GatewayTokenAuthenticatorTest { class GatewayTokenAuthenticatorTest {
@@ -61,9 +60,10 @@ class GatewayTokenAuthenticatorTest {
new SystemSecurityContext(tenantAware)); new SystemSecurityContext(tenantAware));
} }
@Test /**
@Description("Tests successful authentication with gateway token") * Tests successful authentication with gateway token
void testWithGwToken() { */
@Test void testWithGwToken() {
final ControllerSecurityToken securityToken = prepareSecurityToken(GATEWAY_TOKEN); final ControllerSecurityToken securityToken = prepareSecurityToken(GATEWAY_TOKEN);
when(tenantConfigurationManagementMock.getConfigurationValue( when(tenantConfigurationManagementMock.getConfigurationValue(
TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_KEY, String.class)) TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_KEY, String.class))
@@ -77,9 +77,10 @@ class GatewayTokenAuthenticatorTest {
.hasFieldOrPropertyWithValue("principal", CONTROLLER_ID); .hasFieldOrPropertyWithValue("principal", CONTROLLER_ID);
} }
@Test /**
@Description("Tests that if gateway token doesn't match, the authentication fails") * Tests that if gateway token doesn't match, the authentication fails
void testWithBadGwToken() { */
@Test void testWithBadGwToken() {
final ControllerSecurityToken securityToken = prepareSecurityToken(UNKNOWN_TOKEN); final ControllerSecurityToken securityToken = prepareSecurityToken(UNKNOWN_TOKEN);
when(tenantConfigurationManagementMock.getConfigurationValue( when(tenantConfigurationManagementMock.getConfigurationValue(
TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_KEY, String.class)) TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_KEY, String.class))
@@ -91,15 +92,17 @@ class GatewayTokenAuthenticatorTest {
assertThat(authenticator.authenticate(securityToken)).isNull(); assertThat(authenticator.authenticate(securityToken)).isNull();
} }
@Test /**
@Description("Tests that if gateway token miss, the authentication fails") * Tests that if gateway token miss, the authentication fails
void testWithoutGwToken() { */
@Test void testWithoutGwToken() {
assertThat(authenticator.authenticate(new ControllerSecurityToken("DEFAULT", CONTROLLER_ID))).isNull(); assertThat(authenticator.authenticate(new ControllerSecurityToken("DEFAULT", CONTROLLER_ID))).isNull();
} }
@Test /**
@Description("Tests that if disabled, the authentication fails") * Tests that if disabled, the authentication fails
void testWithGwTokenButDisabled() { */
@Test void testWithGwTokenButDisabled() {
final ControllerSecurityToken securityToken = prepareSecurityToken(GATEWAY_TOKEN); final ControllerSecurityToken securityToken = prepareSecurityToken(GATEWAY_TOKEN);
when(tenantConfigurationManagementMock.getConfigurationValue( when(tenantConfigurationManagementMock.getConfigurationValue(
TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_ENABLED, Boolean.class)) TenantConfigurationKey.AUTHENTICATION_MODE_GATEWAY_SECURITY_TOKEN_ENABLED, Boolean.class))

View File

@@ -12,9 +12,6 @@ package org.eclipse.hawkbit.security.controller;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
import io.qameta.allure.Story;
import org.eclipse.hawkbit.repository.TenantConfigurationManagement; import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
import org.eclipse.hawkbit.repository.model.TenantConfigurationValue; import org.eclipse.hawkbit.repository.model.TenantConfigurationValue;
import org.eclipse.hawkbit.security.SecurityContextSerializer; import org.eclipse.hawkbit.security.SecurityContextSerializer;
@@ -28,8 +25,10 @@ import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension; import org.mockito.junit.jupiter.MockitoExtension;
@Feature("Unit Tests - Security") /**
@Story("Security header authenticator") * Feature: Unit Tests - Security<br/>
* Story: Security header authenticator
*/
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
class SecurityHeaderAuthenticatorTest { class SecurityHeaderAuthenticatorTest {
@@ -72,9 +71,10 @@ class SecurityHeaderAuthenticatorTest {
); );
} }
@Test /**
@Description("Tests successful authentication with multiple a single hashes") * Tests successful authentication with multiple a single hashes
void testWithSingleKnownHash() { */
@Test void testWithSingleKnownHash() {
final ControllerSecurityToken securityToken = prepareSecurityToken(SINGLE_HASH); final ControllerSecurityToken securityToken = prepareSecurityToken(SINGLE_HASH);
when(tenantConfigurationManagementMock.getConfigurationValue( when(tenantConfigurationManagementMock.getConfigurationValue(
TenantConfigurationKey.AUTHENTICATION_MODE_HEADER_AUTHORITY_NAME, String.class)) TenantConfigurationKey.AUTHENTICATION_MODE_HEADER_AUTHORITY_NAME, String.class))
@@ -88,9 +88,10 @@ class SecurityHeaderAuthenticatorTest {
.hasFieldOrPropertyWithValue("principal", CA_COMMON_NAME_VALUE); .hasFieldOrPropertyWithValue("principal", CA_COMMON_NAME_VALUE);
} }
@Test /**
@Description("Tests successful authentication with multiple hashes") * Tests successful authentication with multiple hashes
void testWithMultipleKnownHashes() { */
@Test void testWithMultipleKnownHashes() {
when(tenantConfigurationManagementMock.getConfigurationValue( when(tenantConfigurationManagementMock.getConfigurationValue(
TenantConfigurationKey.AUTHENTICATION_MODE_HEADER_AUTHORITY_NAME, String.class)) TenantConfigurationKey.AUTHENTICATION_MODE_HEADER_AUTHORITY_NAME, String.class))
.thenReturn(CONFIG_VALUE_MULTI_HASH); .thenReturn(CONFIG_VALUE_MULTI_HASH);
@@ -109,9 +110,10 @@ class SecurityHeaderAuthenticatorTest {
.hasFieldOrPropertyWithValue("principal", CA_COMMON_NAME_VALUE); .hasFieldOrPropertyWithValue("principal", CA_COMMON_NAME_VALUE);
} }
@Test /**
@Description("Tests that if the hash is unknown, the authentication fails") * Tests that if the hash is unknown, the authentication fails
void testWithUnknownHash() { */
@Test void testWithUnknownHash() {
final ControllerSecurityToken securityToken = prepareSecurityToken(UNKNOWN_HASH); final ControllerSecurityToken securityToken = prepareSecurityToken(UNKNOWN_HASH);
when(tenantConfigurationManagementMock.getConfigurationValue( when(tenantConfigurationManagementMock.getConfigurationValue(
TenantConfigurationKey.AUTHENTICATION_MODE_HEADER_AUTHORITY_NAME, String.class)) TenantConfigurationKey.AUTHENTICATION_MODE_HEADER_AUTHORITY_NAME, String.class))
@@ -123,9 +125,10 @@ class SecurityHeaderAuthenticatorTest {
assertThat(authenticator.authenticate(securityToken)).isNull(); assertThat(authenticator.authenticate(securityToken)).isNull();
} }
@Test /**
@Description("Tests that if CN doesn't match the CN in the security token, the authentication fails") * Tests that if CN doesn't match the CN in the security token, the authentication fails
void testWithNonMatchingCN() { */
@Test void testWithNonMatchingCN() {
final ControllerSecurityToken securityToken = new ControllerSecurityToken("DEFAULT", "otherControllerID"); final ControllerSecurityToken securityToken = new ControllerSecurityToken("DEFAULT", "otherControllerID");
securityToken.putHeader(CA_COMMON_NAME, CA_COMMON_NAME_VALUE); securityToken.putHeader(CA_COMMON_NAME, CA_COMMON_NAME_VALUE);
securityToken.putHeader(X_SSL_ISSUER_HASH_1, SINGLE_HASH); securityToken.putHeader(X_SSL_ISSUER_HASH_1, SINGLE_HASH);
@@ -133,15 +136,17 @@ class SecurityHeaderAuthenticatorTest {
assertThat(authenticator.authenticate(securityToken)).isNull(); assertThat(authenticator.authenticate(securityToken)).isNull();
} }
@Test /**
@Description("Tests that if the hash miss, the authentication fails") * Tests that if the hash miss, the authentication fails
void testWithoutHash() { */
@Test void testWithoutHash() {
assertThat(authenticator.authenticate(new ControllerSecurityToken("DEFAULT", CA_COMMON_NAME_VALUE))).isNull(); assertThat(authenticator.authenticate(new ControllerSecurityToken("DEFAULT", CA_COMMON_NAME_VALUE))).isNull();
} }
@Test /**
@Description("Tests that if disabled, the authentication fails") * Tests that if disabled, the authentication fails
void testWithSingleKnownHashButDisabled() { */
@Test void testWithSingleKnownHashButDisabled() {
final ControllerSecurityToken securityToken = prepareSecurityToken(SINGLE_HASH); final ControllerSecurityToken securityToken = prepareSecurityToken(SINGLE_HASH);
when(tenantConfigurationManagementMock.getConfigurationValue( when(tenantConfigurationManagementMock.getConfigurationValue(
TenantConfigurationKey.AUTHENTICATION_MODE_HEADER_ENABLED, Boolean.class)) TenantConfigurationKey.AUTHENTICATION_MODE_HEADER_ENABLED, Boolean.class))

View File

@@ -14,9 +14,6 @@ import static org.mockito.Mockito.when;
import java.util.Optional; import java.util.Optional;
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
import io.qameta.allure.Story;
import org.eclipse.hawkbit.repository.ControllerManagement; import org.eclipse.hawkbit.repository.ControllerManagement;
import org.eclipse.hawkbit.repository.TenantConfigurationManagement; import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.Target;
@@ -33,8 +30,10 @@ import org.mockito.Mock;
import org.mockito.Mockito; import org.mockito.Mockito;
import org.mockito.junit.jupiter.MockitoExtension; import org.mockito.junit.jupiter.MockitoExtension;
@Feature("Unit Tests - Security") /**
@Story("Gateway token authentication") * Feature: Unit Tests - Security<br/>
* Story: Gateway token authentication
*/
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
class SecurityTokenAuthenticatorTest { class SecurityTokenAuthenticatorTest {
@@ -66,9 +65,10 @@ class SecurityTokenAuthenticatorTest {
new SystemSecurityContext(tenantAware), controllerManagementMock); new SystemSecurityContext(tenantAware), controllerManagementMock);
} }
@Test /**
@Description("Tests successful authentication with gateway token") * Tests successful authentication with gateway token
void testWithSecToken() { */
@Test void testWithSecToken() {
final ControllerSecurityToken securityToken = prepareSecurityToken(SECURITY_TOKEN); final ControllerSecurityToken securityToken = prepareSecurityToken(SECURITY_TOKEN);
when(tenantConfigurationManagementMock.getConfigurationValue( when(tenantConfigurationManagementMock.getConfigurationValue(
TenantConfigurationKey.AUTHENTICATION_MODE_TARGET_SECURITY_TOKEN_ENABLED, Boolean.class)) TenantConfigurationKey.AUTHENTICATION_MODE_TARGET_SECURITY_TOKEN_ENABLED, Boolean.class))
@@ -84,9 +84,10 @@ class SecurityTokenAuthenticatorTest {
.hasFieldOrPropertyWithValue("principal", CONTROLLER_ID); .hasFieldOrPropertyWithValue("principal", CONTROLLER_ID);
} }
@Test /**
@Description("Tests that if gateway token doesn't match, the authentication fails") * Tests that if gateway token doesn't match, the authentication fails
void testWithBadSecToken() { */
@Test void testWithBadSecToken() {
final ControllerSecurityToken securityToken = prepareSecurityToken(UNKNOWN_TOKEN); final ControllerSecurityToken securityToken = prepareSecurityToken(UNKNOWN_TOKEN);
when(tenantConfigurationManagementMock.getConfigurationValue( when(tenantConfigurationManagementMock.getConfigurationValue(
TenantConfigurationKey.AUTHENTICATION_MODE_TARGET_SECURITY_TOKEN_ENABLED, Boolean.class)) TenantConfigurationKey.AUTHENTICATION_MODE_TARGET_SECURITY_TOKEN_ENABLED, Boolean.class))
@@ -95,15 +96,17 @@ class SecurityTokenAuthenticatorTest {
assertThat(authenticator.authenticate(securityToken)).isNull(); assertThat(authenticator.authenticate(securityToken)).isNull();
} }
@Test /**
@Description("Tests that if gateway token miss, the authentication fails") * Tests that if gateway token miss, the authentication fails
void testWithoutSecToken() { */
@Test void testWithoutSecToken() {
assertThat(authenticator.authenticate(new ControllerSecurityToken("DEFAULT", CONTROLLER_ID))).isNull(); assertThat(authenticator.authenticate(new ControllerSecurityToken("DEFAULT", CONTROLLER_ID))).isNull();
} }
@Test /**
@Description("Tests that if disabled, the authentication fails") * Tests that if disabled, the authentication fails
void testWithSecTokenButDisabled() { */
@Test void testWithSecTokenButDisabled() {
final ControllerSecurityToken securityToken = prepareSecurityToken(SECURITY_TOKEN); final ControllerSecurityToken securityToken = prepareSecurityToken(SECURITY_TOKEN);
when(tenantConfigurationManagementMock.getConfigurationValue( when(tenantConfigurationManagementMock.getConfigurationValue(
TenantConfigurationKey.AUTHENTICATION_MODE_TARGET_SECURITY_TOKEN_ENABLED, Boolean.class)) TenantConfigurationKey.AUTHENTICATION_MODE_TARGET_SECURITY_TOKEN_ENABLED, Boolean.class))

View File

@@ -12,9 +12,6 @@ package org.eclipse.hawkbit.app.ddi;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
import io.qameta.allure.Story;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.TestPropertySource;
@@ -23,27 +20,32 @@ import org.springframework.test.context.TestPropertySource;
"spring.flyway.enabled=true", // if hibernate is used there could be db inconsistencies when executing tests with and without flyway "spring.flyway.enabled=true", // if hibernate is used there could be db inconsistencies when executing tests with and without flyway
"hawkbit.server.security.allowedHostNames=localhost", "hawkbit.server.security.allowedHostNames=localhost",
"hawkbit.server.security.httpFirewallIgnoredPaths=/index.html" }) "hawkbit.server.security.httpFirewallIgnoredPaths=/index.html" })
@Feature("Integration Test - Security") /**
@Story("Allowed Host Names") * Feature: Integration Test - Security<br/>
* Story: Allowed Host Names
*/
class AllowedHostNamesTest extends AbstractSecurityTest { class AllowedHostNamesTest extends AbstractSecurityTest {
@Test /**
@Description("Tests whether a RequestRejectedException is thrown when not allowed host is used") * Tests whether a RequestRejectedException is thrown when not allowed host is used
void allowedHostNameWithNotAllowedHost() throws Exception { */
@Test void allowedHostNameWithNotAllowedHost() throws Exception {
mvc.perform(get("/").header(HttpHeaders.HOST, "www.google.com")) mvc.perform(get("/").header(HttpHeaders.HOST, "www.google.com"))
.andExpect(status().isBadRequest()); .andExpect(status().isBadRequest());
} }
@Test /**
@Description("Tests whether request is redirected when allowed host is used") * Tests whether request is redirected when allowed host is used
void allowedHostNameWithAllowedHost() throws Exception { */
@Test void allowedHostNameWithAllowedHost() throws Exception {
mvc.perform(get("/").header(HttpHeaders.HOST, "localhost")) mvc.perform(get("/").header(HttpHeaders.HOST, "localhost"))
.andExpect(status().is3xxRedirection()); .andExpect(status().is3xxRedirection());
} }
@Test /**
@Description("Tests whether request without allowed host name and with ignored path end up with a client error") * Tests whether request without allowed host name and with ignored path end up with a client error
void notAllowedHostnameWithIgnoredPath() throws Exception { */
@Test void notAllowedHostnameWithIgnoredPath() throws Exception {
mvc.perform(get("/index.html").header(HttpHeaders.HOST, "www.google.com")) mvc.perform(get("/index.html").header(HttpHeaders.HOST, "www.google.com"))
.andExpect(status().is4xxClientError()); .andExpect(status().is4xxClientError());
} }

View File

@@ -12,31 +12,32 @@ package org.eclipse.hawkbit.app.ddi;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
import io.qameta.allure.Story;
import org.eclipse.hawkbit.im.authentication.SpPermission; import org.eclipse.hawkbit.im.authentication.SpPermission;
import org.eclipse.hawkbit.repository.test.util.WithUser; import org.eclipse.hawkbit.repository.test.util.WithUser;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.TestPropertySource;
@Feature("Integration Test - Security") /**
@Story("PreAuthorized enabled") * Feature: Integration Test - Security<br/>
* Story: PreAuthorized enabled
*/
@TestPropertySource(properties = { "spring.flyway.enabled=true" }) @TestPropertySource(properties = { "spring.flyway.enabled=true" })
class PreAuthorizeEnabledTest extends AbstractSecurityTest { class PreAuthorizeEnabledTest extends AbstractSecurityTest {
@Test /**
@Description("Tests whether request fail if a role is forbidden for the user") * Tests whether request fail if a role is forbidden for the user
@WithUser(authorities = { SpPermission.READ_TARGET }, autoCreateTenant = false) */
@Test @WithUser(authorities = { SpPermission.READ_TARGET }, autoCreateTenant = false)
void failIfNoRole() throws Exception { void failIfNoRole() throws Exception {
mvc.perform(get("/DEFAULT/controller/v1/controllerId")) mvc.perform(get("/DEFAULT/controller/v1/controllerId"))
.andExpect(result -> assertThat(result.getResponse().getStatus()).isEqualTo(HttpStatus.FORBIDDEN.value())); .andExpect(result -> assertThat(result.getResponse().getStatus()).isEqualTo(HttpStatus.FORBIDDEN.value()));
} }
@Test /**
@Description("Tests whether request succeed if a role is granted for the user") * Tests whether request succeed if a role is granted for the user
@WithUser(authorities = { SpPermission.SpringEvalExpressions.CONTROLLER_ROLE }, autoCreateTenant = false) */
@Test @WithUser(authorities = { SpPermission.SpringEvalExpressions.CONTROLLER_ROLE }, autoCreateTenant = false)
void successIfHasRole() throws Exception { void successIfHasRole() throws Exception {
mvc.perform(get("/DEFAULT/controller/v1/controllerId")) mvc.perform(get("/DEFAULT/controller/v1/controllerId"))
.andExpect(result -> assertThat(result.getResponse().getStatus()).isEqualTo(HttpStatus.OK.value())); .andExpect(result -> assertThat(result.getResponse().getStatus()).isEqualTo(HttpStatus.OK.value()));

View File

@@ -23,9 +23,6 @@ import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.UUID; import java.util.UUID;
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
import io.qameta.allure.Story;
import org.eclipse.hawkbit.artifact.repository.ArtifactFilesystem; import org.eclipse.hawkbit.artifact.repository.ArtifactFilesystem;
import org.eclipse.hawkbit.artifact.repository.model.AbstractDbArtifact; import org.eclipse.hawkbit.artifact.repository.model.AbstractDbArtifact;
import org.eclipse.hawkbit.artifact.repository.model.DbArtifactHash; import org.eclipse.hawkbit.artifact.repository.model.DbArtifactHash;
@@ -65,8 +62,10 @@ import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ActiveProfiles;
@ActiveProfiles({ "test" }) @ActiveProfiles({ "test" })
@Feature("Component Tests - Device Management Federation API") /**
@Story("AmqpMessage Dispatcher Service Test") * Feature: Component Tests - Device Management Federation API<br/>
* Story: AmqpMessage Dispatcher Service Test
*/
@SpringBootTest(classes = { RepositoryApplicationConfiguration.class }, webEnvironment = SpringBootTest.WebEnvironment.NONE) @SpringBootTest(classes = { RepositoryApplicationConfiguration.class }, webEnvironment = SpringBootTest.WebEnvironment.NONE)
class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest { class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
@@ -116,9 +115,10 @@ class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
return argumentCaptor.getValue(); return argumentCaptor.getValue();
} }
@Test /**
@Description("Verifies that download and install event with 3 software modules and no artifacts works") * Verifies that download and install event with 3 software modules and no artifacts works
void testSendDownloadRequestWithSoftwareModulesAndNoArtifacts() { */
@Test void testSendDownloadRequestWithSoftwareModulesAndNoArtifacts() {
final DistributionSet createDistributionSet = testdataFactory final DistributionSet createDistributionSet = testdataFactory
.createDistributionSet(UUID.randomUUID().toString()); .createDistributionSet(UUID.randomUUID().toString());
testdataFactory.addSoftwareModuleMetadata(createDistributionSet); testdataFactory.addSoftwareModuleMetadata(createDistributionSet);
@@ -155,9 +155,10 @@ class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
} }
} }
@Test /**
@Description("Verifies that download and install event with software modules and artifacts works") * Verifies that download and install event with software modules and artifacts works
void testSendDownloadRequest() { */
@Test void testSendDownloadRequest() {
DistributionSet dsA = testdataFactory.createDistributionSet(UUID.randomUUID().toString()); DistributionSet dsA = testdataFactory.createDistributionSet(UUID.randomUUID().toString());
SoftwareModule module = dsA.getModules().iterator().next(); SoftwareModule module = dsA.getModules().iterator().next();
final List<AbstractDbArtifact> receivedList = new ArrayList<>(); final List<AbstractDbArtifact> receivedList = new ArrayList<>();
@@ -206,9 +207,10 @@ class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
} }
} }
@Test /**
@Description("Verifies that sending update controller attributes event works.") * Verifies that sending update controller attributes event works.
void sendUpdateAttributesRequest() { */
@Test void sendUpdateAttributesRequest() {
final String amqpUri = "amqp://anyhost"; final String amqpUri = "amqp://anyhost";
final TargetAttributesRequestedEvent targetAttributesRequestedEvent = new TargetAttributesRequestedEvent(TENANT, final TargetAttributesRequestedEvent targetAttributesRequestedEvent = new TargetAttributesRequestedEvent(TENANT,
1L, CONTROLLER_ID, amqpUri, Target.class, serviceMatcher.getBusId()); 1L, CONTROLLER_ID, amqpUri, Target.class, serviceMatcher.getBusId());
@@ -219,9 +221,10 @@ class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
assertUpdateAttributesMessage(sendMessage); assertUpdateAttributesMessage(sendMessage);
} }
@Test /**
@Description("Verifies that send cancel event works") * Verifies that send cancel event works
void testSendCancelRequest() { */
@Test void testSendCancelRequest() {
final Action action = mock(Action.class); final Action action = mock(Action.class);
when(action.getId()).thenReturn(1L); when(action.getId()).thenReturn(1L);
when(action.getTenant()).thenReturn(TENANT); when(action.getTenant()).thenReturn(TENANT);
@@ -235,9 +238,10 @@ class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
} }
@Test /**
@Description("Verifies that sending a delete message when receiving a delete event works.") * Verifies that sending a delete message when receiving a delete event works.
void sendDeleteRequest() { */
@Test void sendDeleteRequest() {
// setup // setup
final String amqpUri = "amqp://anyhost"; final String amqpUri = "amqp://anyhost";
@@ -252,9 +256,10 @@ class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
assertDeleteMessage(sendMessage); assertDeleteMessage(sendMessage);
} }
@Test /**
@Description("Verifies that a delete message is not send if the address is not an amqp address.") * Verifies that a delete message is not send if the address is not an amqp address.
void sendDeleteRequestWithNoAmqpAddress() { */
@Test void sendDeleteRequestWithNoAmqpAddress() {
// setup // setup
final String noAmqpUri = "http://anyhost"; final String noAmqpUri = "http://anyhost";
@@ -268,9 +273,10 @@ class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTest {
Mockito.verifyNoInteractions(senderService); Mockito.verifyNoInteractions(senderService);
} }
@Test /**
@Description("Verifies that a delete message is not send if the address is null.") * Verifies that a delete message is not send if the address is null.
void sendDeleteRequestWithNullAddress() { */
@Test void sendDeleteRequestWithNullAddress() {
// setup // setup
final String noAmqpUri = null; final String noAmqpUri = null;

View File

@@ -26,10 +26,6 @@ import java.net.URI;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
import io.qameta.allure.Step;
import io.qameta.allure.Story;
import org.eclipse.hawkbit.dmf.amqp.api.EventTopic; import org.eclipse.hawkbit.dmf.amqp.api.EventTopic;
import org.eclipse.hawkbit.dmf.amqp.api.MessageHeaderKey; import org.eclipse.hawkbit.dmf.amqp.api.MessageHeaderKey;
import org.eclipse.hawkbit.dmf.amqp.api.MessageType; import org.eclipse.hawkbit.dmf.amqp.api.MessageType;
@@ -76,8 +72,10 @@ import org.springframework.amqp.support.converter.MessageConversionException;
import org.springframework.amqp.support.converter.MessageConverter; import org.springframework.amqp.support.converter.MessageConverter;
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
@Feature("Component Tests - Device Management Federation API") /**
@Story("AmqpMessage Handler Service Test") * Feature: Component Tests - Device Management Federation API<br/>
* Story: AmqpMessage Handler Service Test
*/
class AmqpMessageHandlerServiceTest { class AmqpMessageHandlerServiceTest {
private static final String FAIL_MESSAGE_AMQP_REJECT_REASON = AmqpRejectAndDontRequeueException.class private static final String FAIL_MESSAGE_AMQP_REJECT_REASON = AmqpRejectAndDontRequeueException.class
@@ -144,9 +142,10 @@ class AmqpMessageHandlerServiceTest {
confirmationManagementMock); confirmationManagementMock);
} }
@Test /**
@Description("Tests not allowed content-type in message") * Tests not allowed content-type in message
void wrongContentType() { */
@Test void wrongContentType() {
final MessageProperties messageProperties = new MessageProperties(); final MessageProperties messageProperties = new MessageProperties();
messageProperties.setContentType("xml"); messageProperties.setContentType("xml");
final Message message = new Message(new byte[0], messageProperties); final Message message = new Message(new byte[0], messageProperties);
@@ -157,9 +156,10 @@ class AmqpMessageHandlerServiceTest {
VIRTUAL_HOST)); VIRTUAL_HOST));
} }
@Test /**
@Description("Tests the creation of a target/thing by calling the same method that incoming RabbitMQ messages would access.") * Tests the creation of a target/thing by calling the same method that incoming RabbitMQ messages would access.
void createThing() { */
@Test void createThing() {
final String knownThingId = "1"; final String knownThingId = "1";
processThingCreatedMessage(knownThingId, null); processThingCreatedMessage(knownThingId, null);
@@ -168,9 +168,10 @@ class AmqpMessageHandlerServiceTest {
assertReplyToCapturedField("MyTest"); assertReplyToCapturedField("MyTest");
} }
@Test /**
@Description("Tests the creation of a target/thing with specified name by calling the same method that incoming RabbitMQ messages would access.") * Tests the creation of a target/thing with specified name by calling the same method that incoming RabbitMQ messages would access.
void createThingWithName() { */
@Test void createThingWithName() {
final String knownThingId = "2"; final String knownThingId = "2";
final String knownThingName = "NonDefaultTargetName"; final String knownThingName = "NonDefaultTargetName";
@@ -183,9 +184,10 @@ class AmqpMessageHandlerServiceTest {
assertThingNameCapturedField(knownThingName); assertThingNameCapturedField(knownThingName);
} }
@Test /**
@Description("Tests the creation of a target/thing with specified type name by calling the same method that incoming RabbitMQ messages would access.") * Tests the creation of a target/thing with specified type name by calling the same method that incoming RabbitMQ messages would access.
void createThingWithType() { */
@Test void createThingWithType() {
final String knownThingId = "2"; final String knownThingId = "2";
final String knownThingTypeName = "TargetTypeName"; final String knownThingTypeName = "TargetTypeName";
@@ -198,9 +200,10 @@ class AmqpMessageHandlerServiceTest {
assertThingTypeCapturedField(knownThingTypeName); assertThingTypeCapturedField(knownThingTypeName);
} }
@Test /**
@Description("Tests not allowed body in message") * Tests not allowed body in message
void createThingWithWrongBody() { */
@Test void createThingWithWrongBody() {
final Message message = createMessage("Not allowed Body".getBytes(), getThingCreatedMessageProperties("3")); final Message message = createMessage("Not allowed Body".getBytes(), getThingCreatedMessageProperties("3"));
final String type = MessageType.THING_CREATED.name(); final String type = MessageType.THING_CREATED.name();
assertThatExceptionOfType(MessageConversionException.class) assertThatExceptionOfType(MessageConversionException.class)
@@ -208,9 +211,10 @@ class AmqpMessageHandlerServiceTest {
.isThrownBy(() -> amqpMessageHandlerService.onMessage(message, type, TENANT, VIRTUAL_HOST)); .isThrownBy(() -> amqpMessageHandlerService.onMessage(message, type, TENANT, VIRTUAL_HOST));
} }
@Test /**
@Description("Tests the creation of a target/thing with specified attributes by calling the same method that incoming RabbitMQ messages would access.") * Tests the creation of a target/thing with specified attributes by calling the same method that incoming RabbitMQ messages would access.
void createThingWithAttributes() { */
@Test void createThingWithAttributes() {
final String knownThingId = "4"; final String knownThingId = "4";
final DmfAttributeUpdate attributeUpdate = dmfAttributeUpdate(); final DmfAttributeUpdate attributeUpdate = dmfAttributeUpdate();
@@ -224,9 +228,10 @@ class AmqpMessageHandlerServiceTest {
assertThingAttributesCapturedField(attributeUpdate.getAttributes()); assertThingAttributesCapturedField(attributeUpdate.getAttributes());
} }
@Test /**
@Description("Tests the creation of a target/thing with specified name and attributes by calling the same method that incoming RabbitMQ messages would access.") * Tests the creation of a target/thing with specified name and attributes by calling the same method that incoming RabbitMQ messages would access.
void createThingWithNameAndAttributes() { */
@Test void createThingWithNameAndAttributes() {
final String knownThingId = "5"; final String knownThingId = "5";
final String knownThingName = "NonDefaultTargetName"; final String knownThingName = "NonDefaultTargetName";
@@ -242,9 +247,10 @@ class AmqpMessageHandlerServiceTest {
assertThingAttributesModeCapturedField(UpdateMode.REPLACE); assertThingAttributesModeCapturedField(UpdateMode.REPLACE);
} }
@Test /**
@Description("Tests the target attribute update by calling the same method that incoming RabbitMQ messages would access.") * Tests the target attribute update by calling the same method that incoming RabbitMQ messages would access.
void updateAttributes() { */
@Test void updateAttributes() {
final String knownThingId = "1"; final String knownThingId = "1";
final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT); final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT);
messageProperties.setHeader(MessageHeaderKey.THING_ID, knownThingId); messageProperties.setHeader(MessageHeaderKey.THING_ID, knownThingId);
@@ -262,9 +268,10 @@ class AmqpMessageHandlerServiceTest {
assertThingAttributesCapturedField(attributeUpdate.getAttributes()); assertThingAttributesCapturedField(attributeUpdate.getAttributes());
} }
@Test /**
@Description("Verifies that the update mode is retrieved from the UPDATE_ATTRIBUTES message and passed to the controller management.") * Verifies that the update mode is retrieved from the UPDATE_ATTRIBUTES message and passed to the controller management.
void attributeUpdateModes() { */
@Test void attributeUpdateModes() {
final String knownThingId = "1"; final String knownThingId = "1";
final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT); final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT);
messageProperties.setHeader(MessageHeaderKey.THING_ID, knownThingId); messageProperties.setHeader(MessageHeaderKey.THING_ID, knownThingId);
@@ -312,9 +319,10 @@ class AmqpMessageHandlerServiceTest {
Map.of("testKey1", "testValue1", "testKey2", "testValue2"), mode); Map.of("testKey1", "testValue1", "testKey2", "testValue2"), mode);
} }
@Test /**
@Description("Tests the creation of a thing without a 'reply to' header in message.") * Tests the creation of a thing without a 'reply to' header in message.
void createThingWithoutReplyTo() { */
@Test void createThingWithoutReplyTo() {
final MessageProperties messageProperties = createMessageProperties(MessageType.THING_CREATED, null); final MessageProperties messageProperties = createMessageProperties(MessageType.THING_CREATED, null);
messageProperties.setHeader(MessageHeaderKey.THING_ID, "1"); messageProperties.setHeader(MessageHeaderKey.THING_ID, "1");
final Message message = createMessage("", messageProperties); final Message message = createMessage("", messageProperties);
@@ -324,9 +332,10 @@ class AmqpMessageHandlerServiceTest {
.isThrownBy(() -> amqpMessageHandlerService.onMessage(message, type, TENANT, VIRTUAL_HOST)); .isThrownBy(() -> amqpMessageHandlerService.onMessage(message, type, TENANT, VIRTUAL_HOST));
} }
@Test /**
@Description("Tests the creation of a target/thing without a thingID by calling the same method that incoming RabbitMQ messages would access.") * Tests the creation of a target/thing without a thingID by calling the same method that incoming RabbitMQ messages would access.
void createThingWithoutID() { */
@Test void createThingWithoutID() {
final MessageProperties messageProperties = createMessageProperties(MessageType.THING_CREATED); final MessageProperties messageProperties = createMessageProperties(MessageType.THING_CREATED);
final Message message = createMessage(new byte[0], messageProperties); final Message message = createMessage(new byte[0], messageProperties);
final String type = MessageType.THING_CREATED.name(); final String type = MessageType.THING_CREATED.name();
@@ -335,9 +344,10 @@ class AmqpMessageHandlerServiceTest {
.isThrownBy(() -> amqpMessageHandlerService.onMessage(message, type, TENANT, VIRTUAL_HOST)); .isThrownBy(() -> amqpMessageHandlerService.onMessage(message, type, TENANT, VIRTUAL_HOST));
} }
@Test /**
@Description("Tests the call of the same method that incoming RabbitMQ messages would access with an unknown message type.") * Tests the call of the same method that incoming RabbitMQ messages would access with an unknown message type.
void unknownMessageType() { */
@Test void unknownMessageType() {
final String type = "bumlux"; final String type = "bumlux";
final MessageProperties messageProperties = createMessageProperties(MessageType.THING_CREATED); final MessageProperties messageProperties = createMessageProperties(MessageType.THING_CREATED);
messageProperties.setHeader(MessageHeaderKey.THING_ID, ""); messageProperties.setHeader(MessageHeaderKey.THING_ID, "");
@@ -348,9 +358,10 @@ class AmqpMessageHandlerServiceTest {
.isThrownBy(() -> amqpMessageHandlerService.onMessage(message, type, TENANT, VIRTUAL_HOST)); .isThrownBy(() -> amqpMessageHandlerService.onMessage(message, type, TENANT, VIRTUAL_HOST));
} }
@Test /**
@Description("Tests a invalid message without event topic") * Tests a invalid message without event topic
void invalidEventTopic() { */
@Test void invalidEventTopic() {
final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT); final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT);
final Message message = new Message(new byte[0], messageProperties); final Message message = new Message(new byte[0], messageProperties);
@@ -370,9 +381,10 @@ class AmqpMessageHandlerServiceTest {
.isThrownBy(() -> amqpMessageHandlerService.onMessage(message, type, TENANT, VIRTUAL_HOST)); .isThrownBy(() -> amqpMessageHandlerService.onMessage(message, type, TENANT, VIRTUAL_HOST));
} }
@Test /**
@Description("Tests the update of an action of a target without a exist action id") * Tests the update of an action of a target without a exist action id
void updateActionStatusWithoutActionId() { */
@Test void updateActionStatusWithoutActionId() {
when(controllerManagementMock.findActionWithDetails(anyLong())).thenReturn(Optional.empty()); when(controllerManagementMock.findActionWithDetails(anyLong())).thenReturn(Optional.empty());
final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT); final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT);
messageProperties.setHeader(MessageHeaderKey.TOPIC, EventTopic.UPDATE_ACTION_STATUS.name()); messageProperties.setHeader(MessageHeaderKey.TOPIC, EventTopic.UPDATE_ACTION_STATUS.name());
@@ -384,9 +396,10 @@ class AmqpMessageHandlerServiceTest {
.isThrownBy(() -> amqpMessageHandlerService.onMessage(message, type, TENANT, VIRTUAL_HOST)); .isThrownBy(() -> amqpMessageHandlerService.onMessage(message, type, TENANT, VIRTUAL_HOST));
} }
@Test /**
@Description("Tests the update of an action of a target without a exist action id") * Tests the update of an action of a target without a exist action id
void updateActionStatusWithoutExistActionId() { */
@Test void updateActionStatusWithoutExistActionId() {
final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT); final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT);
messageProperties.setHeader(MessageHeaderKey.TOPIC, EventTopic.UPDATE_ACTION_STATUS.name()); messageProperties.setHeader(MessageHeaderKey.TOPIC, EventTopic.UPDATE_ACTION_STATUS.name());
when(controllerManagementMock.findActionWithDetails(anyLong())).thenReturn(Optional.empty()); when(controllerManagementMock.findActionWithDetails(anyLong())).thenReturn(Optional.empty());
@@ -400,9 +413,10 @@ class AmqpMessageHandlerServiceTest {
VIRTUAL_HOST)); VIRTUAL_HOST));
} }
@Test /**
@Description("Tests that messages which cause quota violations are not re-added to message queue so they would block other communication.") * Tests that messages which cause quota violations are not re-added to message queue so they would block other communication.
void quotaExceeded() { */
@Test void quotaExceeded() {
final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT); final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT);
messageProperties.setHeader(MessageHeaderKey.TOPIC, EventTopic.UPDATE_ACTION_STATUS.name()); messageProperties.setHeader(MessageHeaderKey.TOPIC, EventTopic.UPDATE_ACTION_STATUS.name());
@@ -425,9 +439,10 @@ class AmqpMessageHandlerServiceTest {
.isThrownBy(() -> amqpMessageHandlerService.onMessage(message, type, TENANT, VIRTUAL_HOST)); .isThrownBy(() -> amqpMessageHandlerService.onMessage(message, type, TENANT, VIRTUAL_HOST));
} }
@Test /**
@Description("Test next update is provided on finished action") * Test next update is provided on finished action
void lookupNextUpdateActionAfterFinished() throws IllegalAccessException { */
@Test void lookupNextUpdateActionAfterFinished() throws IllegalAccessException {
// Mock // Mock
final Action action = createActionWithTarget(22L); final Action action = createActionWithTarget(22L);
@@ -462,9 +477,10 @@ class AmqpMessageHandlerServiceTest {
assertThat(actionProperties.getId()).as("event has wrong action id").isEqualTo(22L); assertThat(actionProperties.getId()).as("event has wrong action id").isEqualTo(22L);
} }
@Test /**
@Description("Test feedback code is persisted in messages when provided with DmfActionUpdateStatus") * Test feedback code is persisted in messages when provided with DmfActionUpdateStatus
void feedBackCodeIsPersistedInMessages() throws IllegalAccessException { */
@Test void feedBackCodeIsPersistedInMessages() throws IllegalAccessException {
// Mock // Mock
final Action action = createActionWithTarget(22L); final Action action = createActionWithTarget(22L);
when(controllerManagementMock.findActionWithDetails(anyLong())).thenReturn(Optional.of(action)); when(controllerManagementMock.findActionWithDetails(anyLong())).thenReturn(Optional.of(action));
@@ -496,9 +512,10 @@ class AmqpMessageHandlerServiceTest {
.contains("Device reported status code: 12"); .contains("Device reported status code: 12");
} }
@Test /**
@Description("Tests the deletion of a target/thing, requested by the target itself.") * Tests the deletion of a target/thing, requested by the target itself.
void deleteThing() { */
@Test void deleteThing() {
// prepare valid message // prepare valid message
final String knownThingId = "1"; final String knownThingId = "1";
final MessageProperties messageProperties = createMessageProperties(MessageType.THING_REMOVED); final MessageProperties messageProperties = createMessageProperties(MessageType.THING_REMOVED);
@@ -512,9 +529,10 @@ class AmqpMessageHandlerServiceTest {
verify(controllerManagementMock).deleteExistingTarget(knownThingId); verify(controllerManagementMock).deleteExistingTarget(knownThingId);
} }
@Test /**
@Description("Tests the deletion of a target/thing with missing thingId") * Tests the deletion of a target/thing with missing thingId
void deleteThingWithoutThingId() { */
@Test void deleteThingWithoutThingId() {
// prepare invalid message // prepare invalid message
final MessageProperties messageProperties = createMessageProperties(MessageType.THING_REMOVED); final MessageProperties messageProperties = createMessageProperties(MessageType.THING_REMOVED);
final Message message = createMessage(new byte[0], messageProperties); final Message message = createMessage(new byte[0], messageProperties);
@@ -525,9 +543,10 @@ class AmqpMessageHandlerServiceTest {
.isThrownBy(() -> amqpMessageHandlerService.onMessage(message, type, TENANT, VIRTUAL_HOST)); .isThrownBy(() -> amqpMessageHandlerService.onMessage(message, type, TENANT, VIRTUAL_HOST));
} }
@Test /**
@Description("Tests activating auto-confirmation on a target.") * Tests activating auto-confirmation on a target.
void setAutoConfirmationStateActive() { */
@Test void setAutoConfirmationStateActive() {
final String knownThingId = "1"; final String knownThingId = "1";
final String initiator = "iAmTheInitiator"; final String initiator = "iAmTheInitiator";
final String remark = "remarkForTesting"; final String remark = "remarkForTesting";
@@ -551,9 +570,10 @@ class AmqpMessageHandlerServiceTest {
assertRemarkCapturedField(remark); assertRemarkCapturedField(remark);
} }
@Test /**
@Description("Tests deactivating auto-confirmation on a target.") * Tests deactivating auto-confirmation on a target.
void setAutoConfirmationStateDeactivated() { */
@Test void setAutoConfirmationStateDeactivated() {
final String knownThingId = "1"; final String knownThingId = "1";
final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT); final MessageProperties messageProperties = createMessageProperties(MessageType.EVENT);
@@ -571,7 +591,6 @@ class AmqpMessageHandlerServiceTest {
assertThingIdCapturedField(knownThingId); assertThingIdCapturedField(knownThingId);
} }
@Step
private void processThingCreatedMessage(final String thingId, final DmfCreateThing payload) { private void processThingCreatedMessage(final String thingId, final DmfCreateThing payload) {
final MessageProperties messageProperties = getThingCreatedMessageProperties(thingId); final MessageProperties messageProperties = getThingCreatedMessageProperties(thingId);
final Message message = createMessage(payload != null ? payload : new byte[0], messageProperties); final Message message = createMessage(payload != null ? payload : new byte[0], messageProperties);
@@ -594,42 +613,34 @@ class AmqpMessageHandlerServiceTest {
amqpMessageHandlerService.onMessage(message, MessageType.THING_CREATED.name(), TENANT, VIRTUAL_HOST); amqpMessageHandlerService.onMessage(message, MessageType.THING_CREATED.name(), TENANT, VIRTUAL_HOST);
} }
@Step
private void assertThingIdCapturedField(final String thingId) { private void assertThingIdCapturedField(final String thingId) {
assertThat(targetIdCaptor.getValue()).as("Thing id is wrong").isEqualTo(thingId); assertThat(targetIdCaptor.getValue()).as("Thing id is wrong").isEqualTo(thingId);
} }
@Step
private void assertReplyToCapturedField(final String replyTo) { private void assertReplyToCapturedField(final String replyTo) {
assertThat(uriCaptor.getValue()).as("Uri is not right").hasToString("amqp://" + VIRTUAL_HOST + "/" + replyTo); assertThat(uriCaptor.getValue()).as("Uri is not right").hasToString("amqp://" + VIRTUAL_HOST + "/" + replyTo);
} }
@Step
private void assertInitiatorCapturedField(final String initiator) { private void assertInitiatorCapturedField(final String initiator) {
assertThat(initiatorCaptor.getValue()).as("Initiator is wrong").isEqualTo(initiator); assertThat(initiatorCaptor.getValue()).as("Initiator is wrong").isEqualTo(initiator);
} }
@Step
private void assertRemarkCapturedField(final String remark) { private void assertRemarkCapturedField(final String remark) {
assertThat(remarkCaptor.getValue()).as("Remark is wrong").isEqualTo(remark); assertThat(remarkCaptor.getValue()).as("Remark is wrong").isEqualTo(remark);
} }
@Step
private void assertThingNameCapturedField(final String thingName) { private void assertThingNameCapturedField(final String thingName) {
assertThat(targetNameCaptor.getValue()).as("Thing name is wrong").isEqualTo(thingName); assertThat(targetNameCaptor.getValue()).as("Thing name is wrong").isEqualTo(thingName);
} }
@Step
private void assertThingTypeCapturedField(final String thingType) { private void assertThingTypeCapturedField(final String thingType) {
assertThat(targetTypeNameCaptor.getValue()).as("Thing type is wrong").isEqualTo(thingType); assertThat(targetTypeNameCaptor.getValue()).as("Thing type is wrong").isEqualTo(thingType);
} }
@Step
private void assertThingAttributesCapturedField(final Map<String, String> attributes) { private void assertThingAttributesCapturedField(final Map<String, String> attributes) {
assertThat(attributesCaptor.getValue()).as("Attributes is not right").isEqualTo(attributes); assertThat(attributesCaptor.getValue()).as("Attributes is not right").isEqualTo(attributes);
} }
@Step
private void assertThingAttributesModeCapturedField(final UpdateMode attributesUpdateMode) { private void assertThingAttributesModeCapturedField(final UpdateMode attributesUpdateMode) {
assertThat(modeCaptor.getValue()).as("Attributes update mode is not right").isEqualTo(attributesUpdateMode); assertThat(modeCaptor.getValue()).as("Attributes update mode is not right").isEqualTo(attributesUpdateMode);
} }

View File

@@ -15,9 +15,6 @@ import static org.mockito.Mockito.when;
import java.util.List; import java.util.List;
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
import io.qameta.allure.Story;
import org.eclipse.hawkbit.dmf.json.model.DmfActionStatus; import org.eclipse.hawkbit.dmf.json.model.DmfActionStatus;
import org.eclipse.hawkbit.dmf.json.model.DmfActionUpdateStatus; import org.eclipse.hawkbit.dmf.json.model.DmfActionUpdateStatus;
import org.eclipse.hawkbit.repository.event.remote.entity.TargetCreatedEvent; import org.eclipse.hawkbit.repository.event.remote.entity.TargetCreatedEvent;
@@ -35,8 +32,10 @@ import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConversionException; import org.springframework.amqp.support.converter.MessageConversionException;
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
@Feature("Component Tests - Device Management Federation API") /**
@Story("Base Amqp Service Test") * Feature: Component Tests - Device Management Federation API<br/>
* Story: Base Amqp Service Test
*/
class BaseAmqpServiceTest { class BaseAmqpServiceTest {
@Mock @Mock
@@ -49,9 +48,10 @@ class BaseAmqpServiceTest {
baseAmqpService = new BaseAmqpService(rabbitTemplate); baseAmqpService = new BaseAmqpService(rabbitTemplate);
} }
@Test /**
@Description("Verify that the message conversion works") * Verify that the message conversion works
void convertMessageTest() { */
@Test void convertMessageTest() {
final DmfActionUpdateStatus actionUpdateStatus = createActionStatus(); final DmfActionUpdateStatus actionUpdateStatus = createActionStatus();
when(rabbitTemplate.getMessageConverter()).thenReturn(new Jackson2JsonMessageConverter()); when(rabbitTemplate.getMessageConverter()).thenReturn(new Jackson2JsonMessageConverter());
@@ -60,18 +60,20 @@ class BaseAmqpServiceTest {
assertThat(convertedActionUpdateStatus).usingRecursiveComparison().isEqualTo(actionUpdateStatus); assertThat(convertedActionUpdateStatus).usingRecursiveComparison().isEqualTo(actionUpdateStatus);
} }
@Test /**
@Description("Tests invalid null message content") * Tests invalid null message content
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) }) */
@Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
void convertMessageWithNullContent() { void convertMessageWithNullContent() {
assertThatExceptionOfType(IllegalArgumentException.class) assertThatExceptionOfType(IllegalArgumentException.class)
.as("Expected IllegalArgumentException for invalid (null) JSON") .as("Expected IllegalArgumentException for invalid (null) JSON")
.isThrownBy(() -> createMessage(null)); .isThrownBy(() -> createMessage(null));
} }
@Test /**
@Description("Tests invalid empty message content") * Tests invalid empty message content
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) }) */
@Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
void updateActionStatusWithEmptyContent() { void updateActionStatusWithEmptyContent() {
final Message message = createMessage("".getBytes()); final Message message = createMessage("".getBytes());
assertThatExceptionOfType(MessageConversionException.class) assertThatExceptionOfType(MessageConversionException.class)
@@ -79,9 +81,10 @@ class BaseAmqpServiceTest {
.isThrownBy(() -> baseAmqpService.convertMessage(message, DmfActionUpdateStatus.class)); .isThrownBy(() -> baseAmqpService.convertMessage(message, DmfActionUpdateStatus.class));
} }
@Test /**
@Description("Tests invalid json message content") * Tests invalid json message content
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) }) */
@Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 0) })
void updateActionStatusWithInvalidJsonContent() { void updateActionStatusWithInvalidJsonContent() {
final Message message = createMessage("Invalid Json".getBytes()); final Message message = createMessage("Invalid Json".getBytes());
when(rabbitTemplate.getMessageConverter()).thenReturn(new Jackson2JsonMessageConverter()); when(rabbitTemplate.getMessageConverter()).thenReturn(new Jackson2JsonMessageConverter());

View File

@@ -13,45 +13,48 @@ import static org.assertj.core.api.Assertions.assertThat;
import java.util.List; import java.util.List;
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
import io.qameta.allure.Story;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.amqp.rabbit.listener.FatalExceptionStrategy; import org.springframework.amqp.rabbit.listener.FatalExceptionStrategy;
import org.springframework.amqp.support.converter.MessageConversionException; import org.springframework.amqp.support.converter.MessageConversionException;
@Feature("Unit Tests - Requeue Exception Strategy") /**
@Story("Requeue Exception Strategy") * Feature: Unit Tests - Requeue Exception Strategy<br/>
* Story: Requeue Exception Strategy
*/
class RequestExceptionStrategyTest { class RequestExceptionStrategyTest {
private final FatalExceptionStrategy requeueExceptionStrategy = new RequeueExceptionStrategy( private final FatalExceptionStrategy requeueExceptionStrategy = new RequeueExceptionStrategy(
List.of(new RequeueExceptionStrategy.TypeBasedFatalExceptionStrategy( List.of(new RequeueExceptionStrategy.TypeBasedFatalExceptionStrategy(
IllegalArgumentException.class, IndexOutOfBoundsException.class)), null); IllegalArgumentException.class, IndexOutOfBoundsException.class)), null);
@Test /**
@Description("Verifies that default handler is used if no handlers are defined for the specific exception.") * Verifies that default handler is used if no handlers are defined for the specific exception.
void verifyDefaultFatal() { */
@Test void verifyDefaultFatal() {
assertThat(requeueExceptionStrategy.isFatal(new MessageConversionException("t"))).as("Non Fatal error").isTrue(); assertThat(requeueExceptionStrategy.isFatal(new MessageConversionException("t"))).as("Non Fatal error").isTrue();
assertThat(requeueExceptionStrategy.isFatal(new Throwable(new MessageConversionException("t")))).as("Non Fatal error").isTrue(); assertThat(requeueExceptionStrategy.isFatal(new Throwable(new MessageConversionException("t")))).as("Non Fatal error").isTrue();
} }
@Test /**
@Description("Verifies additional fatal exception types are fatal.") * Verifies additional fatal exception types are fatal.
void verifyAdditionalFatal() { */
@Test void verifyAdditionalFatal() {
assertThat(requeueExceptionStrategy.isFatal(new IllegalArgumentException())).isTrue(); assertThat(requeueExceptionStrategy.isFatal(new IllegalArgumentException())).isTrue();
assertThat(requeueExceptionStrategy.isFatal(new IndexOutOfBoundsException())).isTrue(); assertThat(requeueExceptionStrategy.isFatal(new IndexOutOfBoundsException())).isTrue();
} }
@Test /**
@Description("Verifies additional fatal exception types are fatal.") * Verifies additional fatal exception types are fatal.
void verifyAdditionalWrappedFatal() { */
@Test void verifyAdditionalWrappedFatal() {
assertThat(requeueExceptionStrategy.isFatal(new Throwable(new IllegalArgumentException()))).isTrue(); assertThat(requeueExceptionStrategy.isFatal(new Throwable(new IllegalArgumentException()))).isTrue();
assertThat(requeueExceptionStrategy.isFatal(new Throwable(new IndexOutOfBoundsException()))).isTrue(); assertThat(requeueExceptionStrategy.isFatal(new Throwable(new IndexOutOfBoundsException()))).isTrue();
} }
@Test /**
@Description("Verifies that default handler is used if no handlers are defined for the specific exception.") * Verifies that default handler is used if no handlers are defined for the specific exception.
void verifyNonFatal() { */
@Test void verifyNonFatal() {
assertThat(requeueExceptionStrategy.isFatal(new NullPointerException())).isFalse(); assertThat(requeueExceptionStrategy.isFatal(new NullPointerException())).isFalse();
assertThat(requeueExceptionStrategy.isFatal(new Throwable(new NullPointerException()))).isFalse(); assertThat(requeueExceptionStrategy.isFatal(new Throwable(new NullPointerException()))).isFalse();
} }

View File

@@ -22,7 +22,6 @@ import java.util.UUID;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import com.cronutils.utils.StringUtils; import com.cronutils.utils.StringUtils;
import io.qameta.allure.Step;
import org.assertj.core.api.HamcrestCondition; import org.assertj.core.api.HamcrestCondition;
import org.eclipse.hawkbit.amqp.DmfApiConfiguration; import org.eclipse.hawkbit.amqp.DmfApiConfiguration;
import org.eclipse.hawkbit.dmf.amqp.api.AmqpSettings; import org.eclipse.hawkbit.dmf.amqp.api.AmqpSettings;
@@ -254,7 +253,6 @@ abstract class AbstractAmqpServiceIntegrationTest extends AbstractAmqpIntegratio
return replyMessage; return replyMessage;
} }
@Step
protected void registerAndAssertTargetWithExistingTenant(final String controllerId) { protected void registerAndAssertTargetWithExistingTenant(final String controllerId) {
registerAndAssertTargetWithExistingTenant(controllerId, 1); registerAndAssertTargetWithExistingTenant(controllerId, 1);
} }
@@ -372,7 +370,6 @@ abstract class AbstractAmqpServiceIntegrationTest extends AbstractAmqpIntegratio
} }
@Step
protected void assertUpdateAttributes(final String controllerId, final Map<String, String> attributes) { protected void assertUpdateAttributes(final String controllerId, final Map<String, String> attributes) {
waitUntilIsPresent(() -> controllerManagement.getByControllerId(controllerId)); waitUntilIsPresent(() -> controllerManagement.getByControllerId(controllerId));
@@ -393,7 +390,6 @@ abstract class AbstractAmqpServiceIntegrationTest extends AbstractAmqpIntegratio
return AmqpSettings.DMF_EXCHANGE; return AmqpSettings.DMF_EXCHANGE;
} }
@Step
protected DistributionSet createTargetAndDistributionSetAndAssign(final String controllerId, final Action.ActionType actionType) { protected DistributionSet createTargetAndDistributionSetAndAssign(final String controllerId, final Action.ActionType actionType) {
registerAndAssertTargetWithExistingTenant(controllerId); registerAndAssertTargetWithExistingTenant(controllerId);

View File

@@ -30,9 +30,6 @@ import java.util.UUID;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
import io.qameta.allure.Story;
import org.eclipse.hawkbit.dmf.amqp.api.EventTopic; import org.eclipse.hawkbit.dmf.amqp.api.EventTopic;
import org.eclipse.hawkbit.dmf.amqp.api.MessageHeaderKey; import org.eclipse.hawkbit.dmf.amqp.api.MessageHeaderKey;
import org.eclipse.hawkbit.dmf.json.model.DmfActionRequest; import org.eclipse.hawkbit.dmf.json.model.DmfActionRequest;
@@ -83,15 +80,18 @@ import org.junit.jupiter.params.provider.EnumSource;
import org.mockito.Mockito; import org.mockito.Mockito;
import org.springframework.amqp.core.Message; import org.springframework.amqp.core.Message;
@Feature("Component Tests - Device Management Federation API") /**
@Story("Amqp Message Dispatcher Service") * Feature: Component Tests - Device Management Federation API<br/>
* Story: Amqp Message Dispatcher Service
*/
class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceIntegrationTest { class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceIntegrationTest {
private static final String TARGET_PREFIX = "Dmf_disp_"; private static final String TARGET_PREFIX = "Dmf_disp_";
@Test /**
@Description("Verify that a distribution assignment send a download and install message.") * Verify that a distribution assignment send a download and install message.
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@@ -109,9 +109,10 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
assertDownloadAndInstallMessage(getDistributionSet().getModules(), controllerId); assertDownloadAndInstallMessage(getDistributionSet().getModules(), controllerId);
} }
@Test /**
@Description("Verify that a distribution assignment sends a download message with window configured but before maintenance window start time.") * Verify that a distribution assignment sends a download message with window configured but before maintenance window start time.
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@@ -134,9 +135,10 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
assertDownloadMessage(distributionSet.getModules(), controllerId); assertDownloadMessage(distributionSet.getModules(), controllerId);
} }
@Test /**
@Description("Verify that a distribution assignment sends a download and install message with window configured and during maintenance window start time.") * Verify that a distribution assignment sends a download and install message with window configured and during maintenance window start time.
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@@ -159,9 +161,10 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
assertDownloadAndInstallMessage(distributionSet.getModules(), controllerId); assertDownloadAndInstallMessage(distributionSet.getModules(), controllerId);
} }
@Test /**
@Description("Verify that a distribution assignment multiple times send cancel and assign events with right softwaremodules") * Verify that a distribution assignment multiple times send cancel and assign events with right softwaremodules
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 2), @Expect(type = TargetAssignDistributionSetEvent.class, count = 2),
@Expect(type = CancelTargetAssignmentEvent.class, count = 1), @Expect(type = CancelTargetAssignmentEvent.class, count = 1),
@@ -205,9 +208,10 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
assertDownloadAndInstallMessage(distributionSet2.getModules(), controllerId); assertDownloadAndInstallMessage(distributionSet2.getModules(), controllerId);
} }
@Test /**
@Description("If multi assignment is enabled multi-action messages are sent.") * If multi assignment is enabled multi-action messages are sent.
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = MultiActionAssignEvent.class, count = 2), @Expect(type = MultiActionAssignEvent.class, count = 2),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 0), @Expect(type = TargetAssignDistributionSetEvent.class, count = 0),
@@ -237,9 +241,10 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
assertLatestMultiActionMessage(controllerId, Arrays.asList(action1Install, action2Install)); assertLatestMultiActionMessage(controllerId, Arrays.asList(action1Install, action2Install));
} }
@Test /**
@Description("Verify payload of multi action messages.") * Verify payload of multi action messages.
void assertMultiActionMessagePayloads() { */
@Test void assertMultiActionMessagePayloads() {
final int expectedWeightIfNotSet = 1000; final int expectedWeightIfNotSet = 1000;
final int weight1 = 600; final int weight1 = 600;
final String controllerId = UUID.randomUUID().toString(); final String controllerId = UUID.randomUUID().toString();
@@ -286,9 +291,10 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
controllerId); controllerId);
} }
@Test /**
@Description("Handle cancelation process of an action in multi assignment mode.") * Handle cancelation process of an action in multi assignment mode.
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 2), @Expect(type = TargetUpdatedEvent.class, count = 2),
@Expect(type = TargetPollEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1),
@@ -325,9 +331,10 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
assertLatestMultiActionMessage(controllerId, Collections.singletonList(action2Install)); assertLatestMultiActionMessage(controllerId, Collections.singletonList(action2Install));
} }
@Test /**
@Description("Handle finishing an action in multi assignment mode.") * Handle finishing an action in multi assignment mode.
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = MultiActionAssignEvent.class, count = 2), @Expect(type = MultiActionAssignEvent.class, count = 2),
@Expect(type = TargetAttributesRequestedEvent.class, count = 1), @Expect(type = TargetAttributesRequestedEvent.class, count = 1),
@@ -358,9 +365,10 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
assertLatestMultiActionMessage(controllerId, Collections.singletonList(action2Install)); assertLatestMultiActionMessage(controllerId, Collections.singletonList(action2Install));
} }
@Test /**
@Description("If multi assignment is enabled assigning a DS multiple times creates a new action every time.") * If multi assignment is enabled assigning a DS multiple times creates a new action every time.
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = MultiActionAssignEvent.class, count = 2), @Expect(type = MultiActionAssignEvent.class, count = 2),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 0), @Expect(type = TargetAssignDistributionSetEvent.class, count = 0),
@@ -390,9 +398,10 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
assertLatestMultiActionMessage(controllerId, Arrays.asList(action1Install, action2Install)); assertLatestMultiActionMessage(controllerId, Arrays.asList(action1Install, action2Install));
} }
@Test /**
@Description("If multi assignment is enabled multiple rollouts with the same DS lead to multiple actions.") * If multi assignment is enabled multiple rollouts with the same DS lead to multiple actions.
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = MultiActionAssignEvent.class, count = 2), @Expect(type = MultiActionAssignEvent.class, count = 2),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 0), @Expect(type = TargetAssignDistributionSetEvent.class, count = 0),
@@ -428,9 +437,10 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
assertLatestMultiActionMessageContainsInstallMessages(controllerId, Arrays.asList(smIds, smIds)); assertLatestMultiActionMessageContainsInstallMessages(controllerId, Arrays.asList(smIds, smIds));
} }
@Test /**
@Description("If multi assignment is enabled finishing one rollout does not affect other rollouts of the target.") * If multi assignment is enabled finishing one rollout does not affect other rollouts of the target.
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = MultiActionAssignEvent.class, count = 3), @Expect(type = MultiActionAssignEvent.class, count = 3),
@Expect(type = ActionCreatedEvent.class, count = 3), @Expect(type = ActionCreatedEvent.class, count = 3),
@@ -479,9 +489,10 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
assertLatestMultiActionMessageContainsInstallMessages(controllerId, Collections.singletonList(smIds1)); assertLatestMultiActionMessageContainsInstallMessages(controllerId, Collections.singletonList(smIds1));
} }
@Test /**
@Description("Verify that a cancel assignment send a cancel message.") * Verify that a cancel assignment send a cancel message.
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = CancelTargetAssignmentEvent.class, count = 1), @Expect(type = CancelTargetAssignmentEvent.class, count = 1),
@@ -503,9 +514,10 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
assertCancelActionMessage(actionId, controllerId); assertCancelActionMessage(actionId, controllerId);
} }
@Test /**
@Description("Verify that when a target is deleted a target delete message is send.") * Verify that when a target is deleted a target delete message is send.
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetPollEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1),
@Expect(type = TargetDeletedEvent.class, count = 1) }) @Expect(type = TargetDeletedEvent.class, count = 1) })
@@ -517,9 +529,10 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
assertDeleteMessage(controllerId); assertDeleteMessage(controllerId);
} }
@Test /**
@Description("Verify that attribute update is requested after device successfully closed software update.") * Verify that attribute update is requested after device successfully closed software update.
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 2), @Expect(type = TargetAssignDistributionSetEvent.class, count = 2),
@Expect(type = ActionUpdatedEvent.class, count = 2), @Expect(type = ActionUpdatedEvent.class, count = 2),
@@ -546,9 +559,10 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
assertRequestAttributesUpdateMessage(controllerId); assertRequestAttributesUpdateMessage(controllerId);
} }
@Test /**
@Description("Tests the download_only assignment: asserts correct dmf Message topic, and assigned DS") * Tests the download_only assignment: asserts correct dmf Message topic, and assigned DS
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@@ -580,15 +594,17 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
assertThat(assignedDistributionSet.getId()).isEqualTo(distributionSet.getId()); assertThat(assignedDistributionSet.getId()).isEqualTo(distributionSet.getId());
} }
@Test /**
@Description("Verify payload of batch assignment download and install message.") * Verify payload of batch assignment download and install message.
void assertBatchAssignmentsDownloadAndInstall() { */
@Test void assertBatchAssignmentsDownloadAndInstall() {
assertBatchAssignmentsMessagePayload(BATCH_DOWNLOAD_AND_INSTALL); assertBatchAssignmentsMessagePayload(BATCH_DOWNLOAD_AND_INSTALL);
} }
@Test /**
@Description("Verify payload of batch assignments download only message.") * Verify payload of batch assignments download only message.
void assertBatchAssignmentsDownloadOnly() { */
@Test void assertBatchAssignmentsDownloadOnly() {
assertBatchAssignmentsMessagePayload(BATCH_DOWNLOAD); assertBatchAssignmentsMessagePayload(BATCH_DOWNLOAD);
} }
@@ -616,9 +632,10 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
assertThat(replyToListener.getLatestEventMessage(eventTopic)).isNull(); assertThat(replyToListener.getLatestEventMessage(eventTopic)).isNull();
} }
@Test /**
@Description("Verify that batch and multi-assignments can't be activated at the same time.") * Verify that batch and multi-assignments can't be activated at the same time.
void assertBatchAndMultiAssignmentsNotCompatible() { */
@Test void assertBatchAndMultiAssignmentsNotCompatible() {
enableBatchAssignments(); enableBatchAssignments();
assertThatExceptionOfType(TenantConfigurationValueChangeNotAllowedException.class) assertThatExceptionOfType(TenantConfigurationValueChangeNotAllowedException.class)
.isThrownBy(() -> enableMultiAssignments()); .isThrownBy(() -> enableMultiAssignments());
@@ -629,9 +646,11 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
.isThrownBy(() -> enableBatchAssignments()); .isThrownBy(() -> enableBatchAssignments());
} }
/**
* Verify payload of batch assignments.
*/
@ParameterizedTest @ParameterizedTest
@EnumSource(names = { "BATCH_DOWNLOAD_AND_INSTALL", "BATCH_DOWNLOAD" }) @EnumSource(names = { "BATCH_DOWNLOAD_AND_INSTALL", "BATCH_DOWNLOAD" })
@Description("Verify payload of batch assignments.")
@ExpectEvents({ @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 3), @Expect(type = TargetCreatedEvent.class, count = 3),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@@ -672,9 +691,10 @@ class AmqpMessageDispatcherServiceIntegrationTest extends AbstractAmqpServiceInt
assertDmfBatchDownloadAndUpdateRequest(batchRequest, ds.getModules(), targets); assertDmfBatchDownloadAndUpdateRequest(batchRequest, ds.getModules(), targets);
} }
@Test /**
@Description("Verify that a distribution assignment send a confirm message.") * Verify that a distribution assignment send a confirm message.
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),

View File

@@ -27,10 +27,6 @@ import java.util.UUID;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ObjectNode;
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
import io.qameta.allure.Step;
import io.qameta.allure.Story;
import org.eclipse.hawkbit.amqp.AmqpMessageHandlerService; import org.eclipse.hawkbit.amqp.AmqpMessageHandlerService;
import org.eclipse.hawkbit.amqp.AmqpProperties; import org.eclipse.hawkbit.amqp.AmqpProperties;
import org.eclipse.hawkbit.dmf.amqp.api.EventTopic; import org.eclipse.hawkbit.dmf.amqp.api.EventTopic;
@@ -78,8 +74,10 @@ import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.core.RabbitAdmin; import org.springframework.amqp.rabbit.core.RabbitAdmin;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@Feature("Component Tests - Device Management Federation API") /**
@Story("Amqp Message Handler Service") * Feature: Component Tests - Device Management Federation API<br/>
* Story: Amqp Message Handler Service
*/
class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegrationTest { class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegrationTest {
static final String DMF_REGISTER_TEST_CONTROLLER_ID = "Dmf_hand_registerTargets_1"; static final String DMF_REGISTER_TEST_CONTROLLER_ID = "Dmf_hand_registerTargets_1";
@@ -93,9 +91,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
@Autowired @Autowired
private AmqpMessageHandlerService amqpMessageHandlerService; private AmqpMessageHandlerService amqpMessageHandlerService;
@Test /**
@Description("Tests DMF PING request and expected response.") * Tests DMF PING request and expected response.
void pingDmfInterface() { */
@Test void pingDmfInterface() {
final Message pingMessage = createPingMessage(CORRELATION_ID, TENANT_EXIST); final Message pingMessage = createPingMessage(CORRELATION_ID, TENANT_EXIST);
getDmfClient().send(pingMessage); getDmfClient().send(pingMessage);
@@ -104,9 +103,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
Mockito.verifyNoInteractions(getDeadletterListener()); Mockito.verifyNoInteractions(getDeadletterListener());
} }
@Test /**
@Description("Tests register target") * Tests register target
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 2), @Expect(type = TargetCreatedEvent.class, count = 2),
@Expect(type = TargetPollEvent.class, count = 3) }) @Expect(type = TargetPollEvent.class, count = 3) })
void registerTargets() { void registerTargets() {
@@ -120,9 +120,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
Mockito.verifyNoInteractions(getDeadletterListener()); Mockito.verifyNoInteractions(getDeadletterListener());
} }
@Test /**
@Description("Tests register target with name") * Tests register target with name
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 1), @Expect(type = TargetUpdatedEvent.class, count = 1),
@Expect(type = TargetPollEvent.class, count = 2) }) @Expect(type = TargetPollEvent.class, count = 2) })
@@ -138,9 +139,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
Mockito.verifyNoInteractions(getDeadletterListener()); Mockito.verifyNoInteractions(getDeadletterListener());
} }
@Test /**
@Description("Tests register target with attributes") * Tests register target with attributes
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 2), @Expect(type = TargetUpdatedEvent.class, count = 2),
@Expect(type = TargetPollEvent.class, count = 2) }) @Expect(type = TargetPollEvent.class, count = 2) })
@@ -159,9 +161,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
Mockito.verifyNoInteractions(getDeadletterListener()); Mockito.verifyNoInteractions(getDeadletterListener());
} }
@Test /**
@Description("Tests register target with name and attributes") * Tests register target with name and attributes
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 3), @Expect(type = TargetUpdatedEvent.class, count = 3),
@Expect(type = TargetPollEvent.class, count = 2) }) @Expect(type = TargetPollEvent.class, count = 2) })
@@ -183,9 +186,11 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
} }
@ParameterizedTest @ParameterizedTest
/**
* Tests register invalid target with empty controller id.
*/
@ValueSource(strings = { "", "Invalid Invalid" }) @ValueSource(strings = { "", "Invalid Invalid" })
@NullSource @NullSource
@Description("Tests register invalid target with empty controller id.")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) }) @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
void shouldNotRegisterTargetsWithInvalidControllerIds(String controllerId) { void shouldNotRegisterTargetsWithInvalidControllerIds(String controllerId) {
createAndSendThingCreated(controllerId); createAndSendThingCreated(controllerId);
@@ -193,18 +198,20 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
verifyOneDeadLetterMessage(); verifyOneDeadLetterMessage();
} }
@Test /**
@Description("Tests register invalid target with too long controller id") * Tests register invalid target with too long controller id
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) }) */
@Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
void registerInvalidTargetWithTooLongControllerId() { void registerInvalidTargetWithTooLongControllerId() {
createAndSendThingCreated(randomString(Target.CONTROLLER_ID_MAX_SIZE + 1)); createAndSendThingCreated(randomString(Target.CONTROLLER_ID_MAX_SIZE + 1));
assertAllTargetsCount(0); assertAllTargetsCount(0);
verifyOneDeadLetterMessage(); verifyOneDeadLetterMessage();
} }
@Test /**
@Description("Tests null reply to property in message header. This message should forwarded to the deadletter queue") * Tests null reply to property in message header. This message should forwarded to the deadletter queue
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) }) */
@Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
void missingReplyToProperty() { void missingReplyToProperty() {
final String controllerId = TARGET_PREFIX + "missingReplyToProperty"; final String controllerId = TARGET_PREFIX + "missingReplyToProperty";
final Message createTargetMessage = createTargetMessage(controllerId, TENANT_EXIST); final Message createTargetMessage = createTargetMessage(controllerId, TENANT_EXIST);
@@ -215,9 +222,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
assertAllTargetsCount(0); assertAllTargetsCount(0);
} }
@Test /**
@Description("Tests missing reply to property in message header. This message should forwarded to the deadletter queue") * Tests missing reply to property in message header. This message should forwarded to the deadletter queue
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) }) */
@Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
void emptyReplyToProperty() { void emptyReplyToProperty() {
final String controllerId = TARGET_PREFIX + "emptyReplyToProperty"; final String controllerId = TARGET_PREFIX + "emptyReplyToProperty";
final Message createTargetMessage = createTargetMessage(controllerId, TENANT_EXIST); final Message createTargetMessage = createTargetMessage(controllerId, TENANT_EXIST);
@@ -228,9 +236,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
assertAllTargetsCount(0); assertAllTargetsCount(0);
} }
@Test /**
@Description("Tests missing thing id property in message. This message should forwarded to the deadletter queue") * Tests missing thing id property in message. This message should forwarded to the deadletter queue
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) }) */
@Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
void missingThingIdProperty() { void missingThingIdProperty() {
final Message createTargetMessage = createTargetMessage(null, TENANT_EXIST); final Message createTargetMessage = createTargetMessage(null, TENANT_EXIST);
createTargetMessage.getMessageProperties().getHeaders().remove(MessageHeaderKey.THING_ID); createTargetMessage.getMessageProperties().getHeaders().remove(MessageHeaderKey.THING_ID);
@@ -240,9 +249,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
assertAllTargetsCount(0); assertAllTargetsCount(0);
} }
@Test /**
@Description("Tests null thing id property in message. This message should forwarded to the deadletter queue") * Tests null thing id property in message. This message should forwarded to the deadletter queue
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) }) */
@Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
void nullThingIdProperty() { void nullThingIdProperty() {
final Message createTargetMessage = createTargetMessage(null, TENANT_EXIST); final Message createTargetMessage = createTargetMessage(null, TENANT_EXIST);
getDmfClient().send(createTargetMessage); getDmfClient().send(createTargetMessage);
@@ -251,9 +261,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
assertAllTargetsCount(0); assertAllTargetsCount(0);
} }
@Test /**
@Description("Tests missing tenant message header. This message should forwarded to the deadletter queue") * Tests missing tenant message header. This message should forwarded to the deadletter queue
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) }) */
@Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
void missingTenantHeader() { void missingTenantHeader() {
final String controllerId = TARGET_PREFIX + "missingTenantHeader"; final String controllerId = TARGET_PREFIX + "missingTenantHeader";
final Message createTargetMessage = createTargetMessage(controllerId, TENANT_EXIST); final Message createTargetMessage = createTargetMessage(controllerId, TENANT_EXIST);
@@ -264,9 +275,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
assertAllTargetsCount(0); assertAllTargetsCount(0);
} }
@Test /**
@Description("Tests null tenant message header. This message should forwarded to the deadletter queue") * Tests null tenant message header. This message should forwarded to the deadletter queue
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) }) */
@Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
void nullTenantHeader() { void nullTenantHeader() {
final String controllerId = TARGET_PREFIX + "nullTenantHeader"; final String controllerId = TARGET_PREFIX + "nullTenantHeader";
final Message createTargetMessage = createTargetMessage(controllerId, null); final Message createTargetMessage = createTargetMessage(controllerId, null);
@@ -276,9 +288,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
assertAllTargetsCount(0); assertAllTargetsCount(0);
} }
@Test /**
@Description("Tests empty tenant message header. This message should forwarded to the deadletter queue") * Tests empty tenant message header. This message should forwarded to the deadletter queue
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) }) */
@Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
void emptyTenantHeader() { void emptyTenantHeader() {
final String controllerId = TARGET_PREFIX + "emptyTenantHeader"; final String controllerId = TARGET_PREFIX + "emptyTenantHeader";
final Message createTargetMessage = createTargetMessage(controllerId, ""); final Message createTargetMessage = createTargetMessage(controllerId, "");
@@ -288,9 +301,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
assertAllTargetsCount(0); assertAllTargetsCount(0);
} }
@Test /**
@Description("Tests missing type message header. This message should forwarded to the deadletter queue") * Tests missing type message header. This message should forwarded to the deadletter queue
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) }) */
@Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
void missingTypeHeader() { void missingTypeHeader() {
final Message createTargetMessage = createTargetMessage(null, TENANT_EXIST); final Message createTargetMessage = createTargetMessage(null, TENANT_EXIST);
createTargetMessage.getMessageProperties().getHeaders().remove(MessageHeaderKey.TYPE); createTargetMessage.getMessageProperties().getHeaders().remove(MessageHeaderKey.TYPE);
@@ -301,9 +315,11 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
} }
@ParameterizedTest @ParameterizedTest
/**
* Tests null type message header. This message should forwarded to the deadletter queue
*/
@ValueSource(strings = { "", "NotExist" }) @ValueSource(strings = { "", "NotExist" })
@NullSource @NullSource
@Description("Tests null type message header. This message should forwarded to the deadletter queue")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) }) @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
void shouldNotCreateTargetsWithInvalidTypeInHeader(String type) { void shouldNotCreateTargetsWithInvalidTypeInHeader(String type) {
final Message createTargetMessage = createTargetMessage(null, TENANT_EXIST); final Message createTargetMessage = createTargetMessage(null, TENANT_EXIST);
@@ -315,9 +331,11 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
} }
@ParameterizedTest @ParameterizedTest
/**
* Tests null topic message header. This message should forwarded to the deadletter queue
*/
@ValueSource(strings = { "", "NotExist" }) @ValueSource(strings = { "", "NotExist" })
@NullSource @NullSource
@Description("Tests null topic message header. This message should forwarded to the deadletter queue")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) }) @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
void shouldNotSendMessagesWithInvalidTopic(String topic) { void shouldNotSendMessagesWithInvalidTopic(String topic) {
final Message eventMessage = createUpdateActionEventMessage(""); final Message eventMessage = createUpdateActionEventMessage("");
@@ -327,9 +345,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
verifyOneDeadLetterMessage(); verifyOneDeadLetterMessage();
} }
@Test /**
@Description("Tests missing topic message header. This message should forwarded to the deadletter queue") * Tests missing topic message header. This message should forwarded to the deadletter queue
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) }) */
@Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
void missingTopicHeader() { void missingTopicHeader() {
final Message eventMessage = createUpdateActionEventMessage(""); final Message eventMessage = createUpdateActionEventMessage("");
eventMessage.getMessageProperties().getHeaders().remove(MessageHeaderKey.TOPIC); eventMessage.getMessageProperties().getHeaders().remove(MessageHeaderKey.TOPIC);
@@ -339,9 +358,11 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
} }
@ParameterizedTest @ParameterizedTest
/**
* Tests invalid null message content. This message should forwarded to the deadletter queue
*/
@ValueSource(strings = { "", "Invalid Content" }) @ValueSource(strings = { "", "Invalid Content" })
@NullSource @NullSource
@Description("Tests invalid null message content. This message should forwarded to the deadletter queue")
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) }) @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
void shouldMoveUpdateActionStatusWithInvalidPayloadIntoDeadLetter(String payload) { void shouldMoveUpdateActionStatusWithInvalidPayloadIntoDeadLetter(String payload) {
final Message eventMessage = createUpdateActionEventMessage(payload); final Message eventMessage = createUpdateActionEventMessage(payload);
@@ -349,9 +370,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
verifyOneDeadLetterMessage(); verifyOneDeadLetterMessage();
} }
@Test /**
@Description("Tests invalid topic message header. This message should forwarded to the deadletter queue") * Tests invalid topic message header. This message should forwarded to the deadletter queue
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class) }) */
@Test @ExpectEvents({ @Expect(type = TargetCreatedEvent.class) })
void updateActionStatusWithInvalidActionId() { void updateActionStatusWithInvalidActionId() {
final DmfActionUpdateStatus actionUpdateStatus = new DmfActionUpdateStatus(1L, DmfActionStatus.RUNNING); final DmfActionUpdateStatus actionUpdateStatus = new DmfActionUpdateStatus(1L, DmfActionStatus.RUNNING);
final Message eventMessage = createUpdateActionEventMessage(actionUpdateStatus); final Message eventMessage = createUpdateActionEventMessage(actionUpdateStatus);
@@ -359,9 +381,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
verifyOneDeadLetterMessage(); verifyOneDeadLetterMessage();
} }
@Test /**
@Description("Tests register target and send finished message") * Tests register target and send finished message
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class, count = 1), @Expect(type = ActionUpdatedEvent.class, count = 1),
@@ -378,9 +401,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.FINISHED, Status.FINISHED, controllerId); registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.FINISHED, Status.FINISHED, controllerId);
} }
@Test /**
@Description("Register a target and send a update action status (running). Verify if the updated action status is correct.") * Register a target and send a update action status (running). Verify if the updated action status is correct.
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class), @Expect(type = ActionUpdatedEvent.class),
@@ -396,9 +420,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.RUNNING, Status.RUNNING, controllerId); registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.RUNNING, Status.RUNNING, controllerId);
} }
@Test /**
@Description("Register a target and send an update action status (downloaded). Verify if the updated action status is correct.") * Register a target and send an update action status (downloaded). Verify if the updated action status is correct.
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class), @Expect(type = ActionUpdatedEvent.class),
@@ -414,9 +439,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.DOWNLOADED, Status.DOWNLOADED, controllerId); registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.DOWNLOADED, Status.DOWNLOADED, controllerId);
} }
@Test /**
@Description("Register a target and send a update action status (download). Verify if the updated action status is correct.") * Register a target and send a update action status (download). Verify if the updated action status is correct.
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@@ -431,9 +457,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.DOWNLOAD, Status.DOWNLOAD, controllerId); registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.DOWNLOAD, Status.DOWNLOAD, controllerId);
} }
@Test /**
@Description("Register a target and send a update action status (error). Verify if the updated action status is correct.") * Register a target and send a update action status (error). Verify if the updated action status is correct.
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class, count = 1), @Expect(type = ActionUpdatedEvent.class, count = 1),
@@ -449,9 +476,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.ERROR, Status.ERROR, controllerId); registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.ERROR, Status.ERROR, controllerId);
} }
@Test /**
@Description("Register a target and send a update action status (warning). Verify if the updated action status is correct.") * Register a target and send a update action status (warning). Verify if the updated action status is correct.
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@@ -466,9 +494,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.WARNING, Status.WARNING, controllerId); registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.WARNING, Status.WARNING, controllerId);
} }
@Test /**
@Description("Register a target and send a update action status (retrieved). Verify if the updated action status is correct.") * Register a target and send a update action status (retrieved). Verify if the updated action status is correct.
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@@ -483,9 +512,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.RETRIEVED, Status.RETRIEVED, controllerId); registerTargetAndSendAndAssertUpdateActionStatus(DmfActionStatus.RETRIEVED, Status.RETRIEVED, controllerId);
} }
@Test /**
@Description("Register a target and send a invalid update action status (cancel). This message should forwarded to the deadletter queue") * Register a target and send a invalid update action status (cancel). This message should forwarded to the deadletter queue
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@@ -501,9 +531,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
verifyOneDeadLetterMessage(); verifyOneDeadLetterMessage();
} }
@Test /**
@Description("Verify receiving a download and install message if a deployment is done before the target has polled the first time.") * Verify receiving a download and install message if a deployment is done before the target has polled the first time.
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@@ -530,9 +561,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
Mockito.verifyNoInteractions(getDeadletterListener()); Mockito.verifyNoInteractions(getDeadletterListener());
} }
@Test /**
@Description("Verify receiving a download message if a deployment is done with window configured but before maintenance window start time.") * Verify receiving a download message if a deployment is done with window configured but before maintenance window start time.
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@@ -560,9 +592,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
Mockito.verifyNoInteractions(getDeadletterListener()); Mockito.verifyNoInteractions(getDeadletterListener());
} }
@Test /**
@Description("Verify receiving a download_and_install message if a deployment is done with window configured and during maintenance window start time.") * Verify receiving a download_and_install message if a deployment is done with window configured and during maintenance window start time.
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@@ -590,9 +623,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
Mockito.verifyNoInteractions(getDeadletterListener()); Mockito.verifyNoInteractions(getDeadletterListener());
} }
@Test /**
@Description("Verify receiving a cancel update message if a deployment is canceled before the target has polled the first time.") * Verify receiving a cancel update message if a deployment is canceled before the target has polled the first time.
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@@ -622,9 +656,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
Mockito.verifyNoInteractions(getDeadletterListener()); Mockito.verifyNoInteractions(getDeadletterListener());
} }
@Test /**
@Description("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") * 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
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class, count = 1), @Expect(type = ActionUpdatedEvent.class, count = 1),
@@ -646,9 +681,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
verifyOneDeadLetterMessage(); verifyOneDeadLetterMessage();
} }
@Test /**
@Description("Register a target and send a invalid update action status (cancel_rejected). This message should forwarded to the deadletter queue") * Register a target and send a invalid update action status (cancel_rejected). This message should forwarded to the deadletter queue
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionCreatedEvent.class, count = 1), @Expect(type = ActionCreatedEvent.class, count = 1),
@@ -664,9 +700,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
verifyOneDeadLetterMessage(); verifyOneDeadLetterMessage();
} }
@Test /**
@Description("Register a target and send a valid update action status (cancel_rejected). Verify if the updated action status is correct.") * Register a target and send a valid update action status (cancel_rejected). Verify if the updated action status is correct.
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = CancelTargetAssignmentEvent.class, count = 1), @Expect(type = CancelTargetAssignmentEvent.class, count = 1),
@@ -692,9 +729,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
} }
@Test /**
@Description("Verify that sending an update controller attribute message to an existing target works. Verify that different update modes (merge, replace, remove) can be used.") * Verify that sending an update controller attribute message to an existing target works. Verify that different update modes (merge, replace, remove) can be used.
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 4), @Expect(type = TargetUpdatedEvent.class, count = 4),
@Expect(type = TargetPollEvent.class, count = 1) }) @Expect(type = TargetPollEvent.class, count = 1) })
@@ -718,9 +756,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
} }
@Test /**
@Description("Verify that sending an update controller attribute message with no thingid header to an existing target does not work.") * Verify that sending an update controller attribute message with no thingid header to an existing target does not work.
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class), @Expect(type = TargetUpdatedEvent.class),
@Expect(type = TargetPollEvent.class, count = 1) }) @Expect(type = TargetPollEvent.class, count = 1) })
@@ -744,9 +783,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
assertUpdateAttributes(controllerId, controllerAttributeEmpty.getAttributes()); assertUpdateAttributes(controllerId, controllerAttributeEmpty.getAttributes());
} }
@Test /**
@Description("Verify that sending an update controller attribute message with invalid body to an existing target does not work.") * Verify that sending an update controller attribute message with invalid body to an existing target does not work.
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class), @Expect(type = TargetUpdatedEvent.class),
@Expect(type = TargetPollEvent.class, count = 1) }) @Expect(type = TargetPollEvent.class, count = 1) })
@@ -762,9 +802,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
verifyOneDeadLetterMessage(); verifyOneDeadLetterMessage();
} }
@Test /**
@Description("Verifies that sending an UPDATE_ATTRIBUTES message with invalid attributes is handled correctly.") * Verifies that sending an UPDATE_ATTRIBUTES message with invalid attributes is handled correctly.
void updateAttributesWithInvalidValues() { */
@Test void updateAttributesWithInvalidValues() {
registerAndAssertTargetWithExistingTenant(UPDATE_ATTR_TEST_CONTROLLER_ID); registerAndAssertTargetWithExistingTenant(UPDATE_ATTR_TEST_CONTROLLER_ID);
sendUpdateAttributesMessageWithGivenAttributes(TargetTestData.ATTRIBUTE_KEY_TOO_LONG, TargetTestData.ATTRIBUTE_VALUE_VALID); sendUpdateAttributesMessageWithGivenAttributes(TargetTestData.ATTRIBUTE_KEY_TOO_LONG, TargetTestData.ATTRIBUTE_VALUE_VALID);
@@ -774,9 +815,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
verifyNumberOfDeadLetterMessages(3); verifyNumberOfDeadLetterMessages(3);
} }
@Test /**
@Description("Tests the download_only assignment: tests the handling of a target reporting DOWNLOADED") * Tests the download_only assignment: tests the handling of a target reporting DOWNLOADED
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class, count = 1), @Expect(type = ActionUpdatedEvent.class, count = 1),
@@ -808,9 +850,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
verifyAssignedDsAndInstalledDs(distributionSet.getId(), null); verifyAssignedDsAndInstalledDs(distributionSet.getId(), null);
} }
@Test /**
@Description("Tests the download_only assignment: tests the handling of a target reporting FINISHED") * Tests the download_only assignment: tests the handling of a target reporting FINISHED
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class, count = 2), @Expect(type = ActionUpdatedEvent.class, count = 2),
@@ -850,9 +893,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
verifyAssignedDsAndInstalledDs(distributionSet.getId(), distributionSet.getId()); verifyAssignedDsAndInstalledDs(distributionSet.getId(), distributionSet.getId());
} }
@Test /**
@Description("Messages that result into certain exceptions being raised should not be requeued. This message should forwarded to the deadletter queue") * Messages that result into certain exceptions being raised should not be requeued. This message should forwarded to the deadletter queue
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class) }) @Expect(type = TargetCreatedEvent.class) })
void ignoredExceptionTypesShouldNotBeRequeued() { void ignoredExceptionTypesShouldNotBeRequeued() {
final ControllerManagement mockedControllerManagement = Mockito.mock(ControllerManagement.class); final ControllerManagement mockedControllerManagement = Mockito.mock(ControllerManagement.class);
@@ -875,9 +919,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
} }
} }
@Test /**
@Description("Register a target and send a update action status (confirmed). Verify if the updated action status is correct.") * Register a target and send a update action status (confirmed). Verify if the updated action status is correct.
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class, count = 1), @Expect(type = ActionUpdatedEvent.class, count = 1),
@@ -903,9 +948,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
assertDownloadAndInstallMessage(assignmentResult.getDistributionSet().getModules(), controllerId); assertDownloadAndInstallMessage(assignmentResult.getDistributionSet().getModules(), controllerId);
} }
@Test /**
@Description("Verify the DMF confirmed feedback can be provided if confirmation flow is disabled") * Verify the DMF confirmed feedback can be provided if confirmation flow is disabled
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class, count = 1), @Expect(type = ActionUpdatedEvent.class, count = 1),
@@ -937,9 +983,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
assertDownloadAndInstallMessage(assignmentResult.getDistributionSet().getModules(), controllerId); assertDownloadAndInstallMessage(assignmentResult.getDistributionSet().getModules(), controllerId);
} }
@Test /**
@Description("Verify the DMF confirmed feedback can be provided if confirmation flow is disabled") * Verify the DMF confirmed feedback can be provided if confirmation flow is disabled
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class, count = 0), @Expect(type = ActionUpdatedEvent.class, count = 0),
@@ -967,9 +1014,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
assertActionStatusList(actionId, 2, Status.WAIT_FOR_CONFIRMATION); assertActionStatusList(actionId, 2, Status.WAIT_FOR_CONFIRMATION);
} }
@Test /**
@Description("Verify the DMF download and install message is send directly if auto-confirmation is active") * Verify the DMF download and install message is send directly if auto-confirmation is active
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetUpdatedEvent.class, count = 2), @Expect(type = TargetUpdatedEvent.class, count = 2),
@Expect(type = TargetPollEvent.class, count = 1), @Expect(type = TargetPollEvent.class, count = 1),
@@ -1001,9 +1049,10 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
assertDownloadAndInstallMessage(assignmentResult.getDistributionSet().getModules(), controllerId); assertDownloadAndInstallMessage(assignmentResult.getDistributionSet().getModules(), controllerId);
} }
@Test /**
@Description("Register a target and send a update action status (denied). Verify if the updated action status is correct.") * Register a target and send a update action status (denied). Verify if the updated action status is correct.
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = TargetCreatedEvent.class, count = 1), @Expect(type = TargetCreatedEvent.class, count = 1),
@Expect(type = TargetAssignDistributionSetEvent.class, count = 1), @Expect(type = TargetAssignDistributionSetEvent.class, count = 1),
@Expect(type = ActionUpdatedEvent.class), @Expect(type = ActionUpdatedEvent.class),
@@ -1032,7 +1081,6 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
return node.get("actionId").asText(); return node.get("actionId").asText();
} }
@Step
private void updateAttributesWithUpdateModeRemove() { private void updateAttributesWithUpdateModeRemove() {
// assemble the expected attributes // assemble the expected attributes
@@ -1053,7 +1101,6 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
assertUpdateAttributes(DMF_ATTR_TEST_CONTROLLER_ID, expectedAttributes); assertUpdateAttributes(DMF_ATTR_TEST_CONTROLLER_ID, expectedAttributes);
} }
@Step
private void updateAttributesWithUpdateModeMerge() { private void updateAttributesWithUpdateModeMerge() {
// get the current attributes // get the current attributes
final Map<String, String> attributes = new HashMap<>( final Map<String, String> attributes = new HashMap<>(
@@ -1074,7 +1121,6 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
assertUpdateAttributes(DMF_ATTR_TEST_CONTROLLER_ID, expectedAttributes); assertUpdateAttributes(DMF_ATTR_TEST_CONTROLLER_ID, expectedAttributes);
} }
@Step
private void updateAttributesWithUpdateModeReplace() { private void updateAttributesWithUpdateModeReplace() {
// send an update message with update mode REPLACE // send an update message with update mode REPLACE
final Map<String, String> expectedAttributes = new HashMap<>(); final Map<String, String> expectedAttributes = new HashMap<>();
@@ -1089,7 +1135,6 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
assertUpdateAttributes(DMF_ATTR_TEST_CONTROLLER_ID, expectedAttributes); assertUpdateAttributes(DMF_ATTR_TEST_CONTROLLER_ID, expectedAttributes);
} }
@Step
private void updateAttributesWithoutUpdateMode() { private void updateAttributesWithoutUpdateMode() {
// send an update message which does not specify an update mode // send an update message which does not specify an update mode
final Map<String, String> expectedAttributes = new HashMap<>(); final Map<String, String> expectedAttributes = new HashMap<>();
@@ -1103,7 +1148,6 @@ class AmqpMessageHandlerServiceIntegrationTest extends AbstractAmqpServiceIntegr
assertUpdateAttributes(DMF_ATTR_TEST_CONTROLLER_ID, expectedAttributes); assertUpdateAttributes(DMF_ATTR_TEST_CONTROLLER_ID, expectedAttributes);
} }
@Step
private void verifyAssignedDsAndInstalledDs(final Long assignedDsId, final Long installedDsId) { private void verifyAssignedDsAndInstalledDs(final Long assignedDsId, final Long installedDsId) {
final Optional<Target> target = controllerManagement.getByControllerId(DMF_REGISTER_TEST_CONTROLLER_ID); final Optional<Target> target = controllerManagement.getByControllerId(DMF_REGISTER_TEST_CONTROLLER_ID);
assertThat(target).isPresent(); assertThat(target).isPresent();

View File

@@ -13,13 +13,13 @@ import static org.assertj.core.api.Assertions.assertThat;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import io.qameta.allure.Feature;
import io.qameta.allure.Story;
import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTarget; import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTarget;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@Feature("Unit Tests - Management API") /**
@Story("Serialization") * Feature: Unit Tests - Management API<br/>
* Story: Serialization
*/
class AuditFieldSerializationTest { class AuditFieldSerializationTest {
@Test @Test

View File

@@ -15,25 +15,26 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
import io.qameta.allure.Story;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@Feature("Unit Tests - Management API") /**
@Story("Paged List Handling") * Feature: Unit Tests - Management API<br/>
* Story: Paged List Handling
*/
class PagedListTest { class PagedListTest {
@Test /**
@Description("Ensures that a null payload entity throws an exception.") * Ensures that a null payload entity throws an exception.
void createListWithNullContentThrowsException() { */
@Test void createListWithNullContentThrowsException() {
assertThatThrownBy(() -> new PagedList<>(null, 0)) assertThatThrownBy(() -> new PagedList<>(null, 0))
.isInstanceOf(NullPointerException.class); .isInstanceOf(NullPointerException.class);
} }
@Test /**
@Description("Create list with payload and verify content.") * Create list with payload and verify content.
void createListWithContent() { */
@Test void createListWithContent() {
final long knownTotal = 2; final long knownTotal = 2;
final List<String> knownContentList = new ArrayList<>(); final List<String> knownContentList = new ArrayList<>();
knownContentList.add("content1"); knownContentList.add("content1");
@@ -42,9 +43,10 @@ class PagedListTest {
assertListSize(knownTotal, knownContentList); assertListSize(knownTotal, knownContentList);
} }
@Test /**
@Description("Create list with payload and verify size values.") * Create list with payload and verify size values.
void createListWithSmallerTotalThanContentSizeIsOk() { */
@Test void createListWithSmallerTotalThanContentSizeIsOk() {
final long knownTotal = 0; final long knownTotal = 0;
final List<String> knownContentList = new ArrayList<>(); final List<String> knownContentList = new ArrayList<>();
knownContentList.add("content1"); knownContentList.add("content1");

View File

@@ -17,21 +17,23 @@ import java.util.List;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import io.qameta.allure.Story;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.context.annotation.Description; import org.springframework.context.annotation.Description;
@Story("Retrieve all open action ids") /**
@Description("Tests for the MgmtTargetAssignmentResponseBody") * Feature: Tests for the MgmtTargetAssignmentResponseBody<br/>
* Story: Retrieve all open action ids
*/
class MgmtTargetAssignmentResponseBodyTest { class MgmtTargetAssignmentResponseBodyTest {
private static final List<Long> ASSIGNED_ACTIONS = Arrays.asList(4L, 5L, 6L); private static final List<Long> ASSIGNED_ACTIONS = Arrays.asList(4L, 5L, 6L);
private static final int ALREADY_ASSIGNED_COUNT = 3; private static final int ALREADY_ASSIGNED_COUNT = 3;
private static final String CONTROLLER_ID = "target"; private static final String CONTROLLER_ID = "target";
@Test /**
@Description("Tests that the ActionIds are serialized correctly in MgmtTargetAssignmentResponseBody") * Tests that the ActionIds are serialized correctly in MgmtTargetAssignmentResponseBody
void testActionIdsSerialization() throws IOException { */
@Test void testActionIdsSerialization() throws IOException {
final MgmtTargetAssignmentResponseBody responseBody = generateResponseBody(); final MgmtTargetAssignmentResponseBody responseBody = generateResponseBody();
final ObjectMapper objectMapper = new ObjectMapper(); final ObjectMapper objectMapper = new ObjectMapper();
final String responseBodyAsString = objectMapper.writeValueAsString(responseBody); final String responseBodyAsString = objectMapper.writeValueAsString(responseBody);

View File

@@ -26,10 +26,6 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
import io.qameta.allure.Step;
import io.qameta.allure.Story;
import org.awaitility.Awaitility; import org.awaitility.Awaitility;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtActionRestApi; import org.eclipse.hawkbit.mgmt.rest.api.MgmtActionRestApi;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRepresentationMode; import org.eclipse.hawkbit.mgmt.rest.api.MgmtRepresentationMode;
@@ -46,9 +42,10 @@ import org.springframework.test.web.servlet.ResultActions;
/** /**
* Integration test for the {@link MgmtActionRestApi}. * Integration test for the {@link MgmtActionRestApi}.
* <p/>
* Feature: Component Tests - Management API<br/>
* Story: Action Resource
*/ */
@Feature("Component Tests - Management API")
@Story("Action Resource")
class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest { class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
private static final String JSON_PATH_ROOT = "$"; private static final String JSON_PATH_ROOT = "$";
@@ -64,21 +61,24 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
private static final String JSON_PATH_ACTION_ID = JSON_PATH_ROOT + JSON_PATH_FIELD_ID; private static final String JSON_PATH_ACTION_ID = JSON_PATH_ROOT + JSON_PATH_FIELD_ID;
@Test /**
@Description("Handles the GET request of retrieving a specific action.") * Handles the GET request of retrieving a specific action.
public void getAction() throws Exception { */
@Test public void getAction() throws Exception {
getAction(false); getAction(false);
} }
@Test /**
@Description("Handles the GET request of retrieving a specific action with external reference.") * Handles the GET request of retrieving a specific action with external reference.
public void getActionExtRef() throws Exception { */
@Test public void getActionExtRef() throws Exception {
getAction(true); getAction(true);
} }
@Test /**
@Description("Verifies that actions can be filtered based on action status.") * Verifies that actions can be filtered based on action status.
void filterActionsByStatus() throws Exception { */
@Test void filterActionsByStatus() throws Exception {
// prepare test // prepare test
final DistributionSet dsA = testdataFactory.createDistributionSet(""); final DistributionSet dsA = testdataFactory.createDistributionSet("");
@@ -113,9 +113,10 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
} }
@Test /**
@Description("Verifies that actions can be filtered based on the detailed action status.") * Verifies that actions can be filtered based on the detailed action status.
void filterActionsByDetailStatus() throws Exception { */
@Test void filterActionsByDetailStatus() throws Exception {
// prepare test // prepare test
final DistributionSet dsA = testdataFactory.createDistributionSet(""); final DistributionSet dsA = testdataFactory.createDistributionSet("");
assignDistributionSet(dsA, Collections.singletonList(testdataFactory.createTarget("knownTargetId"))); assignDistributionSet(dsA, Collections.singletonList(testdataFactory.createTarget("knownTargetId")));
@@ -150,9 +151,10 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
.andExpect(jsonPath("content[0].status", equalTo("pending"))); .andExpect(jsonPath("content[0].status", equalTo("pending")));
} }
@Test /**
@Description("Verifies that actions can be filtered based on extRef.") * Verifies that actions can be filtered based on extRef.
void filterActionsByExternalRef() throws Exception { */
@Test void filterActionsByExternalRef() throws Exception {
// prepare test // prepare test
final String knownTargetId = "targetId"; final String knownTargetId = "targetId";
final List<Action> actions = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId); final List<Action> actions = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId);
@@ -193,9 +195,10 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
.andExpect(jsonPath("size", equalTo(0))); .andExpect(jsonPath("size", equalTo(0)));
} }
@Test /**
@Description("Verifies that actions can be filtered based on the action status code that was reported last.") * Verifies that actions can be filtered based on the action status code that was reported last.
void filterActionsByLastStatusCode() throws Exception { */
@Test void filterActionsByLastStatusCode() throws Exception {
// assign a distribution set to three targets // assign a distribution set to three targets
final DistributionSet dsA = testdataFactory.createDistributionSet(""); final DistributionSet dsA = testdataFactory.createDistributionSet("");
final DistributionSetAssignmentResult assignmentResult = assignDistributionSet(dsA, final DistributionSetAssignmentResult assignmentResult = assignDistributionSet(dsA,
@@ -228,9 +231,10 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
.andExpect(jsonPath("size", equalTo(0))); .andExpect(jsonPath("size", equalTo(0)));
} }
@Test /**
@Description("Verifies that actions can be filtered based on distribution set fields.") * Verifies that actions can be filtered based on distribution set fields.
void filterActionsByDistributionSet() throws Exception { */
@Test void filterActionsByDistributionSet() throws Exception {
// prepare test // prepare test
final DistributionSet ds = testdataFactory.createDistributionSet(""); final DistributionSet ds = testdataFactory.createDistributionSet("");
assignDistributionSet(ds, Collections.singletonList(testdataFactory.createTarget("knownTargetId"))); assignDistributionSet(ds, Collections.singletonList(testdataFactory.createTarget("knownTargetId")));
@@ -273,9 +277,10 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
.andExpect(jsonPath("size", equalTo(1))); .andExpect(jsonPath("size", equalTo(1)));
} }
@Test /**
@Description("Verifies that actions can be filtered based on rollout fields.") * Verifies that actions can be filtered based on rollout fields.
void filterActionsByRollout() throws Exception { */
@Test void filterActionsByRollout() throws Exception {
// prepare test // prepare test
final DistributionSet ds = testdataFactory.createDistributionSet(); final DistributionSet ds = testdataFactory.createDistributionSet();
final Target target0 = testdataFactory.createTarget("t0"); final Target target0 = testdataFactory.createTarget("t0");
@@ -314,9 +319,10 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
"content.[0]._links.distributionset.name", equalTo(ds.getName() + ":" + ds.getVersion()))); "content.[0]._links.distributionset.name", equalTo(ds.getName() + ":" + ds.getVersion())));
} }
@Test /**
@Description("Verifies that actions can be filtered based on target fields.") * Verifies that actions can be filtered based on target fields.
void filterActionsByTargetProperties() throws Exception { */
@Test void filterActionsByTargetProperties() throws Exception {
// prepare test // prepare test
final Target target = testdataFactory.createTarget("knownTargetId", "knownTargetName", "http://0.0.0.0"); final Target target = testdataFactory.createTarget("knownTargetId", "knownTargetName", "http://0.0.0.0");
final DistributionSet ds = testdataFactory.createDistributionSet(""); final DistributionSet ds = testdataFactory.createDistributionSet("");
@@ -328,21 +334,24 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
verifyResultsByTargetPropertyFilter(target, ds, "target.address==http://0.0.0.0"); verifyResultsByTargetPropertyFilter(target, ds, "target.address==http://0.0.0.0");
} }
@Test /**
@Description("Verifies that all available actions are returned if the complete collection is requested.") * Verifies that all available actions are returned if the complete collection is requested.
void getActions() throws Exception { */
@Test void getActions() throws Exception {
getActions(false); getActions(false);
} }
@Test /**
@Description("Verifies that all available actions (whit ext refs) are returned if the complete collection is requested.") * Verifies that all available actions (whit ext refs) are returned if the complete collection is requested.
void getActionsExtRef() throws Exception { */
@Test void getActionsExtRef() throws Exception {
getActions(true); getActions(true);
} }
@Test /**
@Description("Verifies that a full representation of all actions is returned if the collection is requested for representation mode 'full'.") * Verifies that a full representation of all actions is returned if the collection is requested for representation mode 'full'.
void getActionsFullRepresentation() throws Exception { */
@Test void getActionsFullRepresentation() throws Exception {
final String knownTargetId = "targetId"; final String knownTargetId = "targetId";
final List<Action> actions = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId); final List<Action> actions = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId);
@@ -382,9 +391,10 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
.andExpect(jsonPath(JSON_PATH_PAGED_LIST_CONTENT, hasSize(2))); .andExpect(jsonPath(JSON_PATH_PAGED_LIST_CONTENT, hasSize(2)));
} }
@Test /**
@Description("Verifies that the get request for actions returns an empty collection if no assignments have been done yet.") * Verifies that the get request for actions returns an empty collection if no assignments have been done yet.
void getActionsWithEmptyResult() throws Exception { */
@Test void getActionsWithEmptyResult() throws Exception {
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING)) mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING))
.andDo(MockMvcResultPrinter.print()) .andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk()) .andExpect(status().isOk())
@@ -393,9 +403,10 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
.andExpect(jsonPath("total", equalTo(0))); .andExpect(jsonPath("total", equalTo(0)));
} }
@Test /**
@Description("Verifies paging is respected as expected.") * Verifies paging is respected as expected.
void getMultipleActionsWithPagingLimitRequestParameter() throws Exception { */
@Test void getMultipleActionsWithPagingLimitRequestParameter() throws Exception {
final String knownTargetId = "targetId"; final String knownTargetId = "targetId";
final List<Action> actions = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId); final List<Action> actions = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId);
@@ -444,9 +455,10 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
.andExpect(jsonPath(JSON_PATH_PAGED_LIST_CONTENT, hasSize(1))); .andExpect(jsonPath(JSON_PATH_PAGED_LIST_CONTENT, hasSize(1)));
} }
@Test /**
@Description("Verifies that the actions resource is read-only.") * Verifies that the actions resource is read-only.
void invalidRequestsOnActionResource() throws Exception { */
@Test void invalidRequestsOnActionResource() throws Exception {
final String knownTargetId = "targetId"; final String knownTargetId = "targetId";
generateTargetWithTwoUpdatesWithOneOverride(knownTargetId); generateTargetWithTwoUpdatesWithOneOverride(knownTargetId);
@@ -463,9 +475,10 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
.andExpect(status().isMethodNotAllowed()); .andExpect(status().isMethodNotAllowed());
} }
@Test /**
@Description("Verifies that the correct action is returned") * Verifies that the correct action is returned
void shouldRetrieveCorrectActionById() throws Exception { */
@Test void shouldRetrieveCorrectActionById() throws Exception {
final String knownTargetId = "targetId"; final String knownTargetId = "targetId";
final List<Action> actions = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId); final List<Action> actions = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId);
@@ -477,9 +490,10 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
.andExpect(jsonPath(JSON_PATH_ACTION_ID, equalTo(actionId.intValue()))); .andExpect(jsonPath(JSON_PATH_ACTION_ID, equalTo(actionId.intValue())));
} }
@Test /**
@Description("Verifies that NOT_FOUND is returned when there is no such action.") * Verifies that NOT_FOUND is returned when there is no such action.
void requestActionThatDoesNotExistsLeadsToNotFound() throws Exception { */
@Test void requestActionThatDoesNotExistsLeadsToNotFound() throws Exception {
mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "/" + 101)) mvc.perform(get(MgmtRestConstants.ACTION_V1_REQUEST_MAPPING + "/" + 101))
.andDo(MockMvcResultPrinter.print()) .andDo(MockMvcResultPrinter.print())
.andExpect(status().isNotFound()); .andExpect(status().isNotFound());
@@ -499,7 +513,6 @@ class MgmtActionResourceTest extends AbstractManagementApiIntegrationTest {
+ action.getDistributionSet().getId(); + action.getDistributionSet().getId();
} }
@Step
private void verifyResultsByTargetPropertyFilter(final Target target, final DistributionSet ds, final String rsqlTargetFilter) private void verifyResultsByTargetPropertyFilter(final Target target, final DistributionSet ds, final String rsqlTargetFilter)
throws Exception { throws Exception {
// pending status one result // pending status one result

View File

@@ -19,9 +19,6 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
import java.util.Base64; import java.util.Base64;
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
import io.qameta.allure.Story;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.eclipse.hawkbit.repository.jpa.RepositoryApplicationConfiguration; import org.eclipse.hawkbit.repository.jpa.RepositoryApplicationConfiguration;
import org.eclipse.hawkbit.repository.test.TestConfiguration; import org.eclipse.hawkbit.repository.test.TestConfiguration;
@@ -74,8 +71,10 @@ import org.springframework.web.context.WebApplicationContext;
@ContextConfiguration(classes = { MgmtApiConfiguration.class, RestConfiguration.class, @ContextConfiguration(classes = { MgmtApiConfiguration.class, RestConfiguration.class,
RepositoryApplicationConfiguration.class, TestConfiguration.class }) RepositoryApplicationConfiguration.class, TestConfiguration.class })
@Import(TestChannelBinderConfiguration.class) @Import(TestChannelBinderConfiguration.class)
@Feature("Component Tests - Management API") /**
@Story("Basic auth Userinfo Resource") * Feature: Component Tests - Management API<br/>
* Story: Basic auth Userinfo Resource
*/
class MgmtBasicAuthResourceTest { class MgmtBasicAuthResourceTest {
@Autowired @Autowired
@@ -85,9 +84,10 @@ class MgmtBasicAuthResourceTest {
private static final String DEFAULT_TENANT = "DEFAULT"; private static final String DEFAULT_TENANT = "DEFAULT";
private static final String TEST_USER = "testUser"; private static final String TEST_USER = "testUser";
@Test /**
@Description("Test of userinfo api with basic auth validation") * Test of userinfo api with basic auth validation
@WithUser(principal = TEST_USER, authorities = {"READ", "WRITE", "DELETE"}) */
@Test @WithUser(principal = TEST_USER, authorities = {"READ", "WRITE", "DELETE"})
void validateBasicAuthWithUserDetails() throws Exception { void validateBasicAuthWithUserDetails() throws Exception {
withSecurityMock().perform(get(MgmtRestConstants.AUTH_V1_REQUEST_MAPPING)) withSecurityMock().perform(get(MgmtRestConstants.AUTH_V1_REQUEST_MAPPING))
.andDo(MockMvcResultPrinter.print()) .andDo(MockMvcResultPrinter.print())
@@ -100,9 +100,10 @@ class MgmtBasicAuthResourceTest {
.andExpect(jsonPath("$.permissions", hasItems("READ", "WRITE", "DELETE"))); .andExpect(jsonPath("$.permissions", hasItems("READ", "WRITE", "DELETE")));
} }
@Test /**
@Description("Test of userinfo api with invalid basic auth fails") * Test of userinfo api with invalid basic auth fails
void validateBasicAuthFailsWithInvalidCredentials() throws Exception { */
@Test void validateBasicAuthFailsWithInvalidCredentials() throws Exception {
defaultMock.perform(get(MgmtRestConstants.AUTH_V1_REQUEST_MAPPING) defaultMock.perform(get(MgmtRestConstants.AUTH_V1_REQUEST_MAPPING)
.header(HttpHeaders.AUTHORIZATION, getBasicAuth("wrongUser", "wrongSecret"))) .header(HttpHeaders.AUTHORIZATION, getBasicAuth("wrongUser", "wrongSecret")))
.andDo(MockMvcResultPrinter.print()) .andDo(MockMvcResultPrinter.print())

View File

@@ -18,9 +18,6 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
import java.util.Collections; import java.util.Collections;
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
import io.qameta.allure.Story;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.rest.util.JsonBuilder; import org.eclipse.hawkbit.rest.util.JsonBuilder;
@@ -41,8 +38,10 @@ import org.springframework.test.web.servlet.MvcResult;
*/ */
@SpringBootTest(properties = { "server.servlet.encoding.charset=UTF-8", "server.servlet.encoding.force=true" }) @SpringBootTest(properties = { "server.servlet.encoding.charset=UTF-8", "server.servlet.encoding.force=true" })
@Import(HttpEncodingAutoConfiguration.class) @Import(HttpEncodingAutoConfiguration.class)
@Feature("Component Tests - Management API") /**
@Story("Response Content-Type") * Feature: Component Tests - Management API<br/>
* Story: Response Content-Type
*/
@SuppressWarnings("java:S1874") // TODO for compatibility, to be checked if we really want to do that @SuppressWarnings("java:S1874") // TODO for compatibility, to be checked if we really want to do that
public class MgmtContentTypeTest extends AbstractManagementApiIntegrationTest { public class MgmtContentTypeTest extends AbstractManagementApiIntegrationTest {
@@ -54,9 +53,10 @@ public class MgmtContentTypeTest extends AbstractManagementApiIntegrationTest {
ds = testdataFactory.generateDistributionSet(dsName); ds = testdataFactory.generateDistributionSet(dsName);
} }
@Test /**
@Description("The response of a POST request shall contain charset=utf-8") * The response of a POST request shall contain charset=utf-8
public void postDistributionSet_ContentTypeJsonUtf8_woAccept() throws Exception { */
@Test public void postDistributionSet_ContentTypeJsonUtf8_woAccept() throws Exception {
final MvcResult result = mvc.perform( final MvcResult result = mvc.perform(
post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING).content(JsonBuilder.distributionSets( post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING).content(JsonBuilder.distributionSets(
Collections.singletonList(ds))) Collections.singletonList(ds)))
@@ -69,9 +69,10 @@ public class MgmtContentTypeTest extends AbstractManagementApiIntegrationTest {
assertEquals(MediaTypes.HAL_JSON_VALUE + ";charset=UTF-8", getResponseHeaderContentType(result)); assertEquals(MediaTypes.HAL_JSON_VALUE + ";charset=UTF-8", getResponseHeaderContentType(result));
} }
@Test /**
@Description("The response of a POST request shall contain charset=utf-8") * The response of a POST request shall contain charset=utf-8
public void postDistributionSet_ContentTypeJsonUtf8_wAcceptJson() throws Exception { */
@Test public void postDistributionSet_ContentTypeJsonUtf8_wAcceptJson() throws Exception {
final MvcResult result = mvc.perform( final MvcResult result = mvc.perform(
post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING).content(JsonBuilder.distributionSets( post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING).content(JsonBuilder.distributionSets(
Collections.singletonList(ds))) Collections.singletonList(ds)))
@@ -84,9 +85,10 @@ public class MgmtContentTypeTest extends AbstractManagementApiIntegrationTest {
assertEquals(MediaType.APPLICATION_JSON_UTF8_VALUE, getResponseHeaderContentType(result)); assertEquals(MediaType.APPLICATION_JSON_UTF8_VALUE, getResponseHeaderContentType(result));
} }
@Test /**
@Description("The response of a POST request shall contain charset=utf-8") * The response of a POST request shall contain charset=utf-8
public void postDistributionSet_ContentTypeJsonUtf8_wAcceptJsonUtf8() throws Exception { */
@Test public void postDistributionSet_ContentTypeJsonUtf8_wAcceptJsonUtf8() throws Exception {
final MvcResult result = mvc.perform( final MvcResult result = mvc.perform(
post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING).content(JsonBuilder.distributionSets( post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING).content(JsonBuilder.distributionSets(
Collections.singletonList(ds))) Collections.singletonList(ds)))
@@ -99,9 +101,10 @@ public class MgmtContentTypeTest extends AbstractManagementApiIntegrationTest {
assertEquals(MediaType.APPLICATION_JSON_UTF8_VALUE, getResponseHeaderContentType(result)); assertEquals(MediaType.APPLICATION_JSON_UTF8_VALUE, getResponseHeaderContentType(result));
} }
@Test /**
@Description("The response of a POST request shall contain charset=utf-8") * The response of a POST request shall contain charset=utf-8
public void postDistributionSet_ContentTypeJsonUtf8_wAcceptHalJson() throws Exception { */
@Test public void postDistributionSet_ContentTypeJsonUtf8_wAcceptHalJson() throws Exception {
final MvcResult result = mvc.perform( final MvcResult result = mvc.perform(
post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING).content(JsonBuilder.distributionSets( post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING).content(JsonBuilder.distributionSets(
Collections.singletonList(ds))) Collections.singletonList(ds)))
@@ -114,9 +117,10 @@ public class MgmtContentTypeTest extends AbstractManagementApiIntegrationTest {
assertEquals(MediaTypes.HAL_JSON_VALUE + ";charset=UTF-8", getResponseHeaderContentType(result)); assertEquals(MediaTypes.HAL_JSON_VALUE + ";charset=UTF-8", getResponseHeaderContentType(result));
} }
@Test /**
@Description("The response of a POST request shall contain charset=utf-8") * The response of a POST request shall contain charset=utf-8
public void postDistributionSet_ContentTypeJson_woAccept() throws Exception { */
@Test public void postDistributionSet_ContentTypeJson_woAccept() throws Exception {
final MvcResult result = mvc.perform( final MvcResult result = mvc.perform(
post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING).content(JsonBuilder.distributionSets( post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING).content(JsonBuilder.distributionSets(
Collections.singletonList(ds))) Collections.singletonList(ds)))
@@ -129,9 +133,10 @@ public class MgmtContentTypeTest extends AbstractManagementApiIntegrationTest {
assertEquals(MediaTypes.HAL_JSON_VALUE + ";charset=UTF-8", getResponseHeaderContentType(result)); assertEquals(MediaTypes.HAL_JSON_VALUE + ";charset=UTF-8", getResponseHeaderContentType(result));
} }
@Test /**
@Description("The response of a POST request shall contain charset=utf-8") * The response of a POST request shall contain charset=utf-8
public void postDistributionSet_ContentTypeJson_wAcceptJson() throws Exception { */
@Test public void postDistributionSet_ContentTypeJson_wAcceptJson() throws Exception {
final MvcResult result = mvc.perform( final MvcResult result = mvc.perform(
post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING).content(JsonBuilder.distributionSets( post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING).content(JsonBuilder.distributionSets(
Collections.singletonList(ds))) Collections.singletonList(ds)))
@@ -144,9 +149,10 @@ public class MgmtContentTypeTest extends AbstractManagementApiIntegrationTest {
assertEquals(MediaType.APPLICATION_JSON_UTF8_VALUE, getResponseHeaderContentType(result)); assertEquals(MediaType.APPLICATION_JSON_UTF8_VALUE, getResponseHeaderContentType(result));
} }
@Test /**
@Description("The response of a POST request shall contain charset=utf-8") * The response of a POST request shall contain charset=utf-8
public void postDistributionSet_ContentTypeJson_wAcceptJsonUtf8() throws Exception { */
@Test public void postDistributionSet_ContentTypeJson_wAcceptJsonUtf8() throws Exception {
final MvcResult result = mvc.perform(post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING) final MvcResult result = mvc.perform(post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING)
.content(JsonBuilder.distributionSets(Collections.singletonList(ds))).contentType(MediaType.APPLICATION_JSON) .content(JsonBuilder.distributionSets(Collections.singletonList(ds))).contentType(MediaType.APPLICATION_JSON)
.accept(MediaType.APPLICATION_JSON_UTF8)) .accept(MediaType.APPLICATION_JSON_UTF8))
@@ -158,9 +164,10 @@ public class MgmtContentTypeTest extends AbstractManagementApiIntegrationTest {
assertEquals(MediaType.APPLICATION_JSON_UTF8_VALUE, getResponseHeaderContentType(result)); assertEquals(MediaType.APPLICATION_JSON_UTF8_VALUE, getResponseHeaderContentType(result));
} }
@Test /**
@Description("The response of a POST request shall contain charset=utf-8") * The response of a POST request shall contain charset=utf-8
public void postDistributionSet_ContentTypeJson_wAcceptHalJson() throws Exception { */
@Test public void postDistributionSet_ContentTypeJson_wAcceptHalJson() throws Exception {
final MvcResult result = mvc.perform(post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING) final MvcResult result = mvc.perform(post(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING)
.content(JsonBuilder.distributionSets(Collections.singletonList(ds))).contentType(MediaType.APPLICATION_JSON) .content(JsonBuilder.distributionSets(Collections.singletonList(ds))).contentType(MediaType.APPLICATION_JSON)
.accept(MediaTypes.HAL_JSON)) .accept(MediaTypes.HAL_JSON))
@@ -172,9 +179,10 @@ public class MgmtContentTypeTest extends AbstractManagementApiIntegrationTest {
assertEquals(MediaTypes.HAL_JSON_VALUE + ";charset=UTF-8", getResponseHeaderContentType(result)); assertEquals(MediaTypes.HAL_JSON_VALUE + ";charset=UTF-8", getResponseHeaderContentType(result));
} }
@Test /**
@Description("The response of a GET request shall contain charset=utf-8") * The response of a GET request shall contain charset=utf-8
public void getDistributionSet_woAccept() throws Exception { */
@Test public void getDistributionSet_woAccept() throws Exception {
final MvcResult result = mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING)) final MvcResult result = mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING))
.andDo(MockMvcResultPrinter.print()) .andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk()) .andExpect(status().isOk())
@@ -183,9 +191,10 @@ public class MgmtContentTypeTest extends AbstractManagementApiIntegrationTest {
assertEquals(MediaTypes.HAL_JSON_VALUE + ";charset=UTF-8", getResponseHeaderContentType(result)); assertEquals(MediaTypes.HAL_JSON_VALUE + ";charset=UTF-8", getResponseHeaderContentType(result));
} }
@Test /**
@Description("The response of a GET request shall contain charset=utf-8") * The response of a GET request shall contain charset=utf-8
public void getDistributionSet_wAcceptJson() throws Exception { */
@Test public void getDistributionSet_wAcceptJson() throws Exception {
final MvcResult result = mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING).accept(MediaType.APPLICATION_JSON)) final MvcResult result = mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING).accept(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print()) .andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk()) .andExpect(status().isOk())
@@ -194,9 +203,10 @@ public class MgmtContentTypeTest extends AbstractManagementApiIntegrationTest {
assertEquals(MediaType.APPLICATION_JSON_UTF8_VALUE, getResponseHeaderContentType(result)); assertEquals(MediaType.APPLICATION_JSON_UTF8_VALUE, getResponseHeaderContentType(result));
} }
@Test /**
@Description("The response of a GET request shall contain charset=utf-8") * The response of a GET request shall contain charset=utf-8
public void getDistributionSet_wAcceptJsonUtf8() throws Exception { */
@Test public void getDistributionSet_wAcceptJsonUtf8() throws Exception {
final MvcResult result = mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING).accept(MediaType.APPLICATION_JSON_UTF8)) final MvcResult result = mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING).accept(MediaType.APPLICATION_JSON_UTF8))
.andDo(MockMvcResultPrinter.print()) .andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk()) .andExpect(status().isOk())
@@ -205,9 +215,10 @@ public class MgmtContentTypeTest extends AbstractManagementApiIntegrationTest {
assertEquals(MediaType.APPLICATION_JSON_UTF8_VALUE, getResponseHeaderContentType(result)); assertEquals(MediaType.APPLICATION_JSON_UTF8_VALUE, getResponseHeaderContentType(result));
} }
@Test /**
@Description("The response of a GET request shall contain charset=utf-8") * The response of a GET request shall contain charset=utf-8
public void getDistributionSet_wAcceptHalJson() throws Exception { */
@Test public void getDistributionSet_wAcceptHalJson() throws Exception {
final MvcResult result = mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING).accept(MediaTypes.HAL_JSON)) final MvcResult result = mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING).accept(MediaTypes.HAL_JSON))
.andDo(MockMvcResultPrinter.print()) .andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk()) .andExpect(status().isOk())

View File

@@ -37,10 +37,6 @@ import java.util.stream.IntStream;
import java.util.stream.Stream; import java.util.stream.Stream;
import com.jayway.jsonpath.JsonPath; import com.jayway.jsonpath.JsonPath;
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
import io.qameta.allure.Step;
import io.qameta.allure.Story;
import org.eclipse.hawkbit.exception.SpServerError; import org.eclipse.hawkbit.exception.SpServerError;
import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtActionType; import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtActionType;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
@@ -79,16 +75,19 @@ import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MvcResult; import org.springframework.test.web.servlet.MvcResult;
import org.springframework.util.Assert; import org.springframework.util.Assert;
@Feature("Component Tests - Management API") /**
@Story("Distribution Set Resource") * Feature: Component Tests - Management API<br/>
* Story: Distribution Set Resource
*/
class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTest { class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTest {
@Autowired @Autowired
ActionRepository actionRepository; ActionRepository actionRepository;
@Test /**
@Description("This test verifies the call of all Software Modules that are assigned to a Distribution Set through the RESTful API.") * This test verifies the call of all Software Modules that are assigned to a Distribution Set through the RESTful API.
void getSoftwareModules() throws Exception { */
@Test void getSoftwareModules() throws Exception {
// Create DistributionSet with three software modules // Create DistributionSet with three software modules
final DistributionSet set = testdataFactory.createDistributionSet("SMTest"); final DistributionSet set = testdataFactory.createDistributionSet("SMTest");
mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + set.getId() + "/assignedSM")) mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + set.getId() + "/assignedSM"))
@@ -97,9 +96,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
.andExpect(jsonPath("$.size", equalTo(set.getModules().size()))); .andExpect(jsonPath("$.size", equalTo(set.getModules().size())));
} }
@Test /**
@Description("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'.") * 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'.
void getSoftwareModulesWithParameters() throws Exception { */
@Test void getSoftwareModulesWithParameters() throws Exception {
final DistributionSet set = testdataFactory.createUpdatedDistributionSet(); final DistributionSet set = testdataFactory.createUpdatedDistributionSet();
// post assignment // post assignment
@@ -111,9 +111,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
.andExpect(content().contentType(MediaType.APPLICATION_JSON)); .andExpect(content().contentType(MediaType.APPLICATION_JSON));
} }
@Test /**
@Description("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.") * 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.
void deleteFailureWhenDistributionSetInUse() throws Exception { */
@Test void deleteFailureWhenDistributionSetInUse() throws Exception {
// create DisSet // create DisSet
final DistributionSet disSet = testdataFactory.createDistributionSetWithNoSoftwareModules("Eris", "560a"); final DistributionSet disSet = testdataFactory.createDistributionSetWithNoSoftwareModules("Eris", "560a");
final List<Long> smIDs = new ArrayList<>(); final List<Long> smIDs = new ArrayList<>();
@@ -155,9 +156,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
.andExpect(jsonPath("$.errorCode", equalTo(SpServerError.SP_REPO_ENTITY_READ_ONLY.getKey()))); .andExpect(jsonPath("$.errorCode", equalTo(SpServerError.SP_REPO_ENTITY_READ_ONLY.getKey())));
} }
@Test /**
@Description("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.") * 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.
void assignmentFailureWhenAssigningToUsedDistributionSet() throws Exception { */
@Test void assignmentFailureWhenAssigningToUsedDistributionSet() throws Exception {
// create DisSet // create DisSet
final DistributionSet disSet = testdataFactory.createDistributionSetWithNoSoftwareModules("Mars", "686,980"); final DistributionSet disSet = testdataFactory.createDistributionSetWithNoSoftwareModules("Mars", "686,980");
final List<Long> smIDs = new ArrayList<>(); final List<Long> smIDs = new ArrayList<>();
@@ -198,9 +200,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
.andExpect(jsonPath("$.errorCode", equalTo(SpServerError.SP_REPO_ENTITY_READ_ONLY.getKey()))); .andExpect(jsonPath("$.errorCode", equalTo(SpServerError.SP_REPO_ENTITY_READ_ONLY.getKey())));
} }
@Test /**
@Description("This test verifies the assignment of Software Modules to a Distribution Set through the RESTful API.") * This test verifies the assignment of Software Modules to a Distribution Set through the RESTful API.
void assignSoftwareModuleToDistributionSet() throws Exception { */
@Test void assignSoftwareModuleToDistributionSet() throws Exception {
// create DisSet // create DisSet
final DistributionSet disSet = testdataFactory.createDistributionSetWithNoSoftwareModules("Jupiter", "398,88"); final DistributionSet disSet = testdataFactory.createDistributionSetWithNoSoftwareModules("Jupiter", "398,88");
// Test if size is 0 // Test if size is 0
@@ -269,9 +272,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
} }
@Test /**
@Description("This test verifies the removal of Software Modules of a Distribution Set through the RESTful API.") * This test verifies the removal of Software Modules of a Distribution Set through the RESTful API.
void unassignSoftwareModuleFromDistributionSet() throws Exception { */
@Test void unassignSoftwareModuleFromDistributionSet() throws Exception {
// Create DistributionSet with three software modules // Create DistributionSet with three software modules
final DistributionSet set = testdataFactory.createDistributionSet("Venus"); final DistributionSet set = testdataFactory.createDistributionSet("Venus");
int amountOfSM = set.getModules().size(); int amountOfSM = set.getModules().size();
@@ -292,9 +296,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
} }
} }
@Test /**
@Description("Ensures that multi target assignment through API is reflected by the repository.") * Ensures that multi target assignment through API is reflected by the repository.
void assignMultipleTargetsToDistributionSet() throws Exception { */
@Test void assignMultipleTargetsToDistributionSet() throws Exception {
final DistributionSet createdDs = testdataFactory.createDistributionSet(); final DistributionSet createdDs = testdataFactory.createDistributionSet();
// prepare targets // prepare targets
@@ -315,9 +320,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
.as("Five targets in repository have DS assigned").hasSize(5); .as("Five targets in repository have DS assigned").hasSize(5);
} }
@Test /**
@Description("Ensures that targets can be assigned even if the specified controller IDs are in different case (e.g. 'TARGET1' instead of 'target1'.") * Ensures that targets can be assigned even if the specified controller IDs are in different case (e.g. 'TARGET1' instead of 'target1'.
void assignTargetsToDistributionSetIgnoreCase() throws Exception { */
@Test void assignTargetsToDistributionSetIgnoreCase() throws Exception {
final DistributionSet createdDs = testdataFactory.createDistributionSet(); final DistributionSet createdDs = testdataFactory.createDistributionSet();
// prepare targets // prepare targets
@@ -338,9 +344,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
// we just need to make sure that no error 500 is returned // we just need to make sure that no error 500 is returned
} }
@Test /**
@Description("Trying to create a DS from already marked as deleted type - should get as response 400 Bad Request") * Trying to create a DS from already marked as deleted type - should get as response 400 Bad Request
void createDsFromAlreadyMarkedAsDeletedType() throws Exception { */
@Test void createDsFromAlreadyMarkedAsDeletedType() throws Exception {
final SoftwareModule softwareModule = testdataFactory.createSoftwareModule("exampleKey"); final SoftwareModule softwareModule = testdataFactory.createSoftwareModule("exampleKey");
final DistributionSetType type = testdataFactory.findOrCreateDistributionSetType( final DistributionSetType type = testdataFactory.findOrCreateDistributionSetType(
"testKey", "testType", Collections.singletonList(softwareModule.getType()), "testKey", "testType", Collections.singletonList(softwareModule.getType()),
@@ -378,9 +385,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
assertTrue(exceptionInfo.getMessage().contains("Distribution Set Type already deleted")); assertTrue(exceptionInfo.getMessage().contains("Distribution Set Type already deleted"));
} }
@Test /**
@Description("Ensures that multi target assignment is protected by our getMaxTargetDistributionSetAssignmentsPerManualAssignment quota.") * Ensures that multi target assignment is protected by our getMaxTargetDistributionSetAssignmentsPerManualAssignment quota.
void assignMultipleTargetsToDistributionSetUntilQuotaIsExceeded() throws Exception { */
@Test void assignMultipleTargetsToDistributionSetUntilQuotaIsExceeded() throws Exception {
final int maxActions = quotaManagement.getMaxTargetDistributionSetAssignmentsPerManualAssignment(); final int maxActions = quotaManagement.getMaxTargetDistributionSetAssignmentsPerManualAssignment();
final List<Target> targets = testdataFactory.createTargets(maxActions + 1); final List<Target> targets = testdataFactory.createTargets(maxActions + 1);
final DistributionSet ds = testdataFactory.createDistributionSet(); final DistributionSet ds = testdataFactory.createDistributionSet();
@@ -401,9 +409,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
assertThat(targetManagement.findByAssignedDistributionSet(ds.getId(), PAGE).getContent()).isEmpty(); assertThat(targetManagement.findByAssignedDistributionSet(ds.getId(), PAGE).getContent()).isEmpty();
} }
@Test /**
@Description("Ensures that the 'max actions per target' quota is enforced if the distribution set assignment of a target is changed permanently") * Ensures that the 'max actions per target' quota is enforced if the distribution set assignment of a target is changed permanently
void changeDistributionSetAssignmentForTargetUntilQuotaIsExceeded() throws Exception { */
@Test void changeDistributionSetAssignmentForTargetUntilQuotaIsExceeded() throws Exception {
// create one target // create one target
final Target testTarget = testdataFactory.createTarget("trg1"); final Target testTarget = testdataFactory.createTarget("trg1");
@@ -427,9 +436,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
.andExpect(status().isForbidden()); .andExpect(status().isForbidden());
} }
@Test /**
@Description("Ensures that offline reported multi target assignment through API is reflected by the repository.") * Ensures that offline reported multi target assignment through API is reflected by the repository.
void offlineAssignmentOfMultipleTargetsToDistributionSet() throws Exception { */
@Test void offlineAssignmentOfMultipleTargetsToDistributionSet() throws Exception {
final DistributionSet createdDs = testdataFactory.createDistributionSet(); final DistributionSet createdDs = testdataFactory.createDistributionSet();
final List<Target> targets = testdataFactory.createTargets(5); final List<Target> targets = testdataFactory.createTargets(5);
final JSONArray list = new JSONArray(); final JSONArray list = new JSONArray();
@@ -457,9 +467,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
assertThat(targetManagement.findByInstalledDistributionSet(createdDs.getId(), PAGE).getContent()).hasSize(4); assertThat(targetManagement.findByInstalledDistributionSet(createdDs.getId(), PAGE).getContent()).hasSize(4);
} }
@Test /**
@Description("Assigns multiple targets to distribution set with only maintenance schedule.") * Assigns multiple targets to distribution set with only maintenance schedule.
void assignMultipleTargetsToDistributionSetWithMaintenanceWindowStartOnly() throws Exception { */
@Test void assignMultipleTargetsToDistributionSetWithMaintenanceWindowStartOnly() throws Exception {
// prepare distribution set // prepare distribution set
final DistributionSet createdDs = testdataFactory.createDistributionSet(); final DistributionSet createdDs = testdataFactory.createDistributionSet();
// prepare targets // prepare targets
@@ -474,9 +485,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
.andExpect(status().isBadRequest()); .andExpect(status().isBadRequest());
} }
@Test /**
@Description("Assigns multiple targets to distribution set with only maintenance window duration.") * Assigns multiple targets to distribution set with only maintenance window duration.
void assignMultipleTargetsToDistributionSetWithMaintenanceWindowEndOnly() throws Exception { */
@Test void assignMultipleTargetsToDistributionSetWithMaintenanceWindowEndOnly() throws Exception {
// prepare distribution set // prepare distribution set
final DistributionSet createdDs = testdataFactory.createDistributionSet(); final DistributionSet createdDs = testdataFactory.createDistributionSet();
// prepare targets // prepare targets
@@ -491,9 +503,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
.andExpect(status().isBadRequest()); .andExpect(status().isBadRequest());
} }
@Test /**
@Description("Assigns multiple targets to distribution set with valid maintenance window.") * Assigns multiple targets to distribution set with valid maintenance window.
void assignMultipleTargetsToDistributionSetWithValidMaintenanceWindow() throws Exception { */
@Test void assignMultipleTargetsToDistributionSetWithValidMaintenanceWindow() throws Exception {
// prepare distribution set // prepare distribution set
final DistributionSet createdDs = testdataFactory.createDistributionSet(); final DistributionSet createdDs = testdataFactory.createDistributionSet();
// prepare targets // prepare targets
@@ -509,9 +522,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
.andExpect(status().isOk()); .andExpect(status().isOk());
} }
@Test /**
@Description("Assigns multiple targets to distribution set with last maintenance window scheduled before current time.") * Assigns multiple targets to distribution set with last maintenance window scheduled before current time.
void assignMultipleTargetsToDistributionSetWithMaintenanceWindowEndTimeBeforeStartTime() throws Exception { */
@Test void assignMultipleTargetsToDistributionSetWithMaintenanceWindowEndTimeBeforeStartTime() throws Exception {
// prepare distribution set // prepare distribution set
final DistributionSet createdDs = testdataFactory.createDistributionSet(); final DistributionSet createdDs = testdataFactory.createDistributionSet();
// prepare targets // prepare targets
@@ -527,9 +541,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
.andExpect(status().isBadRequest()); .andExpect(status().isBadRequest());
} }
@Test /**
@Description("Assigns multiple targets to distribution set with and without maintenance window.") * Assigns multiple targets to distribution set with and without maintenance window.
void assignMultipleTargetsToDistributionSetWithAndWithoutMaintenanceWindow() throws Exception { */
@Test void assignMultipleTargetsToDistributionSetWithAndWithoutMaintenanceWindow() throws Exception {
// prepare distribution set // prepare distribution set
final DistributionSet createdDs = testdataFactory.createDistributionSet(); final DistributionSet createdDs = testdataFactory.createDistributionSet();
// prepare targets // prepare targets
@@ -554,9 +569,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
.andExpect(status().isOk()); .andExpect(status().isOk());
} }
@Test /**
@Description("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.") * 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.
void assignNotExistingTargetToDistributionSet() throws Exception { */
@Test void assignNotExistingTargetToDistributionSet() throws Exception {
final DistributionSet createdDs = testdataFactory.createDistributionSet(); final DistributionSet createdDs = testdataFactory.createDistributionSet();
final String[] knownTargetIds = new String[] { "1", "2", "3" }; final String[] knownTargetIds = new String[] { "1", "2", "3" };
@@ -574,9 +590,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
.andExpect(jsonPath("$.total", equalTo(3))); .andExpect(jsonPath("$.total", equalTo(3)));
} }
@Test /**
@Description("Ensures that assigned targets of DS are returned as reflected by the repository.") * Ensures that assigned targets of DS are returned as reflected by the repository.
void getAssignedTargetsOfDistributionSet() throws Exception { */
@Test void getAssignedTargetsOfDistributionSet() throws Exception {
// prepare distribution set // prepare distribution set
final String knownTargetId = "knownTargetId1"; final String knownTargetId = "knownTargetId1";
final DistributionSet createdDs = testdataFactory.createDistributionSet(); final DistributionSet createdDs = testdataFactory.createDistributionSet();
@@ -589,9 +606,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
.andExpect(jsonPath("$.content[0].controllerId", equalTo(knownTargetId))); .andExpect(jsonPath("$.content[0].controllerId", equalTo(knownTargetId)));
} }
@Test /**
@Description("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'.") * 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'.
void getAssignedTargetsOfDistributionSetWithParameters() throws Exception { */
@Test void getAssignedTargetsOfDistributionSetWithParameters() throws Exception {
final DistributionSet set = testdataFactory.createUpdatedDistributionSet(); final DistributionSet set = testdataFactory.createUpdatedDistributionSet();
assignDistributionSet(set, testdataFactory.createTargets(5, "targetMisc", "Test targets for query")) assignDistributionSet(set, testdataFactory.createTargets(5, "targetMisc", "Test targets for query"))
@@ -606,9 +624,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
} }
@Test /**
@Description("Ensures that assigned targets of DS are returned as persisted in the repository.") * Ensures that assigned targets of DS are returned as persisted in the repository.
void getAssignedTargetsOfDistributionSetIsEmpty() throws Exception { */
@Test void getAssignedTargetsOfDistributionSetIsEmpty() throws Exception {
final DistributionSet createdDs = testdataFactory.createDistributionSet(); final DistributionSet createdDs = testdataFactory.createDistributionSet();
mvc.perform(get( mvc.perform(get(
MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/assignedTargets")) MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/assignedTargets"))
@@ -617,9 +636,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
.andExpect(jsonPath("$.total", equalTo(0))); .andExpect(jsonPath("$.total", equalTo(0)));
} }
@Test /**
@Description("Ensures that installed targets of DS are returned as persisted in the repository.") * Ensures that installed targets of DS are returned as persisted in the repository.
void getInstalledTargetsOfDistributionSet() throws Exception { */
@Test void getInstalledTargetsOfDistributionSet() throws Exception {
// prepare distribution set // prepare distribution set
final String knownTargetId = "knownTargetId1"; final String knownTargetId = "knownTargetId1";
final DistributionSet createdDs = testdataFactory.createDistributionSet(); final DistributionSet createdDs = testdataFactory.createDistributionSet();
@@ -640,9 +660,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
.andExpect(jsonPath("$.content[0].controllerId", equalTo(knownTargetId))); .andExpect(jsonPath("$.content[0].controllerId", equalTo(knownTargetId)));
} }
@Test /**
@Description("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'.") * 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'.
void getInstalledTargetsOfDistributionSetWithParameters() throws Exception { */
@Test void getInstalledTargetsOfDistributionSetWithParameters() throws Exception {
final DistributionSet set = testdataFactory.createUpdatedDistributionSet(); final DistributionSet set = testdataFactory.createUpdatedDistributionSet();
final List<Target> targets = assignDistributionSet(set, final List<Target> targets = assignDistributionSet(set,
@@ -658,9 +679,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
.andExpect(content().contentType(MediaType.APPLICATION_JSON)); .andExpect(content().contentType(MediaType.APPLICATION_JSON));
} }
@Test /**
@Description("Ensures that target filters with auto assign DS are returned as persisted in the repository.") * Ensures that target filters with auto assign DS are returned as persisted in the repository.
void getAutoAssignTargetFiltersOfDistributionSet() throws Exception { */
@Test void getAutoAssignTargetFiltersOfDistributionSet() throws Exception {
// prepare distribution set // prepare distribution set
final String knownFilterName = "a"; final String knownFilterName = "a";
final DistributionSet createdDs = testdataFactory.createDistributionSet(); final DistributionSet createdDs = testdataFactory.createDistributionSet();
@@ -679,9 +701,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
.andExpect(jsonPath("$.content[0].name", equalTo(knownFilterName))); .andExpect(jsonPath("$.content[0].name", equalTo(knownFilterName)));
} }
@Test /**
@Description("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'.") * 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'.
void ggetAutoAssignTargetFiltersOfDistributionSetWithParameters() throws Exception { */
@Test void ggetAutoAssignTargetFiltersOfDistributionSetWithParameters() throws Exception {
final DistributionSet set = testdataFactory.createUpdatedDistributionSet(); final DistributionSet set = testdataFactory.createUpdatedDistributionSet();
targetFilterQueryManagement.create(entityFactory.targetFilterQuery().create().name("filter1").query("name==a") targetFilterQueryManagement.create(entityFactory.targetFilterQuery().create().name("filter1").query("name==a")
.autoAssignDistributionSet(set)); .autoAssignDistributionSet(set));
@@ -695,9 +718,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
} }
@Test /**
@Description("Ensures that an error is returned when the query is invalid.") * Ensures that an error is returned when the query is invalid.
void getAutoAssignTargetFiltersOfDSWithInvalidFilter() throws Exception { */
@Test void getAutoAssignTargetFiltersOfDSWithInvalidFilter() throws Exception {
// prepare distribution set // prepare distribution set
final DistributionSet createdDs = testdataFactory.createDistributionSet(); final DistributionSet createdDs = testdataFactory.createDistributionSet();
final String invalidQuery = "unknownField=le=42"; final String invalidQuery = "unknownField=le=42";
@@ -707,9 +731,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
.andExpect(status().isBadRequest()); .andExpect(status().isBadRequest());
} }
@Test /**
@Description("Ensures that target filters with auto assign DS are returned according to the query.") * Ensures that target filters with auto assign DS are returned according to the query.
void getMultipleAutoAssignTargetFiltersOfDistributionSet() throws Exception { */
@Test void getMultipleAutoAssignTargetFiltersOfDistributionSet() throws Exception {
final String filterNamePrefix = "filter-"; final String filterNamePrefix = "filter-";
final DistributionSet createdDs = testdataFactory.createDistributionSet(); final DistributionSet createdDs = testdataFactory.createDistributionSet();
final String query = "name==" + filterNamePrefix + "*"; final String query = "name==" + filterNamePrefix + "*";
@@ -724,9 +749,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
.andExpect(jsonPath("$.content[1].name", equalTo(filterNamePrefix + "2"))); .andExpect(jsonPath("$.content[1].name", equalTo(filterNamePrefix + "2")));
} }
@Test /**
@Description("Ensures that no target filters are returned according to the non matching query.") * Ensures that no target filters are returned according to the non matching query.
void getEmptyAutoAssignTargetFiltersOfDistributionSet() throws Exception { */
@Test void getEmptyAutoAssignTargetFiltersOfDistributionSet() throws Exception {
final String filterNamePrefix = "filter-"; final String filterNamePrefix = "filter-";
final DistributionSet createdDs = testdataFactory.createDistributionSet(); final DistributionSet createdDs = testdataFactory.createDistributionSet();
final String query = "name==doesNotExist"; final String query = "name==doesNotExist";
@@ -739,9 +765,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
.andExpect(jsonPath("$.size", equalTo(0))); .andExpect(jsonPath("$.size", equalTo(0)));
} }
@Test /**
@Description("Ensures that DS in repository are listed with proper paging properties.") * Ensures that DS in repository are listed with proper paging properties.
void getDistributionSetsWithoutAdditionalRequestParameters() throws Exception { */
@Test void getDistributionSetsWithoutAdditionalRequestParameters() throws Exception {
final int sets = 5; final int sets = 5;
createDistributionSetsAlphabetical(sets); createDistributionSetsAlphabetical(sets);
mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING)) mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING))
@@ -752,9 +779,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
.andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(sets))); .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(sets)));
} }
@Test /**
@Description("Ensures that DS in repository are listed with proper paging results with paging limit parameter.") * Ensures that DS in repository are listed with proper paging results with paging limit parameter.
void getDistributionSetsWithPagingLimitRequestParameter() throws Exception { */
@Test void getDistributionSetsWithPagingLimitRequestParameter() throws Exception {
final int sets = 5; final int sets = 5;
final int limitSize = 1; final int limitSize = 1;
createDistributionSetsAlphabetical(sets); createDistributionSetsAlphabetical(sets);
@@ -767,9 +795,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
.andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(limitSize))); .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(limitSize)));
} }
@Test /**
@Description("Ensures that DS in repository are listed with proper paging results with paging limit and offset parameter.") * Ensures that DS in repository are listed with proper paging results with paging limit and offset parameter.
void getDistributionSetsWithPagingLimitAndOffsetRequestParameter() throws Exception { */
@Test void getDistributionSetsWithPagingLimitAndOffsetRequestParameter() throws Exception {
final int sets = 5; final int sets = 5;
final int offsetParam = 2; final int offsetParam = 2;
final int expectedSize = sets - offsetParam; final int expectedSize = sets - offsetParam;
@@ -784,9 +813,11 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
.andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(expectedSize))); .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(expectedSize)));
} }
/**
* Ensures that multiple DS requested are listed with expected payload.
*/
@Test @Test
@WithUser(principal = "uploadTester", allSpPermissions = true) @WithUser(principal = "uploadTester", allSpPermissions = true)
@Description("Ensures that multiple DS requested are listed with expected payload.")
void getDistributionSets() throws Exception { void getDistributionSets() throws Exception {
// prepare test data // prepare test data
assertThat(distributionSetManagement.findByCompleted(true, PAGE)).isEmpty(); assertThat(distributionSetManagement.findByCompleted(true, PAGE)).isEmpty();
@@ -826,9 +857,11 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
contains(getOsModule(set).intValue()))); contains(getOsModule(set).intValue())));
} }
/**
* Ensures that single DS requested by ID is listed with expected payload.
*/
@Test @Test
@WithUser(principal = "uploadTester", allSpPermissions = true) @WithUser(principal = "uploadTester", allSpPermissions = true)
@Description("Ensures that single DS requested by ID is listed with expected payload.")
void getDistributionSet() throws Exception { void getDistributionSet() throws Exception {
final DistributionSet set = testdataFactory.createUpdatedDistributionSet(); final DistributionSet set = testdataFactory.createUpdatedDistributionSet();
@@ -860,9 +893,11 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
} }
/**
* Ensures that multipe DS posted to API are created in the repository.
*/
@Test @Test
@WithUser(principal = "uploadTester", allSpPermissions = true) @WithUser(principal = "uploadTester", allSpPermissions = true)
@Description("Ensures that multipe DS posted to API are created in the repository.")
void createDistributionSets() throws Exception { void createDistributionSets() throws Exception {
assertThat(distributionSetManagement.findByCompleted(true, PAGE)).isEmpty(); assertThat(distributionSetManagement.findByCompleted(true, PAGE)).isEmpty();
final SoftwareModule ah = testdataFactory.createSoftwareModule(TestdataFactory.SM_TYPE_APP); final SoftwareModule ah = testdataFactory.createSoftwareModule(TestdataFactory.SM_TYPE_APP);
@@ -917,9 +952,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
assertThat(three.getCreatedAt()).isGreaterThanOrEqualTo(current); assertThat(three.getCreatedAt()).isGreaterThanOrEqualTo(current);
} }
@Test /**
@Description("Ensures that DS deletion request to API is reflected by the repository.") * Ensures that DS deletion request to API is reflected by the repository.
void deleteUnassignedistributionSet() throws Exception { */
@Test void deleteUnassignedistributionSet() throws Exception {
// prepare test data // prepare test data
assertThat(distributionSetManagement.findByCompleted(true, PAGE)).isEmpty(); assertThat(distributionSetManagement.findByCompleted(true, PAGE)).isEmpty();
@@ -937,17 +973,19 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
assertThat(distributionSetManagement.count()).isZero(); assertThat(distributionSetManagement.count()).isZero();
} }
@Test /**
@Description("Ensures that DS deletion request to API on an entity that does not exist results in NOT_FOUND.") * Ensures that DS deletion request to API on an entity that does not exist results in NOT_FOUND.
void deleteDistributionSetThatDoesNotExistLeadsToNotFound() throws Exception { */
@Test void deleteDistributionSetThatDoesNotExistLeadsToNotFound() throws Exception {
mvc.perform(delete("/rest/v1/distributionsets/1234")) mvc.perform(delete("/rest/v1/distributionsets/1234"))
.andDo(MockMvcResultPrinter.print()) .andDo(MockMvcResultPrinter.print())
.andExpect(status().isNotFound()); .andExpect(status().isNotFound());
} }
@Test /**
@Description("Ensures that assigned DS deletion request to API is reflected by the repository by means of deleted flag set.") * Ensures that assigned DS deletion request to API is reflected by the repository by means of deleted flag set.
void deleteAssignedDistributionSet() throws Exception { */
@Test void deleteAssignedDistributionSet() throws Exception {
// prepare test data // prepare test data
assertThat(distributionSetManagement.findByCompleted(true, PAGE)).isEmpty(); assertThat(distributionSetManagement.findByCompleted(true, PAGE)).isEmpty();
@@ -975,9 +1013,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
assertThat(distributionSetManagement.findByCompleted(true, PAGE)).isEmpty(); assertThat(distributionSetManagement.findByCompleted(true, PAGE)).isEmpty();
} }
@Test /**
@Description("Ensures that DS property update request to API is reflected by the repository.") * Ensures that DS property update request to API is reflected by the repository.
void updateDistributionSet() throws Exception { */
@Test void updateDistributionSet() throws Exception {
// prepare test data // prepare test data
assertThat(distributionSetManagement.findByCompleted(true, PAGE)).isEmpty(); assertThat(distributionSetManagement.findByCompleted(true, PAGE)).isEmpty();
@@ -1004,9 +1043,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
assertThat(setupdated.isDeleted()).isFalse(); assertThat(setupdated.isDeleted()).isFalse();
} }
@Test /**
@Description("Ensures that DS property update on requiredMigrationStep fails if DS is assigned to a target.") * Ensures that DS property update on requiredMigrationStep fails if DS is assigned to a target.
void updateRequiredMigrationStepFailsIfDistributionSetisInUse() throws Exception { */
@Test void updateRequiredMigrationStepFailsIfDistributionSetisInUse() throws Exception {
// prepare test data // prepare test data
assertThat(distributionSetManagement.findByCompleted(true, PAGE)).isEmpty(); assertThat(distributionSetManagement.findByCompleted(true, PAGE)).isEmpty();
@@ -1029,9 +1069,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
assertThat(setupdated.getName()).isEqualTo(set.getName()); assertThat(setupdated.getName()).isEqualTo(set.getName());
} }
@Test /**
@Description("Ensures that the server reacts properly to invalid requests (URI, Media Type, Methods) with correct reponses.") * Ensures that the server reacts properly to invalid requests (URI, Media Type, Methods) with correct reponses.
void invalidRequestsOnDistributionSetsResource() throws Exception { */
@Test void invalidRequestsOnDistributionSetsResource() throws Exception {
final DistributionSet set = testdataFactory.createDistributionSet("one"); final DistributionSet set = testdataFactory.createDistributionSet("one");
final List<DistributionSet> sets = new ArrayList<>(); final List<DistributionSet> sets = new ArrayList<>();
@@ -1090,9 +1131,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
} }
@Test /**
@Description("Ensures that the metadata creation through API is reflected by the repository.") * Ensures that the metadata creation through API is reflected by the repository.
void createMetadata() throws Exception { */
@Test void createMetadata() throws Exception {
final DistributionSet testDS = testdataFactory.createDistributionSet("one"); final DistributionSet testDS = testdataFactory.createDistributionSet("one");
final String knownKey1 = "known.key.1.1"; final String knownKey1 = "known.key.1.1";
@@ -1132,9 +1174,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
assertThat(distributionSetManagement.getMetadata(testDS.getId())).hasSize(metaData1.length()); assertThat(distributionSetManagement.getMetadata(testDS.getId())).hasSize(metaData1.length());
} }
@Test /**
@Description("Ensures that a metadata update through API is reflected by the repository.") * Ensures that a metadata update through API is reflected by the repository.
void updateMetadata() throws Exception { */
@Test void updateMetadata() throws Exception {
// prepare and create metadata for update // prepare and create metadata for update
final String knownKey = "knownKey"; final String knownKey = "knownKey";
final String knownValue = "knownValue"; final String knownValue = "knownValue";
@@ -1153,9 +1196,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
assertThat(distributionSetManagement.getMetadata(testDS.getId()).get(knownKey)).isEqualTo(updateValue); assertThat(distributionSetManagement.getMetadata(testDS.getId()).get(knownKey)).isEqualTo(updateValue);
} }
@Test /**
@Description("Ensures that a metadata entry deletion through API is reflected by the repository.") * Ensures that a metadata entry deletion through API is reflected by the repository.
void deleteMetadata() throws Exception { */
@Test void deleteMetadata() throws Exception {
// prepare and create metadata for deletion // prepare and create metadata for deletion
final String knownKey = "knownKey"; final String knownKey = "knownKey";
final String knownValue = "knownValue"; final String knownValue = "knownValue";
@@ -1175,9 +1219,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
assertThat(distributionSetManagement.getMetadata(testDS.getId()).get(knownKey)).isNull(); assertThat(distributionSetManagement.getMetadata(testDS.getId()).get(knownKey)).isNull();
} }
@Test /**
@Description("Ensures that DS metadata deletion request to API on an entity that does not exist results in NOT_FOUND.") * Ensures that DS metadata deletion request to API on an entity that does not exist results in NOT_FOUND.
void deleteMetadataThatDoesNotExistLeadsToNotFound() throws Exception { */
@Test void deleteMetadataThatDoesNotExistLeadsToNotFound() throws Exception {
// prepare and create metadata for deletion // prepare and create metadata for deletion
final String knownKey = "knownKey"; final String knownKey = "knownKey";
final String knownValue = "knownValue"; final String knownValue = "knownValue";
@@ -1195,9 +1240,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
assertThat(distributionSetManagement.getMetadata(testDS.getId()).get(knownKey)).isNotNull(); assertThat(distributionSetManagement.getMetadata(testDS.getId()).get(knownKey)).isNotNull();
} }
@Test /**
@Description("Ensures that a metadata entry selection through API reflects the repository content.") * Ensures that a metadata entry selection through API reflects the repository content.
void getMetadataKey() throws Exception { */
@Test void getMetadataKey() throws Exception {
// prepare and create metadata // prepare and create metadata
final String knownKey = "knownKey"; final String knownKey = "knownKey";
final String knownValue = "knownValue"; final String knownValue = "knownValue";
@@ -1211,9 +1257,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
.andExpect(jsonPath("value", equalTo(knownValue))); .andExpect(jsonPath("value", equalTo(knownValue)));
} }
@Test /**
@Description("Get a paged list of meta data for a distribution set with standard page size.") * Get a paged list of meta data for a distribution set with standard page size.
void getMetadata() throws Exception { */
@Test void getMetadata() throws Exception {
final int totalMetadata = 4; final int totalMetadata = 4;
final String knownKeyPrefix = "knownKey"; final String knownKeyPrefix = "knownKey";
final String knownValuePrefix = "knownValue"; final String knownValuePrefix = "knownValue";
@@ -1228,9 +1275,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
.andExpect(content().contentType(MediaTypes.HAL_JSON)); .andExpect(content().contentType(MediaTypes.HAL_JSON));
} }
@Test /**
@Description("Ensures that a DS search with query parameters returns the expected result.") * Ensures that a DS search with query parameters returns the expected result.
void searchDistributionSetRsql() throws Exception { */
@Test void searchDistributionSetRsql() throws Exception {
final String dsSuffix = "test"; final String dsSuffix = "test";
final int amount = 10; final int amount = 10;
testdataFactory.createDistributionSets(dsSuffix, amount); testdataFactory.createDistributionSets(dsSuffix, amount);
@@ -1249,9 +1297,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
} }
@Test /**
@Description("Ensures that a DS search with complete==true parameter returns only DS that are actually completely filled with mandatory modules.") * Ensures that a DS search with complete==true parameter returns only DS that are actually completely filled with mandatory modules.
void filterDistributionSetComplete() throws Exception { */
@Test void filterDistributionSetComplete() throws Exception {
final int amount = 10; final int amount = 10;
testdataFactory.createDistributionSets(amount); testdataFactory.createDistributionSets(amount);
distributionSetManagement distributionSetManagement
@@ -1266,9 +1315,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
.andExpect(jsonPath("total", equalTo(10))); .andExpect(jsonPath("total", equalTo(10)));
} }
@Test /**
@Description("Ensures that a DS assigned target search with controllerId==1 parameter returns only the target with the given ID.") * Ensures that a DS assigned target search with controllerId==1 parameter returns only the target with the given ID.
void searchDistributionSetAssignedTargetsRsql() throws Exception { */
@Test void searchDistributionSetAssignedTargetsRsql() throws Exception {
// prepare distribution set // prepare distribution set
final Set<DistributionSet> createDistributionSetsAlphabetical = createDistributionSetsAlphabetical(1); final Set<DistributionSet> createDistributionSetsAlphabetical = createDistributionSetsAlphabetical(1);
final DistributionSet createdDs = createDistributionSetsAlphabetical.iterator().next(); final DistributionSet createdDs = createDistributionSetsAlphabetical.iterator().next();
@@ -1291,9 +1341,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
.andExpect(jsonPath("content[0].controllerId", equalTo("1"))); .andExpect(jsonPath("content[0].controllerId", equalTo("1")));
} }
/**
* Ensures that multi target assignment through API is reflected by the repository in the case of DOWNLOAD_ONLY.
*/
@Test @Test
@Description("Ensures that multi target assignment through API is reflected by the repository in the case of "
+ "DOWNLOAD_ONLY.")
void assignMultipleTargetsToDistributionSetAsDownloadOnly() throws Exception { void assignMultipleTargetsToDistributionSetAsDownloadOnly() throws Exception {
final DistributionSet createdDs = testdataFactory.createDistributionSet(); final DistributionSet createdDs = testdataFactory.createDistributionSet();
@@ -1314,9 +1365,11 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
.as("Five targets in repository have DS assigned").hasSize(5); .as("Five targets in repository have DS assigned").hasSize(5);
} }
/**
* Ensures that confirmation option is considered in assignment request.
*/
@ParameterizedTest @ParameterizedTest
@MethodSource("confirmationOptions") @MethodSource("confirmationOptions")
@Description("Ensures that confirmation option is considered in assignment request.")
void assignTargetsToDistributionSetWithConfirmationOptions(final boolean confirmationFlowActive, void assignTargetsToDistributionSetWithConfirmationOptions(final boolean confirmationFlowActive,
final Boolean confirmationRequired) throws Exception { final Boolean confirmationRequired) throws Exception {
final DistributionSet createdDs = testdataFactory.createDistributionSet(); final DistributionSet createdDs = testdataFactory.createDistributionSet();
@@ -1349,9 +1402,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
}); });
} }
@Test /**
@Description("A request for assigning a target multiple times results in a Bad Request when multiassignment is disabled.") * A request for assigning a target multiple times results in a Bad Request when multiassignment is disabled.
void multiAssignmentRequestNotAllowedIfDisabled() throws Exception { */
@Test void multiAssignmentRequestNotAllowedIfDisabled() throws Exception {
final String targetId = testdataFactory.createTarget().getControllerId(); final String targetId = testdataFactory.createTarget().getControllerId();
final Long dsId = testdataFactory.createDistributionSet().getId(); final Long dsId = testdataFactory.createDistributionSet().getId();
@@ -1365,9 +1419,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
.andExpect(status().isBadRequest()); .andExpect(status().isBadRequest());
} }
@Test /**
@Description("Identical assignments in a single request are removed when multiassignment is disabled.") * Identical assignments in a single request are removed when multiassignment is disabled.
void identicalAssignmentInRequestAreRemovedIfMultiassignmentsDisabled() throws Exception { */
@Test void identicalAssignmentInRequestAreRemovedIfMultiassignmentsDisabled() throws Exception {
final String targetId = testdataFactory.createTarget().getControllerId(); final String targetId = testdataFactory.createTarget().getControllerId();
final Long dsId = testdataFactory.createDistributionSet().getId(); final Long dsId = testdataFactory.createDistributionSet().getId();
@@ -1382,9 +1437,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
.andExpect(jsonPath("total", equalTo(1))); .andExpect(jsonPath("total", equalTo(1)));
} }
@Test /**
@Description("Assigning targets multiple times to a DS in one request works in multiassignment mode.") * Assigning targets multiple times to a DS in one request works in multiassignment mode.
void multiAssignment() throws Exception { */
@Test void multiAssignment() throws Exception {
final List<String> targetIds = testdataFactory.createTargets(2).stream().map(Target::getControllerId) final List<String> targetIds = testdataFactory.createTargets(2).stream().map(Target::getControllerId)
.toList(); .toList();
final Long dsId = testdataFactory.createDistributionSet().getId(); final Long dsId = testdataFactory.createDistributionSet().getId();
@@ -1403,9 +1459,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
.andExpect(jsonPath("total", equalTo(body.length()))); .andExpect(jsonPath("total", equalTo(body.length())));
} }
@Test /**
@Description("An assignment request containing a weight is only accepted when weight is valide and multi assignment is on.") * An assignment request containing a weight is only accepted when weight is valide and multi assignment is on.
void weightValidation() throws Exception { */
@Test void weightValidation() throws Exception {
final String targetId = testdataFactory.createTarget().getControllerId(); final String targetId = testdataFactory.createTarget().getControllerId();
final Long dsId = testdataFactory.createDistributionSet().getId(); final Long dsId = testdataFactory.createDistributionSet().getId();
final int weight = 78; final int weight = 78;
@@ -1434,9 +1491,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
assertThat(actions.get(0).getWeight()).get().isEqualTo(weight); assertThat(actions.get(0).getWeight()).get().isEqualTo(weight);
} }
@Test /**
@Description("Request to get the count of all Rollouts by status for specific Distribution set") * Request to get the count of all Rollouts by status for specific Distribution set
void statisticsForRolloutsCountByStatus() throws Exception { */
@Test void statisticsForRolloutsCountByStatus() throws Exception {
testdataFactory.createTargets("targets", 4); testdataFactory.createTargets("targets", 4);
DistributionSet ds1 = testdataFactory.createDistributionSet("DS1"); DistributionSet ds1 = testdataFactory.createDistributionSet("DS1");
DistributionSet ds2 = testdataFactory.createDistributionSet("DS2"); DistributionSet ds2 = testdataFactory.createDistributionSet("DS2");
@@ -1467,9 +1525,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
.andExpect(jsonPath("totalAutoAssignments").doesNotExist()); .andExpect(jsonPath("totalAutoAssignments").doesNotExist());
} }
@Test /**
@Description("Request to get the count of all Actions by status for specific Distribution set") * Request to get the count of all Actions by status for specific Distribution set
void statisticsForActionsCountByStatus() throws Exception { */
@Test void statisticsForActionsCountByStatus() throws Exception {
testdataFactory.createTargets("targets", 4); testdataFactory.createTargets("targets", 4);
DistributionSet ds1 = testdataFactory.createDistributionSet("DS1"); DistributionSet ds1 = testdataFactory.createDistributionSet("DS1");
@@ -1498,9 +1557,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
.andExpect(jsonPath("totalAutoAssignments").doesNotExist()); .andExpect(jsonPath("totalAutoAssignments").doesNotExist());
} }
@Test /**
@Description("Request to get the count of all Auto Assignments for specific Distribution set") * Request to get the count of all Auto Assignments for specific Distribution set
void statisticsForAutoAssignmentsCount() throws Exception { */
@Test void statisticsForAutoAssignmentsCount() throws Exception {
testdataFactory.createTargets("targets", 4); testdataFactory.createTargets("targets", 4);
DistributionSet ds1 = testdataFactory.createDistributionSet("DS1"); DistributionSet ds1 = testdataFactory.createDistributionSet("DS1");
DistributionSet ds2 = testdataFactory.createDistributionSet("DS2"); DistributionSet ds2 = testdataFactory.createDistributionSet("DS2");
@@ -1530,9 +1590,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
.andExpect(jsonPath("totalAutoAssignments").doesNotExist()); .andExpect(jsonPath("totalAutoAssignments").doesNotExist());
} }
@Test /**
@Description("Request to get full Statistics for specific Distribution set") * Request to get full Statistics for specific Distribution set
void statisticsForDistributionSet() throws Exception { */
@Test void statisticsForDistributionSet() throws Exception {
testdataFactory.createTargets("targets", 4); testdataFactory.createTargets("targets", 4);
testdataFactory.createTargets("autoAssignments", 4); testdataFactory.createTargets("autoAssignments", 4);
DistributionSet ds1 = testdataFactory.createDistributionSet("DS1"); DistributionSet ds1 = testdataFactory.createDistributionSet("DS1");
@@ -1566,9 +1627,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
.andExpect(jsonPath("totalAutoAssignments").doesNotExist()); .andExpect(jsonPath("totalAutoAssignments").doesNotExist());
} }
@Test /**
@Description("Verify invalidation of distribution sets that removes distribution sets from auto assignments, stops rollouts and cancels assignments") * Verify invalidation of distribution sets that removes distribution sets from auto assignments, stops rollouts and cancels assignments
void invalidateDistributionSet() throws Exception { */
@Test void invalidateDistributionSet() throws Exception {
final DistributionSet distributionSet = testdataFactory.createDistributionSet(); final DistributionSet distributionSet = testdataFactory.createDistributionSet();
final List<Target> targets = testdataFactory.createTargets(5, "invalidateDistributionSet"); final List<Target> targets = testdataFactory.createTargets(5, "invalidateDistributionSet");
assignDistributionSet(distributionSet, targets); assignDistributionSet(distributionSet, targets);
@@ -1600,9 +1662,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
} }
} }
@Test /**
@Description("Tests the lock. It is verified that the distribution set can be marked as locked through update operation.") * Tests the lock. It is verified that the distribution set can be marked as locked through update operation.
void lockDistributionSet() throws Exception { */
@Test void lockDistributionSet() throws Exception {
// prepare test data // prepare test data
assertThat(distributionSetManagement.findByCompleted(true, PAGE)).isEmpty(); assertThat(distributionSetManagement.findByCompleted(true, PAGE)).isEmpty();
@@ -1622,9 +1685,10 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
assertThat(updatedSet.isLocked()).isTrue(); assertThat(updatedSet.isLocked()).isTrue();
} }
@Test /**
@Description("Tests the unlock.") * Tests the unlock.
void unlockDistributionSet() throws Exception { */
@Test void unlockDistributionSet() throws Exception {
// prepare test data // prepare test data
assertThat(distributionSetManagement.findByCompleted(true, PAGE)).isEmpty(); assertThat(distributionSetManagement.findByCompleted(true, PAGE)).isEmpty();
@@ -1699,7 +1763,6 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe
.create(entityFactory.targetFilterQuery().create().name(filterNamePrefix + "c").query("name==y")); .create(entityFactory.targetFilterQuery().create().name(filterNamePrefix + "c").query("name==y"));
} }
@Step
private MvcResult executeMgmtTargetPost(final DistributionSet one, final DistributionSet two, private MvcResult executeMgmtTargetPost(final DistributionSet one, final DistributionSet two,
final DistributionSet three) throws Exception { final DistributionSet three) throws Exception {
return mvc return mvc

View File

@@ -27,9 +27,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Random; import java.util.Random;
import io.qameta.allure.Description;
import io.qameta.allure.Feature;
import io.qameta.allure.Story;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants; import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
import org.eclipse.hawkbit.mgmt.rest.resource.util.ResourceUtility; import org.eclipse.hawkbit.mgmt.rest.resource.util.ResourceUtility;
import org.eclipse.hawkbit.repository.event.remote.DistributionSetTagDeletedEvent; import org.eclipse.hawkbit.repository.event.remote.DistributionSetTagDeletedEvent;
@@ -51,16 +48,19 @@ import org.junit.jupiter.api.Test;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.ResultActions; import org.springframework.test.web.servlet.ResultActions;
@Feature("Component Tests - Management API") /**
@Story("Distribution Set Tag Resource") * Feature: Component Tests - Management API<br/>
* Story: Distribution Set Tag Resource
*/
class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegrationTest { class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegrationTest {
private static final String DISTRIBUTIONSETTAGS_ROOT = "http://localhost" + MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/"; private static final String DISTRIBUTIONSETTAGS_ROOT = "http://localhost" + MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/";
private static final Random RND = new Random(); private static final Random RND = new Random();
@Test /**
@Description("Verifies that a paged result list of DS tags reflects the content on the repository side.") * Verifies that a paged result list of DS tags reflects the content on the repository side.
@ExpectEvents({ @Expect(type = DistributionSetTagCreatedEvent.class, count = 2) }) */
@Test @ExpectEvents({ @Expect(type = DistributionSetTagCreatedEvent.class, count = 2) })
void getDistributionSetTags() throws Exception { void getDistributionSetTags() throws Exception {
final List<DistributionSetTag> tags = testdataFactory.createDistributionSetTags(2); final List<DistributionSetTag> tags = testdataFactory.createDistributionSetTags(2);
final DistributionSetTag assigned = tags.get(0); final DistributionSetTag assigned = tags.get(0);
@@ -79,18 +79,20 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio
.andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(2))); .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(2)));
} }
@Test /**
@Description("Handles the GET request of retrieving all distribution set tags based by parameter") * Handles the GET request of retrieving all distribution set tags based by parameter
void getDistributionSetTagsWithParameters() throws Exception { */
@Test void getDistributionSetTagsWithParameters() throws Exception {
testdataFactory.createDistributionSetTags(2); testdataFactory.createDistributionSetTags(2);
mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "?limit=10&sort=name:ASC&offset=0&q=name==DsTag")) mvc.perform(get(MgmtRestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "?limit=10&sort=name:ASC&offset=0&q=name==DsTag"))
.andDo(MockMvcResultPrinter.print()) .andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk()); .andExpect(status().isOk());
} }
@Test /**
@Description("Verifies that a paged result list of DS tags reflects the content on the repository side when filtered by distribution set id.") * Verifies that a paged result list of DS tags reflects the content on the repository side when filtered by distribution set id.
void getDistributionSetTagsByDistributionSetId() throws Exception { */
@Test void getDistributionSetTagsByDistributionSetId() throws Exception {
final List<DistributionSetTag> tags = testdataFactory.createDistributionSetTags(2); final List<DistributionSetTag> tags = testdataFactory.createDistributionSetTags(2);
final DistributionSetTag tag1 = tags.get(0); final DistributionSetTag tag1 = tags.get(0);
final DistributionSetTag tag2 = tags.get(1); final DistributionSetTag tag2 = tags.get(1);
@@ -127,9 +129,10 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio
.andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(1))); .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(1)));
} }
@Test /**
@Description("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.") * 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.
void getDistributionSetTagsByDistributionSetIdAndTagDescription() throws Exception { */
@Test void getDistributionSetTagsByDistributionSetIdAndTagDescription() throws Exception {
final List<DistributionSetTag> tags = testdataFactory.createDistributionSetTags(2); final List<DistributionSetTag> tags = testdataFactory.createDistributionSetTags(2);
final DistributionSetTag tag1 = tags.get(0); final DistributionSetTag tag1 = tags.get(0);
final DistributionSetTag tag2 = tags.get(1); final DistributionSetTag tag2 = tags.get(1);
@@ -155,9 +158,10 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio
.andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(1))); .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(1)));
} }
@Test /**
@Description("Verifies that a single result of a DS tag reflects the content on the repository side.") * Verifies that a single result of a DS tag reflects the content on the repository side.
@ExpectEvents({ @Expect(type = DistributionSetTagCreatedEvent.class, count = 2) }) */
@Test @ExpectEvents({ @Expect(type = DistributionSetTagCreatedEvent.class, count = 2) })
void getDistributionSetTag() throws Exception { void getDistributionSetTag() throws Exception {
final List<DistributionSetTag> tags = testdataFactory.createDistributionSetTags(2); final List<DistributionSetTag> tags = testdataFactory.createDistributionSetTags(2);
final DistributionSetTag assigned = tags.get(0); final DistributionSetTag assigned = tags.get(0);
@@ -173,9 +177,10 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio
equalTo(DISTRIBUTIONSETTAGS_ROOT + assigned.getId() + "/assigned?offset=0&limit=50"))); equalTo(DISTRIBUTIONSETTAGS_ROOT + assigned.getId() + "/assigned?offset=0&limit=50")));
} }
@Test /**
@Description("Verifies that created DS tags are stored in the repository as send to the API.") * Verifies that created DS tags are stored in the repository as send to the API.
@ExpectEvents({ @Expect(type = DistributionSetTagCreatedEvent.class, count = 2) }) */
@Test @ExpectEvents({ @Expect(type = DistributionSetTagCreatedEvent.class, count = 2) })
void createDistributionSetTags() throws Exception { void createDistributionSetTags() throws Exception {
final Tag tagOne = entityFactory.tag().create().colour("testcol1").description("its a test1").name("thetest1") final Tag tagOne = entityFactory.tag().create().colour("testcol1").description("its a test1").name("thetest1")
.build(); .build();
@@ -203,9 +208,10 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio
.andExpect(applyTagMatcherOnArrayResult(createdTwo)); .andExpect(applyTagMatcherOnArrayResult(createdTwo));
} }
@Test /**
@Description("Verifies that an updated DS tag is stored in the repository as send to the API.") * Verifies that an updated DS tag is stored in the repository as send to the API.
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = DistributionSetTagCreatedEvent.class, count = 1), @Expect(type = DistributionSetTagCreatedEvent.class, count = 1),
@Expect(type = DistributionSetTagUpdatedEvent.class, count = 1) }) @Expect(type = DistributionSetTagUpdatedEvent.class, count = 1) })
void updateDistributionSetTag() throws Exception { void updateDistributionSetTag() throws Exception {
@@ -232,9 +238,10 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio
.andExpect(applyTagMatcherOnArrayResult(updated)); .andExpect(applyTagMatcherOnArrayResult(updated));
} }
@Test /**
@Description("Verifies that the delete call is reflected by the repository.") * Verifies that the delete call is reflected by the repository.
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = DistributionSetTagCreatedEvent.class, count = 1), @Expect(type = DistributionSetTagCreatedEvent.class, count = 1),
@Expect(type = DistributionSetTagDeletedEvent.class, count = 1) }) @Expect(type = DistributionSetTagDeletedEvent.class, count = 1) })
void deleteDistributionSetTag() throws Exception { void deleteDistributionSetTag() throws Exception {
@@ -248,9 +255,10 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio
assertThat(distributionSetTagManagement.get(original.getId())).isNotPresent(); assertThat(distributionSetTagManagement.get(original.getId())).isNotPresent();
} }
@Test /**
@Description("Ensures that assigned DS to tag in repository are listed with proper paging results.") * Ensures that assigned DS to tag in repository are listed with proper paging results.
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = DistributionSetTagCreatedEvent.class, count = 1), @Expect(type = DistributionSetTagCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 5), @Expect(type = DistributionSetCreatedEvent.class, count = 5),
@Expect(type = DistributionSetUpdatedEvent.class, count = 5) }) @Expect(type = DistributionSetUpdatedEvent.class, count = 5) })
@@ -268,9 +276,10 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio
.andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(setsAssigned))); .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(setsAssigned)));
} }
@Test /**
@Description("Ensures that assigned DS to tag in repository are listed with proper paging results with paging limit parameter.") * Ensures that assigned DS to tag in repository are listed with proper paging results with paging limit parameter.
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = DistributionSetTagCreatedEvent.class, count = 1), @Expect(type = DistributionSetTagCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 5), @Expect(type = DistributionSetCreatedEvent.class, count = 5),
@Expect(type = DistributionSetUpdatedEvent.class, count = 5) }) @Expect(type = DistributionSetUpdatedEvent.class, count = 5) })
@@ -290,9 +299,10 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio
.andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(limitSize))); .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(limitSize)));
} }
@Test /**
@Description("Ensures that assigned DS to tag in repository are listed with proper paging results with paging limit and offset parameter.") * Ensures that assigned DS to tag in repository are listed with proper paging results with paging limit and offset parameter.
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = DistributionSetTagCreatedEvent.class, count = 1), @Expect(type = DistributionSetTagCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 5), @Expect(type = DistributionSetCreatedEvent.class, count = 5),
@Expect(type = DistributionSetUpdatedEvent.class, count = 5) }) @Expect(type = DistributionSetUpdatedEvent.class, count = 5) })
@@ -315,9 +325,10 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio
.andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(expectedSize))); .andExpect(jsonPath(MgmtTargetResourceTest.JSON_PATH_PAGED_LIST_CONTENT, hasSize(expectedSize)));
} }
@Test /**
@Description("Verifies that tag assignments done through tag API command are correctly stored in the repository.") * Verifies that tag assignments done through tag API command are correctly stored in the repository.
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = DistributionSetTagCreatedEvent.class, count = 1), @Expect(type = DistributionSetTagCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 1), @Expect(type = DistributionSetCreatedEvent.class, count = 1),
@Expect(type = DistributionSetUpdatedEvent.class, count = 1) }) @Expect(type = DistributionSetUpdatedEvent.class, count = 1) })
@@ -334,9 +345,10 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio
assertThat(updated.stream().map(DistributionSet::getId).toList()).containsOnly(set.getId()); assertThat(updated.stream().map(DistributionSet::getId).toList()).containsOnly(set.getId());
} }
@Test /**
@Description("Verifies that tag assignments done through tag API command are correctly stored in the repository.") * Verifies that tag assignments done through tag API command are correctly stored in the repository.
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = DistributionSetTagCreatedEvent.class, count = 1), @Expect(type = DistributionSetTagCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 2), @Expect(type = DistributionSetCreatedEvent.class, count = 2),
@Expect(type = DistributionSetUpdatedEvent.class, count = 2) }) @Expect(type = DistributionSetUpdatedEvent.class, count = 2) })
@@ -355,9 +367,10 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio
.containsAll(sets.stream().map(DistributionSet::getId).toList()); .containsAll(sets.stream().map(DistributionSet::getId).toList());
} }
@Test /**
@Description("Verifies that tag unassignments done through tag API command are correctly stored in the repository.") * Verifies that tag unassignments done through tag API command are correctly stored in the repository.
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = DistributionSetTagCreatedEvent.class, count = 1), @Expect(type = DistributionSetTagCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 2), @Expect(type = DistributionSetCreatedEvent.class, count = 2),
@Expect(type = DistributionSetUpdatedEvent.class, count = 3) }) @Expect(type = DistributionSetUpdatedEvent.class, count = 3) })
@@ -380,9 +393,10 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio
.containsOnly(assigned.getId()); .containsOnly(assigned.getId());
} }
@Test /**
@Description("Verifies that tag unassignments done through tag API command are correctly stored in the repository.") * Verifies that tag unassignments done through tag API command are correctly stored in the repository.
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = DistributionSetTagCreatedEvent.class, count = 1), @Expect(type = DistributionSetTagCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 3), @Expect(type = DistributionSetCreatedEvent.class, count = 3),
@Expect(type = DistributionSetUpdatedEvent.class, count = 5) }) @Expect(type = DistributionSetUpdatedEvent.class, count = 5) })
@@ -406,9 +420,10 @@ class MgmtDistributionSetTagResourceTest extends AbstractManagementApiIntegratio
.containsOnly(assigned.getId()); .containsOnly(assigned.getId());
} }
@Test /**
@Description("Verifies that tag assignments (multi targets) done through tag API command are correctly stored in the repository.") * Verifies that tag assignments (multi targets) done through tag API command are correctly stored in the repository.
@ExpectEvents({ */
@Test @ExpectEvents({
@Expect(type = DistributionSetTagCreatedEvent.class, count = 1), @Expect(type = DistributionSetTagCreatedEvent.class, count = 1),
@Expect(type = DistributionSetCreatedEvent.class, count = 2) }) @Expect(type = DistributionSetCreatedEvent.class, count = 2) })
void assignDistributionSetsNotFound() throws Exception { void assignDistributionSetsNotFound() throws Exception {

Some files were not shown because too many files have changed in this diff Show More