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: multiple refacs in ConditionMapperTest #142

Merged
merged 3 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
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
Expand Up @@ -8,11 +8,14 @@
import com.fasterxml.jackson.module.jakarta.xmlbind.JakartaXmlBindAnnotationModule;
import de.basisdatensatz.obds.v3.OBDS;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.TimeZone;
import org.approvaltests.Approvals;
import org.approvaltests.core.Options;
import org.hl7.fhir.r4.model.Reference;
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 @@ -21,23 +24,25 @@
@SpringBootTest(classes = {FhirProperties.class})
@EnableConfigurationProperties
class ConditionMapperTest {
private final ConditionMapper sut;

@Autowired
ConditionMapperTest(FhirProperties fhirProps) {
private static ConditionMapper sut;

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

@Test
void map_withGivenObds_shouldCreateValidConditionResource() throws IOException {
TimeZone.setDefault(TimeZone.getTimeZone("Europe/Berlin"));
// 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_shouldCreateValidConditionResource(String sourceFile) throws IOException {
final var resource = this.getClass().getClassLoader().getResource(sourceFile);
assertThat(resource).isNotNull();

final var xmlMapper =
XmlMapper.builder()
.defaultUseWrapper(false)
.defaultDateFormat(new SimpleDateFormat("yyyy-MM-dd"))
.addModule(new JakartaXmlBindAnnotationModule())
.addModule(new Jdk8Module())
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
"subject": {
"reference": "Patient/1"
},
"recordedDate": "2024-06-10T02:00:00+02:00"
"recordedDate": "2024-06-10T00:00:00+02:00"
}
Loading