Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ikke prøv å avslutte behandling som allerede er avsluttet #1594

Merged
merged 2 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
@@ -1,6 +1,9 @@
package no.nav.familie.tilbake.iverksettvedtak

import ch.qos.logback.classic.spi.ILoggingEvent
import ch.qos.logback.core.read.ListAppender
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blir disse lenger brukt?
Ser at de er lagt til, men ikke brukt i denne filen :D

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skulle ikke vært med, fjernet de nå:)

import io.kotest.matchers.shouldBe
import io.kotest.mpp.log
import no.nav.familie.prosessering.domene.Status
import no.nav.familie.prosessering.domene.Task
import no.nav.familie.prosessering.internal.TaskService
Expand All @@ -22,6 +25,8 @@ 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.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
import java.util.UUID

Expand Down Expand Up @@ -84,4 +89,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())) }
}
}
Loading