summaryrefslogtreecommitdiff
path: root/src/test/java/com
diff options
context:
space:
mode:
authorSzymon Szukalski <szymon@skas.io>2024-07-23 14:48:26 +1000
committerSzymon Szukalski <szymon@skas.io>2024-07-23 14:48:26 +1000
commitfc96ec673822d9f1cbe0e5eb004c12b7f8f2db9b (patch)
tree848e9b7e2f7958b168b1494531dae2ffc5e9f81e /src/test/java/com
parentd4c94470514f28849a5b3cbd9d04982825187554 (diff)
Create JAXB beans and initial test for request model
Diffstat (limited to 'src/test/java/com')
-rw-r--r--src/test/java/com/stileeducation/markr/MarkrApplicationTests.java13
-rw-r--r--src/test/java/com/stileeducation/markr/dto/MCQTestResultsDTOTests.java36
2 files changed, 36 insertions, 13 deletions
diff --git a/src/test/java/com/stileeducation/markr/MarkrApplicationTests.java b/src/test/java/com/stileeducation/markr/MarkrApplicationTests.java
deleted file mode 100644
index 2301e26..0000000
--- a/src/test/java/com/stileeducation/markr/MarkrApplicationTests.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package com.stileeducation.markr;
-
-import org.junit.jupiter.api.Test;
-import org.springframework.boot.test.context.SpringBootTest;
-
-@SpringBootTest
-class MarkrApplicationTests {
-
- @Test
- void contextLoads() {
- }
-
-}
diff --git a/src/test/java/com/stileeducation/markr/dto/MCQTestResultsDTOTests.java b/src/test/java/com/stileeducation/markr/dto/MCQTestResultsDTOTests.java
new file mode 100644
index 0000000..cc0f248
--- /dev/null
+++ b/src/test/java/com/stileeducation/markr/dto/MCQTestResultsDTOTests.java
@@ -0,0 +1,36 @@
+package com.stileeducation.markr.dto;
+
+import jakarta.xml.bind.JAXBContext;
+import jakarta.xml.bind.JAXBException;
+import jakarta.xml.bind.Unmarshaller;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.core.io.ClassPathResource;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+@SpringBootTest
+public class MCQTestResultsDTOTests {
+
+ private static MCQTestResultsDTO sampleResults;
+
+ @BeforeAll
+ static void setup() throws JAXBException, IOException {
+ ClassPathResource resource = new ClassPathResource("sample-results.xml");
+ try (InputStream inputStream = resource.getInputStream()) {
+ JAXBContext jaxbContext = JAXBContext.newInstance(MCQTestResultsDTO.class);
+ Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
+ sampleResults = (MCQTestResultsDTO) unmarshaller.unmarshal(inputStream);
+ }
+ }
+
+ @Test
+ void givenSampleResultsXMLShouldUnmarshall() throws IOException {
+ assertThat(sampleResults).isNotNull();
+ }
+
+}