-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
uuid for institusjon i søknaden (#320)
* uuid for institusjon i søknaden * Legger kursholder med uuid i eget objekt * rename felt
- Loading branch information
Showing
5 changed files
with
119 additions
and
8 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
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
42 changes: 42 additions & 0 deletions
42
soknad/src/main/java/no/nav/k9/søknad/ytelse/olp/v1/kurs/Kursholder.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,42 @@ | ||
package no.nav.k9.søknad.ytelse.olp.v1.kurs; | ||
|
||
import java.util.UUID; | ||
|
||
import javax.validation.Valid; | ||
import javax.validation.constraints.Pattern; | ||
import javax.validation.constraints.Size; | ||
|
||
import com.fasterxml.jackson.annotation.JsonAutoDetect; | ||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE, getterVisibility = JsonAutoDetect.Visibility.NONE, setterVisibility = JsonAutoDetect.Visibility.NONE, isGetterVisibility = JsonAutoDetect.Visibility.NONE, creatorVisibility = JsonAutoDetect.Visibility.NONE) | ||
public class Kursholder { | ||
|
||
@JsonProperty(value = "holder", required = true) | ||
@Valid | ||
@Size(max = 100) | ||
@Pattern(regexp = "^[\\p{Pd}\\p{Graph}\\p{Space}\\p{Sc}\\p{L}\\p{M}\\p{N}§]*$", message = "[${validatedValue}] matcher ikke tillatt pattern [{regexp}]") | ||
private String holder; | ||
|
||
@JsonProperty(value = "institusjonsidentifikator", required = true) | ||
@Valid | ||
private UUID institusjonUuid; | ||
|
||
public Kursholder() { | ||
} | ||
|
||
public Kursholder(String holder, UUID institusjonUuid) { | ||
this.holder = holder; | ||
this.institusjonUuid = institusjonUuid; | ||
} | ||
|
||
public String getHolder() { | ||
return holder; | ||
} | ||
|
||
public UUID getInstitusjonUuid() { | ||
return institusjonUuid; | ||
} | ||
} |
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
53 changes: 53 additions & 0 deletions
53
soknad/src/test/java/no/nav/k9/søknad/ytelse/olp/v1/OpplæringspengerYtelseValidatorTest.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,53 @@ | ||
package no.nav.k9.søknad.ytelse.olp.v1; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.time.LocalDate; | ||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import no.nav.k9.søknad.TestUtils; | ||
import no.nav.k9.søknad.felles.Feil; | ||
import no.nav.k9.søknad.felles.type.Periode; | ||
import no.nav.k9.søknad.ytelse.olp.v1.kurs.Kurs; | ||
import no.nav.k9.søknad.ytelse.olp.v1.kurs.KursPeriodeMedReisetid; | ||
import no.nav.k9.søknad.ytelse.olp.v1.kurs.Kursholder; | ||
import no.nav.k9.søknad.ytelse.psb.YtelseEksempel; | ||
|
||
class OpplæringspengerYtelseValidatorTest { | ||
|
||
private final OpplæringspengerYtelseValidator ytelseValidator = new OpplæringspengerYtelseValidator(); | ||
|
||
private Opplæringspenger lagYtelse(String holder, UUID institusjonUuid) { | ||
Periode søknadsperiode = new Periode(LocalDate.now(), LocalDate.now().plusWeeks(1)); | ||
KursPeriodeMedReisetid kursPeriode = new KursPeriodeMedReisetid(søknadsperiode, søknadsperiode.getFraOgMed(), søknadsperiode.getTilOgMed()); | ||
Kurs kurs = new Kurs(new Kursholder(holder, institusjonUuid), "?", List.of(kursPeriode)); | ||
return new Opplæringspenger().medBarn(YtelseEksempel.lagBarn()).medSøknadsperiode(List.of(søknadsperiode)).medUttak(YtelseEksempel.lagUttak(søknadsperiode)).medKurs(kurs); | ||
} | ||
|
||
@Test | ||
void skalValidereOk() { | ||
Opplæringspenger olpYtelse = lagYtelse(null, UUID.randomUUID()); | ||
|
||
List<Feil> feil = ytelseValidator.valider(olpYtelse); | ||
assertThat(feil).isEmpty(); | ||
} | ||
|
||
@Test | ||
void skalGiFeilHvisBådeHolderOgUuidErNull() { | ||
Opplæringspenger olpYtelse = lagYtelse(null, null); | ||
|
||
List<Feil> feil = ytelseValidator.valider(olpYtelse); | ||
TestUtils.feilInneholder(feil, "ytelse.kurs.kursholder", "ugyldigHolderEllerInstitusjonUuid", "Enten holder eller institusjonUuid må være satt."); | ||
} | ||
|
||
@Test | ||
void skalGiFeilHvisBådeHolderOgUuidErSatt() { | ||
Opplæringspenger olpYtelse = lagYtelse("Franz Holder", UUID.randomUUID()); | ||
|
||
List<Feil> feil = ytelseValidator.valider(olpYtelse); | ||
TestUtils.feilInneholder(feil, "ytelse.kurs.kursholder", "ugyldigHolderEllerInstitusjonUuid", "Kan ikke ha både holder og institusjonUuid satt samtidig."); | ||
} | ||
} |