How to use BigDecimal.shouldBeZero method of io.kotest.matchers.bigdecimal.matchers class

Best Kotest code snippet using io.kotest.matchers.bigdecimal.matchers.BigDecimal.shouldBeZero

TilbakekrevingsberegningServiceTest.kt

Source:TilbakekrevingsberegningServiceTest.kt Github

copy

Full Screen

1package no.nav.familie.tilbake.beregning2import io.kotest.assertions.throwables.shouldThrow3import io.kotest.matchers.bigdecimal.shouldBeZero4import io.kotest.matchers.collections.shouldHaveSize5import io.kotest.matchers.nulls.shouldNotBeNull6import io.kotest.matchers.shouldBe7import no.nav.familie.tilbake.OppslagSpringRunnerTest8import no.nav.familie.tilbake.api.dto.PeriodeDto9import no.nav.familie.tilbake.behandling.BehandlingRepository10import no.nav.familie.tilbake.behandling.FagsakRepository11import no.nav.familie.tilbake.beregning.modell.Beregningsresultat12import no.nav.familie.tilbake.beregning.modell.Beregningsresultatsperiode13import no.nav.familie.tilbake.beregning.modell.Vedtaksresultat14import no.nav.familie.tilbake.common.Periode15import no.nav.familie.tilbake.data.Testdata16import no.nav.familie.tilbake.foreldelse.VurdertForeldelseRepository17import no.nav.familie.tilbake.foreldelse.domain.Foreldelsesperiode18import no.nav.familie.tilbake.foreldelse.domain.Foreldelsesvurderingstype19import no.nav.familie.tilbake.foreldelse.domain.VurdertForeldelse20import no.nav.familie.tilbake.kravgrunnlag.KravgrunnlagRepository21import no.nav.familie.tilbake.kravgrunnlag.domain.Klassekode22import no.nav.familie.tilbake.kravgrunnlag.domain.Klassetype23import no.nav.familie.tilbake.kravgrunnlag.domain.Kravgrunnlag43124import no.nav.familie.tilbake.kravgrunnlag.domain.Kravgrunnlagsbeløp43325import no.nav.familie.tilbake.kravgrunnlag.domain.Kravgrunnlagsperiode43226import no.nav.familie.tilbake.vilkårsvurdering.VilkårsvurderingRepository27import no.nav.familie.tilbake.vilkårsvurdering.domain.Aktsomhet28import no.nav.familie.tilbake.vilkårsvurdering.domain.AnnenVurdering29import no.nav.familie.tilbake.vilkårsvurdering.domain.Vilkårsvurdering30import no.nav.familie.tilbake.vilkårsvurdering.domain.VilkårsvurderingAktsomhet31import no.nav.familie.tilbake.vilkårsvurdering.domain.Vilkårsvurderingsperiode32import no.nav.familie.tilbake.vilkårsvurdering.domain.Vilkårsvurderingsresultat33import org.junit.jupiter.api.BeforeEach34import org.junit.jupiter.api.Test35import org.springframework.beans.factory.annotation.Autowired36import java.math.BigDecimal37import java.time.LocalDate38import java.time.YearMonth39import java.util.UUID40class TilbakekrevingsberegningServiceTest : OppslagSpringRunnerTest() {41 @Autowired42 private lateinit var tilbakekrevingsberegningService: TilbakekrevingsberegningService43 @Autowired44 private lateinit var kravgrunnlagRepository: KravgrunnlagRepository45 @Autowired46 private lateinit var vurdertForeldelseRepository: VurdertForeldelseRepository47 @Autowired48 private lateinit var vilkårsvurderingRepository: VilkårsvurderingRepository49 @Autowired50 private lateinit var behandlingRepository: BehandlingRepository51 @Autowired52 private lateinit var fagsakRepository: FagsakRepository53 @BeforeEach54 fun init() {55 fagsakRepository.insert(Testdata.fagsak)56 behandlingRepository.insert(Testdata.behandling)57 }58 @Test59 fun `beregn skalberegne tilbakekrevingsbeløp for periode som ikke er foreldet`() {60 val periode = Periode(LocalDate.of(2019, 5, 1), LocalDate.of(2019, 5, 3))61 lagKravgrunnlag(periode, BigDecimal.ZERO)62 lagForeldelse(Testdata.behandling.id, periode, Foreldelsesvurderingstype.IKKE_FORELDET, null)63 lagVilkårsvurderingMedForsett(Testdata.behandling.id, periode)64 val beregningsresultat: Beregningsresultat = tilbakekrevingsberegningService.beregn(Testdata.behandling.id)65 val resultat: List<Beregningsresultatsperiode> = beregningsresultat.beregningsresultatsperioder66 resultat.shouldHaveSize(1)67 val r: Beregningsresultatsperiode = resultat[0]68 r.periode shouldBe periode69 r.tilbakekrevingsbeløp shouldBe BigDecimal.valueOf(11000)70 r.vurdering shouldBe Aktsomhet.FORSETT71 r.renteprosent shouldBe BigDecimal.valueOf(10)72 r.feilutbetaltBeløp shouldBe BigDecimal.valueOf(10000)73 r.manueltSattTilbakekrevingsbeløp shouldBe null74 r.andelAvBeløp shouldBe BigDecimal.valueOf(100)75 beregningsresultat.vedtaksresultat shouldBe Vedtaksresultat.FULL_TILBAKEBETALING76 }77 @Test78 fun `hentBeregningsresultat skal hente beregningsresultat for periode som ikke er foreldet`() {79 val periode = Periode(LocalDate.of(2019, 5, 1), LocalDate.of(2019, 5, 3))80 lagKravgrunnlag(periode, BigDecimal.ZERO)81 lagForeldelse(Testdata.behandling.id, periode, Foreldelsesvurderingstype.IKKE_FORELDET, null)82 lagVilkårsvurderingMedForsett(Testdata.behandling.id, periode)83 val beregningsresultat = tilbakekrevingsberegningService.hentBeregningsresultat(Testdata.behandling.id)84 beregningsresultat.beregningsresultatsperioder.size shouldBe 185 val beregningsresultatsperiode = beregningsresultat.beregningsresultatsperioder[0]86 beregningsresultatsperiode.periode shouldBe PeriodeDto(periode)87 beregningsresultatsperiode.tilbakekrevingsbeløp shouldBe BigDecimal.valueOf(11000)88 beregningsresultatsperiode.vurdering shouldBe Aktsomhet.FORSETT89 beregningsresultatsperiode.renteprosent shouldBe BigDecimal.valueOf(10)90 beregningsresultatsperiode.feilutbetaltBeløp shouldBe BigDecimal.valueOf(10000)91 beregningsresultatsperiode.andelAvBeløp shouldBe BigDecimal.valueOf(100)92 beregningsresultat.vedtaksresultat shouldBe Vedtaksresultat.FULL_TILBAKEBETALING93 }94 @Test95 fun `beregn skalberegne tilbakekrevingsbeløp for periode som er foreldet`() {96 val periode = Periode(LocalDate.of(2019, 5, 1), LocalDate.of(2019, 5, 3))97 lagKravgrunnlag(periode, BigDecimal.ZERO)98 lagForeldelse(Testdata.behandling.id, periode, Foreldelsesvurderingstype.FORELDET, periode.fom.plusMonths(8).atDay(1))99 val beregningsresultat: Beregningsresultat = tilbakekrevingsberegningService.beregn(Testdata.behandling.id)100 val resultat: List<Beregningsresultatsperiode> = beregningsresultat.beregningsresultatsperioder101 resultat.shouldHaveSize(1)102 val r: Beregningsresultatsperiode = resultat[0]103 r.periode shouldBe periode104 r.tilbakekrevingsbeløp.shouldBeZero()105 r.vurdering shouldBe AnnenVurdering.FORELDET106 r.renteprosent shouldBe null107 r.feilutbetaltBeløp shouldBe BigDecimal.valueOf(10000)108 r.manueltSattTilbakekrevingsbeløp shouldBe null109 r.andelAvBeløp shouldBe BigDecimal.ZERO110 r.rentebeløp.shouldBeZero()111 r.tilbakekrevingsbeløpUtenRenter.shouldBeZero()112 beregningsresultat.vedtaksresultat shouldBe Vedtaksresultat.INGEN_TILBAKEBETALING113 }114 @Test115 fun `hentBeregningsresultat skal hente beregningsresultat for periode som er foreldet`() {116 val periode = Periode(LocalDate.of(2019, 5, 1), LocalDate.of(2019, 5, 3))117 lagKravgrunnlag(periode, BigDecimal.ZERO)118 lagForeldelse(Testdata.behandling.id, periode, Foreldelsesvurderingstype.FORELDET, periode.fom.plusMonths(8).atDay(1))119 val beregningsresultat = tilbakekrevingsberegningService.hentBeregningsresultat(Testdata.behandling.id)120 beregningsresultat.beregningsresultatsperioder.size shouldBe 1121 val beregningsresultatsperiode = beregningsresultat.beregningsresultatsperioder[0]122 beregningsresultatsperiode.periode shouldBe PeriodeDto(periode)123 beregningsresultatsperiode.tilbakekrevingsbeløp.shouldNotBeNull()124 beregningsresultatsperiode.tilbakekrevingsbeløp!!.shouldBeZero()125 beregningsresultatsperiode.vurdering shouldBe AnnenVurdering.FORELDET126 beregningsresultatsperiode.renteprosent shouldBe null127 beregningsresultatsperiode.feilutbetaltBeløp shouldBe BigDecimal.valueOf(10000)128 beregningsresultatsperiode.andelAvBeløp shouldBe BigDecimal.ZERO129 beregningsresultat.vedtaksresultat shouldBe Vedtaksresultat.INGEN_TILBAKEBETALING130 }131 @Test132 fun `beregn skalberegne tilbakekrevingsbeløp for periode som ikke er foreldet med skattProsent`() {133 val periode = Periode(LocalDate.of(2019, 5, 1), LocalDate.of(2019, 5, 3))134 lagKravgrunnlag(periode, BigDecimal.valueOf(10))135 lagForeldelse(Testdata.behandling.id, periode, Foreldelsesvurderingstype.IKKE_FORELDET, null)136 lagVilkårsvurderingMedForsett(Testdata.behandling.id, periode)137 val beregningsresultat: Beregningsresultat = tilbakekrevingsberegningService.beregn(Testdata.behandling.id)138 val resultat: List<Beregningsresultatsperiode> = beregningsresultat.beregningsresultatsperioder139 resultat.shouldHaveSize(1)140 val r: Beregningsresultatsperiode = resultat[0]141 r.periode shouldBe periode142 r.tilbakekrevingsbeløp shouldBe BigDecimal.valueOf(11000)143 r.vurdering shouldBe Aktsomhet.FORSETT144 r.renteprosent shouldBe BigDecimal.valueOf(10)145 r.feilutbetaltBeløp shouldBe BigDecimal.valueOf(10000)146 r.manueltSattTilbakekrevingsbeløp shouldBe null147 r.andelAvBeløp shouldBe BigDecimal.valueOf(100)148 r.skattebeløp shouldBe BigDecimal.valueOf(1000)149 r.tilbakekrevingsbeløpEtterSkatt shouldBe BigDecimal.valueOf(10000)150 beregningsresultat.vedtaksresultat shouldBe Vedtaksresultat.FULL_TILBAKEBETALING151 }152 @Test153 fun `hentBeregningsresultat skal hente beregningsresultat for periode som ikke er foreldet med skattProsent`() {154 val periode = Periode(LocalDate.of(2019, 5, 1), LocalDate.of(2019, 5, 3))155 lagKravgrunnlag(periode, BigDecimal.valueOf(10))156 lagForeldelse(Testdata.behandling.id, periode, Foreldelsesvurderingstype.IKKE_FORELDET, null)157 lagVilkårsvurderingMedForsett(Testdata.behandling.id, periode)158 val beregningsresultat = tilbakekrevingsberegningService.hentBeregningsresultat(Testdata.behandling.id)159 beregningsresultat.beregningsresultatsperioder.size shouldBe 1160 val beregningsresultatsperiode = beregningsresultat.beregningsresultatsperioder[0]161 beregningsresultatsperiode.periode shouldBe PeriodeDto(periode)162 beregningsresultatsperiode.tilbakekrevingsbeløp shouldBe BigDecimal.valueOf(11000)163 beregningsresultatsperiode.vurdering shouldBe Aktsomhet.FORSETT164 beregningsresultatsperiode.renteprosent shouldBe BigDecimal.valueOf(10)165 beregningsresultatsperiode.feilutbetaltBeløp shouldBe BigDecimal.valueOf(10000)166 beregningsresultatsperiode.andelAvBeløp shouldBe BigDecimal.valueOf(100)167 beregningsresultatsperiode.tilbakekrevesBeløpEtterSkatt shouldBe BigDecimal.valueOf(10000)168 beregningsresultat.vedtaksresultat shouldBe Vedtaksresultat.FULL_TILBAKEBETALING169 }170 @Test171 fun `beregn skalberegne riktig beløp og utbetalt beløp for periode`() {172 val periode = Periode(LocalDate.of(2019, 5, 1), LocalDate.of(2019, 5, 3))173 lagKravgrunnlag(periode, BigDecimal.valueOf(10))174 lagForeldelse(Testdata.behandling.id, periode, Foreldelsesvurderingstype.IKKE_FORELDET, null)175 lagVilkårsvurderingMedForsett(Testdata.behandling.id, periode)176 val beregningsresultat: Beregningsresultat = tilbakekrevingsberegningService.beregn(Testdata.behandling.id)177 val resultat: List<Beregningsresultatsperiode> = beregningsresultat.beregningsresultatsperioder178 resultat.shouldHaveSize(1)179 val r: Beregningsresultatsperiode = resultat[0]180 r.utbetaltYtelsesbeløp shouldBe BigDecimal.valueOf(10000)181 r.riktigYtelsesbeløp shouldBe BigDecimal.ZERO182 }183 @Test184 fun `beregn skal beregne riktige beløp ved delvis feilutbetaling for perioder sammenslått til en logisk periode`() {185 val skatteprosent = BigDecimal.valueOf(10)186 val periode1 = Periode(LocalDate.of(2019, 5, 1), LocalDate.of(2019, 5, 3))187 val periode2 = Periode(LocalDate.of(2019, 5, 4), LocalDate.of(2019, 5, 6))188 val logiskPeriode = Periode(LocalDate.of(2019, 5, 1), LocalDate.of(2019, 5, 6))189 val utbetalt1 = BigDecimal.valueOf(10000)190 val nyttBeløp1 = BigDecimal.valueOf(5000)191 val utbetalt2 = BigDecimal.valueOf(10000)192 val nyttBeløp2 = BigDecimal.valueOf(100)193 val feilutbetalt2 = utbetalt2.subtract(nyttBeløp2)194 val feilutbetalt1 = utbetalt1.subtract(nyttBeløp1)195 val grunnlagPeriode1: Kravgrunnlagsperiode432 =196 lagGrunnlagPeriode(periode1, 1000, setOf(lagYtelBeløp(utbetalt1, nyttBeløp1, skatteprosent),197 lagFeilBeløp(feilutbetalt1)))198 val grunnlagPeriode2: Kravgrunnlagsperiode432 =199 lagGrunnlagPeriode(periode2, 1000, setOf(lagYtelBeløp(utbetalt2, nyttBeløp2, skatteprosent),200 lagFeilBeløp(feilutbetalt2)))201 val grunnlag: Kravgrunnlag431 = lagGrunnlag(setOf(grunnlagPeriode1, grunnlagPeriode2))202 kravgrunnlagRepository.insert(grunnlag)203 lagForeldelse(Testdata.behandling.id, logiskPeriode, Foreldelsesvurderingstype.IKKE_FORELDET, null)204 lagVilkårsvurderingMedForsett(Testdata.behandling.id, logiskPeriode)205 val beregningsresultat: Beregningsresultat = tilbakekrevingsberegningService.beregn(Testdata.behandling.id)206 val resultat: List<Beregningsresultatsperiode> = beregningsresultat.beregningsresultatsperioder207 resultat.shouldHaveSize(1)208 val r: Beregningsresultatsperiode = resultat[0]209 r.periode shouldBe logiskPeriode210 r.utbetaltYtelsesbeløp shouldBe utbetalt1.add(utbetalt2)211 r.riktigYtelsesbeløp shouldBe nyttBeløp1.add(nyttBeløp2)212 }213 @Test214 fun `beregn skal beregne tilbakekrevingsbeløp for ikkeForeldetPeriode når beregnetPeriode er på tvers av grunnlagPeriode`() {215 val periode = Periode(LocalDate.of(2019, 5, 1), LocalDate.of(2019, 5, 31))216 val periode1 = Periode(LocalDate.of(2019, 6, 1), LocalDate.of(2019, 6, 30))217 val logiskPeriode = Periode(LocalDate.of(2019, 5, 1),218 LocalDate.of(2019, 6, 30))219 val grunnlagPeriode: Kravgrunnlagsperiode432 =220 lagGrunnlagPeriode(periode,221 1000,222 setOf(lagYtelBeløp(BigDecimal.valueOf(10000), BigDecimal.valueOf(10)),223 lagFeilBeløp(BigDecimal.valueOf(10000))))224 val grunnlagPeriode1: Kravgrunnlagsperiode432 =225 lagGrunnlagPeriode(periode1,226 1000,227 setOf(lagYtelBeløp(BigDecimal.valueOf(10000),228 BigDecimal.valueOf(10)),229 lagFeilBeløp(BigDecimal.valueOf(10000))))230 val grunnlag: Kravgrunnlag431 = lagGrunnlag(setOf(grunnlagPeriode, grunnlagPeriode1))231 kravgrunnlagRepository.insert(grunnlag)232 lagForeldelse(Testdata.behandling.id, logiskPeriode, Foreldelsesvurderingstype.IKKE_FORELDET, null)233 lagVilkårsvurderingMedForsett(Testdata.behandling.id, logiskPeriode)234 val beregningsresultat: Beregningsresultat = tilbakekrevingsberegningService.beregn(Testdata.behandling.id)235 val resultat: List<Beregningsresultatsperiode> = beregningsresultat.beregningsresultatsperioder236 resultat.shouldHaveSize(1)237 val r: Beregningsresultatsperiode = resultat[0]238 r.periode shouldBe logiskPeriode239 r.tilbakekrevingsbeløp shouldBe BigDecimal.valueOf(22000)240 r.vurdering shouldBe Aktsomhet.FORSETT241 r.renteprosent shouldBe BigDecimal.valueOf(10)242 r.feilutbetaltBeløp shouldBe BigDecimal.valueOf(20000)243 r.manueltSattTilbakekrevingsbeløp shouldBe null244 r.andelAvBeløp shouldBe BigDecimal.valueOf(100)245 r.skattebeløp shouldBe BigDecimal.valueOf(2000)246 r.tilbakekrevingsbeløpEtterSkatt shouldBe BigDecimal.valueOf(20000)247 beregningsresultat.vedtaksresultat shouldBe Vedtaksresultat.FULL_TILBAKEBETALING248 }249 @Test250 fun `beregnBeløp skal beregne feilutbetaltBeløp når saksbehandler deler opp periode`() {251 val kravgrunnlag431 = Testdata.kravgrunnlag431252 val feilkravgrunnlagsbeløp = Testdata.feilKravgrunnlagsbeløp433253 val yteseskravgrunnlagsbeløp = Testdata.ytelKravgrunnlagsbeløp433254 val førsteKravgrunnlagsperiode = Testdata.kravgrunnlagsperiode432255 .copy(periode = Periode(YearMonth.of(2017, 1), YearMonth.of(2017, 1)),256 beløp = setOf(feilkravgrunnlagsbeløp.copy(id = UUID.randomUUID()),257 yteseskravgrunnlagsbeløp.copy(id = UUID.randomUUID())))258 val andreKravgrunnlagsperiode = Testdata.kravgrunnlagsperiode432259 .copy(id = UUID.randomUUID(),260 periode = Periode(YearMonth.of(2017, 2), YearMonth.of(2017, 2)),261 beløp = setOf(feilkravgrunnlagsbeløp.copy(id = UUID.randomUUID()),262 yteseskravgrunnlagsbeløp.copy(id = UUID.randomUUID())))263 kravgrunnlagRepository.insert(kravgrunnlag431.copy(perioder = setOf(førsteKravgrunnlagsperiode,264 andreKravgrunnlagsperiode)))265 val beregnetPerioderDto = tilbakekrevingsberegningService.beregnBeløp(behandlingId = Testdata.behandling.id,266 perioder = listOf(PeriodeDto(LocalDate.of(2017,267 1,268 1),269 LocalDate.of(2017,270 1,271 31)),272 PeriodeDto(LocalDate.of(2017,273 2,274 1),275 LocalDate.of(2017,276 2,277 28))))278 beregnetPerioderDto.beregnetPerioder.size shouldBe 2279 beregnetPerioderDto.beregnetPerioder[0].periode shouldBe PeriodeDto(LocalDate.of(2017, 1, 1), LocalDate.of(2017, 1, 31))280 beregnetPerioderDto.beregnetPerioder[0].feilutbetaltBeløp shouldBe BigDecimal("10000")281 beregnetPerioderDto.beregnetPerioder[1].periode shouldBe PeriodeDto(LocalDate.of(2017, 2, 1), LocalDate.of(2017, 2, 28))282 beregnetPerioderDto.beregnetPerioder[1].feilutbetaltBeløp shouldBe BigDecimal("10000")283 }284 @Test285 fun `beregnBeløp skal ikke beregne feilutbetaltBeløp når saksbehandler deler opp periode som ikke starter første dato`() {286 val exception = shouldThrow<RuntimeException> {287 tilbakekrevingsberegningService.beregnBeløp(behandlingId = Testdata.behandling.id,288 perioder = listOf(PeriodeDto(LocalDate.of(2017, 1, 1),289 LocalDate.of(2017, 1, 31)),290 PeriodeDto(LocalDate.of(2017, 2, 16),291 LocalDate.of(2017, 2, 28))))292 }293 exception.message shouldBe "Periode med ${294 PeriodeDto(LocalDate.of(2017, 2, 16),295 LocalDate.of(2017, 2, 28))296 } er ikke i hele måneder"297 }298 @Test299 fun `beregnBeløp skal ikke beregne feilutbetaltBeløp når saksbehandler deler opp periode som ikke slutter siste dato`() {300 val exception = shouldThrow<RuntimeException> {301 tilbakekrevingsberegningService.beregnBeløp(behandlingId = Testdata.behandling.id,302 perioder = listOf(PeriodeDto(LocalDate.of(2017, 1, 1),303 LocalDate.of(2017, 1, 27)),304 PeriodeDto(LocalDate.of(2017, 2, 1),305 LocalDate.of(2017, 2, 28))))306 }307 exception.message shouldBe "Periode med ${308 PeriodeDto(LocalDate.of(2017, 1, 1),309 LocalDate.of(2017, 1, 27))310 } er ikke i hele måneder"311 }312 private fun lagVilkårsvurderingMedForsett(behandlingId: UUID, vararg perioder: Periode) {313 val vurderingsperioder = perioder.map {314 Vilkårsvurderingsperiode(periode = Periode(it.fom, it.tom),315 begrunnelse = "foo",316 vilkårsvurderingsresultat = Vilkårsvurderingsresultat.FEIL_OPPLYSNINGER_FRA_BRUKER,317 aktsomhet = VilkårsvurderingAktsomhet(aktsomhet = Aktsomhet.FORSETT,318 begrunnelse = "foo"))319 }.toSet()320 val vurdering = Vilkårsvurdering(behandlingId = behandlingId,321 perioder = vurderingsperioder)322 vilkårsvurderingRepository.insert(vurdering)323 }324 private fun lagForeldelse(behandlingId: UUID,325 periode: Periode,326 resultat: Foreldelsesvurderingstype,327 foreldelsesFrist: LocalDate?) {328 val vurdertForeldelse =329 VurdertForeldelse(behandlingId = behandlingId,330 foreldelsesperioder = setOf(Foreldelsesperiode(periode = periode,331 begrunnelse = "foo",332 foreldelsesvurderingstype = resultat,333 foreldelsesfrist = foreldelsesFrist)))334 vurdertForeldelseRepository.insert(vurdertForeldelse)335 }336 private fun lagKravgrunnlag(periode: Periode, skattProsent: BigDecimal) {337 val p = Testdata.kravgrunnlagsperiode432.copy(id = UUID.randomUUID(),338 periode = periode,339 beløp = setOf(lagFeilBeløp(BigDecimal.valueOf(10000)),340 lagYtelBeløp(BigDecimal.valueOf(10000), skattProsent)))341 val grunnlag: Kravgrunnlag431 = Testdata.kravgrunnlag431.copy(perioder = setOf(p))342 kravgrunnlagRepository.insert(grunnlag)343 }344 private fun lagFeilBeløp(feilutbetaling: BigDecimal): Kravgrunnlagsbeløp433 {345 return Kravgrunnlagsbeløp433(klassekode = Klassekode.KL_KODE_FEIL_BA,346 klassetype = Klassetype.FEIL,347 nyttBeløp = feilutbetaling,348 opprinneligUtbetalingsbeløp = BigDecimal.ZERO,349 tilbakekrevesBeløp = BigDecimal.ZERO,350 uinnkrevdBeløp = BigDecimal.ZERO,351 skatteprosent = BigDecimal.ZERO)352 }353 private fun lagYtelBeløp(utbetalt: BigDecimal, skatteprosent: BigDecimal): Kravgrunnlagsbeløp433 {354 return Kravgrunnlagsbeløp433(klassekode = Klassekode.BATR,355 klassetype = Klassetype.YTEL,356 tilbakekrevesBeløp = BigDecimal("10000"),357 opprinneligUtbetalingsbeløp = utbetalt,358 nyttBeløp = BigDecimal.ZERO,359 skatteprosent = skatteprosent)360 }361 private fun lagYtelBeløp(utbetalt: BigDecimal,362 nyttBeløp: BigDecimal,363 skatteprosent: BigDecimal): Kravgrunnlagsbeløp433 {364 return Kravgrunnlagsbeløp433(klassekode = Klassekode.BATR,365 klassetype = Klassetype.YTEL,366 tilbakekrevesBeløp = BigDecimal("10000"),367 opprinneligUtbetalingsbeløp = utbetalt,368 nyttBeløp = nyttBeløp,369 skatteprosent = skatteprosent,370 skyldkode = UUID.randomUUID()371 .toString()) // brukte skyldkode for å få ulike Kravgrunnlagsbeløp433372 }373 private fun lagGrunnlagPeriode(periode: Periode,374 skattMnd: Int,375 beløp: Set<Kravgrunnlagsbeløp433> = setOf()): Kravgrunnlagsperiode432 {376 return Kravgrunnlagsperiode432(periode = periode,377 månedligSkattebeløp = BigDecimal.valueOf(skattMnd.toLong()),378 beløp = beløp)379 }380 private fun lagGrunnlag(perioder: Set<Kravgrunnlagsperiode432>): Kravgrunnlag431 {381 return Testdata.kravgrunnlag431.copy(perioder = perioder)382 }383}...

Full Screen

Full Screen

TilbakekrevingsberegningVilkårTest.kt

Source:TilbakekrevingsberegningVilkårTest.kt Github

copy

Full Screen

1package no.nav.familie.tilbake.beregning2import com.google.common.collect.Lists3import io.kotest.matchers.bigdecimal.shouldBeZero4import io.kotest.matchers.shouldBe5import no.nav.familie.tilbake.beregning.modell.Beregningsresultatsperiode6import no.nav.familie.tilbake.beregning.modell.FordeltKravgrunnlagsbeløp7import no.nav.familie.tilbake.beregning.modell.GrunnlagsperiodeMedSkatteprosent8import no.nav.familie.tilbake.common.Periode9import no.nav.familie.tilbake.vilkårsvurdering.domain.Aktsomhet10import no.nav.familie.tilbake.vilkårsvurdering.domain.AnnenVurdering11import no.nav.familie.tilbake.vilkårsvurdering.domain.VilkårsvurderingAktsomhet12import no.nav.familie.tilbake.vilkårsvurdering.domain.VilkårsvurderingGodTro13import no.nav.familie.tilbake.vilkårsvurdering.domain.Vilkårsvurderingsperiode14import no.nav.familie.tilbake.vilkårsvurdering.domain.Vilkårsvurderingsresultat15import org.junit.jupiter.api.BeforeEach16import org.junit.jupiter.api.Test17import java.math.BigDecimal18import java.time.LocalDate19class TilbakekrevingsberegningVilkårTest {20 private lateinit var vurdering: Vilkårsvurderingsperiode21 private lateinit var grunnlagsperiodeMedSkatteprosent: GrunnlagsperiodeMedSkatteprosent22 private lateinit var forstoBurdeForstattVurdering: Vilkårsvurderingsperiode23 @BeforeEach24 fun setup() {25 vurdering =26 Vilkårsvurderingsperiode(vilkårsvurderingsresultat = Vilkårsvurderingsresultat.FEIL_OPPLYSNINGER_FRA_BRUKER,27 periode = Periode(LocalDate.of(2019, 5, 1),28 LocalDate.of(2019, 5, 3)),29 begrunnelse = "foo")30 forstoBurdeForstattVurdering =31 Vilkårsvurderingsperiode(vilkårsvurderingsresultat = Vilkårsvurderingsresultat.FORSTO_BURDE_FORSTÅTT,32 periode = Periode(LocalDate.of(2019, 5, 1),33 LocalDate.of(2019, 5, 3)),34 begrunnelse = "foo")35 grunnlagsperiodeMedSkatteprosent =36 GrunnlagsperiodeMedSkatteprosent(vurdering.periode, BigDecimal.valueOf(10000), BigDecimal.ZERO)37 }38 @Test39 fun `beregn skal kreve tilbake alt med renter ved forsett og illeggRenter ikke satt`() {40 vurdering = vurdering.copy(aktsomhet = VilkårsvurderingAktsomhet(aktsomhet = Aktsomhet.FORSETT,41 begrunnelse = "foo"))42 //act43 val resultat: Beregningsresultatsperiode =44 beregn(vurdering, BigDecimal.valueOf(10000), Lists.newArrayList(grunnlagsperiodeMedSkatteprosent), true)45 //assert46 resultat.tilbakekrevingsbeløp shouldBe BigDecimal.valueOf(11000)47 resultat.tilbakekrevingsbeløpUtenRenter shouldBe BigDecimal.valueOf(10000)48 resultat.rentebeløp shouldBe BigDecimal.valueOf(1000)49 resultat.renteprosent shouldBe BigDecimal.valueOf(10)50 resultat.andelAvBeløp shouldBe BigDecimal.valueOf(100)51 resultat.feilutbetaltBeløp shouldBe BigDecimal.valueOf(10000)52 resultat.vurdering shouldBe Aktsomhet.FORSETT53 resultat.periode shouldBe Periode(LocalDate.of(2019, 5, 1), LocalDate.of(2019, 5, 3))54 resultat.manueltSattTilbakekrevingsbeløp shouldBe null55 }56 @Test57 fun `beregn skal kreve tilbake alt med renter ved forsett og illeggRenter satt true`() {58 forstoBurdeForstattVurdering =59 forstoBurdeForstattVurdering.copy(aktsomhet = VilkårsvurderingAktsomhet(aktsomhet = Aktsomhet.FORSETT,60 begrunnelse = "foo",61 ileggRenter = true))62 //act63 val resultat: Beregningsresultatsperiode = beregn(forstoBurdeForstattVurdering,64 BigDecimal.valueOf(10000),65 Lists.newArrayList(grunnlagsperiodeMedSkatteprosent),66 true)67 //assert68 resultat.tilbakekrevingsbeløp shouldBe BigDecimal.valueOf(11000)69 resultat.tilbakekrevingsbeløpUtenRenter shouldBe BigDecimal.valueOf(10000)70 resultat.rentebeløp shouldBe BigDecimal.valueOf(1000)71 resultat.renteprosent shouldBe BigDecimal.valueOf(10)72 resultat.andelAvBeløp shouldBe BigDecimal.valueOf(100)73 resultat.feilutbetaltBeløp shouldBe BigDecimal.valueOf(10000)74 resultat.vurdering shouldBe Aktsomhet.FORSETT75 resultat.periode shouldBe Periode(LocalDate.of(2019, 5, 1), LocalDate.of(2019, 5, 3))76 resultat.manueltSattTilbakekrevingsbeløp shouldBe null77 }78 @Test79 fun `beregn skalkreve tilbake alt uten renter ved forsett og illeggRenter satt false`() {80 forstoBurdeForstattVurdering =81 forstoBurdeForstattVurdering.copy(aktsomhet = VilkårsvurderingAktsomhet(aktsomhet = Aktsomhet.FORSETT,82 begrunnelse = "foo",83 ileggRenter = false))84 //act85 val resultat: Beregningsresultatsperiode = beregn(forstoBurdeForstattVurdering,86 BigDecimal.valueOf(10000),87 Lists.newArrayList(grunnlagsperiodeMedSkatteprosent),88 true)89 //assert90 resultat.tilbakekrevingsbeløp shouldBe BigDecimal.valueOf(10000)91 resultat.tilbakekrevingsbeløpUtenRenter shouldBe BigDecimal.valueOf(10000)92 resultat.rentebeløp shouldBe BigDecimal.valueOf(0)93 resultat.renteprosent shouldBe null94 resultat.andelAvBeløp shouldBe BigDecimal.valueOf(100)95 resultat.feilutbetaltBeløp shouldBe BigDecimal.valueOf(10000)96 resultat.vurdering shouldBe Aktsomhet.FORSETT97 resultat.periode shouldBe Periode(LocalDate.of(2019, 5, 1), LocalDate.of(2019, 5, 3))98 resultat.manueltSattTilbakekrevingsbeløp shouldBe null99 }100 @Test101 fun `beregn skalkreve tilbake alt ved grov uaktsomhet når ikke annet er valgt`() {102 vurdering = vurdering.copy(aktsomhet = VilkårsvurderingAktsomhet(aktsomhet = Aktsomhet.GROV_UAKTSOMHET,103 begrunnelse = "foo",104 særligeGrunnerTilReduksjon = false,105 ileggRenter = true))106 //assert107 val resultat: Beregningsresultatsperiode =108 beregn(vurdering, BigDecimal.valueOf(10000), Lists.newArrayList(grunnlagsperiodeMedSkatteprosent), true)109 resultat.tilbakekrevingsbeløp shouldBe BigDecimal.valueOf(11000)110 resultat.renteprosent shouldBe BigDecimal.valueOf(10)111 resultat.vurdering shouldBe Aktsomhet.GROV_UAKTSOMHET112 }113 @Test114 fun `beregn skalikke kreve noe når sjette ledd benyttes for å ikke gjøre innkreving av småbeløp`() {115 vurdering = vurdering.copy(aktsomhet = VilkårsvurderingAktsomhet(aktsomhet = Aktsomhet.SIMPEL_UAKTSOMHET,116 begrunnelse = "foo",117 særligeGrunnerTilReduksjon = false,118 tilbakekrevSmåbeløp = false))119 //assert120 val resultat: Beregningsresultatsperiode =121 beregn(vurdering, BigDecimal.valueOf(522), Lists.newArrayList(grunnlagsperiodeMedSkatteprosent), true)122 resultat.tilbakekrevingsbeløp shouldBe BigDecimal.ZERO123 resultat.vurdering shouldBe Aktsomhet.SIMPEL_UAKTSOMHET124 }125 @Test126 fun `beregn skalkreve tilbake deler ved grov uaktsomhet når særlige grunner er valgt og ilegge renter når det er valgt`() {127 vurdering = vurdering.copy(aktsomhet = VilkårsvurderingAktsomhet(aktsomhet = Aktsomhet.GROV_UAKTSOMHET,128 begrunnelse = "foo",129 særligeGrunnerTilReduksjon = true,130 ileggRenter = true,131 andelTilbakekreves = BigDecimal.valueOf(70)))132 //assert133 val resultat: Beregningsresultatsperiode =134 beregn(vurdering, BigDecimal.valueOf(10000), Lists.newArrayList(grunnlagsperiodeMedSkatteprosent), true)135 resultat.tilbakekrevingsbeløp shouldBe BigDecimal.valueOf(7700)136 resultat.renteprosent shouldBe BigDecimal.valueOf(10)137 }138 @Test139 fun `beregn skal kreve tilbake deler ved grov uaktsomhet ved når særlige grunner og ikke ilegge renter når det er false`() {140 vurdering = vurdering.copy(aktsomhet = VilkårsvurderingAktsomhet(aktsomhet = Aktsomhet.GROV_UAKTSOMHET,141 begrunnelse = "foo",142 særligeGrunnerTilReduksjon = true,143 ileggRenter = false,144 andelTilbakekreves = BigDecimal.valueOf(70)))145 //assert146 val resultat: Beregningsresultatsperiode =147 beregn(vurdering, BigDecimal.valueOf(10000), Lists.newArrayList(grunnlagsperiodeMedSkatteprosent), true)148 resultat.tilbakekrevingsbeløp shouldBe BigDecimal.valueOf(7000)149 resultat.renteprosent shouldBe null150 resultat.rentebeløp.shouldBeZero()151 }152 @Test153 fun `beregn skaltakle desimaler på prosenter som tilbakekreves`() {154 vurdering = vurdering.copy(aktsomhet = VilkårsvurderingAktsomhet(aktsomhet = Aktsomhet.GROV_UAKTSOMHET,155 begrunnelse = "foo",156 særligeGrunnerTilReduksjon = true,157 ileggRenter = false,158 andelTilbakekreves = BigDecimal("0.01")))159 //assert160 val resultat: Beregningsresultatsperiode =161 beregn(vurdering, BigDecimal.valueOf(70000), Lists.newArrayList(grunnlagsperiodeMedSkatteprosent), true)162 resultat.tilbakekrevingsbeløp shouldBe BigDecimal.valueOf(7)163 resultat.renteprosent shouldBe null164 resultat.rentebeløp.shouldBeZero()165 }166 @Test167 fun `beregn skalkreve tilbake manuelt beløp når det er satt`() {168 vurdering = vurdering.copy(aktsomhet = VilkårsvurderingAktsomhet(aktsomhet = Aktsomhet.GROV_UAKTSOMHET,169 begrunnelse = "foo",170 særligeGrunnerTilReduksjon = true,171 ileggRenter = false,172 manueltSattBeløp = BigDecimal.valueOf(6556)))173 //assert174 val resultat: Beregningsresultatsperiode =175 beregn(vurdering, BigDecimal.valueOf(10000), Lists.newArrayList(grunnlagsperiodeMedSkatteprosent), true)176 resultat.tilbakekrevingsbeløp shouldBe BigDecimal.valueOf(6556)177 resultat.renteprosent shouldBe null178 }179 @Test180 fun `beregn skalkreve tilbake manuelt beløp med renter når det er satt`() {181 vurdering = vurdering.copy(aktsomhet = VilkårsvurderingAktsomhet(aktsomhet = Aktsomhet.GROV_UAKTSOMHET,182 begrunnelse = "foo",183 særligeGrunnerTilReduksjon = true,184 ileggRenter = true,185 manueltSattBeløp = BigDecimal.valueOf(6000)))186 //assert187 val resultat: Beregningsresultatsperiode =188 beregn(vurdering, BigDecimal.valueOf(10000), Lists.newArrayList(grunnlagsperiodeMedSkatteprosent), true)189 resultat.tilbakekrevingsbeløp shouldBe BigDecimal.valueOf(6600)190 resultat.renteprosent shouldBe BigDecimal.valueOf(10)191 }192 @Test193 fun `beregn skalkreve tilbake beløp som er i_behold uten renter ved god tro`() {194 vurdering = vurdering.copy(godTro = VilkårsvurderingGodTro(beløpErIBehold = true,195 beløpTilbakekreves = BigDecimal.valueOf(8991),196 begrunnelse = "foo"))197 //assert198 val resultat: Beregningsresultatsperiode =199 beregn(vurdering, BigDecimal.valueOf(10000), Lists.newArrayList(grunnlagsperiodeMedSkatteprosent), true)200 resultat.tilbakekrevingsbeløp shouldBe BigDecimal.valueOf(8991)201 resultat.renteprosent shouldBe null202 resultat.andelAvBeløp shouldBe null203 resultat.vurdering shouldBe AnnenVurdering.GOD_TRO204 resultat.manueltSattTilbakekrevingsbeløp shouldBe BigDecimal.valueOf(8991)205 }206 @Test207 fun `beregn skalkreve tilbake ingenting når det er god tro og beløp ikke er i_behold`() {208 vurdering = vurdering.copy(godTro = VilkårsvurderingGodTro(beløpErIBehold = false,209 begrunnelse = "foo"))210 //assert211 val resultat: Beregningsresultatsperiode =212 beregn(vurdering, BigDecimal.valueOf(10000), Lists.newArrayList(grunnlagsperiodeMedSkatteprosent), true)213 resultat.tilbakekrevingsbeløp shouldBe BigDecimal.ZERO214 resultat.renteprosent shouldBe null215 resultat.andelAvBeløp!!.shouldBeZero()216 resultat.vurdering shouldBe AnnenVurdering.GOD_TRO217 resultat.manueltSattTilbakekrevingsbeløp shouldBe null218 }219 @Test220 fun `beregn skalkreve tilbake beløp som er i_behold uten renter ved god tro med skatt prosent`() {221 vurdering = vurdering.copy(godTro = VilkårsvurderingGodTro(beløpErIBehold = true,222 beløpTilbakekreves = BigDecimal.valueOf(8991),223 begrunnelse = "foo"))224 val grunnlagPeriodeMedSkattProsent =225 GrunnlagsperiodeMedSkatteprosent(vurdering.periode, BigDecimal.valueOf(10000), BigDecimal.valueOf(10))226 //assert227 val resultat: Beregningsresultatsperiode =228 beregn(vurdering, BigDecimal.valueOf(10000), Lists.newArrayList(grunnlagPeriodeMedSkattProsent), true)229 resultat.tilbakekrevingsbeløp shouldBe BigDecimal.valueOf(8991)230 resultat.renteprosent shouldBe null231 resultat.andelAvBeløp shouldBe null232 resultat.vurdering shouldBe AnnenVurdering.GOD_TRO233 resultat.manueltSattTilbakekrevingsbeløp shouldBe BigDecimal.valueOf(8991)234 resultat.skattebeløp shouldBe BigDecimal.valueOf(899)235 resultat.tilbakekrevingsbeløpEtterSkatt shouldBe BigDecimal.valueOf(8092)236 }237 @Test238 fun `beregn skalkreve tilbake alt med renter ved forsett med skatt prosent`() {239 vurdering = vurdering.copy(aktsomhet = VilkårsvurderingAktsomhet(aktsomhet = Aktsomhet.FORSETT,240 begrunnelse = "foo"))241 val grunnlagPeriodeMedSkattProsent =242 GrunnlagsperiodeMedSkatteprosent(vurdering.periode, BigDecimal.valueOf(10000), BigDecimal.valueOf(10))243 //act244 val resultat: Beregningsresultatsperiode =245 beregn(vurdering, BigDecimal.valueOf(10000), Lists.newArrayList(grunnlagPeriodeMedSkattProsent), true)246 //assert247 resultat.tilbakekrevingsbeløp shouldBe BigDecimal.valueOf(11000)248 resultat.tilbakekrevingsbeløpUtenRenter shouldBe BigDecimal.valueOf(10000)249 resultat.rentebeløp shouldBe BigDecimal.valueOf(1000)250 resultat.renteprosent shouldBe BigDecimal.valueOf(10)251 resultat.andelAvBeløp shouldBe BigDecimal.valueOf(100)252 resultat.feilutbetaltBeløp shouldBe BigDecimal.valueOf(10000)253 resultat.vurdering shouldBe Aktsomhet.FORSETT254 resultat.periode shouldBe Periode(LocalDate.of(2019, 5, 1), LocalDate.of(2019, 5, 3))255 resultat.manueltSattTilbakekrevingsbeløp shouldBe null256 resultat.skattebeløp shouldBe BigDecimal.valueOf(1000)257 resultat.tilbakekrevingsbeløpEtterSkatt shouldBe BigDecimal.valueOf(10000)258 }259 @Test260 fun `beregn skalkreve tilbake alt uten renter ved forsett men frisinn med skatt prosent`() {261 vurdering = vurdering.copy(aktsomhet = VilkårsvurderingAktsomhet(aktsomhet = Aktsomhet.FORSETT,262 begrunnelse = "foo"))263 val grunnlagPeriodeMedSkattProsent =264 GrunnlagsperiodeMedSkatteprosent(vurdering.periode, BigDecimal.valueOf(10000), BigDecimal.valueOf(10))265 //act266 val resultat: Beregningsresultatsperiode =267 beregn(vurdering, BigDecimal.valueOf(10000), Lists.newArrayList(grunnlagPeriodeMedSkattProsent), false)268 //assert269 resultat.tilbakekrevingsbeløp shouldBe BigDecimal.valueOf(10000)270 resultat.tilbakekrevingsbeløpUtenRenter shouldBe BigDecimal.valueOf(10000)271 resultat.rentebeløp shouldBe BigDecimal.valueOf(0)272 resultat.renteprosent shouldBe null273 resultat.andelAvBeløp shouldBe BigDecimal.valueOf(100)274 resultat.feilutbetaltBeløp shouldBe BigDecimal.valueOf(10000)275 resultat.vurdering shouldBe Aktsomhet.FORSETT276 resultat.periode shouldBe Periode(LocalDate.of(2019, 5, 1), LocalDate.of(2019, 5, 3))277 resultat.manueltSattTilbakekrevingsbeløp shouldBe null278 resultat.skattebeløp shouldBe BigDecimal.valueOf(1000)279 resultat.tilbakekrevingsbeløpEtterSkatt shouldBe BigDecimal.valueOf(9000)280 }281 private fun beregn(vilkårVurdering: Vilkårsvurderingsperiode,282 feilutbetalt: BigDecimal,283 perioderMedSkatteprosent: List<GrunnlagsperiodeMedSkatteprosent>,284 beregnRenter: Boolean): Beregningsresultatsperiode {285 val delresultat = FordeltKravgrunnlagsbeløp(feilutbetalt, feilutbetalt, BigDecimal.ZERO)286 return TilbakekrevingsberegningVilkår.beregn(vilkårVurdering, delresultat, perioderMedSkatteprosent, beregnRenter)287 }288}...

Full Screen

Full Screen

BigDecimalMatchersTest.kt

Source:BigDecimalMatchersTest.kt Github

copy

Full Screen

1package com.sksamuel.kotest.matchers.bigdecimal2import io.kotest.matchers.bigdecimal.shouldBeGreaterThan3import io.kotest.matchers.bigdecimal.shouldBeGreaterThanOrEquals4import io.kotest.matchers.bigdecimal.shouldBeInRange5import io.kotest.matchers.bigdecimal.shouldBeLessThan6import io.kotest.matchers.bigdecimal.shouldBeLessThanOrEquals7import io.kotest.matchers.bigdecimal.shouldBeNegative8import io.kotest.matchers.bigdecimal.shouldBePositive9import io.kotest.matchers.bigdecimal.shouldBeZero10import io.kotest.matchers.bigdecimal.shouldHavePrecision11import io.kotest.matchers.bigdecimal.shouldHaveScale12import io.kotest.matchers.bigdecimal.shouldNotBeGreaterThan13import io.kotest.matchers.bigdecimal.shouldNotBeGreaterThanOrEquals14import io.kotest.matchers.bigdecimal.shouldNotBeInRange15import io.kotest.matchers.bigdecimal.shouldNotBeLessThan16import io.kotest.matchers.bigdecimal.shouldNotBeLessThanOrEquals17import io.kotest.matchers.bigdecimal.shouldNotHaveScale18import io.kotest.core.spec.style.StringSpec19import java.math.BigDecimal20class BigDecimalMatchersTest : StringSpec() {21 init {22 "shouldBeZero" {23 BigDecimal.ZERO.shouldBeZero()24 BigDecimal(0).shouldBeZero()25 0.toBigDecimal().shouldBeZero()26 }27 "shouldHavePrecision" {28 BigDecimal(10).setScale(3) shouldHavePrecision 529 BigDecimal(10.1) shouldHavePrecision 5130 10.1.toBigDecimal() shouldHavePrecision 331 BigDecimal.ZERO shouldHavePrecision 132 }33 "shouldHaveScale" {34 BigDecimal(10).setScale(3) shouldHaveScale 335 BigDecimal(10.1) shouldHaveScale 4936 10.444.toBigDecimal() shouldHaveScale 337 0.toBigDecimal() shouldHaveScale 038 BigDecimal.ZERO shouldHaveScale 039 BigDecimal(10).setScale(3) shouldNotHaveScale 140 BigDecimal(10.1) shouldNotHaveScale 541 10.444.toBigDecimal() shouldNotHaveScale 242 0.toBigDecimal() shouldNotHaveScale 143 BigDecimal.ZERO shouldNotHaveScale 244 }45 "shouldBePositive" {46 BigDecimal(10).shouldBePositive()47 BigDecimal.ZERO.shouldBePositive()48 BigDecimal(0.1).shouldBePositive()49 0.1.toBigDecimal().shouldBePositive()50 }51 "shouldBeNegative" {52 BigDecimal(-1).shouldBeNegative()53 (-1).toBigDecimal().shouldBeNegative()54 BigDecimal(-0.1).shouldBeNegative()55 BigDecimal(1).minus(BigDecimal(2)).shouldBeNegative()56 }57 "shouldBeGreaterThan" {58 BigDecimal.ONE shouldBeGreaterThan BigDecimal.ZERO59 BigDecimal.TEN shouldBeGreaterThan BigDecimal.ONE60 BigDecimal.ONE shouldNotBeGreaterThan BigDecimal.ONE61 BigDecimal.ONE shouldNotBeGreaterThan BigDecimal.TEN62 BigDecimal.TEN shouldNotBeGreaterThan BigDecimal.TEN63 }64 "shouldBeGreaterThanOrEquals" {65 BigDecimal.ONE shouldBeGreaterThanOrEquals BigDecimal.ZERO66 BigDecimal.ONE shouldBeGreaterThanOrEquals BigDecimal.ONE67 BigDecimal.TEN shouldBeGreaterThanOrEquals BigDecimal.ONE68 BigDecimal.TEN shouldBeGreaterThanOrEquals BigDecimal.TEN69 BigDecimal.ONE shouldNotBeGreaterThanOrEquals BigDecimal.TEN70 BigDecimal.ZERO shouldNotBeGreaterThanOrEquals BigDecimal.ONE71 }72 "shouldBeLessThan" {73 BigDecimal.ZERO shouldBeLessThan BigDecimal.ONE74 BigDecimal.ONE shouldBeLessThan BigDecimal.TEN75 BigDecimal.ONE shouldNotBeLessThan BigDecimal.ONE76 BigDecimal.TEN shouldNotBeLessThan BigDecimal.ONE77 BigDecimal.TEN shouldNotBeLessThan BigDecimal.TEN78 }79 "shouldBeLessThanOrEquals" {80 BigDecimal.ZERO shouldBeLessThanOrEquals BigDecimal.ONE81 BigDecimal.ONE shouldBeLessThanOrEquals BigDecimal.ONE82 BigDecimal.ONE shouldBeLessThanOrEquals BigDecimal.TEN83 BigDecimal.TEN shouldBeLessThanOrEquals BigDecimal.TEN84 BigDecimal.TEN shouldNotBeLessThanOrEquals BigDecimal.ONE85 BigDecimal.ONE shouldNotBeLessThanOrEquals BigDecimal.ZERO86 }87 "shouldBeInRange" {88 BigDecimal.ZERO shouldBeInRange BigDecimal(-1) .. BigDecimal(1)89 BigDecimal.ONE shouldBeInRange BigDecimal(-1) .. BigDecimal(1)90 (-BigDecimal.ONE) shouldBeInRange BigDecimal(-1) .. BigDecimal(1)91 BigDecimal.TEN shouldNotBeInRange BigDecimal(-1) .. BigDecimal(1)92 }93 }94}...

Full Screen

Full Screen

matchers.kt

Source:matchers.kt Github

copy

Full Screen

1package io.kotest.matchers.bigdecimal2import io.kotest.matchers.comparables.gt3import io.kotest.matchers.comparables.gte4import io.kotest.matchers.comparables.lt5import io.kotest.matchers.comparables.lte6import io.kotest.matchers.Matcher7import io.kotest.matchers.MatcherResult8import io.kotest.matchers.should9import io.kotest.matchers.shouldBe10import io.kotest.matchers.shouldNot11import io.kotest.matchers.shouldNotBe12import java.math.BigDecimal13fun BigDecimal.shouldBeZero() = this shouldBe BigDecimal.ZERO14fun BigDecimal.shouldBePositive() = this shouldBe gte(BigDecimal.ZERO)15fun BigDecimal.shouldBeNegative() = this shouldBe lt(BigDecimal.ZERO)16infix fun BigDecimal.shouldHavePrecision(precision: Int) = this.precision() shouldBe precision17infix fun BigDecimal.shouldHaveScale(scale: Int) = this.scale() shouldBe scale18infix fun BigDecimal.shouldNotHaveScale(scale: Int) = this.scale() shouldNotBe scale19infix fun BigDecimal.shouldBeLessThan(other: BigDecimal) = this shouldBe lt(other)20infix fun BigDecimal.shouldBeLessThanOrEquals(other: BigDecimal) = this shouldBe lte(other)21infix fun BigDecimal.shouldNotBeLessThan(other: BigDecimal) = this shouldNotBe lt(other)22infix fun BigDecimal.shouldNotBeLessThanOrEquals(other: BigDecimal) = this shouldNotBe lte(other)23infix fun BigDecimal.shouldBeGreaterThan(other: BigDecimal) = this shouldBe gt(other)24infix fun BigDecimal.shouldBeGreaterThanOrEquals(other: BigDecimal) = this shouldBe gte(other)25infix fun BigDecimal.shouldNotBeGreaterThan(other: BigDecimal) = this shouldNotBe gt(other)26infix fun BigDecimal.shouldNotBeGreaterThanOrEquals(other: BigDecimal) = this shouldNotBe gte(other)27infix fun BigDecimal.shouldBeInRange(range: ClosedRange<BigDecimal>) = this should beInClosedRange(range)28infix fun BigDecimal.shouldNotBeInRange(range: ClosedRange<BigDecimal>) = this shouldNot beInClosedRange(range)29fun beInClosedRange(range: ClosedRange<BigDecimal>) = object : Matcher<BigDecimal> {30 override fun test(value: BigDecimal) = MatcherResult(31 range.contains(value),32 { "Value $value should be in range from ${range.start} to ${range.endInclusive} (Inclusive)" },33 {34 "Value $value should not be in range from ${range.start} to ${range.endInclusive} (Inclusive)"35 })36}...

Full Screen

Full Screen

BigDecimal.shouldBeZero

Using AI Code Generation

copy

Full Screen

1 import io.kotest.matchers.bigdecimal.matchers.shouldBeZero2 import io.kotest.matchers.bigdecimal.matchers.shouldBePositive3 import io.kotest.matchers.bigdecimal.matchers.shouldBeNegative4 import io.kotest.matchers.bigdecimal.matchers.shouldBeNonNegative5 import io.kotest.matchers.bigdecimal.matchers.shouldBeNonPositive6 import io.kotest.matchers.bigdecimal.matchers.shouldBeInRange7 import io.kotest.matchers.bigdecimal.matchers.shouldBeLessThan8 import io.kotest.matchers.bigdecimal.matchers.shouldBeGreaterThan9 import io.kotest.matchers.bigdecimal.matchers.shouldBeLessThanOrEqual10 import io.kotest.matchers.bigdecimal.matchers.shouldBeGreaterThanOrEqual11 import io.kotest.matchers.bigdecimal.matchers.shouldBeEqualIncludingScale12 import io.kotest.matchers.bigdecimal.matchers.shouldBeEqualComparingOnlyScale

Full Screen

Full Screen

BigDecimal.shouldBeZero

Using AI Code Generation

copy

Full Screen

1@DisplayName("BigDecimal.shouldBeZero method")2inner class BigDecimalShouldBeZeroTest {3fun `should pass when BigDecimal is zero`() {4BigDecimal.ZERO.shouldBeZero()5}6fun `should fail when BigDecimal is not zero`() {7shouldThrow<AssertionError> {8BigDecimal.ONE.shouldBeZero()9}10}11}12}13@DisplayName("BigDecimal.shouldBePositive method")14inner class BigDecimalShouldBePositiveTest {15fun `should pass when BigDecimal is positive`() {16BigDecimal.ONE.shouldBePositive()17}18fun `should fail when BigDecimal is not positive`() {19shouldThrow<AssertionError> {20BigDecimal.ZERO.shouldBePositive()21}22}23}24@DisplayName("BigDecimal.shouldBeNegative method")25inner class BigDecimalShouldBeNegativeTest {26fun `should pass when BigDecimal is negative`() {27BigDecimal.ONE.negate().shouldBeNegative()28}29fun `should fail when BigDecimal is not negative`() {30shouldThrow<AssertionError> {31BigDecimal.ZERO.shouldBeNegative()32}33}34}35@DisplayName("BigDecimal.shouldBeNonPositive method")36inner class BigDecimalShouldBeNonPositiveTest {37fun `should pass when BigDecimal is non-positive`() {38BigDecimal.ZERO.shouldBeNonPositive()39}40fun `should fail when BigDecimal is not non-positive`() {41shouldThrow<AssertionError> {42BigDecimal.ONE.shouldBeNonPositive()43}44}45}46@DisplayName("BigDecimal.shouldBeNonNegative method")47inner class BigDecimalShouldBeNonNegativeTest {48fun `should pass when BigDecimal is non-negative`() {49BigDecimal.ZERO.shouldBeNonNegative()50}51fun `should fail when BigDecimal is not non-negative`() {52shouldThrow<AssertionError> {53BigDecimal.ONE.negate().shouldBeNonNegative()54}55}56}57}58@DisplayName("BigDecimal.shouldBeGreaterThan method")59inner class BigDecimalShouldBeGreaterThanTest {

Full Screen

Full Screen

BigDecimal.shouldBeZero

Using AI Code Generation

copy

Full Screen

1class BigDecimalMatchersTest : FunSpec() {2override fun isInstancePerTest() = true3init {4test("BigDecimal.shouldBeZero") {5BigDecimal.ZERO.shouldBeZero()6BigDecimal("0.0").shouldBeZero()7BigDecimal("0.00").shouldBeZero()8BigDecimal("0.000").shouldBeZero()9}10test("BigDecimal.shouldNotBeZero") {11BigDecimal("1.0").shouldNotBeZero()12BigDecimal("1.0

Full Screen

Full Screen

BigDecimal.shouldBeZero

Using AI Code Generation

copy

Full Screen

1@DisplayName ( "BigDecimal shouldBeZero" ) fun ` BigDecimal shouldBeZero` () { 1.0 . shouldBeZero () }2@DisplayName ( "BigDecimal shouldBeNonZero" ) fun ` BigDecimal shouldBeNonZero` () { 1.0 . shouldBeNonZero () }3@DisplayName ( "BigDecimal shouldBeGreaterThan" ) fun ` BigDecimal shouldBeGreaterThan` () { 1.0 . shouldBeGreaterThan ( 0.0 ) }4@DisplayName ( "BigDecimal shouldBeGreaterThanOrEqual" ) fun ` BigDecimal shouldBeGreaterThanOrEqual` () { 1.0 . shouldBeGreaterThanOrEqual ( 0.0 ) }5@DisplayName ( "BigDecimal shouldBeLessThan" ) fun ` BigDecimal shouldBeLessThan` () { 1.0 . shouldBeLessThan ( 2.0 ) }6@DisplayName ( "BigDecimal shouldBeLessThanOrEqual" ) fun ` BigDecimal shouldBeLessThanOrEqual` () { 1.0 . shouldBeLessThanOrEqual ( 2.0 ) }7@DisplayName ( "BigDecimal shouldBeBetween" ) fun ` BigDecimal shouldBeBetween` () { 1.0 . shouldBeBetween ( 0.0 , 2.0 ) }8@DisplayName ( "BigDecimal shouldNotBeBetween" ) fun ` BigDecimal shouldNotBeBetween` () { 1.0 . shouldNotBeBetween ( 2.0 , 3.0 ) }9@DisplayName ( "BigDecimal shouldBePositive" ) fun ` BigDecimal shouldBePositive` () { 1.0 . shouldBePositive () }

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Kotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful