diff --git a/szpitale-graph/src/test/java/com/developx/szpitale/load/CanonicalRoundTripTest.java b/szpitale-graph/src/test/java/com/developx/szpitale/load/CanonicalRoundTripTest.java new file mode 100644 index 0000000..b76e829 --- /dev/null +++ b/szpitale-graph/src/test/java/com/developx/szpitale/load/CanonicalRoundTripTest.java @@ -0,0 +1,105 @@ +package com.developx.szpitale.load; + +import com.developx.szpitale.model.*; +import com.developx.szpitale.model.enums.*; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.List; + +import static org.junit.jupiter.api.Assertions.*; + +class CanonicalRoundTripTest { + + @TempDir + Path tempDir; + + @Test + void write_thenRead_yieldsEqualDataset() throws Exception { + Hospital hospital = new Hospital( + "hosp:podlaskie:usk-bialystok", + "Uniwersytecki Szpital Kliniczny w Białymstoku", + "USK", + "Białystok", + "podlaskie", + LegalForm.SPZOZ, + "Uniwersytet Medyczny", + SupervisoryBodyType.RADA_SPOLECZNA, + null, null, + "https://uskwb.pl", + List.of("https://uskwb.pl/dyrekcja") + ); + + Person person = new Person( + "person:jan-kowalski", + "Jan Kowalski", + "Dyrektor Naczelny", + List.of("prof."), + List.of("https://uskwb.pl/dyrekcja") + ); + + Affiliation affiliation = new Affiliation( + "person:jan-kowalski", + AffiliationType.PARTIA, + "Koalicja Obywatelska", + ConfidenceLevel.POTWIERDZONA, + "PO", + List.of("https://uskwb.pl/dyrekcja") + ); + + Role role = new Role( + "hosp:podlaskie:usk-bialystok", + "person:jan-kowalski", + RoleType.DYREKTOR, + "Dyrektor Naczelny", + OrganType.DYREKCJA, + RoleStatus.AKTUALNY, + null, null, + null, + List.of("https://uskwb.pl/dyrekcja") + ); + + CanonicalDataset original = new CanonicalDataset( + "1.0", "podlaskie", + java.time.LocalDateTime.now(), + List.of(hospital), + List.of(person), + List.of(affiliation), + List.of(role), + List.of() + ); + + Path canonicalDir = tempDir.resolve("canonical"); + Files.createDirectories(canonicalDir); + + ObjectMapper mapper = new ObjectMapper(); + mapper.registerModule(new JavaTimeModule()); + mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); + mapper.writerWithDefaultPrettyPrinter().writeValue( + canonicalDir.resolve("podlaskie.json").toFile(), original + ); + + CanonicalReader reader = new CanonicalReader(); + CanonicalDataset readBack = reader.readSingle(tempDir, "podlaskie"); + + assertNotNull(readBack); + assertEquals(original.schemaVersion(), readBack.schemaVersion()); + assertEquals(original.voivodeship(), readBack.voivodeship()); + assertEquals(1, readBack.hospitals().size()); + assertEquals(hospital.id(), readBack.hospitals().get(0).id()); + assertEquals(hospital.name(), readBack.hospitals().get(0).name()); + assertEquals(1, readBack.people().size()); + assertEquals(person.id(), readBack.people().get(0).id()); + assertEquals(person.fullName(), readBack.people().get(0).fullName()); + assertEquals(1, readBack.affiliations().size()); + assertEquals(affiliation.name(), readBack.affiliations().get(0).name()); + assertEquals(1, readBack.roles().size()); + assertEquals(role.hospitalId(), readBack.roles().get(0).hospitalId()); + assertEquals(role.roleType(), readBack.roles().get(0).roleType()); + } +} diff --git a/szpitale-graph/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst b/szpitale-graph/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst index 54c8cb1..e0e709d 100644 --- a/szpitale-graph/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst +++ b/szpitale-graph/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst @@ -2,3 +2,4 @@ com/developx/szpitale/ingest/normalize/NameNormalizerTest.class com/developx/szpitale/ingest/normalize/PartyNormalizerTest.class com/developx/szpitale/ingest/source/MarkdownRegistrySourceTest.class com/developx/szpitale/ingest/normalize/DeduplicatorTest.class +com/developx/szpitale/load/CanonicalRoundTripTest.class diff --git a/szpitale-graph/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/szpitale-graph/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst index 717bd93..7593483 100644 --- a/szpitale-graph/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst +++ b/szpitale-graph/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst @@ -2,3 +2,4 @@ /home/kruszewskia/Workspace/Private/Szpitale-graph/szpitale-graph/src/test/java/com/developx/szpitale/ingest/normalize/NameNormalizerTest.java /home/kruszewskia/Workspace/Private/Szpitale-graph/szpitale-graph/src/test/java/com/developx/szpitale/ingest/normalize/PartyNormalizerTest.java /home/kruszewskia/Workspace/Private/Szpitale-graph/szpitale-graph/src/test/java/com/developx/szpitale/ingest/source/MarkdownRegistrySourceTest.java +/home/kruszewskia/Workspace/Private/Szpitale-graph/szpitale-graph/src/test/java/com/developx/szpitale/load/CanonicalRoundTripTest.java diff --git a/szpitale-graph/target/surefire-reports/TEST-com.developx.szpitale.ingest.normalize.DeduplicatorTest.xml b/szpitale-graph/target/surefire-reports/TEST-com.developx.szpitale.ingest.normalize.DeduplicatorTest.xml index 68c38f3..58ba379 100644 --- a/szpitale-graph/target/surefire-reports/TEST-com.developx.szpitale.ingest.normalize.DeduplicatorTest.xml +++ b/szpitale-graph/target/surefire-reports/TEST-com.developx.szpitale.ingest.normalize.DeduplicatorTest.xml @@ -1,5 +1,5 @@ - + @@ -13,7 +13,7 @@ - + @@ -28,7 +28,7 @@ - + @@ -55,6 +55,6 @@ - - + + \ No newline at end of file diff --git a/szpitale-graph/target/surefire-reports/TEST-com.developx.szpitale.ingest.normalize.NameNormalizerTest.xml b/szpitale-graph/target/surefire-reports/TEST-com.developx.szpitale.ingest.normalize.NameNormalizerTest.xml index c3ab81e..add8f74 100644 --- a/szpitale-graph/target/surefire-reports/TEST-com.developx.szpitale.ingest.normalize.NameNormalizerTest.xml +++ b/szpitale-graph/target/surefire-reports/TEST-com.developx.szpitale.ingest.normalize.NameNormalizerTest.xml @@ -1,5 +1,5 @@ - + @@ -13,7 +13,7 @@ - + @@ -28,7 +28,7 @@ - + @@ -55,26 +55,26 @@ - - + + - - + + - - - - - - - - + + + + + + + + - - + + diff --git a/szpitale-graph/target/surefire-reports/TEST-com.developx.szpitale.ingest.normalize.PartyNormalizerTest.xml b/szpitale-graph/target/surefire-reports/TEST-com.developx.szpitale.ingest.normalize.PartyNormalizerTest.xml index e593521..ecfbacc 100644 --- a/szpitale-graph/target/surefire-reports/TEST-com.developx.szpitale.ingest.normalize.PartyNormalizerTest.xml +++ b/szpitale-graph/target/surefire-reports/TEST-com.developx.szpitale.ingest.normalize.PartyNormalizerTest.xml @@ -1,5 +1,5 @@ - + @@ -13,7 +13,7 @@ - + @@ -28,7 +28,7 @@ - + @@ -55,19 +55,19 @@ - - - + + + - + - + - - - - - - + + + + + + \ No newline at end of file diff --git a/szpitale-graph/target/surefire-reports/TEST-com.developx.szpitale.ingest.source.MarkdownRegistrySourceTest.xml b/szpitale-graph/target/surefire-reports/TEST-com.developx.szpitale.ingest.source.MarkdownRegistrySourceTest.xml index 8c531f5..87488f6 100644 --- a/szpitale-graph/target/surefire-reports/TEST-com.developx.szpitale.ingest.source.MarkdownRegistrySourceTest.xml +++ b/szpitale-graph/target/surefire-reports/TEST-com.developx.szpitale.ingest.source.MarkdownRegistrySourceTest.xml @@ -1,5 +1,5 @@ - + @@ -13,7 +13,7 @@ - + @@ -28,7 +28,7 @@ - + @@ -55,10 +55,10 @@ - - + - - + + \ No newline at end of file diff --git a/szpitale-graph/target/surefire-reports/TEST-com.developx.szpitale.load.CanonicalRoundTripTest.xml b/szpitale-graph/target/surefire-reports/TEST-com.developx.szpitale.load.CanonicalRoundTripTest.xml new file mode 100644 index 0000000..9cdc832 --- /dev/null +++ b/szpitale-graph/target/surefire-reports/TEST-com.developx.szpitale.load.CanonicalRoundTripTest.xml @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/szpitale-graph/target/surefire-reports/com.developx.szpitale.ingest.normalize.DeduplicatorTest.txt b/szpitale-graph/target/surefire-reports/com.developx.szpitale.ingest.normalize.DeduplicatorTest.txt index 0595544..d2cb67d 100644 --- a/szpitale-graph/target/surefire-reports/com.developx.szpitale.ingest.normalize.DeduplicatorTest.txt +++ b/szpitale-graph/target/surefire-reports/com.developx.szpitale.ingest.normalize.DeduplicatorTest.txt @@ -1,4 +1,4 @@ ------------------------------------------------------------------------------- Test set: com.developx.szpitale.ingest.normalize.DeduplicatorTest ------------------------------------------------------------------------------- -Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.006 s -- in com.developx.szpitale.ingest.normalize.DeduplicatorTest +Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.009 s -- in com.developx.szpitale.ingest.normalize.DeduplicatorTest diff --git a/szpitale-graph/target/surefire-reports/com.developx.szpitale.ingest.normalize.NameNormalizerTest.txt b/szpitale-graph/target/surefire-reports/com.developx.szpitale.ingest.normalize.NameNormalizerTest.txt index f548f62..966e162 100644 --- a/szpitale-graph/target/surefire-reports/com.developx.szpitale.ingest.normalize.NameNormalizerTest.txt +++ b/szpitale-graph/target/surefire-reports/com.developx.szpitale.ingest.normalize.NameNormalizerTest.txt @@ -1,4 +1,4 @@ ------------------------------------------------------------------------------- Test set: com.developx.szpitale.ingest.normalize.NameNormalizerTest ------------------------------------------------------------------------------- -Tests run: 25, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.081 s -- in com.developx.szpitale.ingest.normalize.NameNormalizerTest +Tests run: 25, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.149 s -- in com.developx.szpitale.ingest.normalize.NameNormalizerTest diff --git a/szpitale-graph/target/surefire-reports/com.developx.szpitale.ingest.normalize.PartyNormalizerTest.txt b/szpitale-graph/target/surefire-reports/com.developx.szpitale.ingest.normalize.PartyNormalizerTest.txt index 9b59a88..0848c43 100644 --- a/szpitale-graph/target/surefire-reports/com.developx.szpitale.ingest.normalize.PartyNormalizerTest.txt +++ b/szpitale-graph/target/surefire-reports/com.developx.szpitale.ingest.normalize.PartyNormalizerTest.txt @@ -1,4 +1,4 @@ ------------------------------------------------------------------------------- Test set: com.developx.szpitale.ingest.normalize.PartyNormalizerTest ------------------------------------------------------------------------------- -Tests run: 15, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.010 s -- in com.developx.szpitale.ingest.normalize.PartyNormalizerTest +Tests run: 15, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.038 s -- in com.developx.szpitale.ingest.normalize.PartyNormalizerTest diff --git a/szpitale-graph/target/surefire-reports/com.developx.szpitale.ingest.source.MarkdownRegistrySourceTest.txt b/szpitale-graph/target/surefire-reports/com.developx.szpitale.ingest.source.MarkdownRegistrySourceTest.txt index 093069d..fec8341 100644 --- a/szpitale-graph/target/surefire-reports/com.developx.szpitale.ingest.source.MarkdownRegistrySourceTest.txt +++ b/szpitale-graph/target/surefire-reports/com.developx.szpitale.ingest.source.MarkdownRegistrySourceTest.txt @@ -1,4 +1,4 @@ ------------------------------------------------------------------------------- Test set: com.developx.szpitale.ingest.source.MarkdownRegistrySourceTest ------------------------------------------------------------------------------- -Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.096 s -- in com.developx.szpitale.ingest.source.MarkdownRegistrySourceTest +Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.198 s -- in com.developx.szpitale.ingest.source.MarkdownRegistrySourceTest diff --git a/szpitale-graph/target/surefire-reports/com.developx.szpitale.load.CanonicalRoundTripTest.txt b/szpitale-graph/target/surefire-reports/com.developx.szpitale.load.CanonicalRoundTripTest.txt new file mode 100644 index 0000000..a9c3833 --- /dev/null +++ b/szpitale-graph/target/surefire-reports/com.developx.szpitale.load.CanonicalRoundTripTest.txt @@ -0,0 +1,4 @@ +------------------------------------------------------------------------------- +Test set: com.developx.szpitale.load.CanonicalRoundTripTest +------------------------------------------------------------------------------- +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.324 s -- in com.developx.szpitale.load.CanonicalRoundTripTest diff --git a/szpitale-graph/target/test-classes/com/developx/szpitale/load/CanonicalRoundTripTest.class b/szpitale-graph/target/test-classes/com/developx/szpitale/load/CanonicalRoundTripTest.class new file mode 100644 index 0000000..e1aa355 Binary files /dev/null and b/szpitale-graph/target/test-classes/com/developx/szpitale/load/CanonicalRoundTripTest.class differ