diff options
| author | Szymon Szukalski <szymon@skas.io> | 2024-07-23 14:48:26 +1000 |
|---|---|---|
| committer | Szymon Szukalski <szymon@skas.io> | 2024-07-23 14:48:26 +1000 |
| commit | fc96ec673822d9f1cbe0e5eb004c12b7f8f2db9b (patch) | |
| tree | 848e9b7e2f7958b168b1494531dae2ffc5e9f81e /src/test/java/com/stileeducation | |
| parent | d4c94470514f28849a5b3cbd9d04982825187554 (diff) | |
Create JAXB beans and initial test for request model
Diffstat (limited to 'src/test/java/com/stileeducation')
| -rw-r--r-- | src/test/java/com/stileeducation/markr/MarkrApplicationTests.java | 13 | ||||
| -rw-r--r-- | src/test/java/com/stileeducation/markr/dto/MCQTestResultsDTOTests.java | 36 |
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(); + } + +} |
