Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: some refacs in PatientMapperTest #143

Merged
merged 2 commits into from
Oct 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
package org.miracum.streams.ume.obdstofhir.mapper.mii;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.*;

import ca.uhn.fhir.context.FhirContext;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.fasterxml.jackson.module.jakarta.xmlbind.JakartaXmlBindAnnotationModule;
import de.basisdatensatz.obds.v3.OBDS;
import java.io.IOException;
import java.util.TimeZone;
import org.approvaltests.Approvals;
import org.approvaltests.core.Options;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import org.miracum.streams.ume.obdstofhir.FhirProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
Expand All @@ -20,17 +22,18 @@
@SpringBootTest(classes = {FhirProperties.class})
@EnableConfigurationProperties
class PatientMapperTest {
private final PatientMapper sut;
private static PatientMapper sut;

@Autowired
PatientMapperTest(FhirProperties fhirProps) {
@BeforeAll
static void beforeEach(@Autowired FhirProperties fhirProps) {
TimeZone.setDefault(TimeZone.getTimeZone("Europe/Berlin"));
sut = new PatientMapper(fhirProps);
}

@Test
void map_withGivenObds_shouldCreateValidPatientResource() throws IOException {
// TODO: refactor to use a data provider for parameterized tests
final var resource = this.getClass().getClassLoader().getResource("obds3/test1.xml");
@ParameterizedTest
@CsvSource({"obds3/test1.xml"})
void map_withGivenObds_shouldCreateValidPatientResource(String sourceFile) throws IOException {
final var resource = this.getClass().getClassLoader().getResource(sourceFile);
assertThat(resource).isNotNull();

final var xmlMapper =
Expand Down
Loading