summaryrefslogtreecommitdiff
path: root/src/test/java/com/stileeducation/markr/dto/MCQTestResultsDTOTests.java
blob: cc0f24818025c63a3ce88d54f16b247fb169c6ec (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
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();
  }

}