-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: return timespan of all partial radiations (#80)
* fix: return timespan of all partial radiations fixes #79 * feat: return early on null or empty list * chore: replace lombok val with final var --------- Co-authored-by: Marcel Erpenbeck <[email protected]>
- Loading branch information
1 parent
7a0c3ab
commit c73a4fd
Showing
2 changed files
with
75 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/test/java/org/miracum/streams/ume/obdstofhir/mapper/ObdsProcedureMapperTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package org.miracum.streams.ume.obdstofhir.mapper; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.time.Instant; | ||
import java.util.Date; | ||
import java.util.List; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.miracum.streams.ume.obdstofhir.FhirProperties; | ||
import org.miracum.streams.ume.obdstofhir.model.ADT_GEKID.Menge_Patient.Patient.Menge_Meldung.Meldung.Menge_ST.ST.Menge_Bestrahlung.Bestrahlung; | ||
import org.miracum.streams.ume.obdstofhir.model.Tupel; | ||
|
||
public class ObdsProcedureMapperTest { | ||
|
||
private ObdsProcedureMapper mapper; | ||
|
||
@BeforeEach | ||
void setup() { | ||
this.mapper = new ObdsProcedureMapper(new FhirProperties()); | ||
} | ||
|
||
@Test | ||
void shouldGetWholeTimeSpanFromPartialRadiations() { | ||
final var partialRadiations = | ||
List.of( | ||
getTestPartialRadiationForTimespand("01.01.2024", "31.01.2024"), | ||
getTestPartialRadiationForTimespand("01.03.2024", "30.04.2024"), | ||
getTestPartialRadiationForTimespand("10.05.2024", "31.05.2024")); | ||
|
||
final var actual = this.mapper.getTimeSpanFromPartialRadiations(partialRadiations); | ||
|
||
assertThat(actual) | ||
.isEqualTo( | ||
Tupel.builder() | ||
.first(Date.from(Instant.parse("2024-01-01T00:00:00Z"))) | ||
.second(Date.from(Instant.parse("2024-05-31T00:00:00Z"))) | ||
.build()); | ||
} | ||
|
||
private static Bestrahlung getTestPartialRadiationForTimespand(String start, String end) { | ||
Bestrahlung bestrahlung = new Bestrahlung(); | ||
bestrahlung.setST_Beginn_Datum(start); | ||
bestrahlung.setST_Ende_Datum(end); | ||
return bestrahlung; | ||
} | ||
} |