blob: cceec516eaee2586ff80f9fbd308157ca975cb19 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
package com.stileeducation.markr.dto;
import com.stileeducation.markr.MarkrApplication;
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 org.springframework.test.context.ActiveProfiles;
import java.io.IOException;
import java.io.InputStream;
import static org.assertj.core.api.Assertions.assertThat;
@SpringBootTest(classes = MarkrApplication.class)
@ActiveProfiles("test")
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();
}
}
|