Remove allure (phase2) (#2483)
Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -11,27 +11,28 @@ package org.eclipse.hawkbit.artifact.repository.urlhandler;
|
||||
|
||||
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;
|
||||
|
||||
@Feature("Unit Tests - Artifact URL Handler")
|
||||
@Story("Base62 Utility tests")
|
||||
/**
|
||||
* Feature: Unit Tests - Artifact URL Handler<br/>
|
||||
* Story: Base62 Utility tests
|
||||
*/
|
||||
class Base62UtilTest {
|
||||
|
||||
@Test
|
||||
@Description("Convert Base10 numbers to Base62 ASCII strings.")
|
||||
void fromBase10() {
|
||||
/**
|
||||
* Convert Base10 numbers to Base62 ASCII strings.
|
||||
*/
|
||||
@Test void fromBase10() {
|
||||
assertThat(Base62Util.fromBase10(0L)).isEqualTo("0");
|
||||
assertThat(Base62Util.fromBase10(11L)).isEqualTo("B");
|
||||
assertThat(Base62Util.fromBase10(36L)).isEqualTo("a");
|
||||
assertThat(Base62Util.fromBase10(999L)).isEqualTo("G7");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Convert Base62 ASCII strings to Base10 numbers.")
|
||||
void toBase10() {
|
||||
/**
|
||||
* Convert Base62 ASCII strings to Base10 numbers.
|
||||
*/
|
||||
@Test void toBase10() {
|
||||
assertThat(Base62Util.toBase10("0")).isZero();
|
||||
assertThat(Base62Util.toBase10("B")).isEqualTo(11);
|
||||
assertThat(Base62Util.toBase10("a")).isEqualTo(36L);
|
||||
|
||||
@@ -15,9 +15,6 @@ import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
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.URLPlaceholder.SoftwareData;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
@@ -27,9 +24,10 @@ import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
/**
|
||||
* 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)
|
||||
class PropertyBasedArtifactUrlHandlerTest {
|
||||
|
||||
@@ -61,9 +59,10 @@ class PropertyBasedArtifactUrlHandlerTest {
|
||||
urlHandlerUnderTest = new PropertyBasedArtifactUrlHandler(properties, "");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests the generation of http download url.")
|
||||
void urlGenerationWithDefaultConfiguration() {
|
||||
/**
|
||||
* Tests the generation of http download url.
|
||||
*/
|
||||
@Test void urlGenerationWithDefaultConfiguration() {
|
||||
properties.getProtocols().put("download-http", new UrlProtocol());
|
||||
|
||||
final List<ArtifactUrl> ddiUrls = urlHandlerUnderTest.getUrls(placeHolder, ApiType.DDI);
|
||||
@@ -75,9 +74,10 @@ class PropertyBasedArtifactUrlHandlerTest {
|
||||
.isEqualTo(urlHandlerUnderTest.getUrls(placeHolder, ApiType.DMF));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Tests the generation of custom download url with a CoAP example that supports DMF only.")
|
||||
void urlGenerationWithCustomConfiguration() {
|
||||
/**
|
||||
* Tests the generation of custom download url with a CoAP example that supports DMF only.
|
||||
*/
|
||||
@Test void urlGenerationWithCustomConfiguration() {
|
||||
final UrlProtocol proto = new UrlProtocol();
|
||||
proto.setIp("127.0.0.1");
|
||||
proto.setPort(5683);
|
||||
@@ -94,9 +94,10 @@ class PropertyBasedArtifactUrlHandlerTest {
|
||||
"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.")
|
||||
void urlGenerationWithCustomShortConfiguration() {
|
||||
/**
|
||||
* Tests the generation of custom download url using Base62 references with a CoAP example that supports DMF only.
|
||||
*/
|
||||
@Test void urlGenerationWithCustomShortConfiguration() {
|
||||
final UrlProtocol proto = new UrlProtocol();
|
||||
proto.setIp("127.0.0.1");
|
||||
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
|
||||
@Description("Verifies that the full qualified host of the statically defined hostname is replaced with the host of the request.")
|
||||
void urlGenerationWithHostFromRequest() throws URISyntaxException {
|
||||
/**
|
||||
* Verifies that the full qualified host of the statically defined hostname is replaced with the host of the request.
|
||||
*/
|
||||
@Test void urlGenerationWithHostFromRequest() throws URISyntaxException {
|
||||
final String testHost = "ddi.host.com";
|
||||
|
||||
final UrlProtocol proto = new UrlProtocol();
|
||||
@@ -133,9 +135,10 @@ class PropertyBasedArtifactUrlHandlerTest {
|
||||
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.")
|
||||
void urlGenerationWithProtocolFromRequest() throws URISyntaxException {
|
||||
/**
|
||||
* Verifies that the protocol of the statically defined hostname is replaced with the protocol of the request.
|
||||
*/
|
||||
@Test void urlGenerationWithProtocolFromRequest() throws URISyntaxException {
|
||||
final String testHost = "ddi.host.com";
|
||||
|
||||
final UrlProtocol proto = new UrlProtocol();
|
||||
@@ -148,9 +151,10 @@ class PropertyBasedArtifactUrlHandlerTest {
|
||||
"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.")
|
||||
void urlGenerationWithPortFromRequest() throws URISyntaxException {
|
||||
/**
|
||||
* Verifies that the port of the statically defined hostname is replaced with the port of the request.
|
||||
*/
|
||||
@Test void urlGenerationWithPortFromRequest() throws URISyntaxException {
|
||||
final UrlProtocol proto = new UrlProtocol();
|
||||
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));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Verifies that if default protocol port in request is used then url is returned without port")
|
||||
void urlGenerationWithPortFromRequestForHttps() throws URISyntaxException {
|
||||
/**
|
||||
* Verifies that if default protocol port in request is used then url is returned without port
|
||||
*/
|
||||
@Test void urlGenerationWithPortFromRequestForHttps() throws URISyntaxException {
|
||||
final String protocol = "https";
|
||||
final UrlProtocol proto = new UrlProtocol();
|
||||
proto.setRef("{protocolRequest}://{hostnameRequest}:{portRequest}/{tenant}/controller/v1/{controllerId}/softwaremodules/{softwareModuleId}/artifacts/{artifactFileName}");
|
||||
@@ -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.")
|
||||
void urlGenerationWithDomainFromRequest() throws URISyntaxException {
|
||||
/**
|
||||
* Verifies that the domain of the statically defined hostname is replaced with the domain of the request.
|
||||
*/
|
||||
@Test void urlGenerationWithDomainFromRequest() throws URISyntaxException {
|
||||
final UrlProtocol proto = new UrlProtocol();
|
||||
proto.setHostname("host.bumlux.net");
|
||||
proto.setRef("{protocol}://{domainRequest}/{tenant}/controller/v1/{controllerId}/softwaremodules/{softwareModuleId}/artifacts/{artifactFileName}");
|
||||
|
||||
@@ -11,13 +11,12 @@ package org.eclipse.hawkbit.artifact.repository.urlhandler;
|
||||
|
||||
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;
|
||||
|
||||
@Feature("Unit Tests - Artifact URL Handler")
|
||||
@Story("URL placeholder tests")
|
||||
/**
|
||||
* Feature: Unit Tests - Artifact URL Handler<br/>
|
||||
* Story: URL placeholder tests
|
||||
*/
|
||||
class URLPlaceholderTest {
|
||||
|
||||
private final URLPlaceholder.SoftwareData softwareData;
|
||||
@@ -28,9 +27,10 @@ class URLPlaceholderTest {
|
||||
this.placeholder = new URLPlaceholder("SuperCorp", 123L, "Super-1", 1L, softwareData);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Same object should be equal")
|
||||
// Exception squid:S5785 - JUnit assertTrue/assertFalse should be simplified to the corresponding dedicated assertion
|
||||
/**
|
||||
* Same object should be equal
|
||||
*/
|
||||
@Test // Exception squid:S5785 - JUnit assertTrue/assertFalse should be simplified to the corresponding dedicated assertion
|
||||
// Need to test the equals method and need to bypass magic logic in utility classes
|
||||
@SuppressWarnings({ "squid:S5838" })
|
||||
void sameObjectShouldBeEqual() {
|
||||
@@ -38,9 +38,10 @@ class URLPlaceholderTest {
|
||||
assertThat(placeholder.equals(placeholder)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Different object should not be equal")
|
||||
@SuppressWarnings({ "squid:S5838" })
|
||||
/**
|
||||
* Different object should not be equal
|
||||
*/
|
||||
@Test @SuppressWarnings({ "squid:S5838" })
|
||||
void differentObjectShouldNotBeEqual() {
|
||||
final URLPlaceholder.SoftwareData softwareData2 = new URLPlaceholder.SoftwareData(2L, "file.txt", 123L, "someHash123");
|
||||
final URLPlaceholder placeholder2 = new URLPlaceholder("SuperCorp", 123L, "Super-2", 2L, softwareData2);
|
||||
@@ -53,18 +54,20 @@ class URLPlaceholderTest {
|
||||
assertThat(placeholder.equals(placeholderWithOtherSoftwareData)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Different objects with same properties should be equal")
|
||||
void differentObjectsWithSamePropertiesShouldBeEqual() {
|
||||
/**
|
||||
* Different objects with same properties should be equal
|
||||
*/
|
||||
@Test void differentObjectsWithSamePropertiesShouldBeEqual() {
|
||||
final URLPlaceholder placeholderWithSameProperties = new URLPlaceholder(placeholder.getTenant(), placeholder.getTenantId(),
|
||||
placeholder.getControllerId(), placeholder.getTargetId(), softwareData);
|
||||
assertThat(placeholder).isEqualTo(placeholderWithSameProperties);
|
||||
assertThat(placeholderWithSameProperties).isEqualTo(placeholder);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Should not equal null")
|
||||
// Exception squid:S5785 - JUnit assertTrue/assertFalse should be simplified to
|
||||
/**
|
||||
* Should not equal null
|
||||
*/
|
||||
@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
|
||||
@@ -74,9 +77,10 @@ class URLPlaceholderTest {
|
||||
assertThat(softwareData.equals(null)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("HashCode should not change")
|
||||
void hashCodeShouldNotChange() {
|
||||
/**
|
||||
* HashCode should not change
|
||||
*/
|
||||
@Test void hashCodeShouldNotChange() {
|
||||
final URLPlaceholder placeholderWithSameProperties = new URLPlaceholder(placeholder.getTenant(), placeholder.getTenantId(),
|
||||
placeholder.getControllerId(), placeholder.getTargetId(), softwareData);
|
||||
assertThat(placeholder).hasSameHashCodeAs(placeholder).hasSameHashCodeAs(placeholderWithSameProperties);
|
||||
|
||||
Reference in New Issue
Block a user