Migration to JUnit5 as default test runtime (#1082)
* Migrate tests to JUnit5 Signed-off-by: Dominic Schabel <dominic.schabel@bosch.io> * REST docs tests migrated to JUnit5 Signed-off-by: Dominic Schabel <dominic.schabel@bosch.io> * Migrated security and UI tests to JUnit5 Signed-off-by: Dominic Schabel <dominic.schabel@bosch.io> * Migrated management tests to JUnit5 Signed-off-by: Dominic Schabel <dominic.schabel@bosch.io> * Reflecting changes from JUnit5 migration Signed-off-by: Dominic Schabel <dominic.schabel@bosch.io> * Fix RabbitMQ test detection Signed-off-by: Dominic Schabel <dominic.schabel@bosch.io> * Drop support for JUnit4 Signed-off-by: Dominic Schabel <dominic.schabel@bosch.io>
This commit is contained in:
@@ -44,6 +44,11 @@
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.qameta.allure</groupId>
|
||||
<artifactId>allure-junit5</artifactId>
|
||||
|
||||
@@ -10,11 +10,11 @@
|
||||
package org.eclipse.hawkbit.ddi.json.model;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.assertj.core.util.Lists;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.exc.MismatchedInputException;
|
||||
@@ -22,6 +22,7 @@ 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;
|
||||
|
||||
/**
|
||||
* Test serializability of DDI api model 'DdiActionFeedback'
|
||||
@@ -65,13 +66,13 @@ public class DdiActionFeedbackTest {
|
||||
assertThat(ddiActionFeedback.getTime()).matches("20190809T121314");
|
||||
}
|
||||
|
||||
@Test(expected = MismatchedInputException.class)
|
||||
@Test
|
||||
@Description("Verify that deserialization fails for known properties with a wrong datatype")
|
||||
public void shouldFailForObjectWithWrongDataTypes() throws IOException {
|
||||
// Setup
|
||||
String serializedDdiActionFeedback = "{\"id\": [1],\"time\":\"20190809T121314\",\"status\":{\"execution\":\"closed\",\"result\":null,\"details\":[]}}";
|
||||
|
||||
// Test
|
||||
mapper.readValue(serializedDdiActionFeedback, DdiActionFeedback.class);
|
||||
assertThatExceptionOfType(MismatchedInputException.class).isThrownBy(
|
||||
() -> mapper.readValue(serializedDdiActionFeedback, DdiActionFeedback.class));
|
||||
}
|
||||
}
|
||||
@@ -10,12 +10,13 @@
|
||||
package org.eclipse.hawkbit.ddi.json.model;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.exc.MismatchedInputException;
|
||||
@@ -62,13 +63,13 @@ public class DdiActionHistoryTest {
|
||||
assertThat(ddiActionHistory.toString()).contains("SomeAction", "Some message");
|
||||
}
|
||||
|
||||
@Test(expected = MismatchedInputException.class)
|
||||
@Test
|
||||
@Description("Verify that deserialization fails for known properties with a wrong datatype")
|
||||
public void shouldFailForObjectWithWrongDataTypes() throws IOException {
|
||||
// Setup
|
||||
String serializedDdiActionFeedback = "{\"status\": [SomeAction], \"messages\": [\"Some message\"]}";
|
||||
|
||||
// Test
|
||||
mapper.readValue(serializedDdiActionFeedback, DdiActionHistory.class);
|
||||
assertThatExceptionOfType(MismatchedInputException.class).isThrownBy(
|
||||
() -> mapper.readValue(serializedDdiActionFeedback, DdiActionHistory.class));
|
||||
}
|
||||
}
|
||||
@@ -10,10 +10,11 @@
|
||||
package org.eclipse.hawkbit.ddi.json.model;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.exc.MismatchedInputException;
|
||||
@@ -65,14 +66,15 @@ public class DdiArtifactHashTest {
|
||||
assertThat(ddiArtifact.getSha256()).isEqualTo("789");
|
||||
}
|
||||
|
||||
@Test(expected = MismatchedInputException.class)
|
||||
@Test
|
||||
@Description("Verify that deserialization fails for known properties with a wrong datatype")
|
||||
public void shouldFailForObjectWithWrongDataTypes() throws IOException {
|
||||
// Setup
|
||||
String serializedDdiArtifact = "{\"sha1\": [123], \"md5\": 456, \"sha256\": \"789\"";
|
||||
|
||||
// Test
|
||||
mapper.readValue(serializedDdiArtifact, DdiArtifactHash.class);
|
||||
assertThatExceptionOfType(MismatchedInputException.class).isThrownBy(
|
||||
() -> mapper.readValue(serializedDdiArtifact, DdiArtifactHash.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,10 +10,11 @@
|
||||
package org.eclipse.hawkbit.ddi.json.model;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.exc.MismatchedInputException;
|
||||
@@ -72,13 +73,14 @@ public class DdiArtifactTest {
|
||||
assertThat(ddiArtifact.getHashes().getSha256()).isEqualTo("789");
|
||||
}
|
||||
|
||||
@Test(expected = MismatchedInputException.class)
|
||||
@Test
|
||||
@Description("Verify that deserialization fails for known properties with a wrong datatype")
|
||||
public void shouldFailForObjectWithWrongDataTypes() throws IOException {
|
||||
// Setup
|
||||
String serializedDdiArtifact = "{\"filename\": [\"test.file\"],\"hashes\":{\"sha1\":\"123\",\"md5\":\"456\",\"sha256\":\"789\"},\"size\":111,\"links\":[]}";
|
||||
|
||||
// Test
|
||||
mapper.readValue(serializedDdiArtifact, DdiArtifact.class);
|
||||
assertThatExceptionOfType(MismatchedInputException.class).isThrownBy(
|
||||
() -> mapper.readValue(serializedDdiArtifact, DdiArtifact.class));
|
||||
}
|
||||
}
|
||||
@@ -10,10 +10,11 @@
|
||||
package org.eclipse.hawkbit.ddi.json.model;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.exc.MismatchedInputException;
|
||||
@@ -59,13 +60,14 @@ public class DdiCancelActionToStopTest {
|
||||
assertThat(ddiCancelActionToStop.getStopId()).contains("12345");
|
||||
}
|
||||
|
||||
@Test(expected = MismatchedInputException.class)
|
||||
@Test
|
||||
@Description("Verify that deserialization fails for known properties with a wrong datatype")
|
||||
public void shouldFailForObjectWithWrongDataTypes() throws IOException {
|
||||
// Setup
|
||||
String serializedDdiCancelActionToStop = "{\"stopId\": [\"12345\"]}";
|
||||
|
||||
// Test
|
||||
mapper.readValue(serializedDdiCancelActionToStop, DdiCancelActionToStop.class);
|
||||
assertThatExceptionOfType(MismatchedInputException.class).isThrownBy(
|
||||
() -> mapper.readValue(serializedDdiCancelActionToStop, DdiCancelActionToStop.class));
|
||||
}
|
||||
}
|
||||
@@ -10,10 +10,11 @@
|
||||
package org.eclipse.hawkbit.ddi.json.model;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.exc.MismatchedInputException;
|
||||
@@ -61,13 +62,14 @@ public class DdiCancelTest {
|
||||
assertThat(ddiCancel.getCancelAction().getStopId()).matches("1234");
|
||||
}
|
||||
|
||||
@Test(expected = MismatchedInputException.class)
|
||||
@Test
|
||||
@Description("Verify that deserialization fails for known properties with a wrong datatype")
|
||||
public void shouldFailForObjectWithWrongDataTypes() throws IOException {
|
||||
// Setup
|
||||
String serializedDdiCancel = "{\"id\":[\"1234\"],\"cancelAction\":{\"stopId\":\"1234\"}}";
|
||||
|
||||
// Test
|
||||
mapper.readValue(serializedDdiCancel, DdiCancel.class);
|
||||
assertThatExceptionOfType(MismatchedInputException.class).isThrownBy(
|
||||
() -> mapper.readValue(serializedDdiCancel, DdiCancel.class));
|
||||
}
|
||||
}
|
||||
@@ -10,12 +10,13 @@
|
||||
package org.eclipse.hawkbit.ddi.json.model;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.exc.MismatchedInputException;
|
||||
@@ -69,13 +70,14 @@ public class DdiChunkTest {
|
||||
assertThat(ddiChunk.getArtifacts().size()).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test(expected = MismatchedInputException.class)
|
||||
@Test
|
||||
@Description("Verify that deserialization fails for known properties with a wrong datatype")
|
||||
public void shouldFailForObjectWithWrongDataTypes() throws IOException {
|
||||
// Setup
|
||||
String serializedDdiChunk = "{\"part\":[\"1234\"],\"version\":\"1.0\",\"name\":\"Dummy-Artifact\",\"artifacts\":[]}";
|
||||
|
||||
// Test
|
||||
mapper.readValue(serializedDdiChunk, DdiChunk.class);
|
||||
assertThatExceptionOfType(MismatchedInputException.class).isThrownBy(
|
||||
() -> mapper.readValue(serializedDdiChunk, DdiChunk.class));
|
||||
}
|
||||
}
|
||||
@@ -10,12 +10,13 @@
|
||||
package org.eclipse.hawkbit.ddi.json.model;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.exc.MismatchedInputException;
|
||||
@@ -62,14 +63,15 @@ public class DdiConfigDataTest {
|
||||
assertThat(ddiConfigData.getMode()).isEqualTo(DdiUpdateMode.REPLACE);
|
||||
}
|
||||
|
||||
@Test(expected = MismatchedInputException.class)
|
||||
@Test
|
||||
@Description("Verify that deserialization fails for known properties with a wrong datatype")
|
||||
public void shouldFailForObjectWithWrongDataTypes() throws IOException {
|
||||
// Setup
|
||||
String serializedDdiConfigData = "{\"data\":{\"test\":\"data\"},\"mode\":[\"replace\"],\"unknownProperty\":\"test\"}";
|
||||
|
||||
// Test
|
||||
mapper.readValue(serializedDdiConfigData, DdiConfigData.class);
|
||||
assertThatExceptionOfType(MismatchedInputException.class).isThrownBy(
|
||||
() -> mapper.readValue(serializedDdiConfigData, DdiConfigData.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -10,10 +10,11 @@
|
||||
package org.eclipse.hawkbit.ddi.json.model;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.exc.MismatchedInputException;
|
||||
@@ -58,13 +59,14 @@ public class DdiConfigTest {
|
||||
assertThat(ddiConfig.getPolling().getSleep()).isEqualTo("123");
|
||||
}
|
||||
|
||||
@Test(expected = MismatchedInputException.class)
|
||||
@Test
|
||||
@Description("Verify that deserialization fails for known properties with a wrong datatype")
|
||||
public void shouldFailForObjectWithWrongDataTypes() throws IOException {
|
||||
// Setup
|
||||
String serializedDdiConfig = "{\"polling\":{\"sleep\":[\"10\"]}}";
|
||||
|
||||
// Test
|
||||
mapper.readValue(serializedDdiConfig, DdiConfig.class);
|
||||
assertThatExceptionOfType(MismatchedInputException.class).isThrownBy(
|
||||
() -> mapper.readValue(serializedDdiConfig, DdiConfig.class));
|
||||
}
|
||||
}
|
||||
@@ -10,10 +10,11 @@
|
||||
package org.eclipse.hawkbit.ddi.json.model;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.exc.MismatchedInputException;
|
||||
@@ -61,13 +62,14 @@ public class DdiControllerBaseTest {
|
||||
assertThat(ddiControllerBase.getConfig().getPolling().getSleep()).isEqualTo("123");
|
||||
}
|
||||
|
||||
@Test(expected = MismatchedInputException.class)
|
||||
@Test
|
||||
@Description("Verify that deserialization fails for known properties with a wrong datatype")
|
||||
public void shouldFailForObjectWithWrongDataTypes() throws IOException {
|
||||
// Setup
|
||||
String serializedDdiControllerBase = "{\"config\":{\"polling\":{\"sleep\":[\"123\"]}},\"links\":[],\"unknownProperty\":\"test\"}";
|
||||
|
||||
// Test
|
||||
mapper.readValue(serializedDdiControllerBase, DdiControllerBase.class);
|
||||
assertThatExceptionOfType(MismatchedInputException.class).isThrownBy(
|
||||
() -> mapper.readValue(serializedDdiControllerBase, DdiControllerBase.class));
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@
|
||||
package org.eclipse.hawkbit.ddi.json.model;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.eclipse.hawkbit.ddi.json.model.DdiDeployment.DdiMaintenanceWindowStatus.AVAILABLE;
|
||||
import static org.eclipse.hawkbit.ddi.json.model.DdiDeployment.HandlingType.ATTEMPT;
|
||||
import static org.eclipse.hawkbit.ddi.json.model.DdiDeployment.HandlingType.FORCED;
|
||||
@@ -18,7 +19,7 @@ import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.exc.MismatchedInputException;
|
||||
@@ -79,7 +80,7 @@ public class DdiDeploymentBaseTest {
|
||||
AVAILABLE.getStatus());
|
||||
}
|
||||
|
||||
@Test(expected = MismatchedInputException.class)
|
||||
@Test
|
||||
@Description("Verify that deserialization fails for known properties with a wrong datatype")
|
||||
public void shouldFailForObjectWithWrongDataTypes() throws IOException {
|
||||
// Setup
|
||||
@@ -89,6 +90,7 @@ public class DdiDeploymentBaseTest {
|
||||
+ "\"Action status message 2\"]},\"links\":[]}";
|
||||
|
||||
// Test
|
||||
mapper.readValue(serializedDdiDeploymentBase, DdiDeploymentBase.class);
|
||||
assertThatExceptionOfType(MismatchedInputException.class).isThrownBy(
|
||||
() -> mapper.readValue(serializedDdiDeploymentBase, DdiDeploymentBase.class));
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@
|
||||
package org.eclipse.hawkbit.ddi.json.model;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.eclipse.hawkbit.ddi.json.model.DdiDeployment.DdiMaintenanceWindowStatus.AVAILABLE;
|
||||
import static org.eclipse.hawkbit.ddi.json.model.DdiDeployment.HandlingType.ATTEMPT;
|
||||
import static org.eclipse.hawkbit.ddi.json.model.DdiDeployment.HandlingType.FORCED;
|
||||
@@ -17,7 +18,7 @@ import static org.eclipse.hawkbit.ddi.json.model.DdiDeployment.HandlingType.FORC
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.exc.MismatchedInputException;
|
||||
@@ -68,7 +69,7 @@ public class DdiDeploymentTest {
|
||||
assertThat(ddiDeployment.getMaintenanceWindow().getStatus()).isEqualTo(AVAILABLE.getStatus());
|
||||
}
|
||||
|
||||
@Test(expected = MismatchedInputException.class)
|
||||
@Test
|
||||
@Description("Verify that deserialization fails for known properties with a wrong datatype")
|
||||
public void shouldFailForObjectWithWrongDataTypes() throws IOException {
|
||||
// Setup
|
||||
@@ -76,6 +77,7 @@ public class DdiDeploymentTest {
|
||||
+ "\"maintenanceWindow\":\"available\",\"chunks\":[]}";
|
||||
|
||||
// Test
|
||||
mapper.readValue(serializedDdiDeployment, DdiDeployment.class);
|
||||
assertThatExceptionOfType(MismatchedInputException.class).isThrownBy(
|
||||
() -> mapper.readValue(serializedDdiDeployment, DdiDeployment.class));
|
||||
}
|
||||
}
|
||||
@@ -10,10 +10,11 @@
|
||||
package org.eclipse.hawkbit.ddi.json.model;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.exc.MismatchedInputException;
|
||||
@@ -61,13 +62,14 @@ public class DdiMetadataTest {
|
||||
assertThat(ddiMetadata.getValue()).isEqualTo("testValue");
|
||||
}
|
||||
|
||||
@Test(expected = MismatchedInputException.class)
|
||||
@Test
|
||||
@Description("Verify that deserialization fails for known properties with a wrong datatype")
|
||||
public void shouldFailForObjectWithWrongDataTypes() throws IOException {
|
||||
// Setup
|
||||
String serializedDdiMetadata = "{\"key\":[\"testKey\"],\"value\":\"testValue\"}";
|
||||
|
||||
// Test
|
||||
mapper.readValue(serializedDdiMetadata, DdiMetadata.class);
|
||||
assertThatExceptionOfType(MismatchedInputException.class).isThrownBy(
|
||||
() -> mapper.readValue(serializedDdiMetadata, DdiMetadata.class));
|
||||
}
|
||||
}
|
||||
@@ -10,10 +10,11 @@
|
||||
package org.eclipse.hawkbit.ddi.json.model;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.exc.MismatchedInputException;
|
||||
@@ -57,13 +58,14 @@ public class DdiPollingTest {
|
||||
assertThat(ddiPolling.getSleep()).isEqualTo("10");
|
||||
}
|
||||
|
||||
@Test(expected = MismatchedInputException.class)
|
||||
@Test
|
||||
@Description("Verify that deserialization fails for known properties with a wrong datatype")
|
||||
public void shouldFailForObjectWithWrongDataTypes() throws IOException {
|
||||
// Setup
|
||||
String serializedDdiPolling = "{\"sleep\":[\"10\"]}";
|
||||
|
||||
// Test
|
||||
mapper.readValue(serializedDdiPolling, DdiPolling.class);
|
||||
assertThatExceptionOfType(MismatchedInputException.class).isThrownBy(
|
||||
() -> mapper.readValue(serializedDdiPolling, DdiPolling.class));
|
||||
}
|
||||
}
|
||||
@@ -10,10 +10,11 @@
|
||||
package org.eclipse.hawkbit.ddi.json.model;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.exc.MismatchedInputException;
|
||||
@@ -59,13 +60,14 @@ public class DdiProgressTest {
|
||||
assertThat(ddiProgress.getOf()).isEqualTo(100);
|
||||
}
|
||||
|
||||
@Test(expected = MismatchedInputException.class)
|
||||
@Test
|
||||
@Description("Verify that deserialization fails for known properties with a wrong datatype")
|
||||
public void shouldFailForObjectWithWrongDataTypes() throws IOException {
|
||||
// Setup
|
||||
String serializedDdiProgress = "{\"cnt\":[30],\"of\":100}";
|
||||
|
||||
// Test
|
||||
mapper.readValue(serializedDdiProgress, DdiProgress.class);
|
||||
assertThatExceptionOfType(MismatchedInputException.class).isThrownBy(
|
||||
() -> mapper.readValue(serializedDdiProgress, DdiProgress.class));
|
||||
}
|
||||
}
|
||||
@@ -10,11 +10,12 @@
|
||||
package org.eclipse.hawkbit.ddi.json.model;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.eclipse.hawkbit.ddi.json.model.DdiResult.FinalResult.NONE;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.exc.MismatchedInputException;
|
||||
@@ -64,13 +65,14 @@ public class DdiResultTest {
|
||||
assertThat(ddiResult.getProgress().getOf()).isEqualTo(100);
|
||||
}
|
||||
|
||||
@Test(expected = MismatchedInputException.class)
|
||||
@Test
|
||||
@Description("Verify that deserialization fails for known properties with a wrong datatype")
|
||||
public void shouldFailForObjectWithWrongDataTypes() throws IOException {
|
||||
// Setup
|
||||
String serializedDdiResult = "{\"finished\":[\"none\"],\"progress\":{\"cnt\":30,\"of\":100}}";
|
||||
|
||||
// Test
|
||||
mapper.readValue(serializedDdiResult, DdiResult.class);
|
||||
assertThatExceptionOfType(MismatchedInputException.class).isThrownBy(
|
||||
() -> mapper.readValue(serializedDdiResult, DdiResult.class));
|
||||
}
|
||||
}
|
||||
@@ -10,13 +10,14 @@
|
||||
package org.eclipse.hawkbit.ddi.json.model;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.eclipse.hawkbit.ddi.json.model.DdiResult.FinalResult.NONE;
|
||||
import static org.eclipse.hawkbit.ddi.json.model.DdiStatus.ExecutionStatus.PROCEEDING;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.exc.MismatchedInputException;
|
||||
@@ -72,7 +73,7 @@ public class DdiStatusTest {
|
||||
assertThat(ddiStatus.getResult().getProgress().getOf()).isEqualTo(100);
|
||||
}
|
||||
|
||||
@Test(expected = MismatchedInputException.class)
|
||||
@Test
|
||||
@Description("Verify that deserialization fails for known properties with a wrong datatype")
|
||||
public void shouldFailForObjectWithWrongDataTypes() throws IOException {
|
||||
// Setup
|
||||
@@ -80,6 +81,7 @@ public class DdiStatusTest {
|
||||
+ "\"progress\":{\"cnt\":30,\"of\":100}},\"details\":[]}";
|
||||
|
||||
// Test
|
||||
mapper.readValue(serializedDdiStatus, DdiStatus.class);
|
||||
assertThatExceptionOfType(MismatchedInputException.class).isThrownBy(
|
||||
() -> mapper.readValue(serializedDdiStatus, DdiStatus.class));
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
@@ -11,7 +11,6 @@ package org.eclipse.hawkbit.ddi.rest.resource;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
|
||||
import org.eclipse.hawkbit.repository.jpa.RepositoryApplicationConfiguration;
|
||||
import org.eclipse.hawkbit.repository.test.TestConfiguration;
|
||||
|
||||
@@ -37,8 +37,8 @@ import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.repository.test.util.TestdataFactory;
|
||||
import org.eclipse.hawkbit.repository.test.util.WithUser;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -66,7 +66,7 @@ public class DdiArtifactDownloadTest extends AbstractDDiApiIntegrationTest {
|
||||
|
||||
private final SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.ENGLISH);
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.repository.test.util.TestdataFactory;
|
||||
import org.eclipse.hawkbit.rest.util.JsonBuilder;
|
||||
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.hateoas.MediaTypes;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.integration.json.JsonPathUtils;
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.eclipse.hawkbit.repository.exception.InvalidTargetAttributeException;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.rest.util.JsonBuilder;
|
||||
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.hateoas.MediaTypes;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
|
||||
@@ -49,7 +49,7 @@ import org.eclipse.hawkbit.repository.test.matcher.ExpectEvents;
|
||||
import org.eclipse.hawkbit.rest.exception.MessageNotReadableException;
|
||||
import org.eclipse.hawkbit.rest.util.JsonBuilder;
|
||||
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort.Direction;
|
||||
import org.springframework.hateoas.MediaTypes;
|
||||
|
||||
@@ -58,7 +58,7 @@ import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
||||
import org.eclipse.hawkbit.security.HawkbitSecurityProperties;
|
||||
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey;
|
||||
import org.eclipse.hawkbit.util.IpUtil;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.hateoas.MediaTypes;
|
||||
import org.springframework.http.MediaType;
|
||||
@@ -146,7 +146,7 @@ public class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
|
||||
|
||||
// make a poll, audit information should not be changed, run as
|
||||
// controller principal!
|
||||
securityRule.runAs(WithSpringAuthorityRule.withController("controller", CONTROLLER_ROLE_ANONYMOUS), () -> {
|
||||
WithSpringAuthorityRule.runAs(WithSpringAuthorityRule.withController("controller", CONTROLLER_ROLE_ANONYMOUS), () -> {
|
||||
mvc.perform(get("/{tenant}/controller/v1/" + knownTargetControllerId, tenantAware.getCurrentTenant()))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
||||
return null;
|
||||
@@ -201,13 +201,13 @@ public class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
|
||||
@ExpectEvents({ @Expect(type = TargetCreatedEvent.class, count = 1),
|
||||
@Expect(type = TargetPollEvent.class, count = 1) })
|
||||
public void pollWithModifiedGloablPollingTime() throws Exception {
|
||||
securityRule.runAs(WithSpringAuthorityRule.withUser("tenantadmin", HAS_AUTH_TENANT_CONFIGURATION), () -> {
|
||||
WithSpringAuthorityRule.runAs(WithSpringAuthorityRule.withUser("tenantadmin", HAS_AUTH_TENANT_CONFIGURATION), () -> {
|
||||
tenantConfigurationManagement.addOrUpdateConfiguration(TenantConfigurationKey.POLLING_TIME_INTERVAL,
|
||||
"00:02:00");
|
||||
return null;
|
||||
});
|
||||
|
||||
securityRule.runAs(WithSpringAuthorityRule.withUser("controller", CONTROLLER_ROLE_ANONYMOUS), () -> {
|
||||
WithSpringAuthorityRule.runAs(WithSpringAuthorityRule.withUser("controller", CONTROLLER_ROLE_ANONYMOUS), () -> {
|
||||
mvc.perform(get("/{tenant}/controller/v1/4711", tenantAware.getCurrentTenant()))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
|
||||
.andExpect(content().contentType(MediaTypes.HAL_JSON))
|
||||
@@ -322,7 +322,7 @@ public class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
|
||||
final long create = System.currentTimeMillis();
|
||||
|
||||
// make a poll, audit information should be set on plug and play
|
||||
securityRule.runAs(WithSpringAuthorityRule.withController("controller", CONTROLLER_ROLE_ANONYMOUS), () -> {
|
||||
WithSpringAuthorityRule.runAs(WithSpringAuthorityRule.withController("controller", CONTROLLER_ROLE_ANONYMOUS), () -> {
|
||||
mvc.perform(
|
||||
get("/{tenant}/controller/v1/{controllerId}", tenantAware.getCurrentTenant(), knownControllerId1))
|
||||
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
|
||||
@@ -568,7 +568,7 @@ public class DdiRootControllerTest extends AbstractDDiApiIntegrationTest {
|
||||
public void sleepTimeResponseForDifferentMaintenanceWindowParameters() throws Exception {
|
||||
final DistributionSet ds = testdataFactory.createDistributionSet("");
|
||||
|
||||
securityRule.runAs(WithSpringAuthorityRule.withUser("tenantadmin", HAS_AUTH_TENANT_CONFIGURATION), () -> {
|
||||
WithSpringAuthorityRule.runAs(WithSpringAuthorityRule.withUser("tenantadmin", HAS_AUTH_TENANT_CONFIGURATION), () -> {
|
||||
tenantConfigurationManagement.addOrUpdateConfiguration(TenantConfigurationKey.POLLING_TIME_INTERVAL,
|
||||
"00:05:00");
|
||||
tenantConfigurationManagement.addOrUpdateConfiguration(TenantConfigurationKey.MIN_POLLING_TIME_INTERVAL,
|
||||
|
||||
@@ -21,7 +21,7 @@ import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.rest.util.JsonBuilder;
|
||||
import org.eclipse.hawkbit.security.DosFilter;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
|
||||
@@ -9,16 +9,15 @@
|
||||
package org.eclipse.hawkbit.mgmt.json.model;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import io.qameta.allure.Description;
|
||||
import io.qameta.allure.Feature;
|
||||
import io.qameta.allure.Story;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@Feature("Unit Tests - Management API")
|
||||
@Story("Paged List Handling")
|
||||
@@ -29,7 +28,7 @@ public class PagedListTest {
|
||||
public void createListWithNullContentThrowsException() {
|
||||
try {
|
||||
new PagedList<>(null, 0);
|
||||
fail("as content is null");
|
||||
Assertions.fail("as content is null");
|
||||
} catch (final NullPointerException e) {
|
||||
}
|
||||
}
|
||||
@@ -60,6 +59,5 @@ public class PagedListTest {
|
||||
knownContentList.add("content2");
|
||||
|
||||
assertListSize(knownTotal, knownContentList);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,10 +16,10 @@ import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import io.qameta.allure.Story;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.context.annotation.Description;
|
||||
|
||||
@Story("Retrieve all open action ids")
|
||||
|
||||
@@ -15,8 +15,8 @@ import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.rest.util.JsonBuilder;
|
||||
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.autoconfigure.web.servlet.HttpEncodingAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.web.servlet.server.Encoding;
|
||||
@@ -49,7 +49,7 @@ public class MgmtContentTypeTest extends AbstractManagementApiIntegrationTest {
|
||||
private DistributionSet ds;
|
||||
private final String dsName = "DS-ö";
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setupBeforeTest() {
|
||||
ds = testdataFactory.generateDistributionSet(dsName);
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.web.servlet.MvcResult;
|
||||
|
||||
@@ -38,7 +38,7 @@ import org.eclipse.hawkbit.repository.test.matcher.ExpectEvents;
|
||||
import org.eclipse.hawkbit.rest.util.JsonBuilder;
|
||||
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
||||
import org.json.JSONException;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.web.servlet.ResultActions;
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ import org.eclipse.hawkbit.repository.test.util.WithUser;
|
||||
import org.eclipse.hawkbit.rest.util.JsonBuilder;
|
||||
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
||||
import org.json.JSONObject;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.web.servlet.MvcResult;
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@ import org.eclipse.hawkbit.repository.model.Artifact;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import io.qameta.allure.Description;
|
||||
@@ -38,7 +38,7 @@ public class MgmtDownloadResourceTest extends AbstractManagementApiIntegrationTe
|
||||
|
||||
private static final String DOWNLOAD_ID_NOT_AVAILABLE = "downloadIdNotAvailable";
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setupCache() {
|
||||
|
||||
final DistributionSet distributionSet = testdataFactory.createDistributionSet("Test");
|
||||
|
||||
@@ -44,7 +44,7 @@ import org.eclipse.hawkbit.repository.test.util.WithUser;
|
||||
import org.eclipse.hawkbit.rest.util.JsonBuilder;
|
||||
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
||||
import org.eclipse.hawkbit.rest.util.SuccessCondition;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort.Direction;
|
||||
|
||||
@@ -52,8 +52,8 @@ import org.eclipse.hawkbit.rest.util.JsonBuilder;
|
||||
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.hateoas.MediaTypes;
|
||||
import org.springframework.http.MediaType;
|
||||
@@ -78,7 +78,7 @@ import io.qameta.allure.Story;
|
||||
"hawkbit.server.security.dos.maxArtifactStorage=500000" })
|
||||
public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegrationTest {
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void assertPreparationOfRepo() {
|
||||
assertThat(softwareModuleManagement.findAll(PAGE)).as("no softwaremodule should be founded").hasSize(0);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ import org.eclipse.hawkbit.repository.test.util.WithUser;
|
||||
import org.eclipse.hawkbit.rest.util.JsonBuilder;
|
||||
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
||||
import org.json.JSONObject;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.web.servlet.MvcResult;
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
|
||||
import org.eclipse.hawkbit.rest.exception.MessageNotReadableException;
|
||||
import org.eclipse.hawkbit.rest.json.model.ExceptionInfo;
|
||||
import org.json.JSONObject;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.web.servlet.MvcResult;
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
||||
import org.eclipse.hawkbit.util.IpUtil;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.orm.jpa.JpaProperties;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
|
||||
@@ -36,7 +36,7 @@ import org.eclipse.hawkbit.repository.test.matcher.Expect;
|
||||
import org.eclipse.hawkbit.repository.test.matcher.ExpectEvents;
|
||||
import org.eclipse.hawkbit.rest.util.JsonBuilder;
|
||||
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.web.servlet.ResultActions;
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtRestConstants;
|
||||
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
||||
import org.json.JSONObject;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.http.MediaType;
|
||||
|
||||
import io.qameta.allure.Description;
|
||||
|
||||
@@ -20,10 +20,6 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
/**
|
||||
* Utility additions for the REST API tests.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public final class ResourceUtility {
|
||||
private static final ObjectMapper mapper = new ObjectMapper();
|
||||
@@ -43,5 +39,4 @@ public final class ResourceUtility {
|
||||
throws JsonParseException, JsonMappingException, IOException {
|
||||
return mapper.readValue(responseBody, PagedList.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import org.eclipse.hawkbit.repository.test.TestConfiguration;
|
||||
import org.eclipse.hawkbit.repository.test.util.AbstractIntegrationTest;
|
||||
import org.eclipse.hawkbit.rest.filter.ExcludePathAwareShallowETagFilter;
|
||||
import org.eclipse.hawkbit.rest.util.FilterHttpResponse;
|
||||
import org.junit.Before;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||
import org.springframework.cloud.stream.test.binder.TestSupportBinderAutoConfiguration;
|
||||
@@ -45,10 +45,8 @@ public abstract class AbstractRestIntegrationTest extends AbstractIntegrationTes
|
||||
@Autowired
|
||||
protected WebApplicationContext webApplicationContext;
|
||||
|
||||
@Override
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void before() throws Exception {
|
||||
super.before();
|
||||
mvc = createMvcWebAppContext(webApplicationContext).build();
|
||||
}
|
||||
|
||||
|
||||
@@ -37,8 +37,8 @@ import org.eclipse.hawkbit.rest.documentation.AbstractApiRestDocumentation;
|
||||
import org.eclipse.hawkbit.rest.documentation.ApiModelPropertiesGeneric;
|
||||
import org.eclipse.hawkbit.rest.util.JsonBuilder;
|
||||
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.hateoas.MediaTypes;
|
||||
import org.springframework.http.MediaType;
|
||||
|
||||
@@ -55,12 +55,10 @@ import io.qameta.allure.Story;
|
||||
public class RootControllerDocumentationTest extends AbstractApiRestDocumentation {
|
||||
private static final String CONTROLLER_ID = "CONTROLLER_ID";
|
||||
|
||||
@Override
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
host = "ddi-api.host";
|
||||
resourceName = "rootcontroller";
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -40,11 +40,12 @@ import org.eclipse.hawkbit.rest.AbstractRestIntegrationTest;
|
||||
import org.eclipse.hawkbit.rest.RestConfiguration;
|
||||
import org.eclipse.hawkbit.rest.util.FilterHttpResponse;
|
||||
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cloud.stream.test.binder.TestSupportBinderAutoConfiguration;
|
||||
import org.springframework.restdocs.JUnitRestDocumentation;
|
||||
import org.springframework.restdocs.RestDocumentationContextProvider;
|
||||
import org.springframework.restdocs.RestDocumentationExtension;
|
||||
import org.springframework.restdocs.mockmvc.MockMvcRestDocumentation;
|
||||
import org.springframework.restdocs.mockmvc.RestDocumentationResultHandler;
|
||||
import org.springframework.restdocs.payload.FieldDescriptor;
|
||||
@@ -65,14 +66,12 @@ import io.qameta.allure.Feature;
|
||||
*
|
||||
*/
|
||||
@Feature("Documentation Verfication - API")
|
||||
@ExtendWith(RestDocumentationExtension.class)
|
||||
@ContextConfiguration(classes = { DdiApiConfiguration.class, MgmtApiConfiguration.class, RestConfiguration.class,
|
||||
RepositoryApplicationConfiguration.class, TestConfiguration.class, TestSupportBinderAutoConfiguration.class })
|
||||
@TestPropertySource(locations = { "classpath:/updateserver-restdocumentation-test.properties" })
|
||||
public abstract class AbstractApiRestDocumentation extends AbstractRestIntegrationTest {
|
||||
|
||||
@Rule
|
||||
public final JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation("target/generated-snippets");
|
||||
|
||||
@Autowired
|
||||
protected ObjectMapper objectMapper;
|
||||
|
||||
@@ -89,12 +88,12 @@ public abstract class AbstractApiRestDocumentation extends AbstractRestIntegrati
|
||||
|
||||
protected String host = "management-api.host";
|
||||
|
||||
@Before
|
||||
protected void setUp() {
|
||||
@BeforeEach
|
||||
protected void setupMvc(RestDocumentationContextProvider restDocContext) {
|
||||
this.document = document(resourceName + "/{method-name}", preprocessRequest(prettyPrint()),
|
||||
preprocessResponse(prettyPrint()));
|
||||
this.mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext)
|
||||
.apply(MockMvcRestDocumentation.documentationConfiguration(this.restDocumentation).uris()
|
||||
.apply(MockMvcRestDocumentation.documentationConfiguration(restDocContext).uris()
|
||||
.withScheme("https").withHost(host + ".com").withPort(443))
|
||||
.alwaysDo(this.document).addFilter(filterHttpResponse).build();
|
||||
arrayPrefix = "[]";
|
||||
|
||||
@@ -32,8 +32,8 @@ import org.eclipse.hawkbit.rest.documentation.ApiModelPropertiesGeneric;
|
||||
import org.eclipse.hawkbit.rest.documentation.DocumenationResponseFieldsSnippet;
|
||||
import org.eclipse.hawkbit.rest.documentation.MgmtApiModelProperties;
|
||||
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.restdocs.payload.FieldDescriptor;
|
||||
import org.springframework.restdocs.payload.JsonFieldType;
|
||||
@@ -56,11 +56,9 @@ public class DistributionSetTagResourceDocumentationTest extends AbstractApiRest
|
||||
|
||||
private DistributionSet distributionSet;
|
||||
|
||||
@Override
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
resourceName = "distributionsettag";
|
||||
super.setUp();
|
||||
distributionSet = createDistributionSet();
|
||||
}
|
||||
|
||||
|
||||
@@ -37,8 +37,8 @@ import org.eclipse.hawkbit.rest.documentation.MgmtApiModelProperties;
|
||||
import org.eclipse.hawkbit.rest.util.JsonBuilder;
|
||||
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
||||
import org.json.JSONObject;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.restdocs.payload.JsonFieldType;
|
||||
|
||||
@@ -54,11 +54,9 @@ import io.qameta.allure.Story;
|
||||
@Story("DistributionSetTypes Resource")
|
||||
public class DistributionSetTypesDocumentationTest extends AbstractApiRestDocumentation {
|
||||
|
||||
@Override
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
this.resourceName = "distributionsettypes";
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -39,8 +39,8 @@ import org.eclipse.hawkbit.rest.util.JsonBuilder;
|
||||
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.hateoas.MediaTypes;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.restdocs.payload.JsonFieldType;
|
||||
@@ -53,17 +53,14 @@ import io.qameta.allure.Story;
|
||||
|
||||
/**
|
||||
* Documentation generation for Management API for {@link DistributionSet}.
|
||||
*
|
||||
*/
|
||||
@Feature("Spring Rest Docs Tests - DistributionSet")
|
||||
@Story("DistributionSet Resource")
|
||||
public class DistributionSetsDocumentationTest extends AbstractApiRestDocumentation {
|
||||
|
||||
@Override
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
resourceName = "distributionsets";
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -41,8 +41,8 @@ import org.eclipse.hawkbit.rest.documentation.DocumenationResponseFieldsSnippet;
|
||||
import org.eclipse.hawkbit.rest.documentation.MgmtApiModelProperties;
|
||||
import org.eclipse.hawkbit.rest.util.JsonBuilder;
|
||||
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.hateoas.MediaTypes;
|
||||
@@ -68,11 +68,9 @@ public class RolloutResourceDocumentationTest extends AbstractApiRestDocumentati
|
||||
@Autowired
|
||||
private RolloutTestApprovalStrategy approvalStrategy;
|
||||
|
||||
@Override
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
this.resourceName = "rollouts";
|
||||
super.setUp();
|
||||
arrayPrefix = "content[].";
|
||||
approvalStrategy.setApprovalNeeded(false);
|
||||
}
|
||||
|
||||
@@ -31,8 +31,8 @@ import org.eclipse.hawkbit.rest.documentation.MgmtApiModelProperties;
|
||||
import org.eclipse.hawkbit.rest.util.JsonBuilder;
|
||||
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
||||
import org.json.JSONObject;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.restdocs.payload.JsonFieldType;
|
||||
|
||||
@@ -41,19 +41,15 @@ import io.qameta.allure.Feature;
|
||||
import io.qameta.allure.Story;
|
||||
|
||||
/**
|
||||
*
|
||||
* Documentation generation for Management API for {@link SoftwareModuleType}.
|
||||
*
|
||||
*/
|
||||
@Feature("Spring Rest Docs Tests - SoftwareModuleType")
|
||||
@Story("Softwaremoduletypes Resource")
|
||||
public class SoftwaremoduleTypesDocumentationTest extends AbstractApiRestDocumentation {
|
||||
|
||||
@Override
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
this.resourceName = "softwaremoduletypes";
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -40,8 +40,8 @@ import org.eclipse.hawkbit.rest.util.JsonBuilder;
|
||||
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.hateoas.MediaTypes;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.mock.web.MockMultipartFile;
|
||||
@@ -58,11 +58,9 @@ import io.qameta.allure.Story;
|
||||
@Story("Softwaremodule Resource")
|
||||
public class SoftwaremodulesDocumentationTest extends AbstractApiRestDocumentation {
|
||||
|
||||
@Override
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
resourceName = "softwaremodules";
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -32,8 +32,8 @@ import org.eclipse.hawkbit.rest.documentation.ApiModelPropertiesGeneric;
|
||||
import org.eclipse.hawkbit.rest.documentation.MgmtApiModelProperties;
|
||||
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
||||
import org.json.JSONObject;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.restdocs.payload.JsonFieldType;
|
||||
import org.springframework.restdocs.snippet.Snippet;
|
||||
@@ -54,11 +54,9 @@ public class TargetFilterQueriesResourceDocumentationTest extends AbstractApiRes
|
||||
private static final String EXAMPLE_TFQ_NAME = "filter1";
|
||||
private static final String EXAMPLE_TFQ_QUERY = "name==*";
|
||||
|
||||
@Override
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
resourceName = "targetfilters";
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -42,8 +42,8 @@ import org.eclipse.hawkbit.rest.documentation.MgmtApiModelProperties;
|
||||
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort.Direction;
|
||||
import org.springframework.hateoas.MediaTypes;
|
||||
@@ -68,11 +68,9 @@ public class TargetResourceDocumentationTest extends AbstractApiRestDocumentatio
|
||||
|
||||
private final String targetId = "137";
|
||||
|
||||
@Override
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
resourceName = "targets";
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -33,8 +33,8 @@ import org.eclipse.hawkbit.rest.documentation.ApiModelPropertiesGeneric;
|
||||
import org.eclipse.hawkbit.rest.documentation.DocumenationResponseFieldsSnippet;
|
||||
import org.eclipse.hawkbit.rest.documentation.MgmtApiModelProperties;
|
||||
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.restdocs.payload.FieldDescriptor;
|
||||
import org.springframework.restdocs.payload.JsonFieldType;
|
||||
@@ -57,11 +57,9 @@ public class TargetTagResourceDocumentationTest extends AbstractApiRestDocumenta
|
||||
|
||||
private DistributionSet distributionSet;
|
||||
|
||||
@Override
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
resourceName = "targettag";
|
||||
super.setUp();
|
||||
distributionSet = createDistributionSet();
|
||||
}
|
||||
|
||||
|
||||
@@ -32,8 +32,8 @@ import org.eclipse.hawkbit.rest.documentation.MgmtApiModelProperties;
|
||||
import org.eclipse.hawkbit.rest.util.MockMvcResultPrinter;
|
||||
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties;
|
||||
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.restdocs.payload.FieldDescriptor;
|
||||
@@ -95,11 +95,9 @@ public class TenantResourceDocumentationTest extends AbstractApiRestDocumentatio
|
||||
@Autowired
|
||||
protected TenantConfigurationProperties tenantConfigurationProperties;
|
||||
|
||||
@Override
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
resourceName = "tenant";
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user