From 8a2be7d62c7fad81baa8aa8d9c221dfdd6667ffc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20P=C3=B8hner?= Date: Fri, 30 Aug 2024 15:36:43 +0200 Subject: [PATCH] TFP-5815 svp ferieperioder i soknad (#568) --- .../svangerskapspenger-v1.xsd | 15 +++++++ .../s\303\270knad/v3/ParseSoeknadTest.java" | 45 +++++++++++++------ .../src/test/resources/svp-soeknad.xml | 38 ++++++++++++++++ 3 files changed, 84 insertions(+), 14 deletions(-) create mode 100644 vl-kontrakt-soeknad/soeknad-v3/src/test/resources/svp-soeknad.xml diff --git a/vl-kontrakt-soeknad/soeknad-v3/src/main/resources/xsd/svangerskapspenger/svangerskapspenger-v1.xsd b/vl-kontrakt-soeknad/soeknad-v3/src/main/resources/xsd/svangerskapspenger/svangerskapspenger-v1.xsd index 2a1e0b59..1139c328 100644 --- a/vl-kontrakt-soeknad/soeknad-v3/src/main/resources/xsd/svangerskapspenger/svangerskapspenger-v1.xsd +++ b/vl-kontrakt-soeknad/soeknad-v3/src/main/resources/xsd/svangerskapspenger/svangerskapspenger-v1.xsd @@ -21,11 +21,26 @@ + + + + + + + + + + + + + + + diff --git "a/vl-kontrakt-soeknad/soeknad-v3/src/test/java/no/nav/foreldrepenger/s\303\270knad/v3/ParseSoeknadTest.java" "b/vl-kontrakt-soeknad/soeknad-v3/src/test/java/no/nav/foreldrepenger/s\303\270knad/v3/ParseSoeknadTest.java" index 858a6f48..0058a25a 100644 --- "a/vl-kontrakt-soeknad/soeknad-v3/src/test/java/no/nav/foreldrepenger/s\303\270knad/v3/ParseSoeknadTest.java" +++ "b/vl-kontrakt-soeknad/soeknad-v3/src/test/java/no/nav/foreldrepenger/s\303\270knad/v3/ParseSoeknadTest.java" @@ -2,15 +2,13 @@ import static org.assertj.core.api.Assertions.assertThat; -import java.io.BufferedReader; +import java.io.IOException; import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.Reader; -import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.time.LocalDate; import jakarta.xml.bind.JAXBElement; +import no.nav.vedtak.felles.xml.soeknad.svangerskapspenger.v1.Svangerskapspenger; import org.junit.jupiter.api.Test; import no.nav.foreldrepenger.søknad.util.JaxbHelper; @@ -37,17 +35,9 @@ public class ParseSoeknadTest { @Test public void skal_parse_soeknad_xml() throws Exception { - final InputStream resourceAsStream = getClass().getResourceAsStream("/soeknad-v3.xml"); - StringBuilder textBuilder = new StringBuilder(); - try (Reader reader = new BufferedReader(new InputStreamReader - (resourceAsStream, Charset.forName(StandardCharsets.UTF_8.name())))) { - int c = 0; - while ((c = reader.read()) != -1) { - textBuilder.append((char) c); - } - } + var xml = lesResource("/soeknad-v3.xml"); Soeknad søknad = JaxbHelper.unmarshalAndValidateXMLWithStAX(Soeknad.class, - textBuilder.toString(), + xml, "xsd/soeknad-v3.xsd", new String[]{ "xsd/engangsstoenad/engangsstoenad-v3.xsd", "xsd/foreldrepenger/foreldrepenger-v3.xsd", @@ -154,4 +144,31 @@ public void skal_marshalle_til_xml() throws Exception { assertThat(søknad).isEqualToComparingFieldByFieldRecursively(søknad2); } + + @Test + void svp_utvidet_med_ferieliste_skal_være_bakoverkompatibel() throws Exception { + var xml = lesResource("/svp-soeknad.xml"); + var søknad = JaxbHelper.unmarshalAndValidateXMLWithStAX(Soeknad.class, + xml, "xsd/soeknad-v3.xsd", SøknadConstants.ADDITIONAL_XSD_LOCATION, SøknadConstants.ADDITIONAL_CLASSES); + + assertThat(søknad).isNotNull(); + var svangerskapspenger = søknad.getOmYtelse().getAny().stream() + .filter(o -> o instanceof JAXBElement) + .findFirst() + .map(e -> (Svangerskapspenger) ((JAXBElement) e).getValue()); + + assertThat(svangerskapspenger) + .isNotEmpty() + .get() + .matches(svp -> svp.getAvtaltFerieListe() == null) + .matches(svp -> LocalDate.of(2024,12,1).equals(svp.getTermindato())); + } + + private String lesResource(String resourceFile) throws IOException { + final InputStream resourceAsStream = getClass().getResourceAsStream(resourceFile); + try (resourceAsStream) { + assert resourceAsStream != null; + return new String(resourceAsStream.readAllBytes(), StandardCharsets.UTF_8); + } + } } diff --git a/vl-kontrakt-soeknad/soeknad-v3/src/test/resources/svp-soeknad.xml b/vl-kontrakt-soeknad/soeknad-v3/src/test/resources/svp-soeknad.xml new file mode 100644 index 00000000..f1355577 --- /dev/null +++ b/vl-kontrakt-soeknad/soeknad-v3/src/test/resources/svp-soeknad.xml @@ -0,0 +1,38 @@ + + + 2024-08-30 + + Vbfc43b14-1303-4e40-ad7d-a8f8510f8aaa + + I000109 + Skjema for tilrettelegging og omplassering ved graviditet + + + + + 2024-12-01 + + true + false + false + + + + + + 2024-09-01 + + + 980000001 + + 2024-07-31 + Vbfc43b14-1303-4e40-ad7d-a8f8510f8aaa + + + + + + 1000000000000 + + + \ No newline at end of file