Skip to content

Commit

Permalink
TFP-5815 svp ferieperioder i soknad (#568)
Browse files Browse the repository at this point in the history
  • Loading branch information
dijjal authored Aug 30, 2024
1 parent f6bef03 commit 8a2be7d
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,26 @@
<xsd:element name="medlemskap" type="felles:Medlemskap"/>
<xsd:element name="opptjening" type="fp:Opptjening" minOccurs="0"/>
<xsd:element name="tilretteleggingListe" type="sv:TilretteleggingListe"/>
<xsd:element name="avtaltFerieListe" type="sv:AvtaltFerieListe" minOccurs="0"/>
</xsd:sequence>
<xsd:anyAttribute processContents="lax"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="AvtaltFerieListe">
<xsd:sequence>
<xsd:element name="avtaltFerie" type="sv:AvtaltFerie" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:anyAttribute processContents="lax"/>
</xsd:complexType>
<xsd:complexType name="AvtaltFerie">
<xsd:sequence>
<xsd:element name="arbeidsgiver" type="sv:Arbeidsgiver"/>
<xsd:element name="avtaltFerieFom" type="xsd:date"/>
<xsd:element name="avtaltFerieTom" type="xsd:date"/>
</xsd:sequence>
<xsd:anyAttribute processContents="lax"/>
</xsd:complexType>
<xsd:complexType name="TilretteleggingListe">
<xsd:sequence>
<xsd:element name="tilrettelegging" type="sv:Tilrettelegging" maxOccurs="unbounded"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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",
Expand Down Expand Up @@ -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);
}
}
}
38 changes: 38 additions & 0 deletions vl-kontrakt-soeknad/soeknad-v3/src/test/resources/svp-soeknad.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns7:soeknad xmlns="urn:no:nav:vedtak:felles:xml:soeknad:svangerskapspenger:v1" xmlns:ns6="urn:no:nav:vedtak:felles:xml:soeknad:engangsstoenad:v3" xmlns:ns5="urn:no:nav:vedtak:felles:xml:soeknad:uttak:v3" xmlns:ns7="urn:no:nav:vedtak:felles:xml:soeknad:v3" xmlns:ns2="urn:no:nav:vedtak:felles:xml:soeknad:felles:v3" xmlns:ns4="urn:no:nav:vedtak:felles:xml:soeknad:endringssoeknad:v3" xmlns:ns3="urn:no:nav:vedtak:felles:xml:soeknad:foreldrepenger:v3">
<ns7:mottattDato>2024-08-30</ns7:mottattDato>
<ns7:paakrevdeVedlegg>
<ns2:id>Vbfc43b14-1303-4e40-ad7d-a8f8510f8aaa</ns2:id>
<ns2:innsendingstype kodeverk="INNSENDINGSVALG" kode="LASTET_OPP"/>
<ns2:skjemanummer>I000109</ns2:skjemanummer>
<ns2:tilleggsinformasjon>Skjema for tilrettelegging og omplassering ved graviditet</ns2:tilleggsinformasjon>
</ns7:paakrevdeVedlegg>
<ns7:sprakvalg kode="NB"/>
<ns7:omYtelse>
<svangerskapspenger>
<termindato>2024-12-01</termindato>
<medlemskap>
<ns2:iNorgeVedFoedselstidspunkt>true</ns2:iNorgeVedFoedselstidspunkt>
<ns2:boddINorgeSiste12Mnd>false</ns2:boddINorgeSiste12Mnd>
<ns2:borINorgeNeste12Mnd>false</ns2:borINorgeNeste12Mnd>
</medlemskap>
<opptjening/>
<tilretteleggingListe>
<tilrettelegging>
<ingenTilrettelegging>
<slutteArbeidFom>2024-09-01</slutteArbeidFom>
</ingenTilrettelegging>
<arbeidsforhold xsi:type="Virksomhet" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<identifikator>980000001</identifikator>
</arbeidsforhold>
<behovForTilretteleggingFom>2024-07-31</behovForTilretteleggingFom>
<vedlegg>Vbfc43b14-1303-4e40-ad7d-a8f8510f8aaa</vedlegg>
</tilrettelegging>
</tilretteleggingListe>
</svangerskapspenger>
</ns7:omYtelse>
<ns7:soeker>
<ns2:aktoerId>1000000000000</ns2:aktoerId>
<ns2:soeknadsrolle kodeverk="FORELDRE_TYPE" kode="MOR"/>
</ns7:soeker>
</ns7:soeknad>

0 comments on commit 8a2be7d

Please sign in to comment.