Skip to content

Commit

Permalink
ikke prøv å avslutte behandling som allerede er avsluttet (#1594)
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikpf authored Jan 10, 2025
1 parent dbb38c2 commit f8d69c3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ class AvsluttBehandlingTask(
val behandlingId = UUID.fromString(task.payload)

var behandling = behandlingRepository.findByIdOrThrow(behandlingId)
if (behandling.status == Behandlingsstatus.AVSLUTTET) {
log.info("Behandling er allerede avsluttet")
return
}

if (!behandling.erUnderIverksettelse) {
throw Feil(message = "Behandling med id=$behandlingId kan ikke avsluttes")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import no.nav.familie.tilbake.historikkinnslag.TilbakekrevingHistorikkinnslagsty
import no.nav.familie.tilbake.iverksettvedtak.task.AvsluttBehandlingTask
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertDoesNotThrow
import org.springframework.beans.factory.annotation.Autowired
import java.util.UUID

Expand Down Expand Up @@ -84,4 +85,14 @@ internal class AvsluttBehandlingTaskTest : OppslagSpringRunnerTest() {
taskProperty["aktør"] shouldBe Aktør.VEDTAKSLØSNING.name
taskProperty["historikkinnslagstype"] shouldBe TilbakekrevingHistorikkinnslagstype.BEHANDLING_AVSLUTTET.name
}

@Test
fun `doTask skal ikke avslutte en behandling som allerede er avsluttet`() {
// Arrange
val behandling = behandlingRepository.findByIdOrThrow(behandlingId)
behandlingRepository.update(behandling.copy(status = Behandlingsstatus.AVSLUTTET))

// Act and assert
assertDoesNotThrow { avsluttBehandlingTask.doTask(Task(type = AvsluttBehandlingTask.TYPE, payload = behandlingId.toString())) }
}
}

0 comments on commit f8d69c3

Please sign in to comment.