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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user