-
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.
- Loading branch information
Showing
3 changed files
with
67 additions
and
12 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
5 changes: 4 additions & 1 deletion
5
...no/nav/foreldrepenger/kontrakter/fpsak/tilkjentytelse/TilkjentYtelseEngangsstønadDto.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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
package no.nav.foreldrepenger.kontrakter.fpsak.tilkjentytelse; | ||
|
||
public record TilkjentYtelseEngangsstønadDto(Long beregnetTilkjentYtelse) {} | ||
import jakarta.validation.constraints.Max; | ||
import jakarta.validation.constraints.Min; | ||
|
||
public record TilkjentYtelseEngangsstønadDto(@Min(0) @Max(Long.MAX_VALUE) Long beregnetTilkjentYtelse) {} |
51 changes: 51 additions & 0 deletions
51
...no/nav/foreldrepenger/kontrakter/fpsak/tilkjentytelse/TilkjentYtelseDagytelseDtoTest.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,51 @@ | ||
package no.nav.foreldrepenger.kontrakter.fpsak.tilkjentytelse; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.ObjectReader; | ||
import com.fasterxml.jackson.databind.ObjectWriter; | ||
import no.nav.foreldrepenger.kontrakter.formidling.v1.TestJsonMapper; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.math.BigDecimal; | ||
import java.time.LocalDate; | ||
import java.util.Collections; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
class TilkjentYtelseDagytelseDtoTest { | ||
|
||
private static final ObjectWriter WRITER = TestJsonMapper.getMapper().writerWithDefaultPrettyPrinter(); | ||
private static final ObjectReader READER = TestJsonMapper.getMapper().reader(); | ||
|
||
@Test | ||
void testRoundtrip() throws JsonProcessingException { | ||
var andelRequest = new TilkjentYtelseDagytelseDto.TilkjentYtelseAndelDto("999999999", | ||
200000, 100000, TilkjentYtelseDagytelseDto.Aktivitetstatus.ARBEIDSTAKER, | ||
"arb001", BigDecimal.valueOf(100)); | ||
var periodeRequest = new TilkjentYtelseDagytelseDto.TilkjentYtelsePeriodeDto(LocalDate.now(), LocalDate.now().plusDays(10), 0, | ||
Collections.singletonList( | ||
andelRequest)); | ||
var grunnlagRequest = new TilkjentYtelseDagytelseDto(Collections.singletonList(periodeRequest)); | ||
|
||
// Act | ||
var json = WRITER.writeValueAsString(grunnlagRequest); | ||
|
||
var grunnlagResponse = (TilkjentYtelseDagytelseDto) READER.forType(TilkjentYtelseDagytelseDto.class).readValue(json); | ||
|
||
// Assert | ||
assertThat(grunnlagResponse).isNotNull(); | ||
assertThat(grunnlagResponse.perioder()).hasSize(1); | ||
var periodeResponse = grunnlagResponse.perioder().get(0); | ||
assertThat(periodeResponse.fom()).isEqualTo(periodeRequest.fom()); | ||
assertThat(periodeResponse.tom()).isEqualTo(periodeRequest.tom()); | ||
assertThat(periodeResponse.dagsats()).isEqualTo(periodeRequest.dagsats()); | ||
assertThat(periodeResponse.andeler()).hasSize(1); | ||
var andelResponse = periodeResponse.andeler().get(0); | ||
assertThat(andelResponse.aktivitetstatus()).isEqualTo(andelRequest.aktivitetstatus()); | ||
assertThat(andelResponse.arbeidsforholdId()).isEqualTo(andelRequest.arbeidsforholdId()); | ||
assertThat(andelResponse.arbeidsgiverReferanse()).isEqualTo(andelRequest.arbeidsgiverReferanse()); | ||
assertThat(andelResponse.refusjon()).isEqualTo(andelRequest.refusjon()); | ||
assertThat(andelResponse.tilSoker()).isEqualTo(andelRequest.tilSoker()); | ||
assertThat(andelResponse.stillingsprosent()).isEqualByComparingTo(andelRequest.stillingsprosent()); | ||
} | ||
} |